@planningcenter/chat-react-native 3.15.0-rc.1 → 3.15.0-rc.10

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 (160) hide show
  1. package/build/components/conversations/conversation_actions.js +1 -1
  2. package/build/components/conversations/conversation_actions.js.map +1 -1
  3. package/build/components/display/action_button.js +1 -3
  4. package/build/components/display/action_button.js.map +1 -1
  5. package/build/components/display/avatar.d.ts +3 -1
  6. package/build/components/display/avatar.d.ts.map +1 -1
  7. package/build/components/display/avatar.js +2 -2
  8. package/build/components/display/avatar.js.map +1 -1
  9. package/build/components/display/avatar_group.d.ts +3 -1
  10. package/build/components/display/avatar_group.d.ts.map +1 -1
  11. package/build/components/display/avatar_group.js +2 -2
  12. package/build/components/display/avatar_group.js.map +1 -1
  13. package/build/components/display/icon.d.ts +26 -13
  14. package/build/components/display/icon.d.ts.map +1 -1
  15. package/build/components/display/icon.js +0 -12
  16. package/build/components/display/icon.js.map +1 -1
  17. package/build/components/display/index.d.ts +1 -0
  18. package/build/components/display/index.d.ts.map +1 -1
  19. package/build/components/display/index.js +1 -0
  20. package/build/components/display/index.js.map +1 -1
  21. package/build/components/display/pressable_row.d.ts +14 -0
  22. package/build/components/display/pressable_row.d.ts.map +1 -0
  23. package/build/components/display/pressable_row.js +65 -0
  24. package/build/components/display/pressable_row.js.map +1 -0
  25. package/build/components/primitive/avatar_primitive.d.ts +2 -0
  26. package/build/components/primitive/avatar_primitive.d.ts.map +1 -1
  27. package/build/components/primitive/avatar_primitive.js +20 -19
  28. package/build/components/primitive/avatar_primitive.js.map +1 -1
  29. package/build/components/primitive/form_sheet.d.ts +3 -2
  30. package/build/components/primitive/form_sheet.d.ts.map +1 -1
  31. package/build/components/primitive/form_sheet.js +5 -3
  32. package/build/components/primitive/form_sheet.js.map +1 -1
  33. package/build/hooks/use_api.d.ts +1 -1
  34. package/build/hooks/use_api.d.ts.map +1 -1
  35. package/build/hooks/use_api.js.map +1 -1
  36. package/build/hooks/use_api_client.d.ts +1 -1
  37. package/build/hooks/use_api_client.d.ts.map +1 -1
  38. package/build/hooks/use_api_client.js +1 -1
  39. package/build/hooks/use_api_client.js.map +1 -1
  40. package/build/hooks/use_app_name.d.ts +3 -0
  41. package/build/hooks/use_app_name.d.ts.map +1 -0
  42. package/build/hooks/use_app_name.js +12 -0
  43. package/build/hooks/use_app_name.js.map +1 -0
  44. package/build/hooks/use_async_storage.d.ts +1 -1
  45. package/build/hooks/use_async_storage.d.ts.map +1 -1
  46. package/build/hooks/use_async_storage.js +6 -5
  47. package/build/hooks/use_async_storage.js.map +1 -1
  48. package/build/hooks/use_report_bug_action.d.ts +1 -1
  49. package/build/hooks/use_report_bug_action.d.ts.map +1 -1
  50. package/build/hooks/use_report_bug_action.js +1 -9
  51. package/build/hooks/use_report_bug_action.js.map +1 -1
  52. package/build/hooks/use_suspense_api.d.ts +1 -1
  53. package/build/hooks/use_suspense_api.d.ts.map +1 -1
  54. package/build/hooks/use_suspense_api.js.map +1 -1
  55. package/build/index.d.ts +2 -0
  56. package/build/index.d.ts.map +1 -1
  57. package/build/index.js +2 -0
  58. package/build/index.js.map +1 -1
  59. package/build/navigation/index.d.ts +20 -5
  60. package/build/navigation/index.d.ts.map +1 -1
  61. package/build/navigation/index.js +23 -15
  62. package/build/navigation/index.js.map +1 -1
  63. package/build/polyfills/events/CustomEvent.d.ts +21 -0
  64. package/build/polyfills/events/CustomEvent.d.ts.map +1 -0
  65. package/build/polyfills/events/CustomEvent.js +22 -0
  66. package/build/polyfills/events/CustomEvent.js.map +1 -0
  67. package/build/polyfills/events/Event.d.ts +49 -0
  68. package/build/polyfills/events/Event.d.ts.map +1 -0
  69. package/build/polyfills/events/Event.js +125 -0
  70. package/build/polyfills/events/Event.js.map +1 -0
  71. package/build/polyfills/events/EventHandlerAttributes.d.ts +8 -0
  72. package/build/polyfills/events/EventHandlerAttributes.d.ts.map +1 -0
  73. package/build/polyfills/events/EventHandlerAttributes.js +46 -0
  74. package/build/polyfills/events/EventHandlerAttributes.js.map +1 -0
  75. package/build/polyfills/events/EventTarget.d.ts +33 -0
  76. package/build/polyfills/events/EventTarget.d.ts.map +1 -0
  77. package/build/polyfills/events/EventTarget.js +238 -0
  78. package/build/polyfills/events/EventTarget.js.map +1 -0
  79. package/build/polyfills/events/internals/EventInternals.d.ts +30 -0
  80. package/build/polyfills/events/internals/EventInternals.d.ts.map +1 -0
  81. package/build/polyfills/events/internals/EventInternals.js +76 -0
  82. package/build/polyfills/events/internals/EventInternals.js.map +1 -0
  83. package/build/polyfills/events/internals/EventTargetInternals.d.ts +9 -0
  84. package/build/polyfills/events/internals/EventTargetInternals.d.ts.map +1 -0
  85. package/build/polyfills/events/internals/EventTargetInternals.js +11 -0
  86. package/build/polyfills/events/internals/EventTargetInternals.js.map +1 -0
  87. package/build/polyfills/webidl/PlatformObjects.d.ts +31 -0
  88. package/build/polyfills/webidl/PlatformObjects.d.ts.map +1 -0
  89. package/build/polyfills/webidl/PlatformObjects.js +39 -0
  90. package/build/polyfills/webidl/PlatformObjects.js.map +1 -0
  91. package/build/screens/bug_report_screen.d.ts.map +1 -1
  92. package/build/screens/bug_report_screen.js +62 -57
  93. package/build/screens/bug_report_screen.js.map +1 -1
  94. package/build/screens/conversation_filters/components/conversation_filters.js +9 -7
  95. package/build/screens/conversation_filters/components/conversation_filters.js.map +1 -1
  96. package/build/screens/conversation_filters/components/rows.d.ts.map +1 -1
  97. package/build/screens/conversation_filters/components/rows.js +50 -31
  98. package/build/screens/conversation_filters/components/rows.js.map +1 -1
  99. package/build/screens/conversations/conversations_screen.d.ts.map +1 -1
  100. package/build/screens/conversations/conversations_screen.js +6 -6
  101. package/build/screens/conversations/conversations_screen.js.map +1 -1
  102. package/build/screens/design_system_screen.js +1 -1
  103. package/build/screens/design_system_screen.js.map +1 -1
  104. package/build/screens/get_help_screen.d.ts +5 -0
  105. package/build/screens/get_help_screen.d.ts.map +1 -0
  106. package/build/screens/get_help_screen.js +94 -0
  107. package/build/screens/get_help_screen.js.map +1 -0
  108. package/build/screens/message_actions_screen.d.ts +1 -1
  109. package/build/screens/message_actions_screen.d.ts.map +1 -1
  110. package/build/screens/message_actions_screen.js +14 -11
  111. package/build/screens/message_actions_screen.js.map +1 -1
  112. package/build/utils/client/index.d.ts +1 -0
  113. package/build/utils/client/index.d.ts.map +1 -1
  114. package/build/utils/client/index.js +1 -0
  115. package/build/utils/client/index.js.map +1 -1
  116. package/build/utils/client/types.d.ts +61 -0
  117. package/build/utils/client/types.d.ts.map +1 -0
  118. package/build/utils/client/types.js +2 -0
  119. package/build/utils/client/types.js.map +1 -0
  120. package/build/utils/theme.d.ts +1 -0
  121. package/build/utils/theme.d.ts.map +1 -1
  122. package/build/utils/theme.js +2 -0
  123. package/build/utils/theme.js.map +1 -1
  124. package/package.json +5 -5
  125. package/src/__tests__/event-polyfill.test.ts +314 -0
  126. package/src/components/conversations/conversation_actions.tsx +1 -1
  127. package/src/components/display/action_button.tsx +1 -4
  128. package/src/components/display/avatar.tsx +5 -1
  129. package/src/components/display/avatar_group.tsx +5 -1
  130. package/src/components/display/icon.tsx +17 -14
  131. package/src/components/display/index.ts +1 -0
  132. package/src/components/display/pressable_row.tsx +103 -0
  133. package/src/components/primitive/avatar_primitive.tsx +35 -19
  134. package/src/components/primitive/form_sheet.tsx +33 -5
  135. package/src/hooks/use_api.ts +1 -1
  136. package/src/hooks/use_api_client.ts +2 -2
  137. package/src/hooks/use_app_name.ts +17 -0
  138. package/src/hooks/use_async_storage.ts +8 -5
  139. package/src/hooks/use_report_bug_action.ts +2 -10
  140. package/src/hooks/use_suspense_api.ts +1 -1
  141. package/src/index.tsx +2 -0
  142. package/src/navigation/index.tsx +38 -25
  143. package/src/polyfills/events/CustomEvent.ts +32 -0
  144. package/src/polyfills/events/Event.ts +186 -0
  145. package/src/polyfills/events/EventHandlerAttributes.ts +67 -0
  146. package/src/polyfills/events/EventTarget.ts +360 -0
  147. package/src/polyfills/events/README.md +1 -0
  148. package/src/polyfills/events/internals/EventInternals.ts +95 -0
  149. package/src/polyfills/events/internals/EventTargetInternals.ts +16 -0
  150. package/src/polyfills/webidl/PlatformObjects.ts +50 -0
  151. package/src/screens/bug_report_screen.tsx +79 -67
  152. package/src/screens/conversation_filters/components/conversation_filters.tsx +10 -7
  153. package/src/screens/conversation_filters/components/rows.tsx +63 -50
  154. package/src/screens/conversations/conversations_screen.tsx +7 -7
  155. package/src/screens/design_system_screen.tsx +1 -1
  156. package/src/screens/get_help_screen.tsx +131 -0
  157. package/src/screens/message_actions_screen.tsx +34 -12
  158. package/src/utils/client/index.ts +1 -0
  159. package/src/utils/theme.ts +3 -0
  160. /package/src/utils/client/{types.d.ts → types.ts} +0 -0
@@ -0,0 +1,131 @@
1
+ import { useNavigation } from '@react-navigation/native'
2
+ import { NativeStackScreenProps } from '@react-navigation/native-stack'
3
+ import { useCallback } from 'react'
4
+ import { Linking, StyleSheet, View } from 'react-native'
5
+ import { Heading, PressableRow, Text, TextInlineButton } from '../components'
6
+ import { useApiGet, useTheme } from '../hooks'
7
+ import { useAppName } from '../hooks/use_app_name'
8
+ import { ResourceObject } from '../types'
9
+
10
+ type GetHelpScreenProps = NativeStackScreenProps<{}>
11
+
12
+ interface OrganizationResource extends ResourceObject {
13
+ id: number
14
+ name: string
15
+ contactEmail: string
16
+ contactPhoneNumber: string
17
+ churchCenterChatHelpUrl: string
18
+ servicesChatHelpUrl: string
19
+ }
20
+
21
+ const useOrganization = () => {
22
+ const { data: organization } = useApiGet<OrganizationResource>({
23
+ url: '/',
24
+ data: {
25
+ fields: {
26
+ Organization: [
27
+ 'contact_phone_number',
28
+ 'contact_email',
29
+ 'name',
30
+ 'church_center_chat_help_url',
31
+ 'services_chat_help_url',
32
+ ],
33
+ },
34
+ },
35
+ })
36
+
37
+ return organization
38
+ }
39
+
40
+ export const GetHelpScreen = ({}: GetHelpScreenProps) => {
41
+ const styles = useStyles()
42
+ const appName = useAppName()
43
+ const isChurchCenter = appName === 'churchcenter'
44
+ const navigation = useNavigation()
45
+ const organization = useOrganization()
46
+ const contactPresent = organization?.contactEmail || organization?.contactPhoneNumber
47
+ const getHelpLink = isChurchCenter
48
+ ? organization?.churchCenterChatHelpUrl
49
+ : organization?.servicesChatHelpUrl
50
+
51
+ const handleNavigateToBugReport = useCallback(() => {
52
+ navigation.navigate('BugReport')
53
+ }, [navigation])
54
+
55
+ return (
56
+ <View style={[styles.container]}>
57
+ <Heading variant="h2" style={[styles.heading, styles.headingBottomBorder]}>
58
+ How-to articles
59
+ </Heading>
60
+ <PressableRow
61
+ onPress={() => Linking.openURL(getHelpLink || '')}
62
+ text="Get help with chat"
63
+ isActive={true}
64
+ iconPath="general.newWindow"
65
+ />
66
+ {contactPresent && (
67
+ <Heading variant="h2" style={[styles.heading, styles.headingBottomBorder]}>
68
+ Contact {organization?.name}
69
+ </Heading>
70
+ )}
71
+ <ContactRow email={organization?.contactEmail} />
72
+ <ContactRow phone={organization?.contactPhoneNumber} />
73
+ <Heading variant="h2" style={[styles.heading]}>
74
+ Report a bug
75
+ </Heading>
76
+ <View style={styles.text}>
77
+ <Text>
78
+ Having an issue?{' '}
79
+ <TextInlineButton onPress={handleNavigateToBugReport}>
80
+ Submit a bug report
81
+ </TextInlineButton>{' '}
82
+ to the development team.
83
+ </Text>
84
+ </View>
85
+ </View>
86
+ )
87
+ }
88
+
89
+ const ContactRow = ({ email, phone }: { email?: string; phone?: string }) => {
90
+ if (!email && !phone) return null
91
+
92
+ const contact = email || phone
93
+
94
+ return (
95
+ <PressableRow
96
+ onPress={() => {}}
97
+ text={contact || ''}
98
+ isActive={true}
99
+ iconPath={email ? 'services.email' : 'general.phone'}
100
+ />
101
+ )
102
+ }
103
+
104
+ const useStyles = () => {
105
+ const { colors } = useTheme()
106
+
107
+ return StyleSheet.create({
108
+ container: {
109
+ flex: 1,
110
+ },
111
+ text: {
112
+ paddingVertical: 4,
113
+ paddingHorizontal: 16,
114
+ },
115
+ heading: {
116
+ marginLeft: 16,
117
+ paddingTop: 24,
118
+ paddingBottom: 12,
119
+ },
120
+ headingBottomBorder: {
121
+ marginLeft: 16,
122
+ paddingLeft: 0,
123
+ borderBottomWidth: 1,
124
+ borderBottomColor: colors.borderColorDefaultBase,
125
+ },
126
+ headingAux: {
127
+ paddingTop: 24,
128
+ paddingHorizontal: 16,
129
+ },
130
+ })
131
+ }
@@ -13,6 +13,7 @@ import { useConversationMessages } from '../hooks/use_conversation_messages'
13
13
  import { useMessageReactionToggle } from '../hooks/use_message_reaction_toggle'
14
14
  import { ReactionCountResource } from '../types/resources/reaction'
15
15
  import { Clipboard, Haptic } from '../utils/native_adapters'
16
+ import { MessageResource } from '../types'
16
17
 
17
18
  export const MessageActionsScreenOptions = getFormSheetScreenOptions({
18
19
  sheetAllowedDetents: [0.5],
@@ -26,19 +27,40 @@ export type MessageActionsScreenProps = StaticScreenProps<{
26
27
  }>
27
28
 
28
29
  export function MessageActionsScreen({ route }: MessageActionsScreenProps) {
29
- const navigation = useNavigation()
30
30
  const { conversation_id, message_id, canDeleteNonAuthoredMessages } = route.params
31
31
 
32
- const apiClient = useApiClient()
33
- const styles = useStyles()
34
-
35
32
  const { messages, refetch } = useConversationMessages(
36
33
  { conversation_id },
37
34
  { refetchOnMount: false }
38
35
  )
39
36
  const message = messages.find(m => m.id === message_id)
40
37
 
41
- if (!message) fail('Message not found')
38
+ if (!message) return null
39
+
40
+ return (
41
+ <MessageActionsScreenContent
42
+ message={message}
43
+ conversation_id={conversation_id}
44
+ canDeleteNonAuthoredMessages={canDeleteNonAuthoredMessages || false}
45
+ refetchMessages={refetch}
46
+ />
47
+ )
48
+ }
49
+
50
+ function MessageActionsScreenContent({
51
+ message,
52
+ conversation_id,
53
+ canDeleteNonAuthoredMessages,
54
+ refetchMessages,
55
+ }: {
56
+ message: MessageResource
57
+ conversation_id: number
58
+ canDeleteNonAuthoredMessages: boolean
59
+ refetchMessages: () => void
60
+ }) {
61
+ const navigation = useNavigation()
62
+ const apiClient = useApiClient()
63
+ const styles = useStyles()
42
64
 
43
65
  const myReactions = message?.reactionCounts
44
66
  .filter(reaction => reaction.mine)
@@ -73,15 +95,15 @@ export function MessageActionsScreen({ route }: MessageActionsScreenProps) {
73
95
  })
74
96
 
75
97
  const deleteMessage = useCallback(() => {
76
- const url = `/me/conversations/${conversation_id}/messages/${message_id}/`
98
+ const url = `/me/conversations/${conversation_id}/messages/${message.id}/`
77
99
 
78
100
  return apiClient.chat.delete({ url })
79
- }, [apiClient, conversation_id, message_id])
101
+ }, [apiClient, conversation_id, message.id])
80
102
 
81
103
  const { mutate: handleDeleteMessage } = useMutation({
82
104
  mutationFn: deleteMessage,
83
105
  onSuccess: () => {
84
- refetch()
106
+ refetchMessages()
85
107
  Haptic.notificationSuccess()
86
108
  navigation.goBack()
87
109
  },
@@ -104,24 +126,24 @@ export function MessageActionsScreen({ route }: MessageActionsScreenProps) {
104
126
  {
105
127
  ...(targetRoute?.params || {}),
106
128
  conversation_id,
107
- editing_message_id: message_id,
129
+ editing_message_id: message.id,
108
130
  },
109
131
  isNil
110
132
  )
111
133
  navigation.dispatch(StackActions.popTo('Conversation', params))
112
- }, [navigation, conversation_id, message_id])
134
+ }, [navigation, conversation_id, message.id])
113
135
 
114
136
  const handleViewReadReceiptsPress = useCallback(() => {
115
137
  Haptic.impactLight()
116
138
  const params = omitBy(
117
139
  {
118
140
  conversation_id,
119
- message_id,
141
+ message_id: message.id,
120
142
  },
121
143
  isNil
122
144
  )
123
145
  navigation.dispatch(StackActions.popTo('MessageReadReceipts', params))
124
- }, [navigation, conversation_id, message_id])
146
+ }, [navigation, conversation_id, message.id])
125
147
 
126
148
  return (
127
149
  <FormSheet.Root style={styles.formSheetContent}>
@@ -1 +1,2 @@
1
1
  export * from './client'
2
+ export * from './types'
@@ -57,6 +57,7 @@ interface ChatColors {
57
57
  androidModalHeaderButtonTextColor: ColorValue | string | undefined
58
58
  iOSModalHeaderButtonTextColor: OpaqueColorValue | string | undefined
59
59
  androidSwitchThumbColor: string | undefined
60
+ conversationActionsBackground: string
60
61
  testColor: string
61
62
  statusSuccessIcon: string
62
63
  statusSuccessText: string
@@ -99,6 +100,7 @@ const colorsChatLight: ChatColors = {
99
100
  buttonEnd: undefined,
100
101
  interaction: tokens.fillColorInteractionDefault,
101
102
  androidSwitchThumbColor: undefined,
103
+ conversationActionsBackground: tokens.colorNeutral100White,
102
104
  testColor: 'hotpink',
103
105
  statusInfoIcon: tokens.iconColorStatusInfoPrimary,
104
106
  statusInfoText: tokens.textColorStatusInfo,
@@ -141,6 +143,7 @@ const colorsChatDark: ChatColors = {
141
143
  buttonEnd: undefined,
142
144
  interaction: tokens.fillColorInteractionDefaultDark,
143
145
  androidSwitchThumbColor: undefined,
146
+ conversationActionsBackground: tokens.colorNeutral7,
144
147
  testColor: 'pink',
145
148
  statusInfoIcon: tokens.iconColorStatusInfoPrimaryDark,
146
149
  statusInfoText: tokens.textColorStatusInfoDark,
File without changes