stream-chat-react-native-core 9.4.0-beta.2 → 9.4.0-beta.4
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/commonjs/components/Attachment/Attachment.js +8 -4
- package/lib/commonjs/components/Attachment/Attachment.js.map +1 -1
- package/lib/commonjs/components/Attachment/Audio/AudioAttachment.js +2 -4
- package/lib/commonjs/components/Attachment/Audio/AudioAttachment.js.map +1 -1
- package/lib/commonjs/components/MessageInput/MessageComposer.js +8 -29
- package/lib/commonjs/components/MessageInput/MessageComposer.js.map +1 -1
- package/lib/commonjs/components/Poll/components/CreatePollHeader.js +5 -5
- package/lib/commonjs/components/Poll/components/CreatePollHeader.js.map +1 -1
- package/lib/commonjs/components/Poll/components/PollButtons.js +25 -56
- package/lib/commonjs/components/Poll/components/PollButtons.js.map +1 -1
- package/lib/commonjs/components/Poll/components/PollInputDialog.js +9 -11
- package/lib/commonjs/components/Poll/components/PollInputDialog.js.map +1 -1
- package/lib/commonjs/components/Poll/components/PollModal.js +50 -0
- package/lib/commonjs/components/Poll/components/PollModal.js.map +1 -0
- package/lib/commonjs/components/Poll/components/PollModalHeader.js +3 -3
- package/lib/commonjs/components/Poll/components/PollModalHeader.js.map +1 -1
- package/lib/commonjs/components/Poll/components/PollResults/PollResultItem.js +10 -24
- package/lib/commonjs/components/Poll/components/PollResults/PollResultItem.js.map +1 -1
- package/lib/commonjs/components/Poll/components/index.js +11 -0
- package/lib/commonjs/components/Poll/components/index.js.map +1 -1
- package/lib/commonjs/contexts/messageInputContext/hooks/useCreateMessageComposer.js +2 -2
- package/lib/commonjs/contexts/messageInputContext/hooks/useCreateMessageComposer.js.map +1 -1
- package/lib/commonjs/version.json +1 -1
- package/lib/module/components/Attachment/Attachment.js +8 -4
- package/lib/module/components/Attachment/Attachment.js.map +1 -1
- package/lib/module/components/Attachment/Audio/AudioAttachment.js +2 -4
- package/lib/module/components/Attachment/Audio/AudioAttachment.js.map +1 -1
- package/lib/module/components/MessageInput/MessageComposer.js +8 -29
- package/lib/module/components/MessageInput/MessageComposer.js.map +1 -1
- package/lib/module/components/Poll/components/CreatePollHeader.js +5 -5
- package/lib/module/components/Poll/components/CreatePollHeader.js.map +1 -1
- package/lib/module/components/Poll/components/PollButtons.js +25 -56
- package/lib/module/components/Poll/components/PollButtons.js.map +1 -1
- package/lib/module/components/Poll/components/PollInputDialog.js +9 -11
- package/lib/module/components/Poll/components/PollInputDialog.js.map +1 -1
- package/lib/module/components/Poll/components/PollModal.js +50 -0
- package/lib/module/components/Poll/components/PollModal.js.map +1 -0
- package/lib/module/components/Poll/components/PollModalHeader.js +3 -3
- package/lib/module/components/Poll/components/PollModalHeader.js.map +1 -1
- package/lib/module/components/Poll/components/PollResults/PollResultItem.js +10 -24
- package/lib/module/components/Poll/components/PollResults/PollResultItem.js.map +1 -1
- package/lib/module/components/Poll/components/index.js +11 -0
- package/lib/module/components/Poll/components/index.js.map +1 -1
- package/lib/module/contexts/messageInputContext/hooks/useCreateMessageComposer.js +2 -2
- package/lib/module/contexts/messageInputContext/hooks/useCreateMessageComposer.js.map +1 -1
- package/lib/module/version.json +1 -1
- package/lib/typescript/components/Attachment/Audio/AudioAttachment.d.ts +1 -0
- package/lib/typescript/components/Attachment/Audio/AudioAttachment.d.ts.map +1 -1
- package/lib/typescript/components/MessageInput/MessageComposer.d.ts.map +1 -1
- package/lib/typescript/components/Poll/components/CreatePollHeader.d.ts.map +1 -1
- package/lib/typescript/components/Poll/components/PollButtons.d.ts.map +1 -1
- package/lib/typescript/components/Poll/components/PollModal.d.ts +9 -0
- package/lib/typescript/components/Poll/components/PollModal.d.ts.map +1 -0
- package/lib/typescript/components/Poll/components/PollResults/PollResultItem.d.ts.map +1 -1
- package/lib/typescript/components/Poll/components/index.d.ts +1 -0
- package/lib/typescript/components/Poll/components/index.d.ts.map +1 -1
- package/lib/typescript/contexts/messageInputContext/hooks/useCreateMessageComposer.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/components/Attachment/Attachment.tsx +9 -5
- package/src/components/Attachment/Audio/AudioAttachment.tsx +3 -4
- package/src/components/MessageInput/MessageComposer.tsx +9 -30
- package/src/components/Poll/components/CreatePollHeader.tsx +12 -5
- package/src/components/Poll/components/PollButtons.tsx +14 -38
- package/src/components/Poll/components/PollInputDialog.tsx +12 -12
- package/src/components/Poll/components/PollModal.tsx +55 -0
- package/src/components/Poll/components/PollModalHeader.tsx +3 -3
- package/src/components/Poll/components/PollResults/PollResultItem.tsx +6 -18
- package/src/components/Poll/components/__tests__/CreatePollHeader.test.tsx +4 -36
- package/src/components/Poll/components/__tests__/PollModalHeader.test.tsx +8 -45
- package/src/components/Poll/components/index.ts +1 -0
- package/src/contexts/messageInputContext/hooks/useCreateMessageComposer.ts +10 -4
- package/src/version.json +1 -1
|
@@ -4,7 +4,7 @@ import { StyleSheet, Text, View } from 'react-native';
|
|
|
4
4
|
import { useTheme } from '../../../contexts/themeContext/ThemeContext';
|
|
5
5
|
import { useTranslationContext } from '../../../contexts/translationContext/TranslationContext';
|
|
6
6
|
import { Check, IconProps } from '../../../icons';
|
|
7
|
-
import {
|
|
7
|
+
import { Cross } from '../../../icons/xmark-1';
|
|
8
8
|
import { primitives } from '../../../theme';
|
|
9
9
|
import { Button } from '../../ui';
|
|
10
10
|
import { useCanCreatePoll } from '../hooks/useCanCreatePoll';
|
|
@@ -43,9 +43,16 @@ export const CreatePollHeader = ({
|
|
|
43
43
|
|
|
44
44
|
const renderSendPollIcon = useCallback(
|
|
45
45
|
(props: IconProps) => {
|
|
46
|
-
return
|
|
46
|
+
return (
|
|
47
|
+
<Check
|
|
48
|
+
{...props}
|
|
49
|
+
height={18}
|
|
50
|
+
stroke={canCreatePoll ? semantics.textOnAccent : semantics.textDisabled}
|
|
51
|
+
width={18}
|
|
52
|
+
/>
|
|
53
|
+
);
|
|
47
54
|
},
|
|
48
|
-
[semantics.textOnAccent],
|
|
55
|
+
[canCreatePoll, semantics.textOnAccent, semantics.textDisabled],
|
|
49
56
|
);
|
|
50
57
|
|
|
51
58
|
return (
|
|
@@ -54,9 +61,9 @@ export const CreatePollHeader = ({
|
|
|
54
61
|
accessibilityLabelKey='a11y/Close poll creation'
|
|
55
62
|
variant='secondary'
|
|
56
63
|
onPress={onBackPressHandler}
|
|
57
|
-
type='
|
|
64
|
+
type='outline'
|
|
58
65
|
size='md'
|
|
59
|
-
LeadingIcon={
|
|
66
|
+
LeadingIcon={Cross}
|
|
60
67
|
iconOnly
|
|
61
68
|
/>
|
|
62
69
|
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import React, { useCallback, useMemo } from 'react';
|
|
2
|
-
import {
|
|
3
|
-
import { GestureHandlerRootView } from 'react-native-gesture-handler';
|
|
2
|
+
import { StyleSheet, View } from 'react-native';
|
|
4
3
|
|
|
5
4
|
import { GenericPollButton, PollButtonProps } from './Button';
|
|
6
5
|
import { PollAnswersList } from './PollAnswersList';
|
|
7
6
|
import { PollInputDialog } from './PollInputDialog';
|
|
7
|
+
import { PollModal } from './PollModal';
|
|
8
8
|
import { PollModalHeader } from './PollModalHeader';
|
|
9
9
|
import { PollAllOptions } from './PollOption';
|
|
10
10
|
import { PollResults } from './PollResults';
|
|
@@ -12,7 +12,6 @@ import { PollResults } from './PollResults';
|
|
|
12
12
|
import { useChatContext, usePollContext, useTheme, useTranslationContext } from '../../../contexts';
|
|
13
13
|
import { primitives } from '../../../theme';
|
|
14
14
|
import { defaultPollOptionCount } from '../../../utils/constants';
|
|
15
|
-
import { SafeAreaViewWrapper } from '../../UIComponents/SafeAreaViewWrapper';
|
|
16
15
|
import {
|
|
17
16
|
useAddCommentOpen,
|
|
18
17
|
useAllCommentsOpen,
|
|
@@ -51,14 +50,10 @@ export const ViewResultsButton = (props: PollButtonProps) => {
|
|
|
51
50
|
type='outline'
|
|
52
51
|
/>
|
|
53
52
|
{showResults ? (
|
|
54
|
-
<
|
|
55
|
-
<
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
<PollResults message={message} poll={poll} />
|
|
59
|
-
</SafeAreaViewWrapper>
|
|
60
|
-
</GestureHandlerRootView>
|
|
61
|
-
</Modal>
|
|
53
|
+
<PollModal onRequestClose={closeViewResults} visible={showResults}>
|
|
54
|
+
<PollModalHeader onPress={closeViewResults} title={t('Poll Results')} />
|
|
55
|
+
<PollResults message={message} poll={poll} />
|
|
56
|
+
</PollModal>
|
|
62
57
|
) : null}
|
|
63
58
|
</>
|
|
64
59
|
);
|
|
@@ -81,8 +76,6 @@ export const ShowAllOptionsButton = (props: PollButtonProps) => {
|
|
|
81
76
|
openAllOptions();
|
|
82
77
|
}, [message, onPress, openAllOptions, poll]);
|
|
83
78
|
|
|
84
|
-
const styles = useStyles();
|
|
85
|
-
|
|
86
79
|
return (
|
|
87
80
|
<>
|
|
88
81
|
{options && options.length > defaultPollOptionCount ? (
|
|
@@ -92,14 +85,10 @@ export const ShowAllOptionsButton = (props: PollButtonProps) => {
|
|
|
92
85
|
/>
|
|
93
86
|
) : null}
|
|
94
87
|
{showAllOptions ? (
|
|
95
|
-
<
|
|
96
|
-
<
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
<PollAllOptions message={message} poll={poll} />
|
|
100
|
-
</SafeAreaViewWrapper>
|
|
101
|
-
</GestureHandlerRootView>
|
|
102
|
-
</Modal>
|
|
88
|
+
<PollModal onRequestClose={closeAllOptions} visible={showAllOptions}>
|
|
89
|
+
<PollModalHeader onPress={closeAllOptions} title={t('Poll Options')} />
|
|
90
|
+
<PollAllOptions message={message} poll={poll} />
|
|
91
|
+
</PollModal>
|
|
103
92
|
) : null}
|
|
104
93
|
</>
|
|
105
94
|
);
|
|
@@ -122,8 +111,6 @@ export const ShowAllCommentsButton = (props: PollButtonProps) => {
|
|
|
122
111
|
openAllComments();
|
|
123
112
|
}, [message, onPress, openAllComments, poll]);
|
|
124
113
|
|
|
125
|
-
const styles = useStyles();
|
|
126
|
-
|
|
127
114
|
return (
|
|
128
115
|
<>
|
|
129
116
|
{answersCount && answersCount > 0 ? (
|
|
@@ -133,14 +120,10 @@ export const ShowAllCommentsButton = (props: PollButtonProps) => {
|
|
|
133
120
|
/>
|
|
134
121
|
) : null}
|
|
135
122
|
{showAnswers ? (
|
|
136
|
-
<
|
|
137
|
-
<
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
<PollAnswersList message={message} poll={poll} />
|
|
141
|
-
</SafeAreaViewWrapper>
|
|
142
|
-
</GestureHandlerRootView>
|
|
143
|
-
</Modal>
|
|
123
|
+
<PollModal onRequestClose={closeAllComments} visible={showAnswers}>
|
|
124
|
+
<PollModalHeader onPress={closeAllComments} title={t('Poll Comments')} />
|
|
125
|
+
<PollAnswersList message={message} poll={poll} />
|
|
126
|
+
</PollModal>
|
|
144
127
|
) : null}
|
|
145
128
|
</>
|
|
146
129
|
);
|
|
@@ -254,9 +237,6 @@ const useStyles = () => {
|
|
|
254
237
|
return useMemo(() => {
|
|
255
238
|
return StyleSheet.create({
|
|
256
239
|
buttonsContainer: { gap: primitives.spacingXs },
|
|
257
|
-
modalRoot: {
|
|
258
|
-
flex: 1,
|
|
259
|
-
},
|
|
260
240
|
endVoteButton: {
|
|
261
241
|
borderColor: isPollCreatedByClient
|
|
262
242
|
? semantics.chatBorderOnChatOutgoing
|
|
@@ -267,10 +247,6 @@ const useStyles = () => {
|
|
|
267
247
|
? semantics.chatBorderOnChatOutgoing
|
|
268
248
|
: semantics.chatBorderOnChatIncoming,
|
|
269
249
|
},
|
|
270
|
-
safeArea: {
|
|
271
|
-
backgroundColor: semantics.backgroundCoreElevation1,
|
|
272
|
-
flex: 1,
|
|
273
|
-
},
|
|
274
250
|
});
|
|
275
251
|
}, [semantics, isPollCreatedByClient]);
|
|
276
252
|
};
|
|
@@ -72,19 +72,11 @@ export const PollInputDialog = ({
|
|
|
72
72
|
/>
|
|
73
73
|
</View>
|
|
74
74
|
<View style={[styles.buttonContainer, buttonContainer]}>
|
|
75
|
-
<Button
|
|
76
|
-
variant={'secondary'}
|
|
77
|
-
type={'ghost'}
|
|
78
|
-
label={t('Cancel')}
|
|
79
|
-
size='md'
|
|
80
|
-
onPress={closeDialog}
|
|
81
|
-
style={styles.button}
|
|
82
|
-
/>
|
|
83
75
|
<Button
|
|
84
76
|
variant={'primary'}
|
|
85
77
|
type={'solid'}
|
|
86
78
|
label={t('Send')}
|
|
87
|
-
size='
|
|
79
|
+
size='lg'
|
|
88
80
|
onPress={() => {
|
|
89
81
|
onSubmit(dialogInput);
|
|
90
82
|
closeDialog();
|
|
@@ -92,6 +84,14 @@ export const PollInputDialog = ({
|
|
|
92
84
|
style={styles.button}
|
|
93
85
|
disabled={!dialogInput}
|
|
94
86
|
/>
|
|
87
|
+
<Button
|
|
88
|
+
variant={'secondary'}
|
|
89
|
+
type={'outline'}
|
|
90
|
+
label={t('Cancel')}
|
|
91
|
+
size='lg'
|
|
92
|
+
onPress={closeDialog}
|
|
93
|
+
style={styles.button}
|
|
94
|
+
/>
|
|
95
95
|
</View>
|
|
96
96
|
</Animated.View>
|
|
97
97
|
</KeyboardAvoidingView>
|
|
@@ -112,8 +112,8 @@ const useStyles = () => {
|
|
|
112
112
|
return useMemo(
|
|
113
113
|
() =>
|
|
114
114
|
StyleSheet.create({
|
|
115
|
-
button: {
|
|
116
|
-
buttonContainer: {
|
|
115
|
+
button: { width: undefined, ...button },
|
|
116
|
+
buttonContainer: { gap: primitives.spacingXs },
|
|
117
117
|
container: {
|
|
118
118
|
backgroundColor: semantics.backgroundCoreElevation1,
|
|
119
119
|
borderRadius: primitives.radiusXl,
|
|
@@ -132,7 +132,7 @@ const useStyles = () => {
|
|
|
132
132
|
input: {
|
|
133
133
|
alignItems: 'center',
|
|
134
134
|
borderColor: semantics.borderUtilityActive,
|
|
135
|
-
borderRadius: primitives.
|
|
135
|
+
borderRadius: primitives.radiusLg,
|
|
136
136
|
borderWidth: 1,
|
|
137
137
|
fontSize: primitives.typographyFontSizeMd,
|
|
138
138
|
padding: primitives.spacingSm,
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import React, { PropsWithChildren, useMemo } from 'react';
|
|
2
|
+
import { Modal, ModalProps, StyleSheet } from 'react-native';
|
|
3
|
+
import { GestureHandlerRootView } from 'react-native-gesture-handler';
|
|
4
|
+
|
|
5
|
+
import { useTheme } from '../../../contexts';
|
|
6
|
+
import { SafeAreaViewWrapper } from '../../UIComponents/SafeAreaViewWrapper';
|
|
7
|
+
|
|
8
|
+
export type PollModalProps = PropsWithChildren<{
|
|
9
|
+
animationType?: ModalProps['animationType'];
|
|
10
|
+
onRequestClose?: () => void;
|
|
11
|
+
visible?: boolean;
|
|
12
|
+
}>;
|
|
13
|
+
|
|
14
|
+
export const PollModal = ({
|
|
15
|
+
animationType = 'slide',
|
|
16
|
+
children,
|
|
17
|
+
onRequestClose,
|
|
18
|
+
visible,
|
|
19
|
+
}: PollModalProps) => {
|
|
20
|
+
const styles = useStyles();
|
|
21
|
+
|
|
22
|
+
return (
|
|
23
|
+
<Modal
|
|
24
|
+
animationType={animationType}
|
|
25
|
+
navigationBarTranslucent
|
|
26
|
+
onRequestClose={onRequestClose}
|
|
27
|
+
presentationStyle='pageSheet'
|
|
28
|
+
statusBarTranslucent
|
|
29
|
+
visible={visible}
|
|
30
|
+
>
|
|
31
|
+
<GestureHandlerRootView style={styles.root}>
|
|
32
|
+
<SafeAreaViewWrapper style={styles.safeArea}>{children}</SafeAreaViewWrapper>
|
|
33
|
+
</GestureHandlerRootView>
|
|
34
|
+
</Modal>
|
|
35
|
+
);
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
const useStyles = () => {
|
|
39
|
+
const {
|
|
40
|
+
theme: { semantics },
|
|
41
|
+
} = useTheme();
|
|
42
|
+
return useMemo(
|
|
43
|
+
() =>
|
|
44
|
+
StyleSheet.create({
|
|
45
|
+
root: {
|
|
46
|
+
flex: 1,
|
|
47
|
+
},
|
|
48
|
+
safeArea: {
|
|
49
|
+
flex: 1,
|
|
50
|
+
backgroundColor: semantics.backgroundCoreElevation1,
|
|
51
|
+
},
|
|
52
|
+
}),
|
|
53
|
+
[semantics],
|
|
54
|
+
);
|
|
55
|
+
};
|
|
@@ -2,7 +2,7 @@ import React, { useMemo } from 'react';
|
|
|
2
2
|
import { StyleSheet, Text, View } from 'react-native';
|
|
3
3
|
|
|
4
4
|
import { useTheme } from '../../../contexts';
|
|
5
|
-
import {
|
|
5
|
+
import { Cross } from '../../../icons/xmark-1';
|
|
6
6
|
import { primitives } from '../../../theme';
|
|
7
7
|
import { Button } from '../../ui';
|
|
8
8
|
|
|
@@ -27,10 +27,10 @@ export const PollModalHeader = ({ onPress, title }: PollModalHeaderProps) => {
|
|
|
27
27
|
<Button
|
|
28
28
|
accessibilityLabelKey='a11y/Close poll'
|
|
29
29
|
variant='secondary'
|
|
30
|
-
type='
|
|
30
|
+
type='outline'
|
|
31
31
|
size='md'
|
|
32
32
|
iconOnly
|
|
33
|
-
LeadingIcon={
|
|
33
|
+
LeadingIcon={Cross}
|
|
34
34
|
onPress={onPress}
|
|
35
35
|
testID='poll-results-close-button'
|
|
36
36
|
/>
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import React, { useCallback, useMemo, useState } from 'react';
|
|
2
|
-
import {
|
|
3
|
-
import { GestureHandlerRootView } from 'react-native-gesture-handler';
|
|
2
|
+
import { StyleSheet, Text, View } from 'react-native';
|
|
4
3
|
|
|
5
4
|
import { LocalMessage, Poll, PollOption, PollVote as PollVoteClass } from 'stream-chat';
|
|
6
5
|
|
|
@@ -15,9 +14,9 @@ import {
|
|
|
15
14
|
} from '../../../../contexts';
|
|
16
15
|
|
|
17
16
|
import { primitives } from '../../../../theme';
|
|
18
|
-
import { SafeAreaViewWrapper } from '../../../UIComponents/SafeAreaViewWrapper';
|
|
19
17
|
import { usePollState } from '../../hooks/usePollState';
|
|
20
18
|
import { GenericPollButton } from '../Button';
|
|
19
|
+
import { PollModal } from '../PollModal';
|
|
21
20
|
import { PollModalHeader } from '../PollModalHeader';
|
|
22
21
|
|
|
23
22
|
export type ShowAllVotesButtonProps = {
|
|
@@ -62,18 +61,14 @@ export const ShowAllVotesButton = (props: ShowAllVotesButtonProps) => {
|
|
|
62
61
|
</View>
|
|
63
62
|
) : null}
|
|
64
63
|
{showAllVotes ? (
|
|
65
|
-
<
|
|
64
|
+
<PollModal
|
|
66
65
|
animationType='fade'
|
|
67
66
|
onRequestClose={() => setShowAllVotes(false)}
|
|
68
67
|
visible={showAllVotes}
|
|
69
68
|
>
|
|
70
|
-
<
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
<PollOptionFullResults message={message} option={option} poll={poll} />
|
|
74
|
-
</SafeAreaViewWrapper>
|
|
75
|
-
</GestureHandlerRootView>
|
|
76
|
-
</Modal>
|
|
69
|
+
<PollModalHeader onPress={() => setShowAllVotes(false)} title={t('Votes')} />
|
|
70
|
+
<PollOptionFullResults message={message} option={option} poll={poll} />
|
|
71
|
+
</PollModal>
|
|
77
72
|
) : null}
|
|
78
73
|
</>
|
|
79
74
|
);
|
|
@@ -156,9 +151,6 @@ const useStyles = () => {
|
|
|
156
151
|
alignItems: 'center',
|
|
157
152
|
paddingBottom: primitives.spacingXs,
|
|
158
153
|
},
|
|
159
|
-
modalRoot: {
|
|
160
|
-
flex: 1,
|
|
161
|
-
},
|
|
162
154
|
title: {
|
|
163
155
|
flex: 1,
|
|
164
156
|
fontSize: primitives.typographyFontSizeLg,
|
|
@@ -183,10 +175,6 @@ const useStyles = () => {
|
|
|
183
175
|
marginStart: primitives.spacingMd,
|
|
184
176
|
textAlign: 'left',
|
|
185
177
|
},
|
|
186
|
-
safeArea: {
|
|
187
|
-
backgroundColor: semantics.backgroundCoreElevation1,
|
|
188
|
-
flex: 1,
|
|
189
|
-
},
|
|
190
178
|
inlineButton: {
|
|
191
179
|
borderColor: semantics.borderCoreDefault,
|
|
192
180
|
borderTopWidth: 1,
|
|
@@ -43,39 +43,8 @@ const collectPathData = (node: unknown): string[] => {
|
|
|
43
43
|
return [...(typeof props?.d === 'string' ? [props.d] : []), ...collectPathData(children)];
|
|
44
44
|
};
|
|
45
45
|
|
|
46
|
-
const collectTransforms = (node: unknown): string[] => {
|
|
47
|
-
if (!node || typeof node !== 'object') {
|
|
48
|
-
return [];
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
if (Array.isArray(node)) {
|
|
52
|
-
return node.reduce<string[]>((acc, child) => [...acc, ...collectTransforms(child)], []);
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
const { children, props } = node as {
|
|
56
|
-
children?: unknown;
|
|
57
|
-
props?: { style?: StyleProp<ViewStyle> };
|
|
58
|
-
};
|
|
59
|
-
const style = StyleSheet.flatten(props?.style);
|
|
60
|
-
const styleTransforms = Array.isArray(style?.transform)
|
|
61
|
-
? style.transform.flatMap((transform) => {
|
|
62
|
-
if (
|
|
63
|
-
transform &&
|
|
64
|
-
typeof transform === 'object' &&
|
|
65
|
-
'rotate' in transform &&
|
|
66
|
-
typeof transform.rotate === 'string'
|
|
67
|
-
) {
|
|
68
|
-
return [transform.rotate];
|
|
69
|
-
}
|
|
70
|
-
return [];
|
|
71
|
-
})
|
|
72
|
-
: [];
|
|
73
|
-
|
|
74
|
-
return [...styleTransforms, ...collectTransforms(children)];
|
|
75
|
-
};
|
|
76
|
-
|
|
77
46
|
describe('CreatePollHeader', () => {
|
|
78
|
-
it('renders a secondary
|
|
47
|
+
it('renders a secondary outline cross close button', () => {
|
|
79
48
|
render(
|
|
80
49
|
<ThemeProvider>
|
|
81
50
|
<CreatePollHeader onBackPressHandler={jest.fn()} onCreatePollPressHandler={jest.fn()} />
|
|
@@ -84,11 +53,10 @@ describe('CreatePollHeader', () => {
|
|
|
84
53
|
|
|
85
54
|
const style = getCloseButtonWrapperStyle();
|
|
86
55
|
expect(style.backgroundColor).toBeUndefined();
|
|
87
|
-
expect(style.borderWidth).
|
|
88
|
-
expect(style.borderColor).
|
|
56
|
+
expect(style.borderWidth).toBe(1);
|
|
57
|
+
expect(style.borderColor).toBeDefined();
|
|
89
58
|
expect(collectPathData(screen.toJSON())).toContain(
|
|
90
|
-
'
|
|
59
|
+
'M15.625 4.375L4.375 15.625M15.625 15.625L4.375 4.375',
|
|
91
60
|
);
|
|
92
|
-
expect(collectTransforms(screen.toJSON())).toContain('-90deg');
|
|
93
61
|
});
|
|
94
62
|
});
|
|
@@ -47,41 +47,6 @@ const collectPathData = (node: unknown): string[] => {
|
|
|
47
47
|
return [...(typeof props?.d === 'string' ? [props.d] : []), ...collectPathData(children)];
|
|
48
48
|
};
|
|
49
49
|
|
|
50
|
-
const collectTransforms = (node: unknown): string[] => {
|
|
51
|
-
if (!node || typeof node !== 'object') {
|
|
52
|
-
return [];
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
if (Array.isArray(node)) {
|
|
56
|
-
return node.reduce<string[]>((acc, child) => [...acc, ...collectTransforms(child)], []);
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
const { children, props } = node as {
|
|
60
|
-
children?: unknown;
|
|
61
|
-
props?: { style?: StyleProp<ViewStyle>; transform?: unknown };
|
|
62
|
-
};
|
|
63
|
-
const style = StyleSheet.flatten(props?.style);
|
|
64
|
-
const styleTransforms = Array.isArray(style?.transform)
|
|
65
|
-
? style.transform.flatMap((transform) => {
|
|
66
|
-
if (
|
|
67
|
-
transform &&
|
|
68
|
-
typeof transform === 'object' &&
|
|
69
|
-
'rotate' in transform &&
|
|
70
|
-
typeof transform.rotate === 'string'
|
|
71
|
-
) {
|
|
72
|
-
return [transform.rotate];
|
|
73
|
-
}
|
|
74
|
-
return [];
|
|
75
|
-
})
|
|
76
|
-
: [];
|
|
77
|
-
|
|
78
|
-
return [
|
|
79
|
-
...(typeof props?.transform === 'string' ? [props.transform] : []),
|
|
80
|
-
...styleTransforms,
|
|
81
|
-
...collectTransforms(children),
|
|
82
|
-
];
|
|
83
|
-
};
|
|
84
|
-
|
|
85
50
|
const renderPollModalHeader = () =>
|
|
86
51
|
render(
|
|
87
52
|
<ThemeProvider>
|
|
@@ -94,33 +59,31 @@ describe('PollModalHeader', () => {
|
|
|
94
59
|
setPlatform(originalPlatform);
|
|
95
60
|
});
|
|
96
61
|
|
|
97
|
-
it('renders a secondary
|
|
62
|
+
it('renders a secondary outline cross button outside Android', () => {
|
|
98
63
|
setPlatform('ios');
|
|
99
64
|
|
|
100
65
|
renderPollModalHeader();
|
|
101
66
|
|
|
102
67
|
const style = getCloseButtonWrapperStyle();
|
|
103
68
|
expect(style.backgroundColor).toBeUndefined();
|
|
104
|
-
expect(style.borderWidth).
|
|
105
|
-
expect(style.borderColor).
|
|
69
|
+
expect(style.borderWidth).toBe(1);
|
|
70
|
+
expect(style.borderColor).toBeDefined();
|
|
106
71
|
expect(collectPathData(screen.toJSON())).toContain(
|
|
107
|
-
'
|
|
72
|
+
'M15.625 4.375L4.375 15.625M15.625 15.625L4.375 4.375',
|
|
108
73
|
);
|
|
109
|
-
expect(collectTransforms(screen.toJSON())).toContain('-90deg');
|
|
110
74
|
});
|
|
111
75
|
|
|
112
|
-
it('renders a secondary
|
|
76
|
+
it('renders a secondary outline cross button on Android', () => {
|
|
113
77
|
setPlatform('android');
|
|
114
78
|
|
|
115
79
|
renderPollModalHeader();
|
|
116
80
|
|
|
117
81
|
const style = getCloseButtonWrapperStyle();
|
|
118
82
|
expect(style.backgroundColor).toBeUndefined();
|
|
119
|
-
expect(style.borderWidth).
|
|
120
|
-
expect(style.borderColor).
|
|
83
|
+
expect(style.borderWidth).toBe(1);
|
|
84
|
+
expect(style.borderColor).toBeDefined();
|
|
121
85
|
expect(collectPathData(screen.toJSON())).toContain(
|
|
122
|
-
'
|
|
86
|
+
'M15.625 4.375L4.375 15.625M15.625 15.625L4.375 4.375',
|
|
123
87
|
);
|
|
124
|
-
expect(collectTransforms(screen.toJSON())).toContain('-90deg');
|
|
125
88
|
});
|
|
126
89
|
});
|
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
import { useEffect, useMemo } from 'react';
|
|
2
2
|
|
|
3
|
-
import {
|
|
3
|
+
import { MessageComposer } from 'stream-chat';
|
|
4
4
|
|
|
5
5
|
import { useChatContext } from '../../chatContext/ChatContext';
|
|
6
6
|
import { MessageComposerContextValue } from '../../messageComposerContext/MessageComposerContext';
|
|
7
7
|
|
|
8
|
-
const queueCache = new FixedSizeQueueCache<string, MessageComposer>(64);
|
|
9
|
-
|
|
10
8
|
export const useCreateMessageComposer = ({
|
|
11
9
|
editing: editedMessage,
|
|
12
10
|
thread: parentMessage,
|
|
@@ -14,6 +12,7 @@ export const useCreateMessageComposer = ({
|
|
|
14
12
|
channel,
|
|
15
13
|
}: Pick<MessageComposerContextValue, 'channel' | 'threadInstance' | 'thread' | 'editing'>) => {
|
|
16
14
|
const { client } = useChatContext();
|
|
15
|
+
const { messageComposerCache: queueCache } = client;
|
|
17
16
|
|
|
18
17
|
const cachedEditedMessage = useMemo(() => {
|
|
19
18
|
if (!editedMessage) return undefined;
|
|
@@ -69,7 +68,14 @@ export const useCreateMessageComposer = ({
|
|
|
69
68
|
} else {
|
|
70
69
|
return channel.messageComposer;
|
|
71
70
|
}
|
|
72
|
-
}, [
|
|
71
|
+
}, [
|
|
72
|
+
cachedEditedMessage,
|
|
73
|
+
cachedParentMessage,
|
|
74
|
+
channel.messageComposer,
|
|
75
|
+
client,
|
|
76
|
+
queueCache,
|
|
77
|
+
threadInstance,
|
|
78
|
+
]);
|
|
73
79
|
|
|
74
80
|
if (
|
|
75
81
|
(['legacy_thread', 'message'] as MessageComposer['contextType'][]).includes(
|
package/src/version.json
CHANGED