@pega/cosmos-react-social 2.0.0-dev.9.4 → 2.0.0-rc.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (119) hide show
  1. package/lib/components/Chat/Chat.d.ts.map +1 -1
  2. package/lib/components/Chat/Chat.js +6 -11
  3. package/lib/components/Chat/Chat.js.map +1 -1
  4. package/lib/components/Chat/ChatBody.js +2 -2
  5. package/lib/components/Chat/ChatBody.js.map +1 -1
  6. package/lib/components/Chat/ChatComposer.d.ts.map +1 -1
  7. package/lib/components/Chat/ChatComposer.js +20 -26
  8. package/lib/components/Chat/ChatComposer.js.map +1 -1
  9. package/lib/components/Chat/ChatHeader.js +4 -6
  10. package/lib/components/Chat/ChatHeader.js.map +1 -1
  11. package/lib/components/Chat/ChatTranscript.d.ts.map +1 -1
  12. package/lib/components/Chat/ChatTranscript.js +6 -7
  13. package/lib/components/Chat/ChatTranscript.js.map +1 -1
  14. package/lib/components/Chat/Message.d.ts.map +1 -1
  15. package/lib/components/Chat/Message.js +22 -30
  16. package/lib/components/Chat/Message.js.map +1 -1
  17. package/lib/components/Chat/Message.styles.js +2 -2
  18. package/lib/components/Chat/Message.styles.js.map +1 -1
  19. package/lib/components/Chat/MessageList.d.ts.map +1 -1
  20. package/lib/components/Chat/MessageList.js +11 -12
  21. package/lib/components/Chat/MessageList.js.map +1 -1
  22. package/lib/components/Chat/RepeatingView.js +6 -8
  23. package/lib/components/Chat/RepeatingView.js.map +1 -1
  24. package/lib/components/Chat/SuggestedReplyPicker.d.ts.map +1 -1
  25. package/lib/components/Chat/SuggestedReplyPicker.js +16 -16
  26. package/lib/components/Chat/SuggestedReplyPicker.js.map +1 -1
  27. package/lib/components/Chat/SystemMessage.js +2 -2
  28. package/lib/components/Chat/SystemMessage.js.map +1 -1
  29. package/lib/components/Chat/TranscriptMessage.js +3 -7
  30. package/lib/components/Chat/TranscriptMessage.js.map +1 -1
  31. package/lib/components/Chat/TypeIndicator.js +1 -1
  32. package/lib/components/Chat/TypeIndicator.js.map +1 -1
  33. package/lib/components/Email/Email.d.ts.map +1 -1
  34. package/lib/components/Email/Email.js +42 -80
  35. package/lib/components/Email/Email.js.map +1 -1
  36. package/lib/components/Email/Email.styles.d.ts +7 -2
  37. package/lib/components/Email/Email.styles.d.ts.map +1 -1
  38. package/lib/components/Email/Email.styles.js +75 -26
  39. package/lib/components/Email/Email.styles.js.map +1 -1
  40. package/lib/components/Email/Email.types.d.ts +138 -62
  41. package/lib/components/Email/Email.types.d.ts.map +1 -1
  42. package/lib/components/Email/Email.types.js.map +1 -1
  43. package/lib/components/Email/EmailComposer.d.ts +4 -6
  44. package/lib/components/Email/EmailComposer.d.ts.map +1 -1
  45. package/lib/components/Email/EmailComposer.js +150 -62
  46. package/lib/components/Email/EmailComposer.js.map +1 -1
  47. package/lib/components/Email/EmailConversation.d.ts +3 -1
  48. package/lib/components/Email/EmailConversation.d.ts.map +1 -1
  49. package/lib/components/Email/EmailConversation.js +88 -56
  50. package/lib/components/Email/EmailConversation.js.map +1 -1
  51. package/lib/components/Email/EmailEntity.d.ts +3 -7
  52. package/lib/components/Email/EmailEntity.d.ts.map +1 -1
  53. package/lib/components/Email/EmailEntity.js +11 -22
  54. package/lib/components/Email/EmailEntity.js.map +1 -1
  55. package/lib/components/Email/EmailSelector.d.ts +14 -0
  56. package/lib/components/Email/EmailSelector.d.ts.map +1 -0
  57. package/lib/components/Email/EmailSelector.js +63 -0
  58. package/lib/components/Email/EmailSelector.js.map +1 -0
  59. package/lib/components/Email/EmailShell.d.ts.map +1 -1
  60. package/lib/components/Email/EmailShell.js +18 -23
  61. package/lib/components/Email/EmailShell.js.map +1 -1
  62. package/lib/components/Email/EmailSummaryItem.d.ts +10 -0
  63. package/lib/components/Email/EmailSummaryItem.d.ts.map +1 -0
  64. package/lib/components/Email/EmailSummaryItem.js +93 -0
  65. package/lib/components/Email/EmailSummaryItem.js.map +1 -0
  66. package/lib/components/Email/EmailSummaryList.d.ts +6 -0
  67. package/lib/components/Email/EmailSummaryList.d.ts.map +1 -0
  68. package/lib/components/Email/EmailSummaryList.js +115 -0
  69. package/lib/components/Email/EmailSummaryList.js.map +1 -0
  70. package/lib/components/Email/ViewAnalysis.d.ts +6 -0
  71. package/lib/components/Email/ViewAnalysis.d.ts.map +1 -0
  72. package/lib/components/Email/ViewAnalysis.js +20 -0
  73. package/lib/components/Email/ViewAnalysis.js.map +1 -0
  74. package/lib/components/Feed/Feed.context.d.ts +11 -2
  75. package/lib/components/Feed/Feed.context.d.ts.map +1 -1
  76. package/lib/components/Feed/Feed.context.js +1 -0
  77. package/lib/components/Feed/Feed.context.js.map +1 -1
  78. package/lib/components/Feed/Feed.d.ts +6 -2
  79. package/lib/components/Feed/Feed.d.ts.map +1 -1
  80. package/lib/components/Feed/Feed.js +17 -14
  81. package/lib/components/Feed/Feed.js.map +1 -1
  82. package/lib/components/Feed/FeedAttachments.d.ts +3 -0
  83. package/lib/components/Feed/FeedAttachments.d.ts.map +1 -1
  84. package/lib/components/Feed/FeedAttachments.js +65 -13
  85. package/lib/components/Feed/FeedAttachments.js.map +1 -1
  86. package/lib/components/Feed/FeedButton.d.ts.map +1 -1
  87. package/lib/components/Feed/FeedButton.js.map +1 -1
  88. package/lib/components/Feed/FeedContent.d.ts.map +1 -1
  89. package/lib/components/Feed/FeedContent.js +10 -2
  90. package/lib/components/Feed/FeedContent.js.map +1 -1
  91. package/lib/components/Feed/FeedModalList.js +2 -4
  92. package/lib/components/Feed/FeedModalList.js.map +1 -1
  93. package/lib/components/Feed/FeedNewPost.d.ts.map +1 -1
  94. package/lib/components/Feed/FeedNewPost.js +30 -30
  95. package/lib/components/Feed/FeedNewPost.js.map +1 -1
  96. package/lib/components/Feed/FeedNewPostTypeMenu.d.ts.map +1 -1
  97. package/lib/components/Feed/FeedNewPostTypeMenu.js +26 -49
  98. package/lib/components/Feed/FeedNewPostTypeMenu.js.map +1 -1
  99. package/lib/components/Feed/FeedPost.d.ts.map +1 -1
  100. package/lib/components/Feed/FeedPost.js +50 -63
  101. package/lib/components/Feed/FeedPost.js.map +1 -1
  102. package/lib/components/Feed/FeedReply.d.ts.map +1 -1
  103. package/lib/components/Feed/FeedReply.js +36 -44
  104. package/lib/components/Feed/FeedReply.js.map +1 -1
  105. package/lib/components/Feed/FeedReplyInput.d.ts.map +1 -1
  106. package/lib/components/Feed/FeedReplyInput.js +22 -27
  107. package/lib/components/Feed/FeedReplyInput.js.map +1 -1
  108. package/lib/components/Feed/FeedRichText.d.ts.map +1 -1
  109. package/lib/components/Feed/FeedRichText.js +80 -19
  110. package/lib/components/Feed/FeedRichText.js.map +1 -1
  111. package/lib/components/HashtagButton/HashtagButton.d.ts +5 -3
  112. package/lib/components/HashtagButton/HashtagButton.d.ts.map +1 -1
  113. package/lib/components/HashtagButton/HashtagButton.js +22 -16
  114. package/lib/components/HashtagButton/HashtagButton.js.map +1 -1
  115. package/lib/components/MentionButton/MentionButton.d.ts +9 -3
  116. package/lib/components/MentionButton/MentionButton.d.ts.map +1 -1
  117. package/lib/components/MentionButton/MentionButton.js +33 -16
  118. package/lib/components/MentionButton/MentionButton.js.map +1 -1
  119. package/package.json +13 -14
@@ -1,12 +1,15 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { useState, useRef, useEffect } from 'react';
3
3
  import styled, { css } from 'styled-components';
4
- import { Button, defaultThemeProp, Flex, Grid, Icon, Popover, Switch, Text, Progress, StyledProgressRing } from '@pega/cosmos-react-core';
4
+ import { Button, defaultThemeProp, Flex, Grid, Icon, registerIcon, Popover, Switch, Text, Progress, StyledProgressRing } from '@pega/cosmos-react-core';
5
5
  import { useArrows, useElement, useI18n, useOuterEvent } from '@pega/cosmos-react-core/lib/hooks';
6
+ import * as filterIcon from '@pega/cosmos-react-core/lib/components/Icon/icons/filter.icon';
7
+ import * as filterOnIcon from '@pega/cosmos-react-core/lib/components/Icon/icons/filter-on.icon';
6
8
  import { FeedContext } from './Feed.context';
7
9
  import { StyledFeedNewPost } from './FeedNewPost';
8
10
  import { StyledFeedPost } from './FeedPost';
9
11
  import FeedButton from './FeedButton';
12
+ registerIcon(filterIcon, filterOnIcon);
10
13
  const StyledFeed = styled.div(props => {
11
14
  return css `
12
15
  ${StyledFeedNewPost}:not(:last-child), ${StyledFeedPost}:not(:last-child) {
@@ -57,12 +60,13 @@ const StyledLoadMore = styled.div(({ theme, visible }) => {
57
60
  });
58
61
  StyledLoadMore.defaultProps = defaultThemeProp;
59
62
  const Feed = (props) => {
60
- const { variant, children, userInfo, className, title, onDecoratorSearch, searchResults = [], availableMentions = [], interactionRenderers = [], markdownMap, filters, onFilterChange, onLoadMore, ...restProps } = props;
63
+ const { variant, children, userInfo, className, title, searchTypes, onDecoratorSearch, searchResults = [], onMentionClick, onTagClick, mentionContent, interactionRenderers = [], markdownMap, filters, onFilterChange, onLoadMore, ...restProps } = props;
61
64
  const [popoverEl, setPopoverEl] = useElement();
62
65
  const [buttonEl, setButtonEl] = useElement();
63
66
  const [loadMoreEl, setLoadMoreEl] = useElement();
64
67
  const [mountPopover, setMountPopover] = useState(false);
65
68
  const [feedOverflows, setFeedOverflows] = useState(false);
69
+ const [showSearchResults, setShowSearchResults] = useState(false);
66
70
  const feedOverflowsRef = useRef(false);
67
71
  const filterRef = useRef(null);
68
72
  useArrows(filterRef);
@@ -87,7 +91,7 @@ const Feed = (props) => {
87
91
  feedOverflowsRef.current = true;
88
92
  }
89
93
  else if (entries[0].isIntersecting && feedOverflowsRef.current) {
90
- onLoadMore === null || onLoadMore === void 0 ? void 0 : onLoadMore();
94
+ onLoadMore?.();
91
95
  }
92
96
  });
93
97
  intersectionObserver.observe(loadMoreEl);
@@ -97,26 +101,25 @@ const Feed = (props) => {
97
101
  }
98
102
  }, [loadMoreEl, feedOverflowsRef.current]);
99
103
  const t = useI18n();
100
- return (_jsx(FeedContext.Provider, Object.assign({ value: {
104
+ return (_jsx(FeedContext.Provider, { value: {
105
+ searchTypes,
101
106
  onSearch: e => {
102
107
  if (onDecoratorSearch)
103
108
  onDecoratorSearch(e);
104
109
  },
105
110
  searchResults,
106
- availableMentions,
111
+ showSearchResults,
112
+ setShowSearchResults,
113
+ onMentionClick,
114
+ onTagClick,
107
115
  interactionRenderers,
108
116
  markdownMap,
109
117
  userInfo
110
- } }, { children: _jsxs(StyledFeed, Object.assign({}, restProps, { children: [(title || (filters && !!filters.length)) && (_jsxs(Flex, Object.assign({ container: { justify: 'between', alignItems: 'center' }, as: StyledHeading }, { children: [title ? _jsx(Text, Object.assign({ variant: 'h2' }, { children: title }), void 0) : _jsx("div", {}, void 0),
111
- filters && (_jsx(Button, Object.assign({ as: FeedButton, ref: setButtonEl, variant: 'simple', icon: true, onClick: () => setMountPopover(curr => !curr), label: `${title || ''} ${t('filters')}`, emphasized: true }, { children: _jsx(Icon, { name: (filters === null || filters === void 0 ? void 0 : filters.map(filter => !!filter.on).reduce((acc, curr) => acc || curr))
118
+ }, children: _jsxs(StyledFeed, { ...restProps, children: [(title || (filters && !!filters.length)) && (_jsxs(Flex, { container: { justify: 'between', alignItems: 'center' }, as: StyledHeading, children: [title ? _jsx(Text, { variant: 'h2', children: title }, void 0) : _jsx("div", {}, void 0), filters && (_jsx(Button, { as: FeedButton, ref: setButtonEl, variant: 'simple', icon: true, onClick: () => setMountPopover(curr => !curr), label: `${title || ''} ${t('filters')}`, emphasized: true, children: _jsx(Icon, { name: filters?.map(filter => !!filter.on).reduce((acc, curr) => acc || curr)
112
119
  ? 'filter-on'
113
- : 'filter' }, void 0) }), void 0))] }), void 0)),
114
- _jsx(Popover, Object.assign({ show: !!filters && mountPopover, ref: setPopoverEl, target: buttonEl, as: StyledFilterMenu }, { children: _jsxs(Flex, Object.assign({ container: { direction: 'column', gap: 2 }, as: 'fieldset' }, { children: [_jsx(Text, Object.assign({ variant: 'h3', as: 'legend' }, { children: t('filters') }), void 0),
115
- _jsx(Grid, Object.assign({ container: { gap: 1 }, as: StyledFilterList, ref: filterRef }, { children: filters === null || filters === void 0 ? void 0 : filters.map(filter => {
116
- return (_jsx("li", { children: _jsx(Switch, Object.assign({}, filter, { onChange: (event) => onFilterChange === null || onFilterChange === void 0 ? void 0 : onFilterChange(event.target.id, event.target.checked) }), void 0) }, filter.id));
117
- }) }), void 0)] }), void 0) }), void 0),
118
- _jsx("div", { children: children }, void 0),
119
- onLoadMore && (_jsx(Flex, Object.assign({ ref: setLoadMoreEl, as: StyledLoadMore, visible: feedOverflows, container: { justify: 'center' } }, { children: _jsx(Progress, { placement: 'inline' }, void 0) }), void 0))] }), void 0) }), void 0));
120
+ : 'filter' }, void 0) }, void 0))] }, void 0)), _jsx(Popover, { show: !!filters && mountPopover, ref: setPopoverEl, target: buttonEl, as: StyledFilterMenu, children: _jsxs(Flex, { container: { direction: 'column', gap: 2 }, as: 'fieldset', children: [_jsx(Text, { variant: 'h3', as: 'legend', children: t('filters') }, void 0), _jsx(Grid, { container: { gap: 1 }, as: StyledFilterList, ref: filterRef, children: filters?.map(filter => {
121
+ return (_jsx("li", { children: _jsx(Switch, { ...filter, onChange: (event) => onFilterChange?.(event.target.id, event.target.checked) }, void 0) }, filter.id));
122
+ }) }, void 0)] }, void 0) }, void 0), _jsx("div", { children: children }, void 0), onLoadMore && (_jsx(Flex, { ref: setLoadMoreEl, as: StyledLoadMore, visible: feedOverflows, container: { justify: 'center' }, children: _jsx(Progress, { placement: 'inline' }, void 0) }, void 0))] }, void 0) }, void 0));
120
123
  };
121
124
  export default Feed;
122
125
  //# sourceMappingURL=Feed.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Feed.js","sourceRoot":"","sources":["../../../src/components/Feed/Feed.tsx"],"names":[],"mappings":";AAAA,OAAO,EAA8B,QAAQ,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAChF,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAEhD,OAAO,EACL,MAAM,EACN,gBAAgB,EAChB,IAAI,EAEJ,I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C,SAAS,EAAE,EAAE,SAAS,EAAE,QAAQ,EAAE,GAAG,EAAE,CAAC,EAAE,EAAE,EAAE,EAAC,UAAU,iBAC7D,KAAC,IAAI,kBAAC,OAAO,EAAC,IAAI,EAAC,EAAE,EAAC,QAAQ,gBAC3B,CAAC,CAAC,SAAS,CAAC,YACR;4BACP,KAAC,IAAI,kBAAC,SAAS,EAAE,EAAE,GAAG,EAAE,CAAC,EAAE,EAAE,EAAE,EAAE,gBAAgB,EAAE,GAAG,EAAE,SAAS,gBAC9D,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,GAAG,CAAC,MAAM,CAAC,EAAE;oCACrB,OAAO,CACL,uBACE,KAAC,MAAM,oBACD,MAAM,IACV,QAAQ,EAAE,CAAC,KAAoC,EAAE,EAAE,CACjD,cAAc,aAAd,cAAc,uBAAd,cAAc,CAAG,KAAK,CAAC,MAAM,CAAC,EAAE,EAAE,KAAK,CAAC,MAAM,CAAC,OAAO,CAAC,YAEzD,IANK,MAAM,CAAC,EAAE,CAOb,CACN,CAAC;gCACJ,CAAC,CAAC,YACG,aACF,YACC;gBAEV,wBAAM,QAAQ,WAAO;gBAEpB,UAAU,IAAI,CACb,KAAC,IAAI,kBACH,GAAG,EAAE,aAAa,EAClB,EAAE,EAAE,cAAc,EAClB,OAAO,EAAE,aAAa,EACtB,SAAS,EAAE,EAAE,OAAO,EAAE,QAAQ,EAAE,gBAEhC,KAAC,QAAQ,IAAC,SAAS,EAAC,QAAQ,WAAG,YAC1B,CACR,aACU,YACQ,CACxB,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,IAAI,CAAC","sourcesContent":["import { ChangeEvent, ReactNode, FC, useState, useRef, useEffect } from 'react';\nimport styled, { css } from 'styled-components';\n\nimport {\n Button,\n defaultThemeProp,\n Flex,\n ForwardProps,\n Grid,\n Icon,\n Popover,\n Switch,\n Text,\n Progress,\n StyledProgressRing\n} from '@pega/cosmos-react-core';\nimport { useArrows, useElement, useI18n, useOuterEvent } from '@pega/cosmos-react-core/lib/hooks';\n\nimport { FeedContext, FeedContextValue } from './Feed.context';\nimport { StyledFeedNewPost } from './FeedNewPost';\nimport { StyledFeedPost } from './FeedPost';\nimport FeedButton from './FeedButton';\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}\nexport interface FeedProps {\n children: ReactNode;\n /** Title for the feed. */\n title?: string;\n /** Information related to the user of the Feed. */\n userInfo: FeedContextValue['userInfo'];\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 list of available users that map directly to the initial set of search results for a mention. */\n availableMentions?: FeedContextValue['availableMentions'];\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}\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<{ visible: boolean }>(({ theme, visible }) => {\n return css`\n ${visible &&\n css`\n margin-top: calc(2 * ${theme.base.spacing});\n `}\n\n ${StyledProgressRing} {\n min-height: 0;\n min-width: 0;\n\n ${visible &&\n css`\n min-height: 2rem;\n min-width: 2rem;\n `}\n }\n `;\n});\n\nStyledLoadMore.defaultProps = defaultThemeProp;\n\nconst Feed: FC<ForwardProps & FeedProps> = (props: ForwardProps & FeedProps) => {\n const {\n variant,\n children,\n userInfo,\n className,\n title,\n onDecoratorSearch,\n searchResults = [],\n availableMentions = [],\n interactionRenderers = [],\n markdownMap,\n filters,\n onFilterChange,\n onLoadMore,\n ...restProps\n } = props;\n\n const [popoverEl, setPopoverEl] = useElement<HTMLElement>();\n const [buttonEl, setButtonEl] = useElement<HTMLElement>();\n const [loadMoreEl, setLoadMoreEl] = useElement<HTMLDivElement>();\n const [mountPopover, setMountPopover] = useState(false);\n const [feedOverflows, setFeedOverflows] = useState(false);\n const feedOverflowsRef = useRef(false);\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 useEffect(() => {\n if (loadMoreEl) {\n const intersectionObserver = new IntersectionObserver(entries => {\n if (!entries[0].isIntersecting) {\n setFeedOverflows(true);\n feedOverflowsRef.current = true;\n } else if (entries[0].isIntersecting && feedOverflowsRef.current) {\n onLoadMore?.();\n }\n });\n\n intersectionObserver.observe(loadMoreEl);\n\n return () => {\n intersectionObserver.disconnect();\n };\n }\n }, [loadMoreEl, feedOverflowsRef.current]);\n\n const t = useI18n();\n\n return (\n <FeedContext.Provider\n value={{\n onSearch: e => {\n if (onDecoratorSearch) onDecoratorSearch(e);\n },\n searchResults,\n availableMentions,\n interactionRenderers,\n markdownMap,\n userInfo\n }}\n >\n <StyledFeed {...restProps}>\n {(title || (filters && !!filters.length)) && (\n <Flex container={{ justify: 'between', alignItems: 'center' }} as={StyledHeading}>\n {title ? <Text variant='h2'>{title}</Text> : <div />}\n {filters && (\n <Button\n as={FeedButton}\n ref={setButtonEl}\n variant='simple'\n icon\n onClick={() => setMountPopover(curr => !curr)}\n label={`${title || ''} ${t('filters')}`}\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 )}\n <Popover\n show={!!filters && mountPopover}\n ref={setPopoverEl}\n target={buttonEl}\n as={StyledFilterMenu}\n >\n <Flex container={{ direction: 'column', gap: 2 }} as='fieldset'>\n <Text variant='h3' as='legend'>\n {t('filters')}\n </Text>\n <Grid container={{ gap: 1 }} as={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 </Grid>\n </Flex>\n </Popover>\n\n <div>{children}</div>\n\n {onLoadMore && (\n <Flex\n ref={setLoadMoreEl}\n as={StyledLoadMore}\n visible={feedOverflows}\n container={{ justify: 'center' }}\n >\n <Progress placement='inline' />\n </Flex>\n )}\n </StyledFeed>\n </FeedContext.Provider>\n );\n};\n\nexport default Feed;\n"]}
1
+ {"version":3,"file":"Feed.js","sourceRoot":"","sources":["../../../src/components/Feed/Feed.tsx"],"names":[],"mappings":";AAAA,OAAO,EAA8B,QAAQ,EAAE,MAAM,EAAE,SAAS,EAAE,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AAQ,WAAG,WAC1B,CACR,YACU,WACQ,CACxB,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,IAAI,CAAC","sourcesContent":["import { ChangeEvent, ReactNode, FC, useState, useRef, useEffect } from 'react';\nimport styled, { css } from 'styled-components';\n\nimport {\n Button,\n defaultThemeProp,\n Flex,\n ForwardProps,\n Grid,\n Icon,\n registerIcon,\n Popover,\n Switch,\n Text,\n Progress,\n StyledProgressRing\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';\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}\nexport interface FeedProps {\n children: ReactNode;\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 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 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}\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<{ visible: boolean }>(({ theme, visible }) => {\n return css`\n ${visible &&\n css`\n margin-top: calc(2 * ${theme.base.spacing});\n `}\n\n ${StyledProgressRing} {\n min-height: 0;\n min-width: 0;\n\n ${visible &&\n css`\n min-height: 2rem;\n min-width: 2rem;\n `}\n }\n `;\n});\n\nStyledLoadMore.defaultProps = defaultThemeProp;\n\nconst Feed: FC<ForwardProps & FeedProps> = (props: ForwardProps & FeedProps) => {\n const {\n variant,\n children,\n userInfo,\n className,\n title,\n searchTypes,\n onDecoratorSearch,\n searchResults = [],\n onMentionClick,\n onTagClick,\n mentionContent,\n interactionRenderers = [],\n markdownMap,\n filters,\n onFilterChange,\n onLoadMore,\n ...restProps\n } = props;\n\n const [popoverEl, setPopoverEl] = useElement<HTMLElement>();\n const [buttonEl, setButtonEl] = useElement<HTMLElement>();\n const [loadMoreEl, setLoadMoreEl] = useElement<HTMLDivElement>();\n const [mountPopover, setMountPopover] = useState(false);\n const [feedOverflows, setFeedOverflows] = useState(false);\n const [showSearchResults, setShowSearchResults] = useState(false);\n const feedOverflowsRef = useRef(false);\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 useEffect(() => {\n if (loadMoreEl) {\n const intersectionObserver = new IntersectionObserver(entries => {\n if (!entries[0].isIntersecting) {\n setFeedOverflows(true);\n feedOverflowsRef.current = true;\n } else if (entries[0].isIntersecting && feedOverflowsRef.current) {\n onLoadMore?.();\n }\n });\n\n intersectionObserver.observe(loadMoreEl);\n\n return () => {\n intersectionObserver.disconnect();\n };\n }\n }, [loadMoreEl, feedOverflowsRef.current]);\n\n const t = useI18n();\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 onTagClick,\n interactionRenderers,\n markdownMap,\n userInfo\n }}\n >\n <StyledFeed {...restProps}>\n {(title || (filters && !!filters.length)) && (\n <Flex container={{ justify: 'between', alignItems: 'center' }} as={StyledHeading}>\n {title ? <Text variant='h2'>{title}</Text> : <div />}\n {filters && (\n <Button\n as={FeedButton}\n ref={setButtonEl}\n variant='simple'\n icon\n onClick={() => setMountPopover(curr => !curr)}\n label={`${title || ''} ${t('filters')}`}\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 )}\n <Popover\n show={!!filters && mountPopover}\n ref={setPopoverEl}\n target={buttonEl}\n as={StyledFilterMenu}\n >\n <Flex container={{ direction: 'column', gap: 2 }} as='fieldset'>\n <Text variant='h3' as='legend'>\n {t('filters')}\n </Text>\n <Grid container={{ gap: 1 }} as={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 </Grid>\n </Flex>\n </Popover>\n\n <div>{children}</div>\n\n {onLoadMore && (\n <Flex\n ref={setLoadMoreEl}\n as={StyledLoadMore}\n visible={feedOverflows}\n container={{ justify: 'center' }}\n >\n <Progress placement='inline' />\n </Flex>\n )}\n </StyledFeed>\n </FeedContext.Provider>\n );\n};\n\nexport default Feed;\n"]}
@@ -3,9 +3,12 @@ import { FileUploadItemProps } from '@pega/cosmos-react-core';
3
3
  export declare type AttachedFiles = FileUploadItemProps & File;
4
4
  interface FeedAttachmentsProps {
5
5
  attachments?: AttachedFiles[];
6
+ readOnly?: boolean;
6
7
  ref?: Ref<HTMLUListElement>;
7
8
  }
8
9
  export declare const StyledFeedAttachments: import("styled-components").StyledComponent<"ul", import("styled-components").DefaultTheme, {}, never>;
10
+ export declare const StyledImagePreview: import("styled-components").StyledComponent<import("react").FunctionComponent<import("@pega/cosmos-react-core/lib/components/Button/BareButton").BareButtonProps & import("@pega/cosmos-react-core").ForwardProps>, import("styled-components").DefaultTheme, {}, never>;
11
+ export declare const StyledAttachmentsRegion: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, {}, never>;
9
12
  declare const FeedAttachments: FC<FeedAttachmentsProps>;
10
13
  export default FeedAttachments;
11
14
  //# sourceMappingURL=FeedAttachments.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"FeedAttachments.d.ts","sourceRoot":"","sources":["../../../src/components/Feed/FeedAttachments.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAA+B,GAAG,EAAE,MAAM,OAAO,CAAC;AAG7D,OAAO,EAEL,mBAAmB,EAGpB,MAAM,yBAAyB,CAAC;AAEjC,oBAAY,aAAa,GAAG,mBAAmB,GAAG,IAAI,CAAC;AAEvD,UAAU,oBAAoB;IAC5B,WAAW,CAAC,EAAE,aAAa,EAAE,CAAC;IAC9B,GAAG,CAAC,EAAE,GAAG,CAAC,gBAAgB,CAAC,CAAC;CAC7B;AAED,eAAO,MAAM,qBAAqB,wGAYhC,CAAC;AAIH,QAAA,MAAM,eAAe,EAAE,EAAE,CAAC,oBAAoB,CAoB7C,CAAC;AAEF,eAAe,eAAe,CAAC"}
1
+ {"version":3,"file":"FeedAttachments.d.ts","sourceRoot":"","sources":["../../../src/components/Feed/FeedAttachments.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAA+B,GAAG,EAAE,MAAM,OAAO,CAAC;AAG7D,OAAO,EAEL,mBAAmB,EAQpB,MAAM,yBAAyB,CAAC;AAGjC,oBAAY,aAAa,GAAG,mBAAmB,GAAG,IAAI,CAAC;AAEvD,UAAU,oBAAoB;IAC5B,WAAW,CAAC,EAAE,aAAa,EAAE,CAAC;IAC9B,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,GAAG,CAAC,EAAE,GAAG,CAAC,gBAAgB,CAAC,CAAC;CAC7B;AAED,eAAO,MAAM,qBAAqB,wGAShC,CAAC;AAIH,eAAO,MAAM,kBAAkB,0QA0B7B,CAAC;AAIH,eAAO,MAAM,uBAAuB,yGAQlC,CAAC;AAIH,QAAA,MAAM,eAAe,EAAE,EAAE,CAAC,oBAAoB,CAgD7C,CAAC;AAEF,eAAe,eAAe,CAAC"}
@@ -1,11 +1,10 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { forwardRef } from 'react';
3
3
  import styled, { css } from 'styled-components';
4
- import { FileUploadItem, Grid, defaultThemeProp } from '@pega/cosmos-react-core';
5
- export const StyledFeedAttachments = styled.ul(props => {
6
- const { theme } = props;
4
+ import { FileUploadItem, Grid, Image, defaultThemeProp, getKindFromMimeType, getMimeTypeFromFile, Flex, StyledFlex } from '@pega/cosmos-react-core';
5
+ import BareButton from '@pega/cosmos-react-core/lib/components/Button/BareButton';
6
+ export const StyledFeedAttachments = styled.ul(({ theme }) => {
7
7
  return css `
8
- margin: ${theme.base.spacing} 0;
9
8
  overflow-x: auto;
10
9
 
11
10
  > li {
@@ -15,15 +14,68 @@ export const StyledFeedAttachments = styled.ul(props => {
15
14
  `;
16
15
  });
17
16
  StyledFeedAttachments.defaultProps = defaultThemeProp;
17
+ export const StyledImagePreview = styled(BareButton)(({ theme }) => {
18
+ return css `
19
+ line-height: 0;
20
+
21
+ /* stylelint-disable declaration-block-no-duplicate-properties */
22
+ width: -moz-fit-content;
23
+ width: fit-content;
24
+
25
+ /* stylelint-enable declaration-block-no-duplicate-properties */
26
+ border-radius: calc(0.5 * ${theme.base['border-radius']});
27
+
28
+ & + & {
29
+ margin: 0;
30
+ }
31
+
32
+ &:focus {
33
+ box-shadow: ${theme.components.button['focus-shadow']};
34
+ }
35
+
36
+ img {
37
+ border-radius: calc(0.5 * ${theme.base['border-radius']});
38
+ object-fit: contain;
39
+ max-height: 32rem;
40
+ max-width: 100%;
41
+ }
42
+ `;
43
+ });
44
+ StyledImagePreview.defaultProps = defaultThemeProp;
45
+ export const StyledAttachmentsRegion = styled.div(({ theme }) => {
46
+ return css `
47
+ margin: ${theme.base.spacing} 0;
48
+
49
+ ${StyledFlex} + ${StyledFeedAttachments} {
50
+ margin-block-start: ${theme.base.spacing};
51
+ }
52
+ `;
53
+ });
54
+ StyledAttachmentsRegion.defaultProps = defaultThemeProp;
18
55
  const FeedAttachments = forwardRef((props, ref) => {
19
- const { attachments } = props;
20
- return attachments && !!attachments.length ? (_jsx(Grid, Object.assign({ ref: ref, as: StyledFeedAttachments, container: {
21
- cols: 'repeat(auto-fill, minmax(15rem, 1fr))',
22
- gap: 1
23
- } }, { children: Array.from(attachments).map(file => {
24
- const { name, ...restProps } = file;
25
- return _jsx(FileUploadItem, Object.assign({ name: name }, restProps), file.lastModified);
26
- }) }), void 0)) : null;
56
+ const { attachments = [], readOnly } = props;
57
+ if (attachments.length === 0)
58
+ return null;
59
+ const previewableFiles = [];
60
+ const nonPreviewableFiles = [];
61
+ attachments.forEach(file => {
62
+ const type = getKindFromMimeType(getMimeTypeFromFile(file.name) ?? '');
63
+ if (type === 'image')
64
+ previewableFiles.push(file);
65
+ else
66
+ nonPreviewableFiles.push(file);
67
+ });
68
+ return (_jsxs(StyledAttachmentsRegion, { children: [readOnly && !!previewableFiles.length && (_jsx(Flex, { container: { direction: 'column', gap: 1 }, children: previewableFiles.map(({ lastModified, name, onPreview, thumbnail }) => {
69
+ return (_jsx(StyledImagePreview, { onClick: () => onPreview?.(name), children: _jsx(Image, { alt: name, src: thumbnail }, void 0) }, lastModified));
70
+ }) }, void 0)), _jsxs(Grid, { ref: ref, as: StyledFeedAttachments, container: {
71
+ cols: 'repeat(auto-fill, minmax(15rem, 1fr))',
72
+ gap: 1
73
+ }, children: [!readOnly &&
74
+ previewableFiles.map(({ lastModified, name, size, ...restProps }) => {
75
+ return _jsx(FileUploadItem, { name: name, size: size, ...restProps }, lastModified);
76
+ }), nonPreviewableFiles.map(({ lastModified, name, size, ...restProps }) => {
77
+ return _jsx(FileUploadItem, { name: name, size: size, ...restProps }, lastModified);
78
+ })] }, void 0)] }, void 0));
27
79
  });
28
80
  export default FeedAttachments;
29
81
  //# sourceMappingURL=FeedAttachments.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"FeedAttachments.js","sourceRoot":"","sources":["../../../src/components/Feed/FeedAttachments.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAM,UAAU,EAAwB,MAAM,OAAO,CAAC;AA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components';\n\nimport {\n FileUploadItem,\n FileUploadItemProps,\n Grid,\n defaultThemeProp\n} from '@pega/cosmos-react-core';\n\nexport type AttachedFiles = FileUploadItemProps & File;\n\ninterface FeedAttachmentsProps {\n attachments?: AttachedFiles[];\n ref?: Ref<HTMLUListElement>;\n}\n\nexport const StyledFeedAttachments = styled.ul(props => {\n const { theme } = props;\n\n return css`\n margin: ${theme.base.spacing} 0;\n overflow-x: auto;\n\n > li {\n background-color: ${theme.base.palette['primary-background']};\n cursor: initial;\n }\n `;\n});\n\nStyledFeedAttachments.defaultProps = defaultThemeProp;\n\nconst FeedAttachments: FC<FeedAttachmentsProps> = forwardRef(\n (props: PropsWithoutRef<FeedAttachmentsProps>, ref: FeedAttachmentsProps['ref']) => {\n const { attachments } = props;\n\n return attachments && !!attachments.length ? (\n <Grid\n ref={ref}\n as={StyledFeedAttachments}\n container={{\n cols: 'repeat(auto-fill, minmax(15rem, 1fr))',\n gap: 1\n }}\n >\n {Array.from(attachments).map(file => {\n const { name, ...restProps } = file;\n return <FileUploadItem key={file.lastModified} name={name} {...restProps} />;\n })}\n </Grid>\n ) : null;\n }\n);\n\nexport default FeedAttachments;\n"]}
1
+ {"version":3,"file":"FeedAttachments.js","sourceRoot":"","sources":["../../../src/components/Feed/FeedAttachments.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAM,UAAU,EAAwB,MAAM,OAAO,CAAC;AAC7D,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAEhD,OAAO,EACL,cAAc,EAEd,IAAI,EACJ,KAAK,EACL,gBAAgB,EAChB,mBAAmB,EACnB,mBAAmB,EACnB,IAAI,EACJ,UAAU,EACX,MAAM,yBAAyB,CAAC;AACjC,OAAO,UAAU,MAAM,0DAA0D,CAAC;AAUlF,MAAM,CAAC,MAAM,qBAAqB,GAAG,MAAM,CAAC,EAAE,CAAC,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE;IAC3D,OAAO,GAAG,CAAA;;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AAE,EAAE,EAAE;wBACtE,OAAO,KAAC,cAAc,IAAoB,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,KAAM,SAAS,IAAnD,YAAY,CAA2C,CAAC;oBACtF,CAAC,CAAC,YACG,YACiB,CAC3B,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,eAAe,eAAe,CAAC","sourcesContent":["import { FC, forwardRef, PropsWithoutRef, Ref } from 'react';\nimport styled, { css } from 'styled-components';\n\nimport {\n FileUploadItem,\n FileUploadItemProps,\n Grid,\n Image,\n defaultThemeProp,\n getKindFromMimeType,\n getMimeTypeFromFile,\n Flex,\n StyledFlex\n} from '@pega/cosmos-react-core';\nimport BareButton from '@pega/cosmos-react-core/lib/components/Button/BareButton';\n\nexport type AttachedFiles = FileUploadItemProps & File;\n\ninterface FeedAttachmentsProps {\n attachments?: AttachedFiles[];\n readOnly?: boolean;\n ref?: Ref<HTMLUListElement>;\n}\n\nexport const StyledFeedAttachments = styled.ul(({ theme }) => {\n return css`\n overflow-x: auto;\n\n > li {\n background-color: ${theme.base.palette['primary-background']};\n cursor: initial;\n }\n `;\n});\n\nStyledFeedAttachments.defaultProps = defaultThemeProp;\n\nexport const StyledImagePreview = styled(BareButton)(({ theme }) => {\n return css`\n line-height: 0;\n\n /* stylelint-disable declaration-block-no-duplicate-properties */\n width: -moz-fit-content;\n width: fit-content;\n\n /* stylelint-enable declaration-block-no-duplicate-properties */\n border-radius: calc(0.5 * ${theme.base['border-radius']});\n\n & + & {\n margin: 0;\n }\n\n &:focus {\n box-shadow: ${theme.components.button['focus-shadow']};\n }\n\n img {\n border-radius: calc(0.5 * ${theme.base['border-radius']});\n object-fit: contain;\n max-height: 32rem;\n max-width: 100%;\n }\n `;\n});\n\nStyledImagePreview.defaultProps = defaultThemeProp;\n\nexport const StyledAttachmentsRegion = styled.div(({ theme }) => {\n return css`\n margin: ${theme.base.spacing} 0;\n\n ${StyledFlex} + ${StyledFeedAttachments} {\n margin-block-start: ${theme.base.spacing};\n }\n `;\n});\n\nStyledAttachmentsRegion.defaultProps = defaultThemeProp;\n\nconst FeedAttachments: FC<FeedAttachmentsProps> = forwardRef(\n (props: PropsWithoutRef<FeedAttachmentsProps>, ref: FeedAttachmentsProps['ref']) => {\n const { attachments = [], readOnly } = props;\n\n if (attachments.length === 0) return null;\n\n const previewableFiles: AttachedFiles[] = [];\n const nonPreviewableFiles: AttachedFiles[] = [];\n\n attachments.forEach(file => {\n const type = getKindFromMimeType(getMimeTypeFromFile(file.name) ?? '');\n\n if (type === 'image') previewableFiles.push(file);\n else nonPreviewableFiles.push(file);\n });\n\n return (\n <StyledAttachmentsRegion>\n {readOnly && !!previewableFiles.length && (\n <Flex container={{ direction: 'column', gap: 1 }}>\n {previewableFiles.map(({ lastModified, name, onPreview, thumbnail }) => {\n return (\n <StyledImagePreview key={lastModified} onClick={() => onPreview?.(name)}>\n <Image alt={name} src={thumbnail} />\n </StyledImagePreview>\n );\n })}\n </Flex>\n )}\n <Grid\n ref={ref}\n as={StyledFeedAttachments}\n container={{\n cols: 'repeat(auto-fill, minmax(15rem, 1fr))',\n gap: 1\n }}\n >\n {!readOnly &&\n previewableFiles.map(({ lastModified, name, size, ...restProps }) => {\n return <FileUploadItem key={lastModified} name={name} size={size} {...restProps} />;\n })}\n {nonPreviewableFiles.map(({ lastModified, name, size, ...restProps }) => {\n return <FileUploadItem key={lastModified} name={name} size={size} {...restProps} />;\n })}\n </Grid>\n </StyledAttachmentsRegion>\n );\n }\n);\n\nexport default FeedAttachments;\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"FeedButton.d.ts","sourceRoot":"","sources":["../../../src/components/Feed/FeedButton.tsx"],"names":[],"mappings":"AAIA,QAAA,MAAM,UAAU;;;SAkBd,CAAC;AAIH,eAAe,UAAU,CAAC"}
1
+ {"version":3,"file":"FeedButton.d.ts","sourceRoot":"","sources":["../../../src/components/Feed/FeedButton.ts"],"names":[],"mappings":"AAIA,QAAA,MAAM,UAAU;;;SAkBd,CAAC;AAIH,eAAe,UAAU,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"FeedButton.js","sourceRoot":"","sources":["../../../src/components/Feed/FeedButton.tsx"],"names":[],"mappings":"AAAA,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAEhD,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAE3D,MAAM,UAAU,GAAG,MAAM,CAAC,MAAM,CAA2C,KAAK,CAAC,EAAE;IACjF,MAAM,EAAE,UAAU,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,KAAK,CAAC;IAE1C,OAAO,GAAG,CAAA;aACC,UAAU,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,kBAAkB,CAAC;;;;wCAIzD,KAAK,CAAC,IAAI,CAAC,OAAO;;;MAGpD,IAAI;QACN,GAAG,CAAA;;;;KAIF;GACF,CAAC;AACJ,CAAC,CAAC,CAAC;AAEH,UAAU,CAAC,YAAY,GAAG,gBAAgB,CAAC;AAE3C,eAAe,UAAU,CAAC","sourcesContent":["import styled, { css } from 'styled-components';\n\nimport { defaultThemeProp } from '@pega/cosmos-react-core';\n\nconst FeedButton = styled.button<{ emphasized?: boolean; icon?: boolean }>(props => {\n const { emphasized, icon, theme } = props;\n\n return css`\n color: ${emphasized ? theme.base.palette.interactive : theme.base.palette['foreground-color']};\n vertical-align: top;\n\n span {\n margin-inline-start: calc(0.5 * ${theme.base.spacing});\n }\n\n ${icon &&\n css`\n display: inline-flex;\n flex-direction: row;\n align-items: center;\n `}\n `;\n});\n\nFeedButton.defaultProps = defaultThemeProp;\n\nexport default FeedButton;\n"]}
1
+ {"version":3,"file":"FeedButton.js","sourceRoot":"","sources":["../../../src/components/Feed/FeedButton.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAEhD,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAE3D,MAAM,UAAU,GAAG,MAAM,CAAC,MAAM,CAA2C,KAAK,CAAC,EAAE;IACjF,MAAM,EAAE,UAAU,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,KAAK,CAAC;IAE1C,OAAO,GAAG,CAAA;aACC,UAAU,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,kBAAkB,CAAC;;;;wCAIzD,KAAK,CAAC,IAAI,CAAC,OAAO;;;MAGpD,IAAI;QACN,GAAG,CAAA;;;;KAIF;GACF,CAAC;AACJ,CAAC,CAAC,CAAC;AAEH,UAAU,CAAC,YAAY,GAAG,gBAAgB,CAAC;AAE3C,eAAe,UAAU,CAAC","sourcesContent":["import styled, { css } from 'styled-components';\n\nimport { defaultThemeProp } from '@pega/cosmos-react-core';\n\nconst FeedButton = styled.button<{ emphasized?: boolean; icon?: boolean }>(props => {\n const { emphasized, icon, theme } = props;\n\n return css`\n color: ${emphasized ? theme.base.palette.interactive : theme.base.palette['foreground-color']};\n vertical-align: top;\n\n span {\n margin-inline-start: calc(0.5 * ${theme.base.spacing});\n }\n\n ${icon &&\n css`\n display: inline-flex;\n flex-direction: row;\n align-items: center;\n `}\n `;\n});\n\nFeedButton.defaultProps = defaultThemeProp;\n\nexport default FeedButton;\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"FeedContent.d.ts","sourceRoot":"","sources":["../../../src/components/Feed/FeedContent.tsx"],"names":[],"mappings":"AAAA,OAAO,EACL,EAAE,EACF,GAAG,EAOH,YAAY,EAEb,MAAM,OAAO,CAAC;AAEf,OAAO,EAAgC,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAKrF,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,EAAE,YAAY,GAAG,MAAM,CAAC;IAChC;;;OAGG;IACH,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,GAAG,CAAC,EAAE,GAAG,CAAC,cAAc,CAAC,CAAC;CAC3B;AAED,QAAA,MAAM,WAAW,EAAE,EAAE,CAAC,gBAAgB,GAAG,YAAY,CA6DpD,CAAC;AAEF,eAAe,WAAW,CAAC"}
1
+ {"version":3,"file":"FeedContent.d.ts","sourceRoot":"","sources":["../../../src/components/Feed/FeedContent.tsx"],"names":[],"mappings":"AAAA,OAAO,EACL,EAAE,EACF,GAAG,EAOH,YAAY,EAEb,MAAM,OAAO,CAAC;AAEf,OAAO,EAAgC,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAKrF,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,EAAE,YAAY,GAAG,MAAM,CAAC;IAChC;;;OAGG;IACH,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,GAAG,CAAC,EAAE,GAAG,CAAC,cAAc,CAAC,CAAC;CAC3B;AAED,QAAA,MAAM,WAAW,EAAE,EAAE,CAAC,gBAAgB,GAAG,YAAY,CAsEpD,CAAC;AAEF,eAAe,WAAW,CAAC"}
@@ -24,8 +24,16 @@ const FeedContent = forwardRef(({ children, maxContentHeight = Infinity, ...rest
24
24
  observer.disconnect();
25
25
  };
26
26
  }, [rtvRef.current, maxContentHeight]);
27
- return useMemo(() => typeof children === 'string' ? (_jsxs(Flex, Object.assign({ ref: ref, container: { direction: 'column', gap: 1 } }, { children: [_jsx(ExpandCollapse, Object.assign({ collapsed: collapsed, min: exceedsMaxHeight ? `${maxContentHeight}px` : 'max-content' }, restProps, { children: _jsx(RichTextViewer, { ref: rtvRef, content: children, type: 'markdown', interactionRenderers: interactionRenderers, markdownMap: markdownMap }, void 0) }), void 0),
28
- exceedsMaxHeight && (_jsx(Flex, Object.assign({ container: { justify: 'center' } }, { children: _jsx(Button, Object.assign({ variant: 'link', onClick: () => setCollapsed(current => !current) }, { children: collapsed ? 'Show more' : 'Show less' }), void 0) }), void 0))] }), void 0)) : (children), [children, collapsed, exceedsMaxHeight, interactionRenderers]);
27
+ return useMemo(() => typeof children === 'string' ? (_jsxs(Flex, { ref: ref, container: { direction: 'column', gap: 1 }, children: [_jsx(ExpandCollapse, { collapsed: collapsed, min: exceedsMaxHeight ? `${maxContentHeight}px` : 'max-content', ...restProps, children: _jsx(RichTextViewer, { ref: rtvRef, content: children, type: 'markdown', interactionRenderers: interactionRenderers, markdownMap: markdownMap }, void 0) }, void 0), exceedsMaxHeight && (_jsx(Flex, { container: { justify: 'center' }, children: _jsx(Button, { variant: 'link', onClick: () => setCollapsed(current => !current), children: collapsed ? 'Show more' : 'Show less' }, void 0) }, void 0))] }, void 0)) : (children), [
28
+ children,
29
+ collapsed,
30
+ exceedsMaxHeight,
31
+ interactionRenderers,
32
+ markdownMap,
33
+ maxContentHeight,
34
+ ref,
35
+ restProps
36
+ ]);
29
37
  });
30
38
  export default FeedContent;
31
39
  //# sourceMappingURL=FeedContent.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"FeedContent.js","sourceRoot":"","sources":["../../../src/components/Feed/FeedContent.tsx"],"names":[],"mappings":";AAAA,OAAO,EAGL,UAAU,EACV,QAAQ,EACR,OAAO,EACP,MAAM,EACN,eAAe,EAGf,UAAU,EACX,MAAM,OAAO,CAAC;AAEf,OAAO,EAAE,MAAM,EAAE,cAAc,EAAE,IAAI,EAAgB,MAAM,yBAAyB,CAAC;AACrF,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAExD,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAY7C,MAAM,WAAW,GAAwC,UAAU,CACjE,CACE,EAAE,QAAQ,EAAE,gBAAgB,GAAG,QAAQ,EAAE,GAAG,SAAS,EAAqC,EAC1F,GAA4B,EAC5B,EAAE;IACF,MAAM,EAAE,oBAAoB,EAAE,WAAW,EAAE,GAAG,UAAU,CAAC,WAAW,CAAC,CAAC;IACtE,MAAM,CAAC,SAAS,EAAE,YAAY,CAAC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O,EAAE,QAAQ,EACjB,IAAI,EAAC,UAAU,EACf,oBAAoB,EAAE,oBAAoB,EAC1C,WAAW,EAAE,WAAW,WACxB,YACa;YAChB,gBAAgB,IAAI,CACnB,KAAC,IAAI,kBAAC,SAAS,EAAE,EAAE,OAAO,EAAE,QAAQ,EAAE,gBACpC,KAAC,MAAM,kBAAC,OAAO,EAAC,MAAM,EAAC,OAAO,EAAE,GAAG,EAAE,CAAC,YAAY,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC,OAAO,CAAC,gBACpE,SAAS,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,WAAW,YAC/B,YACJ,CACR,aACI,CACR,CAAC,CAAC,CAAC,CACF,QAAQ,CACT,EACH,CAAC,QAAQ,EAAE,SAAS,EAAE,gBAAgB,EAAE,oBAAoB,CAAC,CAC9D,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,eAAe,WAAW,CAAC","sourcesContent":["import {\n FC,\n Ref,\n forwardRef,\n useState,\n useMemo,\n useRef,\n useLayoutEffect,\n PropsWithoutRef,\n ReactElement,\n useContext\n} from 'react';\n\nimport { Button, ExpandCollapse, Flex, ForwardProps } from '@pega/cosmos-react-core';\nimport { RichTextViewer } from '@pega/cosmos-react-rte';\n\nimport { FeedContext } from './Feed.context';\n\nexport interface FeedContentProps {\n children: ReactElement | string;\n /**\n * A maximum height in pixels to display post content within before prompting to expand the post.\n * @default Infinity\n */\n maxContentHeight?: number;\n ref?: Ref<HTMLDivElement>;\n}\n\nconst FeedContent: FC<FeedContentProps & ForwardProps> = forwardRef(\n (\n { children, maxContentHeight = Infinity, ...restProps }: PropsWithoutRef<FeedContentProps>,\n ref: FeedContentProps['ref']\n ) => {\n const { interactionRenderers, markdownMap } = useContext(FeedContext);\n const [collapsed, setCollapsed] = useState(true);\n const [exceedsMaxHeight, setExceedsMaxHeight] = useState(true);\n const rtvRef = useRef<HTMLDivElement>(null);\n\n useLayoutEffect(() => {\n if (!rtvRef.current) return;\n\n const observer = new ResizeObserver(entries => {\n const exceedsHeight = entries.some(({ target, contentRect }) => {\n if (target !== rtvRef.current) return;\n\n return contentRect.height > maxContentHeight;\n });\n\n setExceedsMaxHeight(exceedsHeight);\n });\n\n observer.observe(rtvRef.current);\n\n return () => {\n observer.disconnect();\n };\n }, [rtvRef.current, maxContentHeight]);\n\n return useMemo(\n () =>\n typeof children === 'string' ? (\n <Flex ref={ref} container={{ direction: 'column', gap: 1 }}>\n <ExpandCollapse\n collapsed={collapsed}\n min={exceedsMaxHeight ? `${maxContentHeight}px` : 'max-content'}\n {...restProps}\n >\n <RichTextViewer\n ref={rtvRef}\n content={children}\n type='markdown'\n interactionRenderers={interactionRenderers}\n markdownMap={markdownMap}\n />\n </ExpandCollapse>\n {exceedsMaxHeight && (\n <Flex container={{ justify: 'center' }}>\n <Button variant='link' onClick={() => setCollapsed(current => !current)}>\n {collapsed ? 'Show more' : 'Show less'}\n </Button>\n </Flex>\n )}\n </Flex>\n ) : (\n children\n ),\n [children, collapsed, exceedsMaxHeight, interactionRenderers]\n );\n }\n);\n\nexport default FeedContent;\n"]}
1
+ {"version":3,"file":"FeedContent.js","sourceRoot":"","sources":["../../../src/components/Feed/FeedContent.tsx"],"names":[],"mappings":";AAAA,OAAO,EAGL,UAAU,EACV,QAAQ,EACR,OAAO,EACP,MAAM,EACN,eAAe,EAGf,UAAU,EACX,MAAM,OAAO,CAAC;AAEf,OAAO,EAAE,MAAM,EAAE,cAAc,EAAE,IAAI,EAAgB,MAAM,yBAAyB,CAAC;AACrF,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAExD,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAY7C,MAAM,WAAW,GAAwC,UAAU,CACjE,CACE,EAAE,QAAQ,EAAE,gBAAgB,GAAG,QAAQ,EAAE,GAAG,SAAS,EAAqC,EAC1F,GAA4B,EAC5B,EAAE;IACF,MAAM,EAAE,oBAAoB,EAAE,WAAW,EAAE,GAAG,UA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a,KAC3D,SAAS,YAEb,KAAC,cAAc,IACb,GAAG,EAAE,MAAM,EACX,OAAO,EAAE,QAAQ,EACjB,IAAI,EAAC,UAAU,EACf,oBAAoB,EAAE,oBAAoB,EAC1C,WAAW,EAAE,WAAW,WACxB,WACa,EAChB,gBAAgB,IAAI,CACnB,KAAC,IAAI,IAAC,SAAS,EAAE,EAAE,OAAO,EAAE,QAAQ,EAAE,YACpC,KAAC,MAAM,IAAC,OAAO,EAAC,MAAM,EAAC,OAAO,EAAE,GAAG,EAAE,CAAC,YAAY,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC,OAAO,CAAC,YACpE,SAAS,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,WAAW,WAC/B,WACJ,CACR,YACI,CACR,CAAC,CAAC,CAAC,CACF,QAAQ,CACT,EACH;QACE,QAAQ;QACR,SAAS;QACT,gBAAgB;QAChB,oBAAoB;QACpB,WAAW;QACX,gBAAgB;QAChB,GAAG;QACH,SAAS;KACV,CACF,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,eAAe,WAAW,CAAC","sourcesContent":["import {\n FC,\n Ref,\n forwardRef,\n useState,\n useMemo,\n useRef,\n useLayoutEffect,\n PropsWithoutRef,\n ReactElement,\n useContext\n} from 'react';\n\nimport { Button, ExpandCollapse, Flex, ForwardProps } from '@pega/cosmos-react-core';\nimport { RichTextViewer } from '@pega/cosmos-react-rte';\n\nimport { FeedContext } from './Feed.context';\n\nexport interface FeedContentProps {\n children: ReactElement | string;\n /**\n * A maximum height in pixels to display post content within before prompting to expand the post.\n * @default Infinity\n */\n maxContentHeight?: number;\n ref?: Ref<HTMLDivElement>;\n}\n\nconst FeedContent: FC<FeedContentProps & ForwardProps> = forwardRef(\n (\n { children, maxContentHeight = Infinity, ...restProps }: PropsWithoutRef<FeedContentProps>,\n ref: FeedContentProps['ref']\n ) => {\n const { interactionRenderers, markdownMap } = useContext(FeedContext);\n const [collapsed, setCollapsed] = useState(true);\n const [exceedsMaxHeight, setExceedsMaxHeight] = useState(true);\n const rtvRef = useRef<HTMLDivElement>(null);\n\n useLayoutEffect(() => {\n if (!rtvRef.current) return;\n\n const observer = new ResizeObserver(entries => {\n const exceedsHeight = entries.some(({ target, contentRect }) => {\n if (target !== rtvRef.current) return;\n\n return contentRect.height > maxContentHeight;\n });\n\n setExceedsMaxHeight(exceedsHeight);\n });\n\n observer.observe(rtvRef.current);\n\n return () => {\n observer.disconnect();\n };\n }, [rtvRef.current, maxContentHeight]);\n\n return useMemo(\n () =>\n typeof children === 'string' ? (\n <Flex ref={ref} container={{ direction: 'column', gap: 1 }}>\n <ExpandCollapse\n collapsed={collapsed}\n min={exceedsMaxHeight ? `${maxContentHeight}px` : 'max-content'}\n {...restProps}\n >\n <RichTextViewer\n ref={rtvRef}\n content={children}\n type='markdown'\n interactionRenderers={interactionRenderers}\n markdownMap={markdownMap}\n />\n </ExpandCollapse>\n {exceedsMaxHeight && (\n <Flex container={{ justify: 'center' }}>\n <Button variant='link' onClick={() => setCollapsed(current => !current)}>\n {collapsed ? 'Show more' : 'Show less'}\n </Button>\n </Flex>\n )}\n </Flex>\n ) : (\n children\n ),\n [\n children,\n collapsed,\n exceedsMaxHeight,\n interactionRenderers,\n markdownMap,\n maxContentHeight,\n ref,\n restProps\n ]\n );\n }\n);\n\nexport default FeedContent;\n"]}
@@ -34,7 +34,7 @@ const FeedModalList = ({ count, heading, listItems, onLoadMore }) => {
34
34
  listOverflowsRef.current = true;
35
35
  }
36
36
  else if (entries[0].isIntersecting && listOverflowsRef.current) {
37
- onLoadMore === null || onLoadMore === void 0 ? void 0 : onLoadMore();
37
+ onLoadMore?.();
38
38
  }
39
39
  });
40
40
  intersectionObserver.observe(loadMoreEl);
@@ -43,9 +43,7 @@ const FeedModalList = ({ count, heading, listItems, onLoadMore }) => {
43
43
  };
44
44
  }
45
45
  }, [loadMoreEl, listOverflowsRef.current]);
46
- return (_jsxs(Modal, Object.assign({ heading: _jsxs(Flex, Object.assign({ container: { gap: 1 } }, { children: [heading,
47
- _jsx(Flex, Object.assign({ item: { alignSelf: 'center' }, as: Count }, { children: count }), void 0)] }), void 0) }, { children: [_jsx(SummaryListItems, { items: listItems }, void 0),
48
- onLoadMore && (_jsx(Flex, Object.assign({ ref: setLoadMoreEl, as: StyledLoadMore, visible: listOverflows, container: { justify: 'center' } }, { children: _jsx(Progress, { placement: 'inline' }, void 0) }), void 0))] }), void 0));
46
+ return (_jsxs(Modal, { heading: _jsxs(Flex, { container: { gap: 1 }, children: [heading, _jsx(Flex, { item: { alignSelf: 'center' }, as: Count, children: count }, void 0)] }, void 0), children: [_jsx(SummaryListItems, { items: listItems }, void 0), onLoadMore && (_jsx(Flex, { ref: setLoadMoreEl, as: StyledLoadMore, visible: listOverflows, container: { justify: 'center' }, children: _jsx(Progress, { placement: 'inline' }, void 0) }, void 0))] }, void 0));
49
47
  };
50
48
  export default FeedModalList;
51
49
  //# sourceMappingURL=FeedModalList.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"FeedModalList.js","sourceRoot":"","sources":["../../../src/components/Feed/FeedModalList.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAM,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACxD,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAEhD,OAAO,EAEL,gBAAgB,EAChB,IAAI,EACJ,QAAQ,EACR,UAAU,EACV,kBAAkB,EAClB,KAAK,EACL,KAAK,EACL,gBAAgB,EACjB,MAAM,yBAAyB,CAAC;AAajC,MAAM,cAAc,GAAG,MAAM,CAAC,GAAG,CAAuB,CAAC,EAAE,KAAK,EAAE,OAAO,EAAE,EAAE,EAAE;IAC7E,OAAO,GAAG,CAAA;MACN,OAAO;QACT,GAAG,CAAA;6BACsB,KAAK,CAAC,IAAI,CAAC,OAAO;KAC1C;;MAEC,kBAAkB;;;;QAIhB,OAAO;QACT,GAAG,CAAA;;;OAGF;;GAEJ,CAAC;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,gBAC3C,KAAK,YACD,aACF,iBAGT,KAAC,gBAAgB,IAAC,KAAK,EAAE,SAAS,WAAI;YAErC,UAAU,IAAI,CACb,KAAC,IAAI,kBACH,GAAG,EAAE,aAAa,EAClB,EAAE,EAAE,cAAc,EAClB,OAAO,EAAE,aAAa,EACtB,SAAS,EAAE,EAAE,OAAO,EAAE,QAAQ,EAAE,gBAEhC,KAAC,QAAQ,IAAC,SAAS,EAAC,QAAQ,WAAG,YAC1B,CACR,aACK,CACT,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,aAAa,CAAC","sourcesContent":["import { FC, useEffect, useRef, useState } from 'react';\nimport styled, { css } from 'styled-components';\n\nimport {\n SummaryListItem,\n defaultThemeProp,\n Flex,\n Progress,\n useElement,\n StyledProgressRing,\n Count,\n Modal,\n SummaryListItems\n} from '@pega/cosmos-react-core';\n\nexport interface FeedModalListProps {\n /** The count for the list of items. */\n count: number;\n /** The heading for the Modal. */\n heading: string;\n /** The list of MenuItems to render in the Modal. */\n listItems: SummaryListItem[];\n /** A callback that is triggered when the bottom of the Modal list is scrolled into view so that additional data may be displayed. */\n onLoadMore?: () => void;\n}\n\nconst StyledLoadMore = styled.div<{ visible: boolean }>(({ theme, visible }) => {\n return css`\n ${visible &&\n css`\n margin-top: calc(2 * ${theme.base.spacing});\n `}\n\n ${StyledProgressRing} {\n min-height: 0;\n min-width: 0;\n\n ${visible &&\n css`\n min-height: 2rem;\n min-width: 2rem;\n `}\n }\n `;\n});\n\nStyledLoadMore.defaultProps = defaultThemeProp;\n\nconst FeedModalList: FC<FeedModalListProps> = ({\n count,\n heading,\n listItems,\n onLoadMore\n}: FeedModalListProps) => {\n const [loadMoreEl, setLoadMoreEl] = useElement<HTMLDivElement>();\n const [listOverflows, setListOverflows] = useState(false);\n const listOverflowsRef = useRef(false);\n\n useEffect(() => {\n if (loadMoreEl) {\n const intersectionObserver = new IntersectionObserver(entries => {\n if (!entries[0].isIntersecting) {\n setListOverflows(true);\n listOverflowsRef.current = true;\n } else if (entries[0].isIntersecting && listOverflowsRef.current) {\n onLoadMore?.();\n }\n });\n\n intersectionObserver.observe(loadMoreEl);\n\n return () => {\n intersectionObserver.disconnect();\n };\n }\n }, [loadMoreEl, listOverflowsRef.current]);\n\n return (\n <Modal\n heading={\n <Flex container={{ gap: 1 }}>\n {heading}\n <Flex item={{ alignSelf: 'center' }} as={Count}>\n {count}\n </Flex>\n </Flex>\n }\n >\n <SummaryListItems items={listItems} />\n\n {onLoadMore && (\n <Flex\n ref={setLoadMoreEl}\n as={StyledLoadMore}\n visible={listOverflows}\n container={{ justify: 'center' }}\n >\n <Progress placement='inline' />\n </Flex>\n )}\n </Modal>\n );\n};\n\nexport default FeedModalList;\n"]}
1
+ {"version":3,"file":"FeedModalList.js","sourceRoot":"","sources":["../../../src/components/Feed/FeedModalList.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAM,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACxD,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAEhD,OAAO,EAEL,gBAAgB,EAChB,IAAI,EACJ,QAAQ,EACR,UAAU,EACV,kBAAkB,EAClB,KAAK,EACL,KAAK,EACL,gBAAgB,EACjB,MAAM,yBAAyB,CAAC;AAajC,MAAM,cAAc,GAAG,MAAM,CAAC,GAAG,CAAuB,CAAC,EAAE,KAAK,EAAE,OAAO,EAAE,EAAE,EAAE;IAC7E,OAAO,GAAG,CAAA;MACN,OAAO;QACT,GAAG,CAAA;6BACsB,KAAK,CAAC,IAAI,CAAC,OAAO;KAC1C;;MAEC,kBAAkB;;;;QAIhB,OAAO;QACT,GAAG,CAAA;;;OAGF;;GAEJ,CAAC;AACJ,CAAC,CAAC,CAAC;AAEH,cAAc,CAAC,YAAY,GAAG,gBAAgB,CAAC;AAE/C,MAAM,aAAa,GAA2B,CAAC,EAC7C,KAAK,EACL,OAAO,EACP,SAAS,EACT,UAAU,EACS,EAAE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ACtB,SAAS,EAAE,EAAE,OAAO,EAAE,QAAQ,EAAE,YAEhC,KAAC,QAAQ,IAAC,SAAS,EAAC,QAAQ,WAAG,WAC1B,CACR,YACK,CACT,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,aAAa,CAAC","sourcesContent":["import { FC, useEffect, useRef, useState } from 'react';\nimport styled, { css } from 'styled-components';\n\nimport {\n SummaryListItem,\n defaultThemeProp,\n Flex,\n Progress,\n useElement,\n StyledProgressRing,\n Count,\n Modal,\n SummaryListItems\n} from '@pega/cosmos-react-core';\n\nexport interface FeedModalListProps {\n /** The count for the list of items. */\n count: number;\n /** The heading for the Modal. */\n heading: string;\n /** The list of MenuItems to render in the Modal. */\n listItems: SummaryListItem[];\n /** A callback that is triggered when the bottom of the Modal list is scrolled into view so that additional data may be displayed. */\n onLoadMore?: () => void;\n}\n\nconst StyledLoadMore = styled.div<{ visible: boolean }>(({ theme, visible }) => {\n return css`\n ${visible &&\n css`\n margin-top: calc(2 * ${theme.base.spacing});\n `}\n\n ${StyledProgressRing} {\n min-height: 0;\n min-width: 0;\n\n ${visible &&\n css`\n min-height: 2rem;\n min-width: 2rem;\n `}\n }\n `;\n});\n\nStyledLoadMore.defaultProps = defaultThemeProp;\n\nconst FeedModalList: FC<FeedModalListProps> = ({\n count,\n heading,\n listItems,\n onLoadMore\n}: FeedModalListProps) => {\n const [loadMoreEl, setLoadMoreEl] = useElement<HTMLDivElement>();\n const [listOverflows, setListOverflows] = useState(false);\n const listOverflowsRef = useRef(false);\n\n useEffect(() => {\n if (loadMoreEl) {\n const intersectionObserver = new IntersectionObserver(entries => {\n if (!entries[0].isIntersecting) {\n setListOverflows(true);\n listOverflowsRef.current = true;\n } else if (entries[0].isIntersecting && listOverflowsRef.current) {\n onLoadMore?.();\n }\n });\n\n intersectionObserver.observe(loadMoreEl);\n\n return () => {\n intersectionObserver.disconnect();\n };\n }\n }, [loadMoreEl, listOverflowsRef.current]);\n\n return (\n <Modal\n heading={\n <Flex container={{ gap: 1 }}>\n {heading}\n <Flex item={{ alignSelf: 'center' }} as={Count}>\n {count}\n </Flex>\n </Flex>\n }\n >\n <SummaryListItems items={listItems} />\n\n {onLoadMore && (\n <Flex\n ref={setLoadMoreEl}\n as={StyledLoadMore}\n visible={listOverflows}\n container={{ justify: 'center' }}\n >\n <Progress placement='inline' />\n </Flex>\n )}\n </Modal>\n );\n};\n\nexport default FeedModalList;\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"FeedNewPost.d.ts","sourceRoot":"","sources":["../../../src/components/Feed/FeedNewPost.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAY,EAAE,EAA6C,MAAM,OAAO,CAAC;AAGhF,OAAO,EAaL,YAAY,EAGb,MAAM,yBAAyB,CAAC;AAGjC,OAA4B,EAE1B,iBAAiB,EACjB,iBAAiB,EAClB,MAAM,uBAAuB,CAAC;AAC/B,OAAwB,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAKnE,MAAM,WAAW,gBAAgB;IAC/B,kCAAkC;IAClC,EAAE,EAAE,MAAM,CAAC;IACX,iCAAiC;IACjC,WAAW,CAAC,EAAE,aAAa,EAAE,CAAC;IAC9B,sFAAsF;IACtF,eAAe,EAAE;QACf,mBAAmB,EAAE,MAAM,CAAC;QAC5B,SAAS,EAAE,MAAM,CAAC;KACnB,CAAC;IACF,sGAAsG;IACtG,YAAY,CAAC,EAAE,CAAC,KAAK,EAAE,aAAa,EAAE,KAAK,IAAI,CAAC;IAChD,yEAAyE;IACzE,MAAM,EAAE,CAAC,KAAK,EAAE;QACd,SAAS,EAAE,MAAM,CAAC;QAClB,KAAK,EAAE,MAAM,CAAC;QACd,WAAW,EAAE,aAAa,EAAE,CAAC;QAC7B,UAAU,EAAE,iBAAiB,EAAE,CAAC;QAChC,QAAQ,EAAE,MAAM,CAAC;QACjB,KAAK,EAAE,MAAM,IAAI,CAAC;KACnB,KAAK,IAAI,CAAC;IACX,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,yC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,KAAK,IAAI,CAAC;IACX,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,yCAAyC;IACzC,UAAU,CAAC,EAAE,iBAAiB,CAAC,YAAY,CAAC,CAAC;IAC7C,0DAA0D;IAC1D,iBAAiB,CAAC,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,IAAI,CAAC;CACjD;AAED,eAAO,MAAM,sBAAsB,yGAajC,CAAC;AAIH,eAAO,MAAM,iBAAiB,yGAU5B,CAAC;AAQH,QAAA,MAAM,WAAW,EAAE,EAAE,CAAC,YAAY,GAAG,gBAAgB,CA2JpD,CAAC;AAEF,eAAe,WAAW,CAAC"}
@@ -1,17 +1,21 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { useState, useRef, useContext, useEffect } from 'react';
2
+ import { useState, useRef, useContext } from 'react';
3
3
  import styled, { css } from 'styled-components';
4
- import { Avatar, Button, CardContent, Flex, Icon, StyledIcon, StyledCard, StyledPopover, defaultThemeProp, useAutoResize, useElement, useOuterEvent, useI18n, ExpandCollapse } from '@pega/cosmos-react-core';
4
+ import { Avatar, Button, CardContent, Flex, Icon, registerIcon, StyledIcon, StyledCard, StyledPopover, defaultThemeProp, useAutoResize, useElement, useOuterEvent, useI18n, ExpandCollapse, useAfterInitialEffect, cap } from '@pega/cosmos-react-core';
5
5
  import { StyledRichTextEditor } from '@pega/cosmos-react-rte';
6
+ import * as timesIcon from '@pega/cosmos-react-core/lib/components/Icon/icons/times.icon';
7
+ import * as paperClipIcon from '@pega/cosmos-react-core/lib/components/Icon/icons/paper-clip.icon';
6
8
  import FeedNewPostTypeMenu from './FeedNewPostTypeMenu';
7
9
  import FeedAttachments from './FeedAttachments';
8
10
  import FeedButton from './FeedButton';
9
11
  import FeedRichText from './FeedRichText';
10
12
  import { FeedContext } from './Feed.context';
11
- export const StyledTextAreaOverflow = styled.div(({ theme }) => {
13
+ registerIcon(timesIcon, paperClipIcon);
14
+ export const StyledTextAreaOverflow = styled.div(() => {
12
15
  return css `
13
16
  overflow-y: hidden;
14
- margin-top: ${theme.base.spacing};
17
+ margin-top: 0.625rem;
18
+ min-height: 1rem;
15
19
  width: 100%;
16
20
 
17
21
  ${StyledRichTextEditor} {
@@ -38,10 +42,11 @@ const HiddenFileInput = styled.input `
38
42
  display: none;
39
43
  `;
40
44
  const FeedNewPost = (props) => {
41
- var _a;
42
45
  const { id, attachments = [], interactionInfo, onPost, onFilesAdded, autoFocus, recipients, onRecipientSearch, ...restProps } = props;
43
46
  const rteRef = useRef();
44
47
  const { textAreaPlaceholder, postLabel } = interactionInfo;
48
+ const { setShowSearchResults } = useContext(FeedContext);
49
+ const { avatarSrc, fullname, username } = useContext(FeedContext).userInfo;
45
50
  const [emptyText, setEmptyText] = useState(true);
46
51
  const [hasFocus, setHasFocus] = useState(autoFocus);
47
52
  const [postType, setPostType] = useState('post');
@@ -50,59 +55,54 @@ const FeedNewPost = (props) => {
50
55
  const [attachmentEl, setAttachmentEl] = useElement();
51
56
  const [newPostEl, setNewPostEl] = useElement();
52
57
  const [textAreaRef, resizeTextArea] = useAutoResize();
53
- const { avatarSrc, fullname, username } = useContext(FeedContext).userInfo;
54
58
  useOuterEvent('mousedown', [newPostEl], () => {
55
- var _a;
56
59
  if (emptyText)
57
- (_a = rteRef.current) === null || _a === void 0 ? void 0 : _a.clear();
60
+ rteRef.current?.clear();
58
61
  });
59
62
  const t = useI18n();
60
63
  const handlePost = () => {
61
- var _a;
62
- if (!emptyText || attachments.length > 0) {
64
+ setShowSearchResults?.(false);
65
+ if ((!emptyText || attachments.length > 0) && attachments.every(x => !x.error)) {
63
66
  onPost({
64
67
  newPostId: id,
65
- value: ((_a = rteRef.current) === null || _a === void 0 ? void 0 : _a.getPlainText()) || '',
68
+ value: rteRef.current?.getPlainText() || '',
66
69
  attachments: attachments || [],
67
70
  recipients: selectedRecipients,
68
71
  username,
69
72
  clear: () => {
70
- var _a;
71
- (_a = rteRef.current) === null || _a === void 0 ? void 0 : _a.clear();
73
+ rteRef.current?.clear();
72
74
  setResetPostTypeMenu(true);
73
75
  }
74
76
  });
75
77
  }
76
78
  };
77
- useEffect(() => {
78
- var _a;
79
+ const handleClear = () => {
80
+ setShowSearchResults?.(false);
81
+ rteRef.current?.clear();
82
+ };
83
+ useAfterInitialEffect(() => {
79
84
  if (postType === 'post') {
80
- (_a = rteRef.current) === null || _a === void 0 ? void 0 : _a.focus();
85
+ rteRef.current?.focus();
81
86
  }
82
87
  if (postType !== 'private') {
83
88
  setSelectedRecipients([]);
84
89
  }
85
90
  }, [postType]);
86
- return (_jsx(StyledCard, Object.assign({ ref: setNewPostEl, as: StyledFeedNewPost }, restProps, { children: _jsxs(CardContent, { children: [onRecipientSearch && (_jsx(FeedNewPostTypeMenu, { recipients: recipients || [], onSetPostType: setPostType, onSelectedRecipientsUpdate: setSelectedRecipients, onRecipientSearch: onRecipientSearch, reset: resetPostTypeMenu, onReset: () => setResetPostTypeMenu(false) }, void 0)),
87
- _jsxs(Flex, Object.assign({ container: { alignItems: 'start', gap: 1 } }, { children: [_jsx(Avatar, { name: fullname, size: 'l', imageSrc: avatarSrc }, void 0),
88
- _jsx(StyledTextAreaOverflow, Object.assign({ ref: textAreaRef }, { children: _jsx(FeedRichText, { onChange: () => {
89
- var _a;
90
- setEmptyText(((_a = rteRef.current) === null || _a === void 0 ? void 0 : _a.getPlainText().trim()) === '');
91
+ return (_jsx(StyledCard, { ref: setNewPostEl, as: StyledFeedNewPost, ...restProps, children: _jsxs(CardContent, { children: [onRecipientSearch && (_jsx(FeedNewPostTypeMenu, { recipients: recipients || [], onSetPostType: setPostType, onSelectedRecipientsUpdate: setSelectedRecipients, onRecipientSearch: onRecipientSearch, reset: resetPostTypeMenu, onReset: () => setResetPostTypeMenu(false) }, void 0)), _jsxs(Flex, { container: { alignItems: 'start', gap: 1 }, children: [_jsx(Avatar, { name: fullname, size: 'l', imageSrc: avatarSrc }, void 0), _jsx(StyledTextAreaOverflow, { ref: textAreaRef, children: _jsx(FeedRichText, { label: t('feed_new_post'), labelHidden: true, onChange: () => {
92
+ setEmptyText(rteRef.current?.getPlainText().trim() === '');
91
93
  resizeTextArea();
92
- }, placeholder: textAreaPlaceholder, autoFocus: autoFocus, onSubmit: handlePost, onFocus: () => setHasFocus(true), onBlur: () => setHasFocus(false), ref: rteRef }, void 0) }), void 0),
93
- !emptyText && (_jsx(Button, Object.assign({ variant: 'simple', as: FeedButton, onClick: (_a = rteRef.current) === null || _a === void 0 ? void 0 : _a.clear, icon: true, label: t('feed_cancel_conversation') }, { children: _jsx(Icon, { name: 'times' }, void 0) }), void 0)),
94
- onFilesAdded && (_jsx(Button, Object.assign({ variant: 'simple', as: FeedButton, onClick: () => attachmentEl === null || attachmentEl === void 0 ? void 0 : attachmentEl.click(), icon: true, label: t('attachment') }, { children: _jsx(Icon, { name: 'paper-clip' }, void 0) }), void 0))] }), void 0),
95
- _jsx(HiddenFileInput, { ref: setAttachmentEl, type: 'file', multiple: true, onChange: () => {
96
- if (attachmentEl === null || attachmentEl === void 0 ? void 0 : attachmentEl.files) {
97
- onFilesAdded === null || onFilesAdded === void 0 ? void 0 : onFilesAdded(Array.from(attachmentEl === null || attachmentEl === void 0 ? void 0 : attachmentEl.files));
94
+ }, placeholder: textAreaPlaceholder, autoFocus: autoFocus, onSubmit: handlePost, onFocus: () => setHasFocus(true), onBlur: () => setHasFocus(false), ref: rteRef }, void 0) }, void 0), !emptyText && (_jsx(Button, { variant: 'simple', as: FeedButton, onClick: handleClear, icon: true, label: t('feed_cancel_conversation'), children: _jsx(Icon, { name: 'times' }, void 0) }, void 0)), onFilesAdded && (_jsx(Button, { variant: 'simple', as: FeedButton, onClick: () => {
95
+ setShowSearchResults?.(false);
96
+ attachmentEl?.click();
97
+ }, icon: true, label: cap(t('attachments_count', [], { count: 1 })), children: _jsx(Icon, { name: 'paper-clip' }, void 0) }, void 0))] }, void 0), _jsx(HiddenFileInput, { ref: setAttachmentEl, type: 'file', multiple: true, onChange: () => {
98
+ if (attachmentEl?.files) {
99
+ onFilesAdded?.(Array.from(attachmentEl?.files));
98
100
  }
99
101
  },
100
102
  // Must trick input to believe there is no value when activated so that the same file may be added consecutively.
101
103
  onClick: (event) => {
102
104
  event.target.value = '';
103
- } }, void 0),
104
- _jsx(FeedAttachments, { attachments: attachments }, void 0),
105
- _jsx(ExpandCollapse, Object.assign({ collapsed: !hasFocus && emptyText && !attachments.length }, { children: _jsx(Flex, Object.assign({ container: { justify: 'end' } }, { children: _jsx(Button, Object.assign({ variant: 'primary', disabled: emptyText && attachments.length === 0, onClick: handlePost }, { children: postLabel }), void 0) }), void 0) }), void 0)] }, void 0) }), void 0));
105
+ } }, void 0), _jsx(FeedAttachments, { attachments: attachments }, void 0), _jsx(ExpandCollapse, { collapsed: !hasFocus && emptyText && !attachments.length, children: _jsx(Flex, { container: { justify: 'end' }, children: _jsx(Button, { variant: 'primary', disabled: (emptyText && attachments.length === 0) || attachments.some(x => x.error), onClick: handlePost, children: postLabel }, void 0) }, void 0) }, void 0)] }, void 0) }, void 0));
106
106
  };
107
107
  export default FeedNewPost;
108
108
  //# sourceMappingURL=FeedNewPost.js.map