@pega/cosmos-react-social 3.0.0-dev.13.0 → 3.0.0-dev.16.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.
Files changed (51) hide show
  1. package/lib/components/Email/Email.d.ts.map +1 -1
  2. package/lib/components/Email/Email.js +32 -18
  3. package/lib/components/Email/Email.js.map +1 -1
  4. package/lib/components/Email/Email.styles.d.ts +12 -0
  5. package/lib/components/Email/Email.styles.d.ts.map +1 -1
  6. package/lib/components/Email/Email.styles.js +55 -0
  7. package/lib/components/Email/Email.styles.js.map +1 -1
  8. package/lib/components/Email/Email.types.d.ts +74 -31
  9. package/lib/components/Email/Email.types.d.ts.map +1 -1
  10. package/lib/components/Email/Email.types.js.map +1 -1
  11. package/lib/components/Email/EmailComposer.d.ts.map +1 -1
  12. package/lib/components/Email/EmailComposer.js +60 -103
  13. package/lib/components/Email/EmailComposer.js.map +1 -1
  14. package/lib/components/Email/EmailManager.d.ts +6 -0
  15. package/lib/components/Email/EmailManager.d.ts.map +1 -0
  16. package/lib/components/Email/EmailManager.js +36 -0
  17. package/lib/components/Email/EmailManager.js.map +1 -0
  18. package/lib/components/Email/EmailSelector.d.ts +3 -1
  19. package/lib/components/Email/EmailSelector.d.ts.map +1 -1
  20. package/lib/components/Email/EmailSelector.js +5 -10
  21. package/lib/components/Email/EmailSelector.js.map +1 -1
  22. package/lib/components/Email/EmailShell.d.ts.map +1 -1
  23. package/lib/components/Email/EmailShell.js +4 -1
  24. package/lib/components/Email/EmailShell.js.map +1 -1
  25. package/lib/components/Email/EmailSummaryItem.js +2 -2
  26. package/lib/components/Email/EmailSummaryItem.js.map +1 -1
  27. package/lib/components/Email/EmailSummaryList.d.ts.map +1 -1
  28. package/lib/components/Email/EmailSummaryList.js +25 -73
  29. package/lib/components/Email/EmailSummaryList.js.map +1 -1
  30. package/lib/components/Email/EntityList.d.ts.map +1 -1
  31. package/lib/components/Email/EntityList.js +44 -5
  32. package/lib/components/Email/EntityList.js.map +1 -1
  33. package/lib/components/Email/index.d.ts +2 -1
  34. package/lib/components/Email/index.d.ts.map +1 -1
  35. package/lib/components/Email/index.js +1 -0
  36. package/lib/components/Email/index.js.map +1 -1
  37. package/lib/components/Feed/Feed.context.d.ts +5 -0
  38. package/lib/components/Feed/Feed.context.d.ts.map +1 -1
  39. package/lib/components/Feed/Feed.context.js.map +1 -1
  40. package/lib/components/Feed/Feed.d.ts +3 -1
  41. package/lib/components/Feed/Feed.d.ts.map +1 -1
  42. package/lib/components/Feed/Feed.js +2 -1
  43. package/lib/components/Feed/Feed.js.map +1 -1
  44. package/lib/components/Feed/FeedRichText.d.ts.map +1 -1
  45. package/lib/components/Feed/FeedRichText.js +16 -6
  46. package/lib/components/Feed/FeedRichText.js.map +1 -1
  47. package/lib/components/MentionButton/MentionButton.d.ts +2 -0
  48. package/lib/components/MentionButton/MentionButton.d.ts.map +1 -1
  49. package/lib/components/MentionButton/MentionButton.js +21 -5
  50. package/lib/components/MentionButton/MentionButton.js.map +1 -1
  51. package/package.json +4 -4
@@ -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,WAAW,EAAE,MAAM,OAAO,CAAC;AAC7F,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAEhD,OAAO,EACL,MAAM,EACN,gBAAgB,EAChB,IAAI,EAEJ,IAAI,EACJ,IAAI,EACJ,YAAY,EACZ,OAAO,EACP,MAAM,EACN,IAAI,EACJ,QAAQ,EACR,WAAW,EAEX,mBAAmB,EACnB,MAAM,EACP,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,O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CACxB,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,IAAI,CAAC","sourcesContent":["import { ChangeEvent, ReactNode, FC, useState, useRef, useEffect, useCallback } 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 usePrevious,\n NoChildrenProp,\n useItemIntersection,\n useUID\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 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 /** 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> = (props: ForwardProps & FeedProps) => {\n const {\n loadingPosts = false,\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 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 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 setTimeout(() => {\n setAnnouncementText(announcement);\n }, 0);\n }, []);\n\n useEffect(() => {\n if (loadingPosts) announce(t('loading_post'));\n }, [loadingPosts]);\n\n useEffect(() => {\n if (prevPosts) {\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 }, [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 onTagClick,\n interactionRenderers,\n markdownMap,\n userInfo,\n announce\n }}\n >\n <StyledFeed {...restProps}>\n <FeedAnnouncer>{announcementText}</FeedAnnouncer>\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 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\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,WAAW,EAAE,MAAM,OAAO,CAAC;AAC7F,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAEhD,OAAO,EACL,MAAM,EACN,gBAAgB,EAChB,IAAI,EAEJ,IAAI,EACJ,IAAI,EACJ,YAAY,EACZ,OAAO,EACP,MAAM,EACN,IAAI,EACJ,QAAQ,EACR,WAAW,EAEX,mBAAmB,EACnB,MAAM,EACP,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,OAAO,EAAE,aAAa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AAQ,EAAE,EAAE,EAAE,EAAE,cAAc,YACxD,KAAC,QAAQ,IAAC,SAAS,EAAC,QAAQ,GAAG,GAC1B,CACR,IACU,GACQ,CACxB,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,IAAI,CAAC","sourcesContent":["import { ChangeEvent, ReactNode, FC, useState, useRef, useEffect, useCallback } 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 usePrevious,\n NoChildrenProp,\n useItemIntersection,\n useUID\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> = (props: ForwardProps & FeedProps) => {\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 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 setTimeout(() => {\n setAnnouncementText(announcement);\n }, 0);\n }, []);\n\n useEffect(() => {\n if (loadingPosts) announce(t('loading_post'));\n }, [loadingPosts]);\n\n useEffect(() => {\n if (prevPosts) {\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 }, [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 }}\n >\n <StyledFeed {...restProps}>\n <FeedAnnouncer>{announcementText}</FeedAnnouncer>\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 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\nexport default Feed;\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"FeedRichText.d.ts","sourceRoot":"","sources":["../../../src/components/Feed/FeedRichText.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAiD,MAAM,OAAO,CAAC;AAE1E,OAAO,EAAO,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAC5D,OAAO,EAAkB,mBAAmB,EAAuB,MAAM,wBAAwB,CAAC;AAOlG,MAAM,WAAW,iBACf,SAAQ,IAAI,CAAC,mBAAmB,EAAE,UAAU,GAAG,SAAS,GAAG,QAAQ,GAAG,aAAa,GAAG,QAAQ,CAAC;IAC/F,QAAQ,EAAE,MAAM,IAAI,CAAC;CACtB;AAED,QAAA,MAAM,YAAY,EAAE,EAAE,CAAC,iBAAiB,GAAG,YAAY,CAuHtD,CAAC;AAEF,eAAe,YAAY,CAAC"}
1
+ {"version":3,"file":"FeedRichText.d.ts","sourceRoot":"","sources":["../../../src/components/Feed/FeedRichText.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAiD,MAAM,OAAO,CAAC;AAE1E,OAAO,EAAO,YAAY,EAAW,MAAM,yBAAyB,CAAC;AACrE,OAAO,EAAkB,mBAAmB,EAAuB,MAAM,wBAAwB,CAAC;AAOlG,MAAM,WAAW,iBACf,SAAQ,IAAI,CAAC,mBAAmB,EAAE,UAAU,GAAG,SAAS,GAAG,QAAQ,GAAG,aAAa,GAAG,QAAQ,CAAC;IAC/F,QAAQ,EAAE,MAAM,IAAI,CAAC;CACtB;AAED,QAAA,MAAM,YAAY,EAAE,EAAE,CAAC,iBAAiB,GAAG,YAAY,CAmItD,CAAC;AAEF,eAAe,YAAY,CAAC"}
@@ -1,6 +1,6 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import { useContext, forwardRef, useState, useRef } from 'react';
3
- import { cap } from '@pega/cosmos-react-core';
3
+ import { cap, useI18n } from '@pega/cosmos-react-core';
4
4
  import { RichTextEditor } from '@pega/cosmos-react-rte';
5
5
  import { MentionButtonConfig } from '../MentionButton';
6
6
  import { HashtagButtonConfig } from '../HashtagButton';
@@ -11,6 +11,7 @@ const FeedRichText = forwardRef((props, ref) => {
11
11
  const [triggerType, setTriggerType] = useState('mention');
12
12
  const [showMentionType, setShowMentionType] = useState(false);
13
13
  const searchType = useRef('');
14
+ const t = useI18n();
14
15
  const onDecoSearch = (event) => {
15
16
  const trigger = event.trigger === '@' ? 'mention' : 'tag';
16
17
  setTriggerType(trigger);
@@ -42,8 +43,10 @@ const FeedRichText = forwardRef((props, ref) => {
42
43
  };
43
44
  const searchMenu = searchResults.length && showSearchResults
44
45
  ? {
45
- header: triggerType === 'mention' ? `Mention a ${searchType.current}` : '',
46
- items: searchResults
46
+ header: triggerType === 'mention' ? t('mention_type', [searchType.current]) : '',
47
+ items: searchResults.map(res => {
48
+ return { ...res, href: undefined };
49
+ })
47
50
  }
48
51
  : undefined;
49
52
  const getSearchAttributes = (searchResult) => {
@@ -60,10 +63,11 @@ const FeedRichText = forwardRef((props, ref) => {
60
63
  const id = searchResult.groups.id;
61
64
  const text = searchResult.groups.text;
62
65
  const type = searchResult.groups.type;
66
+ const href = searchResult.groups.href || '';
63
67
  return {
64
68
  markdown: searchResult.groups.match,
65
69
  component: MentionButtonConfig.component,
66
- props: { id, text, type },
70
+ props: { id, text, type, href },
67
71
  text
68
72
  };
69
73
  }
@@ -77,13 +81,19 @@ const FeedRichText = forwardRef((props, ref) => {
77
81
  return undefined;
78
82
  return {
79
83
  markdown: triggerType === 'mention'
80
- ? `@${item.id}:${item.primary}:${searchType.current}:`
84
+ ? `@[${item.id}]:[${item.primary}]:[${searchType.current}]:${item.href ? `[${item.href}]:` : ''}`
81
85
  : `#${item.id}:`,
82
86
  component: triggerType === 'mention'
83
87
  ? MentionButtonConfig.component
84
88
  : HashtagButtonConfig.component,
85
89
  props: triggerType === 'mention'
86
- ? { id: item.id, text: item.primary, type: searchType.current, tabIndex: -1 }
90
+ ? {
91
+ id: item.id,
92
+ text: item.primary,
93
+ type: searchType.current,
94
+ href: item.href,
95
+ tabIndex: -1
96
+ }
87
97
  : { tag: item.primary, tabIndex: -1 },
88
98
  text: item.primary
89
99
  };
@@ -1 +1 @@
1
- {"version":3,"file":"FeedRichText.js","sourceRoot":"","sources":["../../../src/components/Feed/FeedRichText.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAM,UAAU,EAAE,UAAU,EAAO,QAAQ,EAAE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AI;gBAAE,OAAO,SAAS,CAAC;YAE5B,OAAO;gBACL,QAAQ,EACN,WAAW,KAAK,SAAS;oBACvB,CAAC,CAAC,IAAI,IAAI,CAAC,EAAE,IAAI,IAAI,CAAC,OAAO,IAAI,UAAU,CAAC,OAAO,GAAG;oBACtD,CAAC,CAAC,IAAI,IAAI,CAAC,EAAE,GAAG;gBACpB,SAAS,EACP,WAAW,KAAK,SAAS;oBACvB,CAAC,CAAC,mBAAmB,CAAC,SAAS;oBAC/B,CAAC,CAAC,mBAAmB,CAAC,SAAS;gBACnC,KAAK,EACH,WAAW,KAAK,SAAS;oBACvB,CAAC,CAAC,EAAE,EAAE,EAAE,IAAI,CAAC,EAAE,EAAE,IAAI,EAAE,IAAI,CAAC,OAAO,EAAE,IAAI,EAAE,UAAU,CAAC,OAAO,EAAE,QAAQ,EAAE,CAAC,CAAC,EAAE;oBAC7E,CAAC,CAAC,EAAE,GAAG,EAAE,IAAI,CAAC,OAAO,EAAE,QAAQ,EAAE,CAAC,CAAC,EAAE;gBACzC,IAAI,EAAE,IAAI,CAAC,OAAO;aACnB,CAAC;QACJ,CAAC,EACD,eAAe,EAAE;YACf,EAAE,YAAY,EAAE,mBAAmB,CAAC,YAAY,EAAE,mBAAmB,EAAE;YACvE,EAAE,YAAY,EAAE,mBAAmB,CAAC,YAAY,EAAE,mBAAmB,EAAE;SACxE,EACD,QAAQ,EAAE,YAAY,EACtB,IAAI,EAAE,eAAe,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,UAAU,GAC9C,CACH,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,eAAe,YAAY,CAAC","sourcesContent":["import { FC, useContext, forwardRef, Ref, useState, useRef } from 'react';\n\nimport { cap, ForwardProps } from '@pega/cosmos-react-core';\nimport { RichTextEditor, RichTextEditorProps, RichTextEditorState } from '@pega/cosmos-react-rte';\n\nimport { MentionButtonConfig } from '../MentionButton';\nimport { HashtagButtonConfig } from '../HashtagButton';\n\nimport { FeedContext } from './Feed.context';\n\nexport interface FeedRichTextProps\n extends Pick<RichTextEditorProps, 'onChange' | 'onFocus' | 'onBlur' | 'placeholder' | 'height'> {\n onSubmit: () => void;\n}\n\nconst FeedRichText: FC<FeedRichTextProps & ForwardProps> = forwardRef(\n (props: FeedRichTextProps, ref: Ref<RichTextEditorState>) => {\n const { onSubmit, height = { min: 'auto' }, ...restProps } = props;\n const {\n searchTypes = [],\n onSearch,\n searchResults = [],\n showSearchResults,\n setShowSearchResults\n } = useContext(FeedContext);\n const [triggerType, setTriggerType] = useState<'mention' | 'tag'>('mention');\n const [showMentionType, setShowMentionType] = useState(false);\n const searchType = useRef('');\n\n const onDecoSearch = (event: { search: string; trigger: string }) => {\n const trigger = event.trigger === '@' ? 'mention' : 'tag';\n setTriggerType(trigger);\n if (trigger === 'mention' && event.search === '') {\n setShowMentionType(true);\n } else {\n setShowMentionType(false);\n onSearch?.({ type: trigger, search: event.search, mentionType: searchType.current });\n }\n };\n\n const onKeyDown = (event: KeyboardEvent) => {\n setShowSearchResults?.(true);\n if ((event.metaKey || event.ctrlKey) && event.key === 'Enter') onSubmit();\n };\n\n const typesMenu = {\n onItemActive: (id: string) => {\n searchType.current = id;\n },\n onItemClick: (id: string) => {\n searchType.current = id;\n setShowMentionType(false);\n onSearch?.({ type: 'mention', search: '', mentionType: id });\n },\n items: searchTypes.map(type => {\n return { id: type, primary: cap(type) };\n })\n };\n\n const searchMenu =\n searchResults.length && showSearchResults\n ? {\n header: triggerType === 'mention' ? `Mention a ${searchType.current}` : '',\n items: searchResults\n }\n : undefined;\n\n const getSearchAttributes = (searchResult: RegExpExecArray) => {\n if (searchResult.groups) {\n if (searchResult.groups.tag) {\n const tag = searchResult.groups.tag;\n\n return {\n markdown: searchResult.groups.match,\n component: HashtagButtonConfig.component,\n props: { tag },\n text: tag\n };\n }\n\n const id = searchResult.groups.id;\n const text = searchResult.groups.text;\n const type = searchResult.groups.type;\n\n return {\n markdown: searchResult.groups.match,\n component: MentionButtonConfig.component,\n props: { id, text, type },\n text\n };\n }\n };\n\n return (\n <RichTextEditor\n {...restProps}\n markdownOnly\n onKeyDown={onKeyDown}\n ref={ref}\n height={height}\n searchTriggers={[\n { trigger: '@', regex: String.raw`(?:\\S+(?:[^\\n\\S][^@#\\s]\\S*)*[^\\n\\S]?|)` },\n { trigger: '#', regex: String.raw`[^\\s,]*` }\n ]}\n getSearchItemReplacement={(id: string) => {\n const item = searchResults?.find(({ id: itemId }) => itemId === id);\n\n if (!item) return undefined;\n\n return {\n markdown:\n triggerType === 'mention'\n ? `@${item.id}:${item.primary}:${searchType.current}:`\n : `#${item.id}:`,\n component:\n triggerType === 'mention'\n ? MentionButtonConfig.component\n : HashtagButtonConfig.component,\n props:\n triggerType === 'mention'\n ? { id: item.id, text: item.primary, type: searchType.current, tabIndex: -1 }\n : { tag: item.primary, tabIndex: -1 },\n text: item.primary\n };\n }}\n searchRenderers={[\n { regexPattern: MentionButtonConfig.regexPattern, getSearchAttributes },\n { regexPattern: HashtagButtonConfig.regexPattern, getSearchAttributes }\n ]}\n onSearch={onDecoSearch}\n menu={showMentionType ? typesMenu : searchMenu}\n />\n );\n }\n);\n\nexport default FeedRichText;\n"]}
1
+ {"version":3,"file":"FeedRichText.js","sourceRoot":"","sources":["../../../src/components/Feed/FeedRichText.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAM,UAAU,EAAE,UAAU,EAAO,QAAQ,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAE1E,OAAO,EAAE,GAAG,EAAgB,OAAO,EAAE,MAAM,yBAAyB,CAAC;AACrE,OAAO,EAAE,cAAc,EAA4C,MAAM,wBAAwB,CAAC;AAElG,OAAO,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AACvD,OAAO,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAEvD,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAO7C,MAAM,YAAY,GAAyC,UAAU,CACnE,CAAC,KAAwB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KAAK,SAAS;oBACvB,CAAC,CAAC,KAAK,IAAI,CAAC,EAAE,MAAM,IAAI,CAAC,OAAO,MAAM,UAAU,CAAC,OAAO,KACpD,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,IAAI,CAAC,IAAI,IAAI,CAAC,CAAC,CAAC,EAClC,EAAE;oBACJ,CAAC,CAAC,IAAI,IAAI,CAAC,EAAE,GAAG;gBACpB,SAAS,EACP,WAAW,KAAK,SAAS;oBACvB,CAAC,CAAC,mBAAmB,CAAC,SAAS;oBAC/B,CAAC,CAAC,mBAAmB,CAAC,SAAS;gBACnC,KAAK,EACH,WAAW,KAAK,SAAS;oBACvB,CAAC,CAAC;wBACE,EAAE,EAAE,IAAI,CAAC,EAAE;wBACX,IAAI,EAAE,IAAI,CAAC,OAAO;wBAClB,IAAI,EAAE,UAAU,CAAC,OAAO;wBACxB,IAAI,EAAE,IAAI,CAAC,IAAI;wBACf,QAAQ,EAAE,CAAC,CAAC;qBACb;oBACH,CAAC,CAAC,EAAE,GAAG,EAAE,IAAI,CAAC,OAAO,EAAE,QAAQ,EAAE,CAAC,CAAC,EAAE;gBACzC,IAAI,EAAE,IAAI,CAAC,OAAO;aACnB,CAAC;QACJ,CAAC,EACD,eAAe,EAAE;YACf,EAAE,YAAY,EAAE,mBAAmB,CAAC,YAAY,EAAE,mBAAmB,EAAE;YACvE,EAAE,YAAY,EAAE,mBAAmB,CAAC,YAAY,EAAE,mBAAmB,EAAE;SACxE,EACD,QAAQ,EAAE,YAAY,EACtB,IAAI,EAAE,eAAe,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,UAAU,GAC9C,CACH,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,eAAe,YAAY,CAAC","sourcesContent":["import { FC, useContext, forwardRef, Ref, useState, useRef } from 'react';\n\nimport { cap, ForwardProps, useI18n } from '@pega/cosmos-react-core';\nimport { RichTextEditor, RichTextEditorProps, RichTextEditorState } from '@pega/cosmos-react-rte';\n\nimport { MentionButtonConfig } from '../MentionButton';\nimport { HashtagButtonConfig } from '../HashtagButton';\n\nimport { FeedContext } from './Feed.context';\n\nexport interface FeedRichTextProps\n extends Pick<RichTextEditorProps, 'onChange' | 'onFocus' | 'onBlur' | 'placeholder' | 'height'> {\n onSubmit: () => void;\n}\n\nconst FeedRichText: FC<FeedRichTextProps & ForwardProps> = forwardRef(\n (props: FeedRichTextProps, ref: Ref<RichTextEditorState>) => {\n const { onSubmit, height = { min: 'auto' }, ...restProps } = props;\n const {\n searchTypes = [],\n onSearch,\n searchResults = [],\n showSearchResults,\n setShowSearchResults\n } = useContext(FeedContext);\n const [triggerType, setTriggerType] = useState<'mention' | 'tag'>('mention');\n const [showMentionType, setShowMentionType] = useState(false);\n const searchType = useRef('');\n const t = useI18n();\n\n const onDecoSearch = (event: { search: string; trigger: string }) => {\n const trigger = event.trigger === '@' ? 'mention' : 'tag';\n setTriggerType(trigger);\n if (trigger === 'mention' && event.search === '') {\n setShowMentionType(true);\n } else {\n setShowMentionType(false);\n onSearch?.({ type: trigger, search: event.search, mentionType: searchType.current });\n }\n };\n\n const onKeyDown = (event: KeyboardEvent) => {\n setShowSearchResults?.(true);\n if ((event.metaKey || event.ctrlKey) && event.key === 'Enter') onSubmit();\n };\n\n const typesMenu = {\n onItemActive: (id: string) => {\n searchType.current = id;\n },\n onItemClick: (id: string) => {\n searchType.current = id;\n setShowMentionType(false);\n onSearch?.({ type: 'mention', search: '', mentionType: id });\n },\n items: searchTypes.map(type => {\n return { id: type, primary: cap(type) };\n })\n };\n\n const searchMenu =\n searchResults.length && showSearchResults\n ? {\n header: triggerType === 'mention' ? t('mention_type', [searchType.current]) : '',\n items: searchResults.map(res => {\n return { ...res, href: undefined };\n })\n }\n : undefined;\n\n const getSearchAttributes = (searchResult: RegExpExecArray) => {\n if (searchResult.groups) {\n if (searchResult.groups.tag) {\n const tag = searchResult.groups.tag;\n\n return {\n markdown: searchResult.groups.match,\n component: HashtagButtonConfig.component,\n props: { tag },\n text: tag\n };\n }\n\n const id = searchResult.groups.id;\n const text = searchResult.groups.text;\n const type = searchResult.groups.type;\n const href = searchResult.groups.href || '';\n\n return {\n markdown: searchResult.groups.match,\n component: MentionButtonConfig.component,\n props: { id, text, type, href },\n text\n };\n }\n };\n\n return (\n <RichTextEditor\n {...restProps}\n markdownOnly\n onKeyDown={onKeyDown}\n ref={ref}\n height={height}\n searchTriggers={[\n { trigger: '@', regex: String.raw`(?:\\S+(?:[^\\n\\S][^@#\\s]\\S*)*[^\\n\\S]?|)` },\n { trigger: '#', regex: String.raw`[^\\s,]*` }\n ]}\n getSearchItemReplacement={(id: string) => {\n const item = searchResults?.find(({ id: itemId }) => itemId === id);\n\n if (!item) return undefined;\n\n return {\n markdown:\n triggerType === 'mention'\n ? `@[${item.id}]:[${item.primary}]:[${searchType.current}]:${\n item.href ? `[${item.href}]:` : ''\n }`\n : `#${item.id}:`,\n component:\n triggerType === 'mention'\n ? MentionButtonConfig.component\n : HashtagButtonConfig.component,\n props:\n triggerType === 'mention'\n ? {\n id: item.id,\n text: item.primary,\n type: searchType.current,\n href: item.href,\n tabIndex: -1\n }\n : { tag: item.primary, tabIndex: -1 },\n text: item.primary\n };\n }}\n searchRenderers={[\n { regexPattern: MentionButtonConfig.regexPattern, getSearchAttributes },\n { regexPattern: HashtagButtonConfig.regexPattern, getSearchAttributes }\n ]}\n onSearch={onDecoSearch}\n menu={showMentionType ? typesMenu : searchMenu}\n />\n );\n }\n);\n\nexport default FeedRichText;\n"]}
@@ -9,6 +9,8 @@ interface MentionButtonProps {
9
9
  text?: string;
10
10
  /** Designates the type of the mention for proper handling on click. */
11
11
  type?: string;
12
+ /** If an href is provided, render a link. Otherwise, render a button. */
13
+ href?: string;
12
14
  }
13
15
  declare const MentionButton: FunctionComponent<MentionButtonProps & ForwardProps>;
14
16
  export declare const MentionButtonConfig: {
@@ -1 +1 @@
1
- {"version":3,"file":"MentionButton.d.ts","sourceRoot":"","sources":["../../../src/components/MentionButton/MentionButton.tsx"],"names":[],"mappings":"AAAA,OAAO,EAEL,iBAAiB,EAGjB,YAAY,EAKb,MAAM,OAAO,CAAC;AAGf,OAAO,EAEL,YAAY,EAIb,MAAM,yBAAyB,CAAC;AAIjC,UAAU,kBAAkB;IAC1B,4EAA4E;IAC5E,QAAQ,EAAE,eAAe,GAAG,YAAY,CAAC;IACzC,8BAA8B;IAC9B,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,sCAAsC;IACtC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,uEAAuE;IACvE,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAUD,QAAA,MAAM,aAAa,EAAE,iBAAiB,CAAC,kBAAkB,GAAG,YAAY,CA2EvE,CAAC;AAEF,eAAO,MAAM,mBAAmB;;;;CAI/B,CAAC;AAEF,eAAe,aAAa,CAAC"}
1
+ {"version":3,"file":"MentionButton.d.ts","sourceRoot":"","sources":["../../../src/components/MentionButton/MentionButton.tsx"],"names":[],"mappings":"AAAA,OAAO,EAEL,iBAAiB,EAGjB,YAAY,EAKb,MAAM,OAAO,CAAC;AAGf,OAAO,EAEL,YAAY,EAKb,MAAM,yBAAyB,CAAC;AAIjC,UAAU,kBAAkB;IAC1B,4EAA4E;IAC5E,QAAQ,EAAE,eAAe,GAAG,YAAY,CAAC;IACzC,8BAA8B;IAC9B,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,sCAAsC;IACtC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,uEAAuE;IACvE,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,yEAAyE;IACzE,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAkBD,QAAA,MAAM,aAAa,EAAE,iBAAiB,CAAC,kBAAkB,GAAG,YAAY,CAqGvE,CAAC;AAEF,eAAO,MAAM,mBAAmB;;;;CAK/B,CAAC;AAEF,eAAe,aAAa,CAAC"}
@@ -1,7 +1,7 @@
1
1
  import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { forwardRef, isValidElement, useContext, useRef, useState } from 'react';
3
3
  import styled from 'styled-components';
4
- import { Button, Popover, useConsolidatedRef, useOuterEvent } from '@pega/cosmos-react-core';
4
+ import { Button, Link, Popover, useConsolidatedRef, useOuterEvent } from '@pega/cosmos-react-core';
5
5
  import { FeedContext } from '../Feed/Feed.context';
6
6
  const StyledButton = styled(Button) `
7
7
  &:enabled:focus,
@@ -10,8 +10,15 @@ const StyledButton = styled(Button) `
10
10
  text-decoration: underline;
11
11
  }
12
12
  `;
13
- const MentionButton = forwardRef(({ children, id: idProp = '', text: textProp = '', type: typeProp = '', ...restProps }, ref) => {
14
- const { onMentionClick } = useContext(FeedContext);
13
+ const StyledLink = styled(Link) `
14
+ &:enabled:focus,
15
+ &:not([disabled]):focus {
16
+ box-shadow: none;
17
+ text-decoration: underline;
18
+ }
19
+ `;
20
+ const MentionButton = forwardRef(({ children, id: idProp = '', text: textProp = '', type: typeProp = '', href: hrefProp = '', ...restProps }, ref) => {
21
+ const { onMentionClick, onMentionPreview } = useContext(FeedContext);
15
22
  const [showPopover, setShowPopover] = useState(false);
16
23
  const [mentionContent, setMentionContent] = useState();
17
24
  const mentionRef = useConsolidatedRef(ref);
@@ -24,6 +31,7 @@ const MentionButton = forwardRef(({ children, id: idProp = '', text: textProp =
24
31
  let id = '';
25
32
  let text = '';
26
33
  let type = '';
34
+ let href = '';
27
35
  if (!isValidElement(children)) {
28
36
  if (!children.groups)
29
37
  return _jsx("span", { children: children[0] });
@@ -31,11 +39,13 @@ const MentionButton = forwardRef(({ children, id: idProp = '', text: textProp =
31
39
  id = children.groups.id;
32
40
  text = children.groups.text;
33
41
  type = children.groups.type;
42
+ href = children.groups.href || '';
34
43
  }
35
44
  else {
36
45
  id = idProp;
37
46
  text = textProp;
38
47
  type = typeProp;
48
+ href = hrefProp;
39
49
  }
40
50
  const handleClick = () => {
41
51
  const comp = onMentionClick?.({
@@ -47,11 +57,17 @@ const MentionButton = forwardRef(({ children, id: idProp = '', text: textProp =
47
57
  setShowPopover(true);
48
58
  setMentionContent(comp);
49
59
  };
50
- return (_jsxs(_Fragment, { children: [leadingChar && _jsx("span", { children: leadingChar }), _jsx(StyledButton, { ...restProps, ref: mentionRef, variant: 'link', onClick: handleClick, spellCheck: false, children: isValidElement(children) ? children : text }), trailingChar && _jsx("span", { children: trailingChar }), _jsx(Popover, { ref: popoverRef, show: showPopover, target: mentionRef.current, placement: 'bottom-start', arrow: true, children: mentionContent })] }));
60
+ return (_jsxs(_Fragment, { children: [leadingChar && _jsx("span", { children: leadingChar }), href ? (_jsx(StyledLink, { ...restProps, ref: mentionRef, href: href, previewable: !!onMentionPreview, onPreview: onMentionPreview
61
+ ? () => onMentionPreview({
62
+ id,
63
+ text,
64
+ type
65
+ })
66
+ : undefined, spellCheck: false, children: isValidElement(children) ? children : text })) : (_jsx(StyledButton, { ...restProps, ref: mentionRef, variant: 'link', onClick: handleClick, spellCheck: false, children: isValidElement(children) ? children : text })), trailingChar && _jsx("span", { children: trailingChar }), _jsx(Popover, { ref: popoverRef, show: showPopover, target: mentionRef.current, placement: 'bottom-start', arrow: true, children: mentionContent })] }));
51
67
  });
52
68
  export const MentionButtonConfig = {
53
69
  type: 'mention',
54
- regexPattern: /(?:^|)(?<match>@(?<id>[^ :]+\w):(?<text>[^:]+\w):(?<type>[^:]+\w):)/g,
70
+ regexPattern: /(?:^|)(?<match>@\[(?<id>[^ [\]]+)\]:\[(?<text>[^[\]]+)\]:\[(?<type>[^[\]]+)\]:(?:\[(?<href>[^ [\]]+)\]:)?)/g,
55
71
  component: MentionButton
56
72
  };
57
73
  export default MentionButton;
@@ -1 +1 @@
1
- {"version":3,"file":"MentionButton.js","sourceRoot":"","sources":["../../../src/components/MentionButton/MentionButton.tsx"],"names":[],"mappings":";AAAA,OAAO,EACL,UAAU,EAEV,cAAc,EAId,UAAU,EACV,MAAM,EACN,QAAQ,EACT,MAAM,OAAO,CAAC;AACf,OAAO,MAAM,MAAM,mBAAm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f,YAAY,EAAE,sEAAsE;IACpF,SAAS,EAAE,aAAa;CACzB,CAAC;AAEF,eAAe,aAAa,CAAC","sourcesContent":["import {\n forwardRef,\n FunctionComponent,\n isValidElement,\n PropsWithoutRef,\n ReactElement,\n Ref,\n useContext,\n useRef,\n useState\n} from 'react';\nimport styled from 'styled-components';\n\nimport {\n Button,\n ForwardProps,\n Popover,\n useConsolidatedRef,\n useOuterEvent\n} from '@pega/cosmos-react-core';\n\nimport { FeedContext } from '../Feed/Feed.context';\n\ninterface MentionButtonProps {\n /** Text for the button, or a regex match containing all necessary props. */\n children: RegExpExecArray | ReactElement;\n /** The id of the mention. */\n id?: string;\n /** The text of the mention button. */\n text?: string;\n /** Designates the type of the mention for proper handling on click. */\n type?: string;\n}\n\nconst StyledButton = styled(Button)`\n &:enabled:focus,\n &:not([disabled]):focus {\n box-shadow: none;\n text-decoration: underline;\n }\n`;\n\nconst MentionButton: FunctionComponent<MentionButtonProps & ForwardProps> = forwardRef(\n (\n {\n children,\n id: idProp = '',\n text: textProp = '',\n type: typeProp = '',\n ...restProps\n }: PropsWithoutRef<MentionButtonProps>,\n ref: Ref<HTMLButtonElement>\n ) => {\n const { onMentionClick } = useContext(FeedContext);\n const [showPopover, setShowPopover] = useState(false);\n const [mentionContent, setMentionContent] = useState<JSX.Element | undefined>();\n const mentionRef = useConsolidatedRef(ref);\n const popoverRef = useRef(null);\n\n useOuterEvent(['click', 'focusin'], [mentionRef, popoverRef], () => {\n setShowPopover(false);\n });\n\n let leadingChar = '';\n let trailingChar = '';\n let id = '';\n let text = '';\n let type = '';\n\n if (!isValidElement(children)) {\n if (!children.groups) return <span>{children[0]}</span>;\n\n [leadingChar, trailingChar] = children[0].split(children.groups.match);\n id = children.groups.id;\n text = children.groups.text;\n type = children.groups.type;\n } else {\n id = idProp;\n text = textProp;\n type = typeProp;\n }\n\n const handleClick = () => {\n const comp = onMentionClick?.({\n id,\n text,\n type\n });\n if (comp) setShowPopover(true);\n setMentionContent(comp);\n };\n\n return (\n <>\n {leadingChar && <span>{leadingChar}</span>}\n <StyledButton\n {...restProps}\n ref={mentionRef}\n variant='link'\n onClick={handleClick}\n spellCheck={false}\n >\n {isValidElement(children) ? children : text}\n </StyledButton>\n {trailingChar && <span>{trailingChar}</span>}\n <Popover\n ref={popoverRef}\n show={showPopover}\n target={mentionRef.current}\n placement='bottom-start'\n arrow\n >\n {mentionContent}\n </Popover>\n </>\n );\n }\n);\n\nexport const MentionButtonConfig = {\n type: 'mention',\n regexPattern: /(?:^|)(?<match>@(?<id>[^ :]+\\w):(?<text>[^:]+\\w):(?<type>[^:]+\\w):)/g,\n component: MentionButton\n};\n\nexport default MentionButton;\n"]}
1
+ {"version":3,"file":"MentionButton.js","sourceRoot":"","sources":["../../../src/components/MentionButton/MentionButton.tsx"],"names":[],"mappings":";AAAA,OAAO,EACL,UAAU,EAEV,cAAc,EAId,UAAU,EACV,MAAM,EACN,QAAQ,EACT,MAAM,OAAO,CAAC;AACf,OAAO,MAAM,MAAM,mBAAmB,CAAC;AAEvC,OAAO,EACL,MAAM,EAEN,IAAI,EACJ,OAAO,EACP,kBAAkB,EAClB,aAAa,EACd,MAAM,yBAAyB,CAAC;AAEjC,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAenD,MAAM,YAAY,GAAG,MAAM,CAAC,MAAM,CAAC,CAAA;;;;;;CAMlC,CAAC;AAEF,MAAM,UAAU,GAAG,MAAM,CAAC,IAAI,CAAC,CAAA;;;;;;CAM9B,CAAC;AAEF,MAAM,aAAa,GAAyD,UAAU,CACpF,CACE,EACE,QAAQ,EACR,EAAE,EAAE,MAAM,GAAG,EAAE,EACf,IAAI,EAAE,QAAQ,GAAG,EAAE,EACnB,IAAI,EAAE,QAAQ,GAAG,EAAE,EACnB,IAAI,EAAE,QAAQ,GAAG,EAAE,EACnB,GAAG,SAAS,EACwB,EACtC,GAA2B,EAC3B,EAAE;IACF,MAAM,EAAE,cAAc,EAAE,gBAAgB,EAAE,GAA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,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,MAAM,CAAC,MAAM,mBAAmB,GAAG;IACjC,IAAI,EAAE,SAAS;IACf,YAAY,EACV,6GAA6G;IAC/G,SAAS,EAAE,aAAa;CACzB,CAAC;AAEF,eAAe,aAAa,CAAC","sourcesContent":["import {\n forwardRef,\n FunctionComponent,\n isValidElement,\n PropsWithoutRef,\n ReactElement,\n Ref,\n useContext,\n useRef,\n useState\n} from 'react';\nimport styled from 'styled-components';\n\nimport {\n Button,\n ForwardProps,\n Link,\n Popover,\n useConsolidatedRef,\n useOuterEvent\n} from '@pega/cosmos-react-core';\n\nimport { FeedContext } from '../Feed/Feed.context';\n\ninterface MentionButtonProps {\n /** Text for the button, or a regex match containing all necessary props. */\n children: RegExpExecArray | ReactElement;\n /** The id of the mention. */\n id?: string;\n /** The text of the mention button. */\n text?: string;\n /** Designates the type of the mention for proper handling on click. */\n type?: string;\n /** If an href is provided, render a link. Otherwise, render a button. */\n href?: string;\n}\n\nconst StyledButton = styled(Button)`\n &:enabled:focus,\n &:not([disabled]):focus {\n box-shadow: none;\n text-decoration: underline;\n }\n`;\n\nconst StyledLink = styled(Link)`\n &:enabled:focus,\n &:not([disabled]):focus {\n box-shadow: none;\n text-decoration: underline;\n }\n`;\n\nconst MentionButton: FunctionComponent<MentionButtonProps & ForwardProps> = forwardRef(\n (\n {\n children,\n id: idProp = '',\n text: textProp = '',\n type: typeProp = '',\n href: hrefProp = '',\n ...restProps\n }: PropsWithoutRef<MentionButtonProps>,\n ref: Ref<HTMLButtonElement>\n ) => {\n const { onMentionClick, onMentionPreview } = useContext(FeedContext);\n const [showPopover, setShowPopover] = useState(false);\n const [mentionContent, setMentionContent] = useState<JSX.Element | undefined>();\n const mentionRef = useConsolidatedRef(ref);\n const popoverRef = useRef(null);\n\n useOuterEvent(['click', 'focusin'], [mentionRef, popoverRef], () => {\n setShowPopover(false);\n });\n\n let leadingChar = '';\n let trailingChar = '';\n let id = '';\n let text = '';\n let type = '';\n let href = '';\n\n if (!isValidElement(children)) {\n if (!children.groups) return <span>{children[0]}</span>;\n\n [leadingChar, trailingChar] = children[0].split(children.groups.match);\n id = children.groups.id;\n text = children.groups.text;\n type = children.groups.type;\n href = children.groups.href || '';\n } else {\n id = idProp;\n text = textProp;\n type = typeProp;\n href = hrefProp;\n }\n\n const handleClick = () => {\n const comp = onMentionClick?.({\n id,\n text,\n type\n });\n if (comp) setShowPopover(true);\n setMentionContent(comp);\n };\n\n return (\n <>\n {leadingChar && <span>{leadingChar}</span>}\n {href ? (\n <StyledLink\n {...restProps}\n ref={mentionRef}\n href={href}\n previewable={!!onMentionPreview}\n onPreview={\n onMentionPreview\n ? () =>\n onMentionPreview({\n id,\n text,\n type\n })\n : undefined\n }\n spellCheck={false}\n >\n {isValidElement(children) ? children : text}\n </StyledLink>\n ) : (\n <StyledButton\n {...restProps}\n ref={mentionRef}\n variant='link'\n onClick={handleClick}\n spellCheck={false}\n >\n {isValidElement(children) ? children : text}\n </StyledButton>\n )}\n {trailingChar && <span>{trailingChar}</span>}\n <Popover\n ref={popoverRef}\n show={showPopover}\n target={mentionRef.current}\n placement='bottom-start'\n arrow\n >\n {mentionContent}\n </Popover>\n </>\n );\n }\n);\n\nexport const MentionButtonConfig = {\n type: 'mention',\n regexPattern:\n /(?:^|)(?<match>@\\[(?<id>[^ [\\]]+)\\]:\\[(?<text>[^[\\]]+)\\]:\\[(?<type>[^[\\]]+)\\]:(?:\\[(?<href>[^ [\\]]+)\\]:)?)/g,\n component: MentionButton\n};\n\nexport default MentionButton;\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pega/cosmos-react-social",
3
- "version": "3.0.0-dev.13.0",
3
+ "version": "3.0.0-dev.16.0",
4
4
  "author": "Pegasystems",
5
5
  "license": "SEE LICENSE IN LICENSE",
6
6
  "repository": {
@@ -20,9 +20,9 @@
20
20
  "build": "tsc -b"
21
21
  },
22
22
  "dependencies": {
23
- "@pega/cosmos-react-core": "3.0.0-dev.13.0",
24
- "@pega/cosmos-react-rte": "3.0.0-dev.13.0",
25
- "@pega/cosmos-react-work": "3.0.0-dev.13.0",
23
+ "@pega/cosmos-react-core": "3.0.0-dev.16.0",
24
+ "@pega/cosmos-react-rte": "3.0.0-dev.16.0",
25
+ "@pega/cosmos-react-work": "3.0.0-dev.16.0",
26
26
  "@types/react": "^16.14.24 || ^17.0.38",
27
27
  "@types/react-dom": "^16.9.14 || ^17.0.11",
28
28
  "@types/styled-components": "^5.1.7",