@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,8 +1,7 @@
1
1
  import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { forwardRef, useContext, useRef, useState } from 'react';
2
+ import { forwardRef, isValidElement, useContext, useRef, useState } from 'react';
3
3
  import styled from 'styled-components';
4
4
  import { Button, Popover, useConsolidatedRef, useOuterEvent } from '@pega/cosmos-react-core';
5
- import { Glimpse } from '@pega/cosmos-react-work';
6
5
  import { FeedContext } from '../Feed/Feed.context';
7
6
  const StyledButton = styled(Button) `
8
7
  &:enabled:focus,
@@ -11,30 +10,48 @@ const StyledButton = styled(Button) `
11
10
  text-decoration: underline;
12
11
  }
13
12
  `;
14
- const MentionButton = forwardRef(({ children, ...restProps }, ref) => {
15
- const { availableMentions } = useContext(FeedContext);
13
+ const MentionButton = forwardRef(({ children, id: idProp = '', text: textProp = '', type: typeProp = '', ...restProps }, ref) => {
14
+ const { onMentionClick } = useContext(FeedContext);
16
15
  const [showPopover, setShowPopover] = useState(false);
16
+ const [mentionContent, setMentionContent] = useState();
17
17
  const mentionRef = useConsolidatedRef(ref);
18
18
  const popoverRef = useRef(null);
19
19
  useOuterEvent(['click', 'focusin'], [mentionRef, popoverRef], () => {
20
20
  setShowPopover(false);
21
21
  });
22
- if (!children.groups)
23
- return _jsx("span", { children: children[0] }, void 0);
24
- const getMentionedUser = (id) => {
25
- return availableMentions === null || availableMentions === void 0 ? void 0 : availableMentions.find(user => user.id === id);
22
+ let leadingChar = '';
23
+ let trailingChar = '';
24
+ let id = '';
25
+ let text = '';
26
+ let type = '';
27
+ if (!isValidElement(children)) {
28
+ if (!children.groups)
29
+ return _jsx("span", { children: children[0] }, void 0);
30
+ [leadingChar, trailingChar] = children[0].split(children.groups.match);
31
+ id = children.groups.id;
32
+ text = children.groups.text;
33
+ type = children.groups.type;
34
+ }
35
+ else {
36
+ id = idProp;
37
+ text = textProp;
38
+ type = typeProp;
39
+ }
40
+ const handleClick = () => {
41
+ const comp = onMentionClick?.({
42
+ id,
43
+ text,
44
+ type
45
+ });
46
+ if (comp)
47
+ setShowPopover(true);
48
+ setMentionContent(comp);
26
49
  };
27
- const [leadingChar, trailingChar] = children[0].split(children.groups.match);
28
- const id = children.groups.id;
29
- const user = getMentionedUser(id) || { id, primary: id };
30
- return (_jsxs(_Fragment, { children: [leadingChar && _jsx("span", { children: leadingChar }, void 0),
31
- _jsx(StyledButton, Object.assign({}, restProps, { ref: mentionRef, variant: 'link', onClick: () => setShowPopover(true) }, { children: user.primary }), void 0),
32
- trailingChar && _jsx("span", { children: trailingChar }, void 0),
33
- _jsx(Popover, Object.assign({ ref: popoverRef, show: showPopover, target: mentionRef.current, placement: 'bottom-start', arrow: true, portal: true }, { children: _jsx(Glimpse, Object.assign({}, user), void 0) }), void 0)] }, void 0));
50
+ return (_jsxs(_Fragment, { children: [leadingChar && _jsx("span", { children: leadingChar }, void 0), _jsx(StyledButton, { ...restProps, ref: mentionRef, variant: 'link', onClick: handleClick, spellCheck: false, children: isValidElement(children) ? children : text }, void 0), trailingChar && _jsx("span", { children: trailingChar }, void 0), _jsx(Popover, { ref: popoverRef, show: showPopover, target: mentionRef.current, placement: 'bottom-start', arrow: true, children: mentionContent }, void 0)] }, void 0));
34
51
  });
35
52
  export const MentionButtonConfig = {
36
53
  type: 'mention',
37
- regexPattern: /(?:^|\s)(?<match>@(?<id>\S+\w))/g,
54
+ regexPattern: /(?:^|)(?<match>@(?<id>[^ :]+\w):(?<text>[^:]+\w):(?<type>[^:]+\w):)/g,
38
55
  component: MentionButton
39
56
  };
40
57
  export default MentionButton;
@@ -1 +1 @@
1
- {"version":3,"file":"MentionButton.js","sourceRoot":"","sources":["../../../src/components/MentionButton/MentionButton.tsx"],"names":[],"mappings":";AAAA,OAAO,EACL,UAAU,EAIV,UAAU,EACV,MAAM,EACN,QAAQ,EACT,MAAM,OAAO,CAAC;AACf,OAAO,MAAM,MAAM,mBAAmB,CAAC;AAEvC,OAAO,EACL,MAAM,EAEN,OAAO,EACP,kBAAkB,EAClB,aAAa,EACd,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,OAAO,EAAgB,MAAM,yBAAyB,CAAC;AAEhE,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAOnD,MAAM,YAAY,GAAG,MAAM,CAAC,MAAM,CAAC,CAAA;;;;;;CAMlC,CAAC;AAEF,MAAM,aAAa,GAAyD,UAAU,CACpF,CACE,EAAE,QAAQ,EAAE,GAAG,SAAS,EAAuC,EAC/D,GAA2B,EAC3B,EAAE;IACF,MAAM,EAAE,iBAAiB,EAAE,GAAG,UAAU,CAAC,WAAW,CAAC,CAAC;IACtD,MAAM,CAAC,WAAW,EAAE,cAAc,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC;IACtD,MAAM,UAAU,GAAG,kBA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C,cAAc,EACxB,KAAK,QACL,MAAM,sBAEN,KAAC,OAAO,oBAAK,IAAI,UAAI,YACb,YACT,CACJ,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,MAAM,CAAC,MAAM,mBAAmB,GAAG;IACjC,IAAI,EAAE,SAAS;IACf,YAAY,EAAE,kCAAkC;IAChD,SAAS,EAAE,aAAa;CACzB,CAAC;AAEF,eAAe,aAAa,CAAC","sourcesContent":["import {\n forwardRef,\n FunctionComponent,\n PropsWithoutRef,\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';\nimport { Glimpse, GlimpseProps } from '@pega/cosmos-react-work';\n\nimport { FeedContext } from '../Feed/Feed.context';\n\ninterface MentionButtonProps {\n /** Text for the Button. */\n children: RegExpExecArray;\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 { children, ...restProps }: PropsWithoutRef<MentionButtonProps>,\n ref: Ref<HTMLButtonElement>\n ) => {\n const { availableMentions } = useContext(FeedContext);\n const [showPopover, setShowPopover] = useState(false);\n const mentionRef = useConsolidatedRef(ref);\n const popoverRef = useRef(null);\n\n useOuterEvent(['click', 'focusin'], [mentionRef, popoverRef], () => {\n setShowPopover(false);\n });\n\n if (!children.groups) return <span>{children[0]}</span>;\n\n const getMentionedUser = (id: string): GlimpseProps | undefined => {\n return availableMentions?.find(user => user.id === id);\n };\n\n const [leadingChar, trailingChar] = children[0].split(children.groups.match);\n const id = children.groups.id;\n const user = getMentionedUser(id) || { id, primary: id };\n\n return (\n <>\n {leadingChar && <span>{leadingChar}</span>}\n <StyledButton\n {...restProps}\n ref={mentionRef}\n variant='link'\n onClick={() => setShowPopover(true)}\n >\n {user.primary}\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 portal\n >\n <Glimpse {...user} />\n </Popover>\n </>\n );\n }\n);\n\nexport const MentionButtonConfig = {\n type: 'mention',\n regexPattern: /(?:^|\\s)(?<match>@(?<id>\\S+\\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,OAAO,EACP,kBAAkB,EAClB,aAAa,EACd,MAAM,yBAAyB,CAAC;AAEjC,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAanD,MAAM,YAAY,GAAG,MAAM,CAAC,MAAM,CAAC,CAAA;;;;;;CAMlC,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,GAAG,SAAS,EACwB,EACtC,GAA2B,EAC3B,EAAE;IACF,MAAM,EAAE,cAAc,EAAE,GAAG,UAAU,CAAC,WAAW,CAAC,CAAC;IACnD,MAAM,CAAC,WAAW,EAAE,cAAc,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC;IACtD,MAAM,CAAC,cAAc,EAAE,iBAAiB,CAAC,GAAG,QAAQ,EAA2B,CAAC;IAChF,MAAM,UAAU,GAAG,kBAAkB,CAAC,GAAG,CAAC,CAAC;IAC3C,MAAM,UAAU,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC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G,EAAE,UAAU,EACf,OAAO,EAAC,MAAM,EACd,OAAO,EAAE,WAAW,EACpB,UAAU,EAAE,KAAK,YAEhB,cAAc,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,WAC9B,EACd,YAAY,IAAI,yBAAO,YAAY,WAAQ,EAC5C,KAAC,OAAO,IACN,GAAG,EAAE,UAAU,EACf,IAAI,EAAE,WAAW,EACjB,MAAM,EAAE,UAAU,CAAC,OAAO,EAC1B,SAAS,EAAC,cAAc,EACxB,KAAK,kBAEJ,cAAc,WACP,YACT,CACJ,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,MAAM,CAAC,MAAM,mBAAmB,GAAG;IACjC,IAAI,EAAE,SAAS;IACf,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"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pega/cosmos-react-social",
3
- "version": "2.0.0-dev.9.4",
3
+ "version": "2.0.0-rc.1",
4
4
  "author": "Pegasystems",
5
5
  "license": "SEE LICENSE IN LICENSE",
6
6
  "repository": {
@@ -20,25 +20,24 @@
20
20
  "build": "tsc -b"
21
21
  },
22
22
  "dependencies": {
23
- "@pega/cosmos-react-core": "2.0.0-dev.9.4",
24
- "@pega/cosmos-react-rte": "2.0.0-dev.9.4",
25
- "@pega/cosmos-react-work": "2.0.0-dev.9.4",
23
+ "@pega/cosmos-react-core": "2.0.0-rc.1",
24
+ "@pega/cosmos-react-rte": "2.0.0-rc.1",
25
+ "@pega/cosmos-react-work": "2.0.0-rc.1",
26
26
  "polished": "^4.1.0",
27
27
  "react": "^16.14.0 || ^17.0.0",
28
28
  "react-dom": "^16.14.0 || ^17.0.0",
29
29
  "styled-components": "^5.2.0"
30
30
  },
31
31
  "devDependencies": {
32
- "@storybook/addon-a11y": "^6.3.7",
33
- "@storybook/addon-actions": "^6.3.7",
34
- "@storybook/addon-knobs": "^6.3.0",
35
- "@storybook/addon-storysource": "^6.3.7",
36
- "@storybook/addon-toolbars": "^6.3.7",
37
- "@storybook/addons": "^6.3.7",
38
- "@storybook/react": "^6.3.7",
39
- "@storybook/theming": "^6.3.7",
32
+ "@storybook/addon-a11y": "^6.3.8",
33
+ "@storybook/addon-actions": "^6.3.8",
34
+ "@storybook/addon-knobs": "^6.3.1",
35
+ "@storybook/addon-storysource": "^6.3.8",
36
+ "@storybook/addon-toolbars": "^6.3.8",
37
+ "@storybook/addons": "^6.3.8",
38
+ "@storybook/react": "^6.3.8",
39
+ "@storybook/theming": "^6.3.8",
40
40
  "enzyme": "^3.11.0",
41
- "enzyme-adapter-react-16": "^1.15.5",
42
- "typescript": "~4.3.2"
41
+ "typescript": "~4.5.2"
43
42
  }
44
43
  }