@vidispine/vdt-react 22.4.0 → 23.1.0-pre.2

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.
Files changed (67) hide show
  1. package/dist/DropArea.js +7 -0
  2. package/dist/context/AuthContext.js +15 -0
  3. package/dist/context/BinContext.js +12 -0
  4. package/dist/context/RolesContext.js +10 -0
  5. package/dist/context/SettingsContext.js +15 -0
  6. package/dist/hoc/compose.js +3 -0
  7. package/dist/hoc/withErrorBoundary.js +7 -0
  8. package/dist/hooks/useAddMetadataFieldAttributes.js +15 -0
  9. package/dist/hooks/useApi.js +10 -0
  10. package/dist/hooks/useAutocomplete.js +10 -0
  11. package/dist/hooks/useCollectionAutoPlay.js +10 -0
  12. package/dist/hooks/useCompoundMetadata.js +10 -0
  13. package/dist/hooks/useCsvDownload.js +10 -0
  14. package/dist/hooks/useDocSearchAutocomplete.js +11 -0
  15. package/dist/hooks/useEntityAccess.js +10 -0
  16. package/dist/hooks/useGetCollection.js +7 -0
  17. package/dist/hooks/useGetCollectionItem.js +7 -0
  18. package/dist/hooks/useGetEntity.js +16 -0
  19. package/dist/hooks/useGetEntityMetadata.js +7 -0
  20. package/dist/hooks/useGetFieldGroup.js +7 -0
  21. package/dist/hooks/useGetFieldMetadataDataset.js +6 -0
  22. package/dist/hooks/useGetItem.js +7 -0
  23. package/dist/hooks/useGetSavedSearchFolders.js +15 -0
  24. package/dist/hooks/useGroup.js +7 -0
  25. package/dist/hooks/useHoverScrub.js +17 -0
  26. package/dist/hooks/useInterval.js +5 -0
  27. package/dist/hooks/useJobSearch.js +9 -0
  28. package/dist/hooks/useListGroup.js +8 -0
  29. package/dist/hooks/useListUser.js +8 -0
  30. package/dist/hooks/useLocalStorage.js +6 -0
  31. package/dist/hooks/useMouseDownPosition.js +6 -0
  32. package/dist/hooks/useQueryInitialState.js +7 -0
  33. package/dist/hooks/useRepresentativeItems.js +12 -0
  34. package/dist/hooks/useSavedSearch.js +12 -0
  35. package/dist/hooks/useSearch.js +8 -0
  36. package/dist/hooks/useSearchGroup.js +11 -0
  37. package/dist/hooks/useSearchItem.js +7 -0
  38. package/dist/hooks/useSearchUser.js +11 -0
  39. package/dist/hooks/useSelected.js +7 -0
  40. package/dist/hooks/useTab.js +6 -0
  41. package/dist/hooks/useThumbnailScrub.js +6 -0
  42. package/dist/hooks/useUpdateEffect.js +6 -0
  43. package/dist/hooks/useUpdateQueryState.js +9 -0
  44. package/dist/hooks/useUploadFiles.js +13 -0
  45. package/dist/hooks/useUser.js +8 -0
  46. package/dist/index.js +61 -5236
  47. package/dist/moveEntity.js +6 -0
  48. package/dist/utils.js +7 -0
  49. package/dist/wrappers/Auth.js +11 -0
  50. package/dist/wrappers/ComposeProviders.js +7 -0
  51. package/dist/wrappers/ErrorBoundary.js +11 -0
  52. package/dist/wrappers/GetCollection.js +6 -0
  53. package/dist/wrappers/GetEntityMetadata.js +6 -0
  54. package/dist/wrappers/GetFieldGroup.js +6 -0
  55. package/dist/wrappers/GetItem.js +6 -0
  56. package/dist/wrappers/GetJobs.js +8 -0
  57. package/dist/wrappers/HasRole.js +6 -0
  58. package/dist/wrappers/ListEntityAccess.js +8 -0
  59. package/dist/wrappers/MetadataType.js +8 -0
  60. package/dist/wrappers/SearchCollection.js +8 -0
  61. package/dist/wrappers/SearchItem.js +6 -0
  62. package/dist/wrappers/SearchItemCollection.js +8 -0
  63. package/dist/wrappers/VidispineApi.js +11 -0
  64. package/package.json +10 -8
  65. package/dist/index.es.js +0 -5143
  66. package/dist/index.es.js.map +0 -1
  67. package/dist/index.js.map +0 -1
@@ -0,0 +1,8 @@
1
+ import _slicedToArray from '@babel/runtime/helpers/slicedToArray';
2
+ import _defineProperty from '@babel/runtime/helpers/defineProperty';
3
+ import _objectWithoutProperties from '@babel/runtime/helpers/objectWithoutProperties';
4
+ import { useReducer, useCallback } from 'react';
5
+
6
+ var _excluded=["queryParams","matrixParams","itemSearchDocument","rowsPerPage","page"];function ownKeys(object,enumerableOnly){var keys=Object.keys(object);if(Object.getOwnPropertySymbols){var symbols=Object.getOwnPropertySymbols(object);enumerableOnly&&(symbols=symbols.filter(function(sym){return Object.getOwnPropertyDescriptor(object,sym).enumerable;})),keys.push.apply(keys,symbols);}return keys;}function _objectSpread(target){for(var i=1;i<arguments.length;i++){var source=null!=arguments[i]?arguments[i]:{};i%2?ownKeys(Object(source),!0).forEach(function(key){_defineProperty(target,key,source[key]);}):Object.getOwnPropertyDescriptors?Object.defineProperties(target,Object.getOwnPropertyDescriptors(source)):ownKeys(Object(source)).forEach(function(key){Object.defineProperty(target,key,Object.getOwnPropertyDescriptor(source,key));});}return target;}var CHANGE_PAGE='CHANGE_PAGE';var CHANGE_ROWS='CHANGE_ROWS';var CHANGE_SORT='CHANGE_SORT';var CHANGE_SEARCHTEXT='CHANGE_SEARCHTEXT';var CHANGE_SEARCHFIELD='CHANGE_SEARCHFIELD';var CHANGE_SEARCHFIELDFACET='CHANGE_SEARCHFIELDFACET';var CHANGE_SEARCHFILTER='CHANGE_SEARCHFILTER';var CHANGE_SEARCHFILTERFACET='CHANGE_SEARCHFILTERFACET';var CHANGE_PARENT_COLLECTION='CHANGE_PARENT_COLLECTION';var CHANGE_FACET='CHANGE_FACET';var CHANGE_ITEMSEARCHDOCUMENT='CHANGE_ITEMSEARCHDOCUMENT';var CHANGE_QUERYPARAMS='CHANGE_QUERYPARAMS';var CHANGE_MATRIXPARAMS='CHANGE_MATRIXPARAMS';var CHANGE_SUGGESTION='CHANGE_SUGGESTION';var ACTION_TYPE={CHANGE_PAGE:CHANGE_PAGE,CHANGE_ROWS:CHANGE_ROWS,CHANGE_SORT:CHANGE_SORT,CHANGE_SEARCHTEXT:CHANGE_SEARCHTEXT,CHANGE_SEARCHFIELD:CHANGE_SEARCHFIELD,CHANGE_SEARCHFIELDFACET:CHANGE_SEARCHFIELDFACET,CHANGE_SEARCHFILTER:CHANGE_SEARCHFILTER,CHANGE_SEARCHFILTERFACET:CHANGE_SEARCHFILTERFACET,CHANGE_PARENT_COLLECTION:CHANGE_PARENT_COLLECTION,CHANGE_FACET:CHANGE_FACET,CHANGE_ITEMSEARCHDOCUMENT:CHANGE_ITEMSEARCHDOCUMENT,CHANGE_QUERYPARAMS:CHANGE_QUERYPARAMS,CHANGE_MATRIXPARAMS:CHANGE_MATRIXPARAMS,CHANGE_SUGGESTION:CHANGE_SUGGESTION};var setInitialDefaultState=function setInitialDefaultState(){var _ref=arguments.length>0&&arguments[0]!==undefined?arguments[0]:{},_ref$queryParams=_ref.queryParams,queryParams=_ref$queryParams===void 0?{}:_ref$queryParams,_ref$matrixParams=_ref.matrixParams,matrixParams=_ref$matrixParams===void 0?{}:_ref$matrixParams,_ref$itemSearchDocume=_ref.itemSearchDocument,itemSearchDocument=_ref$itemSearchDocume===void 0?{}:_ref$itemSearchDocume,_ref$rowsPerPage=_ref.rowsPerPage,rowsPerPage=_ref$rowsPerPage===void 0?10:_ref$rowsPerPage,_ref$page=_ref.page,page=_ref$page===void 0?0:_ref$page,state=_objectWithoutProperties(_ref,_excluded);return _objectSpread(_objectSpread({},state),{},{queryParams:_objectSpread({content:'metadata',interval:'generic'},queryParams),matrixParams:_objectSpread({first:page*rowsPerPage+1,number:rowsPerPage},matrixParams),itemSearchDocument:_objectSpread({intervals:'generic',filter:[]},itemSearchDocument),rowsPerPage:rowsPerPage,page:page});};var searchReducer=function searchReducer(state,action){switch(action.type){case ACTION_TYPE.CHANGE_ITEMSEARCHDOCUMENT:{return _objectSpread(_objectSpread({},state),{},{page:Number.isInteger(action.page)?action.page:state.page,itemSearchDocument:action.itemSearchDocument,matrixParams:_objectSpread(_objectSpread({},state.matrixParams),{},{first:Number.isInteger(action.page)?action.page*state.rowsPerPage+1:state.matrixParams.first})});}case ACTION_TYPE.CHANGE_QUERYPARAMS:{return _objectSpread(_objectSpread({},state),{},{queryParams:action.queryParams});}case ACTION_TYPE.CHANGE_MATRIXPARAMS:{return _objectSpread(_objectSpread({},state),{},{matrixParams:action.matrixParams});}case ACTION_TYPE.CHANGE_PAGE:{return _objectSpread(_objectSpread({},state),{},{page:action.page,matrixParams:_objectSpread(_objectSpread({},state.matrixParams),{},{first:action.page*state.rowsPerPage+1})});}case ACTION_TYPE.CHANGE_ROWS:{return _objectSpread(_objectSpread({},state),{},{rowsPerPage:action.rowsPerPage,page:0,matrixParams:_objectSpread(_objectSpread({},state.matrixParams),{},{first:1,number:action.rowsPerPage})});}case ACTION_TYPE.CHANGE_SORT:{return _objectSpread(_objectSpread({},state),{},{page:0,searchText:action.value,sort:action.value,itemSearchDocument:_objectSpread(_objectSpread({},state.itemSearchDocument),{},{sort:action.field?[{field:action.field,order:action.order||'descending'}]:[]}),matrixParams:_objectSpread(_objectSpread({},state.matrixParams),{},{first:1})});}case ACTION_TYPE.CHANGE_SEARCHTEXT:{return _objectSpread(_objectSpread({},state),{},{page:0,searchText:action.value,itemSearchDocument:action.value?_objectSpread(_objectSpread({},state.itemSearchDocument),{},{text:[{value:"".concat(action.value)}]}):_objectSpread(_objectSpread({},state.itemSearchDocument),{},{text:[]}),matrixParams:_objectSpread(_objectSpread({},state.matrixParams),{},{first:1})});}case ACTION_TYPE.CHANGE_SEARCHFIELD:{return _objectSpread(_objectSpread({},state),{},{page:0,field:action.field,itemSearchDocument:action.field?_objectSpread(_objectSpread({},state.itemSearchDocument),{},{field:action.field}):_objectSpread(_objectSpread({},state.itemSearchDocument),{},{field:[]}),matrixParams:_objectSpread(_objectSpread({},state.matrixParams),{},{first:1})});}case ACTION_TYPE.CHANGE_SEARCHFIELDFACET:{return _objectSpread(_objectSpread({},state),{},{page:0,field:action.field,facet:action.facet,itemSearchDocument:action.field?_objectSpread(_objectSpread({},state.itemSearchDocument),{},{field:action.field,facet:action.facet}):_objectSpread(_objectSpread({},state.itemSearchDocument),{},{field:[],facet:[]}),matrixParams:_objectSpread(_objectSpread({},state.matrixParams),{},{first:1})});}case ACTION_TYPE.CHANGE_SEARCHFILTER:{return _objectSpread(_objectSpread({},state),{},{page:0,filter:action.filter,itemSearchDocument:action.filter?_objectSpread(_objectSpread({},state.itemSearchDocument),{},{filter:action.filter}):_objectSpread(_objectSpread({},state.itemSearchDocument),{},{filter:[]}),matrixParams:_objectSpread(_objectSpread({},state.matrixParams),{},{first:1})});}case ACTION_TYPE.CHANGE_SEARCHFILTERFACET:{return _objectSpread(_objectSpread({},state),{},{page:0,filter:action.filter,itemSearchDocument:action.filter?_objectSpread(_objectSpread({},state.itemSearchDocument),{},{filter:action.filter,facet:action.facet}):_objectSpread(_objectSpread({},state.itemSearchDocument),{},{filter:[],facet:[]}),matrixParams:_objectSpread(_objectSpread({},state.matrixParams),{},{first:1})});}case ACTION_TYPE.CHANGE_FACET:{return _objectSpread(_objectSpread({},state),{},{page:0,facet:action.facet,itemSearchDocument:action.facet?_objectSpread(_objectSpread({},state.itemSearchDocument),{},{facet:action.facet}):_objectSpread(_objectSpread({},state.itemSearchDocument),{},{facet:[]}),matrixParams:_objectSpread(_objectSpread({},state.matrixParams),{},{first:1})});}case ACTION_TYPE.CHANGE_PARENT_COLLECTION:{return _objectSpread(_objectSpread({},state),{},{page:0,parentCollection:action.value,itemSearchDocument:action.value?_objectSpread(_objectSpread({},state.itemSearchDocument),{},{operator:{field:[{name:'__parent_collection',value:[{value:"".concat(action.value)}]},{name:'__collection',value:[{value:"".concat(action.value)}]}],operation:'OR'}}):_objectSpread(_objectSpread({},state.itemSearchDocument),{},{operator:undefined}),matrixParams:_objectSpread(_objectSpread({},state.matrixParams),{},{first:1})});}case ACTION_TYPE.CHANGE_SUGGESTION:{return _objectSpread(_objectSpread({},state),{},{itemSearchDocument:_objectSpread(_objectSpread({},state.itemSearchDocument),{},{suggestion:action.suggestion})});}default:{return state;}}};function useSearch(initialState){var initialDefaultState=setInitialDefaultState(initialState);var _useReducer=useReducer(searchReducer,initialDefaultState),_useReducer2=_slicedToArray(_useReducer,2),state=_useReducer2[0],dispatch=_useReducer2[1];var onChangeRowsPerPage=function onChangeRowsPerPage(){var _ref2=arguments.length>0&&arguments[0]!==undefined?arguments[0]:{},newRows=_ref2.target.value;return dispatch({type:ACTION_TYPE.CHANGE_ROWS,rowsPerPage:newRows});};var onChangePage=function onChangePage(_ref3){var newPage=_ref3.page;return dispatch({type:ACTION_TYPE.CHANGE_PAGE,page:newPage});};var onChangeSort=function onChangeSort(event,field,order){return dispatch({type:ACTION_TYPE.CHANGE_SORT,field:field,order:order});};var setSearchText=useCallback(function(value){return dispatch({type:ACTION_TYPE.CHANGE_SEARCHTEXT,value:value});},[]);var setItemSearchDocument=useCallback(function(itemSearchDocument,page){return dispatch({type:ACTION_TYPE.CHANGE_ITEMSEARCHDOCUMENT,itemSearchDocument:itemSearchDocument,page:page});},[]);var setQueryParams=useCallback(function(queryParams){return dispatch({type:ACTION_TYPE.CHANGE_QUERYPARAMS,queryParams:queryParams});},[]);var setMatrixParams=useCallback(function(matrixParams){return dispatch({type:ACTION_TYPE.CHANGE_MATRIXPARAMS,matrixParams:matrixParams});},[]);var setSearchField=useCallback(function(field){return dispatch({type:ACTION_TYPE.CHANGE_SEARCHFIELD,field:field});},[]);var setSearchFieldFacet=useCallback(function(field){var facet=field.map(function(_ref4){var name=_ref4.name;return {field:name,count:true};});dispatch({type:ACTION_TYPE.CHANGE_SEARCHFIELDFACET,field:field,facet:facet});},[]);var setSearchFilter=useCallback(function(filter){return dispatch({type:ACTION_TYPE.CHANGE_SEARCHFILTER,filter:filter});},[]);var setSearchFilterFacet=useCallback(function(filter){var fieldList=filter.reduce(function(a,_ref5){var _ref5$field=_ref5.field,field=_ref5$field===void 0?[]:_ref5$field;return a.concat(field);},[]);var facet=fieldList.map(function(_ref6){var name=_ref6.name;return {name:name,field:name,count:true,exclude:[name]};});dispatch({type:ACTION_TYPE.CHANGE_SEARCHFILTERFACET,filter:filter,facet:facet});},[dispatch]);var setFacet=useCallback(function(facet){dispatch({type:ACTION_TYPE.CHANGE_FACET,facet:facet});},[dispatch]);var setParentCollection=useCallback(function(value){return dispatch({type:ACTION_TYPE.CHANGE_PARENT_COLLECTION,value:value});},[]);var setSuggestion=useCallback(function(suggestion){dispatch({type:ACTION_TYPE.CHANGE_SUGGESTION,suggestion:suggestion});},[]);return {state:state,onChangeRowsPerPage:onChangeRowsPerPage,onChangePage:onChangePage,onChangeSort:onChangeSort,setSearchText:setSearchText,setSearchField:setSearchField,setSearchFieldFacet:setSearchFieldFacet,setSearchFilter:setSearchFilter,setSearchFilterFacet:setSearchFilterFacet,setFacet:setFacet,setItemSearchDocument:setItemSearchDocument,setQueryParams:setQueryParams,setMatrixParams:setMatrixParams,setParentCollection:setParentCollection,setSuggestion:setSuggestion};}
7
+
8
+ export { useSearch as default };
@@ -0,0 +1,11 @@
1
+ import _typeof from '@babel/runtime/helpers/typeof';
2
+ import _slicedToArray from '@babel/runtime/helpers/slicedToArray';
3
+ import _defineProperty from '@babel/runtime/helpers/defineProperty';
4
+ import { useReducer, useEffect } from 'react';
5
+ import { group } from '@vidispine/vdt-api';
6
+ import useApi from './useApi.js';
7
+
8
+ function ownKeys(object,enumerableOnly){var keys=Object.keys(object);if(Object.getOwnPropertySymbols){var symbols=Object.getOwnPropertySymbols(object);enumerableOnly&&(symbols=symbols.filter(function(sym){return Object.getOwnPropertyDescriptor(object,sym).enumerable;})),keys.push.apply(keys,symbols);}return keys;}function _objectSpread(target){for(var i=1;i<arguments.length;i++){var source=null!=arguments[i]?arguments[i]:{};i%2?ownKeys(Object(source),!0).forEach(function(key){_defineProperty(target,key,source[key]);}):Object.getOwnPropertyDescriptors?Object.defineProperties(target,Object.getOwnPropertyDescriptors(source)):ownKeys(Object(source)).forEach(function(key){Object.defineProperty(target,key,Object.getOwnPropertyDescriptor(source,key));});}return target;}var CHANGE_PAGE='CHANGE_PAGE';var CHANGE_ROWS='CHANGE_ROWS';var CHANGE_SORT='CHANGE_SORT';var CHANGE_QUERY='CHANGE_QUERY';var HIDE_ROLES='HIDE_ROLES';var ACTION_TYPE={CHANGE_PAGE:CHANGE_PAGE,CHANGE_ROWS:CHANGE_ROWS,CHANGE_SORT:CHANGE_SORT,CHANGE_QUERY:CHANGE_QUERY,HIDE_ROLES:HIDE_ROLES};var setInitialDefaultState=function setInitialDefaultState(){var _ref=arguments.length>0&&arguments[0]!==undefined?arguments[0]:{},_ref$queryParams=_ref.queryParams,queryParams=_ref$queryParams===void 0?{}:_ref$queryParams,_ref$rowsPerPage=_ref.rowsPerPage,rowsPerPage=_ref$rowsPerPage===void 0?10:_ref$rowsPerPage,_ref$page=_ref.page,page=_ref$page===void 0?0:_ref$page;return {queryParams:_objectSpread({first:page*rowsPerPage+1,number:rowsPerPage},queryParams),rowsPerPage:rowsPerPage,page:page,groupSearchDocument:{}};};var searchReducer=function searchReducer(state,action){var type=action.type;switch(type){case ACTION_TYPE.CHANGE_PAGE:{var page=action.page;return _objectSpread(_objectSpread({},state),{},{page:page,queryParams:_objectSpread(_objectSpread({},state.queryParams),{},{first:page*state.rowsPerPage+1})});}case ACTION_TYPE.CHANGE_ROWS:{var rowsPerPage=action.rowsPerPage;return _objectSpread(_objectSpread({},state),{},{rowsPerPage:rowsPerPage,page:0,queryParams:_objectSpread(_objectSpread({},state.queryParams),{},{first:1,number:rowsPerPage})});}case ACTION_TYPE.HIDE_ROLES:{var hideRoles=action.hideRoles;var role=hideRoles===true?false:undefined;return _objectSpread(_objectSpread({},state),{},{page:0,queryParams:_objectSpread(_objectSpread({},state.queryParams),{},{first:1,role:role})});}case ACTION_TYPE.CHANGE_QUERY:{return _objectSpread(_objectSpread({},state),{},{page:0,groupSearchDocument:_objectSpread(_objectSpread({},state.groupSearchDocument),{},{field:[{name:action.field||'groupname',value:action.query||''}]}),queryParams:_objectSpread(_objectSpread({},state.queryParams),{},{first:1})});}default:return state;}};function useSearchGroup(initialState){var initialDefaultState=setInitialDefaultState(initialState);var _useReducer=useReducer(searchReducer,initialDefaultState),_useReducer2=_slicedToArray(_useReducer,2),state=_useReducer2[0],dispatch=_useReducer2[1];var _useApi=useApi(group.searchGroup),groupListDocument=_useApi.data,searchGroup=_useApi.request,hasLoaded=_useApi.hasLoaded,isError=_useApi.isError;var onSearchGroup=function onSearchGroup(){return searchGroup({groupSearchDocument:state.groupSearchDocument,queryParams:state.queryParams});};useEffect(function(){onSearchGroup();// eslint-disable-next-line react-hooks/exhaustive-deps
9
+ },[state.queryParams,state.groupSearchDocument]);var onChangeRowsPerPage=function onChangeRowsPerPage(){var _ref2=arguments.length>0&&arguments[0]!==undefined?arguments[0]:{},rowsPerPage=_ref2.target.value;return dispatch({type:ACTION_TYPE.CHANGE_ROWS,rowsPerPage:rowsPerPage});};var onChangePage=function onChangePage(_ref3){var page=_ref3.page;return dispatch({type:ACTION_TYPE.CHANGE_PAGE,page:page});};var onHideRoles=function onHideRoles(_ref4){var hideRoles=_ref4.hideRoles;return dispatch({type:ACTION_TYPE.HIDE_ROLES,hideRoles:hideRoles});};var onChangeSort=function onChangeSort(event,field,order){var fieldName=_typeof(field)==='object'?field.value:field;dispatch({type:ACTION_TYPE.CHANGE_SORT,field:fieldName,order:order});};var onChangeQuery=function onChangeQuery(field,query){dispatch({type:ACTION_TYPE.CHANGE_QUERY,field:field,query:query});};return _objectSpread(_objectSpread({},state),{},{hasLoaded:hasLoaded,isError:isError,groupListDocument:groupListDocument,onSearchGroup:onSearchGroup,onChangePage:onChangePage,onChangeSort:onChangeSort,onChangeRowsPerPage:onChangeRowsPerPage,onChangeQuery:onChangeQuery,onHideRoles:onHideRoles});}
10
+
11
+ export { useSearchGroup as default };
@@ -0,0 +1,7 @@
1
+ import useDeepCompareEffect from 'use-deep-compare-effect';
2
+ import { item } from '@vidispine/vdt-api';
3
+ import useApi from './useApi.js';
4
+
5
+ function useSearchItem(_ref){var itemSearchDocument=_ref.itemSearchDocument,queryParams=_ref.queryParams,matrixParams=_ref.matrixParams;var _useApi=useApi(item.searchItem),request=_useApi.request,_useApi$data=_useApi.data,itemListType=_useApi$data===void 0?{}:_useApi$data,isLoading=_useApi.isLoading,isError=_useApi.isError,cancel=_useApi.cancel;var onRefresh=function onRefresh(){return request({itemSearchDocument:itemSearchDocument,queryParams:queryParams,matrixParams:matrixParams});};useDeepCompareEffect(function(){onRefresh();},[itemSearchDocument,queryParams,matrixParams]);return {itemListType:itemListType,isLoading:isLoading,isError:isError,onRefresh:onRefresh,cancel:cancel};}
6
+
7
+ export { useSearchItem as default };
@@ -0,0 +1,11 @@
1
+ import _typeof from '@babel/runtime/helpers/typeof';
2
+ import _slicedToArray from '@babel/runtime/helpers/slicedToArray';
3
+ import _defineProperty from '@babel/runtime/helpers/defineProperty';
4
+ import { useReducer, useEffect } from 'react';
5
+ import { user } from '@vidispine/vdt-api';
6
+ import useApi from './useApi.js';
7
+
8
+ function ownKeys(object,enumerableOnly){var keys=Object.keys(object);if(Object.getOwnPropertySymbols){var symbols=Object.getOwnPropertySymbols(object);enumerableOnly&&(symbols=symbols.filter(function(sym){return Object.getOwnPropertyDescriptor(object,sym).enumerable;})),keys.push.apply(keys,symbols);}return keys;}function _objectSpread(target){for(var i=1;i<arguments.length;i++){var source=null!=arguments[i]?arguments[i]:{};i%2?ownKeys(Object(source),!0).forEach(function(key){_defineProperty(target,key,source[key]);}):Object.getOwnPropertyDescriptors?Object.defineProperties(target,Object.getOwnPropertyDescriptors(source)):ownKeys(Object(source)).forEach(function(key){Object.defineProperty(target,key,Object.getOwnPropertyDescriptor(source,key));});}return target;}var CHANGE_PAGE='CHANGE_PAGE';var CHANGE_ROWS='CHANGE_ROWS';var CHANGE_SORT='CHANGE_SORT';var CHANGE_QUERY='CHANGE_QUERY';var ACTION_TYPE={CHANGE_PAGE:CHANGE_PAGE,CHANGE_ROWS:CHANGE_ROWS,CHANGE_SORT:CHANGE_SORT,CHANGE_QUERY:CHANGE_QUERY};var setInitialDefaultState=function setInitialDefaultState(){var _ref=arguments.length>0&&arguments[0]!==undefined?arguments[0]:{},_ref$queryParams=_ref.queryParams,queryParams=_ref$queryParams===void 0?{}:_ref$queryParams,_ref$rowsPerPage=_ref.rowsPerPage,rowsPerPage=_ref$rowsPerPage===void 0?10:_ref$rowsPerPage,_ref$page=_ref.page,page=_ref$page===void 0?0:_ref$page;return {queryParams:_objectSpread({first:page*rowsPerPage+1,number:rowsPerPage},queryParams),rowsPerPage:rowsPerPage,page:page,userSearchDocument:{sort:[{field:'username',order:'ascending'}]}};};var searchReducer=function searchReducer(state,action){var type=action.type;switch(type){case ACTION_TYPE.CHANGE_PAGE:{var page=action.page;return _objectSpread(_objectSpread({},state),{},{page:page,queryParams:_objectSpread(_objectSpread({},state.queryParams),{},{first:page*state.rowsPerPage+1})});}case ACTION_TYPE.CHANGE_ROWS:{var rowsPerPage=action.rowsPerPage;return _objectSpread(_objectSpread({},state),{},{rowsPerPage:rowsPerPage,page:0,queryParams:_objectSpread(_objectSpread({},state.queryParams),{},{first:1,number:rowsPerPage})});}case ACTION_TYPE.CHANGE_QUERY:{return _objectSpread(_objectSpread({},state),{},{page:0,userSearchDocument:_objectSpread(_objectSpread({},state.userSearchDocument),{},{field:[{name:action.field||'username',value:action.query||''}]}),queryParams:_objectSpread(_objectSpread({},state.queryParams),{},{first:1})});}default:return state;}};function useSearchUser(initialState){var initialDefaultState=setInitialDefaultState(initialState);var _useReducer=useReducer(searchReducer,initialDefaultState),_useReducer2=_slicedToArray(_useReducer,2),state=_useReducer2[0],dispatch=_useReducer2[1];var _useApi=useApi(user.searchUser),userListDocument=_useApi.data,searchUser=_useApi.request,hasLoaded=_useApi.hasLoaded,isError=_useApi.isError;var onSearchUser=function onSearchUser(){return searchUser({userSearchDocument:state.userSearchDocument,queryParams:state.queryParams});};useEffect(function(){onSearchUser();// eslint-disable-next-line react-hooks/exhaustive-deps
9
+ },[state.queryParams,state.userSearchDocument]);var onChangeRowsPerPage=function onChangeRowsPerPage(){var _ref2=arguments.length>0&&arguments[0]!==undefined?arguments[0]:{},rowsPerPage=_ref2.target.value;return dispatch({type:ACTION_TYPE.CHANGE_ROWS,rowsPerPage:rowsPerPage});};var onChangePage=function onChangePage(_ref3){var page=_ref3.page;return dispatch({type:ACTION_TYPE.CHANGE_PAGE,page:page});};var onChangeSort=function onChangeSort(event,field,order){var fieldName=_typeof(field)==='object'?field.value:field;dispatch({type:ACTION_TYPE.CHANGE_SORT,field:fieldName,order:order});};var onChangeQuery=function onChangeQuery(field,query){dispatch({type:ACTION_TYPE.CHANGE_QUERY,field:field,query:query});};return _objectSpread(_objectSpread({},state),{},{hasLoaded:hasLoaded,isError:isError,userListDocument:userListDocument,onSearchUser:onSearchUser,onChangePage:onChangePage,onChangeSort:onChangeSort,onChangeRowsPerPage:onChangeRowsPerPage,onChangeQuery:onChangeQuery});}
10
+
11
+ export { useSearchUser as default };
@@ -0,0 +1,7 @@
1
+ import _toConsumableArray from '@babel/runtime/helpers/toConsumableArray';
2
+ import _slicedToArray from '@babel/runtime/helpers/slicedToArray';
3
+ import { useState } from 'react';
4
+
5
+ var useSelected = (function(){var propKey=arguments.length>0&&arguments[0]!==undefined?arguments[0]:'id';var initialState=arguments.length>1&&arguments[1]!==undefined?arguments[1]:[];var _useState=useState(initialState),_useState2=_slicedToArray(_useState,2),selected=_useState2[0],setSelected=_useState2[1];var onSelect=function onSelect(event,checked,props){var propValue=props[propKey];var currentIndex=selected.findIndex(function(thisSelected){return thisSelected[propKey]===propValue;});if(currentIndex===-1&&checked===true){if(checked===true){setSelected([].concat(_toConsumableArray(selected),[props]));}}else if(currentIndex>-1&&checked===false){var newSelected=_toConsumableArray(selected);newSelected.splice(currentIndex,1);setSelected(newSelected);}};var isSelected=function isSelected(props){var propValue=props[propKey];var currentIndex=selected.findIndex(function(thisSelected){return thisSelected[propKey]===propValue;});return currentIndex>-1;};var onClear=function onClear(){return setSelected([]);};return {selected:selected,onSelect:onSelect,onClear:onClear,isSelected:isSelected};});
6
+
7
+ export { useSelected as default };
@@ -0,0 +1,6 @@
1
+ import _slicedToArray from '@babel/runtime/helpers/slicedToArray';
2
+ import { useState } from 'react';
3
+
4
+ var useTab = (function(initialTab){var _useState=useState(initialTab),_useState2=_slicedToArray(_useState,2),activeTab=_useState2[0],setActiveTab=_useState2[1];var changeTab=function changeTab(_,newValue){return setActiveTab(newValue);};return {activeTab:activeTab,changeTab:changeTab};});
5
+
6
+ export { useTab as default };
@@ -0,0 +1,6 @@
1
+ import _slicedToArray from '@babel/runtime/helpers/slicedToArray';
2
+ import { useRef, useMemo, useState, useEffect } from 'react';
3
+
4
+ function useThumbnailScrub(){var srcList=arguments.length>0&&arguments[0]!==undefined?arguments[0]:[];var savedInterval=useRef();var initialImgIdx=useMemo(function(){return Math.floor(srcList.length/2);},[srcList]);var _useState=useState(),_useState2=_slicedToArray(_useState,2),imgIdx=_useState2[0],setImgIdx=_useState2[1];var imgIdxRef=useRef(imgIdx);useEffect(function(){return function(){return savedInterval.current&&clearInterval(savedInterval.current);};},[]);if(srcList.length===0)return {width:0};imgIdxRef.current=imgIdx;var onMouseEnter=function onMouseEnter(){var delay=500;var tick=function tick(){if(imgIdxRef.current===undefined){setImgIdx(0);}else if(imgIdxRef.current===srcList.length-1){clearInterval(savedInterval.current);}else {setImgIdx(imgIdxRef.current+1);}};savedInterval.current=setInterval(tick,delay);};var onMouseLeave=function onMouseLeave(){setImgIdx();clearInterval(savedInterval.current);};var imageSrc=srcList[imgIdx===undefined?initialImgIdx:imgIdx];var width=imgIdx===undefined?0:"".concat(Math.floor(imgIdx/(srcList.length-1)*100),"%");return {imageSrc:imageSrc,onMouseEnter:onMouseEnter,onMouseLeave:onMouseLeave,width:width};}
5
+
6
+ export { useThumbnailScrub as default };
@@ -0,0 +1,6 @@
1
+ import { useRef, useEffect } from 'react';
2
+
3
+ function useUpdateEffect(fn,inputs){var hasMountedRef=useRef(false);useEffect(function(){if(hasMountedRef.current){fn();}else {hasMountedRef.current=true;}// eslint-disable-next-line react-hooks/exhaustive-deps
4
+ },inputs);}
5
+
6
+ export { useUpdateEffect as default };
@@ -0,0 +1,9 @@
1
+ import { useCallback } from 'react';
2
+ import { b64EncodeUnicode } from '../utils.js';
3
+ import useUpdateEffect from './useUpdateEffect.js';
4
+
5
+ // TODO: change to expose "onNavigate" and take in "path" and "search" strings
6
+ function useUpdateQueryState(_ref){var history=_ref.history,navigate=_ref.navigate,propLocation=_ref.location,state=_ref.state,_ref$queryName=_ref.queryName,queryName=_ref$queryName===void 0?'q':_ref$queryName;var onSearchStateChange=useCallback(function(){var _ref2=history||{},_ref2$location=_ref2.location,location=_ref2$location===void 0?propLocation:_ref2$location;var encodedQuery=b64EncodeUnicode(JSON.stringify(state));if(history){history.replace({pathName:location.pathName,search:"?".concat(queryName,"=").concat(encodedQuery)});}else if(navigate){navigate("".concat(location.pathName,"?").concat(queryName,"=").concat(encodedQuery),{replace:true});}},[history,navigate,propLocation,queryName,state]);// Don't need to set query on mount
7
+ useUpdateEffect(function(){onSearchStateChange(state);},[onSearchStateChange,state]);}
8
+
9
+ export { useUpdateQueryState as default };
@@ -0,0 +1,13 @@
1
+ import _toConsumableArray from '@babel/runtime/helpers/toConsumableArray';
2
+ import _objectWithoutProperties from '@babel/runtime/helpers/objectWithoutProperties';
3
+ import _slicedToArray from '@babel/runtime/helpers/slicedToArray';
4
+ import _defineProperty from '@babel/runtime/helpers/defineProperty';
5
+ import { useState, useEffect, useCallback } from 'react';
6
+ import { vsimport, collection, ChunkedUpload } from '@vidispine/vdt-api';
7
+ import { createMetadataType } from '@vidispine/vdt-js';
8
+ import { uuidv4 } from '../utils.js';
9
+
10
+ var _excluded=["onUploadFile","initialMetadata"];function ownKeys(object,enumerableOnly){var keys=Object.keys(object);if(Object.getOwnPropertySymbols){var symbols=Object.getOwnPropertySymbols(object);enumerableOnly&&(symbols=symbols.filter(function(sym){return Object.getOwnPropertyDescriptor(object,sym).enumerable;})),keys.push.apply(keys,symbols);}return keys;}function _objectSpread(target){for(var i=1;i<arguments.length;i++){var source=null!=arguments[i]?arguments[i]:{};i%2?ownKeys(Object(source),!0).forEach(function(key){_defineProperty(target,key,source[key]);}):Object.getOwnPropertyDescriptors?Object.defineProperties(target,Object.getOwnPropertyDescriptors(source)):ownKeys(Object(source)).forEach(function(key){Object.defineProperty(target,key,Object.getOwnPropertyDescriptor(source,key));});}return target;}var DEFAULT_AUDIO_SHAPETAGS=['__mp3_160k'];var DEFAULT_VIDEO_SHAPETAGS=['__mp4'];var DEFAULT_IMAGE_SHAPETAGS=['__png'];var AUDIO_MIMETYPE_PREFIX='audio';var VIDEO_MIMETYPE_PREFIX='video';var IMAGE_MIMETYPE_PREFIX='image';var ADDITIONAL_VIDEO_MIMETYPES=['application/mxf'];var ADDITIONAL_IMAGE_MIMETYPES=[];var ADDITIONAL_AUDIO_MIMETYPES=[];var getDefaultShapeTags=function getDefaultShapeTags(file){if(!file||!file.type)return [];var mimeType=file.type.toLowerCase();if(mimeType.startsWith(AUDIO_MIMETYPE_PREFIX)||ADDITIONAL_AUDIO_MIMETYPES.includes(mimeType))return DEFAULT_AUDIO_SHAPETAGS;if(mimeType.startsWith(VIDEO_MIMETYPE_PREFIX)||ADDITIONAL_VIDEO_MIMETYPES.includes(mimeType))return DEFAULT_VIDEO_SHAPETAGS;if(mimeType.startsWith(IMAGE_MIMETYPE_PREFIX)||ADDITIONAL_IMAGE_MIMETYPES.includes(mimeType))return DEFAULT_IMAGE_SHAPETAGS;return [];};var chunkedUpload=function chunkedUpload(file){var props=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{};return new Promise(function(resolve,reject){var uploadInstance=new ChunkedUpload(file,_objectSpread({onFail:function onFail(error){return reject(error);},onComplete:function onComplete(resp){return resolve(resp);}},props));uploadInstance.upload();});};var onUploadFile=function onUploadFile(_ref){var file=_ref.file,collectionId=_ref.collectionId,onProgress=_ref.onProgress,_ref$metadata=_ref.metadata,propsMetadata=_ref$metadata===void 0?{}:_ref$metadata,_ref$placeholderParam=_ref.placeholderParams,placeholderParams=_ref$placeholderParam===void 0?{}:_ref$placeholderParam,_ref$importParams=_ref.importParams,importParams=_ref$importParams===void 0?{}:_ref$importParams,_ref$chunkedUploadPro=_ref.chunkedUploadProps,chunkedUploadProps=_ref$chunkedUploadPro===void 0?{}:_ref$chunkedUploadPro,_ref$generateTransfer=_ref.generateTransferId,generateTransferId=_ref$generateTransfer===void 0?uuidv4:_ref$generateTransfer,_ref$getShapeTags=_ref.getShapeTags,getShapeTags=_ref$getShapeTags===void 0?getDefaultShapeTags:_ref$getShapeTags;return new Promise(function(resolve,reject){try{var itemId;onProgress({});var shapeTags=getShapeTags(file);var filename=file.name;var mimeType=file.type;var _mimeType$split=mimeType.split('/'),_mimeType$split2=_slicedToArray(_mimeType$split,1),mediaType=_mimeType$split2[0];var metadata=_objectSpread({originalFilename:filename,mimeType:mimeType,mediaType:mediaType},propsMetadata);var metadataDocument=createMetadataType(metadata);vsimport.createImportPlaceholder({metadataDocument:metadataDocument,queryParams:_objectSpread({container:1},placeholderParams)}).then(function(_ref2){var itemDocument=_ref2.data;itemId=itemDocument.id;if(!collectionId)return Promise.resolve();var collectionIds=Array.isArray(collectionId)?collectionId:[collectionId];return Promise.all(collectionIds.map(function(id){return collection.addCollectionEntity({collectionId:id,entityId:itemId});}));}).then(function(){var transferId=generateTransferId();var queryParams=_objectSpread({filename:filename,transferId:transferId,tag:shapeTags},importParams);return chunkedUpload(file,_objectSpread({api:{method:vsimport.createImportComponentRaw,props:{itemId:itemId,component:'container',queryParams:queryParams}},onProgress:onProgress},chunkedUploadProps));}).then(function(response){resolve(_objectSpread(_objectSpread({},response),{},{itemId:itemId,collectionId:collectionId}));})["catch"](function(error){return reject(error);});}catch(err){/* eslint-disable-next-line no-console */console.error(err);reject(err);}});};function useUploadFiles(_ref3){var _ref3$onUploadFile=_ref3.onUploadFile,handleUploadFile=_ref3$onUploadFile===void 0?onUploadFile:_ref3$onUploadFile,_ref3$initialMetadata=_ref3.initialMetadata,initialMetadata=_ref3$initialMetadata===void 0?{}:_ref3$initialMetadata,props=_objectWithoutProperties(_ref3,_excluded);var _useState=useState([]),_useState2=_slicedToArray(_useState,2),files=_useState2[0],setFiles=_useState2[1];useEffect(function(){return function(){// Make sure to revoke the data uris to avoid memory leaks
11
+ files.forEach(function(file){return URL.revokeObjectURL(file.preview);});};},[files]);var onAddFiles=useCallback(function(){var newFiles=arguments.length>0&&arguments[0]!==undefined?arguments[0]:[];var newFilesObj=newFiles.map(function(file){return {file:file,metadata:_objectSpread({title:file.name},initialMetadata)};});setFiles(function(currentFiles){return newFilesObj.concat(currentFiles);});},[initialMetadata]);var onChangeFile=useCallback(function(idx){var changeFile=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{};setFiles(function(currentFilesList){var currentFile=currentFilesList[idx];var newMetadata=changeFile.metadata,newProgress=changeFile.progress;var _currentFile$metadata=currentFile.metadata,currentMetadata=_currentFile$metadata===void 0?{}:_currentFile$metadata,_currentFile$progress=currentFile.progress,currentProgress=_currentFile$progress===void 0?{}:_currentFile$progress;var newFilesList=_toConsumableArray(currentFilesList);var newFile=_objectSpread({},currentFile);if(newMetadata)newFile.metadata=_objectSpread(_objectSpread({},currentMetadata),newMetadata);if(newProgress)newFile.progress=_objectSpread(_objectSpread({},currentProgress),newProgress);newFilesList[idx]=newFile;return newFilesList;});},[setFiles]);var onChangeProgress=useCallback(function(idx){return function(){var newProgress=arguments.length>0&&arguments[0]!==undefined?arguments[0]:{};onChangeFile(idx,{progress:newProgress});};},[onChangeFile]);var onChangeMetadata=useCallback(function(idx){return function(){var newMetadata=arguments.length>0&&arguments[0]!==undefined?arguments[0]:{};onChangeFile(idx,{metadata:newMetadata});};},[onChangeFile]);var onUpload=useCallback(function(uploadProps){return files.reduce(function(previousPromise,thisFile,idx){return previousPromise.then(function(res){if(thisFile.progress){return previousPromise;}return handleUploadFile(_objectSpread(_objectSpread({file:thisFile.file,onProgress:onChangeProgress(idx),metadata:thisFile.metadata},uploadProps),props)).then(function(currentResult){return [].concat(_toConsumableArray(res),[currentResult]);});});},Promise.resolve([]));},[files,handleUploadFile,onChangeProgress,props]);var onRemoveFile=useCallback(function(idx){return function(){setFiles(_toConsumableArray(files).filter(function(_,i){return i!==idx;}));};},[setFiles,files]);var onRemoveFiles=useCallback(function(idxs){return function(){setFiles(_toConsumableArray(files).filter(function(_,i){return !idxs.includes(i);}));};},[setFiles,files]);return {onAddFiles:onAddFiles,onChangeFile:onChangeFile,onChangeMetadata:onChangeMetadata,onUpload:onUpload,onRemoveFile:onRemoveFile,onRemoveFiles:onRemoveFiles,files:files,setFiles:setFiles};}
12
+
13
+ export { useUploadFiles as default };
@@ -0,0 +1,8 @@
1
+ import _defineProperty from '@babel/runtime/helpers/defineProperty';
2
+ import { useCallback, useEffect } from 'react';
3
+ import { user, group } from '@vidispine/vdt-api';
4
+ import useApi from './useApi.js';
5
+
6
+ function ownKeys(object,enumerableOnly){var keys=Object.keys(object);if(Object.getOwnPropertySymbols){var symbols=Object.getOwnPropertySymbols(object);enumerableOnly&&(symbols=symbols.filter(function(sym){return Object.getOwnPropertyDescriptor(object,sym).enumerable;})),keys.push.apply(keys,symbols);}return keys;}function _objectSpread(target){for(var i=1;i<arguments.length;i++){var source=null!=arguments[i]?arguments[i]:{};i%2?ownKeys(Object(source),!0).forEach(function(key){_defineProperty(target,key,source[key]);}):Object.getOwnPropertyDescriptors?Object.defineProperties(target,Object.getOwnPropertyDescriptors(source)):ownKeys(Object(source)).forEach(function(key){Object.defineProperty(target,key,Object.getOwnPropertyDescriptor(source,key));});}return target;}function useUser(initialState){var _useApi=useApi(user.getUser,{data:initialState}),userType=_useApi.data,request=_useApi.request;var _ref=userType||{},userName=_ref.userName;var getUser=useCallback(function(){return request({userName:userName});},[request,userName]);useEffect(function(){if(userName)getUser();},[getUser,userName]);var updateUser=useCallback(function(_ref2){var userDocument=_ref2.userDocument;return user.updateUser({userName:userName,userDocument:userDocument}).then(function(){return request({userName:userDocument.userName});});},[request,userName]);var updateUserGroups=useCallback(function(_ref3){var _ref3$groups=_ref3.groups,groups=_ref3$groups===void 0?[]:_ref3$groups;return user.updateUserGroup({userName:userName,groupListDocument:{group:groups.map(function(g){return {groupName:g};})}}).then(getUser);},[getUser,userName]);var removeUserFromGroup=useCallback(function(groupName){return group.removeGroupUser({groupName:groupName,userName:userName}).then(getUser);},[getUser,userName]);var changePassword=useCallback(function(password){return user.updateUser({userName:userName,userDocument:{password:password},queryParams:{passwordType:'raw'}});},[userName]);var deleteUser=function deleteUser(){var _ref4=arguments.length>0&&arguments[0]!==undefined?arguments[0]:{},_ref4$queryParams=_ref4.queryParams,queryParams=_ref4$queryParams===void 0?{}:_ref4$queryParams;return user.disableUser({userName:userName,queryParams:_objectSpread({hard:true},queryParams)});};var disableUser=function disableUser(args){return user.disableUser(_objectSpread({userName:userName},args)).then(getUser);};var enableUser=function enableUser(args){return user.enableUser(_objectSpread({userName:userName},args)).then(getUser);};return {userType:userType,getUser:getUser,updateUser:updateUser,updateUserGroups:updateUserGroups,removeUserFromGroup:removeUserFromGroup,disableUser:disableUser,enableUser:enableUser,deleteUser:deleteUser,changePassword:changePassword};}
7
+
8
+ export { useUser as default };