UNPKG

@nexusui/components

Version:

These are custom components specially-developed for NexusUI applications. They will make your life easier by giving you out-of-the-box implementations for various high-level UI elements that you can drop directly into your application.

3 lines (2 loc) 2.3 kB
"use client"; import{jsx as e}from"react/jsx-runtime";import{useState as t,useCallback as o,useMemo as n}from"react";import{CommentDrawerComponent as r}from"./CommentDrawer.component.js";import{CommentReplyDrawerComponent as i}from"./CommentReplyDrawer.component.js";import{CommentFilterDrawerComponent as m}from"./CommentFilterDrawer.component.js";const s=s=>{const{loading:l,currentUser:a,comments:d=[],filterOptions:c,selectedFilterOptions:p,sortOptions:h,selectedSortOption:C,onFilterChanged:g,onPinFilterChanged:F,onSortChanged:u,selectedTagsFilter:f,tagsFilterOptions:x,onTagsFilterChanged:O,selectedCommentAuthorFilter:T,commentAuthorFilterOptions:A,onCommentAuthorFilterChanged:R,filterExtension:S,onFilterReset:w,selectedCommentId:j,onCommentClick:y,onCommentAdd:E,onCommentSearch:$,onReplyAdd:N,emptyStateProps:P,filterChanged:k,commentsTotal:D=0,mode:U="plaintext",richTextConfig:I,...L}=s,v={open:!0,variant:"persistent",anchor:"right"},[b,q]=t(!1),[z,B]=t(""),G=o((e=>{$?.(e),B(e)}),[$]),H=n((()=>{if(!z||$)return d;const e="richtext"===U?new RegExp(`"text":"[^"]*${z}[^"]*"`,"i"):new RegExp(z,"i");return d.filter((t=>{const o=[t.message],n=[`${t.author.firstName} ${t.author.lastName}`];return t.replies&&t.replies.length>0&&t.replies.forEach((e=>{o.push(e.message),n.push(`${e.author.firstName} ${e.author.lastName}`)})),e.test(o.join(" "))||n.join(" ").toLowerCase().includes(z.toLowerCase())}))}),[d,U,$,z]),J=H.find((e=>e.id===j&&e.replies&&e.replies.length>0));return b?e(m,{...v,filterOptions:c,selectedFilterOptions:p,onFilterChanged:g,onPinFilterChanged:F,sortOptions:h,selectedSortOption:C,onSortChanged:u,selectedTagsFilter:f,tagsFilterOptions:x,onTagsFilterChanged:O,selectedCommentAuthorFilter:T,commentAuthorFilterOptions:A,onCommentAuthorFilterChanged:R,onFilterClose:()=>{q(!1)},filterExtension:S,onFilterReset:w,filteredCommentsCount:H.length,commentsTotal:D||d.length,mode:U,...L}):J&&!l?e(i,{...v,currentUser:a,comment:J,onCommentClick:y,onReplyAdd:N,mode:U,richTextConfig:I,searchTerm:z,...L}):e(r,{...v,loading:l,currentUser:a,comments:H,selectedCommentId:j,onCommentClick:y,onCommentAdd:E,onReplyAdd:N,onCommentSearch:G,filterChanged:k,onFilterToggle:()=>{q(!b)},searchTerm:z,emptyStateProps:P,mode:U,richTextConfig:I,...L})};export{s as CommentDrawerContainer};