@pega/cosmos-react-social 4.0.0-dev.9.1 → 4.0.0
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/lib/components/Chat/Chat.d.ts +10 -12
- package/lib/components/Chat/Chat.d.ts.map +1 -1
- package/lib/components/Chat/Chat.js +10 -13
- package/lib/components/Chat/Chat.js.map +1 -1
- package/lib/components/Chat/Chat.types.d.ts +106 -4
- package/lib/components/Chat/Chat.types.d.ts.map +1 -1
- package/lib/components/Chat/Chat.types.js +9 -1
- package/lib/components/Chat/Chat.types.js.map +1 -1
- package/lib/components/Chat/ChatBody.d.ts +3 -8
- package/lib/components/Chat/ChatBody.d.ts.map +1 -1
- package/lib/components/Chat/ChatBody.js +289 -15
- package/lib/components/Chat/ChatBody.js.map +1 -1
- package/lib/components/Chat/ChatComposer.d.ts +3 -4
- package/lib/components/Chat/ChatComposer.d.ts.map +1 -1
- package/lib/components/Chat/ChatComposer.js +41 -31
- package/lib/components/Chat/ChatComposer.js.map +1 -1
- package/lib/components/Chat/ChatHeader.d.ts +2 -2
- package/lib/components/Chat/ChatHeader.d.ts.map +1 -1
- package/lib/components/Chat/ChatHeader.js +3 -3
- package/lib/components/Chat/ChatHeader.js.map +1 -1
- package/lib/components/Chat/ChatSettingsPanel.styles.js +1 -1
- package/lib/components/Chat/ChatSettingsPanel.styles.js.map +1 -1
- package/lib/components/Chat/Message.d.ts +3 -43
- package/lib/components/Chat/Message.d.ts.map +1 -1
- package/lib/components/Chat/Message.js +68 -28
- package/lib/components/Chat/Message.js.map +1 -1
- package/lib/components/Chat/Message.styles.d.ts +32 -21
- package/lib/components/Chat/Message.styles.d.ts.map +1 -1
- package/lib/components/Chat/Message.styles.js +92 -20
- package/lib/components/Chat/Message.styles.js.map +1 -1
- package/lib/components/Chat/SuggestedReplyPicker.d.ts +20 -4
- package/lib/components/Chat/SuggestedReplyPicker.d.ts.map +1 -1
- package/lib/components/Chat/SuggestedReplyPicker.js +115 -51
- package/lib/components/Chat/SuggestedReplyPicker.js.map +1 -1
- package/lib/components/Chat/SystemMessage.d.ts +4 -15
- package/lib/components/Chat/SystemMessage.d.ts.map +1 -1
- package/lib/components/Chat/SystemMessage.js +33 -23
- package/lib/components/Chat/SystemMessage.js.map +1 -1
- package/lib/components/Chat/TypeIndicator.d.ts +3 -10
- package/lib/components/Chat/TypeIndicator.d.ts.map +1 -1
- package/lib/components/Chat/TypeIndicator.js +6 -3
- package/lib/components/Chat/TypeIndicator.js.map +1 -1
- package/lib/components/Chat/index.d.ts +13 -13
- package/lib/components/Chat/index.d.ts.map +1 -1
- package/lib/components/Chat/index.js +1 -5
- package/lib/components/Chat/index.js.map +1 -1
- package/lib/components/Email/ContextMenuPopover.js +1 -1
- package/lib/components/Email/ContextMenuPopover.js.map +1 -1
- package/lib/components/Email/Email.d.ts.map +1 -1
- package/lib/components/Email/Email.js +1 -1
- package/lib/components/Email/Email.js.map +1 -1
- package/lib/components/Email/Email.styles.d.ts +12 -4
- package/lib/components/Email/Email.styles.d.ts.map +1 -1
- package/lib/components/Email/Email.styles.js +11 -4
- package/lib/components/Email/Email.styles.js.map +1 -1
- package/lib/components/Email/Email.types.d.ts +9 -7
- package/lib/components/Email/Email.types.d.ts.map +1 -1
- package/lib/components/Email/Email.types.js.map +1 -1
- package/lib/components/Email/EmailCaseView.d.ts.map +1 -1
- package/lib/components/Email/EmailCaseView.js +2 -2
- package/lib/components/Email/EmailCaseView.js.map +1 -1
- package/lib/components/Email/EmailComposer.d.ts.map +1 -1
- package/lib/components/Email/EmailComposer.js +71 -93
- package/lib/components/Email/EmailComposer.js.map +1 -1
- package/lib/components/Email/EmailConversation.d.ts.map +1 -1
- package/lib/components/Email/EmailConversation.js +77 -82
- package/lib/components/Email/EmailConversation.js.map +1 -1
- package/lib/components/Email/EmailEntity.d.ts.map +1 -1
- package/lib/components/Email/EmailEntity.js +1 -1
- package/lib/components/Email/EmailEntity.js.map +1 -1
- package/lib/components/Email/EmailManager.js +2 -2
- package/lib/components/Email/EmailManager.js.map +1 -1
- package/lib/components/Email/EmailShell.js +1 -1
- package/lib/components/Email/EmailShell.js.map +1 -1
- package/lib/components/Email/EmailSummaryItem.d.ts +1 -0
- package/lib/components/Email/EmailSummaryItem.d.ts.map +1 -1
- package/lib/components/Email/EmailSummaryItem.js +4 -5
- package/lib/components/Email/EmailSummaryItem.js.map +1 -1
- package/lib/components/Email/EmailSummaryList.js +2 -2
- package/lib/components/Email/EmailSummaryList.js.map +1 -1
- package/lib/components/Email/EntityList.js +2 -2
- package/lib/components/Email/EntityList.js.map +1 -1
- package/lib/components/Email/index.d.ts +1 -1
- package/lib/components/Email/index.d.ts.map +1 -1
- package/lib/components/Email/index.js.map +1 -1
- package/lib/components/Email/utils/EntityHighlighter.d.ts.map +1 -1
- package/lib/components/Email/utils/EntityHighlighter.js +4 -10
- package/lib/components/Email/utils/EntityHighlighter.js.map +1 -1
- package/lib/components/Feed/Feed.context.d.ts +5 -1
- package/lib/components/Feed/Feed.context.d.ts.map +1 -1
- package/lib/components/Feed/Feed.context.js.map +1 -1
- package/lib/components/Feed/Feed.d.ts +3 -53
- package/lib/components/Feed/Feed.d.ts.map +1 -1
- package/lib/components/Feed/Feed.js +52 -32
- package/lib/components/Feed/Feed.js.map +1 -1
- package/lib/components/Feed/Feed.types.d.ts +330 -0
- package/lib/components/Feed/Feed.types.d.ts.map +1 -0
- package/lib/components/Feed/Feed.types.js +2 -0
- package/lib/components/Feed/Feed.types.js.map +1 -0
- package/lib/components/Feed/FeedAnnouncer.d.ts +2 -3
- package/lib/components/Feed/FeedAnnouncer.d.ts.map +1 -1
- package/lib/components/Feed/FeedAnnouncer.js.map +1 -1
- package/lib/components/Feed/FeedAttachments.d.ts +3 -9
- package/lib/components/Feed/FeedAttachments.d.ts.map +1 -1
- package/lib/components/Feed/FeedAttachments.js +20 -18
- package/lib/components/Feed/FeedAttachments.js.map +1 -1
- package/lib/components/Feed/FeedButton.d.ts +0 -1
- package/lib/components/Feed/FeedButton.d.ts.map +1 -1
- package/lib/components/Feed/FeedButton.js +2 -10
- package/lib/components/Feed/FeedButton.js.map +1 -1
- package/lib/components/Feed/FeedContent.d.ts +2 -10
- package/lib/components/Feed/FeedContent.d.ts.map +1 -1
- package/lib/components/Feed/FeedContent.js +9 -2
- package/lib/components/Feed/FeedContent.js.map +1 -1
- package/lib/components/Feed/FeedContentFooter.d.ts +5 -0
- package/lib/components/Feed/FeedContentFooter.d.ts.map +1 -0
- package/lib/components/Feed/FeedContentFooter.js +34 -0
- package/lib/components/Feed/FeedContentFooter.js.map +1 -0
- package/lib/components/Feed/FeedContentHeader.d.ts +5 -0
- package/lib/components/Feed/FeedContentHeader.d.ts.map +1 -0
- package/lib/components/Feed/FeedContentHeader.js +101 -0
- package/lib/components/Feed/FeedContentHeader.js.map +1 -0
- package/lib/components/Feed/FeedEditRegion.d.ts +6 -0
- package/lib/components/Feed/FeedEditRegion.d.ts.map +1 -0
- package/lib/components/Feed/FeedEditRegion.js +57 -0
- package/lib/components/Feed/FeedEditRegion.js.map +1 -0
- package/lib/components/Feed/FeedInputRegion.d.ts +8 -0
- package/lib/components/Feed/FeedInputRegion.d.ts.map +1 -0
- package/lib/components/Feed/FeedInputRegion.js +86 -0
- package/lib/components/Feed/FeedInputRegion.js.map +1 -0
- package/lib/components/Feed/FeedLikeButton.d.ts +5 -17
- package/lib/components/Feed/FeedLikeButton.d.ts.map +1 -1
- package/lib/components/Feed/FeedLikeButton.js +54 -42
- package/lib/components/Feed/FeedLikeButton.js.map +1 -1
- package/lib/components/Feed/FeedModalList.d.ts +1 -13
- package/lib/components/Feed/FeedModalList.d.ts.map +1 -1
- package/lib/components/Feed/FeedModalList.js +6 -3
- package/lib/components/Feed/FeedModalList.js.map +1 -1
- package/lib/components/Feed/FeedNewPost.d.ts +1 -30
- package/lib/components/Feed/FeedNewPost.d.ts.map +1 -1
- package/lib/components/Feed/FeedNewPost.js +7 -85
- package/lib/components/Feed/FeedNewPost.js.map +1 -1
- package/lib/components/Feed/FeedNewPostTypeMenu.d.ts +1 -30
- package/lib/components/Feed/FeedNewPostTypeMenu.d.ts.map +1 -1
- package/lib/components/Feed/FeedNewPostTypeMenu.js +38 -50
- package/lib/components/Feed/FeedNewPostTypeMenu.js.map +1 -1
- package/lib/components/Feed/FeedPost.d.ts +2 -4
- package/lib/components/Feed/FeedPost.d.ts.map +1 -1
- package/lib/components/Feed/FeedPost.js +97 -170
- package/lib/components/Feed/FeedPost.js.map +1 -1
- package/lib/components/Feed/FeedReply.d.ts +1 -4
- package/lib/components/Feed/FeedReply.d.ts.map +1 -1
- package/lib/components/Feed/FeedReply.js +56 -138
- package/lib/components/Feed/FeedReply.js.map +1 -1
- package/lib/components/Feed/FeedReplyInput.d.ts +2 -27
- package/lib/components/Feed/FeedReplyInput.d.ts.map +1 -1
- package/lib/components/Feed/FeedReplyInput.js +9 -96
- package/lib/components/Feed/FeedReplyInput.js.map +1 -1
- package/lib/components/Feed/FeedRichText.d.ts +1 -4
- package/lib/components/Feed/FeedRichText.d.ts.map +1 -1
- package/lib/components/Feed/FeedRichText.js +4 -9
- package/lib/components/Feed/FeedRichText.js.map +1 -1
- package/lib/components/Feed/index.d.ts +4 -7
- package/lib/components/Feed/index.d.ts.map +1 -1
- package/lib/components/Feed/index.js.map +1 -1
- package/lib/components/HashtagButton/HashtagButton.d.ts.map +1 -1
- package/lib/components/HashtagButton/HashtagButton.js +3 -3
- package/lib/components/HashtagButton/HashtagButton.js.map +1 -1
- package/lib/components/MentionButton/MentionButton.d.ts +1 -1
- package/lib/components/MentionButton/MentionButton.d.ts.map +1 -1
- package/lib/components/MentionButton/MentionButton.js +12 -14
- package/lib/components/MentionButton/MentionButton.js.map +1 -1
- package/package.json +17 -19
- package/lib/components/Chat/ChatTranscript.d.ts +0 -23
- package/lib/components/Chat/ChatTranscript.d.ts.map +0 -1
- package/lib/components/Chat/ChatTranscript.js +0 -45
- package/lib/components/Chat/ChatTranscript.js.map +0 -1
- package/lib/components/Chat/MessageList.d.ts +0 -35
- package/lib/components/Chat/MessageList.d.ts.map +0 -1
- package/lib/components/Chat/MessageList.js +0 -134
- package/lib/components/Chat/MessageList.js.map +0 -1
- package/lib/components/Chat/RepeatingView.d.ts +0 -31
- package/lib/components/Chat/RepeatingView.d.ts.map +0 -1
- package/lib/components/Chat/RepeatingView.js +0 -47
- package/lib/components/Chat/RepeatingView.js.map +0 -1
- package/lib/components/Chat/TranscriptMessage.d.ts +0 -25
- package/lib/components/Chat/TranscriptMessage.d.ts.map +0 -1
- package/lib/components/Chat/TranscriptMessage.js +0 -48
- package/lib/components/Chat/TranscriptMessage.js.map +0 -1
- package/lib/components/Feed/FeedPost.types.d.ts +0 -107
- package/lib/components/Feed/FeedPost.types.d.ts.map +0 -1
- package/lib/components/Feed/FeedPost.types.js +0 -2
- package/lib/components/Feed/FeedPost.types.js.map +0 -1
- package/lib/components/Feed/FeedReply.types.d.ts +0 -72
- package/lib/components/Feed/FeedReply.types.d.ts.map +0 -1
- package/lib/components/Feed/FeedReply.types.js +0 -2
- package/lib/components/Feed/FeedReply.types.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EntityHighlighter.js","sourceRoot":"","sources":["../../../../src/components/Email/utils/EntityHighlighter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAuC,KAAK,EAAE,SAAS,EAAY,MAAM,QAAQ,CAAC;AAIzF,MAAM,YAAY,GAAG,CAAC,IAAsB,EAAsB,EAAE,CAClE,CAAC,CAAC,IAAI;IACN,IAAI,CAAC,QAAQ,KAAK,OAAO;IACzB,IAAI,CAAC,QAAQ,KAAK,UAAU;IAC5B,IAAI,CAAC,QAAQ,KAAK,eAAe,CAAC;AAEpC;;;;;GAKG;AACH,MAAM,SAAS,GAAG,CAAC,MAAkB,EAAE,MAAkB,EAAW,EAAE;IACpE,IACE,CAAC,MAAM,CAAC,KAAK,IAAI,MAAM,CAAC,KAAK,IAAI,MAAM,CAAC,GAAG,IAAI,MA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Node, Element, Node, ParentNode, parse, serialize, Document } from 'parse5';\n\nimport { EmailProps, EntityMatch, MatchRange } from '../Email.types';\n\nconst isParentNode = (node: Node | undefined): node is ParentNode =>\n !!node &&\n node.nodeName !== '#text' &&\n node.nodeName !== '#comment' &&\n node.nodeName !== '#documentType';\n\n/**\n * Function to check if there is nesting in the given ranges\n * @param {MatchRange} range1\n * @param {MatchRange} range2\n * @returns {boolean}\n */\nconst isNesting = (range1: MatchRange, range2: MatchRange): boolean => {\n if (\n (range1.start >= range2.start && range1.end <= range2.end) ||\n (range2.start >= range1.start && range2.end <= range1.end)\n ) {\n return true;\n }\n\n return false;\n};\n\n/**\n * Function to check if there is an intersection in the ranges\n * @param {MatchRange} range1\n * @param {MatchRange} range2\n * @returns {boolean}\n */\nconst isIntersecting = (range1: MatchRange, range2: MatchRange): boolean => {\n if (\n (range1.start > range2.start && range1.start <= range2.end && range1.end > range2.end) ||\n (range2.start > range1.start && range2.start <= range1.end && range2.end > range1.end)\n ) {\n return true;\n }\n\n return false;\n};\n\n/**\n * Callback function to sort ranges\n * @param {MatchRange} range1\n * @param {MatchRange} range2\n * @returns {number}\n */\nconst matchSorter = (range1: MatchRange, range2: MatchRange): number => {\n if (range1.start === range2.start) {\n return range2.end - range1.end;\n }\n\n return range1.start - range2.start;\n};\n\n/**\n * Recursive function to generate nested matches structure by inserting it at the right place\n * @param {EntityMatch} match\n * @param {EntityMatch[]} nestedMatches\n * @returns {EntityMatch[]}\n */\nconst insertIntoNestedMatches: (\n match: EntityMatch,\n nestedMatches: EntityMatch[]\n) => EntityMatch[] = (match: EntityMatch, nestedMatches: EntityMatch[]): EntityMatch[] => {\n const updatedNestedMatches = [...nestedMatches];\n let isInserted = false;\n\n for (let index = 0; index < nestedMatches.length; index += 1) {\n const matchInArr = nestedMatches[index];\n\n if (isNesting(match, matchInArr)) {\n if (match.end - match.start <= matchInArr.end - matchInArr.start) {\n // The range of existing match in array is either larger or equal, so new match can be a child.\n if (matchInArr.children && matchInArr.children.length > 0) {\n // Recursive call\n const updatedChildren = insertIntoNestedMatches(match, matchInArr.children);\n // Update matchInArr in the newOverlapsArray\n matchInArr.children = updatedChildren;\n } else {\n matchInArr.children = [match];\n }\n updatedNestedMatches.splice(index, 1, matchInArr);\n isInserted = true;\n break;\n } else {\n // Replace the existing match and make it the child of current match\n updatedNestedMatches.splice(index, 1, { ...match, children: [matchInArr] });\n isInserted = true;\n break;\n }\n }\n\n if (isIntersecting(match, matchInArr)) {\n // Intersection\n // We are only keeping the first match and discarding the following match\n if (match.start < matchInArr.start) {\n updatedNestedMatches.splice(index, 1, match);\n isInserted = true;\n } else {\n isInserted = true;\n }\n break;\n }\n }\n\n if (!isInserted) {\n // Not nesting or intersecting\n updatedNestedMatches.push(match);\n }\n\n return updatedNestedMatches;\n};\n\nconst getConsolidatedDescription = (match: EntityMatch) => {\n const consolidatedDescription: { [name: string]: Set<string> } = {};\n\n match.names?.forEach(name => {\n if (!consolidatedDescription[name]) {\n consolidatedDescription[name] = new Set();\n }\n consolidatedDescription[name].add(match.matchedText);\n });\n\n if (match.children && match.children.length > 0) {\n match.children.forEach(nestedMatch => {\n const nestMatchDesc = getConsolidatedDescription(nestedMatch);\n Object.keys(nestMatchDesc).forEach(key => {\n if (consolidatedDescription[key]) {\n consolidatedDescription[key] = new Set([\n ...consolidatedDescription[key],\n ...nestMatchDesc[key]\n ]);\n } else {\n consolidatedDescription[key] = nestMatchDesc[key];\n }\n });\n });\n }\n\n return consolidatedDescription;\n};\n\nconst highlightEntitiesInTextNode = (\n textNode: TextNode,\n entityMapping: EmailProps['entityHighlightMapping']\n) => {\n const matches: EntityMatch[] = [];\n // Find all matches\n entityMapping?.forEach(mapping => {\n const escapedValue = mapping.value.replace(/[-[\\]{}()*+?.,\\\\^$|#\\s]/g, '\\\\$&');\n // TODO - look-behind is not supported in safari at this point\n // So we miss the use case of matching entities staring with non word characters like .5\n // The best regex for webkit browsers is (?<=\\\\W|^)${escapedValue}(?=(\\\\W|$))\n const regExp = new RegExp(`\\\\b${escapedValue}(?=(\\\\W|$))`, 'ig');\n let res;\n // eslint-disable-next-line no-cond-assign\n while ((res = regExp.exec(textNode.value)) !== null) {\n matches.push({\n start: res.index,\n end: res.index + res[0].length,\n matchedText: res[0],\n ...mapping\n });\n }\n });\n\n if (matches.length === 0) {\n // Early exit as there are no matches\n const newSpanNode: Element = {\n nodeName: 'span',\n tagName: 'span',\n parentNode: textNode.parentNode,\n attrs: [],\n namespaceURI: '',\n childNodes: []\n };\n newSpanNode.childNodes.push(textNode);\n return newSpanNode;\n }\n\n matches.sort(matchSorter);\n\n // Handle nesting and intersections\n let nestedMatches: EntityMatch[] = [];\n matches.forEach(match => {\n nestedMatches = insertIntoNestedMatches(match, nestedMatches);\n });\n\n // Wrap matched ranges\n let lastIndex = 0;\n const updatedNodes: Node[] = [];\n nestedMatches.sort(matchSorter);\n nestedMatches.forEach(match => {\n if (match.start !== lastIndex) {\n const newSpanNode: Element = {\n nodeName: 'span',\n tagName: 'span',\n parentNode: textNode.parentNode,\n attrs: [],\n namespaceURI: '',\n childNodes: []\n };\n\n newSpanNode.childNodes.push({\n ...textNode,\n nodeName: '#text',\n value: textNode.value.substring(lastIndex, match.start),\n parentNode: newSpanNode\n });\n\n updatedNodes.push(newSpanNode);\n }\n\n const consolidatedDescription = getConsolidatedDescription(match);\n let consolidatedDescriptionArray;\n if (Object.entries(consolidatedDescription).length === 1) {\n consolidatedDescriptionArray = [`${Object.keys(consolidatedDescription)[0]}`];\n } else {\n consolidatedDescriptionArray = Object.entries(consolidatedDescription).map(([key, value]) => {\n return `${key}: ${[...value].join(', ')}`;\n });\n }\n\n const newMarkNode: Element = {\n nodeName: 'pega-email-entity',\n tagName: 'pega-email-entity',\n parentNode: textNode.parentNode,\n attrs: [\n { name: 'data-variant', value: `${match.variant}` },\n { name: 'data-entity-type', value: match.type },\n { name: 'data-description', value: JSON.stringify(consolidatedDescriptionArray) }\n ],\n namespaceURI: '',\n childNodes: []\n };\n\n newMarkNode.childNodes.push({\n nodeName: '#text',\n value: match.matchedText,\n parentNode: newMarkNode\n });\n\n updatedNodes.push(newMarkNode);\n\n lastIndex = match.end;\n });\n\n if (lastIndex !== textNode.value.length) {\n const newSpanNode: Element = {\n nodeName: 'span',\n tagName: 'span',\n parentNode: textNode.parentNode,\n attrs: [],\n namespaceURI: '',\n childNodes: []\n };\n\n newSpanNode.childNodes.push({\n ...textNode,\n nodeName: '#text',\n value: textNode.value.substring(lastIndex),\n parentNode: newSpanNode\n } as TextNode);\n\n updatedNodes.push(newSpanNode);\n }\n\n return updatedNodes;\n};\n\nconst highlightEntitiesInNode = (\n node: Node,\n entityMapping: EmailProps['entityHighlightMapping']\n) => {\n // Either call self recursively or call mark entities in text\n if (isParentNode(node) && node.childNodes?.length > 0) {\n // Iteratively mark entities to all child nodes\n let newChildNodes: Node[] = [];\n node.childNodes.forEach(childNode => {\n const res = highlightEntitiesInNode(childNode, entityMapping);\n if (Array.isArray(res)) {\n newChildNodes = [...newChildNodes, ...res];\n } else {\n newChildNodes.push(res as Node);\n }\n });\n return { ...node, childNodes: newChildNodes };\n }\n\n if (node.nodeName === '#text') {\n return highlightEntitiesInTextNode(node as TextNode, entityMapping);\n }\n\n return node;\n};\n\n/**\n * Function to highlight entities in a given html\n * @param {string} html\n * @param {EmailProps['entityHighlightMapping']} entityMapping\n * @returns {string}\n */\nconst highlightEntities = (\n html: string,\n entityMapping: EmailProps['entityHighlightMapping']\n): string => {\n const document: Document = parse(html);\n\n const markedDocument = highlightEntitiesInNode(document, entityMapping);\n\n return serialize(markedDocument as Document);\n};\n\nexport default highlightEntities;\n"]}
|
|
1
|
+
{"version":3,"file":"EntityHighlighter.js","sourceRoot":"","sources":["../../../../src/components/Email/utils/EntityHighlighter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAuC,KAAK,EAAE,SAAS,EAAY,MAAM,QAAQ,CAAC;AAIzF,MAAM,YAAY,GAAG,CAAC,IAAsB,EAAsB,EAAE,CAClE,CAAC,C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,MAAM,QAAQ,GAAa,KAAK,CAAC,IAAI,CAAC,CAAC;IAEvC,MAAM,cAAc,GAAG,uBAAuB,CAAC,QAAQ,EAAE,aAAa,CAAC,CAAC;IAExE,OAAO,SAAS,CAAC,cAA0B,CAAC,CAAC;AAC/C,CAAC,CAAC;AAEF,eAAe,iBAAiB,CAAC","sourcesContent":["import { TextNode, Element, Node, ParentNode, parse, serialize, Document } from 'parse5';\n\nimport { EmailProps, EntityMatch, MatchRange } from '../Email.types';\n\nconst isParentNode = (node: Node | undefined): node is ParentNode =>\n !!node &&\n node.nodeName !== '#text' &&\n node.nodeName !== '#comment' &&\n node.nodeName !== '#documentType';\n\n/**\n * Function to check if there is nesting in the given ranges\n * @param {MatchRange} range1\n * @param {MatchRange} range2\n * @returns {boolean}\n */\nconst isNesting = (range1: MatchRange, range2: MatchRange): boolean => {\n return (\n (range1.start >= range2.start && range1.end <= range2.end) ||\n (range2.start >= range1.start && range2.end <= range1.end)\n );\n};\n\n/**\n * Function to check if there is an intersection in the ranges\n * @param {MatchRange} range1\n * @param {MatchRange} range2\n * @returns {boolean}\n */\nconst isIntersecting = (range1: MatchRange, range2: MatchRange): boolean => {\n return (\n (range1.start > range2.start && range1.start <= range2.end && range1.end > range2.end) ||\n (range2.start > range1.start && range2.start <= range1.end && range2.end > range1.end)\n );\n};\n\n/**\n * Callback function to sort ranges\n * @param {MatchRange} range1\n * @param {MatchRange} range2\n * @returns {number}\n */\nconst matchSorter = (range1: MatchRange, range2: MatchRange): number => {\n if (range1.start === range2.start) {\n return range2.end - range1.end;\n }\n\n return range1.start - range2.start;\n};\n\n/**\n * Recursive function to generate nested matches structure by inserting it at the right place\n * @param {EntityMatch} match\n * @param {EntityMatch[]} nestedMatches\n * @returns {EntityMatch[]}\n */\nconst insertIntoNestedMatches: (\n match: EntityMatch,\n nestedMatches: EntityMatch[]\n) => EntityMatch[] = (match: EntityMatch, nestedMatches: EntityMatch[]): EntityMatch[] => {\n const updatedNestedMatches = [...nestedMatches];\n let isInserted = false;\n\n for (let index = 0; index < nestedMatches.length; index += 1) {\n const matchInArr = nestedMatches[index];\n\n if (isNesting(match, matchInArr)) {\n if (match.end - match.start <= matchInArr.end - matchInArr.start) {\n // The range of existing match in array is either larger or equal, so new match can be a child.\n if (matchInArr.children && matchInArr.children.length > 0) {\n // Recursive call\n const updatedChildren = insertIntoNestedMatches(match, matchInArr.children);\n // Update matchInArr in the newOverlapsArray\n matchInArr.children = updatedChildren;\n } else {\n matchInArr.children = [match];\n }\n updatedNestedMatches.splice(index, 1, matchInArr);\n isInserted = true;\n break;\n } else {\n // Replace the existing match and make it the child of current match\n updatedNestedMatches.splice(index, 1, { ...match, children: [matchInArr] });\n isInserted = true;\n break;\n }\n }\n\n if (isIntersecting(match, matchInArr)) {\n // Intersection\n // We are only keeping the first match and discarding the following match\n if (match.start < matchInArr.start) {\n updatedNestedMatches.splice(index, 1, match);\n isInserted = true;\n } else {\n isInserted = true;\n }\n break;\n }\n }\n\n if (!isInserted) {\n // Not nesting or intersecting\n updatedNestedMatches.push(match);\n }\n\n return updatedNestedMatches;\n};\n\nconst getConsolidatedDescription = (match: EntityMatch) => {\n const consolidatedDescription: { [name: string]: Set<string> } = {};\n\n match.names?.forEach(name => {\n if (!consolidatedDescription[name]) {\n consolidatedDescription[name] = new Set();\n }\n consolidatedDescription[name].add(match.matchedText);\n });\n\n if (match.children && match.children.length > 0) {\n match.children.forEach(nestedMatch => {\n const nestMatchDesc = getConsolidatedDescription(nestedMatch);\n Object.keys(nestMatchDesc).forEach(key => {\n if (consolidatedDescription[key]) {\n consolidatedDescription[key] = new Set([\n ...consolidatedDescription[key],\n ...nestMatchDesc[key]\n ]);\n } else {\n consolidatedDescription[key] = nestMatchDesc[key];\n }\n });\n });\n }\n\n return consolidatedDescription;\n};\n\nconst highlightEntitiesInTextNode = (\n textNode: TextNode,\n entityMapping: EmailProps['entityHighlightMapping']\n) => {\n const matches: EntityMatch[] = [];\n // Find all matches\n entityMapping?.forEach(mapping => {\n const escapedValue = mapping.value.replace(/[-[\\]{}()*+?.,\\\\^$|#\\s]/g, '\\\\$&');\n // TODO - look-behind is not supported in safari at this point\n // So we miss the use case of matching entities staring with non word characters like .5\n // The best regex for webkit browsers is (?<=\\\\W|^)${escapedValue}(?=(\\\\W|$))\n const regExp = new RegExp(`\\\\b${escapedValue}(?=(\\\\W|$))`, 'ig');\n let res;\n // eslint-disable-next-line no-cond-assign\n while ((res = regExp.exec(textNode.value)) !== null) {\n matches.push({\n start: res.index,\n end: res.index + res[0].length,\n matchedText: res[0],\n ...mapping\n });\n }\n });\n\n if (matches.length === 0) {\n // Early exit as there are no matches\n const newSpanNode: Element = {\n nodeName: 'span',\n tagName: 'span',\n parentNode: textNode.parentNode,\n attrs: [],\n namespaceURI: '',\n childNodes: []\n };\n newSpanNode.childNodes.push(textNode);\n return newSpanNode;\n }\n\n matches.sort(matchSorter);\n\n // Handle nesting and intersections\n let nestedMatches: EntityMatch[] = [];\n matches.forEach(match => {\n nestedMatches = insertIntoNestedMatches(match, nestedMatches);\n });\n\n // Wrap matched ranges\n let lastIndex = 0;\n const updatedNodes: Node[] = [];\n nestedMatches.sort(matchSorter);\n nestedMatches.forEach(match => {\n if (match.start !== lastIndex) {\n const newSpanNode: Element = {\n nodeName: 'span',\n tagName: 'span',\n parentNode: textNode.parentNode,\n attrs: [],\n namespaceURI: '',\n childNodes: []\n };\n\n newSpanNode.childNodes.push({\n ...textNode,\n nodeName: '#text',\n value: textNode.value.substring(lastIndex, match.start),\n parentNode: newSpanNode\n });\n\n updatedNodes.push(newSpanNode);\n }\n\n const consolidatedDescription = getConsolidatedDescription(match);\n let consolidatedDescriptionArray;\n if (Object.entries(consolidatedDescription).length === 1) {\n consolidatedDescriptionArray = [`${Object.keys(consolidatedDescription)[0]}`];\n } else {\n consolidatedDescriptionArray = Object.entries(consolidatedDescription).map(([key, value]) => {\n return `${key}: ${[...value].join(', ')}`;\n });\n }\n\n const newMarkNode: Element = {\n nodeName: 'pega-email-entity',\n tagName: 'pega-email-entity',\n parentNode: textNode.parentNode,\n attrs: [\n { name: 'data-variant', value: `${match.variant}` },\n { name: 'data-entity-type', value: match.type },\n { name: 'data-description', value: JSON.stringify(consolidatedDescriptionArray) }\n ],\n namespaceURI: '',\n childNodes: []\n };\n\n newMarkNode.childNodes.push({\n nodeName: '#text',\n value: match.matchedText,\n parentNode: newMarkNode\n });\n\n updatedNodes.push(newMarkNode);\n\n lastIndex = match.end;\n });\n\n if (lastIndex !== textNode.value.length) {\n const newSpanNode: Element = {\n nodeName: 'span',\n tagName: 'span',\n parentNode: textNode.parentNode,\n attrs: [],\n namespaceURI: '',\n childNodes: []\n };\n\n newSpanNode.childNodes.push({\n ...textNode,\n nodeName: '#text',\n value: textNode.value.substring(lastIndex),\n parentNode: newSpanNode\n } as TextNode);\n\n updatedNodes.push(newSpanNode);\n }\n\n return updatedNodes;\n};\n\nconst highlightEntitiesInNode = (\n node: Node,\n entityMapping: EmailProps['entityHighlightMapping']\n) => {\n // Either call self recursively or call mark entities in text\n if (isParentNode(node) && node.childNodes?.length > 0) {\n // Iteratively mark entities to all child nodes\n let newChildNodes: Node[] = [];\n node.childNodes.forEach(childNode => {\n const res = highlightEntitiesInNode(childNode, entityMapping);\n if (Array.isArray(res)) {\n newChildNodes = [...newChildNodes, ...res];\n } else {\n newChildNodes.push(res as Node);\n }\n });\n return { ...node, childNodes: newChildNodes };\n }\n\n if (node.nodeName === '#text') {\n return highlightEntitiesInTextNode(node as TextNode, entityMapping);\n }\n\n return node;\n};\n\n/**\n * Function to highlight entities in a given html\n * @param {string} html\n * @param {EmailProps['entityHighlightMapping']} entityMapping\n * @returns {string}\n */\nconst highlightEntities = (\n html: string,\n entityMapping: EmailProps['entityHighlightMapping']\n): string => {\n const document: Document = parse(html);\n\n const markedDocument = highlightEntitiesInNode(document, entityMapping);\n\n return serialize(markedDocument as Document);\n};\n\nexport default highlightEntities;\n"]}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Dispatch, RefObject, SetStateAction } from 'react';
|
|
2
2
|
import { InteractionRenderers, MDMap } from '@pega/cosmos-react-rte';
|
|
3
|
-
import { MenuItemProps } from '@pega/cosmos-react-core';
|
|
3
|
+
import { AvatarProps, MenuItemProps } from '@pega/cosmos-react-core';
|
|
4
|
+
import { BaseDialogProps } from '@pega/cosmos-react-core/lib/components/Dialog/Dialog.types';
|
|
4
5
|
export interface FeedContextValue {
|
|
5
6
|
searchTypes?: string[];
|
|
6
7
|
onSearch?: (e: {
|
|
@@ -15,6 +16,8 @@ export interface FeedContextValue {
|
|
|
15
16
|
id: string;
|
|
16
17
|
text: string;
|
|
17
18
|
type: string;
|
|
19
|
+
target?: BaseDialogProps['target'];
|
|
20
|
+
closeGlimpse?: () => void;
|
|
18
21
|
}) => JSX.Element | undefined;
|
|
19
22
|
onMentionPreview?: (e: {
|
|
20
23
|
id: string;
|
|
@@ -28,6 +31,7 @@ export interface FeedContextValue {
|
|
|
28
31
|
username: string;
|
|
29
32
|
fullname: string;
|
|
30
33
|
avatarSrc?: string;
|
|
34
|
+
userStatus?: AvatarProps['status'];
|
|
31
35
|
meta?: string[];
|
|
32
36
|
timeZone?: string;
|
|
33
37
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Feed.context.d.ts","sourceRoot":"","sources":["../../../src/components/Feed/Feed.context.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiB,QAAQ,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,OAAO,CAAC;AAE3E,OAAO,EAAE,oBAAoB,EAAE,KAAK,EAAE,MAAM,wBAAwB,CAAC;AACrE,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;
|
|
1
|
+
{"version":3,"file":"Feed.context.d.ts","sourceRoot":"","sources":["../../../src/components/Feed/Feed.context.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiB,QAAQ,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,OAAO,CAAC;AAE3E,OAAO,EA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jB,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,UAAU,CAAC,EAAE,WAAW,CAAC,QAAQ,CAAC,CAAC;QACnC,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;QAChB,QAAQ,CAAC,EAAE,MAAM,CAAC;KACnB,CAAC;IACF,QAAQ,EAAE,CAAC,YAAY,EAAE,MAAM,KAAK,UAAU,CAAC,OAAO,UAAU,CAAC,CAAC;IAClE,OAAO,CAAC,EAAE,SAAS,CAAC,cAAc,CAAC,CAAC;CACrC;AAED,eAAO,MAAM,WAAW,2CAMtB,CAAC;AAEH,MAAM,WAAW,qBAAqB;IACpC,gBAAgB,CAAC,EAAE,MAAM,IAAI,CAAC;CAC/B;AAED,eAAO,MAAM,gBAAgB,gDAA2C,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Feed.context.js","sourceRoot":"","sources":["../../../src/components/Feed/Feed.context.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAuC,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"Feed.context.js","sourceRoot":"","sources":["../../../src/components/Feed/Feed.context.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAuC,MAAM,OAAO,CAAC;AAmC3E,MAAM,CAAC,MAAM,WAAW,GAAG,aAAa,CAAmB;IACzD,WAAW,EAAE,EAAE;IACf,QAAQ,EAAE,EAAE,QAAQ,EAAE,EAAE,EAAE,QAAQ,EAAE,EAAE,EAAE;IACxC,QAAQ,EAAE,GAAG,EAAE;QACb,OAAO,CAAC,CAAwD,CAAC;IACnE,CAAC;CACF,CAAC,CAAC;AAMH,MAAM,CAAC,MAAM,gBAAgB,GAAG,aAAa,CAAwB,EAAE,CAAC,CAAC","sourcesContent":["import { createContext, Dispatch, RefObject, SetStateAction } from 'react';\n\nimport { InteractionRenderers, MDMap } from '@pega/cosmos-react-rte';\nimport { AvatarProps, MenuItemProps } from '@pega/cosmos-react-core';\nimport { BaseDialogProps } from '@pega/cosmos-react-core/lib/components/Dialog/Dialog.types';\n\nexport interface FeedContextValue {\n searchTypes?: string[];\n onSearch?: (e: { type: 'mention' | 'tag'; search: string; mentionType: string }) => void;\n searchResults?: MenuItemProps[];\n showSearchResults?: boolean;\n setShowSearchResults?: Dispatch<SetStateAction<boolean>>;\n onMentionClick?: (e: {\n id: string;\n text: string;\n type: string;\n target?: BaseDialogProps['target'];\n closeGlimpse?: () => void;\n }) => JSX.Element | undefined;\n onMentionPreview?: (e: { id: string; text: string; type: string }) => void;\n onTagClick?: (tag: string) => void;\n interactionRenderers?: InteractionRenderers[];\n markdownMap?: MDMap;\n userInfo: {\n username: string;\n fullname: string;\n avatarSrc?: string;\n userStatus?: AvatarProps['status'];\n meta?: string[];\n timeZone?: string;\n };\n announce: (announcement: string) => ReturnType<typeof setTimeout>;\n feedRef?: RefObject<HTMLDivElement>;\n}\n\nexport const FeedContext = createContext<FeedContextValue>({\n searchTypes: [],\n userInfo: { username: '', fullname: '' },\n announce: () => {\n return -1 as unknown as ReturnType<FeedContextValue['announce']>;\n }\n});\n\nexport interface FeedReplyContextValue {\n onShowReplyInput?: () => void;\n}\n\nexport const FeedReplyContext = createContext<FeedReplyContextValue>({});\n"]}
|
|
@@ -1,56 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { ForwardProps
|
|
3
|
-
import {
|
|
4
|
-
export interface Filter {
|
|
5
|
-
/** Sets DOM id for the control and associates label element via 'for' attribute. */
|
|
6
|
-
id: string;
|
|
7
|
-
/** Pass a string or a fragment with an Icon and string for the filter label. */
|
|
8
|
-
label: ReactNode;
|
|
9
|
-
/**
|
|
10
|
-
* Disables the filter.
|
|
11
|
-
* @default false
|
|
12
|
-
*/
|
|
13
|
-
disabled?: boolean;
|
|
14
|
-
/**
|
|
15
|
-
* Sets on prop via onFilterChange.
|
|
16
|
-
* @default false
|
|
17
|
-
*/
|
|
18
|
-
on?: boolean;
|
|
19
|
-
}
|
|
20
|
-
export interface FeedProps extends NoChildrenProp {
|
|
21
|
-
/** Title for the feed. */
|
|
22
|
-
title: string;
|
|
23
|
-
/** Information related to the user of the Feed. */
|
|
24
|
-
userInfo: FeedContextValue['userInfo'];
|
|
25
|
-
/** A set of search types that can be used to determine which data set to conduct a mention search on. */
|
|
26
|
-
searchTypes?: FeedContextValue['searchTypes'];
|
|
27
|
-
/** A callback that runs when a decorator search has been run inside of the feed. */
|
|
28
|
-
onDecoratorSearch?: FeedContextValue['onSearch'];
|
|
29
|
-
/** Results that will be shown in a Popover for a mention or tag search. */
|
|
30
|
-
searchResults?: FeedContextValue['searchResults'];
|
|
31
|
-
/** A callback that is triggered when a mention button is clicked. The callback sends back the id, text, and type of the mention. The callback should return a function component. */
|
|
32
|
-
onMentionClick?: FeedContextValue['onMentionClick'];
|
|
33
|
-
/** A callback that is triggered when a mention link is previewed. The callback sends back the id, text, and type of the mention. */
|
|
34
|
-
onMentionPreview?: FeedContextValue['onMentionPreview'];
|
|
35
|
-
/** A callback that is triggered when a hashtag is clicked. The callback sends back the test of the tag. */
|
|
36
|
-
onTagClick?: FeedContextValue['onTagClick'];
|
|
37
|
-
/** A list of configuration objects used to render custom components within Feed posts and replies based off of a given regex pattern. */
|
|
38
|
-
interactionRenderers?: FeedContextValue['interactionRenderers'];
|
|
39
|
-
/** A mapping for various element types to render custom components for within posts. */
|
|
40
|
-
markdownMap?: FeedContextValue['markdownMap'];
|
|
41
|
-
/** A set of filters to apply to the Feed. */
|
|
42
|
-
filters?: Filter[];
|
|
43
|
-
/** A callback that runs when the filter is toggled. */
|
|
44
|
-
onFilterChange?: (filterId: string, on: boolean) => void;
|
|
45
|
-
/** A callback that is triggered when the bottom of the Feed is scrolled into view so that additional posts may be displayed. */
|
|
46
|
-
onLoadMore?: () => void;
|
|
47
|
-
/** Indicates if the posts are being currently loading */
|
|
48
|
-
loadingPosts?: boolean;
|
|
49
|
-
/** A region to hold the new post component */
|
|
50
|
-
newPostRegion?: ReactNode;
|
|
51
|
-
/** A list of FeedPost components */
|
|
52
|
-
posts?: ReactNode[];
|
|
53
|
-
}
|
|
1
|
+
import { FC } from 'react';
|
|
2
|
+
import { ForwardProps } from '@pega/cosmos-react-core';
|
|
3
|
+
import { FeedProps } from './Feed.types';
|
|
54
4
|
declare const Feed: FC<ForwardProps & FeedProps>;
|
|
55
5
|
export default Feed;
|
|
56
6
|
//# sourceMappingURL=Feed.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Feed.d.ts","sourceRoot":"","sources":["../../../src/components/Feed/Feed.tsx"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"Feed.d.ts","sourceRoot":"","sources":["../../../src/components/Feed/Feed.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAe,EAAE,EAA6D,MAAM,OAAO,CAAC;AAGnG,OAAO,EAOL,YAAY,EAab,MAAM,yBAAyB,CAAC;AASjC,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAkDzC,QAAA,MAAM,IAAI,EAAE,EAAE,CAAC,YAAY,GAAG,SAAS,CAsMrC,CAAC;AAEH,eAAe,IAAI,CAAC"}
|
|
@@ -1,44 +1,44 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { useState, useRef, useEffect, useCallback, forwardRef } from 'react';
|
|
3
3
|
import styled, { css } from 'styled-components';
|
|
4
|
-
import { Button, defaultThemeProp, Flex, Icon, registerIcon, Popover, Switch, Text, Progress, usePrevious, useItemIntersection, useUID, useConsolidatedRef } from '@pega/cosmos-react-core';
|
|
4
|
+
import { Button, Card, CardContent, CardHeader, defaultThemeProp, Flex, getFocusables, Icon, registerIcon, Popover, StyledCard, Switch, Text, Progress, usePrevious, useItemIntersection, useUID, useConsolidatedRef } from '@pega/cosmos-react-core';
|
|
5
5
|
import { useArrows, useElement, useI18n, useOuterEvent } from '@pega/cosmos-react-core/lib/hooks';
|
|
6
6
|
import * as filterIcon from '@pega/cosmos-react-core/lib/components/Icon/icons/filter.icon';
|
|
7
7
|
import * as filterOnIcon from '@pega/cosmos-react-core/lib/components/Icon/icons/filter-on.icon';
|
|
8
|
+
import { StyledCardHeader } from '@pega/cosmos-react-core/lib/components/Card/CardHeader';
|
|
8
9
|
import { FeedContext } from './Feed.context';
|
|
9
|
-
import { StyledFeedNewPost } from './FeedNewPost';
|
|
10
|
-
import { StyledFeedPost } from './FeedPost';
|
|
11
10
|
import FeedButton from './FeedButton';
|
|
12
11
|
import FeedAnnouncer from './FeedAnnouncer';
|
|
13
12
|
registerIcon(filterIcon, filterOnIcon);
|
|
14
|
-
const StyledFeed = styled.div
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
`;
|
|
20
|
-
});
|
|
13
|
+
const StyledFeed = styled.div `
|
|
14
|
+
${StyledCardHeader}:not(${StyledCard} ${StyledCard} > ${StyledCardHeader}) {
|
|
15
|
+
padding-bottom: 0.25rem;
|
|
16
|
+
}
|
|
17
|
+
`;
|
|
21
18
|
StyledFeed.defaultProps = defaultThemeProp;
|
|
22
|
-
const
|
|
19
|
+
const StyledFilterMenu = styled.div(({ theme }) => {
|
|
23
20
|
return css `
|
|
24
|
-
margin: ${props.theme.base.spacing} 0;
|
|
25
|
-
`;
|
|
26
|
-
});
|
|
27
|
-
StyledHeading.defaultProps = defaultThemeProp;
|
|
28
|
-
const StyledFilterMenu = styled.div(props => {
|
|
29
|
-
return css `
|
|
30
|
-
padding: calc(2 * ${props.theme.base.spacing});
|
|
31
|
-
|
|
32
21
|
fieldset {
|
|
22
|
+
padding-block-end: calc(2 * ${theme.base.spacing});
|
|
33
23
|
border: none;
|
|
24
|
+
max-height: inherit;
|
|
25
|
+
|
|
26
|
+
legend {
|
|
27
|
+
padding-block-start: calc(2 * ${theme.base.spacing});
|
|
28
|
+
padding-inline: calc(2 * ${theme.base.spacing});
|
|
29
|
+
}
|
|
34
30
|
}
|
|
35
31
|
`;
|
|
36
32
|
});
|
|
37
33
|
StyledFilterMenu.defaultProps = defaultThemeProp;
|
|
38
|
-
const StyledFilterList = styled.ul
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
34
|
+
const StyledFilterList = styled.ul(({ theme }) => {
|
|
35
|
+
return css `
|
|
36
|
+
list-style-type: none;
|
|
37
|
+
min-width: ${theme.base['content-width'].xs};
|
|
38
|
+
padding-inline: calc(2 * ${theme.base.spacing});
|
|
39
|
+
overflow: auto;
|
|
40
|
+
`;
|
|
41
|
+
});
|
|
42
42
|
StyledFilterList.defaultProps = defaultThemeProp;
|
|
43
43
|
const StyledLoadMore = styled.div(({ theme }) => {
|
|
44
44
|
return css `
|
|
@@ -48,7 +48,7 @@ const StyledLoadMore = styled.div(({ theme }) => {
|
|
|
48
48
|
`;
|
|
49
49
|
});
|
|
50
50
|
StyledLoadMore.defaultProps = defaultThemeProp;
|
|
51
|
-
const Feed = forwardRef((props, ref)
|
|
51
|
+
const Feed = forwardRef(function Feed(props, ref) {
|
|
52
52
|
const { loadingPosts = false, variant, children, userInfo, className, title, searchTypes, onDecoratorSearch, searchResults = [], onMentionClick, onMentionPreview, onTagClick, mentionContent, interactionRenderers = [], markdownMap, filters, onFilterChange, onLoadMore, newPostRegion, posts = [], ...restProps } = props;
|
|
53
53
|
const t = useI18n();
|
|
54
54
|
const [popoverEl, setPopoverEl] = useElement();
|
|
@@ -63,6 +63,9 @@ const Feed = forwardRef((props, ref) => {
|
|
|
63
63
|
useOuterEvent('mousedown', [popoverEl, buttonEl], () => {
|
|
64
64
|
setMountPopover(false);
|
|
65
65
|
});
|
|
66
|
+
useOuterEvent('focusin', [popoverEl], () => {
|
|
67
|
+
setMountPopover(false);
|
|
68
|
+
});
|
|
66
69
|
const onKeydown = ({ key }) => {
|
|
67
70
|
if (key === 'Escape')
|
|
68
71
|
setMountPopover(false);
|
|
@@ -76,7 +79,7 @@ const Feed = forwardRef((props, ref) => {
|
|
|
76
79
|
const id = useUID();
|
|
77
80
|
useItemIntersection({ current: null }, posts.length - 1, () => {
|
|
78
81
|
onLoadMore?.();
|
|
79
|
-
}, `#${id} >
|
|
82
|
+
}, `#${id} > article[role='none']`);
|
|
80
83
|
const announce = useCallback((announcement) => {
|
|
81
84
|
setAnnouncementText('');
|
|
82
85
|
return setTimeout(() => {
|
|
@@ -92,7 +95,7 @@ const Feed = forwardRef((props, ref) => {
|
|
|
92
95
|
useEffect(() => {
|
|
93
96
|
if (prevPosts) {
|
|
94
97
|
let timeoutId;
|
|
95
|
-
const difference = posts.length - prevPosts
|
|
98
|
+
const difference = posts.length - prevPosts.length;
|
|
96
99
|
if (difference < 0)
|
|
97
100
|
announce(t('feed_post_removed'));
|
|
98
101
|
else if (difference > 0)
|
|
@@ -100,7 +103,19 @@ const Feed = forwardRef((props, ref) => {
|
|
|
100
103
|
return () => clearTimeout(timeoutId);
|
|
101
104
|
}
|
|
102
105
|
}, [posts]);
|
|
103
|
-
|
|
106
|
+
useEffect(() => {
|
|
107
|
+
if (mountPopover) {
|
|
108
|
+
setTimeout(() => {
|
|
109
|
+
const focusables = getFocusables(filterRef);
|
|
110
|
+
focusables[0]?.focus();
|
|
111
|
+
}, 0);
|
|
112
|
+
}
|
|
113
|
+
}, [mountPopover]);
|
|
114
|
+
return (_jsx(FeedContext.Provider
|
|
115
|
+
// eslint-disable-next-line react/jsx-no-constructed-context-values
|
|
116
|
+
, {
|
|
117
|
+
// eslint-disable-next-line react/jsx-no-constructed-context-values
|
|
118
|
+
value: {
|
|
104
119
|
searchTypes,
|
|
105
120
|
onSearch: e => {
|
|
106
121
|
if (onDecoratorSearch)
|
|
@@ -117,11 +132,16 @@ const Feed = forwardRef((props, ref) => {
|
|
|
117
132
|
userInfo,
|
|
118
133
|
announce,
|
|
119
134
|
feedRef
|
|
120
|
-
}, children: _jsxs(StyledFeed, { ref: feedRef, ...restProps, children: [_jsx(FeedAnnouncer, { children: announcementText }), _jsxs(
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
135
|
+
}, children: _jsxs(StyledFeed, { ref: feedRef, ...restProps, children: [_jsx(FeedAnnouncer, { children: announcementText }), _jsxs(Card, { children: [_jsxs(CardHeader, { children: [_jsx(Text, { variant: 'h2', children: title }), filters && filters.length > 0 && (_jsx(Button, { as: FeedButton, ref: setButtonEl, variant: 'simple', icon: true, onClick: () => setMountPopover(curr => !curr), label: `${title} ${t('filters').toLowerCase()}`, emphasized: true, children: _jsx(Icon, { name: filters?.map(filter => !!filter.on).reduce((acc, curr) => acc || curr)
|
|
136
|
+
? 'filter-on'
|
|
137
|
+
: 'filter' }) })), _jsx(Popover, { show: !!filters && mountPopover, ref: setPopoverEl, target: buttonEl, as: StyledFilterMenu, hideOnTargetHidden: true, onKeyDown: (event) => {
|
|
138
|
+
if (event.key === 'Tab') {
|
|
139
|
+
event.preventDefault();
|
|
140
|
+
buttonEl?.focus();
|
|
141
|
+
}
|
|
142
|
+
}, children: _jsxs(Flex, { container: { direction: 'column', gap: 2 }, as: 'fieldset', children: [_jsx(Text, { variant: 'h3', as: 'legend', children: t('filters') }), _jsx(StyledFilterList, { ref: filterRef, children: filters?.map(filter => {
|
|
143
|
+
return (_jsx("li", { children: _jsx(Switch, { ...filter, onChange: (event) => onFilterChange?.(event.target.id, event.target.checked) }) }, filter.id));
|
|
144
|
+
}) })] }) })] }), _jsx(CardContent, { children: newPostRegion })] }), _jsx("div", { id: id, children: posts }), loadingPosts && (_jsx(Flex, { container: { justify: 'center' }, as: StyledLoadMore, children: _jsx(Progress, { placement: 'inline' }) }))] }) }));
|
|
125
145
|
});
|
|
126
146
|
export default Feed;
|
|
127
147
|
//# sourceMappingURL=Feed.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Feed.js","sourceRoot":"","sources":["../../../src/components/Feed/Feed.tsx"],"names":[],"mappings":";AAAA,OAAO,EAIL,QAAQ,EACR,MAAM,EACN,SAAS,EACT,WAAW,EACX,UAAU,EAEX,MAAM,OAAO,C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AC,CAAC,SAAS,CAAC,GACR,EACP,KAAC,gBAAgB,IAAC,GAAG,EAAE,SAAS,YAC7B,OAAO,EAAE,GAAG,CAAC,MAAM,CAAC,EAAE;oCACrB,OAAO,CACL,uBACE,KAAC,MAAM,OACD,MAAM,EACV,QAAQ,EAAE,CAAC,KAAoC,EAAE,EAAE,CACjD,cAAc,EAAE,CAAC,KAAK,CAAC,MAAM,CAAC,EAAE,EAAE,KAAK,CAAC,MAAM,CAAC,OAAO,CAAC,GAEzD,IANK,MAAM,CAAC,EAAE,CAOb,CACN,CAAC;gCACJ,CAAC,CAAC,GACe,IACd,GACC,EAEV,eAAK,EAAE,EAAE,EAAE,aACR,aAAa,EACb,KAAK,IACF,EAEL,YAAY,IAAI,CACf,KAAC,IAAI,IAAC,SAAS,EAAE,EAAE,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,EAAE,cAAc,YACxD,KAAC,QAAQ,IAAC,SAAS,EAAC,QAAQ,GAAG,GAC1B,CACR,IACU,GACQ,CACxB,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,eAAe,IAAI,CAAC","sourcesContent":["import {\n ChangeEvent,\n ReactNode,\n FC,\n useState,\n useRef,\n useEffect,\n useCallback,\n forwardRef,\n Ref\n} from 'react';\nimport styled, { css } from 'styled-components';\n\nimport {\n Button,\n defaultThemeProp,\n Flex,\n ForwardProps,\n Icon,\n registerIcon,\n Popover,\n Switch,\n Text,\n Progress,\n usePrevious,\n NoChildrenProp,\n useItemIntersection,\n useUID,\n useConsolidatedRef\n} from '@pega/cosmos-react-core';\nimport { useArrows, useElement, useI18n, useOuterEvent } from '@pega/cosmos-react-core/lib/hooks';\nimport * as filterIcon from '@pega/cosmos-react-core/lib/components/Icon/icons/filter.icon';\nimport * as filterOnIcon from '@pega/cosmos-react-core/lib/components/Icon/icons/filter-on.icon';\n\nimport { FeedContext, FeedContextValue } from './Feed.context';\nimport { StyledFeedNewPost } from './FeedNewPost';\nimport { StyledFeedPost } from './FeedPost';\nimport FeedButton from './FeedButton';\nimport FeedAnnouncer from './FeedAnnouncer';\n\nregisterIcon(filterIcon, filterOnIcon);\n\nexport interface Filter {\n /** Sets DOM id for the control and associates label element via 'for' attribute. */\n id: string;\n /** Pass a string or a fragment with an Icon and string for the filter label. */\n label: ReactNode;\n /**\n * Disables the filter.\n * @default false\n */\n disabled?: boolean;\n /**\n * Sets on prop via onFilterChange.\n * @default false\n */\n on?: boolean;\n}\n\nexport interface FeedProps extends NoChildrenProp {\n /** Title for the feed. */\n title: string;\n /** Information related to the user of the Feed. */\n userInfo: FeedContextValue['userInfo'];\n /** A set of search types that can be used to determine which data set to conduct a mention search on. */\n searchTypes?: FeedContextValue['searchTypes'];\n /** A callback that runs when a decorator search has been run inside of the feed. */\n onDecoratorSearch?: FeedContextValue['onSearch'];\n /** Results that will be shown in a Popover for a mention or tag search. */\n searchResults?: FeedContextValue['searchResults'];\n /** A callback that is triggered when a mention button is clicked. The callback sends back the id, text, and type of the mention. The callback should return a function component. */\n onMentionClick?: FeedContextValue['onMentionClick'];\n /** A callback that is triggered when a mention link is previewed. The callback sends back the id, text, and type of the mention. */\n onMentionPreview?: FeedContextValue['onMentionPreview'];\n /** A callback that is triggered when a hashtag is clicked. The callback sends back the test of the tag. */\n onTagClick?: FeedContextValue['onTagClick'];\n /** A list of configuration objects used to render custom components within Feed posts and replies based off of a given regex pattern. */\n interactionRenderers?: FeedContextValue['interactionRenderers'];\n /** A mapping for various element types to render custom components for within posts. */\n markdownMap?: FeedContextValue['markdownMap'];\n /** A set of filters to apply to the Feed. */\n filters?: Filter[];\n /** A callback that runs when the filter is toggled. */\n onFilterChange?: (filterId: string, on: boolean) => void;\n /** A callback that is triggered when the bottom of the Feed is scrolled into view so that additional posts may be displayed. */\n onLoadMore?: () => void;\n /** Indicates if the posts are being currently loading */\n loadingPosts?: boolean;\n /** A region to hold the new post component */\n newPostRegion?: ReactNode;\n /** A list of FeedPost components */\n posts?: ReactNode[];\n}\n\nconst StyledFeed = styled.div(props => {\n return css`\n ${StyledFeedNewPost}:not(:last-child), ${StyledFeedPost}:not(:last-child) {\n margin-bottom: calc(2 * ${props.theme.base.spacing});\n }\n `;\n});\n\nStyledFeed.defaultProps = defaultThemeProp;\n\nconst StyledHeading = styled.div(props => {\n return css`\n margin: ${props.theme.base.spacing} 0;\n `;\n});\n\nStyledHeading.defaultProps = defaultThemeProp;\n\nconst StyledFilterMenu = styled.div(props => {\n return css`\n padding: calc(2 * ${props.theme.base.spacing});\n\n fieldset {\n border: none;\n }\n `;\n});\n\nStyledFilterMenu.defaultProps = defaultThemeProp;\n\nconst StyledFilterList = styled.ul`\n list-style-type: none;\n min-width: 10rem;\n`;\n\nStyledFilterList.defaultProps = defaultThemeProp;\n\nconst StyledLoadMore = styled.div(({ theme }) => {\n return css`\n margin-top: ${theme.base.spacing};\n min-height: 2rem;\n min-width: 2rem;\n `;\n});\n\nStyledLoadMore.defaultProps = defaultThemeProp;\n\nconst Feed: FC<ForwardProps & FeedProps> = forwardRef(\n (props: ForwardProps & FeedProps, ref: Ref<HTMLDivElement>) => {\n const {\n loadingPosts = false,\n variant,\n children,\n userInfo,\n className,\n title,\n searchTypes,\n onDecoratorSearch,\n searchResults = [],\n onMentionClick,\n onMentionPreview,\n onTagClick,\n mentionContent,\n interactionRenderers = [],\n markdownMap,\n filters,\n onFilterChange,\n onLoadMore,\n newPostRegion,\n posts = [],\n ...restProps\n } = props;\n const t = useI18n();\n const [popoverEl, setPopoverEl] = useElement<HTMLElement>();\n const [buttonEl, setButtonEl] = useElement<HTMLElement>();\n const [mountPopover, setMountPopover] = useState(false);\n const [showSearchResults, setShowSearchResults] = useState(false);\n const prevPosts = usePrevious(posts);\n const [announcementText, setAnnouncementText] = useState('');\n\n const feedRef = useConsolidatedRef(ref);\n\n const filterRef = useRef(null);\n useArrows(filterRef);\n\n useOuterEvent('mousedown', [popoverEl, buttonEl], () => {\n setMountPopover(false);\n });\n\n const onKeydown = ({ key }: KeyboardEvent) => {\n if (key === 'Escape') setMountPopover(false);\n };\n\n useEffect(() => {\n document.addEventListener('keydown', onKeydown);\n return () => {\n document.removeEventListener('keydown', onKeydown);\n };\n }, []);\n\n const id = useUID();\n useItemIntersection(\n { current: null },\n posts.length - 1,\n () => {\n onLoadMore?.();\n },\n `#${id} > div[role='region']`\n );\n\n const announce = useCallback((announcement: string) => {\n setAnnouncementText('');\n return setTimeout(() => {\n setAnnouncementText(announcement);\n }, 0);\n }, []);\n\n useEffect(() => {\n if (loadingPosts) {\n const timeoutId = announce(t('loading_post'));\n return () => clearTimeout(timeoutId);\n }\n }, [loadingPosts]);\n\n useEffect(() => {\n if (prevPosts) {\n let timeoutId: ReturnType<typeof setTimeout>;\n const difference = posts.length - prevPosts?.length;\n if (difference < 0) announce(t('feed_post_removed'));\n else if (difference > 0)\n announce(t('feed_new_post_added', [difference], { count: difference }));\n\n return () => clearTimeout(timeoutId);\n }\n }, [posts]);\n\n return (\n <FeedContext.Provider\n value={{\n searchTypes,\n onSearch: e => {\n if (onDecoratorSearch) onDecoratorSearch(e);\n },\n searchResults,\n showSearchResults,\n setShowSearchResults,\n onMentionClick,\n onMentionPreview,\n onTagClick,\n interactionRenderers,\n markdownMap,\n userInfo,\n announce,\n feedRef\n }}\n >\n <StyledFeed ref={feedRef} {...restProps}>\n <FeedAnnouncer>{announcementText}</FeedAnnouncer>\n <Flex container={{ justify: 'between', alignItems: 'center' }} as={StyledHeading}>\n <Text variant='h2'>{title}</Text>\n {filters && filters.length > 0 && (\n <Button\n as={FeedButton}\n ref={setButtonEl}\n variant='simple'\n icon\n onClick={() => setMountPopover(curr => !curr)}\n label={`${title} ${t('filters').toLowerCase()}`}\n emphasized\n >\n <Icon\n name={\n filters?.map(filter => !!filter.on).reduce((acc, curr) => acc || curr)\n ? 'filter-on'\n : 'filter'\n }\n />\n </Button>\n )}\n </Flex>\n <Popover\n show={!!filters && mountPopover}\n ref={setPopoverEl}\n target={buttonEl}\n as={StyledFilterMenu}\n portal={feedRef.current ?? undefined}\n hideOnTargetHidden\n >\n <Flex container={{ direction: 'column', gap: 2 }} as='fieldset'>\n <Text variant='h3' as='legend'>\n {t('filters')}\n </Text>\n <StyledFilterList ref={filterRef}>\n {filters?.map(filter => {\n return (\n <li key={filter.id}>\n <Switch\n {...filter}\n onChange={(event: ChangeEvent<HTMLInputElement>) =>\n onFilterChange?.(event.target.id, event.target.checked)\n }\n />\n </li>\n );\n })}\n </StyledFilterList>\n </Flex>\n </Popover>\n\n <div id={id}>\n {newPostRegion}\n {posts}\n </div>\n\n {loadingPosts && (\n <Flex container={{ justify: 'center' }} as={StyledLoadMore}>\n <Progress placement='inline' />\n </Flex>\n )}\n </StyledFeed>\n </FeedContext.Provider>\n );\n }\n);\n\nexport default Feed;\n"]}
|
|
1
|
+
{"version":3,"file":"Feed.js","sourceRoot":"","sources":["../../../src/components/Feed/Feed.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAmB,QAAQ,EAAE,MAAM,EAAE,SAAS,EAAE,WAAW,EAAE,UAAU,EAAO,MAAM,OAAO,CAAC;AACnG,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAEhD,OAAO,EACL,MAAM,EACN,IAAI,EACJ,WAAW,EACX,UAAU,EACV,gBAAgB,EAChB,IAAI,EAEJ,aAAa,EACb,IAAI,EACJ,YAAY,EACZ,OAAO,EACP,UAAU,EACV,MAAM,EACN,IAAI,EACJ,QAAQ,EACR,WAAW,EACX,mBAAmB,EACnB,MAAM,EACN,kBAAkB,EACnB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,OAAO,EAAE,aAAa,EAAE,MAAM,mCAAmC,CAAC;AAClG,OAAO,KAAK,UAAU,MAAM,+DAA+D,CAAC;AAC5F,OAAO,KAAK,YAAY,MAAM,kEAAkE,CAAC;AACjG,OAAO,EAAE,gBAAgB,EAAE,MAAM,wDAAwD,CAAC;AAE1F,OAAO,EAAE,WAAW,EAAE,MAAM,gB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BACE,KAAC,MAAM,OACD,MAAM,EACV,QAAQ,EAAE,CAAC,KAAoC,EAAE,EAAE,CACjD,cAAc,EAAE,CAAC,KAAK,CAAC,MAAM,CAAC,EAAE,EAAE,KAAK,CAAC,MAAM,CAAC,OAAO,CAAC,GAEzD,IANK,MAAM,CAAC,EAAE,CAOb,CACN,CAAC;gDACJ,CAAC,CAAC,GACe,IACd,GACC,IACC,EAEb,KAAC,WAAW,cAAE,aAAa,GAAe,IACrC,EAEP,cAAK,EAAE,EAAE,EAAE,YAAG,KAAK,GAAO,EAEzB,YAAY,IAAI,CACf,KAAC,IAAI,IAAC,SAAS,EAAE,EAAE,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,EAAE,cAAc,YACxD,KAAC,QAAQ,IAAC,SAAS,EAAC,QAAQ,GAAG,GAC1B,CACR,IACU,GACQ,CACxB,CAAC;AACJ,CAAC,CAAC,CAAC;AAEH,eAAe,IAAI,CAAC","sourcesContent":["import { ChangeEvent, FC, useState, useRef, useEffect, useCallback, forwardRef, Ref } from 'react';\nimport styled, { css } from 'styled-components';\n\nimport {\n Button,\n Card,\n CardContent,\n CardHeader,\n defaultThemeProp,\n Flex,\n ForwardProps,\n getFocusables,\n Icon,\n registerIcon,\n Popover,\n StyledCard,\n Switch,\n Text,\n Progress,\n usePrevious,\n useItemIntersection,\n useUID,\n useConsolidatedRef\n} from '@pega/cosmos-react-core';\nimport { useArrows, useElement, useI18n, useOuterEvent } from '@pega/cosmos-react-core/lib/hooks';\nimport * as filterIcon from '@pega/cosmos-react-core/lib/components/Icon/icons/filter.icon';\nimport * as filterOnIcon from '@pega/cosmos-react-core/lib/components/Icon/icons/filter-on.icon';\nimport { StyledCardHeader } from '@pega/cosmos-react-core/lib/components/Card/CardHeader';\n\nimport { FeedContext } from './Feed.context';\nimport FeedButton from './FeedButton';\nimport FeedAnnouncer from './FeedAnnouncer';\nimport { FeedProps } from './Feed.types';\n\nregisterIcon(filterIcon, filterOnIcon);\n\nconst StyledFeed = styled.div`\n ${StyledCardHeader}:not(${StyledCard} ${StyledCard} > ${StyledCardHeader}) {\n padding-bottom: 0.25rem;\n }\n`;\n\nStyledFeed.defaultProps = defaultThemeProp;\n\nconst StyledFilterMenu = styled.div(({ theme }) => {\n return css`\n fieldset {\n padding-block-end: calc(2 * ${theme.base.spacing});\n border: none;\n max-height: inherit;\n\n legend {\n padding-block-start: calc(2 * ${theme.base.spacing});\n padding-inline: calc(2 * ${theme.base.spacing});\n }\n }\n `;\n});\n\nStyledFilterMenu.defaultProps = defaultThemeProp;\n\nconst StyledFilterList = styled.ul(({ theme }) => {\n return css`\n list-style-type: none;\n min-width: ${theme.base['content-width'].xs};\n padding-inline: calc(2 * ${theme.base.spacing});\n overflow: auto;\n `;\n});\n\nStyledFilterList.defaultProps = defaultThemeProp;\n\nconst StyledLoadMore = styled.div(({ theme }) => {\n return css`\n margin-top: ${theme.base.spacing};\n min-height: 2rem;\n min-width: 2rem;\n `;\n});\n\nStyledLoadMore.defaultProps = defaultThemeProp;\n\nconst Feed: FC<ForwardProps & FeedProps> = forwardRef(function Feed(\n props: ForwardProps & FeedProps,\n ref: Ref<HTMLDivElement>\n) {\n const {\n loadingPosts = false,\n variant,\n children,\n userInfo,\n className,\n title,\n searchTypes,\n onDecoratorSearch,\n searchResults = [],\n onMentionClick,\n onMentionPreview,\n onTagClick,\n mentionContent,\n interactionRenderers = [],\n markdownMap,\n filters,\n onFilterChange,\n onLoadMore,\n newPostRegion,\n posts = [],\n ...restProps\n } = props;\n const t = useI18n();\n const [popoverEl, setPopoverEl] = useElement<HTMLElement>();\n const [buttonEl, setButtonEl] = useElement<HTMLElement>();\n const [mountPopover, setMountPopover] = useState(false);\n const [showSearchResults, setShowSearchResults] = useState(false);\n const prevPosts = usePrevious(posts);\n const [announcementText, setAnnouncementText] = useState('');\n\n const feedRef = useConsolidatedRef(ref);\n\n const filterRef = useRef(null);\n useArrows(filterRef);\n\n useOuterEvent('mousedown', [popoverEl, buttonEl], () => {\n setMountPopover(false);\n });\n\n useOuterEvent('focusin', [popoverEl], () => {\n setMountPopover(false);\n });\n\n const onKeydown = ({ key }: KeyboardEvent) => {\n if (key === 'Escape') setMountPopover(false);\n };\n\n useEffect(() => {\n document.addEventListener('keydown', onKeydown);\n return () => {\n document.removeEventListener('keydown', onKeydown);\n };\n }, []);\n\n const id = useUID();\n useItemIntersection(\n { current: null },\n posts.length - 1,\n () => {\n onLoadMore?.();\n },\n `#${id} > article[role='none']`\n );\n\n const announce = useCallback((announcement: string) => {\n setAnnouncementText('');\n return setTimeout(() => {\n setAnnouncementText(announcement);\n }, 0);\n }, []);\n\n useEffect(() => {\n if (loadingPosts) {\n const timeoutId = announce(t('loading_post'));\n return () => clearTimeout(timeoutId);\n }\n }, [loadingPosts]);\n\n useEffect(() => {\n if (prevPosts) {\n let timeoutId: ReturnType<typeof setTimeout>;\n const difference = posts.length - prevPosts.length;\n if (difference < 0) announce(t('feed_post_removed'));\n else if (difference > 0)\n announce(t('feed_new_post_added', [difference], { count: difference }));\n\n return () => clearTimeout(timeoutId);\n }\n }, [posts]);\n\n useEffect(() => {\n if (mountPopover) {\n setTimeout(() => {\n const focusables = getFocusables(filterRef);\n focusables[0]?.focus();\n }, 0);\n }\n }, [mountPopover]);\n\n return (\n <FeedContext.Provider\n // eslint-disable-next-line react/jsx-no-constructed-context-values\n value={{\n searchTypes,\n onSearch: e => {\n if (onDecoratorSearch) onDecoratorSearch(e);\n },\n searchResults,\n showSearchResults,\n setShowSearchResults,\n onMentionClick,\n onMentionPreview,\n onTagClick,\n interactionRenderers,\n markdownMap,\n userInfo,\n announce,\n feedRef\n }}\n >\n <StyledFeed ref={feedRef} {...restProps}>\n <FeedAnnouncer>{announcementText}</FeedAnnouncer>\n <Card>\n <CardHeader>\n <Text variant='h2'>{title}</Text>\n {filters && filters.length > 0 && (\n <Button\n as={FeedButton}\n ref={setButtonEl}\n variant='simple'\n icon\n onClick={() => setMountPopover(curr => !curr)}\n label={`${title} ${t('filters').toLowerCase()}`}\n emphasized\n >\n <Icon\n name={\n filters?.map(filter => !!filter.on).reduce((acc, curr) => acc || curr)\n ? 'filter-on'\n : 'filter'\n }\n />\n </Button>\n )}\n\n <Popover\n show={!!filters && mountPopover}\n ref={setPopoverEl}\n target={buttonEl}\n as={StyledFilterMenu}\n hideOnTargetHidden\n onKeyDown={(event: KeyboardEvent) => {\n if (event.key === 'Tab') {\n event.preventDefault();\n buttonEl?.focus();\n }\n }}\n >\n <Flex container={{ direction: 'column', gap: 2 }} as='fieldset'>\n <Text variant='h3' as='legend'>\n {t('filters')}\n </Text>\n <StyledFilterList ref={filterRef}>\n {filters?.map(filter => {\n return (\n <li key={filter.id}>\n <Switch\n {...filter}\n onChange={(event: ChangeEvent<HTMLInputElement>) =>\n onFilterChange?.(event.target.id, event.target.checked)\n }\n />\n </li>\n );\n })}\n </StyledFilterList>\n </Flex>\n </Popover>\n </CardHeader>\n\n <CardContent>{newPostRegion}</CardContent>\n </Card>\n\n <div id={id}>{posts}</div>\n\n {loadingPosts && (\n <Flex container={{ justify: 'center' }} as={StyledLoadMore}>\n <Progress placement='inline' />\n </Flex>\n )}\n </StyledFeed>\n </FeedContext.Provider>\n );\n});\n\nexport default Feed;\n"]}
|