@pega/cosmos-react-social 2.0.0-dev.2.1 → 2.0.0-dev.20.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/components/Chat/Chat.d.ts.map +1 -1
- package/lib/components/Chat/Chat.js +9 -16
- package/lib/components/Chat/Chat.js.map +1 -1
- package/lib/components/Chat/Chat.types.d.ts +3 -3
- package/lib/components/Chat/Chat.types.d.ts.map +1 -1
- package/lib/components/Chat/Chat.types.js.map +1 -1
- package/lib/components/Chat/ChatBody.d.ts.map +1 -1
- package/lib/components/Chat/ChatBody.js +4 -3
- package/lib/components/Chat/ChatBody.js.map +1 -1
- package/lib/components/Chat/ChatComposer.d.ts.map +1 -1
- package/lib/components/Chat/ChatComposer.js +36 -51
- package/lib/components/Chat/ChatComposer.js.map +1 -1
- package/lib/components/Chat/ChatHeader.d.ts.map +1 -1
- package/lib/components/Chat/ChatHeader.js +10 -13
- package/lib/components/Chat/ChatHeader.js.map +1 -1
- package/lib/components/Chat/ChatTranscript.d.ts.map +1 -1
- package/lib/components/Chat/ChatTranscript.js +15 -16
- package/lib/components/Chat/ChatTranscript.js.map +1 -1
- package/lib/components/Chat/Message.d.ts.map +1 -1
- package/lib/components/Chat/Message.js +41 -59
- package/lib/components/Chat/Message.js.map +1 -1
- package/lib/components/Chat/Message.styles.js +2 -2
- package/lib/components/Chat/Message.styles.js.map +1 -1
- package/lib/components/Chat/MessageList.d.ts.map +1 -1
- package/lib/components/Chat/MessageList.js +36 -41
- package/lib/components/Chat/MessageList.js.map +1 -1
- package/lib/components/Chat/RepeatingView.d.ts.map +1 -1
- package/lib/components/Chat/RepeatingView.js +10 -14
- package/lib/components/Chat/RepeatingView.js.map +1 -1
- package/lib/components/Chat/SuggestedReplyPicker.d.ts.map +1 -1
- package/lib/components/Chat/SuggestedReplyPicker.js +46 -54
- package/lib/components/Chat/SuggestedReplyPicker.js.map +1 -1
- package/lib/components/Chat/SystemMessage.d.ts.map +1 -1
- package/lib/components/Chat/SystemMessage.js +4 -6
- package/lib/components/Chat/SystemMessage.js.map +1 -1
- package/lib/components/Chat/TranscriptMessage.d.ts.map +1 -1
- package/lib/components/Chat/TranscriptMessage.js +7 -13
- package/lib/components/Chat/TranscriptMessage.js.map +1 -1
- package/lib/components/Chat/TypeIndicator.d.ts.map +1 -1
- package/lib/components/Chat/TypeIndicator.js +3 -2
- package/lib/components/Chat/TypeIndicator.js.map +1 -1
- package/lib/components/Email/Email.d.ts.map +1 -1
- package/lib/components/Email/Email.js +102 -129
- package/lib/components/Email/Email.js.map +1 -1
- package/lib/components/Email/Email.styles.d.ts +7 -1
- package/lib/components/Email/Email.styles.d.ts.map +1 -1
- package/lib/components/Email/Email.styles.js +73 -4
- package/lib/components/Email/Email.styles.js.map +1 -1
- package/lib/components/Email/Email.types.d.ts +124 -62
- package/lib/components/Email/Email.types.d.ts.map +1 -1
- package/lib/components/Email/Email.types.js.map +1 -1
- package/lib/components/Email/EmailComposer.d.ts +4 -6
- package/lib/components/Email/EmailComposer.d.ts.map +1 -1
- package/lib/components/Email/EmailComposer.js +155 -73
- package/lib/components/Email/EmailComposer.js.map +1 -1
- package/lib/components/Email/EmailConversation.d.ts +7 -4
- package/lib/components/Email/EmailConversation.d.ts.map +1 -1
- package/lib/components/Email/EmailConversation.js +132 -76
- package/lib/components/Email/EmailConversation.js.map +1 -1
- package/lib/components/Email/EmailEntity.d.ts +6 -0
- package/lib/components/Email/EmailEntity.d.ts.map +1 -0
- package/lib/components/Email/EmailEntity.js +19 -0
- package/lib/components/Email/EmailEntity.js.map +1 -0
- package/lib/components/Email/EmailSelector.d.ts +14 -0
- package/lib/components/Email/EmailSelector.d.ts.map +1 -0
- package/lib/components/Email/EmailSelector.js +62 -0
- package/lib/components/Email/EmailSelector.js.map +1 -0
- package/lib/components/Email/EmailShell.d.ts.map +1 -1
- package/lib/components/Email/EmailShell.js +23 -31
- package/lib/components/Email/EmailShell.js.map +1 -1
- package/lib/components/Email/EmailSummaryItem.d.ts +10 -0
- package/lib/components/Email/EmailSummaryItem.d.ts.map +1 -0
- package/lib/components/Email/EmailSummaryItem.js +93 -0
- package/lib/components/Email/EmailSummaryItem.js.map +1 -0
- package/lib/components/Email/EmailSummaryList.d.ts +6 -0
- package/lib/components/Email/EmailSummaryList.d.ts.map +1 -0
- package/lib/components/Email/EmailSummaryList.js +115 -0
- package/lib/components/Email/EmailSummaryList.js.map +1 -0
- package/lib/components/Feed/Feed.context.d.ts +16 -6
- package/lib/components/Feed/Feed.context.d.ts.map +1 -1
- package/lib/components/Feed/Feed.context.js +1 -0
- package/lib/components/Feed/Feed.context.js.map +1 -1
- package/lib/components/Feed/Feed.d.ts +13 -17
- package/lib/components/Feed/Feed.d.ts.map +1 -1
- package/lib/components/Feed/Feed.js +20 -31
- package/lib/components/Feed/Feed.js.map +1 -1
- package/lib/components/Feed/FeedAttachments.d.ts.map +1 -1
- package/lib/components/Feed/FeedAttachments.js +7 -6
- package/lib/components/Feed/FeedAttachments.js.map +1 -1
- package/lib/components/Feed/FeedButton.d.ts.map +1 -1
- package/lib/components/Feed/FeedButton.js.map +1 -1
- package/lib/components/Feed/FeedContent.d.ts.map +1 -1
- package/lib/components/Feed/FeedContent.js +12 -6
- package/lib/components/Feed/FeedContent.js.map +1 -1
- package/lib/components/Feed/FeedModalList.d.ts +15 -0
- package/lib/components/Feed/FeedModalList.d.ts.map +1 -0
- package/lib/components/Feed/FeedModalList.js +49 -0
- package/lib/components/Feed/FeedModalList.js.map +1 -0
- package/lib/components/Feed/FeedNewPost.d.ts +2 -1
- package/lib/components/Feed/FeedNewPost.d.ts.map +1 -1
- package/lib/components/Feed/FeedNewPost.js +44 -44
- package/lib/components/Feed/FeedNewPost.js.map +1 -1
- package/lib/components/Feed/FeedNewPostTypeMenu.d.ts.map +1 -1
- package/lib/components/Feed/FeedNewPostTypeMenu.js +47 -79
- package/lib/components/Feed/FeedNewPostTypeMenu.js.map +1 -1
- package/lib/components/Feed/FeedPost.d.ts +34 -12
- package/lib/components/Feed/FeedPost.d.ts.map +1 -1
- package/lib/components/Feed/FeedPost.js +165 -101
- package/lib/components/Feed/FeedPost.js.map +1 -1
- package/lib/components/Feed/FeedReply.d.ts +31 -13
- package/lib/components/Feed/FeedReply.d.ts.map +1 -1
- package/lib/components/Feed/FeedReply.js +123 -39
- package/lib/components/Feed/FeedReply.js.map +1 -1
- package/lib/components/Feed/FeedReplyInput.d.ts +6 -6
- package/lib/components/Feed/FeedReplyInput.d.ts.map +1 -1
- package/lib/components/Feed/FeedReplyInput.js +43 -46
- package/lib/components/Feed/FeedReplyInput.js.map +1 -1
- package/lib/components/Feed/FeedRichText.d.ts.map +1 -1
- package/lib/components/Feed/FeedRichText.js +81 -19
- package/lib/components/Feed/FeedRichText.js.map +1 -1
- package/lib/components/HashtagButton/HashtagButton.d.ts +6 -4
- package/lib/components/HashtagButton/HashtagButton.d.ts.map +1 -1
- package/lib/components/HashtagButton/HashtagButton.js +23 -17
- package/lib/components/HashtagButton/HashtagButton.js.map +1 -1
- package/lib/components/MentionButton/MentionButton.d.ts +10 -4
- package/lib/components/MentionButton/MentionButton.d.ts.map +1 -1
- package/lib/components/MentionButton/MentionButton.js +34 -18
- package/lib/components/MentionButton/MentionButton.js.map +1 -1
- package/package.json +15 -16
|
@@ -1,34 +1,96 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useContext, forwardRef, useState, useRef } from 'react';
|
|
3
|
+
import { cap } from '@pega/cosmos-react-core';
|
|
2
4
|
import { RichTextEditor } from '@pega/cosmos-react-rte';
|
|
5
|
+
import { MentionButtonConfig } from '../MentionButton';
|
|
6
|
+
import { HashtagButtonConfig } from '../HashtagButton';
|
|
3
7
|
import { FeedContext } from './Feed.context';
|
|
4
8
|
const FeedRichText = forwardRef((props, ref) => {
|
|
5
9
|
const { onSubmit, height = { min: 'auto' }, ...restProps } = props;
|
|
6
|
-
const { onSearch, searchResults = [] } = useContext(FeedContext);
|
|
7
|
-
const [
|
|
10
|
+
const { searchTypes = [], onSearch, searchResults = [], showSearchResults, setShowSearchResults } = useContext(FeedContext);
|
|
11
|
+
const [triggerType, setTriggerType] = useState('mention');
|
|
12
|
+
const [showMentionType, setShowMentionType] = useState(false);
|
|
13
|
+
const searchType = useRef('');
|
|
8
14
|
const onDecoSearch = (event) => {
|
|
9
|
-
|
|
10
|
-
|
|
15
|
+
const trigger = event.trigger === '@' ? 'mention' : 'tag';
|
|
16
|
+
setTriggerType(trigger);
|
|
17
|
+
if (trigger === 'mention' && event.search === '') {
|
|
18
|
+
setShowMentionType(true);
|
|
19
|
+
}
|
|
20
|
+
else {
|
|
21
|
+
setShowMentionType(false);
|
|
22
|
+
onSearch?.({ type: trigger, search: event.search, mentionType: searchType.current });
|
|
23
|
+
}
|
|
11
24
|
};
|
|
12
25
|
const onKeyDown = (event) => {
|
|
26
|
+
setShowSearchResults?.(true);
|
|
13
27
|
if ((event.metaKey || event.ctrlKey) && event.key === 'Enter')
|
|
14
28
|
onSubmit();
|
|
15
29
|
};
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
30
|
+
const typesMenu = {
|
|
31
|
+
onItemActive: (id) => {
|
|
32
|
+
searchType.current = id;
|
|
33
|
+
},
|
|
34
|
+
onItemClick: (id) => {
|
|
35
|
+
searchType.current = id;
|
|
36
|
+
setShowMentionType(false);
|
|
37
|
+
onSearch?.({ type: 'mention', search: '', mentionType: id });
|
|
38
|
+
},
|
|
39
|
+
items: searchTypes.map(type => {
|
|
40
|
+
return { id: type, primary: cap(type) };
|
|
41
|
+
})
|
|
42
|
+
};
|
|
43
|
+
const searchMenu = searchResults.length && showSearchResults
|
|
44
|
+
? {
|
|
45
|
+
header: triggerType === 'mention' ? `Mention a ${searchType.current}` : '',
|
|
46
|
+
items: searchResults
|
|
47
|
+
}
|
|
48
|
+
: undefined;
|
|
49
|
+
const getSearchAttributes = (searchResult) => {
|
|
50
|
+
if (searchResult.groups) {
|
|
51
|
+
if (searchResult.groups.tag) {
|
|
52
|
+
const tag = searchResult.groups.tag;
|
|
53
|
+
return {
|
|
54
|
+
markdown: searchResult.groups.match,
|
|
55
|
+
component: HashtagButtonConfig.component,
|
|
56
|
+
props: { tag },
|
|
57
|
+
text: tag
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
const id = searchResult.groups.id;
|
|
61
|
+
const text = searchResult.groups.text;
|
|
62
|
+
const type = searchResult.groups.type;
|
|
63
|
+
return {
|
|
64
|
+
markdown: searchResult.groups.match,
|
|
65
|
+
component: MentionButtonConfig.component,
|
|
66
|
+
props: { id, text, type },
|
|
67
|
+
text
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
return (_jsx(RichTextEditor, { ...restProps, markdownOnly: true, onKeyDown: onKeyDown, ref: ref, height: height, searchTriggers: [
|
|
72
|
+
{ trigger: '@', regex: String.raw `(?:\S+(?:[^\n\S][^@#\s]\S*)*[^\n\S]?|)` },
|
|
73
|
+
{ trigger: '#', regex: String.raw `[^\s,]*` }
|
|
19
74
|
], getSearchItemReplacement: (id) => {
|
|
20
|
-
const item = searchResults
|
|
75
|
+
const item = searchResults?.find(({ id: itemId }) => itemId === id);
|
|
21
76
|
if (!item)
|
|
22
|
-
return
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
77
|
+
return undefined;
|
|
78
|
+
return {
|
|
79
|
+
markdown: triggerType === 'mention'
|
|
80
|
+
? `@${item.id}:${item.primary}:${searchType.current}:`
|
|
81
|
+
: `#${item.id}:`,
|
|
82
|
+
component: triggerType === 'mention'
|
|
83
|
+
? MentionButtonConfig.component
|
|
84
|
+
: HashtagButtonConfig.component,
|
|
85
|
+
props: triggerType === 'mention'
|
|
86
|
+
? { id: item.id, text: item.primary, type: searchType.current, tabIndex: -1 }
|
|
87
|
+
: { tag: item.primary, tabIndex: -1 },
|
|
88
|
+
text: item.primary
|
|
89
|
+
};
|
|
90
|
+
}, searchRenderers: [
|
|
91
|
+
{ regexPattern: MentionButtonConfig.regexPattern, getSearchAttributes },
|
|
92
|
+
{ regexPattern: HashtagButtonConfig.regexPattern, getSearchAttributes }
|
|
93
|
+
], onSearch: onDecoSearch, menu: showMentionType ? typesMenu : searchMenu }, void 0));
|
|
32
94
|
});
|
|
33
95
|
export default FeedRichText;
|
|
34
96
|
//# sourceMappingURL=FeedRichText.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FeedRichText.js","sourceRoot":"","sources":["../../../src/components/Feed/FeedRichText.tsx"],"names":[],"mappings":"AAAA,OAAO,
|
|
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,MAAM,yBAAyB,CAAC;AAC5D,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,EAAE,GAA6B,EAAE,EAAE;IAC1D,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,EAAE,GAAG,EAAE,MAAM,EAAE,EAAE,GAAG,SAAS,EAAE,GAAG,KAAK,CAAC;IACnE,MAAM,EACJ,WAAW,GAAG,EAAE,EAChB,QAAQ,EACR,aAAa,GAAG,EAAE,EAClB,iBAAiB,EACjB,oBAAoB,EACrB,GAAG,UAAU,CAAC,WAAW,CAAC,CAAC;IAC5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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,WAC9C,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,14 +1,16 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { FunctionComponent, ReactElement } from 'react';
|
|
2
2
|
import { ForwardProps } from '@pega/cosmos-react-core';
|
|
3
3
|
interface HashtagButtonProps {
|
|
4
|
-
/** Text for the
|
|
5
|
-
children: RegExpExecArray;
|
|
4
|
+
/** Text for the button, or a regex match containing all necessary props. */
|
|
5
|
+
children: RegExpExecArray | ReactElement;
|
|
6
|
+
/** The tag value. */
|
|
7
|
+
tag?: string;
|
|
6
8
|
}
|
|
7
9
|
declare const HashtagButton: FunctionComponent<HashtagButtonProps & ForwardProps>;
|
|
8
10
|
export declare const HashtagButtonConfig: {
|
|
9
11
|
type: string;
|
|
10
12
|
regexPattern: RegExp;
|
|
11
|
-
component:
|
|
13
|
+
component: FunctionComponent<HashtagButtonProps & ForwardProps>;
|
|
12
14
|
};
|
|
13
15
|
export default HashtagButton;
|
|
14
16
|
//# sourceMappingURL=HashtagButton.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HashtagButton.d.ts","sourceRoot":"","sources":["../../../src/components/HashtagButton/HashtagButton.tsx"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"HashtagButton.d.ts","sourceRoot":"","sources":["../../../src/components/HashtagButton/HashtagButton.tsx"],"names":[],"mappings":"AAAA,OAAO,EAEL,iBAAiB,EAGjB,YAAY,EAGb,MAAM,OAAO,CAAC;AAGf,OAAO,EAAO,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAI5D,UAAU,kBAAkB;IAC1B,4EAA4E;IAC5E,QAAQ,EAAE,eAAe,GAAG,YAAY,CAAC;IACzC,qBAAqB;IACrB,GAAG,CAAC,EAAE,MAAM,CAAC;CACd;AAMD,QAAA,MAAM,aAAa,EAAE,iBAAiB,CAAC,kBAAkB,GAAG,YAAY,CA8BvE,CAAC;AAEF,eAAO,MAAM,mBAAmB;;;;CAI/B,CAAC;AAEF,eAAe,aAAa,CAAC"}
|
|
@@ -1,24 +1,30 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef, isValidElement, useContext } from 'react';
|
|
3
|
+
import styled from 'styled-components';
|
|
3
4
|
import { Tag } from '@pega/cosmos-react-core';
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
})
|
|
9
|
-
const
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
5
|
+
import { FeedContext } from '../Feed/Feed.context';
|
|
6
|
+
const StyledTag = styled(Tag) `
|
|
7
|
+
cursor: pointer;
|
|
8
|
+
`;
|
|
9
|
+
const HashtagButton = forwardRef(({ children, tag: tagProp = '', ...restProps }, ref) => {
|
|
10
|
+
const { onTagClick } = useContext(FeedContext);
|
|
11
|
+
let leadingChar = '';
|
|
12
|
+
let trailingChar = '';
|
|
13
|
+
let tag = '';
|
|
14
|
+
if (!isValidElement(children)) {
|
|
15
|
+
if (!children.groups)
|
|
16
|
+
return _jsx("span", { children: children[0] }, void 0);
|
|
17
|
+
[leadingChar, trailingChar] = children[0].split(children.groups.match);
|
|
18
|
+
tag = children.groups.tag;
|
|
19
|
+
}
|
|
20
|
+
else {
|
|
21
|
+
tag = tagProp;
|
|
22
|
+
}
|
|
23
|
+
return (_jsxs(_Fragment, { children: [leadingChar && _jsx("span", { children: leadingChar }, void 0), _jsx(StyledTag, { ...restProps, ref: ref, onClick: () => onTagClick?.(tag), spellCheck: false, children: isValidElement(children) ? children : tag }, void 0), trailingChar && _jsx("span", { children: trailingChar }, void 0)] }, void 0));
|
|
18
24
|
});
|
|
19
25
|
export const HashtagButtonConfig = {
|
|
20
26
|
type: 'tag',
|
|
21
|
-
regexPattern: /(
|
|
27
|
+
regexPattern: /(?:^|)(?<match>#(?<tag>[^ :]+\w):)/g,
|
|
22
28
|
component: HashtagButton
|
|
23
29
|
};
|
|
24
30
|
export default HashtagButton;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HashtagButton.js","sourceRoot":"","sources":["../../../src/components/HashtagButton/HashtagButton.tsx"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"HashtagButton.js","sourceRoot":"","sources":["../../../src/components/HashtagButton/HashtagButton.tsx"],"names":[],"mappings":";AAAA,OAAO,EACL,UAAU,EAEV,cAAc,EAId,UAAU,EACX,MAAM,OAAO,CAAC;AACf,OAAO,MAAM,MAAM,mBAAmB,CAAC;AAEvC,OAAO,EAAE,GAAG,EAAgB,MAAM,yBAAyB,CAAC;AAE5D,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AASnD,MAAM,SAAS,GAAG,MAAM,CAAC,GAAG,CAAC,CAAA;;CAE5B,CAAC;AAEF,MAAM,aAAa,GAAyD,UAAU,CACpF,CACE,EAAE,QAAQ,EAAE,GAAG,EAAE,OAAO,GAAG,EAAE,EAAE,GAAG,SAAS,EAAuC,EAClF,GAA2B,EAC3B,EAAE;IACF,MAAM,EAAE,UAAU,EAAE,GAAG,UAAU,CAAC,WAAW,CAAC,CAAC;IAE/C,IAAI,WAAW,GAAG,EAAE,CAAC;IACrB,IAAI,YAAY,GAAG,EAAE,CAAC;IACtB,IAAI,GAAG,GAAG,EAAE,CAAC;IAEb,IAAI,CAAC,cAAc,CAAC,QAAQ,CAAC,EAAE;QAC7B,IAAI,CAAC,QAAQ,CAAC,MAAM;YAAE,OAAO,yBAAO,QAAQ,CAAC,CAAC,CAAC,WAAQ,CAAC;QAExD,CAAC,WAAW,EAAE,YAAY,CAAC,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,QAAQ,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QACvE,GAAG,GAAG,QAAQ,CAAC,MAAM,CAAC,GAAG,CAAC;KAC3B;SAAM;QACL,GAAG,GAAG,OAAO,CAAC;KACf;IAED,OAAO,CACL,8BACG,WAAW,IAAI,yBAAO,WAAW,WAAQ,EAC1C,KAAC,SAAS,OAAK,SAAS,EAAE,GAAG,EAAE,GAAG,EAAE,OAAO,EAAE,GAAG,EAAE,CAAC,UAAU,EAAE,CAAC,GAAG,CAAC,EAAE,UAAU,EAAE,KAAK,YACpF,cAAc,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,GAAG,WAChC,EACX,YAAY,IAAI,yBAAO,YAAY,WAAQ,YAC3C,CACJ,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,MAAM,CAAC,MAAM,mBAAmB,GAAG;IACjC,IAAI,EAAE,KAAK;IACX,YAAY,EAAE,qCAAqC;IACnD,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} from 'react';\nimport styled from 'styled-components';\n\nimport { Tag, ForwardProps } from '@pega/cosmos-react-core';\n\nimport { FeedContext } from '../Feed/Feed.context';\n\ninterface HashtagButtonProps {\n /** Text for the button, or a regex match containing all necessary props. */\n children: RegExpExecArray | ReactElement;\n /** The tag value. */\n tag?: string;\n}\n\nconst StyledTag = styled(Tag)`\n cursor: pointer;\n`;\n\nconst HashtagButton: FunctionComponent<HashtagButtonProps & ForwardProps> = forwardRef(\n (\n { children, tag: tagProp = '', ...restProps }: PropsWithoutRef<HashtagButtonProps>,\n ref: Ref<HTMLButtonElement>\n ) => {\n const { onTagClick } = useContext(FeedContext);\n\n let leadingChar = '';\n let trailingChar = '';\n let tag = '';\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 tag = children.groups.tag;\n } else {\n tag = tagProp;\n }\n\n return (\n <>\n {leadingChar && <span>{leadingChar}</span>}\n <StyledTag {...restProps} ref={ref} onClick={() => onTagClick?.(tag)} spellCheck={false}>\n {isValidElement(children) ? children : tag}\n </StyledTag>\n {trailingChar && <span>{trailingChar}</span>}\n </>\n );\n }\n);\n\nexport const HashtagButtonConfig = {\n type: 'tag',\n regexPattern: /(?:^|)(?<match>#(?<tag>[^ :]+\\w):)/g,\n component: HashtagButton\n};\n\nexport default HashtagButton;\n"]}
|
|
@@ -1,14 +1,20 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { FunctionComponent, ReactElement } from 'react';
|
|
2
2
|
import { ForwardProps } from '@pega/cosmos-react-core';
|
|
3
3
|
interface MentionButtonProps {
|
|
4
|
-
/** Text for the
|
|
5
|
-
children: RegExpExecArray;
|
|
4
|
+
/** Text for the button, or a regex match containing all necessary props. */
|
|
5
|
+
children: RegExpExecArray | ReactElement;
|
|
6
|
+
/** The id of the mention. */
|
|
7
|
+
id?: string;
|
|
8
|
+
/** The text of the mention button. */
|
|
9
|
+
text?: string;
|
|
10
|
+
/** Designates the type of the mention for proper handling on click. */
|
|
11
|
+
type?: string;
|
|
6
12
|
}
|
|
7
13
|
declare const MentionButton: FunctionComponent<MentionButtonProps & ForwardProps>;
|
|
8
14
|
export declare const MentionButtonConfig: {
|
|
9
15
|
type: string;
|
|
10
16
|
regexPattern: RegExp;
|
|
11
|
-
component:
|
|
17
|
+
component: FunctionComponent<MentionButtonProps & ForwardProps>;
|
|
12
18
|
};
|
|
13
19
|
export default MentionButton;
|
|
14
20
|
//# sourceMappingURL=MentionButton.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MentionButton.d.ts","sourceRoot":"","sources":["../../../src/components/MentionButton/MentionButton.tsx"],"names":[],"mappings":"AAAA,OAAO,
|
|
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,7 +1,7 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef, isValidElement, useContext, useRef, useState } from 'react';
|
|
2
3
|
import styled from 'styled-components';
|
|
3
4
|
import { Button, Popover, useConsolidatedRef, useOuterEvent } from '@pega/cosmos-react-core';
|
|
4
|
-
import { Glimpse } from '@pega/cosmos-react-work';
|
|
5
5
|
import { FeedContext } from '../Feed/Feed.context';
|
|
6
6
|
const StyledButton = styled(Button) `
|
|
7
7
|
&:enabled:focus,
|
|
@@ -10,32 +10,48 @@ const StyledButton = styled(Button) `
|
|
|
10
10
|
text-decoration: underline;
|
|
11
11
|
}
|
|
12
12
|
`;
|
|
13
|
-
const MentionButton = forwardRef(({ children, ...restProps }, ref) => {
|
|
14
|
-
const {
|
|
13
|
+
const MentionButton = forwardRef(({ children, id: idProp = '', text: textProp = '', type: typeProp = '', ...restProps }, ref) => {
|
|
14
|
+
const { onMentionClick } = useContext(FeedContext);
|
|
15
15
|
const [showPopover, setShowPopover] = useState(false);
|
|
16
|
+
const [mentionContent, setMentionContent] = useState();
|
|
16
17
|
const mentionRef = useConsolidatedRef(ref);
|
|
17
18
|
const popoverRef = useRef(null);
|
|
18
19
|
useOuterEvent(['click', 'focusin'], [mentionRef, popoverRef], () => {
|
|
19
20
|
setShowPopover(false);
|
|
20
21
|
});
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
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);
|
|
25
49
|
};
|
|
26
|
-
|
|
27
|
-
const id = children.groups.id;
|
|
28
|
-
const user = getMentionedUser(id) || { id, primary: id };
|
|
29
|
-
return (React.createElement(React.Fragment, null,
|
|
30
|
-
leadingChar && React.createElement("span", null, leadingChar),
|
|
31
|
-
React.createElement(StyledButton, { ...restProps, ref: mentionRef, variant: 'link', onClick: () => setShowPopover(true) }, user.primary),
|
|
32
|
-
trailingChar && React.createElement("span", null, trailingChar),
|
|
33
|
-
React.createElement(Popover, { ref: popoverRef, show: showPopover, target: mentionRef.current, placement: 'bottom-start', arrow: true, portal: true },
|
|
34
|
-
React.createElement(Glimpse, { ...user }))));
|
|
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));
|
|
35
51
|
});
|
|
36
52
|
export const MentionButtonConfig = {
|
|
37
53
|
type: 'mention',
|
|
38
|
-
regexPattern: /(
|
|
54
|
+
regexPattern: /(?:^|)(?<match>@(?<id>[^ :]+\w):(?<text>[^:]+\w):(?<type>[^:]+\w):)/g,
|
|
39
55
|
component: MentionButton
|
|
40
56
|
};
|
|
41
57
|
export default MentionButton;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MentionButton.js","sourceRoot":"","sources":["../../../src/components/MentionButton/MentionButton.tsx"],"names":[],"mappings":"AAAA,OAAO,
|
|
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,GA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,GAAG,MAAM,CAAC;QACZ,IAAI,GAAG,QAAQ,CAAC;QAChB,IAAI,GAAG,QAAQ,CAAC;KACjB;IAED,MAAM,WAAW,GAAG,GAAG,EAAE;QACvB,MAAM,IAAI,GAAG,cAAc,EAAE,CAAC;YAC5B,EAAE;YACF,IAAI;YACJ,IAAI;SACL,CAAC,CAAC;QACH,IAAI,IAAI;YAAE,cAAc,CAAC,IAAI,CAAC,CAAC;QAC/B,iBAAiB,CAAC,IAAI,CAAC,CAAC;IAC1B,CAAC,CAAC;IAEF,OAAO,CACL,8BACG,WAAW,IAAI,yBAAO,WAAW,WAAQ,EAC1C,KAAC,YAAY,OACP,SAAS,EACb,GAAG,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.
|
|
3
|
+
"version": "2.0.0-dev.20.0",
|
|
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.
|
|
24
|
-
"@pega/cosmos-react-rte": "2.0.0-dev.
|
|
25
|
-
"@pega/cosmos-react-work": "2.0.0-dev.
|
|
23
|
+
"@pega/cosmos-react-core": "2.0.0-dev.20.0",
|
|
24
|
+
"@pega/cosmos-react-rte": "2.0.0-dev.20.0",
|
|
25
|
+
"@pega/cosmos-react-work": "2.0.0-dev.20.0",
|
|
26
26
|
"polished": "^4.1.0",
|
|
27
|
-
"react": "^16.
|
|
28
|
-
"react-dom": "^16.
|
|
27
|
+
"react": "^16.14.0 || ^17.0.0",
|
|
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.
|
|
33
|
-
"@storybook/addon-actions": "^6.
|
|
34
|
-
"@storybook/addon-knobs": "^6.
|
|
35
|
-
"@storybook/addon-storysource": "^6.
|
|
36
|
-
"@storybook/addon-toolbars": "^6.
|
|
37
|
-
"@storybook/addons": "^6.
|
|
38
|
-
"@storybook/react": "^6.
|
|
39
|
-
"@storybook/theming": "^6.
|
|
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
|
-
"
|
|
42
|
-
"typescript": "~4.3.2"
|
|
41
|
+
"typescript": "~4.5.2"
|
|
43
42
|
}
|
|
44
43
|
}
|