@livetiles/reach-components-react 0.4.0-preview.239 → 0.4.0-preview.241
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/NewsGrid.d.ts +1 -0
- package/NewsList.d.ts +1 -0
- package/common/utils.d.ts +1 -1
- package/index.d.ts +2 -0
- package/index.esm2.js +12 -10
- package/index.umd.js +12 -10
- package/package.json +1 -1
package/NewsGrid.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ import { NewsItem } from '@livetiles/reach/util/common';
|
|
|
3
3
|
import { LibNewsFilterDefinition } from './common/filter/LibNewsFilterDefinition';
|
|
4
4
|
export interface NewsGridProps {
|
|
5
5
|
filter?: LibNewsFilterDefinition;
|
|
6
|
+
searchText?: string;
|
|
6
7
|
hidePagination?: boolean;
|
|
7
8
|
columnCount?: number;
|
|
8
9
|
rowCount?: number;
|
package/NewsList.d.ts
CHANGED
|
@@ -7,6 +7,7 @@ export declare enum ItemLayoutMode {
|
|
|
7
7
|
}
|
|
8
8
|
export interface NewsListProps {
|
|
9
9
|
filter?: LibNewsFilterDefinition;
|
|
10
|
+
searchText?: string;
|
|
10
11
|
itemLayoutMode?: ItemLayoutMode;
|
|
11
12
|
onItemClick?: (item: NewsItem, itemUrl?: string, isTitleClicked?: boolean) => unknown;
|
|
12
13
|
hidePlaceholderIfNoBanner?: boolean;
|
package/common/utils.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { NewsItem } from '@livetiles/reach/util/common';
|
|
|
2
2
|
import { NewsFilterDefinition } from '@livetiles/reach/feature/content';
|
|
3
3
|
import { LibNewsFilterDefinition } from './filter/LibNewsFilterDefinition';
|
|
4
4
|
export declare function useNewsItemClickHandler(): (e: React.MouseEvent<unknown>, item: NewsItem, shouldHandleExternalContent: boolean, onItemClick?: (item: NewsItem, itemUrl?: string) => unknown, newTab?: boolean) => void;
|
|
5
|
-
export declare function useNewsLoaderWithFiltersAndPagination(pageSize: number, filter?: LibNewsFilterDefinition): {
|
|
5
|
+
export declare function useNewsLoaderWithFiltersAndPagination(pageSize: number, filter?: LibNewsFilterDefinition, searchText?: string): {
|
|
6
6
|
items: any[];
|
|
7
7
|
isInitialLoading: boolean;
|
|
8
8
|
isLoadingNextPage: boolean;
|
package/index.d.ts
CHANGED
|
@@ -684,6 +684,7 @@ declare enum ItemLayoutMode {
|
|
|
684
684
|
}
|
|
685
685
|
interface NewsListProps {
|
|
686
686
|
filter?: LibNewsFilterDefinition;
|
|
687
|
+
searchText?: string;
|
|
687
688
|
itemLayoutMode?: ItemLayoutMode;
|
|
688
689
|
onItemClick?: (item: NewsItem, itemUrl?: string, isTitleClicked?: boolean) => unknown;
|
|
689
690
|
hidePlaceholderIfNoBanner?: boolean;
|
|
@@ -700,6 +701,7 @@ declare const ManageChannels: FC<ManageChannelsProps>;
|
|
|
700
701
|
|
|
701
702
|
interface NewsGridProps {
|
|
702
703
|
filter?: LibNewsFilterDefinition;
|
|
704
|
+
searchText?: string;
|
|
703
705
|
hidePagination?: boolean;
|
|
704
706
|
columnCount?: number;
|
|
705
707
|
rowCount?: number;
|
package/index.esm2.js
CHANGED
|
@@ -87469,9 +87469,9 @@ var AuthenticationContextProvider = function AuthenticationContextProvider(_a) {
|
|
|
87469
87469
|
}), void 0);
|
|
87470
87470
|
};
|
|
87471
87471
|
|
|
87472
|
-
var version$1 = "0.4.0-preview.
|
|
87473
|
-
var buildId = "
|
|
87474
|
-
var commitId = "
|
|
87472
|
+
var version$1 = "0.4.0-preview.241";
|
|
87473
|
+
var buildId = "99061";
|
|
87474
|
+
var commitId = "9d41edf38c4702879173fc8d6bd420325af4046c";
|
|
87475
87475
|
var isCustomerBuild = false;
|
|
87476
87476
|
var buildInfo = {
|
|
87477
87477
|
version: version$1,
|
|
@@ -131693,7 +131693,7 @@ storage.set(cacheKey,apiPage_1).then(function(){return null;});if(!cachedPage){o
|
|
|
131693
131693
|
apiItem.fileAccessToken=cachedItem.fileAccessToken;}});observer.next(apiPage_1);observer.complete();return [3/*break*/,4];case 3:err_1=_a.sent();observer.error(err_1);return [3/*break*/,4];case 4:return [2/*return*/];}});});})();});}function validateFileAccessTokens(page,modifyFunc){if(!page||!page.items){return;}page.items.forEach(function(item){var isTokenValid=isTokenStillValid(item.fileAccessToken);modifyFunc(isTokenValid,item);});}var NewsApiService=/** @class */function(){function NewsApiService(factory,subscriptionId,storage){var _this=this;this.factory=factory;this.storage=storage;this.trackExternalItem=function(itemId,itemType){return _this.api.custom(itemType+"/"+encodeURIComponent(itemId)+"/external_url/track").get().then(function(result){return result.body().data();});};this.getAllNews=function(filterDefinition,paginationToken){return fetchNewsItems('news',NewsApiService.allNewsCacheKey,_this.api,_this.storage,paginationToken,__assign(__assign({},filterDefinition||{}),{includePromoted:true}));};this.getAllUnreadNews=function(filterDefinition,paginationToken){return fetchNewsItems('news',NewsApiService.allNewsCacheKey,_this.api,_this.storage,paginationToken,__assign(__assign({},filterDefinition||{}),{unreadOnly:true,pageSize:0}));};this.getMyNews=function(filterDefinition,paginationToken){return fetchNewsItems('users/current/news',NewsApiService.newsCacheKey,_this.api,_this.storage,paginationToken,filterDefinition);};this.getMyUnreadNews=function(filterDefinition,paginationToken){return fetchNewsItems('users/current/news/unread',NewsApiService.myUnreadNewsCacheKey,_this.api,_this.storage,paginationToken,filterDefinition,true);};this.getBookmarks=function(filterDefinition){return fetchNewsItems('users/current/bookmarks',NewsApiService.bookmarksCacheKey,_this.api,_this.storage,null,filterDefinition,true);};this.getNewsFromCache=function(){return __awaiter(_this,void 0,void 0,function(){var _a;return __generator(this,function(_b){switch(_b.label){case 0:return [4/*yield*/,this.storage.getObject(NewsApiService.newsItemsCacheKey)];case 1:return [2/*return*/,(_a=_b.sent())!==null&&_a!==void 0?_a:[]];}});});};this.get=function(newsId){var getFromCache=function getFromCache(id){return __awaiter(_this,void 0,void 0,function(){var cache,hits;return __generator(this,function(_a){switch(_a.label){case 0:return [4/*yield*/,this.getNewsFromCache()];case 1:cache=_a.sent();hits=cache.filter(function(i){return i.id===id;});return [2/*return*/,hits.length>0?hits[0]:null];}});});};var getFromApi=function getFromApi(id){return from(_this.api.all('news').get(id)).pipe(mergeMap(function(res){return updateItemCache(res.body().data());}));};var updateItemCache=function updateItemCache(item){return __awaiter(_this,void 0,void 0,function(){var fromCache,index,cacheItem,clonedCachedItem,clonedNewItem;return __generator(this,function(_a){switch(_a.label){case 0:if(item.statistics){itemStatisticsCache[item.id]=Promise.resolve(__assign({},item.statistics));}return [4/*yield*/,this.getNewsFromCache()];case 1:fromCache=_a.sent();index=fromCache.findIndex(function(i){return i.id===item.id;});if(index>-1){cacheItem=fromCache[index];if(isTokenStillValid(cacheItem.fileAccessToken)){clonedCachedItem=__assign({},cacheItem);delete clonedCachedItem.fileAccessToken;clonedNewItem=__assign({},item);delete clonedNewItem.fileAccessToken;if(JSON.stringify(clonedCachedItem)===JSON.stringify(clonedNewItem)){return [2/*return*/,null];}}fromCache.splice(index,1,item);}else {fromCache.push(item);}return [4/*yield*/,this.storage.set(NewsApiService.newsItemsCacheKey,fromCache)];case 2:_a.sent();return [2/*return*/,item];}});});};return concat(getFromCache(newsId),getFromApi(newsId)).pipe(filter(function(i){return i!=null;}),catchError(function(err){if(err.response&&err.response.statusCode===404){return of(null);}else {return throwError(err);}}));};this.getImageUrlWithToken=function(token,itemId,subscriptionId,resourceType,imageIdentifier,width,height){if(imageIdentifier===void 0){imageIdentifier='banner';}return _this.factory.createApiUrl("/"+resourceType+"/"+itemId+"/images/"+imageIdentifier+"/"+width+"/"+(height||''),{access_token:token,subscriptionId:subscriptionId});};this.getStatistics=function(newsId){if(!itemStatisticsCache[newsId]){itemStatisticsCache[newsId]=_this.api.custom("news/"+newsId+"/statistics").get().then(function(result){return result.body().data();}).then(function(result){var feedbackCountsKeys=Object.keys(result.feedbackCounts);return {bookmarkCount:result.bookmarkCount,likeCount:result.feedbackCounts[feedbackCountsKeys.find(function(k){return k==='like';})],commentCount:result.commentCount,confirmationCount:result.feedbackCounts[feedbackCountsKeys.find(function(k){return k==='confirm';})],readCount:result.readCount};});}return itemStatisticsCache[newsId];};this.refreshStatistics=function(itemId,delta){return __awaiter(_this,void 0,void 0,function(){var _this=this;return __generator(this,function(_a){switch(_a.label){case 0:// update statistics cache with new delta
|
|
131694
131694
|
if(!itemStatisticsCache[itemId]){return [2/*return*/];}return [4/*yield*/,itemStatisticsCache[itemId].then(function(statistics){var updatedStatistics=NewsApiService.getUpdatedStatistics(statistics,delta);_this.tryUpdateStatisticsInCache(itemId,updatedStatistics).then(null,null);itemStatisticsCache[itemId]=Promise.resolve(updatedStatistics);onStatisticsUpdated.next(updatedStatistics);})];case 1:_a.sent();return [2/*return*/];}});});};this.tryUpdateStatisticsInCache=function(newsId,statistics){return __awaiter(_this,void 0,void 0,function(){var fromCache,index,item;return __generator(this,function(_a){switch(_a.label){case 0:return [4/*yield*/,this.getNewsFromCache()];case 1:fromCache=_a.sent();index=fromCache.findIndex(function(i){return i.id===newsId;});item=fromCache[index];if(!item||!item.statistics){return [2/*return*/];}item.statistics=statistics;fromCache.splice(index,1,item);return [4/*yield*/,this.storage.set(NewsApiService.newsItemsCacheKey,fromCache)];case 2:_a.sent();return [2/*return*/];}});});};this.getExternalItemRoute=function(resourceType,itemId,accessToken){return _this.factory.createApiUrl("/"+resourceType+"/"+encodeURIComponent(itemId)+"/external_url",{access_token:accessToken});};this.api=factory.createApi(false,subscriptionId);}NewsApiService.getUpdatedStatistics=function(curr,delta){var _a,_b,_c,_d,_e,_f;return {bookmarkCount:curr.bookmarkCount+((_a=delta.bookmarkCount)!==null&&_a!==void 0?_a:0),commentCount:curr.commentCount+((_b=delta.commentCount)!==null&&_b!==void 0?_b:0),likeCount:curr.likeCount+((_c=delta.likeCount)!==null&&_c!==void 0?_c:0),confirmationCount:curr.confirmationCount+((_d=delta.confirmationCount)!==null&&_d!==void 0?_d:0),readCount:curr.readCount+((_e=delta.readCount)!==null&&_e!==void 0?_e:0),participantsCount:curr.participantsCount+((_f=delta.participantsCount)!==null&&_f!==void 0?_f:0)};};NewsApiService.bookmarksCacheKey='NewsService::BookmarksV2';NewsApiService.newsItemsCacheKey='NewsService::NewsItems';NewsApiService.newsCacheKey='NewsService::News';NewsApiService.allNewsCacheKey='NewsService::AllNews';NewsApiService.myUnreadNewsCacheKey='NewsService::MyUnreadNews';return NewsApiService;}();function useNewsApi(){var storage=useStorage();var factory=useApiFactory();var identifier=useContext(SubscriptionIdContext).identifier;return useMemo(function(){return new NewsApiService(factory,identifier===null||identifier===void 0?void 0:identifier.id,storage);},[factory,identifier,storage]);}function usePagesApi(){var api=useApi();var createApiUrl=useApiFactory().createApiUrl;return useMemo(function(){return {loadPage:loadPage,loadPageChildren:loadPageChildren,getRootPagesNavigation:getRootPagesNavigation,getPublishedRootPages:getPublishedRootPages,searchPublishedPages:searchPublishedPages,getSubpages:getSubpages,searchPages:searchPages,getDocumentFileUrl:getDocumentFileUrl,searchToc:searchToc};function loadPage(id){return api.all('pages').get(id,{includeNavigationContext:true}).then(function(response){var page=response.body().data();itemStatisticsCache[page.id]=Promise.resolve(__assign({},page.statistics));return page;});}function loadPageChildren(id){return api.all("pages/"+id+"/navigation/children").getAll().then(function(r){return r.body().map(function(g){return g.data();});});}function getRootPagesNavigation(){return api.all('pages').getAll().then(function(r){return r.body().map(function(g){return g.data();});});}function getPublishedRootPages(filter){var rootPagesFilter=__assign(__assign({},filter),{rootPagesOnly:true});return searchPages('pages',rootPagesFilter);}function searchPublishedPages(filter){return searchPages('pages',filter);}function getSubpages(parentId,filter){var subPagesFilter=__assign(__assign({},filter),{parentId:parentId});if(!subPagesFilter.pageSize){// return all subpages & documents
|
|
131695
131695
|
subPagesFilter.pageSize=0;}return searchPages('pages',subPagesFilter);}function searchToc(basePath,searchValue){return searchPages(basePath,{pageSize:100,search:searchValue,searchInTitlesOnly:true});}function searchPages(basePath,filter){if(filter){filter=__assign({},filter);if(!filter.restrictToPageContext){delete filter.pageContextId;}// we never need / want to send this param to the API, only used for the UI
|
|
131696
|
-
delete filter.restrictToPageContext;}var params=__assign(__assign({},filter),getCommaSeparatedKeywordsString(filter===null||filter===void 0?void 0:filter.keywords));return api.all(basePath+"/search").get('',params).then(function(result){return result.body().data();});}function getDocumentFileUrl(basePath,subscriptionId,pageId,fileId,language,token){return createApiUrl("/"+basePath+"/"+pageId+"/"+language+"/documents/"+fileId,{access_token:token,subscriptionId:subscriptionId});}},[api,createApiUrl]);}function usePostsApi(){var searchAccounts=useAccountApi().searchAccounts;var api=useApi();return useMemo(function(){return {createPost:createPost,togglePostLike:togglePostLike,getPosts:getPosts,updatePost:updatePost,deletePost:deletePost,getPost:getPost,getPostThread:getPostThread,translatePost:translatePost,searchPostMentionUsers:searchPostMentionUsers};function createPost(post){return api.all("posts").post(post).then(function(result){return result.body().data();});}function togglePostLike(postId,isLiked){if(isLiked){return api.custom("posts/"+postId+"/feedback/like").put({});}else {return api.custom("posts/"+postId+"/feedback/like").delete();}}function getPosts(filter){var groupIds=[];for(var _i=1;_i<arguments.length;_i++){groupIds[_i-1]=arguments[_i];}return api.custom("posts?"+queryString.stringify(__assign(__assign({},filter),{groupId:groupIds}))).get().then(function(res){return res.body().data();});}function updatePost(postId,content,attachments,keywords){return api.all('posts').patch(postId,{content:content,attachments:attachments,keywords:keywords}).then(function(result){return result.body().data();});}function deletePost(postId){return api.all("posts").delete(postId);}function getPost(postId){return api.all('posts').get(postId).then(function(result){return result.body().data();});}function getPostThread(postId,threadId){return api.custom("posts/"+postId+"/comments/"+threadId+"/thread").get().then(function(result){return result.body().data();});}function translatePost(postId,language){return api.custom("posts/"+postId+"/content/"+language).get().then(function(res){return res.body().data();});}function searchPostMentionUsers(searchText,postGroupId){return searchAccounts({search:searchText,type:AccountType.User,localOnly:true,groupId:[postGroupId],excludeApiUsers:true});}},[api,searchAccounts]);}function useEmbeddedObjectValidator(){var _this=this;var getPost=usePostsApi().getPost;var getNews=useNewsApi().get;var loadPage=usePagesApi().loadPage;var getEvent=useEventsApi().getEvent;return function(embeddedObject){return __awaiter(_this,void 0,void 0,function(){var _a,item,error_1;return __generator(this,function(_b){switch(_b.label){case 0:_b.trys.push([0,11,,12]);_a=embeddedObject.type;switch(_a){case AttachmentType.Post:return [3/*break*/,1];case AttachmentType.News:return [3/*break*/,3];case AttachmentType.Page:return [3/*break*/,5];case AttachmentType.Event:return [3/*break*/,7];}return [3/*break*/,9];case 1:return [4/*yield*/,getPost(embeddedObject.id)];case 2:_b.sent();return [2/*return*/,true];case 3:return [4/*yield*/,getNews(embeddedObject.id).toPromise()];case 4:item=_b.sent();return [2/*return*/,!!item];case 5:return [4/*yield*/,loadPage(embeddedObject.id)];case 6:_b.sent();return [2/*return*/,true];case 7:return [4/*yield*/,getEvent(embeddedObject.id)];case 8:_b.sent();return [2/*return*/,true];case 9:throw Error('Invalid type');case 10:return [3/*break*/,12];case 11:error_1=_b.sent();logger.error(error_1);return [2/*return*/,false];case 12:return [2/*return*/];}});});};}var RichCommentInput=/*#__PURE__*/forwardRef(function(_a,ref){var className=_a.className,buttons=_a.buttons,attachments=_a.attachments,deletedAttachmentUrls=_a.deletedAttachmentUrls,onAttachmentsChange=_a.onAttachmentsChange;_a.onDeleteAttachment;var allowAttachments=_a.allowAttachments,useLargeDropTarget=_a.useLargeDropTarget,disableDragAndDrop=_a.disableDragAndDrop;_a.allowKeywords;var defaultKeywords=_a.defaultKeywords,availableKeywords=_a.availableKeywords,mandatoryKeywords=_a.mandatoryKeywords,showKeywordsPicker=_a.showKeywordsPicker,onKeywordsChange=_a.onKeywordsChange,disableAddGif=_a.disableAddGif,disableAddFiles=_a.disableAddFiles,props=__rest(_a,["className","buttons","attachments","deletedAttachmentUrls","onAttachmentsChange","onDeleteAttachment","allowAttachments","useLargeDropTarget","disableDragAndDrop","allowKeywords","defaultKeywords","availableKeywords","mandatoryKeywords","showKeywordsPicker","onKeywordsChange","disableAddGif","disableAddFiles"]);var onDrop=useCallback(handleDropFiles,[attachments,onAttachmentsChange]);var _b=useDropzone({onDrop:onDrop}),getRootProps=_b.getRootProps,getInputProps=_b.getInputProps,open=_b.open,isDragActive=_b.isDragActive;var inputRef=useRef$1(null);var formatMessage=useIntl().formatMessage;useImperativeHandle(ref,function(){return inputRef.current;},[inputRef]);var user=useCurrentUser();var debouncedOnEmbeddedObjectsOrVideosChange=useDebouncedCallback(onEmbeddedObjectsOrVideosChange,500)[0];var validateEmbeddedObject=useEmbeddedObjectValidator();var isGifButtonDisabled=props.disabled||disableAddGif;var isAttachmentsButtonDisabled=props.disabled||disableAddFiles;if(props.disabled||!allowAttachments){return jsxs(Fragment,{children:[jsx$1(CommentInput,__assign({ref:inputRef,className:className,buttons:buttons},props),void 0),showKeywordsPicker&&!props.disabled&&jsx$1(KeywordsPicker,{defaultKeywords:defaultKeywords,availableKeywords:availableKeywords,mandatoryKeywords:mandatoryKeywords,onChangeKeywords:onKeywordsChange},void 0)]},void 0);}return jsxs("div",__assign({className:className},{children:[jsx$1("input",__assign({},getInputProps()),void 0),!disableDragAndDrop&&jsx$1(DropTarget,__assign({isActive:isDragActive,isLarge:useLargeDropTarget},getRootProps({onClick:function(e){return e.stopPropagation();}}),{"data-drop-target":true},{children:isDragActive&&jsx$1(DropInfo,{isLarge:useLargeDropTarget},void 0)}),void 0),jsx$1(CommentInput,__assign({},props,{onChange:handleChange,ref:inputRef,buttons:jsxs(Fragment,{children:[jsx$1(GifButton,{disabled:isGifButtonDisabled,onGifClick:handleGifClick},'gifButton'+isGifButtonDisabled),jsx$1(IconButton,{iconProps:{iconName:'Attach'},onClick:open,disabled:isAttachmentsButtonDisabled,"data-button-type":"attach",ariaLabel:formatMessage({id:'AriaLabel.attachmentsButton'})},'attachmentsButton'+isAttachmentsButtonDisabled),buttons]},void 0)}),void 0),showKeywordsPicker&&!props.disabled&&jsx$1(KeywordsPicker,{defaultKeywords:defaultKeywords,availableKeywords:availableKeywords,mandatoryKeywords:mandatoryKeywords,onChangeKeywords:onKeywordsChange},void 0)]}),void 0);function handleChange(content){props.onChange(content);debouncedOnEmbeddedObjectsOrVideosChange(content);}function onEmbeddedObjectsOrVideosChange(content){return __awaiter(this,void 0,void 0,function(){var existingAttachments,newAttachments,matchedVideoUrls,_i,matchedVideoUrls_1,matchedUrl,url,id,matchedEmbeddedObjects,_a,matchedEmbeddedObjects_1,matchedEmbeddedObject,url,isValid;return __generator(this,function(_b){switch(_b.label){case 0:existingAttachments=new Set(attachments.map(function(a){return a.url;}));newAttachments=[];matchedVideoUrls=__spreadArray([],Array.from(getAllVideosFromString(content)));for(_i=0,matchedVideoUrls_1=matchedVideoUrls;_i<matchedVideoUrls_1.length;_i++){matchedUrl=matchedVideoUrls_1[_i];url=matchedUrl.url;id=new VideoUrlParser(url).id;if(!existingAttachments.has(url)){newAttachments.push(__assign({id:id},matchedUrl));existingAttachments.add(url);}}matchedEmbeddedObjects=__spreadArray([],Array.from(getEmbeddedObjectsFromString(content)).filter(function(ob){return ob.subscriptionIdentifier===user.subscription.id||ob.subscriptionIdentifier===user.subscription.subscriptionHandle;}));_a=0,matchedEmbeddedObjects_1=matchedEmbeddedObjects;_b.label=1;case 1:if(!(_a<matchedEmbeddedObjects_1.length))return [3/*break*/,4];matchedEmbeddedObject=matchedEmbeddedObjects_1[_a];url=matchedEmbeddedObject.url;if(!(!existingAttachments.has(url)&&!(deletedAttachmentUrls===null||deletedAttachmentUrls===void 0?void 0:deletedAttachmentUrls.includes(url))))return [3/*break*/,3];return [4/*yield*/,validateEmbeddedObject(matchedEmbeddedObject)];case 2:isValid=_b.sent();if(isValid){newAttachments.push(__assign({},matchedEmbeddedObject));existingAttachments.add(url);}_b.label=3;case 3:_a++;return [3/*break*/,1];case 4:if(newAttachments.length!==0){onAttachmentsChange(attachments.concat(newAttachments));}return [2/*return*/];}});});}function handleGifClick(newAttachment){return __awaiter(this,void 0,void 0,function(){return __generator(this,function(_a){onAttachmentsChange(attachments.filter(function(attachment){return attachment.type!==AttachmentType.Giphy;}).concat(newAttachment));return [2/*return*/];});});}function handleDropFiles(dropResult){return __awaiter(this,void 0,void 0,function(){var newFiles,_i,_a,image,size;return __generator(this,function(_b){switch(_b.label){case 0:newFiles=dropResult.map(function(f){return {id:createId(),file:f,filename:f.name,previewUrl:URL.createObjectURL(f),type:f.type.startsWith('image/')?AttachmentType.Image:AttachmentType.File};});_i=0,_a=newFiles.filter(function(f){return f.type===AttachmentType.Image;});_b.label=1;case 1:if(!(_i<_a.length))return [3/*break*/,4];image=_a[_i];return [4/*yield*/,getImageSize(image.previewUrl)];case 2:size=_b.sent();image.width=size.width;image.height=size.height;_b.label=3;case 3:_i++;return [3/*break*/,1];case 4:onAttachmentsChange(attachments.concat(newFiles));return [2/*return*/];}});});}});var getMicrosoftStreamEmbedVideoUrl=function getMicrosoftStreamEmbedVideoUrl(id,autoPlay){if(autoPlay===void 0){autoPlay=false;}return "https://web.microsoftstream.com/embed/video/"+id+"?autoplay="+autoPlay+"&showInfo=true";};var getMicrosoftStreamVideoUrl=function getMicrosoftStreamVideoUrl(id){return "https://web.microsoftstream.com/video/"+id+"?autoplay=true";};var VideoElementGenerator=/** @class */function(){function VideoElementGenerator(videoInfo,iframeAreaLabel,autoplay,width,videoProperties){this.videoInfo=videoInfo;this.iframeAreaLabel=iframeAreaLabel;this.autoplay=autoplay;this.width=width;this.videoProperties=videoProperties;}VideoElementGenerator.prototype.getYouTubeVideoElement=function(){// <iframe
|
|
131696
|
+
delete filter.restrictToPageContext;}var params=__assign(__assign({},filter),getCommaSeparatedKeywordsString(filter===null||filter===void 0?void 0:filter.keywords));return api.all(basePath+"/search").get('',params).then(function(result){return result.body().data();});}function getDocumentFileUrl(basePath,subscriptionId,pageId,fileId,language,token){return createApiUrl("/"+basePath+"/"+pageId+"/"+language+"/documents/"+fileId,{access_token:token,subscriptionId:subscriptionId});}},[api,createApiUrl]);}function usePostsApi(){var searchAccounts=useAccountApi().searchAccounts;var api=useApi();return useMemo(function(){return {createPost:createPost,togglePostLike:togglePostLike,getPosts:getPosts,updatePost:updatePost,deletePost:deletePost,getPost:getPost,getPostThread:getPostThread,translatePost:translatePost,searchPostMentionUsers:searchPostMentionUsers};function createPost(post){return api.all("posts").post(post).then(function(result){return result.body().data();});}function togglePostLike(postId,isLiked){if(isLiked){return api.custom("posts/"+postId+"/feedback/like").put({});}else {return api.custom("posts/"+postId+"/feedback/like").delete();}}function getPosts(filter){var groupIds=[];for(var _i=1;_i<arguments.length;_i++){groupIds[_i-1]=arguments[_i];}var params=__assign(__assign(__assign({},filter),{groupId:groupIds}),getCommaSeparatedKeywordsString(filter===null||filter===void 0?void 0:filter.keywords));return api.custom("posts?"+queryString.stringify(params)).get().then(function(res){return res.body().data();});}function updatePost(postId,content,attachments,keywords){return api.all('posts').patch(postId,{content:content,attachments:attachments,keywords:keywords}).then(function(result){return result.body().data();});}function deletePost(postId){return api.all("posts").delete(postId);}function getPost(postId){return api.all('posts').get(postId).then(function(result){return result.body().data();});}function getPostThread(postId,threadId){return api.custom("posts/"+postId+"/comments/"+threadId+"/thread").get().then(function(result){return result.body().data();});}function translatePost(postId,language){return api.custom("posts/"+postId+"/content/"+language).get().then(function(res){return res.body().data();});}function searchPostMentionUsers(searchText,postGroupId){return searchAccounts({search:searchText,type:AccountType.User,localOnly:true,groupId:[postGroupId],excludeApiUsers:true});}},[api,searchAccounts]);}function useEmbeddedObjectValidator(){var _this=this;var getPost=usePostsApi().getPost;var getNews=useNewsApi().get;var loadPage=usePagesApi().loadPage;var getEvent=useEventsApi().getEvent;return function(embeddedObject){return __awaiter(_this,void 0,void 0,function(){var _a,item,error_1;return __generator(this,function(_b){switch(_b.label){case 0:_b.trys.push([0,11,,12]);_a=embeddedObject.type;switch(_a){case AttachmentType.Post:return [3/*break*/,1];case AttachmentType.News:return [3/*break*/,3];case AttachmentType.Page:return [3/*break*/,5];case AttachmentType.Event:return [3/*break*/,7];}return [3/*break*/,9];case 1:return [4/*yield*/,getPost(embeddedObject.id)];case 2:_b.sent();return [2/*return*/,true];case 3:return [4/*yield*/,getNews(embeddedObject.id).toPromise()];case 4:item=_b.sent();return [2/*return*/,!!item];case 5:return [4/*yield*/,loadPage(embeddedObject.id)];case 6:_b.sent();return [2/*return*/,true];case 7:return [4/*yield*/,getEvent(embeddedObject.id)];case 8:_b.sent();return [2/*return*/,true];case 9:throw Error('Invalid type');case 10:return [3/*break*/,12];case 11:error_1=_b.sent();logger.error(error_1);return [2/*return*/,false];case 12:return [2/*return*/];}});});};}var RichCommentInput=/*#__PURE__*/forwardRef(function(_a,ref){var className=_a.className,buttons=_a.buttons,attachments=_a.attachments,deletedAttachmentUrls=_a.deletedAttachmentUrls,onAttachmentsChange=_a.onAttachmentsChange;_a.onDeleteAttachment;var allowAttachments=_a.allowAttachments,useLargeDropTarget=_a.useLargeDropTarget,disableDragAndDrop=_a.disableDragAndDrop;_a.allowKeywords;var defaultKeywords=_a.defaultKeywords,availableKeywords=_a.availableKeywords,mandatoryKeywords=_a.mandatoryKeywords,showKeywordsPicker=_a.showKeywordsPicker,onKeywordsChange=_a.onKeywordsChange,disableAddGif=_a.disableAddGif,disableAddFiles=_a.disableAddFiles,props=__rest(_a,["className","buttons","attachments","deletedAttachmentUrls","onAttachmentsChange","onDeleteAttachment","allowAttachments","useLargeDropTarget","disableDragAndDrop","allowKeywords","defaultKeywords","availableKeywords","mandatoryKeywords","showKeywordsPicker","onKeywordsChange","disableAddGif","disableAddFiles"]);var onDrop=useCallback(handleDropFiles,[attachments,onAttachmentsChange]);var _b=useDropzone({onDrop:onDrop}),getRootProps=_b.getRootProps,getInputProps=_b.getInputProps,open=_b.open,isDragActive=_b.isDragActive;var inputRef=useRef$1(null);var formatMessage=useIntl().formatMessage;useImperativeHandle(ref,function(){return inputRef.current;},[inputRef]);var user=useCurrentUser();var debouncedOnEmbeddedObjectsOrVideosChange=useDebouncedCallback(onEmbeddedObjectsOrVideosChange,500)[0];var validateEmbeddedObject=useEmbeddedObjectValidator();var isGifButtonDisabled=props.disabled||disableAddGif;var isAttachmentsButtonDisabled=props.disabled||disableAddFiles;if(props.disabled||!allowAttachments){return jsxs(Fragment,{children:[jsx$1(CommentInput,__assign({ref:inputRef,className:className,buttons:buttons},props),void 0),showKeywordsPicker&&!props.disabled&&jsx$1(KeywordsPicker,{defaultKeywords:defaultKeywords,availableKeywords:availableKeywords,mandatoryKeywords:mandatoryKeywords,onChangeKeywords:onKeywordsChange},void 0)]},void 0);}return jsxs("div",__assign({className:className},{children:[jsx$1("input",__assign({},getInputProps()),void 0),!disableDragAndDrop&&jsx$1(DropTarget,__assign({isActive:isDragActive,isLarge:useLargeDropTarget},getRootProps({onClick:function(e){return e.stopPropagation();}}),{"data-drop-target":true},{children:isDragActive&&jsx$1(DropInfo,{isLarge:useLargeDropTarget},void 0)}),void 0),jsx$1(CommentInput,__assign({},props,{onChange:handleChange,ref:inputRef,buttons:jsxs(Fragment,{children:[jsx$1(GifButton,{disabled:isGifButtonDisabled,onGifClick:handleGifClick},'gifButton'+isGifButtonDisabled),jsx$1(IconButton,{iconProps:{iconName:'Attach'},onClick:open,disabled:isAttachmentsButtonDisabled,"data-button-type":"attach",ariaLabel:formatMessage({id:'AriaLabel.attachmentsButton'})},'attachmentsButton'+isAttachmentsButtonDisabled),buttons]},void 0)}),void 0),showKeywordsPicker&&!props.disabled&&jsx$1(KeywordsPicker,{defaultKeywords:defaultKeywords,availableKeywords:availableKeywords,mandatoryKeywords:mandatoryKeywords,onChangeKeywords:onKeywordsChange},void 0)]}),void 0);function handleChange(content){props.onChange(content);debouncedOnEmbeddedObjectsOrVideosChange(content);}function onEmbeddedObjectsOrVideosChange(content){return __awaiter(this,void 0,void 0,function(){var existingAttachments,newAttachments,matchedVideoUrls,_i,matchedVideoUrls_1,matchedUrl,url,id,matchedEmbeddedObjects,_a,matchedEmbeddedObjects_1,matchedEmbeddedObject,url,isValid;return __generator(this,function(_b){switch(_b.label){case 0:existingAttachments=new Set(attachments.map(function(a){return a.url;}));newAttachments=[];matchedVideoUrls=__spreadArray([],Array.from(getAllVideosFromString(content)));for(_i=0,matchedVideoUrls_1=matchedVideoUrls;_i<matchedVideoUrls_1.length;_i++){matchedUrl=matchedVideoUrls_1[_i];url=matchedUrl.url;id=new VideoUrlParser(url).id;if(!existingAttachments.has(url)){newAttachments.push(__assign({id:id},matchedUrl));existingAttachments.add(url);}}matchedEmbeddedObjects=__spreadArray([],Array.from(getEmbeddedObjectsFromString(content)).filter(function(ob){return ob.subscriptionIdentifier===user.subscription.id||ob.subscriptionIdentifier===user.subscription.subscriptionHandle;}));_a=0,matchedEmbeddedObjects_1=matchedEmbeddedObjects;_b.label=1;case 1:if(!(_a<matchedEmbeddedObjects_1.length))return [3/*break*/,4];matchedEmbeddedObject=matchedEmbeddedObjects_1[_a];url=matchedEmbeddedObject.url;if(!(!existingAttachments.has(url)&&!(deletedAttachmentUrls===null||deletedAttachmentUrls===void 0?void 0:deletedAttachmentUrls.includes(url))))return [3/*break*/,3];return [4/*yield*/,validateEmbeddedObject(matchedEmbeddedObject)];case 2:isValid=_b.sent();if(isValid){newAttachments.push(__assign({},matchedEmbeddedObject));existingAttachments.add(url);}_b.label=3;case 3:_a++;return [3/*break*/,1];case 4:if(newAttachments.length!==0){onAttachmentsChange(attachments.concat(newAttachments));}return [2/*return*/];}});});}function handleGifClick(newAttachment){return __awaiter(this,void 0,void 0,function(){return __generator(this,function(_a){onAttachmentsChange(attachments.filter(function(attachment){return attachment.type!==AttachmentType.Giphy;}).concat(newAttachment));return [2/*return*/];});});}function handleDropFiles(dropResult){return __awaiter(this,void 0,void 0,function(){var newFiles,_i,_a,image,size;return __generator(this,function(_b){switch(_b.label){case 0:newFiles=dropResult.map(function(f){return {id:createId(),file:f,filename:f.name,previewUrl:URL.createObjectURL(f),type:f.type.startsWith('image/')?AttachmentType.Image:AttachmentType.File};});_i=0,_a=newFiles.filter(function(f){return f.type===AttachmentType.Image;});_b.label=1;case 1:if(!(_i<_a.length))return [3/*break*/,4];image=_a[_i];return [4/*yield*/,getImageSize(image.previewUrl)];case 2:size=_b.sent();image.width=size.width;image.height=size.height;_b.label=3;case 3:_i++;return [3/*break*/,1];case 4:onAttachmentsChange(attachments.concat(newFiles));return [2/*return*/];}});});}});var getMicrosoftStreamEmbedVideoUrl=function getMicrosoftStreamEmbedVideoUrl(id,autoPlay){if(autoPlay===void 0){autoPlay=false;}return "https://web.microsoftstream.com/embed/video/"+id+"?autoplay="+autoPlay+"&showInfo=true";};var getMicrosoftStreamVideoUrl=function getMicrosoftStreamVideoUrl(id){return "https://web.microsoftstream.com/video/"+id+"?autoplay=true";};var VideoElementGenerator=/** @class */function(){function VideoElementGenerator(videoInfo,iframeAreaLabel,autoplay,width,videoProperties){this.videoInfo=videoInfo;this.iframeAreaLabel=iframeAreaLabel;this.autoplay=autoplay;this.width=width;this.videoProperties=videoProperties;}VideoElementGenerator.prototype.getYouTubeVideoElement=function(){// <iframe
|
|
131697
131697
|
// src="https://www.youtube.com/embed/{videoId}?ecver=1" frameborder="0" allowfullscreen>
|
|
131698
131698
|
// </iframe>
|
|
131699
131699
|
var iframe=document.createElement('iframe');iframe.setAttribute('aria-label',this.iframeAreaLabel);iframe.setAttribute('src',"https://www.youtube.com/embed/"+this.videoInfo.id+"?rel=0&autoplay="+(this.autoplay?'1':'0'));iframe.setAttribute('frameborder','0');iframe.setAttribute('allowfullscreen','');return iframe;};VideoElementGenerator.prototype.getVimeoVideoElement=function(){// <iframe src="https://player.vimeo.com/video/{videoId}"
|
|
@@ -131881,7 +131881,7 @@ var timer=setInterval(function(){return __awaiter(_this,void 0,void 0,function()
|
|
|
131881
131881
|
return [4/*yield*/,api.custom("editor/"+itemId+"/lease").put({leaseId:leaseId})];case 1:// update the lease
|
|
131882
131882
|
_a.sent();return [4/*yield*/,onRequestToken()];case 2:// renew the access token
|
|
131883
131883
|
expireLeaseToken=_a.sent();return [2/*return*/];}});});},1000*10);return {cancel:function(){return clearInterval(timer);},destroy:function(){clearInterval(timer);sendBeacon("/editor/"+itemId+"/lease/delete",expireLeaseToken,subscriptionId,{leaseId:leaseId});}};}function saveItem(subscriptionId,type,item,createLease){if(createLease===void 0){createLease=true;}return from(onRequestToken()).pipe(switchMap(function(token){var config={method:item.id==null?'POST':'PUT',body:JSON.stringify(item),headers:{authorization:'Bearer '+token,'subscription-id':subscriptionId,'Content-Type':'application/json'}};var basePath=type?'/editor/'+type:'/editor';var path=item.id==null?basePath:basePath+"/"+item.id;// note (sl): use custom fetch, since post/put with query string is annoying to build with restful.js
|
|
131884
|
-
return fetchFromApi(path+"?createLease="+createLease.toString(),config);}),switchMap(function(response){if(response.status===409){return new Promise(function(_,reject){return response.json().then(function(account){if(account.userPrincipalName!=null){reject({account:account});}else {reject({status:response.status,error:response.statusText});}});});}else if(response.ok){return from(response.json());}else {return throwError({status:response.status,error:response.statusText});}}));}},[onRequestToken,api,fetchFromApi,sendBeacon]);}function useNewsEditorApi(){var api=useApi();var saveItem=useEditorApi().saveItem;return useMemo(function(){return {getNews:getNews,unpublish:unpublish,save:save};function getNews(newsId){return __awaiter(this,void 0,void 0,function(){var response,error_1;return __generator(this,function(_a){switch(_a.label){case 0:_a.trys.push([0,3,,4]);return [4/*yield*/,api.all('editor/news').get(newsId)];case 1:response=_a.sent();return [4/*yield*/,response.body().data()];case 2:return [2/*return*/,_a.sent()];case 3:error_1=_a.sent();if(error_1.response&&error_1.response.statusCode===404){return [2/*return*/,null];}else {throw error_1;}case 4:return [2/*return*/];}});});}function unpublish(id,leaseId){var path=leaseId?"news/"+id+"?"+queryString.stringify({leaseId:leaseId}):"news/"+id;return from(api.custom(path).delete());}function save(item,subscriptionId){if(item.id==null){item.source='Condense';}return saveItem(subscriptionId,ItemResourceTypes.News,item);}},[api,saveItem]);}_styled.div.withConfig({displayName:"GlobalSearchButton__Host",componentId:"sc-1c5dmlm-0"})(templateObject_1$2$1||(templateObject_1$2$1=__makeTemplateObject(["\n display: flex;\n margin-top: ","px;\n justify-content: center;\n"],["\n display: flex;\n margin-top: ","px;\n justify-content: center;\n"])),spacingM);var templateObject_1$2$1;_styled.article.withConfig({displayName:"StreamList__Host",componentId:"sc-1rdkc01-0"})(templateObject_2$1A||(templateObject_2$1A=__makeTemplateObject(["\n position: relative;\n margin-bottom: ","px;\n\n ",";\n"],["\n position: relative;\n margin-bottom: ","px;\n\n ",";\n"])),spacingM,function(p){return p.highlight&&css$2(templateObject_1$1$1||(templateObject_1$1$1=__makeTemplateObject(["\n &::after {\n content: '';\n border-right-width: ","px;\n border-right-color: ",";\n border-right-style: solid;\n position: absolute;\n top: 0;\n right: 0;\n bottom: 0;\n }\n "],["\n &::after {\n content: '';\n border-right-width: ","px;\n border-right-color: ",";\n border-right-style: solid;\n position: absolute;\n top: 0;\n right: 0;\n bottom: 0;\n }\n "])),spacingXs,p.theme.palette.accent);});var templateObject_1$1$1,templateObject_2$1A;function useNewsStreamDataLoader(filter){var _this=this;var client=useApolloClient();var user=useCurrentUser();var channels=useContext(LazySubscriptionContext).channels;return function(take,skip){return __awaiter(_this,void 0,void 0,function(){var variables,result,stream;var _a,_b,_c,_d;return __generator(this,function(_e){switch(_e.label){case 0:variables={take:take,skip:skip!==null&&skip!==void 0?skip:0};return [4/*yield*/,client.query({query:NEWS_QUERY(false,"\n "+CHANNELS_CONDITION(filter===null||filter===void 0?void 0:filter.channels,channels)+"\n "+KEYWORDS_CONDITION(filter===null||filter===void 0?void 0:filter.keywords)+"\n "+OWNER_CONDITION(filter===null||filter===void 0?void 0:filter.owner)+"\n "+PUBLISHING_DATE_CONDITION(filter===null||filter===void 0?void 0:filter.beforeDate,filter===null||filter===void 0?void 0:filter.afterDate)+"\n "+AUTHORS_CONDITION(filter===null||filter===void 0?void 0:filter.authors)+"\n "),fetchPolicy:'no-cache',variables:variables})];case 1:result=_e.sent();if(((_a=result===null||result===void 0?void 0:result.errors)===null||_a===void 0?void 0:_a.length)>0){logger.error(result.errors[0]);throw result.errors[0];}stream=(_b=result===null||result===void 0?void 0:result.data)===null||_b===void 0?void 0:_b.stream;return [2/*return*/,{items:convertProperties((_c=stream===null||stream===void 0?void 0:stream.items)!==null&&_c!==void 0?_c:[],user,channels),hasNextPage:(_d=stream===null||stream===void 0?void 0:stream.pageInfo)===null||_d===void 0?void 0:_d.hasNextPage,paginationToken:(skip!==null&&skip!==void 0?skip:0)+take}];}});});};}var NEWS_QUERY=function NEWS_QUERY(includeAllItems,whereConditions){if(whereConditions===void 0){whereConditions='';}return gql(templateObject_1$2o||(templateObject_1$2o=__makeTemplateObject(["\n query GetStream(\n $skip: Int!\n $take: Int!\n $searchText: String\n $unreadOnly: Boolean\n ) {\n stream(\n searchText: $searchText\n unreadOnly: $unreadOnly\n order: [{ publishingDate: DESC }]\n skip: $skip\n take: $take\n includeAllItems: ","\n where: {\n type: { eq: NEWS }\n ","\n }\n ) {\n items {\n id: itemId\n knownNewsState\n type\n contentsList: contents {\n language\n intro\n headline\n title\n externalUrl\n active\n }\n modified\n publishingDate\n permalink\n channelsList: channels\n author {\n userPrincipalName\n displayName\n id: userId\n }\n owner {\n userPrincipalName\n displayName\n id: userId\n }\n onBehalfOf {\n userPrincipalName\n displayName\n id: userId\n }\n statistics {\n commentCount\n likeCount\n }\n metadata {\n feedbackSettings {\n feedbackOptions\n }\n }\n bannerInfo {\n type\n imageId\n videoId\n videoUrl\n videoSource\n isDirectVideoUrl\n }\n fileAccessToken\n keywordsList: keywords {\n id\n name\n groupId\n translations {\n key\n value\n }\n }\n isUnread\n hasNewComments\n groupIds\n useExternalContent\n }\n pageInfo {\n hasNextPage\n }\n }\n }\n "],["\n query GetStream(\n $skip: Int!\n $take: Int!\n $searchText: String\n $unreadOnly: Boolean\n ) {\n stream(\n searchText: $searchText\n unreadOnly: $unreadOnly\n order: [{ publishingDate: DESC }]\n skip: $skip\n take: $take\n includeAllItems: ","\n where: {\n type: { eq: NEWS }\n ","\n }\n ) {\n items {\n id: itemId\n knownNewsState\n type\n contentsList: contents {\n language\n intro\n headline\n title\n externalUrl\n active\n }\n modified\n publishingDate\n permalink\n channelsList: channels\n author {\n userPrincipalName\n displayName\n id: userId\n }\n owner {\n userPrincipalName\n displayName\n id: userId\n }\n onBehalfOf {\n userPrincipalName\n displayName\n id: userId\n }\n statistics {\n commentCount\n likeCount\n }\n metadata {\n feedbackSettings {\n feedbackOptions\n }\n }\n bannerInfo {\n type\n imageId\n videoId\n videoUrl\n videoSource\n isDirectVideoUrl\n }\n fileAccessToken\n keywordsList: keywords {\n id\n name\n groupId\n translations {\n key\n value\n }\n }\n isUnread\n hasNewComments\n groupIds\n useExternalContent\n }\n pageInfo {\n hasNextPage\n }\n }\n }\n "])),includeAllItems,whereConditions);};var templateObject_1$2o;
|
|
131884
|
+
return fetchFromApi(path+"?createLease="+createLease.toString(),config);}),switchMap(function(response){if(response.status===409){return new Promise(function(_,reject){return response.json().then(function(account){if(account.userPrincipalName!=null){reject({account:account});}else {reject({status:response.status,error:response.statusText});}});});}else if(response.ok){return from(response.json());}else {return throwError({status:response.status,error:response.statusText});}}));}},[onRequestToken,api,fetchFromApi,sendBeacon]);}function useNewsEditorApi(){var api=useApi();var saveItem=useEditorApi().saveItem;return useMemo(function(){return {getNews:getNews,unpublish:unpublish,save:save};function getNews(newsId){return __awaiter(this,void 0,void 0,function(){var response,error_1;return __generator(this,function(_a){switch(_a.label){case 0:_a.trys.push([0,3,,4]);return [4/*yield*/,api.all('editor/news').get(newsId)];case 1:response=_a.sent();return [4/*yield*/,response.body().data()];case 2:return [2/*return*/,_a.sent()];case 3:error_1=_a.sent();if(error_1.response&&error_1.response.statusCode===404){return [2/*return*/,null];}else {throw error_1;}case 4:return [2/*return*/];}});});}function unpublish(id,leaseId){var path=leaseId?"news/"+id+"?"+queryString.stringify({leaseId:leaseId}):"news/"+id;return from(api.custom(path).delete());}function save(item,subscriptionId){if(item.id==null){item.source='Condense';}return saveItem(subscriptionId,ItemResourceTypes.News,item);}},[api,saveItem]);}_styled.div.withConfig({displayName:"GlobalSearchButton__Host",componentId:"sc-1c5dmlm-0"})(templateObject_1$2$1||(templateObject_1$2$1=__makeTemplateObject(["\n display: flex;\n margin-top: ","px;\n justify-content: center;\n"],["\n display: flex;\n margin-top: ","px;\n justify-content: center;\n"])),spacingM);var templateObject_1$2$1;_styled.article.withConfig({displayName:"StreamList__Host",componentId:"sc-1rdkc01-0"})(templateObject_2$1A||(templateObject_2$1A=__makeTemplateObject(["\n position: relative;\n margin-bottom: ","px;\n\n ",";\n"],["\n position: relative;\n margin-bottom: ","px;\n\n ",";\n"])),spacingM,function(p){return p.highlight&&css$2(templateObject_1$1$1||(templateObject_1$1$1=__makeTemplateObject(["\n &::after {\n content: '';\n border-right-width: ","px;\n border-right-color: ",";\n border-right-style: solid;\n position: absolute;\n top: 0;\n right: 0;\n bottom: 0;\n }\n "],["\n &::after {\n content: '';\n border-right-width: ","px;\n border-right-color: ",";\n border-right-style: solid;\n position: absolute;\n top: 0;\n right: 0;\n bottom: 0;\n }\n "])),spacingXs,p.theme.palette.accent);});var templateObject_1$1$1,templateObject_2$1A;function useNewsStreamDataLoader(filter,searchText){var _this=this;var client=useApolloClient();var user=useCurrentUser();var channels=useContext(LazySubscriptionContext).channels;return function(take,skip){return __awaiter(_this,void 0,void 0,function(){var variables,result,stream;var _a,_b,_c,_d;return __generator(this,function(_e){switch(_e.label){case 0:variables={take:take,skip:skip!==null&&skip!==void 0?skip:0,unreadOnly:filter===null||filter===void 0?void 0:filter.unreadOnly,searchText:searchText};return [4/*yield*/,client.query({query:NEWS_QUERY(false,"\n "+CHANNELS_CONDITION(filter===null||filter===void 0?void 0:filter.channels,channels)+"\n "+KEYWORDS_CONDITION(filter===null||filter===void 0?void 0:filter.keywords)+"\n "+OWNER_CONDITION(filter===null||filter===void 0?void 0:filter.owner)+"\n "+PUBLISHING_DATE_CONDITION(filter===null||filter===void 0?void 0:filter.beforeDate,filter===null||filter===void 0?void 0:filter.afterDate)+"\n "+AUTHORS_CONDITION(filter===null||filter===void 0?void 0:filter.authors)+"\n "),fetchPolicy:'no-cache',variables:variables})];case 1:result=_e.sent();if(((_a=result===null||result===void 0?void 0:result.errors)===null||_a===void 0?void 0:_a.length)>0){logger.error(result.errors[0]);throw result.errors[0];}stream=(_b=result===null||result===void 0?void 0:result.data)===null||_b===void 0?void 0:_b.stream;return [2/*return*/,{items:convertProperties((_c=stream===null||stream===void 0?void 0:stream.items)!==null&&_c!==void 0?_c:[],user,channels),hasNextPage:(_d=stream===null||stream===void 0?void 0:stream.pageInfo)===null||_d===void 0?void 0:_d.hasNextPage,paginationToken:(skip!==null&&skip!==void 0?skip:0)+take}];}});});};}var NEWS_QUERY=function NEWS_QUERY(includeAllItems,whereConditions){if(whereConditions===void 0){whereConditions='';}return gql(templateObject_1$2o||(templateObject_1$2o=__makeTemplateObject(["\n query GetStream(\n $skip: Int!\n $take: Int!\n $searchText: String\n $unreadOnly: Boolean\n ) {\n stream(\n searchText: $searchText\n unreadOnly: $unreadOnly\n order: [{ publishingDate: DESC }]\n skip: $skip\n take: $take\n includeAllItems: ","\n where: {\n type: { eq: NEWS }\n ","\n }\n ) {\n items {\n id: itemId\n knownNewsState\n type\n contentsList: contents {\n language\n intro\n headline\n title\n externalUrl\n active\n }\n modified\n publishingDate\n permalink\n channelsList: channels\n author {\n userPrincipalName\n displayName\n id: userId\n }\n owner {\n userPrincipalName\n displayName\n id: userId\n }\n onBehalfOf {\n userPrincipalName\n displayName\n id: userId\n }\n statistics {\n commentCount\n likeCount\n }\n metadata {\n feedbackSettings {\n feedbackOptions\n }\n }\n bannerInfo {\n type\n imageId\n videoId\n videoUrl\n videoSource\n isDirectVideoUrl\n }\n fileAccessToken\n keywordsList: keywords {\n id\n name\n groupId\n translations {\n key\n value\n }\n }\n isUnread\n hasNewComments\n groupIds\n useExternalContent\n }\n pageInfo {\n hasNextPage\n }\n }\n }\n "],["\n query GetStream(\n $skip: Int!\n $take: Int!\n $searchText: String\n $unreadOnly: Boolean\n ) {\n stream(\n searchText: $searchText\n unreadOnly: $unreadOnly\n order: [{ publishingDate: DESC }]\n skip: $skip\n take: $take\n includeAllItems: ","\n where: {\n type: { eq: NEWS }\n ","\n }\n ) {\n items {\n id: itemId\n knownNewsState\n type\n contentsList: contents {\n language\n intro\n headline\n title\n externalUrl\n active\n }\n modified\n publishingDate\n permalink\n channelsList: channels\n author {\n userPrincipalName\n displayName\n id: userId\n }\n owner {\n userPrincipalName\n displayName\n id: userId\n }\n onBehalfOf {\n userPrincipalName\n displayName\n id: userId\n }\n statistics {\n commentCount\n likeCount\n }\n metadata {\n feedbackSettings {\n feedbackOptions\n }\n }\n bannerInfo {\n type\n imageId\n videoId\n videoUrl\n videoSource\n isDirectVideoUrl\n }\n fileAccessToken\n keywordsList: keywords {\n id\n name\n groupId\n translations {\n key\n value\n }\n }\n isUnread\n hasNewComments\n groupIds\n useExternalContent\n }\n pageInfo {\n hasNextPage\n }\n }\n }\n "])),includeAllItems,whereConditions);};var templateObject_1$2o;
|
|
131885
131885
|
|
|
131886
131886
|
var PublishableItemDetailViewContainer = function PublishableItemDetailViewContainer(_a) {
|
|
131887
131887
|
var preventExternalContentAutoRedirect = _a.preventExternalContentAutoRedirect,
|
|
@@ -132745,10 +132745,10 @@ function useNewsItemClickHandler() {
|
|
|
132745
132745
|
});
|
|
132746
132746
|
}
|
|
132747
132747
|
}
|
|
132748
|
-
function useNewsLoaderWithFiltersAndPagination(pageSize, filter) {
|
|
132749
|
-
var dataLoader = useNewsStreamDataLoader(getNewsFilterDefinition());
|
|
132748
|
+
function useNewsLoaderWithFiltersAndPagination(pageSize, filter, searchText) {
|
|
132749
|
+
var dataLoader = useNewsStreamDataLoader(getNewsFilterDefinition(), searchText);
|
|
132750
132750
|
|
|
132751
|
-
var _a = useItemLoaderWithPreFetch(pageSize, dataLoader, [filter]),
|
|
132751
|
+
var _a = useItemLoaderWithPreFetch(pageSize, dataLoader, [filter, searchText]),
|
|
132752
132752
|
items = _a.items,
|
|
132753
132753
|
isLoadingNextPage = _a.isLoadingNextPage,
|
|
132754
132754
|
isInitialLoading = _a.isInitialLoading,
|
|
@@ -133049,6 +133049,7 @@ var ItemLayoutMode;
|
|
|
133049
133049
|
|
|
133050
133050
|
var NewsList = function NewsList(_a) {
|
|
133051
133051
|
var filter = _a.filter,
|
|
133052
|
+
searchText = _a.searchText,
|
|
133052
133053
|
_b = _a.itemLayoutMode,
|
|
133053
133054
|
itemLayoutMode = _b === void 0 ? ItemLayoutMode.Default : _b,
|
|
133054
133055
|
onItemClick = _a.onItemClick,
|
|
@@ -133058,7 +133059,7 @@ var NewsList = function NewsList(_a) {
|
|
|
133058
133059
|
pageSize = _c === void 0 ? 8 : _c,
|
|
133059
133060
|
className = _a.className;
|
|
133060
133061
|
|
|
133061
|
-
var _d = useNewsLoaderWithFiltersAndPagination(pageSize, filter),
|
|
133062
|
+
var _d = useNewsLoaderWithFiltersAndPagination(pageSize, filter, searchText),
|
|
133062
133063
|
items = _d.items,
|
|
133063
133064
|
showSpinner = _d.isInitialLoading,
|
|
133064
133065
|
isLoadingNextPage = _d.isLoadingNextPage,
|
|
@@ -133639,6 +133640,7 @@ var templateObject_1$j;
|
|
|
133639
133640
|
|
|
133640
133641
|
var NewsGrid = function NewsGrid(_a) {
|
|
133641
133642
|
var filter = _a.filter,
|
|
133643
|
+
searchText = _a.searchText,
|
|
133642
133644
|
hidePagination = _a.hidePagination,
|
|
133643
133645
|
_b = _a.columnCount,
|
|
133644
133646
|
columnCount = _b === void 0 ? 4 : _b,
|
|
@@ -133648,7 +133650,7 @@ var NewsGrid = function NewsGrid(_a) {
|
|
|
133648
133650
|
className = _a.className;
|
|
133649
133651
|
var itemsToShowPerPage = rowCount * columnCount;
|
|
133650
133652
|
|
|
133651
|
-
var _d = useNewsLoaderWithFiltersAndPagination(itemsToShowPerPage, filter),
|
|
133653
|
+
var _d = useNewsLoaderWithFiltersAndPagination(itemsToShowPerPage, filter, searchText),
|
|
133652
133654
|
items = _d.items,
|
|
133653
133655
|
showSpinner = _d.isInitialLoading,
|
|
133654
133656
|
isLoadingNextPage = _d.isLoadingNextPage,
|
package/index.umd.js
CHANGED
|
@@ -87327,9 +87327,9 @@
|
|
|
87327
87327
|
}), void 0);
|
|
87328
87328
|
};
|
|
87329
87329
|
|
|
87330
|
-
var version$1 = "0.4.0-preview.
|
|
87331
|
-
var buildId = "
|
|
87332
|
-
var commitId = "
|
|
87330
|
+
var version$1 = "0.4.0-preview.241";
|
|
87331
|
+
var buildId = "99061";
|
|
87332
|
+
var commitId = "9d41edf38c4702879173fc8d6bd420325af4046c";
|
|
87333
87333
|
var isCustomerBuild = false;
|
|
87334
87334
|
var buildInfo = {
|
|
87335
87335
|
version: version$1,
|
|
@@ -131567,7 +131567,7 @@
|
|
|
131567
131567
|
apiItem.fileAccessToken=cachedItem.fileAccessToken;}});observer.next(apiPage_1);observer.complete();return [3/*break*/,4];case 3:err_1=_a.sent();observer.error(err_1);return [3/*break*/,4];case 4:return [2/*return*/];}});});})();});}function validateFileAccessTokens(page,modifyFunc){if(!page||!page.items){return;}page.items.forEach(function(item){var isTokenValid=isTokenStillValid(item.fileAccessToken);modifyFunc(isTokenValid,item);});}var NewsApiService=/** @class */function(){function NewsApiService(factory,subscriptionId,storage){var _this=this;this.factory=factory;this.storage=storage;this.trackExternalItem=function(itemId,itemType){return _this.api.custom(itemType+"/"+encodeURIComponent(itemId)+"/external_url/track").get().then(function(result){return result.body().data();});};this.getAllNews=function(filterDefinition,paginationToken){return fetchNewsItems('news',NewsApiService.allNewsCacheKey,_this.api,_this.storage,paginationToken,__assign(__assign({},filterDefinition||{}),{includePromoted:true}));};this.getAllUnreadNews=function(filterDefinition,paginationToken){return fetchNewsItems('news',NewsApiService.allNewsCacheKey,_this.api,_this.storage,paginationToken,__assign(__assign({},filterDefinition||{}),{unreadOnly:true,pageSize:0}));};this.getMyNews=function(filterDefinition,paginationToken){return fetchNewsItems('users/current/news',NewsApiService.newsCacheKey,_this.api,_this.storage,paginationToken,filterDefinition);};this.getMyUnreadNews=function(filterDefinition,paginationToken){return fetchNewsItems('users/current/news/unread',NewsApiService.myUnreadNewsCacheKey,_this.api,_this.storage,paginationToken,filterDefinition,true);};this.getBookmarks=function(filterDefinition){return fetchNewsItems('users/current/bookmarks',NewsApiService.bookmarksCacheKey,_this.api,_this.storage,null,filterDefinition,true);};this.getNewsFromCache=function(){return __awaiter(_this,void 0,void 0,function(){var _a;return __generator(this,function(_b){switch(_b.label){case 0:return [4/*yield*/,this.storage.getObject(NewsApiService.newsItemsCacheKey)];case 1:return [2/*return*/,(_a=_b.sent())!==null&&_a!==void 0?_a:[]];}});});};this.get=function(newsId){var getFromCache=function getFromCache(id){return __awaiter(_this,void 0,void 0,function(){var cache,hits;return __generator(this,function(_a){switch(_a.label){case 0:return [4/*yield*/,this.getNewsFromCache()];case 1:cache=_a.sent();hits=cache.filter(function(i){return i.id===id;});return [2/*return*/,hits.length>0?hits[0]:null];}});});};var getFromApi=function getFromApi(id){return from(_this.api.all('news').get(id)).pipe(mergeMap(function(res){return updateItemCache(res.body().data());}));};var updateItemCache=function updateItemCache(item){return __awaiter(_this,void 0,void 0,function(){var fromCache,index,cacheItem,clonedCachedItem,clonedNewItem;return __generator(this,function(_a){switch(_a.label){case 0:if(item.statistics){itemStatisticsCache[item.id]=Promise.resolve(__assign({},item.statistics));}return [4/*yield*/,this.getNewsFromCache()];case 1:fromCache=_a.sent();index=fromCache.findIndex(function(i){return i.id===item.id;});if(index>-1){cacheItem=fromCache[index];if(isTokenStillValid(cacheItem.fileAccessToken)){clonedCachedItem=__assign({},cacheItem);delete clonedCachedItem.fileAccessToken;clonedNewItem=__assign({},item);delete clonedNewItem.fileAccessToken;if(JSON.stringify(clonedCachedItem)===JSON.stringify(clonedNewItem)){return [2/*return*/,null];}}fromCache.splice(index,1,item);}else {fromCache.push(item);}return [4/*yield*/,this.storage.set(NewsApiService.newsItemsCacheKey,fromCache)];case 2:_a.sent();return [2/*return*/,item];}});});};return concat(getFromCache(newsId),getFromApi(newsId)).pipe(filter(function(i){return i!=null;}),catchError(function(err){if(err.response&&err.response.statusCode===404){return of(null);}else {return throwError(err);}}));};this.getImageUrlWithToken=function(token,itemId,subscriptionId,resourceType,imageIdentifier,width,height){if(imageIdentifier===void 0){imageIdentifier='banner';}return _this.factory.createApiUrl("/"+resourceType+"/"+itemId+"/images/"+imageIdentifier+"/"+width+"/"+(height||''),{access_token:token,subscriptionId:subscriptionId});};this.getStatistics=function(newsId){if(!itemStatisticsCache[newsId]){itemStatisticsCache[newsId]=_this.api.custom("news/"+newsId+"/statistics").get().then(function(result){return result.body().data();}).then(function(result){var feedbackCountsKeys=Object.keys(result.feedbackCounts);return {bookmarkCount:result.bookmarkCount,likeCount:result.feedbackCounts[feedbackCountsKeys.find(function(k){return k==='like';})],commentCount:result.commentCount,confirmationCount:result.feedbackCounts[feedbackCountsKeys.find(function(k){return k==='confirm';})],readCount:result.readCount};});}return itemStatisticsCache[newsId];};this.refreshStatistics=function(itemId,delta){return __awaiter(_this,void 0,void 0,function(){var _this=this;return __generator(this,function(_a){switch(_a.label){case 0:// update statistics cache with new delta
|
|
131568
131568
|
if(!itemStatisticsCache[itemId]){return [2/*return*/];}return [4/*yield*/,itemStatisticsCache[itemId].then(function(statistics){var updatedStatistics=NewsApiService.getUpdatedStatistics(statistics,delta);_this.tryUpdateStatisticsInCache(itemId,updatedStatistics).then(null,null);itemStatisticsCache[itemId]=Promise.resolve(updatedStatistics);onStatisticsUpdated.next(updatedStatistics);})];case 1:_a.sent();return [2/*return*/];}});});};this.tryUpdateStatisticsInCache=function(newsId,statistics){return __awaiter(_this,void 0,void 0,function(){var fromCache,index,item;return __generator(this,function(_a){switch(_a.label){case 0:return [4/*yield*/,this.getNewsFromCache()];case 1:fromCache=_a.sent();index=fromCache.findIndex(function(i){return i.id===newsId;});item=fromCache[index];if(!item||!item.statistics){return [2/*return*/];}item.statistics=statistics;fromCache.splice(index,1,item);return [4/*yield*/,this.storage.set(NewsApiService.newsItemsCacheKey,fromCache)];case 2:_a.sent();return [2/*return*/];}});});};this.getExternalItemRoute=function(resourceType,itemId,accessToken){return _this.factory.createApiUrl("/"+resourceType+"/"+encodeURIComponent(itemId)+"/external_url",{access_token:accessToken});};this.api=factory.createApi(false,subscriptionId);}NewsApiService.getUpdatedStatistics=function(curr,delta){var _a,_b,_c,_d,_e,_f;return {bookmarkCount:curr.bookmarkCount+((_a=delta.bookmarkCount)!==null&&_a!==void 0?_a:0),commentCount:curr.commentCount+((_b=delta.commentCount)!==null&&_b!==void 0?_b:0),likeCount:curr.likeCount+((_c=delta.likeCount)!==null&&_c!==void 0?_c:0),confirmationCount:curr.confirmationCount+((_d=delta.confirmationCount)!==null&&_d!==void 0?_d:0),readCount:curr.readCount+((_e=delta.readCount)!==null&&_e!==void 0?_e:0),participantsCount:curr.participantsCount+((_f=delta.participantsCount)!==null&&_f!==void 0?_f:0)};};NewsApiService.bookmarksCacheKey='NewsService::BookmarksV2';NewsApiService.newsItemsCacheKey='NewsService::NewsItems';NewsApiService.newsCacheKey='NewsService::News';NewsApiService.allNewsCacheKey='NewsService::AllNews';NewsApiService.myUnreadNewsCacheKey='NewsService::MyUnreadNews';return NewsApiService;}();function useNewsApi(){var storage=useStorage();var factory=useApiFactory();var identifier=React$d.useContext(SubscriptionIdContext).identifier;return React$d.useMemo(function(){return new NewsApiService(factory,identifier===null||identifier===void 0?void 0:identifier.id,storage);},[factory,identifier,storage]);}function usePagesApi(){var api=useApi();var createApiUrl=useApiFactory().createApiUrl;return React$d.useMemo(function(){return {loadPage:loadPage,loadPageChildren:loadPageChildren,getRootPagesNavigation:getRootPagesNavigation,getPublishedRootPages:getPublishedRootPages,searchPublishedPages:searchPublishedPages,getSubpages:getSubpages,searchPages:searchPages,getDocumentFileUrl:getDocumentFileUrl,searchToc:searchToc};function loadPage(id){return api.all('pages').get(id,{includeNavigationContext:true}).then(function(response){var page=response.body().data();itemStatisticsCache[page.id]=Promise.resolve(__assign({},page.statistics));return page;});}function loadPageChildren(id){return api.all("pages/"+id+"/navigation/children").getAll().then(function(r){return r.body().map(function(g){return g.data();});});}function getRootPagesNavigation(){return api.all('pages').getAll().then(function(r){return r.body().map(function(g){return g.data();});});}function getPublishedRootPages(filter){var rootPagesFilter=__assign(__assign({},filter),{rootPagesOnly:true});return searchPages('pages',rootPagesFilter);}function searchPublishedPages(filter){return searchPages('pages',filter);}function getSubpages(parentId,filter){var subPagesFilter=__assign(__assign({},filter),{parentId:parentId});if(!subPagesFilter.pageSize){// return all subpages & documents
|
|
131569
131569
|
subPagesFilter.pageSize=0;}return searchPages('pages',subPagesFilter);}function searchToc(basePath,searchValue){return searchPages(basePath,{pageSize:100,search:searchValue,searchInTitlesOnly:true});}function searchPages(basePath,filter){if(filter){filter=__assign({},filter);if(!filter.restrictToPageContext){delete filter.pageContextId;}// we never need / want to send this param to the API, only used for the UI
|
|
131570
|
-
delete filter.restrictToPageContext;}var params=__assign(__assign({},filter),getCommaSeparatedKeywordsString(filter===null||filter===void 0?void 0:filter.keywords));return api.all(basePath+"/search").get('',params).then(function(result){return result.body().data();});}function getDocumentFileUrl(basePath,subscriptionId,pageId,fileId,language,token){return createApiUrl("/"+basePath+"/"+pageId+"/"+language+"/documents/"+fileId,{access_token:token,subscriptionId:subscriptionId});}},[api,createApiUrl]);}function usePostsApi(){var searchAccounts=useAccountApi().searchAccounts;var api=useApi();return React$d.useMemo(function(){return {createPost:createPost,togglePostLike:togglePostLike,getPosts:getPosts,updatePost:updatePost,deletePost:deletePost,getPost:getPost,getPostThread:getPostThread,translatePost:translatePost,searchPostMentionUsers:searchPostMentionUsers};function createPost(post){return api.all("posts").post(post).then(function(result){return result.body().data();});}function togglePostLike(postId,isLiked){if(isLiked){return api.custom("posts/"+postId+"/feedback/like").put({});}else {return api.custom("posts/"+postId+"/feedback/like").delete();}}function getPosts(filter){var groupIds=[];for(var _i=1;_i<arguments.length;_i++){groupIds[_i-1]=arguments[_i];}return api.custom("posts?"+queryString.stringify(__assign(__assign({},filter),{groupId:groupIds}))).get().then(function(res){return res.body().data();});}function updatePost(postId,content,attachments,keywords){return api.all('posts').patch(postId,{content:content,attachments:attachments,keywords:keywords}).then(function(result){return result.body().data();});}function deletePost(postId){return api.all("posts").delete(postId);}function getPost(postId){return api.all('posts').get(postId).then(function(result){return result.body().data();});}function getPostThread(postId,threadId){return api.custom("posts/"+postId+"/comments/"+threadId+"/thread").get().then(function(result){return result.body().data();});}function translatePost(postId,language){return api.custom("posts/"+postId+"/content/"+language).get().then(function(res){return res.body().data();});}function searchPostMentionUsers(searchText,postGroupId){return searchAccounts({search:searchText,type:AccountType.User,localOnly:true,groupId:[postGroupId],excludeApiUsers:true});}},[api,searchAccounts]);}function useEmbeddedObjectValidator(){var _this=this;var getPost=usePostsApi().getPost;var getNews=useNewsApi().get;var loadPage=usePagesApi().loadPage;var getEvent=useEventsApi().getEvent;return function(embeddedObject){return __awaiter(_this,void 0,void 0,function(){var _a,item,error_1;return __generator(this,function(_b){switch(_b.label){case 0:_b.trys.push([0,11,,12]);_a=embeddedObject.type;switch(_a){case AttachmentType.Post:return [3/*break*/,1];case AttachmentType.News:return [3/*break*/,3];case AttachmentType.Page:return [3/*break*/,5];case AttachmentType.Event:return [3/*break*/,7];}return [3/*break*/,9];case 1:return [4/*yield*/,getPost(embeddedObject.id)];case 2:_b.sent();return [2/*return*/,true];case 3:return [4/*yield*/,getNews(embeddedObject.id).toPromise()];case 4:item=_b.sent();return [2/*return*/,!!item];case 5:return [4/*yield*/,loadPage(embeddedObject.id)];case 6:_b.sent();return [2/*return*/,true];case 7:return [4/*yield*/,getEvent(embeddedObject.id)];case 8:_b.sent();return [2/*return*/,true];case 9:throw Error('Invalid type');case 10:return [3/*break*/,12];case 11:error_1=_b.sent();logger.error(error_1);return [2/*return*/,false];case 12:return [2/*return*/];}});});};}var RichCommentInput=/*#__PURE__*/React$d.forwardRef(function(_a,ref){var className=_a.className,buttons=_a.buttons,attachments=_a.attachments,deletedAttachmentUrls=_a.deletedAttachmentUrls,onAttachmentsChange=_a.onAttachmentsChange;_a.onDeleteAttachment;var allowAttachments=_a.allowAttachments,useLargeDropTarget=_a.useLargeDropTarget,disableDragAndDrop=_a.disableDragAndDrop;_a.allowKeywords;var defaultKeywords=_a.defaultKeywords,availableKeywords=_a.availableKeywords,mandatoryKeywords=_a.mandatoryKeywords,showKeywordsPicker=_a.showKeywordsPicker,onKeywordsChange=_a.onKeywordsChange,disableAddGif=_a.disableAddGif,disableAddFiles=_a.disableAddFiles,props=__rest(_a,["className","buttons","attachments","deletedAttachmentUrls","onAttachmentsChange","onDeleteAttachment","allowAttachments","useLargeDropTarget","disableDragAndDrop","allowKeywords","defaultKeywords","availableKeywords","mandatoryKeywords","showKeywordsPicker","onKeywordsChange","disableAddGif","disableAddFiles"]);var onDrop=React$d.useCallback(handleDropFiles,[attachments,onAttachmentsChange]);var _b=useDropzone({onDrop:onDrop}),getRootProps=_b.getRootProps,getInputProps=_b.getInputProps,open=_b.open,isDragActive=_b.isDragActive;var inputRef=React$d.useRef(null);var formatMessage=useIntl().formatMessage;React$d.useImperativeHandle(ref,function(){return inputRef.current;},[inputRef]);var user=useCurrentUser();var debouncedOnEmbeddedObjectsOrVideosChange=useDebouncedCallback(onEmbeddedObjectsOrVideosChange,500)[0];var validateEmbeddedObject=useEmbeddedObjectValidator();var isGifButtonDisabled=props.disabled||disableAddGif;var isAttachmentsButtonDisabled=props.disabled||disableAddFiles;if(props.disabled||!allowAttachments){return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(CommentInput,__assign({ref:inputRef,className:className,buttons:buttons},props),void 0),showKeywordsPicker&&!props.disabled&&jsxRuntime.jsx(KeywordsPicker,{defaultKeywords:defaultKeywords,availableKeywords:availableKeywords,mandatoryKeywords:mandatoryKeywords,onChangeKeywords:onKeywordsChange},void 0)]},void 0);}return jsxRuntime.jsxs("div",__assign({className:className},{children:[jsxRuntime.jsx("input",__assign({},getInputProps()),void 0),!disableDragAndDrop&&jsxRuntime.jsx(DropTarget,__assign({isActive:isDragActive,isLarge:useLargeDropTarget},getRootProps({onClick:function(e){return e.stopPropagation();}}),{"data-drop-target":true},{children:isDragActive&&jsxRuntime.jsx(DropInfo,{isLarge:useLargeDropTarget},void 0)}),void 0),jsxRuntime.jsx(CommentInput,__assign({},props,{onChange:handleChange,ref:inputRef,buttons:jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(GifButton,{disabled:isGifButtonDisabled,onGifClick:handleGifClick},'gifButton'+isGifButtonDisabled),jsxRuntime.jsx(IconButton,{iconProps:{iconName:'Attach'},onClick:open,disabled:isAttachmentsButtonDisabled,"data-button-type":"attach",ariaLabel:formatMessage({id:'AriaLabel.attachmentsButton'})},'attachmentsButton'+isAttachmentsButtonDisabled),buttons]},void 0)}),void 0),showKeywordsPicker&&!props.disabled&&jsxRuntime.jsx(KeywordsPicker,{defaultKeywords:defaultKeywords,availableKeywords:availableKeywords,mandatoryKeywords:mandatoryKeywords,onChangeKeywords:onKeywordsChange},void 0)]}),void 0);function handleChange(content){props.onChange(content);debouncedOnEmbeddedObjectsOrVideosChange(content);}function onEmbeddedObjectsOrVideosChange(content){return __awaiter(this,void 0,void 0,function(){var existingAttachments,newAttachments,matchedVideoUrls,_i,matchedVideoUrls_1,matchedUrl,url,id,matchedEmbeddedObjects,_a,matchedEmbeddedObjects_1,matchedEmbeddedObject,url,isValid;return __generator(this,function(_b){switch(_b.label){case 0:existingAttachments=new Set(attachments.map(function(a){return a.url;}));newAttachments=[];matchedVideoUrls=__spreadArray([],Array.from(getAllVideosFromString(content)));for(_i=0,matchedVideoUrls_1=matchedVideoUrls;_i<matchedVideoUrls_1.length;_i++){matchedUrl=matchedVideoUrls_1[_i];url=matchedUrl.url;id=new VideoUrlParser(url).id;if(!existingAttachments.has(url)){newAttachments.push(__assign({id:id},matchedUrl));existingAttachments.add(url);}}matchedEmbeddedObjects=__spreadArray([],Array.from(getEmbeddedObjectsFromString(content)).filter(function(ob){return ob.subscriptionIdentifier===user.subscription.id||ob.subscriptionIdentifier===user.subscription.subscriptionHandle;}));_a=0,matchedEmbeddedObjects_1=matchedEmbeddedObjects;_b.label=1;case 1:if(!(_a<matchedEmbeddedObjects_1.length))return [3/*break*/,4];matchedEmbeddedObject=matchedEmbeddedObjects_1[_a];url=matchedEmbeddedObject.url;if(!(!existingAttachments.has(url)&&!(deletedAttachmentUrls===null||deletedAttachmentUrls===void 0?void 0:deletedAttachmentUrls.includes(url))))return [3/*break*/,3];return [4/*yield*/,validateEmbeddedObject(matchedEmbeddedObject)];case 2:isValid=_b.sent();if(isValid){newAttachments.push(__assign({},matchedEmbeddedObject));existingAttachments.add(url);}_b.label=3;case 3:_a++;return [3/*break*/,1];case 4:if(newAttachments.length!==0){onAttachmentsChange(attachments.concat(newAttachments));}return [2/*return*/];}});});}function handleGifClick(newAttachment){return __awaiter(this,void 0,void 0,function(){return __generator(this,function(_a){onAttachmentsChange(attachments.filter(function(attachment){return attachment.type!==AttachmentType.Giphy;}).concat(newAttachment));return [2/*return*/];});});}function handleDropFiles(dropResult){return __awaiter(this,void 0,void 0,function(){var newFiles,_i,_a,image,size;return __generator(this,function(_b){switch(_b.label){case 0:newFiles=dropResult.map(function(f){return {id:createId(),file:f,filename:f.name,previewUrl:URL.createObjectURL(f),type:f.type.startsWith('image/')?AttachmentType.Image:AttachmentType.File};});_i=0,_a=newFiles.filter(function(f){return f.type===AttachmentType.Image;});_b.label=1;case 1:if(!(_i<_a.length))return [3/*break*/,4];image=_a[_i];return [4/*yield*/,getImageSize(image.previewUrl)];case 2:size=_b.sent();image.width=size.width;image.height=size.height;_b.label=3;case 3:_i++;return [3/*break*/,1];case 4:onAttachmentsChange(attachments.concat(newFiles));return [2/*return*/];}});});}});var getMicrosoftStreamEmbedVideoUrl=function getMicrosoftStreamEmbedVideoUrl(id,autoPlay){if(autoPlay===void 0){autoPlay=false;}return "https://web.microsoftstream.com/embed/video/"+id+"?autoplay="+autoPlay+"&showInfo=true";};var getMicrosoftStreamVideoUrl=function getMicrosoftStreamVideoUrl(id){return "https://web.microsoftstream.com/video/"+id+"?autoplay=true";};var VideoElementGenerator=/** @class */function(){function VideoElementGenerator(videoInfo,iframeAreaLabel,autoplay,width,videoProperties){this.videoInfo=videoInfo;this.iframeAreaLabel=iframeAreaLabel;this.autoplay=autoplay;this.width=width;this.videoProperties=videoProperties;}VideoElementGenerator.prototype.getYouTubeVideoElement=function(){// <iframe
|
|
131570
|
+
delete filter.restrictToPageContext;}var params=__assign(__assign({},filter),getCommaSeparatedKeywordsString(filter===null||filter===void 0?void 0:filter.keywords));return api.all(basePath+"/search").get('',params).then(function(result){return result.body().data();});}function getDocumentFileUrl(basePath,subscriptionId,pageId,fileId,language,token){return createApiUrl("/"+basePath+"/"+pageId+"/"+language+"/documents/"+fileId,{access_token:token,subscriptionId:subscriptionId});}},[api,createApiUrl]);}function usePostsApi(){var searchAccounts=useAccountApi().searchAccounts;var api=useApi();return React$d.useMemo(function(){return {createPost:createPost,togglePostLike:togglePostLike,getPosts:getPosts,updatePost:updatePost,deletePost:deletePost,getPost:getPost,getPostThread:getPostThread,translatePost:translatePost,searchPostMentionUsers:searchPostMentionUsers};function createPost(post){return api.all("posts").post(post).then(function(result){return result.body().data();});}function togglePostLike(postId,isLiked){if(isLiked){return api.custom("posts/"+postId+"/feedback/like").put({});}else {return api.custom("posts/"+postId+"/feedback/like").delete();}}function getPosts(filter){var groupIds=[];for(var _i=1;_i<arguments.length;_i++){groupIds[_i-1]=arguments[_i];}var params=__assign(__assign(__assign({},filter),{groupId:groupIds}),getCommaSeparatedKeywordsString(filter===null||filter===void 0?void 0:filter.keywords));return api.custom("posts?"+queryString.stringify(params)).get().then(function(res){return res.body().data();});}function updatePost(postId,content,attachments,keywords){return api.all('posts').patch(postId,{content:content,attachments:attachments,keywords:keywords}).then(function(result){return result.body().data();});}function deletePost(postId){return api.all("posts").delete(postId);}function getPost(postId){return api.all('posts').get(postId).then(function(result){return result.body().data();});}function getPostThread(postId,threadId){return api.custom("posts/"+postId+"/comments/"+threadId+"/thread").get().then(function(result){return result.body().data();});}function translatePost(postId,language){return api.custom("posts/"+postId+"/content/"+language).get().then(function(res){return res.body().data();});}function searchPostMentionUsers(searchText,postGroupId){return searchAccounts({search:searchText,type:AccountType.User,localOnly:true,groupId:[postGroupId],excludeApiUsers:true});}},[api,searchAccounts]);}function useEmbeddedObjectValidator(){var _this=this;var getPost=usePostsApi().getPost;var getNews=useNewsApi().get;var loadPage=usePagesApi().loadPage;var getEvent=useEventsApi().getEvent;return function(embeddedObject){return __awaiter(_this,void 0,void 0,function(){var _a,item,error_1;return __generator(this,function(_b){switch(_b.label){case 0:_b.trys.push([0,11,,12]);_a=embeddedObject.type;switch(_a){case AttachmentType.Post:return [3/*break*/,1];case AttachmentType.News:return [3/*break*/,3];case AttachmentType.Page:return [3/*break*/,5];case AttachmentType.Event:return [3/*break*/,7];}return [3/*break*/,9];case 1:return [4/*yield*/,getPost(embeddedObject.id)];case 2:_b.sent();return [2/*return*/,true];case 3:return [4/*yield*/,getNews(embeddedObject.id).toPromise()];case 4:item=_b.sent();return [2/*return*/,!!item];case 5:return [4/*yield*/,loadPage(embeddedObject.id)];case 6:_b.sent();return [2/*return*/,true];case 7:return [4/*yield*/,getEvent(embeddedObject.id)];case 8:_b.sent();return [2/*return*/,true];case 9:throw Error('Invalid type');case 10:return [3/*break*/,12];case 11:error_1=_b.sent();logger.error(error_1);return [2/*return*/,false];case 12:return [2/*return*/];}});});};}var RichCommentInput=/*#__PURE__*/React$d.forwardRef(function(_a,ref){var className=_a.className,buttons=_a.buttons,attachments=_a.attachments,deletedAttachmentUrls=_a.deletedAttachmentUrls,onAttachmentsChange=_a.onAttachmentsChange;_a.onDeleteAttachment;var allowAttachments=_a.allowAttachments,useLargeDropTarget=_a.useLargeDropTarget,disableDragAndDrop=_a.disableDragAndDrop;_a.allowKeywords;var defaultKeywords=_a.defaultKeywords,availableKeywords=_a.availableKeywords,mandatoryKeywords=_a.mandatoryKeywords,showKeywordsPicker=_a.showKeywordsPicker,onKeywordsChange=_a.onKeywordsChange,disableAddGif=_a.disableAddGif,disableAddFiles=_a.disableAddFiles,props=__rest(_a,["className","buttons","attachments","deletedAttachmentUrls","onAttachmentsChange","onDeleteAttachment","allowAttachments","useLargeDropTarget","disableDragAndDrop","allowKeywords","defaultKeywords","availableKeywords","mandatoryKeywords","showKeywordsPicker","onKeywordsChange","disableAddGif","disableAddFiles"]);var onDrop=React$d.useCallback(handleDropFiles,[attachments,onAttachmentsChange]);var _b=useDropzone({onDrop:onDrop}),getRootProps=_b.getRootProps,getInputProps=_b.getInputProps,open=_b.open,isDragActive=_b.isDragActive;var inputRef=React$d.useRef(null);var formatMessage=useIntl().formatMessage;React$d.useImperativeHandle(ref,function(){return inputRef.current;},[inputRef]);var user=useCurrentUser();var debouncedOnEmbeddedObjectsOrVideosChange=useDebouncedCallback(onEmbeddedObjectsOrVideosChange,500)[0];var validateEmbeddedObject=useEmbeddedObjectValidator();var isGifButtonDisabled=props.disabled||disableAddGif;var isAttachmentsButtonDisabled=props.disabled||disableAddFiles;if(props.disabled||!allowAttachments){return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(CommentInput,__assign({ref:inputRef,className:className,buttons:buttons},props),void 0),showKeywordsPicker&&!props.disabled&&jsxRuntime.jsx(KeywordsPicker,{defaultKeywords:defaultKeywords,availableKeywords:availableKeywords,mandatoryKeywords:mandatoryKeywords,onChangeKeywords:onKeywordsChange},void 0)]},void 0);}return jsxRuntime.jsxs("div",__assign({className:className},{children:[jsxRuntime.jsx("input",__assign({},getInputProps()),void 0),!disableDragAndDrop&&jsxRuntime.jsx(DropTarget,__assign({isActive:isDragActive,isLarge:useLargeDropTarget},getRootProps({onClick:function(e){return e.stopPropagation();}}),{"data-drop-target":true},{children:isDragActive&&jsxRuntime.jsx(DropInfo,{isLarge:useLargeDropTarget},void 0)}),void 0),jsxRuntime.jsx(CommentInput,__assign({},props,{onChange:handleChange,ref:inputRef,buttons:jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(GifButton,{disabled:isGifButtonDisabled,onGifClick:handleGifClick},'gifButton'+isGifButtonDisabled),jsxRuntime.jsx(IconButton,{iconProps:{iconName:'Attach'},onClick:open,disabled:isAttachmentsButtonDisabled,"data-button-type":"attach",ariaLabel:formatMessage({id:'AriaLabel.attachmentsButton'})},'attachmentsButton'+isAttachmentsButtonDisabled),buttons]},void 0)}),void 0),showKeywordsPicker&&!props.disabled&&jsxRuntime.jsx(KeywordsPicker,{defaultKeywords:defaultKeywords,availableKeywords:availableKeywords,mandatoryKeywords:mandatoryKeywords,onChangeKeywords:onKeywordsChange},void 0)]}),void 0);function handleChange(content){props.onChange(content);debouncedOnEmbeddedObjectsOrVideosChange(content);}function onEmbeddedObjectsOrVideosChange(content){return __awaiter(this,void 0,void 0,function(){var existingAttachments,newAttachments,matchedVideoUrls,_i,matchedVideoUrls_1,matchedUrl,url,id,matchedEmbeddedObjects,_a,matchedEmbeddedObjects_1,matchedEmbeddedObject,url,isValid;return __generator(this,function(_b){switch(_b.label){case 0:existingAttachments=new Set(attachments.map(function(a){return a.url;}));newAttachments=[];matchedVideoUrls=__spreadArray([],Array.from(getAllVideosFromString(content)));for(_i=0,matchedVideoUrls_1=matchedVideoUrls;_i<matchedVideoUrls_1.length;_i++){matchedUrl=matchedVideoUrls_1[_i];url=matchedUrl.url;id=new VideoUrlParser(url).id;if(!existingAttachments.has(url)){newAttachments.push(__assign({id:id},matchedUrl));existingAttachments.add(url);}}matchedEmbeddedObjects=__spreadArray([],Array.from(getEmbeddedObjectsFromString(content)).filter(function(ob){return ob.subscriptionIdentifier===user.subscription.id||ob.subscriptionIdentifier===user.subscription.subscriptionHandle;}));_a=0,matchedEmbeddedObjects_1=matchedEmbeddedObjects;_b.label=1;case 1:if(!(_a<matchedEmbeddedObjects_1.length))return [3/*break*/,4];matchedEmbeddedObject=matchedEmbeddedObjects_1[_a];url=matchedEmbeddedObject.url;if(!(!existingAttachments.has(url)&&!(deletedAttachmentUrls===null||deletedAttachmentUrls===void 0?void 0:deletedAttachmentUrls.includes(url))))return [3/*break*/,3];return [4/*yield*/,validateEmbeddedObject(matchedEmbeddedObject)];case 2:isValid=_b.sent();if(isValid){newAttachments.push(__assign({},matchedEmbeddedObject));existingAttachments.add(url);}_b.label=3;case 3:_a++;return [3/*break*/,1];case 4:if(newAttachments.length!==0){onAttachmentsChange(attachments.concat(newAttachments));}return [2/*return*/];}});});}function handleGifClick(newAttachment){return __awaiter(this,void 0,void 0,function(){return __generator(this,function(_a){onAttachmentsChange(attachments.filter(function(attachment){return attachment.type!==AttachmentType.Giphy;}).concat(newAttachment));return [2/*return*/];});});}function handleDropFiles(dropResult){return __awaiter(this,void 0,void 0,function(){var newFiles,_i,_a,image,size;return __generator(this,function(_b){switch(_b.label){case 0:newFiles=dropResult.map(function(f){return {id:createId(),file:f,filename:f.name,previewUrl:URL.createObjectURL(f),type:f.type.startsWith('image/')?AttachmentType.Image:AttachmentType.File};});_i=0,_a=newFiles.filter(function(f){return f.type===AttachmentType.Image;});_b.label=1;case 1:if(!(_i<_a.length))return [3/*break*/,4];image=_a[_i];return [4/*yield*/,getImageSize(image.previewUrl)];case 2:size=_b.sent();image.width=size.width;image.height=size.height;_b.label=3;case 3:_i++;return [3/*break*/,1];case 4:onAttachmentsChange(attachments.concat(newFiles));return [2/*return*/];}});});}});var getMicrosoftStreamEmbedVideoUrl=function getMicrosoftStreamEmbedVideoUrl(id,autoPlay){if(autoPlay===void 0){autoPlay=false;}return "https://web.microsoftstream.com/embed/video/"+id+"?autoplay="+autoPlay+"&showInfo=true";};var getMicrosoftStreamVideoUrl=function getMicrosoftStreamVideoUrl(id){return "https://web.microsoftstream.com/video/"+id+"?autoplay=true";};var VideoElementGenerator=/** @class */function(){function VideoElementGenerator(videoInfo,iframeAreaLabel,autoplay,width,videoProperties){this.videoInfo=videoInfo;this.iframeAreaLabel=iframeAreaLabel;this.autoplay=autoplay;this.width=width;this.videoProperties=videoProperties;}VideoElementGenerator.prototype.getYouTubeVideoElement=function(){// <iframe
|
|
131571
131571
|
// src="https://www.youtube.com/embed/{videoId}?ecver=1" frameborder="0" allowfullscreen>
|
|
131572
131572
|
// </iframe>
|
|
131573
131573
|
var iframe=document.createElement('iframe');iframe.setAttribute('aria-label',this.iframeAreaLabel);iframe.setAttribute('src',"https://www.youtube.com/embed/"+this.videoInfo.id+"?rel=0&autoplay="+(this.autoplay?'1':'0'));iframe.setAttribute('frameborder','0');iframe.setAttribute('allowfullscreen','');return iframe;};VideoElementGenerator.prototype.getVimeoVideoElement=function(){// <iframe src="https://player.vimeo.com/video/{videoId}"
|
|
@@ -131755,7 +131755,7 @@
|
|
|
131755
131755
|
return [4/*yield*/,api.custom("editor/"+itemId+"/lease").put({leaseId:leaseId})];case 1:// update the lease
|
|
131756
131756
|
_a.sent();return [4/*yield*/,onRequestToken()];case 2:// renew the access token
|
|
131757
131757
|
expireLeaseToken=_a.sent();return [2/*return*/];}});});},1000*10);return {cancel:function(){return clearInterval(timer);},destroy:function(){clearInterval(timer);sendBeacon("/editor/"+itemId+"/lease/delete",expireLeaseToken,subscriptionId,{leaseId:leaseId});}};}function saveItem(subscriptionId,type,item,createLease){if(createLease===void 0){createLease=true;}return from(onRequestToken()).pipe(switchMap(function(token){var config={method:item.id==null?'POST':'PUT',body:JSON.stringify(item),headers:{authorization:'Bearer '+token,'subscription-id':subscriptionId,'Content-Type':'application/json'}};var basePath=type?'/editor/'+type:'/editor';var path=item.id==null?basePath:basePath+"/"+item.id;// note (sl): use custom fetch, since post/put with query string is annoying to build with restful.js
|
|
131758
|
-
return fetchFromApi(path+"?createLease="+createLease.toString(),config);}),switchMap(function(response){if(response.status===409){return new Promise(function(_,reject){return response.json().then(function(account){if(account.userPrincipalName!=null){reject({account:account});}else {reject({status:response.status,error:response.statusText});}});});}else if(response.ok){return from(response.json());}else {return throwError({status:response.status,error:response.statusText});}}));}},[onRequestToken,api,fetchFromApi,sendBeacon]);}function useNewsEditorApi(){var api=useApi();var saveItem=useEditorApi().saveItem;return React$d.useMemo(function(){return {getNews:getNews,unpublish:unpublish,save:save};function getNews(newsId){return __awaiter(this,void 0,void 0,function(){var response,error_1;return __generator(this,function(_a){switch(_a.label){case 0:_a.trys.push([0,3,,4]);return [4/*yield*/,api.all('editor/news').get(newsId)];case 1:response=_a.sent();return [4/*yield*/,response.body().data()];case 2:return [2/*return*/,_a.sent()];case 3:error_1=_a.sent();if(error_1.response&&error_1.response.statusCode===404){return [2/*return*/,null];}else {throw error_1;}case 4:return [2/*return*/];}});});}function unpublish(id,leaseId){var path=leaseId?"news/"+id+"?"+queryString.stringify({leaseId:leaseId}):"news/"+id;return from(api.custom(path).delete());}function save(item,subscriptionId){if(item.id==null){item.source='Condense';}return saveItem(subscriptionId,ItemResourceTypes.News,item);}},[api,saveItem]);}_styled__default["default"].div.withConfig({displayName:"GlobalSearchButton__Host",componentId:"sc-1c5dmlm-0"})(templateObject_1$2$1||(templateObject_1$2$1=__makeTemplateObject(["\n display: flex;\n margin-top: ","px;\n justify-content: center;\n"],["\n display: flex;\n margin-top: ","px;\n justify-content: center;\n"])),spacingM);var templateObject_1$2$1;_styled__default["default"].article.withConfig({displayName:"StreamList__Host",componentId:"sc-1rdkc01-0"})(templateObject_2$1A||(templateObject_2$1A=__makeTemplateObject(["\n position: relative;\n margin-bottom: ","px;\n\n ",";\n"],["\n position: relative;\n margin-bottom: ","px;\n\n ",";\n"])),spacingM,function(p){return p.highlight&&_styled.css(templateObject_1$1$1||(templateObject_1$1$1=__makeTemplateObject(["\n &::after {\n content: '';\n border-right-width: ","px;\n border-right-color: ",";\n border-right-style: solid;\n position: absolute;\n top: 0;\n right: 0;\n bottom: 0;\n }\n "],["\n &::after {\n content: '';\n border-right-width: ","px;\n border-right-color: ",";\n border-right-style: solid;\n position: absolute;\n top: 0;\n right: 0;\n bottom: 0;\n }\n "])),spacingXs,p.theme.palette.accent);});var templateObject_1$1$1,templateObject_2$1A;function useNewsStreamDataLoader(filter){var _this=this;var client=useApolloClient();var user=useCurrentUser();var channels=React$d.useContext(LazySubscriptionContext).channels;return function(take,skip){return __awaiter(_this,void 0,void 0,function(){var variables,result,stream;var _a,_b,_c,_d;return __generator(this,function(_e){switch(_e.label){case 0:variables={take:take,skip:skip!==null&&skip!==void 0?skip:0};return [4/*yield*/,client.query({query:NEWS_QUERY(false,"\n "+CHANNELS_CONDITION(filter===null||filter===void 0?void 0:filter.channels,channels)+"\n "+KEYWORDS_CONDITION(filter===null||filter===void 0?void 0:filter.keywords)+"\n "+OWNER_CONDITION(filter===null||filter===void 0?void 0:filter.owner)+"\n "+PUBLISHING_DATE_CONDITION(filter===null||filter===void 0?void 0:filter.beforeDate,filter===null||filter===void 0?void 0:filter.afterDate)+"\n "+AUTHORS_CONDITION(filter===null||filter===void 0?void 0:filter.authors)+"\n "),fetchPolicy:'no-cache',variables:variables})];case 1:result=_e.sent();if(((_a=result===null||result===void 0?void 0:result.errors)===null||_a===void 0?void 0:_a.length)>0){logger.error(result.errors[0]);throw result.errors[0];}stream=(_b=result===null||result===void 0?void 0:result.data)===null||_b===void 0?void 0:_b.stream;return [2/*return*/,{items:convertProperties((_c=stream===null||stream===void 0?void 0:stream.items)!==null&&_c!==void 0?_c:[],user,channels),hasNextPage:(_d=stream===null||stream===void 0?void 0:stream.pageInfo)===null||_d===void 0?void 0:_d.hasNextPage,paginationToken:(skip!==null&&skip!==void 0?skip:0)+take}];}});});};}var NEWS_QUERY=function NEWS_QUERY(includeAllItems,whereConditions){if(whereConditions===void 0){whereConditions='';}return gql(templateObject_1$2o||(templateObject_1$2o=__makeTemplateObject(["\n query GetStream(\n $skip: Int!\n $take: Int!\n $searchText: String\n $unreadOnly: Boolean\n ) {\n stream(\n searchText: $searchText\n unreadOnly: $unreadOnly\n order: [{ publishingDate: DESC }]\n skip: $skip\n take: $take\n includeAllItems: ","\n where: {\n type: { eq: NEWS }\n ","\n }\n ) {\n items {\n id: itemId\n knownNewsState\n type\n contentsList: contents {\n language\n intro\n headline\n title\n externalUrl\n active\n }\n modified\n publishingDate\n permalink\n channelsList: channels\n author {\n userPrincipalName\n displayName\n id: userId\n }\n owner {\n userPrincipalName\n displayName\n id: userId\n }\n onBehalfOf {\n userPrincipalName\n displayName\n id: userId\n }\n statistics {\n commentCount\n likeCount\n }\n metadata {\n feedbackSettings {\n feedbackOptions\n }\n }\n bannerInfo {\n type\n imageId\n videoId\n videoUrl\n videoSource\n isDirectVideoUrl\n }\n fileAccessToken\n keywordsList: keywords {\n id\n name\n groupId\n translations {\n key\n value\n }\n }\n isUnread\n hasNewComments\n groupIds\n useExternalContent\n }\n pageInfo {\n hasNextPage\n }\n }\n }\n "],["\n query GetStream(\n $skip: Int!\n $take: Int!\n $searchText: String\n $unreadOnly: Boolean\n ) {\n stream(\n searchText: $searchText\n unreadOnly: $unreadOnly\n order: [{ publishingDate: DESC }]\n skip: $skip\n take: $take\n includeAllItems: ","\n where: {\n type: { eq: NEWS }\n ","\n }\n ) {\n items {\n id: itemId\n knownNewsState\n type\n contentsList: contents {\n language\n intro\n headline\n title\n externalUrl\n active\n }\n modified\n publishingDate\n permalink\n channelsList: channels\n author {\n userPrincipalName\n displayName\n id: userId\n }\n owner {\n userPrincipalName\n displayName\n id: userId\n }\n onBehalfOf {\n userPrincipalName\n displayName\n id: userId\n }\n statistics {\n commentCount\n likeCount\n }\n metadata {\n feedbackSettings {\n feedbackOptions\n }\n }\n bannerInfo {\n type\n imageId\n videoId\n videoUrl\n videoSource\n isDirectVideoUrl\n }\n fileAccessToken\n keywordsList: keywords {\n id\n name\n groupId\n translations {\n key\n value\n }\n }\n isUnread\n hasNewComments\n groupIds\n useExternalContent\n }\n pageInfo {\n hasNextPage\n }\n }\n }\n "])),includeAllItems,whereConditions);};var templateObject_1$2o;
|
|
131758
|
+
return fetchFromApi(path+"?createLease="+createLease.toString(),config);}),switchMap(function(response){if(response.status===409){return new Promise(function(_,reject){return response.json().then(function(account){if(account.userPrincipalName!=null){reject({account:account});}else {reject({status:response.status,error:response.statusText});}});});}else if(response.ok){return from(response.json());}else {return throwError({status:response.status,error:response.statusText});}}));}},[onRequestToken,api,fetchFromApi,sendBeacon]);}function useNewsEditorApi(){var api=useApi();var saveItem=useEditorApi().saveItem;return React$d.useMemo(function(){return {getNews:getNews,unpublish:unpublish,save:save};function getNews(newsId){return __awaiter(this,void 0,void 0,function(){var response,error_1;return __generator(this,function(_a){switch(_a.label){case 0:_a.trys.push([0,3,,4]);return [4/*yield*/,api.all('editor/news').get(newsId)];case 1:response=_a.sent();return [4/*yield*/,response.body().data()];case 2:return [2/*return*/,_a.sent()];case 3:error_1=_a.sent();if(error_1.response&&error_1.response.statusCode===404){return [2/*return*/,null];}else {throw error_1;}case 4:return [2/*return*/];}});});}function unpublish(id,leaseId){var path=leaseId?"news/"+id+"?"+queryString.stringify({leaseId:leaseId}):"news/"+id;return from(api.custom(path).delete());}function save(item,subscriptionId){if(item.id==null){item.source='Condense';}return saveItem(subscriptionId,ItemResourceTypes.News,item);}},[api,saveItem]);}_styled__default["default"].div.withConfig({displayName:"GlobalSearchButton__Host",componentId:"sc-1c5dmlm-0"})(templateObject_1$2$1||(templateObject_1$2$1=__makeTemplateObject(["\n display: flex;\n margin-top: ","px;\n justify-content: center;\n"],["\n display: flex;\n margin-top: ","px;\n justify-content: center;\n"])),spacingM);var templateObject_1$2$1;_styled__default["default"].article.withConfig({displayName:"StreamList__Host",componentId:"sc-1rdkc01-0"})(templateObject_2$1A||(templateObject_2$1A=__makeTemplateObject(["\n position: relative;\n margin-bottom: ","px;\n\n ",";\n"],["\n position: relative;\n margin-bottom: ","px;\n\n ",";\n"])),spacingM,function(p){return p.highlight&&_styled.css(templateObject_1$1$1||(templateObject_1$1$1=__makeTemplateObject(["\n &::after {\n content: '';\n border-right-width: ","px;\n border-right-color: ",";\n border-right-style: solid;\n position: absolute;\n top: 0;\n right: 0;\n bottom: 0;\n }\n "],["\n &::after {\n content: '';\n border-right-width: ","px;\n border-right-color: ",";\n border-right-style: solid;\n position: absolute;\n top: 0;\n right: 0;\n bottom: 0;\n }\n "])),spacingXs,p.theme.palette.accent);});var templateObject_1$1$1,templateObject_2$1A;function useNewsStreamDataLoader(filter,searchText){var _this=this;var client=useApolloClient();var user=useCurrentUser();var channels=React$d.useContext(LazySubscriptionContext).channels;return function(take,skip){return __awaiter(_this,void 0,void 0,function(){var variables,result,stream;var _a,_b,_c,_d;return __generator(this,function(_e){switch(_e.label){case 0:variables={take:take,skip:skip!==null&&skip!==void 0?skip:0,unreadOnly:filter===null||filter===void 0?void 0:filter.unreadOnly,searchText:searchText};return [4/*yield*/,client.query({query:NEWS_QUERY(false,"\n "+CHANNELS_CONDITION(filter===null||filter===void 0?void 0:filter.channels,channels)+"\n "+KEYWORDS_CONDITION(filter===null||filter===void 0?void 0:filter.keywords)+"\n "+OWNER_CONDITION(filter===null||filter===void 0?void 0:filter.owner)+"\n "+PUBLISHING_DATE_CONDITION(filter===null||filter===void 0?void 0:filter.beforeDate,filter===null||filter===void 0?void 0:filter.afterDate)+"\n "+AUTHORS_CONDITION(filter===null||filter===void 0?void 0:filter.authors)+"\n "),fetchPolicy:'no-cache',variables:variables})];case 1:result=_e.sent();if(((_a=result===null||result===void 0?void 0:result.errors)===null||_a===void 0?void 0:_a.length)>0){logger.error(result.errors[0]);throw result.errors[0];}stream=(_b=result===null||result===void 0?void 0:result.data)===null||_b===void 0?void 0:_b.stream;return [2/*return*/,{items:convertProperties((_c=stream===null||stream===void 0?void 0:stream.items)!==null&&_c!==void 0?_c:[],user,channels),hasNextPage:(_d=stream===null||stream===void 0?void 0:stream.pageInfo)===null||_d===void 0?void 0:_d.hasNextPage,paginationToken:(skip!==null&&skip!==void 0?skip:0)+take}];}});});};}var NEWS_QUERY=function NEWS_QUERY(includeAllItems,whereConditions){if(whereConditions===void 0){whereConditions='';}return gql(templateObject_1$2o||(templateObject_1$2o=__makeTemplateObject(["\n query GetStream(\n $skip: Int!\n $take: Int!\n $searchText: String\n $unreadOnly: Boolean\n ) {\n stream(\n searchText: $searchText\n unreadOnly: $unreadOnly\n order: [{ publishingDate: DESC }]\n skip: $skip\n take: $take\n includeAllItems: ","\n where: {\n type: { eq: NEWS }\n ","\n }\n ) {\n items {\n id: itemId\n knownNewsState\n type\n contentsList: contents {\n language\n intro\n headline\n title\n externalUrl\n active\n }\n modified\n publishingDate\n permalink\n channelsList: channels\n author {\n userPrincipalName\n displayName\n id: userId\n }\n owner {\n userPrincipalName\n displayName\n id: userId\n }\n onBehalfOf {\n userPrincipalName\n displayName\n id: userId\n }\n statistics {\n commentCount\n likeCount\n }\n metadata {\n feedbackSettings {\n feedbackOptions\n }\n }\n bannerInfo {\n type\n imageId\n videoId\n videoUrl\n videoSource\n isDirectVideoUrl\n }\n fileAccessToken\n keywordsList: keywords {\n id\n name\n groupId\n translations {\n key\n value\n }\n }\n isUnread\n hasNewComments\n groupIds\n useExternalContent\n }\n pageInfo {\n hasNextPage\n }\n }\n }\n "],["\n query GetStream(\n $skip: Int!\n $take: Int!\n $searchText: String\n $unreadOnly: Boolean\n ) {\n stream(\n searchText: $searchText\n unreadOnly: $unreadOnly\n order: [{ publishingDate: DESC }]\n skip: $skip\n take: $take\n includeAllItems: ","\n where: {\n type: { eq: NEWS }\n ","\n }\n ) {\n items {\n id: itemId\n knownNewsState\n type\n contentsList: contents {\n language\n intro\n headline\n title\n externalUrl\n active\n }\n modified\n publishingDate\n permalink\n channelsList: channels\n author {\n userPrincipalName\n displayName\n id: userId\n }\n owner {\n userPrincipalName\n displayName\n id: userId\n }\n onBehalfOf {\n userPrincipalName\n displayName\n id: userId\n }\n statistics {\n commentCount\n likeCount\n }\n metadata {\n feedbackSettings {\n feedbackOptions\n }\n }\n bannerInfo {\n type\n imageId\n videoId\n videoUrl\n videoSource\n isDirectVideoUrl\n }\n fileAccessToken\n keywordsList: keywords {\n id\n name\n groupId\n translations {\n key\n value\n }\n }\n isUnread\n hasNewComments\n groupIds\n useExternalContent\n }\n pageInfo {\n hasNextPage\n }\n }\n }\n "])),includeAllItems,whereConditions);};var templateObject_1$2o;
|
|
131759
131759
|
|
|
131760
131760
|
var PublishableItemDetailViewContainer = function PublishableItemDetailViewContainer(_a) {
|
|
131761
131761
|
var preventExternalContentAutoRedirect = _a.preventExternalContentAutoRedirect,
|
|
@@ -132619,10 +132619,10 @@
|
|
|
132619
132619
|
});
|
|
132620
132620
|
}
|
|
132621
132621
|
}
|
|
132622
|
-
function useNewsLoaderWithFiltersAndPagination(pageSize, filter) {
|
|
132623
|
-
var dataLoader = useNewsStreamDataLoader(getNewsFilterDefinition());
|
|
132622
|
+
function useNewsLoaderWithFiltersAndPagination(pageSize, filter, searchText) {
|
|
132623
|
+
var dataLoader = useNewsStreamDataLoader(getNewsFilterDefinition(), searchText);
|
|
132624
132624
|
|
|
132625
|
-
var _a = useItemLoaderWithPreFetch(pageSize, dataLoader, [filter]),
|
|
132625
|
+
var _a = useItemLoaderWithPreFetch(pageSize, dataLoader, [filter, searchText]),
|
|
132626
132626
|
items = _a.items,
|
|
132627
132627
|
isLoadingNextPage = _a.isLoadingNextPage,
|
|
132628
132628
|
isInitialLoading = _a.isInitialLoading,
|
|
@@ -132923,6 +132923,7 @@
|
|
|
132923
132923
|
|
|
132924
132924
|
var NewsList = function NewsList(_a) {
|
|
132925
132925
|
var filter = _a.filter,
|
|
132926
|
+
searchText = _a.searchText,
|
|
132926
132927
|
_b = _a.itemLayoutMode,
|
|
132927
132928
|
itemLayoutMode = _b === void 0 ? exports.ItemLayoutMode.Default : _b,
|
|
132928
132929
|
onItemClick = _a.onItemClick,
|
|
@@ -132932,7 +132933,7 @@
|
|
|
132932
132933
|
pageSize = _c === void 0 ? 8 : _c,
|
|
132933
132934
|
className = _a.className;
|
|
132934
132935
|
|
|
132935
|
-
var _d = useNewsLoaderWithFiltersAndPagination(pageSize, filter),
|
|
132936
|
+
var _d = useNewsLoaderWithFiltersAndPagination(pageSize, filter, searchText),
|
|
132936
132937
|
items = _d.items,
|
|
132937
132938
|
showSpinner = _d.isInitialLoading,
|
|
132938
132939
|
isLoadingNextPage = _d.isLoadingNextPage,
|
|
@@ -133513,6 +133514,7 @@
|
|
|
133513
133514
|
|
|
133514
133515
|
var NewsGrid = function NewsGrid(_a) {
|
|
133515
133516
|
var filter = _a.filter,
|
|
133517
|
+
searchText = _a.searchText,
|
|
133516
133518
|
hidePagination = _a.hidePagination,
|
|
133517
133519
|
_b = _a.columnCount,
|
|
133518
133520
|
columnCount = _b === void 0 ? 4 : _b,
|
|
@@ -133522,7 +133524,7 @@
|
|
|
133522
133524
|
className = _a.className;
|
|
133523
133525
|
var itemsToShowPerPage = rowCount * columnCount;
|
|
133524
133526
|
|
|
133525
|
-
var _d = useNewsLoaderWithFiltersAndPagination(itemsToShowPerPage, filter),
|
|
133527
|
+
var _d = useNewsLoaderWithFiltersAndPagination(itemsToShowPerPage, filter, searchText),
|
|
133526
133528
|
items = _d.items,
|
|
133527
133529
|
showSpinner = _d.isInitialLoading,
|
|
133528
133530
|
isLoadingNextPage = _d.isLoadingNextPage,
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@livetiles/reach-components-react",
|
|
3
3
|
"description": "Provides React components to consume LiveTiles Reach data",
|
|
4
|
-
"version": "0.4.0-preview.
|
|
4
|
+
"version": "0.4.0-preview.241",
|
|
5
5
|
"peerDependencies": {
|
|
6
6
|
"react": "^16.14.0 || ^17",
|
|
7
7
|
"react-dom": "^16.14.0 || ^17",
|