@vidispine/vdt-react 0.15.0-pre.7 → 21.4.0-pre.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/dist/index.es.js +849 -64
- package/dist/index.es.js.map +1 -1
- package/dist/index.js +852 -61
- package/dist/index.js.map +1 -1
- package/package.json +10 -8
package/dist/index.es.js
CHANGED
|
@@ -1,9 +1,49 @@
|
|
|
1
1
|
import React, { useCallback } from 'react';
|
|
2
|
-
import { utils, search, vsimport, collection, ChunkedUpload, access, metadatafield, fieldgroup, item, library, user, group, job, metadata, noauth } from '@vidispine/vdt-api';
|
|
3
|
-
import { createMetadataType, parseMetadataType, roles } from '@vidispine/vdt-js';
|
|
2
|
+
import { utils, search, vsimport, collection, ChunkedUpload, access, metadatafield, fieldgroup, item, library, user, group, storage, job, file, metadata, noauth } from '@vidispine/vdt-api';
|
|
3
|
+
import { createMetadataType, formatTimeCodeText, formatSeconds, parseMetadataType, roles } from '@vidispine/vdt-js';
|
|
4
|
+
import { decompressFromEncodedURIComponent, compressToEncodedURIComponent } from 'lz-string';
|
|
4
5
|
import useDeepCompareEffect from 'use-deep-compare-effect';
|
|
6
|
+
import debounce from 'lodash.debounce';
|
|
5
7
|
import { useCookies } from 'react-cookie';
|
|
6
8
|
|
|
9
|
+
function ownKeys(object, enumerableOnly) {
|
|
10
|
+
var keys = Object.keys(object);
|
|
11
|
+
|
|
12
|
+
if (Object.getOwnPropertySymbols) {
|
|
13
|
+
var symbols = Object.getOwnPropertySymbols(object);
|
|
14
|
+
|
|
15
|
+
if (enumerableOnly) {
|
|
16
|
+
symbols = symbols.filter(function (sym) {
|
|
17
|
+
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
keys.push.apply(keys, symbols);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
return keys;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
function _objectSpread2(target) {
|
|
28
|
+
for (var i = 1; i < arguments.length; i++) {
|
|
29
|
+
var source = arguments[i] != null ? arguments[i] : {};
|
|
30
|
+
|
|
31
|
+
if (i % 2) {
|
|
32
|
+
ownKeys(Object(source), true).forEach(function (key) {
|
|
33
|
+
_defineProperty(target, key, source[key]);
|
|
34
|
+
});
|
|
35
|
+
} else if (Object.getOwnPropertyDescriptors) {
|
|
36
|
+
Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
|
|
37
|
+
} else {
|
|
38
|
+
ownKeys(Object(source)).forEach(function (key) {
|
|
39
|
+
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
return target;
|
|
45
|
+
}
|
|
46
|
+
|
|
7
47
|
function _typeof(obj) {
|
|
8
48
|
"@babel/helpers - typeof";
|
|
9
49
|
|
|
@@ -111,40 +151,6 @@ function _extends() {
|
|
|
111
151
|
return _extends.apply(this, arguments);
|
|
112
152
|
}
|
|
113
153
|
|
|
114
|
-
function ownKeys(object, enumerableOnly) {
|
|
115
|
-
var keys = Object.keys(object);
|
|
116
|
-
|
|
117
|
-
if (Object.getOwnPropertySymbols) {
|
|
118
|
-
var symbols = Object.getOwnPropertySymbols(object);
|
|
119
|
-
if (enumerableOnly) symbols = symbols.filter(function (sym) {
|
|
120
|
-
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
|
|
121
|
-
});
|
|
122
|
-
keys.push.apply(keys, symbols);
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
return keys;
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
function _objectSpread2(target) {
|
|
129
|
-
for (var i = 1; i < arguments.length; i++) {
|
|
130
|
-
var source = arguments[i] != null ? arguments[i] : {};
|
|
131
|
-
|
|
132
|
-
if (i % 2) {
|
|
133
|
-
ownKeys(Object(source), true).forEach(function (key) {
|
|
134
|
-
_defineProperty(target, key, source[key]);
|
|
135
|
-
});
|
|
136
|
-
} else if (Object.getOwnPropertyDescriptors) {
|
|
137
|
-
Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
|
|
138
|
-
} else {
|
|
139
|
-
ownKeys(Object(source)).forEach(function (key) {
|
|
140
|
-
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
|
141
|
-
});
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
return target;
|
|
146
|
-
}
|
|
147
|
-
|
|
148
154
|
function _inherits(subClass, superClass) {
|
|
149
155
|
if (typeof superClass !== "function" && superClass !== null) {
|
|
150
156
|
throw new TypeError("Super expression must either be null or a function");
|
|
@@ -182,7 +188,7 @@ function _isNativeReflectConstruct() {
|
|
|
182
188
|
if (typeof Proxy === "function") return true;
|
|
183
189
|
|
|
184
190
|
try {
|
|
185
|
-
|
|
191
|
+
Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));
|
|
186
192
|
return true;
|
|
187
193
|
} catch (e) {
|
|
188
194
|
return false;
|
|
@@ -236,6 +242,8 @@ function _assertThisInitialized(self) {
|
|
|
236
242
|
function _possibleConstructorReturn(self, call) {
|
|
237
243
|
if (call && (typeof call === "object" || typeof call === "function")) {
|
|
238
244
|
return call;
|
|
245
|
+
} else if (call !== void 0) {
|
|
246
|
+
throw new TypeError("Derived constructors may only return object or undefined");
|
|
239
247
|
}
|
|
240
248
|
|
|
241
249
|
return _assertThisInitialized(self);
|
|
@@ -277,18 +285,21 @@ function _arrayWithHoles(arr) {
|
|
|
277
285
|
}
|
|
278
286
|
|
|
279
287
|
function _iterableToArray(iter) {
|
|
280
|
-
if (typeof Symbol !== "undefined" && Symbol.iterator
|
|
288
|
+
if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
|
|
281
289
|
}
|
|
282
290
|
|
|
283
291
|
function _iterableToArrayLimit(arr, i) {
|
|
284
|
-
|
|
292
|
+
var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
|
|
293
|
+
|
|
294
|
+
if (_i == null) return;
|
|
285
295
|
var _arr = [];
|
|
286
296
|
var _n = true;
|
|
287
297
|
var _d = false;
|
|
288
|
-
|
|
298
|
+
|
|
299
|
+
var _s, _e;
|
|
289
300
|
|
|
290
301
|
try {
|
|
291
|
-
for (
|
|
302
|
+
for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) {
|
|
292
303
|
_arr.push(_s.value);
|
|
293
304
|
|
|
294
305
|
if (i && _arr.length === i) break;
|
|
@@ -470,6 +481,7 @@ function useApi(apiHandler, initialState, responseRef) {
|
|
|
470
481
|
}, state);
|
|
471
482
|
}
|
|
472
483
|
|
|
484
|
+
var _excluded = ["queryParams", "matrixParams", "itemSearchDocument", "rowsPerPage", "page"];
|
|
473
485
|
var CHANGE_PAGE = 'CHANGE_PAGE';
|
|
474
486
|
var CHANGE_ROWS = 'CHANGE_ROWS';
|
|
475
487
|
var CHANGE_SORT = 'CHANGE_SORT';
|
|
@@ -513,7 +525,7 @@ var setInitialDefaultState = function setInitialDefaultState() {
|
|
|
513
525
|
rowsPerPage = _ref$rowsPerPage === void 0 ? 10 : _ref$rowsPerPage,
|
|
514
526
|
_ref$page = _ref.page,
|
|
515
527
|
page = _ref$page === void 0 ? 0 : _ref$page,
|
|
516
|
-
state = _objectWithoutProperties(_ref,
|
|
528
|
+
state = _objectWithoutProperties(_ref, _excluded);
|
|
517
529
|
|
|
518
530
|
return _objectSpread2(_objectSpread2({}, state), {}, {
|
|
519
531
|
queryParams: _objectSpread2({
|
|
@@ -923,9 +935,11 @@ function useAutocomplete(initialState) {
|
|
|
923
935
|
setAutocompleteDoc = _React$useState2[1];
|
|
924
936
|
|
|
925
937
|
var setAutocompleteField = React.useCallback(function (field) {
|
|
938
|
+
var text = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
|
|
926
939
|
setAutocompleteDoc(function (state) {
|
|
927
940
|
return _objectSpread2(_objectSpread2({}, state), {}, {
|
|
928
|
-
field: field
|
|
941
|
+
field: field,
|
|
942
|
+
text: text
|
|
929
943
|
});
|
|
930
944
|
});
|
|
931
945
|
}, []);
|
|
@@ -1098,6 +1112,7 @@ function useThumbnailScrub() {
|
|
|
1098
1112
|
};
|
|
1099
1113
|
}
|
|
1100
1114
|
|
|
1115
|
+
var _excluded$1 = ["type"];
|
|
1101
1116
|
var CHANGE_PAGE$1 = 'CHANGE_PAGE';
|
|
1102
1117
|
var CHANGE_ROWS$1 = 'CHANGE_ROWS';
|
|
1103
1118
|
var CHANGE_SORT$1 = 'CHANGE_SORT';
|
|
@@ -1138,7 +1153,7 @@ var setInitialDefaultState$2 = function setInitialDefaultState() {
|
|
|
1138
1153
|
|
|
1139
1154
|
var searchReducer$1 = function searchReducer(state, action) {
|
|
1140
1155
|
var type = action.type,
|
|
1141
|
-
rest = _objectWithoutProperties(action,
|
|
1156
|
+
rest = _objectWithoutProperties(action, _excluded$1);
|
|
1142
1157
|
|
|
1143
1158
|
switch (type) {
|
|
1144
1159
|
case ACTION_TYPE$1.CHANGE_PAGE:
|
|
@@ -1438,7 +1453,6 @@ var useLocalStorage = function useLocalStorage(localStorageKey, defaultValue) {
|
|
|
1438
1453
|
return [value, setValue, getValue];
|
|
1439
1454
|
};
|
|
1440
1455
|
|
|
1441
|
-
// eslint-disable-next-line import/prefer-default-export
|
|
1442
1456
|
function uuidv4() {
|
|
1443
1457
|
return ([1e7] + -1e3 + -4e3 + -8e3 + -1e11).replace(/[018]/g, function (c) {
|
|
1444
1458
|
return (// eslint-disable-next-line
|
|
@@ -1447,16 +1461,16 @@ function uuidv4() {
|
|
|
1447
1461
|
});
|
|
1448
1462
|
}
|
|
1449
1463
|
function b64EncodeUnicode(str) {
|
|
1450
|
-
return
|
|
1451
|
-
return String.fromCharCode("0x".concat(p1));
|
|
1452
|
-
}));
|
|
1464
|
+
return compressToEncodedURIComponent(str);
|
|
1453
1465
|
}
|
|
1454
1466
|
function b64DecodeUnicode(str) {
|
|
1455
|
-
|
|
1467
|
+
// fallback for old base64 encoded links
|
|
1468
|
+
return str.slice(-1) === '=' ? decodeURIComponent(atob(str).split('').map(function (c) {
|
|
1456
1469
|
return "%".concat("00".concat(c.charCodeAt(0).toString(16)).slice(-2));
|
|
1457
|
-
}).join(''));
|
|
1470
|
+
}).join('')) : decompressFromEncodedURIComponent(str);
|
|
1458
1471
|
}
|
|
1459
1472
|
|
|
1473
|
+
var _excluded$2 = ["onUploadFile", "initialMetadata"];
|
|
1460
1474
|
var DEFAULT_AUDIO_SHAPETAGS = ['__mp3_160k'];
|
|
1461
1475
|
var DEFAULT_VIDEO_SHAPETAGS = ['__mp4'];
|
|
1462
1476
|
var DEFAULT_IMAGE_SHAPETAGS = ['__png'];
|
|
@@ -1583,7 +1597,7 @@ function useUploadFiles(_ref3) {
|
|
|
1583
1597
|
handleUploadFile = _ref3$onUploadFile === void 0 ? onUploadFile : _ref3$onUploadFile,
|
|
1584
1598
|
_ref3$initialMetadata = _ref3.initialMetadata,
|
|
1585
1599
|
initialMetadata = _ref3$initialMetadata === void 0 ? {} : _ref3$initialMetadata,
|
|
1586
|
-
props = _objectWithoutProperties(_ref3,
|
|
1600
|
+
props = _objectWithoutProperties(_ref3, _excluded$2);
|
|
1587
1601
|
|
|
1588
1602
|
var _React$useState = React.useState([]),
|
|
1589
1603
|
_React$useState2 = _slicedToArray(_React$useState, 2),
|
|
@@ -1745,6 +1759,9 @@ function useUpdateQueryState(_ref) {
|
|
|
1745
1759
|
}, [onSearchStateChange, state]);
|
|
1746
1760
|
}
|
|
1747
1761
|
|
|
1762
|
+
var _excluded$3 = ["accessId"],
|
|
1763
|
+
_excluded2 = ["accessControlDocument"];
|
|
1764
|
+
|
|
1748
1765
|
var useEntityAccess = function useEntityAccess(_ref) {
|
|
1749
1766
|
var entityId = _ref.entityId,
|
|
1750
1767
|
entityType = _ref.entityType;
|
|
@@ -1765,7 +1782,7 @@ var useEntityAccess = function useEntityAccess(_ref) {
|
|
|
1765
1782
|
[entityId, entityType]);
|
|
1766
1783
|
var onRemove = useCallback(function (_ref2) {
|
|
1767
1784
|
var accessId = _ref2.accessId,
|
|
1768
|
-
props = _objectWithoutProperties(_ref2,
|
|
1785
|
+
props = _objectWithoutProperties(_ref2, _excluded$3);
|
|
1769
1786
|
|
|
1770
1787
|
return access.removeEntityAccess(_objectSpread2({
|
|
1771
1788
|
accessId: accessId,
|
|
@@ -1775,7 +1792,7 @@ var useEntityAccess = function useEntityAccess(_ref) {
|
|
|
1775
1792
|
}, [entityId, entityType]);
|
|
1776
1793
|
var onAdd = useCallback(function (_ref3) {
|
|
1777
1794
|
var accessControlDocument = _ref3.accessControlDocument,
|
|
1778
|
-
props = _objectWithoutProperties(_ref3,
|
|
1795
|
+
props = _objectWithoutProperties(_ref3, _excluded2);
|
|
1779
1796
|
|
|
1780
1797
|
return access.createEntityAccess(_objectSpread2({
|
|
1781
1798
|
entityType: entityType,
|
|
@@ -1792,6 +1809,11 @@ var useEntityAccess = function useEntityAccess(_ref) {
|
|
|
1792
1809
|
};
|
|
1793
1810
|
};
|
|
1794
1811
|
|
|
1812
|
+
var _excluded$4 = ["name"],
|
|
1813
|
+
_excluded2$1 = ["label"],
|
|
1814
|
+
_excluded3 = ["name", "field", "group"],
|
|
1815
|
+
_excluded4 = ["label"];
|
|
1816
|
+
|
|
1795
1817
|
var getValueFromData = function getValueFromData() {
|
|
1796
1818
|
var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
|
|
1797
1819
|
_ref$data = _ref.data,
|
|
@@ -1888,18 +1910,19 @@ var useAddMetadataFieldAttributes = function useAddMetadataFieldAttributes(_ref5
|
|
|
1888
1910
|
var fieldsAttributes = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
1889
1911
|
return fieldsArray.map(function (_ref6) {
|
|
1890
1912
|
var name = _ref6.name,
|
|
1891
|
-
overrides = _objectWithoutProperties(_ref6,
|
|
1913
|
+
overrides = _objectWithoutProperties(_ref6, _excluded$4);
|
|
1892
1914
|
|
|
1893
1915
|
var fieldAttributes = fieldsAttributes[name] || {};
|
|
1894
1916
|
|
|
1895
1917
|
var _getDataAttributes = getDataAttributes(fieldAttributes, fieldDataToInclude.split(',')),
|
|
1896
1918
|
label = _getDataAttributes.label,
|
|
1897
|
-
dataAttributes = _objectWithoutProperties(_getDataAttributes,
|
|
1919
|
+
dataAttributes = _objectWithoutProperties(_getDataAttributes, _excluded2$1);
|
|
1898
1920
|
|
|
1899
1921
|
return _objectSpread2(_objectSpread2({
|
|
1900
1922
|
name: name,
|
|
1901
1923
|
label: label || name,
|
|
1902
1924
|
type: fieldAttributes.type,
|
|
1925
|
+
constraint: fieldAttributes.constraint,
|
|
1903
1926
|
options: getOptions(fieldAttributes)
|
|
1904
1927
|
}, dataAttributes), overrides);
|
|
1905
1928
|
});
|
|
@@ -1913,7 +1936,7 @@ var useAddMetadataFieldAttributes = function useAddMetadataFieldAttributes(_ref5
|
|
|
1913
1936
|
var name = _ref7.name,
|
|
1914
1937
|
field = _ref7.field,
|
|
1915
1938
|
group = _ref7.group,
|
|
1916
|
-
overrides = _objectWithoutProperties(_ref7,
|
|
1939
|
+
overrides = _objectWithoutProperties(_ref7, _excluded3);
|
|
1917
1940
|
|
|
1918
1941
|
var groupAttributes = groupsAttributes[name] || {};
|
|
1919
1942
|
var childFields = field || groupAttributes && groupAttributes.field;
|
|
@@ -1921,7 +1944,7 @@ var useAddMetadataFieldAttributes = function useAddMetadataFieldAttributes(_ref5
|
|
|
1921
1944
|
|
|
1922
1945
|
var _getDataAttributes2 = getDataAttributes(groupAttributes, groupDataToInclude.split(',')),
|
|
1923
1946
|
label = _getDataAttributes2.label,
|
|
1924
|
-
dataAttributes = _objectWithoutProperties(_getDataAttributes2,
|
|
1947
|
+
dataAttributes = _objectWithoutProperties(_getDataAttributes2, _excluded4);
|
|
1925
1948
|
|
|
1926
1949
|
return _objectSpread2(_objectSpread2({
|
|
1927
1950
|
name: name,
|
|
@@ -2121,6 +2144,8 @@ var useAddMetadataFieldAttributes = function useAddMetadataFieldAttributes(_ref5
|
|
|
2121
2144
|
};
|
|
2122
2145
|
};
|
|
2123
2146
|
|
|
2147
|
+
var _excluded$5 = ["setItemSearchDocument"];
|
|
2148
|
+
|
|
2124
2149
|
var UPDATE_FREQUENCY = 1000; // Prevents access controls set on the library (i.e. saved search) from cascading down to items
|
|
2125
2150
|
|
|
2126
2151
|
var UPDATE_MODE = 'TRANSIENT';
|
|
@@ -2257,7 +2282,7 @@ function useSavedSearch(_ref11) {
|
|
|
2257
2282
|
}));
|
|
2258
2283
|
|
|
2259
2284
|
var _setItemSearchDocument = searchProps.setItemSearchDocument,
|
|
2260
|
-
props = _objectWithoutProperties(searchProps,
|
|
2285
|
+
props = _objectWithoutProperties(searchProps, _excluded$5);
|
|
2261
2286
|
|
|
2262
2287
|
return {
|
|
2263
2288
|
onSaveSearch: saveSearchWithMarker,
|
|
@@ -2388,6 +2413,8 @@ function useGetCollection$1(_ref) {
|
|
|
2388
2413
|
};
|
|
2389
2414
|
}
|
|
2390
2415
|
|
|
2416
|
+
var _excluded$6 = ["request", "data"];
|
|
2417
|
+
|
|
2391
2418
|
var useGetEntity = function useGetEntity(_ref) {
|
|
2392
2419
|
var _objectSpread3;
|
|
2393
2420
|
|
|
@@ -2423,7 +2450,7 @@ var useGetEntity = function useGetEntity(_ref) {
|
|
|
2423
2450
|
var _useApi = useApi(entityApi),
|
|
2424
2451
|
request = _useApi.request,
|
|
2425
2452
|
data = _useApi.data,
|
|
2426
|
-
apiProps = _objectWithoutProperties(_useApi,
|
|
2453
|
+
apiProps = _objectWithoutProperties(_useApi, _excluded$6);
|
|
2427
2454
|
|
|
2428
2455
|
var onGetEntity = React.useCallback(function (props) {
|
|
2429
2456
|
return request(_objectSpread2(_defineProperty({}, entityTypeId, entityId), props));
|
|
@@ -3186,6 +3213,761 @@ var useCollectionAutoPlay = function useCollectionAutoPlay(_ref) {
|
|
|
3186
3213
|
};
|
|
3187
3214
|
};
|
|
3188
3215
|
|
|
3216
|
+
function useHoverScrub() {
|
|
3217
|
+
var srcList = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
3218
|
+
var customOffset = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
|
|
3219
|
+
var durationSeconds = arguments.length > 2 ? arguments[2] : undefined;
|
|
3220
|
+
|
|
3221
|
+
var _React$useState = React.useState(0),
|
|
3222
|
+
_React$useState2 = _slicedToArray(_React$useState, 2),
|
|
3223
|
+
scrubPosition = _React$useState2[0],
|
|
3224
|
+
setScrubPosition = _React$useState2[1];
|
|
3225
|
+
|
|
3226
|
+
var _React$useState3 = React.useState(0),
|
|
3227
|
+
_React$useState4 = _slicedToArray(_React$useState3, 2),
|
|
3228
|
+
thumbnailIndex = _React$useState4[0],
|
|
3229
|
+
setThumbnailIndex = _React$useState4[1];
|
|
3230
|
+
|
|
3231
|
+
var _React$useState5 = React.useState(false),
|
|
3232
|
+
_React$useState6 = _slicedToArray(_React$useState5, 2),
|
|
3233
|
+
showScrub = _React$useState6[0],
|
|
3234
|
+
setShowScrub = _React$useState6[1];
|
|
3235
|
+
|
|
3236
|
+
var _React$useState7 = React.useState([]),
|
|
3237
|
+
_React$useState8 = _slicedToArray(_React$useState7, 2),
|
|
3238
|
+
thumbnailTimeCodeArray = _React$useState8[0],
|
|
3239
|
+
setThumbnailTimeCodeArray = _React$useState8[1];
|
|
3240
|
+
|
|
3241
|
+
var _React$useState9 = React.useState(),
|
|
3242
|
+
_React$useState10 = _slicedToArray(_React$useState9, 2),
|
|
3243
|
+
thumbnailTimeCode = _React$useState10[0],
|
|
3244
|
+
setThumbnailTimeCode = _React$useState10[1];
|
|
3245
|
+
|
|
3246
|
+
var _React$useState11 = React.useState(0),
|
|
3247
|
+
_React$useState12 = _slicedToArray(_React$useState11, 2),
|
|
3248
|
+
thumbnailWidth = _React$useState12[0],
|
|
3249
|
+
setThumbnailWidth = _React$useState12[1];
|
|
3250
|
+
|
|
3251
|
+
var getInnerLeft = useCallback(function (e) {
|
|
3252
|
+
var left = e.clientX - e.currentTarget.offsetLeft - customOffset;
|
|
3253
|
+
|
|
3254
|
+
if (left < 0) {
|
|
3255
|
+
return 0;
|
|
3256
|
+
}
|
|
3257
|
+
|
|
3258
|
+
if (left > e.currentTarget.offsetWidth) {
|
|
3259
|
+
return e.currentTarget.offsetWidth;
|
|
3260
|
+
}
|
|
3261
|
+
|
|
3262
|
+
return left;
|
|
3263
|
+
}, [customOffset]);
|
|
3264
|
+
|
|
3265
|
+
var onMouseMove = function onMouseMove(e) {
|
|
3266
|
+
if (durationSeconds) {
|
|
3267
|
+
var innerLeft = getInnerLeft(e);
|
|
3268
|
+
setScrubPosition(innerLeft - 1);
|
|
3269
|
+
setThumbnailWidth(e.currentTarget.offsetWidth);
|
|
3270
|
+
var pxToSec = e.currentTarget.offsetWidth / +durationSeconds;
|
|
3271
|
+
var pxAsTimeCode = innerLeft / pxToSec;
|
|
3272
|
+
setThumbnailTimeCode(formatSeconds(pxAsTimeCode));
|
|
3273
|
+
|
|
3274
|
+
for (var index = 0; index < thumbnailTimeCodeArray.length; index += 1) {
|
|
3275
|
+
var timeCode = thumbnailTimeCodeArray[index];
|
|
3276
|
+
var nextTimeCode = thumbnailTimeCodeArray[index + 1] || thumbnailTimeCodeArray[thumbnailTimeCodeArray.length - 1];
|
|
3277
|
+
|
|
3278
|
+
if (timeCode && nextTimeCode && timeCode.toSeconds().toFixed(0) <= pxAsTimeCode && nextTimeCode.toSeconds().toFixed(0) >= pxAsTimeCode) {
|
|
3279
|
+
setThumbnailIndex(index);
|
|
3280
|
+
}
|
|
3281
|
+
}
|
|
3282
|
+
}
|
|
3283
|
+
};
|
|
3284
|
+
|
|
3285
|
+
useDeepCompareEffect(function () {
|
|
3286
|
+
var timeCodes = [];
|
|
3287
|
+
|
|
3288
|
+
for (var index = 0; index < srcList.length; index += 1) {
|
|
3289
|
+
var uri = srcList[index];
|
|
3290
|
+
|
|
3291
|
+
if (uri && typeof uri === 'string') {
|
|
3292
|
+
try {
|
|
3293
|
+
var timeCodeFromURI = uri.split('version')[1].split('/')[1].split('?')[0];
|
|
3294
|
+
var timecodeText = formatTimeCodeText(timeCodeFromURI);
|
|
3295
|
+
timeCodes.push(timecodeText);
|
|
3296
|
+
} catch (error) {
|
|
3297
|
+
return;
|
|
3298
|
+
}
|
|
3299
|
+
}
|
|
3300
|
+
}
|
|
3301
|
+
|
|
3302
|
+
setThumbnailTimeCodeArray(timeCodes);
|
|
3303
|
+
}, [srcList]);
|
|
3304
|
+
|
|
3305
|
+
var handleShowScrub = function handleShowScrub(value) {
|
|
3306
|
+
return function () {
|
|
3307
|
+
if (durationSeconds > 0) {
|
|
3308
|
+
setShowScrub(value);
|
|
3309
|
+
}
|
|
3310
|
+
};
|
|
3311
|
+
};
|
|
3312
|
+
|
|
3313
|
+
return {
|
|
3314
|
+
thumbnailIndex: thumbnailIndex,
|
|
3315
|
+
thumbnailTimeCode: thumbnailTimeCode,
|
|
3316
|
+
thumbnailWidth: thumbnailWidth,
|
|
3317
|
+
showScrub: showScrub,
|
|
3318
|
+
scrubPosition: scrubPosition,
|
|
3319
|
+
handleShowScrub: handleShowScrub,
|
|
3320
|
+
onMouseMove: onMouseMove
|
|
3321
|
+
};
|
|
3322
|
+
}
|
|
3323
|
+
|
|
3324
|
+
function useDocSearchAutocomplete(_ref) {
|
|
3325
|
+
var searchDoc = _ref.searchDoc,
|
|
3326
|
+
queryParams = _ref.queryParams,
|
|
3327
|
+
debounceTime = _ref.debounceTime,
|
|
3328
|
+
_ref$suggestionSettin = _ref.suggestionSettings,
|
|
3329
|
+
suggestionSettings = _ref$suggestionSettin === void 0 ? {
|
|
3330
|
+
maximumSuggestions: 10,
|
|
3331
|
+
accuracy: 1
|
|
3332
|
+
} : _ref$suggestionSettin,
|
|
3333
|
+
_ref$triggerLength = _ref.triggerLength,
|
|
3334
|
+
triggerLength = _ref$triggerLength === void 0 ? 1 : _ref$triggerLength,
|
|
3335
|
+
_ref$apiCall = _ref.apiCall,
|
|
3336
|
+
apiCall = _ref$apiCall === void 0 ? item.searchItem : _ref$apiCall;
|
|
3337
|
+
|
|
3338
|
+
var _React$useState = React.useState(''),
|
|
3339
|
+
_React$useState2 = _slicedToArray(_React$useState, 2),
|
|
3340
|
+
textValue = _React$useState2[0],
|
|
3341
|
+
setTextValue = _React$useState2[1];
|
|
3342
|
+
|
|
3343
|
+
var handleAutocompleteChange = React.useRef(debounce(setTextValue, debounceTime)).current;
|
|
3344
|
+
|
|
3345
|
+
var _useApi = useApi(apiCall),
|
|
3346
|
+
_useApi$data = _useApi.data;
|
|
3347
|
+
|
|
3348
|
+
_useApi$data = _useApi$data === void 0 ? {} : _useApi$data;
|
|
3349
|
+
var _useApi$data$autocomp = _useApi$data.autocomplete,
|
|
3350
|
+
autocomplete = _useApi$data$autocomp === void 0 ? [] : _useApi$data$autocomp,
|
|
3351
|
+
request = _useApi.request;
|
|
3352
|
+
|
|
3353
|
+
var _ref2 = autocomplete[0] || {},
|
|
3354
|
+
_ref2$suggestion = _ref2.suggestion,
|
|
3355
|
+
suggestion = _ref2$suggestion === void 0 ? [] : _ref2$suggestion;
|
|
3356
|
+
|
|
3357
|
+
useDeepCompareEffect(function () {
|
|
3358
|
+
if (searchDoc && textValue && textValue.length >= triggerLength) {
|
|
3359
|
+
request({
|
|
3360
|
+
body: _objectSpread2(_objectSpread2({}, searchDoc), {}, {
|
|
3361
|
+
suggestion: suggestionSettings,
|
|
3362
|
+
autocomplete: [{
|
|
3363
|
+
text: textValue
|
|
3364
|
+
}],
|
|
3365
|
+
text: [{
|
|
3366
|
+
value: textValue
|
|
3367
|
+
}]
|
|
3368
|
+
}),
|
|
3369
|
+
queryParams: _objectSpread2({
|
|
3370
|
+
count: false,
|
|
3371
|
+
number: 0
|
|
3372
|
+
}, queryParams)
|
|
3373
|
+
});
|
|
3374
|
+
}
|
|
3375
|
+
}, [request, textValue, queryParams, triggerLength]);
|
|
3376
|
+
return {
|
|
3377
|
+
suggestion: suggestion,
|
|
3378
|
+
handleAutocompleteChange: handleAutocompleteChange
|
|
3379
|
+
};
|
|
3380
|
+
}
|
|
3381
|
+
|
|
3382
|
+
function useGetFieldMetadataDataset() {
|
|
3383
|
+
var _useApi = useApi(metadatafield.getMetadataFieldAllowedValues),
|
|
3384
|
+
request = _useApi.request,
|
|
3385
|
+
_useApi$data = _useApi.data;
|
|
3386
|
+
|
|
3387
|
+
_useApi$data = _useApi$data === void 0 ? {} : _useApi$data;
|
|
3388
|
+
var _useApi$data$value = _useApi$data.value,
|
|
3389
|
+
constraintValueListType = _useApi$data$value === void 0 ? [] : _useApi$data$value,
|
|
3390
|
+
isLoading = _useApi.isLoading;
|
|
3391
|
+
|
|
3392
|
+
var getMetadataDataset = function getMetadataDataset(datasetField, parentValue, parentField) {
|
|
3393
|
+
var metadataFieldValueConstraintListDocument = {
|
|
3394
|
+
constraint: parentValue ? [{
|
|
3395
|
+
field: parentField,
|
|
3396
|
+
value: parentValue
|
|
3397
|
+
}] : []
|
|
3398
|
+
};
|
|
3399
|
+
|
|
3400
|
+
if (datasetField) {
|
|
3401
|
+
request({
|
|
3402
|
+
fieldName: datasetField,
|
|
3403
|
+
metadataFieldValueConstraintListDocument: metadataFieldValueConstraintListDocument
|
|
3404
|
+
});
|
|
3405
|
+
}
|
|
3406
|
+
};
|
|
3407
|
+
|
|
3408
|
+
return {
|
|
3409
|
+
getMetadataDataset: getMetadataDataset,
|
|
3410
|
+
dataset: constraintValueListType,
|
|
3411
|
+
isLoading: isLoading
|
|
3412
|
+
};
|
|
3413
|
+
}
|
|
3414
|
+
|
|
3415
|
+
var UPDATE_FREQUENCY$1 = 1000; // Prevents access controls set on the library (i.e. saved search) from cascading down to items
|
|
3416
|
+
|
|
3417
|
+
var UPDATE_MODE$1 = 'TRANSIENT';
|
|
3418
|
+
|
|
3419
|
+
var getCollectionTitle = function getCollectionTitle(fields) {
|
|
3420
|
+
return fields.find(function (field) {
|
|
3421
|
+
return field.name === 'title';
|
|
3422
|
+
}).value[0].value;
|
|
3423
|
+
};
|
|
3424
|
+
|
|
3425
|
+
function useGetSavedSearchFolders(_ref) {
|
|
3426
|
+
var _ref$childFolders = _ref.childFolders,
|
|
3427
|
+
childFolders = _ref$childFolders === void 0 ? [] : _ref$childFolders,
|
|
3428
|
+
_ref$queryParams = _ref.queryParams,
|
|
3429
|
+
queryParams = _ref$queryParams === void 0 ? {
|
|
3430
|
+
content: ['metadata']
|
|
3431
|
+
} : _ref$queryParams,
|
|
3432
|
+
_ref$markerProps = _ref.markerProps,
|
|
3433
|
+
markerProps = _ref$markerProps === void 0 ? {
|
|
3434
|
+
markerValue: 'savedSearch',
|
|
3435
|
+
markerField: 'eidr_referentType'
|
|
3436
|
+
} : _ref$markerProps,
|
|
3437
|
+
expand = _ref.expand;
|
|
3438
|
+
|
|
3439
|
+
var _React$useState = React.useState(childFolders),
|
|
3440
|
+
_React$useState2 = _slicedToArray(_React$useState, 2),
|
|
3441
|
+
currentFolders = _React$useState2[0],
|
|
3442
|
+
setCurrentFolders = _React$useState2[1];
|
|
3443
|
+
|
|
3444
|
+
var _React$useState3 = React.useState([]),
|
|
3445
|
+
_React$useState4 = _slicedToArray(_React$useState3, 2),
|
|
3446
|
+
subFolders = _React$useState4[0],
|
|
3447
|
+
setSubFolders = _React$useState4[1];
|
|
3448
|
+
|
|
3449
|
+
var _React$useState5 = React.useState(),
|
|
3450
|
+
_React$useState6 = _slicedToArray(_React$useState5, 2),
|
|
3451
|
+
errors = _React$useState6[0],
|
|
3452
|
+
setErrors = _React$useState6[1];
|
|
3453
|
+
|
|
3454
|
+
var getSubFolders = React.useCallback(function () {
|
|
3455
|
+
Promise.all(currentFolders.map( /*#__PURE__*/function () {
|
|
3456
|
+
var _ref2 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee(id) {
|
|
3457
|
+
var _yield$CollectionApi$, _yield$CollectionApi$2, content, _yield$CollectionApi$3, metadata, field;
|
|
3458
|
+
|
|
3459
|
+
return regeneratorRuntime.wrap(function _callee$(_context) {
|
|
3460
|
+
while (1) {
|
|
3461
|
+
switch (_context.prev = _context.next) {
|
|
3462
|
+
case 0:
|
|
3463
|
+
_context.next = 2;
|
|
3464
|
+
return collection.getCollection({
|
|
3465
|
+
collectionId: id,
|
|
3466
|
+
queryParams: queryParams
|
|
3467
|
+
});
|
|
3468
|
+
|
|
3469
|
+
case 2:
|
|
3470
|
+
_yield$CollectionApi$ = _context.sent;
|
|
3471
|
+
_yield$CollectionApi$2 = _yield$CollectionApi$.data;
|
|
3472
|
+
content = _yield$CollectionApi$2.content;
|
|
3473
|
+
_yield$CollectionApi$3 = _yield$CollectionApi$2.metadata;
|
|
3474
|
+
metadata = _yield$CollectionApi$3 === void 0 ? {} : _yield$CollectionApi$3;
|
|
3475
|
+
field = metadata.timespan[0].field;
|
|
3476
|
+
|
|
3477
|
+
if (!(content && content[0].type === 'library')) {
|
|
3478
|
+
_context.next = 10;
|
|
3479
|
+
break;
|
|
3480
|
+
}
|
|
3481
|
+
|
|
3482
|
+
return _context.abrupt("return", {
|
|
3483
|
+
id: id,
|
|
3484
|
+
libraryId: content[0].id,
|
|
3485
|
+
title: getCollectionTitle(field),
|
|
3486
|
+
type: 'query',
|
|
3487
|
+
metadata: metadata
|
|
3488
|
+
});
|
|
3489
|
+
|
|
3490
|
+
case 10:
|
|
3491
|
+
return _context.abrupt("return", {
|
|
3492
|
+
id: id,
|
|
3493
|
+
title: getCollectionTitle(field),
|
|
3494
|
+
subFolders: content && content.map(function (c) {
|
|
3495
|
+
return c.id;
|
|
3496
|
+
}),
|
|
3497
|
+
type: 'folder',
|
|
3498
|
+
metadata: metadata
|
|
3499
|
+
});
|
|
3500
|
+
|
|
3501
|
+
case 11:
|
|
3502
|
+
case "end":
|
|
3503
|
+
return _context.stop();
|
|
3504
|
+
}
|
|
3505
|
+
}
|
|
3506
|
+
}, _callee);
|
|
3507
|
+
}));
|
|
3508
|
+
|
|
3509
|
+
return function (_x) {
|
|
3510
|
+
return _ref2.apply(this, arguments);
|
|
3511
|
+
};
|
|
3512
|
+
}())).then(function (newFolders) {
|
|
3513
|
+
setSubFolders(function (prevState) {
|
|
3514
|
+
return [].concat(_toConsumableArray(newFolders), _toConsumableArray(prevState));
|
|
3515
|
+
});
|
|
3516
|
+
})["catch"](function (error) {
|
|
3517
|
+
setErrors(error);
|
|
3518
|
+
});
|
|
3519
|
+
}, [currentFolders, queryParams]);
|
|
3520
|
+
|
|
3521
|
+
var createFolder = function createFolder(parentId, type, title, callback) {
|
|
3522
|
+
collection.createCollection({
|
|
3523
|
+
collectionDocument: {
|
|
3524
|
+
metadata: createMetadataType({
|
|
3525
|
+
saved_search_folder: type,
|
|
3526
|
+
title: title
|
|
3527
|
+
})
|
|
3528
|
+
}
|
|
3529
|
+
}).then(function (_ref3) {
|
|
3530
|
+
var id = _ref3.data.id;
|
|
3531
|
+
|
|
3532
|
+
if (parentId) {
|
|
3533
|
+
return collection.updateCollection({
|
|
3534
|
+
collectionId: parentId,
|
|
3535
|
+
collectionDocument: {
|
|
3536
|
+
content: [{
|
|
3537
|
+
id: id,
|
|
3538
|
+
mode: 'add',
|
|
3539
|
+
type: 'collection'
|
|
3540
|
+
}]
|
|
3541
|
+
}
|
|
3542
|
+
}).then(function (_ref4) {
|
|
3543
|
+
var content = _ref4.data.content;
|
|
3544
|
+
|
|
3545
|
+
if (content) {
|
|
3546
|
+
setCurrentFolders(content.filter(function (collection) {
|
|
3547
|
+
return collection.id === id;
|
|
3548
|
+
}).map(function (collection) {
|
|
3549
|
+
return collection.id;
|
|
3550
|
+
}));
|
|
3551
|
+
if (callback) callback();
|
|
3552
|
+
}
|
|
3553
|
+
})["catch"](function (error) {
|
|
3554
|
+
setErrors(error);
|
|
3555
|
+
});
|
|
3556
|
+
}
|
|
3557
|
+
|
|
3558
|
+
return null;
|
|
3559
|
+
})["catch"](function (error) {
|
|
3560
|
+
setErrors(error);
|
|
3561
|
+
});
|
|
3562
|
+
};
|
|
3563
|
+
|
|
3564
|
+
var saveSearch = function saveSearch(folderId, title, itemSearchDocument, callback) {
|
|
3565
|
+
try {
|
|
3566
|
+
item.searchItem({
|
|
3567
|
+
queryParams: {
|
|
3568
|
+
result: 'library',
|
|
3569
|
+
updateMode: UPDATE_MODE$1,
|
|
3570
|
+
updateFrequency: UPDATE_FREQUENCY$1
|
|
3571
|
+
},
|
|
3572
|
+
itemSearchDocument: itemSearchDocument
|
|
3573
|
+
}).then(function (_ref5) {
|
|
3574
|
+
var _createMetadataType;
|
|
3575
|
+
|
|
3576
|
+
var library = _ref5.data.library;
|
|
3577
|
+
return collection.createCollection({
|
|
3578
|
+
collectionDocument: {
|
|
3579
|
+
metadata: createMetadataType((_createMetadataType = {}, _defineProperty(_createMetadataType, markerProps.markerField, markerProps.markerValue), _defineProperty(_createMetadataType, "title", title), _createMetadataType)),
|
|
3580
|
+
content: [{
|
|
3581
|
+
id: library,
|
|
3582
|
+
type: 'library'
|
|
3583
|
+
}]
|
|
3584
|
+
}
|
|
3585
|
+
});
|
|
3586
|
+
}).then(function (_ref6) {
|
|
3587
|
+
var id = _ref6.data.id;
|
|
3588
|
+
return collection.updateCollection({
|
|
3589
|
+
collectionId: folderId,
|
|
3590
|
+
collectionDocument: {
|
|
3591
|
+
content: [{
|
|
3592
|
+
id: id,
|
|
3593
|
+
mode: 'add',
|
|
3594
|
+
type: 'collection'
|
|
3595
|
+
}]
|
|
3596
|
+
}
|
|
3597
|
+
}).then(function (_ref7) {
|
|
3598
|
+
var content = _ref7.data.content;
|
|
3599
|
+
|
|
3600
|
+
if (content) {
|
|
3601
|
+
setCurrentFolders(content.filter(function (collection) {
|
|
3602
|
+
return collection.id === id;
|
|
3603
|
+
}).map(function (collection) {
|
|
3604
|
+
return collection.id;
|
|
3605
|
+
}));
|
|
3606
|
+
if (callback) callback();
|
|
3607
|
+
}
|
|
3608
|
+
})["catch"](function (error) {
|
|
3609
|
+
setErrors(error);
|
|
3610
|
+
});
|
|
3611
|
+
})["catch"](function (error) {
|
|
3612
|
+
setErrors(error);
|
|
3613
|
+
});
|
|
3614
|
+
} catch (error) {
|
|
3615
|
+
setErrors(error);
|
|
3616
|
+
}
|
|
3617
|
+
};
|
|
3618
|
+
|
|
3619
|
+
var deleteFolder = function deleteFolder(collectionId) {
|
|
3620
|
+
return collection.removeCollection({
|
|
3621
|
+
collectionId: collectionId
|
|
3622
|
+
})["catch"](function (error) {
|
|
3623
|
+
setErrors(error);
|
|
3624
|
+
});
|
|
3625
|
+
};
|
|
3626
|
+
|
|
3627
|
+
var removeItem = function removeItem(id) {
|
|
3628
|
+
setSubFolders(function (prevState) {
|
|
3629
|
+
return prevState.filter(function (folder) {
|
|
3630
|
+
return folder.id !== id;
|
|
3631
|
+
});
|
|
3632
|
+
});
|
|
3633
|
+
};
|
|
3634
|
+
|
|
3635
|
+
useDeepCompareEffect(function () {
|
|
3636
|
+
if (currentFolders.length > 0 && expand) {
|
|
3637
|
+
getSubFolders();
|
|
3638
|
+
}
|
|
3639
|
+
}, [currentFolders, expand]);
|
|
3640
|
+
React.useEffect(function () {
|
|
3641
|
+
if (!expand && typeof expand === 'boolean') {
|
|
3642
|
+
setCurrentFolders(function () {
|
|
3643
|
+
return subFolders.map(function (folder) {
|
|
3644
|
+
return folder.id;
|
|
3645
|
+
});
|
|
3646
|
+
});
|
|
3647
|
+
setSubFolders([]);
|
|
3648
|
+
} // eslint-disable-next-line react-hooks/exhaustive-deps
|
|
3649
|
+
|
|
3650
|
+
}, [expand]);
|
|
3651
|
+
return {
|
|
3652
|
+
createFolder: createFolder,
|
|
3653
|
+
saveSearch: saveSearch,
|
|
3654
|
+
getSubFolders: getSubFolders,
|
|
3655
|
+
deleteFolder: deleteFolder,
|
|
3656
|
+
removeItem: removeItem,
|
|
3657
|
+
subFolders: subFolders,
|
|
3658
|
+
setSubFolders: setSubFolders,
|
|
3659
|
+
setCurrentFolders: setCurrentFolders,
|
|
3660
|
+
errors: errors
|
|
3661
|
+
};
|
|
3662
|
+
}
|
|
3663
|
+
|
|
3664
|
+
var useRepresentativeItems = function useRepresentativeItems(_ref) {
|
|
3665
|
+
var collectionId = _ref.collectionId,
|
|
3666
|
+
onError = _ref.onError;
|
|
3667
|
+
|
|
3668
|
+
var _React$useState = React.useState([]),
|
|
3669
|
+
_React$useState2 = _slicedToArray(_React$useState, 2),
|
|
3670
|
+
representativeItems = _React$useState2[0],
|
|
3671
|
+
setRepresentativeItems = _React$useState2[1];
|
|
3672
|
+
|
|
3673
|
+
var asyncGetRepresentativeItems = /*#__PURE__*/function () {
|
|
3674
|
+
var _ref2 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee() {
|
|
3675
|
+
var _yield$CollectionApi$, _yield$CollectionApi$2, metadata, _parseMetadataType, _parseMetadataType$re, newRepresentativeItems;
|
|
3676
|
+
|
|
3677
|
+
return regeneratorRuntime.wrap(function _callee$(_context) {
|
|
3678
|
+
while (1) {
|
|
3679
|
+
switch (_context.prev = _context.next) {
|
|
3680
|
+
case 0:
|
|
3681
|
+
_context.prev = 0;
|
|
3682
|
+
|
|
3683
|
+
if (collectionId) {
|
|
3684
|
+
_context.next = 3;
|
|
3685
|
+
break;
|
|
3686
|
+
}
|
|
3687
|
+
|
|
3688
|
+
throw Error('Missing collectionId');
|
|
3689
|
+
|
|
3690
|
+
case 3:
|
|
3691
|
+
_context.next = 5;
|
|
3692
|
+
return collection.getCollectionMetadata({
|
|
3693
|
+
collectionId: collectionId,
|
|
3694
|
+
queryParams: {
|
|
3695
|
+
content: 'metadata',
|
|
3696
|
+
field: 'representativeItems'
|
|
3697
|
+
}
|
|
3698
|
+
})["catch"](function (error) {
|
|
3699
|
+
if (onError) onError(error);
|
|
3700
|
+
});
|
|
3701
|
+
|
|
3702
|
+
case 5:
|
|
3703
|
+
_yield$CollectionApi$ = _context.sent;
|
|
3704
|
+
_yield$CollectionApi$2 = _yield$CollectionApi$.data;
|
|
3705
|
+
metadata = _yield$CollectionApi$2 === void 0 ? {} : _yield$CollectionApi$2;
|
|
3706
|
+
_parseMetadataType = parseMetadataType(metadata, {
|
|
3707
|
+
flat: true,
|
|
3708
|
+
includeValueAttributes: true
|
|
3709
|
+
}), _parseMetadataType$re = _parseMetadataType.representativeItems, newRepresentativeItems = _parseMetadataType$re === void 0 ? [] : _parseMetadataType$re;
|
|
3710
|
+
setRepresentativeItems(function () {
|
|
3711
|
+
return newRepresentativeItems;
|
|
3712
|
+
});
|
|
3713
|
+
_context.next = 15;
|
|
3714
|
+
break;
|
|
3715
|
+
|
|
3716
|
+
case 12:
|
|
3717
|
+
_context.prev = 12;
|
|
3718
|
+
_context.t0 = _context["catch"](0);
|
|
3719
|
+
if (onError) onError(_context.t0);
|
|
3720
|
+
|
|
3721
|
+
case 15:
|
|
3722
|
+
case "end":
|
|
3723
|
+
return _context.stop();
|
|
3724
|
+
}
|
|
3725
|
+
}
|
|
3726
|
+
}, _callee, null, [[0, 12]]);
|
|
3727
|
+
}));
|
|
3728
|
+
|
|
3729
|
+
return function asyncGetRepresentativeItems() {
|
|
3730
|
+
return _ref2.apply(this, arguments);
|
|
3731
|
+
};
|
|
3732
|
+
}();
|
|
3733
|
+
|
|
3734
|
+
var onRefresh = asyncGetRepresentativeItems;
|
|
3735
|
+
|
|
3736
|
+
var updateAsRepresentativeItem = /*#__PURE__*/function () {
|
|
3737
|
+
var _ref3 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee2(values) {
|
|
3738
|
+
var metadataDocument, response;
|
|
3739
|
+
return regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
3740
|
+
while (1) {
|
|
3741
|
+
switch (_context2.prev = _context2.next) {
|
|
3742
|
+
case 0:
|
|
3743
|
+
_context2.prev = 0;
|
|
3744
|
+
metadataDocument = createMetadataType({
|
|
3745
|
+
representativeItems: Array.isArray(values) ? values : [values]
|
|
3746
|
+
});
|
|
3747
|
+
_context2.next = 4;
|
|
3748
|
+
return collection.updateCollectionMetadata({
|
|
3749
|
+
collectionId: collectionId,
|
|
3750
|
+
metadataDocument: metadataDocument
|
|
3751
|
+
});
|
|
3752
|
+
|
|
3753
|
+
case 4:
|
|
3754
|
+
response = _context2.sent;
|
|
3755
|
+
onRefresh();
|
|
3756
|
+
return _context2.abrupt("return", response);
|
|
3757
|
+
|
|
3758
|
+
case 9:
|
|
3759
|
+
_context2.prev = 9;
|
|
3760
|
+
_context2.t0 = _context2["catch"](0);
|
|
3761
|
+
if (onError) onError(_context2.t0);
|
|
3762
|
+
return _context2.abrupt("return", undefined);
|
|
3763
|
+
|
|
3764
|
+
case 13:
|
|
3765
|
+
case "end":
|
|
3766
|
+
return _context2.stop();
|
|
3767
|
+
}
|
|
3768
|
+
}
|
|
3769
|
+
}, _callee2, null, [[0, 9]]);
|
|
3770
|
+
}));
|
|
3771
|
+
|
|
3772
|
+
return function updateAsRepresentativeItem(_x) {
|
|
3773
|
+
return _ref3.apply(this, arguments);
|
|
3774
|
+
};
|
|
3775
|
+
}();
|
|
3776
|
+
|
|
3777
|
+
var onAdd = function onAdd(entityId) {
|
|
3778
|
+
return updateAsRepresentativeItem({
|
|
3779
|
+
value: entityId,
|
|
3780
|
+
mode: 'add'
|
|
3781
|
+
});
|
|
3782
|
+
};
|
|
3783
|
+
|
|
3784
|
+
var onRemove = function onRemove(entityId) {
|
|
3785
|
+
try {
|
|
3786
|
+
// Get all (if it has been added multiple times)
|
|
3787
|
+
var entityIdValueUuids = representativeItems.filter(function (i) {
|
|
3788
|
+
return i.value === entityId;
|
|
3789
|
+
}).map(function (i) {
|
|
3790
|
+
return i.uuid;
|
|
3791
|
+
});
|
|
3792
|
+
if (!entityIdValueUuids.length) return undefined;
|
|
3793
|
+
return updateAsRepresentativeItem(entityIdValueUuids.map(function (uuid) {
|
|
3794
|
+
return {
|
|
3795
|
+
uuid: uuid,
|
|
3796
|
+
mode: 'remove'
|
|
3797
|
+
};
|
|
3798
|
+
}));
|
|
3799
|
+
} catch (error) {
|
|
3800
|
+
if (onError) onError(error);
|
|
3801
|
+
return undefined;
|
|
3802
|
+
}
|
|
3803
|
+
};
|
|
3804
|
+
|
|
3805
|
+
React.useEffect(function () {
|
|
3806
|
+
onRefresh(); // eslint-disable-next-line react-hooks/exhaustive-deps
|
|
3807
|
+
}, [collectionId]);
|
|
3808
|
+
return {
|
|
3809
|
+
representativeItems: representativeItems,
|
|
3810
|
+
onRefresh: onRefresh,
|
|
3811
|
+
onAdd: onAdd,
|
|
3812
|
+
onRemove: onRemove
|
|
3813
|
+
};
|
|
3814
|
+
};
|
|
3815
|
+
|
|
3816
|
+
function defaultOnGetStorage() {
|
|
3817
|
+
var storageData = storage.listStorage().then(function (response) {
|
|
3818
|
+
var storage = {
|
|
3819
|
+
id: response.data.storage[0].id,
|
|
3820
|
+
uri: response.data.storage[0].method[0].uri
|
|
3821
|
+
};
|
|
3822
|
+
return storage;
|
|
3823
|
+
});
|
|
3824
|
+
return storageData;
|
|
3825
|
+
}
|
|
3826
|
+
|
|
3827
|
+
function defaultOnCreate(list) {
|
|
3828
|
+
return library.createLibrary({
|
|
3829
|
+
itemListDocument: {
|
|
3830
|
+
item: _toConsumableArray(list.item.map(function (_ref) {
|
|
3831
|
+
var id = _ref.id;
|
|
3832
|
+
return {
|
|
3833
|
+
id: id
|
|
3834
|
+
};
|
|
3835
|
+
}))
|
|
3836
|
+
}
|
|
3837
|
+
});
|
|
3838
|
+
}
|
|
3839
|
+
|
|
3840
|
+
function defaultOnList(response, storageInfo, queryParams) {
|
|
3841
|
+
var _queryParams$fileName = queryParams.fileName,
|
|
3842
|
+
fileName = _queryParams$fileName === void 0 ? 'output' : _queryParams$fileName,
|
|
3843
|
+
_queryParams$outputFo = queryParams.outputFormat,
|
|
3844
|
+
outputFormat = _queryParams$outputFo === void 0 ? 'csv' : _queryParams$outputFo;
|
|
3845
|
+
var uri = storageInfo.uri;
|
|
3846
|
+
var _response$data = response.data;
|
|
3847
|
+
_response$data = _response$data === void 0 ? {} : _response$data;
|
|
3848
|
+
var _response$data$uri = _response$data.uri;
|
|
3849
|
+
_response$data$uri = _response$data$uri === void 0 ? [] : _response$data$uri;
|
|
3850
|
+
|
|
3851
|
+
var _response$data$uri2 = _slicedToArray(_response$data$uri, 1),
|
|
3852
|
+
libraryId = _response$data$uri2[0];
|
|
3853
|
+
|
|
3854
|
+
var createNewUri = function createNewUri() {
|
|
3855
|
+
if (uri.includes('s3')) {
|
|
3856
|
+
var _uri$split = uri.split('?region'),
|
|
3857
|
+
_uri$split2 = _slicedToArray(_uri$split, 2),
|
|
3858
|
+
uriBeforeRegion = _uri$split2[0],
|
|
3859
|
+
uriAfterRegion = _uri$split2[1];
|
|
3860
|
+
|
|
3861
|
+
return "".concat(uriBeforeRegion).concat(fileName, ".").concat(outputFormat, "?region").concat(uriAfterRegion);
|
|
3862
|
+
}
|
|
3863
|
+
|
|
3864
|
+
return "".concat(uri).concat(fileName, ".").concat(outputFormat);
|
|
3865
|
+
};
|
|
3866
|
+
|
|
3867
|
+
var newUri = encodeURIComponent(createNewUri());
|
|
3868
|
+
return library.getLibraryBatch({
|
|
3869
|
+
libraryId: libraryId,
|
|
3870
|
+
queryParams: _objectSpread2({
|
|
3871
|
+
destinationUri: newUri
|
|
3872
|
+
}, queryParams)
|
|
3873
|
+
});
|
|
3874
|
+
}
|
|
3875
|
+
|
|
3876
|
+
var SUCCESSFUL_STATES = ['FINISHED', 'FINISHED_WARNING'];
|
|
3877
|
+
var INACTIVE_STATES = ['FINISHED', 'FINISHED_WARNING', 'FAILED_TOTAL', 'ABORTED'];
|
|
3878
|
+
|
|
3879
|
+
function defaultOnGetFile(response, storageInfo, params, onError) {
|
|
3880
|
+
var _response$data2 = response.data;
|
|
3881
|
+
_response$data2 = _response$data2 === void 0 ? {} : _response$data2;
|
|
3882
|
+
var jobId = _response$data2.jobId;
|
|
3883
|
+
var id = storageInfo.id;
|
|
3884
|
+
var _params$fileName = params.fileName,
|
|
3885
|
+
fileName = _params$fileName === void 0 ? 'output' : _params$fileName,
|
|
3886
|
+
_params$outputFormat = params.outputFormat,
|
|
3887
|
+
outputFormat = _params$outputFormat === void 0 ? 'csv' : _params$outputFormat;
|
|
3888
|
+
var filePath = "".concat(fileName, ".").concat(outputFormat);
|
|
3889
|
+
job.getJob({
|
|
3890
|
+
jobId: jobId
|
|
3891
|
+
}).then(function () {
|
|
3892
|
+
var _ref2 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
|
|
3893
|
+
_ref2$data = _ref2.data;
|
|
3894
|
+
|
|
3895
|
+
_ref2$data = _ref2$data === void 0 ? {} : _ref2$data;
|
|
3896
|
+
var status = _ref2$data.status;
|
|
3897
|
+
|
|
3898
|
+
if (SUCCESSFUL_STATES.includes(status)) {
|
|
3899
|
+
try {
|
|
3900
|
+
file.listFileStorage({
|
|
3901
|
+
storageId: id,
|
|
3902
|
+
queryParams: {
|
|
3903
|
+
path: filePath,
|
|
3904
|
+
methodMetadata: [{
|
|
3905
|
+
key: 'format',
|
|
3906
|
+
value: 'SIGNED-AUTO'
|
|
3907
|
+
}, {
|
|
3908
|
+
key: 'contentDisposition',
|
|
3909
|
+
value: "attachment;+filename=".concat(filePath)
|
|
3910
|
+
}],
|
|
3911
|
+
'noauth-url': true
|
|
3912
|
+
}
|
|
3913
|
+
}).then(function (r) {
|
|
3914
|
+
return window.open(r.data.file[0].uri[0]);
|
|
3915
|
+
});
|
|
3916
|
+
} catch (error) {
|
|
3917
|
+
console.error('Download error:'.concat("\n", error));
|
|
3918
|
+
onError({
|
|
3919
|
+
message: 'Download failed'
|
|
3920
|
+
});
|
|
3921
|
+
}
|
|
3922
|
+
} else if (!INACTIVE_STATES.includes(status)) {
|
|
3923
|
+
setTimeout(function () {
|
|
3924
|
+
defaultOnGetFile(response, storageInfo, params);
|
|
3925
|
+
}, 1000);
|
|
3926
|
+
} else {
|
|
3927
|
+
onError({
|
|
3928
|
+
message: 'Download failed'
|
|
3929
|
+
});
|
|
3930
|
+
}
|
|
3931
|
+
});
|
|
3932
|
+
} // Note: Not needed as a react-hook since doesn't use react,
|
|
3933
|
+
// but this is usually where we put logic functions right now
|
|
3934
|
+
|
|
3935
|
+
|
|
3936
|
+
var useCsvDownload = function useCsvDownload(_ref3) {
|
|
3937
|
+
var itemListType = _ref3.itemListType,
|
|
3938
|
+
queryParams = _ref3.queryParams,
|
|
3939
|
+
onSuccess = _ref3.onSuccess,
|
|
3940
|
+
_ref3$onError = _ref3.onError,
|
|
3941
|
+
onError = _ref3$onError === void 0 ? function (_ref4) {
|
|
3942
|
+
var message = _ref4.message,
|
|
3943
|
+
error = _ref4.error;
|
|
3944
|
+
return console.error("".concat(message, "\n").concat(error));
|
|
3945
|
+
} : _ref3$onError,
|
|
3946
|
+
_ref3$onGetFile = _ref3.onGetFile,
|
|
3947
|
+
onGetFile = _ref3$onGetFile === void 0 ? defaultOnGetFile : _ref3$onGetFile,
|
|
3948
|
+
_ref3$onCreateList = _ref3.onCreateList,
|
|
3949
|
+
onCreateList = _ref3$onCreateList === void 0 ? defaultOnCreate : _ref3$onCreateList,
|
|
3950
|
+
_ref3$onList = _ref3.onList,
|
|
3951
|
+
onList = _ref3$onList === void 0 ? defaultOnList : _ref3$onList,
|
|
3952
|
+
_ref3$onGetStorage = _ref3.onGetStorage,
|
|
3953
|
+
onGetStorage = _ref3$onGetStorage === void 0 ? defaultOnGetStorage : _ref3$onGetStorage;
|
|
3954
|
+
|
|
3955
|
+
var onDownload = function onDownload() {
|
|
3956
|
+
return onGetStorage().then(function (storageInfo) {
|
|
3957
|
+
return Promise.all([onCreateList(itemListType).then(function (response) {
|
|
3958
|
+
return onList(response, storageInfo, queryParams);
|
|
3959
|
+
}).then(onSuccess()).then(function (response) {
|
|
3960
|
+
return onGetFile(response, storageInfo, queryParams, onError);
|
|
3961
|
+
})]);
|
|
3962
|
+
});
|
|
3963
|
+
};
|
|
3964
|
+
|
|
3965
|
+
return {
|
|
3966
|
+
onDownload: onDownload
|
|
3967
|
+
};
|
|
3968
|
+
};
|
|
3969
|
+
|
|
3970
|
+
var _excluded$7 = ["itemType", "collectionType", "joinValue", "flat", "children"];
|
|
3189
3971
|
function MetadataType(_ref) {
|
|
3190
3972
|
var itemType = _ref.itemType,
|
|
3191
3973
|
collectionType = _ref.collectionType,
|
|
@@ -3194,7 +3976,7 @@ function MetadataType(_ref) {
|
|
|
3194
3976
|
_ref$flat = _ref.flat,
|
|
3195
3977
|
flat = _ref$flat === void 0 ? true : _ref$flat,
|
|
3196
3978
|
children = _ref.children,
|
|
3197
|
-
props = _objectWithoutProperties(_ref,
|
|
3979
|
+
props = _objectWithoutProperties(_ref, _excluded$7);
|
|
3198
3980
|
|
|
3199
3981
|
var entityType = itemType || collectionType || {};
|
|
3200
3982
|
var metadataType = entityType.metadata;
|
|
@@ -3578,6 +4360,7 @@ var VidispineApi = /*#__PURE__*/function (_React$Component) {
|
|
|
3578
4360
|
return VidispineApi;
|
|
3579
4361
|
}(React.Component);
|
|
3580
4362
|
|
|
4363
|
+
var _excluded$8 = ["LoginComponent", "LoginProps", "AppComponent", "AppProps", "onGetToken", "onSuccess", "onError", "cookieOptions"];
|
|
3581
4364
|
var VIDISPINE_TOKEN = 'VIDISPINE-TOKEN';
|
|
3582
4365
|
var VIDISPINE_USERNAME = 'VIDISPINE-USERNAME';
|
|
3583
4366
|
var VIDISPINE_SERVER_URL = 'VIDISPINE-SERVER-URL';
|
|
@@ -3643,7 +4426,7 @@ function Auth(_ref4) {
|
|
|
3643
4426
|
maxAge: 604800,
|
|
3644
4427
|
path: '/'
|
|
3645
4428
|
} : _ref4$cookieOptions,
|
|
3646
|
-
props = _objectWithoutProperties(_ref4,
|
|
4429
|
+
props = _objectWithoutProperties(_ref4, _excluded$8);
|
|
3647
4430
|
|
|
3648
4431
|
var _useCookies = useCookies([VIDISPINE_TOKEN, VIDISPINE_USERNAME, VIDISPINE_SERVER_URL, VIDISPINE_REMEMBER_ME]),
|
|
3649
4432
|
_useCookies2 = _slicedToArray(_useCookies, 3),
|
|
@@ -3939,11 +4722,13 @@ function HasRole(_ref) {
|
|
|
3939
4722
|
return null;
|
|
3940
4723
|
}
|
|
3941
4724
|
|
|
4725
|
+
var _excluded$9 = ["providers", "children"],
|
|
4726
|
+
_excluded2$2 = ["provider"];
|
|
3942
4727
|
function ComposeProviders(_ref) {
|
|
3943
4728
|
var _ref$providers = _ref.providers,
|
|
3944
4729
|
providers = _ref$providers === void 0 ? [] : _ref$providers,
|
|
3945
4730
|
children = _ref.children,
|
|
3946
|
-
props = _objectWithoutProperties(_ref,
|
|
4731
|
+
props = _objectWithoutProperties(_ref, _excluded$9);
|
|
3947
4732
|
|
|
3948
4733
|
return providers.reduceRight(function (acc, Provider) {
|
|
3949
4734
|
if (typeof Provider === 'function') {
|
|
@@ -3952,7 +4737,7 @@ function ComposeProviders(_ref) {
|
|
|
3952
4737
|
}
|
|
3953
4738
|
|
|
3954
4739
|
var ProviderComponent = Provider.provider,
|
|
3955
|
-
providerProps = _objectWithoutProperties(Provider,
|
|
4740
|
+
providerProps = _objectWithoutProperties(Provider, _excluded2$2);
|
|
3956
4741
|
|
|
3957
4742
|
return /*#__PURE__*/React.createElement(ProviderComponent // eslint-disable-next-line react/jsx-props-no-spreading
|
|
3958
4743
|
, _extends({}, props, providerProps), acc);
|
|
@@ -4797,5 +5582,5 @@ var handleMoveEntity = function handleMoveEntity(_ref3) {
|
|
|
4797
5582
|
}
|
|
4798
5583
|
};
|
|
4799
5584
|
|
|
4800
|
-
export { Auth, AuthContext, AuthProvider, BinContext, BinProvider, ComposeProviders, DropArea, ErrorBoundary, GetCollectionContent as GetCollection, GetFieldGroup, GetItem, GetJobs, HasRole, ListEntityAccess, MetadataType, RolesProvider, SearchCollection, SearchItem, SearchItemCollection, SettingsProvider, VidispineApi, compose, handleAddEntity, handleMoveEntity, handleRemoveEntity, useAddMetadataFieldAttributes, useApi, useAuthContext, useAutocomplete, useCollectionAutoPlay, useEntityAccess, useGetCollection, useGetCollection$1 as useGetCollectionItem, useGetEntity, useGetItem, useGroup, useInterval, useJobSearch, useListGroup, useListUser, useLocalStorage, useMouseDownPosition, useQueryInitialState, useRoles, useSavedSearch, useSearch, useSearchGroup, useSearchItem, useSearchUser, useSelected, useSettings, useSettingsActions, useTab, useThumbnailScrub, useUpdateEffect, useUpdateQueryState, useUploadFiles, useUser, withErrorBoundary };
|
|
5585
|
+
export { Auth, AuthContext, AuthProvider, BinContext, BinProvider, ComposeProviders, DropArea, ErrorBoundary, GetCollectionContent as GetCollection, GetFieldGroup, GetItem, GetJobs, HasRole, ListEntityAccess, MetadataType, RolesProvider, SearchCollection, SearchItem, SearchItemCollection, SettingsProvider, VidispineApi, compose, handleAddEntity, handleMoveEntity, handleRemoveEntity, useAddMetadataFieldAttributes, useApi, useAuthContext, useAutocomplete, useCollectionAutoPlay, useCsvDownload, useDocSearchAutocomplete, useEntityAccess, useGetCollection, useGetCollection$1 as useGetCollectionItem, useGetEntity, useGetFieldMetadataDataset, useGetItem, useGetSavedSearchFolders, useGroup, useHoverScrub, useInterval, useJobSearch, useListGroup, useListUser, useLocalStorage, useMouseDownPosition, useQueryInitialState, useRepresentativeItems, useRoles, useSavedSearch, useSearch, useSearchGroup, useSearchItem, useSearchUser, useSelected, useSettings, useSettingsActions, useTab, useThumbnailScrub, useUpdateEffect, useUpdateQueryState, useUploadFiles, useUser, withErrorBoundary };
|
|
4801
5586
|
//# sourceMappingURL=index.es.js.map
|