@planningcenter/chat-react-native 3.42.3-qa-staging.2 → 3.42.3-qa-staging.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.
Files changed (67) hide show
  1. package/build/components/conversation/messages_disabled_banners.d.ts +2 -3
  2. package/build/components/conversation/messages_disabled_banners.d.ts.map +1 -1
  3. package/build/components/conversation/messages_disabled_banners.js +2 -7
  4. package/build/components/conversation/messages_disabled_banners.js.map +1 -1
  5. package/build/components/display/adult_requirement_notice.js +1 -1
  6. package/build/components/display/adult_requirement_notice.js.map +1 -1
  7. package/build/components/display/platform_modal_header_buttons.d.ts +47 -7
  8. package/build/components/display/platform_modal_header_buttons.d.ts.map +1 -1
  9. package/build/components/display/platform_modal_header_buttons.js +119 -9
  10. package/build/components/display/platform_modal_header_buttons.js.map +1 -1
  11. package/build/hooks/use_conversation.d.ts.map +1 -1
  12. package/build/hooks/use_conversation.js +1 -0
  13. package/build/hooks/use_conversation.js.map +1 -1
  14. package/build/hooks/use_conversation_jolt_events.d.ts.map +1 -1
  15. package/build/hooks/use_conversation_jolt_events.js +10 -2
  16. package/build/hooks/use_conversation_jolt_events.js.map +1 -1
  17. package/build/navigation/index.d.ts +67 -170
  18. package/build/navigation/index.d.ts.map +1 -1
  19. package/build/navigation/index.js +59 -70
  20. package/build/navigation/index.js.map +1 -1
  21. package/build/screens/bug_report_screen.d.ts.map +1 -1
  22. package/build/screens/bug_report_screen.js +10 -13
  23. package/build/screens/bug_report_screen.js.map +1 -1
  24. package/build/screens/conversation_details_screen.d.ts.map +1 -1
  25. package/build/screens/conversation_details_screen.js +11 -12
  26. package/build/screens/conversation_details_screen.js.map +1 -1
  27. package/build/screens/conversation_filters_screen.js +2 -2
  28. package/build/screens/conversation_filters_screen.js.map +1 -1
  29. package/build/screens/conversation_screen.d.ts.map +1 -1
  30. package/build/screens/conversation_screen.js +10 -3
  31. package/build/screens/conversation_screen.js.map +1 -1
  32. package/build/screens/message_report_screen.d.ts.map +1 -1
  33. package/build/screens/message_report_screen.js +14 -18
  34. package/build/screens/message_report_screen.js.map +1 -1
  35. package/build/screens/notification_settings_screen.d.ts.map +1 -1
  36. package/build/screens/notification_settings_screen.js +0 -14
  37. package/build/screens/notification_settings_screen.js.map +1 -1
  38. package/build/types/jolt_events/conversation_events.d.ts +2 -2
  39. package/build/types/jolt_events/conversation_events.d.ts.map +1 -1
  40. package/build/types/jolt_events/conversation_events.js.map +1 -1
  41. package/build/types/resources/conversation.d.ts +2 -2
  42. package/build/types/resources/conversation.d.ts.map +1 -1
  43. package/build/types/resources/conversation.js.map +1 -1
  44. package/build/utils/conversation_safety_constants.d.ts +1 -1
  45. package/build/utils/conversation_safety_constants.d.ts.map +1 -1
  46. package/build/utils/conversation_safety_constants.js +1 -1
  47. package/build/utils/conversation_safety_constants.js.map +1 -1
  48. package/build/utils/request/conversation.d.ts.map +1 -1
  49. package/build/utils/request/conversation.js +1 -0
  50. package/build/utils/request/conversation.js.map +1 -1
  51. package/package.json +3 -3
  52. package/src/components/conversation/messages_disabled_banners.tsx +3 -11
  53. package/src/components/display/adult_requirement_notice.tsx +1 -1
  54. package/src/components/display/platform_modal_header_buttons.tsx +254 -13
  55. package/src/hooks/use_conversation.ts +1 -0
  56. package/src/hooks/use_conversation_jolt_events.ts +16 -3
  57. package/src/navigation/index.tsx +147 -164
  58. package/src/screens/bug_report_screen.tsx +16 -15
  59. package/src/screens/conversation_details_screen.tsx +11 -17
  60. package/src/screens/conversation_filters_screen.tsx +2 -2
  61. package/src/screens/conversation_screen.tsx +11 -3
  62. package/src/screens/message_report_screen.tsx +20 -21
  63. package/src/screens/notification_settings_screen.tsx +1 -21
  64. package/src/types/jolt_events/conversation_events.ts +2 -2
  65. package/src/types/resources/conversation.ts +2 -3
  66. package/src/utils/conversation_safety_constants.ts +1 -1
  67. package/src/utils/request/conversation.ts +1 -0
@@ -1,9 +1,19 @@
1
- import { HeaderButton } from '@react-navigation/elements'
2
- import type { NativeStackHeaderRightProps } from '@react-navigation/native-stack'
1
+ import { HeaderBackButton, HeaderButton, PlatformPressable } from '@react-navigation/elements'
2
+ import { useNavigation } from '@react-navigation/native'
3
+ import type {
4
+ NativeStackHeaderItemProps,
5
+ NativeStackNavigationOptions,
6
+ } from '@react-navigation/native-stack'
7
+ import { useLayoutEffect } from 'react'
3
8
  import { ColorValue, Platform, StyleSheet } from 'react-native'
4
- import { useTheme } from '../../hooks'
5
- import { Icon } from './icon'
9
+ import LinearGradient from 'react-native-linear-gradient'
10
+ import { useFontScale, useTheme } from '../../hooks'
11
+ import { MAX_FONT_SIZE_MULTIPLIER_LANDMARK } from '../../utils'
12
+ import { isLiquidGlassEnabled } from '../../utils/liquid_glass'
13
+ import { tokens } from '../../vendor/tapestry/tokens'
14
+ import { Icon, type IconString } from './icon'
6
15
  import { TextButton } from './text_button'
16
+ import { getColorKey, useGradientColorMap } from './utils/button_colors'
7
17
 
8
18
  interface HeaderTextButtonProps {
9
19
  onPress: () => void
@@ -63,19 +73,250 @@ export const HeaderDismissButton = ({
63
73
  })
64
74
  }
65
75
 
66
- interface HeaderDoneButtonProps extends NativeStackHeaderRightProps {
67
- navigation: { goBack: () => void; getState: () => any }
76
+ const createTextHeaderRight =
77
+ ({ onPress, title, disabled }: HeaderTextButtonProps) =>
78
+ (props: NativeStackHeaderItemProps) => (
79
+ <HeaderTextButton {...props} onPress={onPress} title={title} disabled={disabled} />
80
+ )
81
+
82
+ export type OptionsDecorator = (
83
+ options: NativeStackNavigationOptions
84
+ ) => NativeStackNavigationOptions
85
+
86
+ export const composeOptions = (
87
+ base: NativeStackNavigationOptions,
88
+ ...decorators: OptionsDecorator[]
89
+ ): NativeStackNavigationOptions => decorators.reduce((options, decorate) => decorate(options), base)
90
+
91
+ interface TextButtonDecoratorProps {
92
+ text: string
93
+ onPress: () => void
94
+ disabled?: boolean
95
+ }
96
+
97
+ // Native bar items pick up liquid glass on iOS 26; hosts on an older
98
+ // react-navigation ignore the unstable option and keep using the
99
+ // headerRight/headerLeft fallbacks, as does Android.
100
+ export const withRightText =
101
+ ({ text, onPress, disabled }: TextButtonDecoratorProps): OptionsDecorator =>
102
+ options => ({
103
+ ...options,
104
+ headerRight: createTextHeaderRight({ onPress, title: text, disabled }),
105
+ unstable_headerRightItems: () => [{ type: 'button' as const, label: text, onPress, disabled }],
106
+ })
107
+
108
+ const HEADER_ICON_SIZE = 17
109
+ const HEADER_FILL_ICON_SIZE = 16
110
+ const HEADER_FILL_PADDING = 14
111
+ const HEADER_BAR_INSET = 16
112
+ const HEADER_SLOT_GAP = 12
113
+
114
+ const headerFillSize = (fontScale: number) => {
115
+ const icon = HEADER_FILL_ICON_SIZE * fontScale
116
+
117
+ return { icon, circle: icon + HEADER_FILL_PADDING * 2 }
118
+ }
119
+
120
+ // Liquid glass icons don't communicate
121
+ export const useHeaderSlotReserve = (): number => {
122
+ const fontScale = useFontScale({ maxFontSizeMultiplier: MAX_FONT_SIZE_MULTIPLIER_LANDMARK })
123
+
124
+ return HEADER_BAR_INSET + headerFillSize(fontScale).circle + HEADER_SLOT_GAP
125
+ }
126
+
127
+ const HEADER_FALLBACK_HIT_SLOP = 14
128
+
129
+ const iconStyles = StyleSheet.create({
130
+ disabled: {
131
+ opacity: 0.4,
132
+ },
133
+ fallbackButton: {
134
+ alignItems: 'center',
135
+ justifyContent: 'center',
136
+ paddingHorizontal: 8,
137
+ },
138
+ fillCircle: {
139
+ alignItems: 'center',
140
+ justifyContent: 'center',
141
+ },
142
+ })
143
+
144
+ export interface HeaderIconProps {
145
+ icon: IconString
146
+ accessibilityLabel: string
147
+ onPress: () => void
148
+ disabled?: boolean
149
+ variant?: 'plain' | 'fill'
150
+ }
151
+
152
+ const HeaderIcon = ({
153
+ icon,
154
+ disabled,
155
+ variant,
156
+ }: Pick<HeaderIconProps, 'icon' | 'disabled' | 'variant'>) => {
157
+ const { colors } = useTheme()
158
+ const gradients = useGradientColorMap()
159
+ const fontScale = useFontScale({ maxFontSizeMultiplier: MAX_FONT_SIZE_MULTIPLIER_LANDMARK })
160
+
161
+ if (variant !== 'fill') return <Icon name={icon} size={HEADER_ICON_SIZE} />
162
+
163
+ const { icon: iconSize, circle: circleSize } = headerFillSize(fontScale)
164
+
165
+ return (
166
+ <LinearGradient
167
+ start={{ x: 0.1, y: 0.1 }}
168
+ end={{ x: 0.9, y: 0.9 }}
169
+ colors={gradients[getColorKey({ disabled: Boolean(disabled), appearance: 'interaction' })]}
170
+ style={[
171
+ iconStyles.fillCircle,
172
+ { borderRadius: circleSize, height: circleSize, width: circleSize },
173
+ ]}
174
+ >
175
+ <Icon
176
+ name={icon}
177
+ size={iconSize}
178
+ color={disabled ? colors.iconColorDefaultDisabled : tokens.colorNeutral100White}
179
+ />
180
+ </LinearGradient>
181
+ )
68
182
  }
69
183
 
70
- export const HeaderDoneButton = ({ navigation, ...props }: HeaderDoneButtonProps) => {
71
- const state = navigation.getState()
72
- const isFirstScreen = state.index === 0
184
+ // Native bar items take SF Symbols, images, or any element, so both paths
185
+ // render the same icon: iOS 26 puts this one in the glass circle, and the
186
+ // element below covers Android and older iOS.
187
+ const createHeaderIconItem = ({
188
+ icon,
189
+ accessibilityLabel,
190
+ onPress,
191
+ disabled,
192
+ variant,
193
+ }: HeaderIconProps) => ({
194
+ type: 'custom' as const,
195
+ // The gradient circle replaces the glass one rather than sitting on it.
196
+ hidesSharedBackground: variant === 'fill',
197
+ element: (
198
+ <PlatformPressable
199
+ onPress={onPress}
200
+ disabled={disabled}
201
+ hitSlop={12}
202
+ accessibilityRole="button"
203
+ accessibilityLabel={accessibilityLabel}
204
+ style={disabled && variant !== 'fill' && iconStyles.disabled}
205
+ >
206
+ <HeaderIcon icon={icon} disabled={disabled} variant={variant} />
207
+ </PlatformPressable>
208
+ ),
209
+ })
210
+
211
+ const createHeaderIconElement =
212
+ ({ icon, accessibilityLabel, onPress, disabled, variant }: HeaderIconProps) =>
213
+ () => (
214
+ <PlatformPressable
215
+ onPress={onPress}
216
+ disabled={disabled}
217
+ hitSlop={HEADER_FALLBACK_HIT_SLOP}
218
+ accessibilityRole="button"
219
+ accessibilityLabel={accessibilityLabel}
220
+ style={[iconStyles.fallbackButton, disabled && variant !== 'fill' && iconStyles.disabled]}
221
+ >
222
+ <HeaderIcon icon={icon} disabled={disabled} variant={variant} />
223
+ </PlatformPressable>
224
+ )
225
+
226
+ export const withRightIcon =
227
+ (props: HeaderIconProps): OptionsDecorator =>
228
+ options => ({
229
+ ...options,
230
+ headerRight: createHeaderIconElement(props),
231
+ unstable_headerRightItems: () => [createHeaderIconItem(props)],
232
+ })
233
+
234
+ export const withLeftIcon =
235
+ (props: HeaderIconProps): OptionsDecorator =>
236
+ options => ({
237
+ ...options,
238
+ headerLeft: createHeaderIconElement(props),
239
+ unstable_headerLeftItems: () => [createHeaderIconItem(props)],
240
+ })
241
+
242
+ export const withRightClose = ({ onPress }: { onPress: () => void }) =>
243
+ withRightIcon({ icon: 'general.x', accessibilityLabel: 'Close', onPress })
244
+
245
+ export const withLeftClose = ({ onPress }: { onPress: () => void }) =>
246
+ withLeftIcon({ icon: 'general.x', accessibilityLabel: 'Close', onPress })
247
+
248
+ export const withRightDone = ({ onPress }: { onPress: () => void }) =>
249
+ withRightIcon({ icon: 'general.check', accessibilityLabel: 'Done', onPress })
250
+
251
+ // The default back icon reserves trailing space for a label that
252
+ // displayMode="minimal" never shows; a custom image skips it so the glass
253
+ // capsule hugs the glyph.
254
+ const renderGlassBackImage = ({ tintColor }: { tintColor: string }) => (
255
+ <Icon name="general.leftChevron" size={18} color={tintColor} />
256
+ )
257
+
258
+ // The iOS 26 glass capsule manages its own insets — negative margins clip
259
+ // the button against the capsule edge.
260
+ export const createMinimalHeaderBackButton =
261
+ ({ onPress }: { onPress: () => void }) =>
262
+ (props: NativeStackHeaderItemProps) => (
263
+ <HeaderBackButton
264
+ style={
265
+ isLiquidGlassEnabled()
266
+ ? undefined
267
+ : {
268
+ marginLeft: Platform.select({ ios: -8, default: -3 }),
269
+ marginRight: Platform.select({ ios: 0, default: 30 }),
270
+ }
271
+ }
272
+ backImage={isLiquidGlassEnabled() ? renderGlassBackImage : undefined}
273
+ displayMode="minimal"
274
+ onPress={onPress}
275
+ {...props}
276
+ />
277
+ )
278
+
279
+ // Under glass the native minimal back button suffices; pre-26 needs the
280
+ // custom button and its layout nudges.
281
+ export const withMinimalBack =
282
+ ({ onPress }: { onPress: () => void }): OptionsDecorator =>
283
+ options => ({
284
+ ...options,
285
+ ...(isLiquidGlassEnabled() ? {} : { headerLeft: createMinimalHeaderBackButton({ onPress }) }),
286
+ })
287
+
288
+ // An icon or a title, never both — passing both is a compile error rather
289
+ // than a question of which one wins.
290
+ type UseHeaderRightOptions = {
291
+ onPress: () => void
292
+ disabled?: boolean
293
+ enabled?: boolean
294
+ } & (
295
+ | (HeaderIconProps & { title?: never })
296
+ | { title: string; icon?: never; accessibilityLabel?: never; variant?: never }
297
+ )
298
+
299
+ // For screens whose header button depends on live state (form validity,
300
+ // mutation callbacks). Static buttons belong in the navigator options.
301
+ export const useHeaderRight = (options: UseHeaderRightOptions) => {
302
+ const navigation = useNavigation()
303
+ const { onPress, disabled, enabled = true } = options
304
+ const icon = options.icon
305
+ const label = options.icon !== undefined ? options.accessibilityLabel : options.title
306
+ const variant = options.variant
307
+
308
+ useLayoutEffect(() => {
309
+ if (!enabled) {
310
+ navigation.setOptions({ headerRight: () => null, unstable_headerRightItems: undefined })
311
+ return
312
+ }
73
313
 
74
- if (!isFirstScreen) {
75
- return null
76
- }
314
+ const decorate = icon
315
+ ? withRightIcon({ icon, accessibilityLabel: label, onPress, disabled, variant })
316
+ : withRightText({ text: label, onPress, disabled })
77
317
 
78
- return <HeaderTextButton {...props} onPress={navigation.goBack} title="Done" />
318
+ navigation.setOptions(decorate({}))
319
+ }, [disabled, enabled, icon, label, navigation, onPress, variant])
79
320
  }
80
321
 
81
322
  const useStyles = () => {
@@ -32,6 +32,7 @@ export const getConversationRequestArgs = ({ conversation_id }: { conversation_i
32
32
  'direct_message',
33
33
  'disabled',
34
34
  'disabled_reason',
35
+ 'disabled_message',
35
36
  'member_ability',
36
37
  'muted',
37
38
  'replies_disabled',
@@ -26,8 +26,13 @@ export function useConversationJoltEvents({ conversationId }: Props) {
26
26
 
27
27
  const handleUpdatedConversation = useCallback(
28
28
  (e: JoltConversationEvent) => {
29
- const { last_message_idempotent_key, last_message_author_id, disabled, disabled_reason } =
30
- e.data.data
29
+ const {
30
+ last_message_idempotent_key,
31
+ last_message_author_id,
32
+ disabled,
33
+ disabled_reason,
34
+ disabled_message,
35
+ } = e.data.data
31
36
 
32
37
  if (last_message_idempotent_key && last_message_author_id === currentPersonId) {
33
38
  completeMessageCreationConversationTracking({
@@ -38,7 +43,15 @@ export function useConversationJoltEvents({ conversationId }: Props) {
38
43
 
39
44
  queryClient.setQueryData<ApiResource<ConversationResource>>(queryKey, prev => {
40
45
  if (!prev?.data) return prev
41
- return { ...prev, data: { ...prev.data, disabled, disabledReason: disabled_reason } }
46
+ return {
47
+ ...prev,
48
+ data: {
49
+ ...prev.data,
50
+ disabled,
51
+ disabledReason: disabled_reason,
52
+ disabledMessage: disabled_message,
53
+ },
54
+ }
42
55
  })
43
56
 
44
57
  queryClient.invalidateQueries({ queryKey })