@planningcenter/chat-react-native 3.23.0 → 3.23.1-qa-538.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.
Files changed (122) hide show
  1. package/build/components/display/toggle_button.d.ts +11 -4
  2. package/build/components/display/toggle_button.d.ts.map +1 -1
  3. package/build/components/display/toggle_button.js +6 -5
  4. package/build/components/display/toggle_button.js.map +1 -1
  5. package/build/components/primitive/form_sheet.d.ts +1 -1
  6. package/build/components/primitive/form_sheet.d.ts.map +1 -1
  7. package/build/components/primitive/form_sheet.js +1 -1
  8. package/build/components/primitive/form_sheet.js.map +1 -1
  9. package/build/hooks/index.d.ts +1 -0
  10. package/build/hooks/index.d.ts.map +1 -1
  11. package/build/hooks/index.js +1 -0
  12. package/build/hooks/index.js.map +1 -1
  13. package/build/hooks/use_conversation.d.ts.map +1 -1
  14. package/build/hooks/use_conversation.js +6 -1
  15. package/build/hooks/use_conversation.js.map +1 -1
  16. package/build/hooks/use_conversation_membership.d.ts +5 -0
  17. package/build/hooks/use_conversation_membership.d.ts.map +1 -0
  18. package/build/hooks/use_conversation_membership.js +54 -0
  19. package/build/hooks/use_conversation_membership.js.map +1 -0
  20. package/build/hooks/use_features.d.ts +1 -0
  21. package/build/hooks/use_features.d.ts.map +1 -1
  22. package/build/hooks/use_features.js +1 -0
  23. package/build/hooks/use_features.js.map +1 -1
  24. package/build/hooks/use_new_conversation_entry.d.ts +3 -0
  25. package/build/hooks/use_new_conversation_entry.d.ts.map +1 -0
  26. package/build/hooks/use_new_conversation_entry.js +20 -0
  27. package/build/hooks/use_new_conversation_entry.js.map +1 -0
  28. package/build/hooks/use_report_message.d.ts +6 -0
  29. package/build/hooks/use_report_message.d.ts.map +1 -0
  30. package/build/hooks/use_report_message.js +28 -0
  31. package/build/hooks/use_report_message.js.map +1 -0
  32. package/build/navigation/index.d.ts +18 -8
  33. package/build/navigation/index.d.ts.map +1 -1
  34. package/build/navigation/index.js +16 -6
  35. package/build/navigation/index.js.map +1 -1
  36. package/build/screens/conversation_details_screen.d.ts.map +1 -1
  37. package/build/screens/conversation_details_screen.js +18 -10
  38. package/build/screens/conversation_details_screen.js.map +1 -1
  39. package/build/screens/conversation_filter_recipients/conversation_filter_recipients_screen.js +5 -3
  40. package/build/screens/conversation_filter_recipients/conversation_filter_recipients_screen.js.map +1 -1
  41. package/build/screens/conversation_select_recipients/conversation_new_entry_screen.d.ts +4 -0
  42. package/build/screens/conversation_select_recipients/conversation_new_entry_screen.d.ts.map +1 -0
  43. package/build/screens/conversation_select_recipients/conversation_new_entry_screen.js +67 -0
  44. package/build/screens/conversation_select_recipients/conversation_new_entry_screen.js.map +1 -0
  45. package/build/screens/conversation_select_recipients/conversation_select_teams_i_lead_recipients_screen.d.ts.map +1 -1
  46. package/build/screens/conversation_select_recipients/conversation_select_teams_i_lead_recipients_screen.js +17 -2
  47. package/build/screens/conversation_select_recipients/conversation_select_teams_i_lead_recipients_screen.js.map +1 -1
  48. package/build/screens/conversation_select_type_screen.d.ts +11 -0
  49. package/build/screens/conversation_select_type_screen.d.ts.map +1 -0
  50. package/build/screens/conversation_select_type_screen.js +32 -0
  51. package/build/screens/conversation_select_type_screen.js.map +1 -0
  52. package/build/screens/conversations/components/list_header_component.d.ts.map +1 -1
  53. package/build/screens/conversations/components/list_header_component.js +54 -25
  54. package/build/screens/conversations/components/list_header_component.js.map +1 -1
  55. package/build/screens/index.d.ts +1 -1
  56. package/build/screens/index.d.ts.map +1 -1
  57. package/build/screens/index.js +1 -1
  58. package/build/screens/index.js.map +1 -1
  59. package/build/screens/message_actions_screen.js +14 -2
  60. package/build/screens/message_actions_screen.js.map +1 -1
  61. package/build/screens/message_report/components/message_preview.d.ts +10 -0
  62. package/build/screens/message_report/components/message_preview.d.ts.map +1 -0
  63. package/build/screens/message_report/components/message_preview.js +81 -0
  64. package/build/screens/message_report/components/message_preview.js.map +1 -0
  65. package/build/screens/message_report/components/report_reason_list.d.ts +9 -0
  66. package/build/screens/message_report/components/report_reason_list.d.ts.map +1 -0
  67. package/build/screens/message_report/components/report_reason_list.js +67 -0
  68. package/build/screens/message_report/components/report_reason_list.js.map +1 -0
  69. package/build/screens/message_report_screen.d.ts +10 -0
  70. package/build/screens/message_report_screen.d.ts.map +1 -0
  71. package/build/screens/message_report_screen.js +214 -0
  72. package/build/screens/message_report_screen.js.map +1 -0
  73. package/build/types/resources/conversation.d.ts +2 -3
  74. package/build/types/resources/conversation.d.ts.map +1 -1
  75. package/build/types/resources/conversation.js.map +1 -1
  76. package/build/types/resources/conversation_membership.d.ts +14 -0
  77. package/build/types/resources/conversation_membership.d.ts.map +1 -0
  78. package/build/types/resources/conversation_membership.js +2 -0
  79. package/build/types/resources/conversation_membership.js.map +1 -0
  80. package/build/types/resources/index.d.ts +1 -0
  81. package/build/types/resources/index.d.ts.map +1 -1
  82. package/build/types/resources/index.js +1 -0
  83. package/build/types/resources/index.js.map +1 -1
  84. package/build/types/resources/message_report.d.ts +19 -0
  85. package/build/types/resources/message_report.d.ts.map +1 -0
  86. package/build/types/resources/message_report.js +9 -0
  87. package/build/types/resources/message_report.js.map +1 -0
  88. package/build/utils/deep_snake_case_keys.d.ts +4 -0
  89. package/build/utils/deep_snake_case_keys.d.ts.map +1 -0
  90. package/build/utils/deep_snake_case_keys.js +13 -0
  91. package/build/utils/deep_snake_case_keys.js.map +1 -0
  92. package/package.json +2 -2
  93. package/src/components/display/toggle_button.tsx +27 -15
  94. package/src/components/primitive/form_sheet.tsx +4 -2
  95. package/src/hooks/index.ts +1 -0
  96. package/src/hooks/use_conversation.ts +6 -1
  97. package/src/hooks/use_conversation_membership.ts +82 -0
  98. package/src/hooks/use_features.ts +1 -0
  99. package/src/hooks/use_new_conversation_entry.ts +31 -0
  100. package/src/hooks/use_report_message.ts +37 -0
  101. package/src/navigation/index.tsx +19 -6
  102. package/src/screens/conversation_details_screen.tsx +34 -16
  103. package/src/screens/conversation_filter_recipients/conversation_filter_recipients_screen.tsx +10 -3
  104. package/src/screens/conversation_select_recipients/conversation_new_entry_screen.tsx +100 -0
  105. package/src/screens/conversation_select_recipients/conversation_select_teams_i_lead_recipients_screen.tsx +23 -3
  106. package/src/screens/conversation_select_type_screen.tsx +53 -0
  107. package/src/screens/conversations/components/list_header_component.tsx +103 -67
  108. package/src/screens/index.ts +1 -1
  109. package/src/screens/message_actions_screen.tsx +24 -2
  110. package/src/screens/message_report/components/message_preview.tsx +99 -0
  111. package/src/screens/message_report/components/report_reason_list.tsx +106 -0
  112. package/src/screens/message_report_screen.tsx +278 -0
  113. package/src/types/resources/conversation.ts +2 -3
  114. package/src/types/resources/conversation_membership.ts +15 -0
  115. package/src/types/resources/index.ts +1 -0
  116. package/src/types/resources/message_report.ts +20 -0
  117. package/src/utils/deep_snake_case_keys.ts +16 -0
  118. package/build/screens/conversation_select_recipients/conversation_select_recipients_screen.d.ts +0 -4
  119. package/build/screens/conversation_select_recipients/conversation_select_recipients_screen.d.ts.map +0 -1
  120. package/build/screens/conversation_select_recipients/conversation_select_recipients_screen.js +0 -146
  121. package/build/screens/conversation_select_recipients/conversation_select_recipients_screen.js.map +0 -1
  122. package/src/screens/conversation_select_recipients/conversation_select_recipients_screen.tsx +0 -215
@@ -4,9 +4,15 @@ import { IconString } from './icon';
4
4
  type RestrictedPressableProps = Omit<PressableProps, 'onLongPress'>;
5
5
  export interface ToggleButtonProps extends RestrictedPressableProps {
6
6
  /**
7
- * Pressable container styles
7
+ * Whether the toggle button is active/checked
8
8
  */
9
9
  active: boolean;
10
+ /**
11
+ * Required accessibility label for screen readers.
12
+ * When title is provided, this provides additional context.
13
+ * When title is omitted (icon-only mode), this is the primary label.
14
+ */
15
+ accessibilityLabel: string;
10
16
  /**
11
17
  * Specifies whether fonts should be scaled down automatically to fit given style constraints.
12
18
  */
@@ -32,9 +38,10 @@ export interface ToggleButtonProps extends RestrictedPressableProps {
32
38
  */
33
39
  minimumFontScale?: number;
34
40
  /**
35
- * Renders as text within the button
41
+ * Renders as text within the button.
42
+ * When omitted, button displays in icon-only mode.
36
43
  */
37
- title: string;
44
+ title?: string;
38
45
  /**
39
46
  * Pressable container styles
40
47
  */
@@ -44,6 +51,6 @@ export interface ToggleButtonProps extends RestrictedPressableProps {
44
51
  */
45
52
  hapticFeedback?: boolean;
46
53
  }
47
- export declare function ToggleButton({ active, adjustsFontSizeToFit, allowFontScaling, iconNameLeft, iconNameRight, maxFontSizeMultiplier, minimumFontScale, title, style, hapticFeedback, onPress, ...props }: ToggleButtonProps): React.JSX.Element;
54
+ export declare function ToggleButton({ active, accessibilityLabel, adjustsFontSizeToFit, allowFontScaling, iconNameLeft, iconNameRight, maxFontSizeMultiplier, minimumFontScale, title, style, hapticFeedback, onPress, ...props }: ToggleButtonProps): React.JSX.Element;
48
55
  export {};
49
56
  //# sourceMappingURL=toggle_button.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"toggle_button.d.ts","sourceRoot":"","sources":["../../../src/components/display/toggle_button.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AAEzB,OAAO,KAAK,EAAE,cAAc,EAAyB,MAAM,cAAc,CAAA;AAazE,OAAO,EAAQ,UAAU,EAAE,MAAM,QAAQ,CAAA;AAWzC,KAAK,wBAAwB,GAAG,IAAI,CAAC,cAAc,EAAE,aAAa,CAAC,CAAA;AAMnE,MAAM,WAAW,iBAAkB,SAAQ,wBAAwB;IACjE;;OAEG;IACH,MAAM,EAAE,OAAO,CAAA;IACf;;OAEG;IACH,oBAAoB,CAAC,EAAE,OAAO,CAAA;IAC9B;;OAEG;IACH,gBAAgB,CAAC,EAAE,OAAO,CAAA;IAC1B;;OAEG;IACH,YAAY,CAAC,EAAE,UAAU,CAAA;IACzB;;OAEG;IACH,aAAa,CAAC,EAAE,UAAU,CAAA;IAC1B;;OAEG;IACH,qBAAqB,CAAC,EAAE,MAAM,CAAA;IAC9B;;OAEG;IACH,gBAAgB,CAAC,EAAE,MAAM,CAAA;IACzB;;OAEG;IACH,KAAK,EAAE,MAAM,CAAA;IACb;;OAEG;IACH,KAAK,CAAC,EAAE,cAAc,CAAC,OAAO,CAAC,CAAA;IAC/B;;OAEG;IACH,cAAc,CAAC,EAAE,OAAO,CAAA;CACzB;AAED,wBAAgB,YAAY,CAAC,EAC3B,MAAM,EACN,oBAA4B,EAC5B,gBAAuB,EACvB,YAAY,EACZ,aAAa,EACb,qBAAyD,EACzD,gBAAgB,EAChB,KAAK,EACL,KAAK,EACL,cAAqB,EACrB,OAAO,EACP,GAAG,KAAK,EACT,EAAE,iBAAiB,qBAwDnB"}
1
+ {"version":3,"file":"toggle_button.d.ts","sourceRoot":"","sources":["../../../src/components/display/toggle_button.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AAEzB,OAAO,KAAK,EAAE,cAAc,EAAyB,MAAM,cAAc,CAAA;AAazE,OAAO,EAAQ,UAAU,EAAE,MAAM,QAAQ,CAAA;AAWzC,KAAK,wBAAwB,GAAG,IAAI,CAAC,cAAc,EAAE,aAAa,CAAC,CAAA;AAMnE,MAAM,WAAW,iBAAkB,SAAQ,wBAAwB;IACjE;;OAEG;IACH,MAAM,EAAE,OAAO,CAAA;IACf;;;;OAIG;IACH,kBAAkB,EAAE,MAAM,CAAA;IAC1B;;OAEG;IACH,oBAAoB,CAAC,EAAE,OAAO,CAAA;IAC9B;;OAEG;IACH,gBAAgB,CAAC,EAAE,OAAO,CAAA;IAC1B;;OAEG;IACH,YAAY,CAAC,EAAE,UAAU,CAAA;IACzB;;OAEG;IACH,aAAa,CAAC,EAAE,UAAU,CAAA;IAC1B;;OAEG;IACH,qBAAqB,CAAC,EAAE,MAAM,CAAA;IAC9B;;OAEG;IACH,gBAAgB,CAAC,EAAE,MAAM,CAAA;IACzB;;;OAGG;IACH,KAAK,CAAC,EAAE,MAAM,CAAA;IACd;;OAEG;IACH,KAAK,CAAC,EAAE,cAAc,CAAC,OAAO,CAAC,CAAA;IAC/B;;OAEG;IACH,cAAc,CAAC,EAAE,OAAO,CAAA;CACzB;AAED,wBAAgB,YAAY,CAAC,EAC3B,MAAM,EACN,kBAAkB,EAClB,oBAA4B,EAC5B,gBAAuB,EACvB,YAAY,EACZ,aAAa,EACb,qBAAyD,EACzD,gBAAgB,EAChB,KAAK,EACL,KAAK,EACL,cAAqB,EACrB,OAAO,EACP,GAAG,KAAK,EACT,EAAE,iBAAiB,qBA4DnB"}
@@ -6,7 +6,8 @@ import { MAX_FONT_SIZE_MULTIPLIER_LANDMARK, platformFontWeightBold, platformPres
6
6
  import { Icon } from './icon';
7
7
  import { tokens } from '../../vendor/tapestry/tokens';
8
8
  import { Haptic } from '../../utils/native_adapters/configuration';
9
- export function ToggleButton({ active, adjustsFontSizeToFit = false, allowFontScaling = true, iconNameLeft, iconNameRight, maxFontSizeMultiplier = MAX_FONT_SIZE_MULTIPLIER_LANDMARK, minimumFontScale, title, style, hapticFeedback = true, onPress, ...props }) {
9
+ export function ToggleButton({ active, accessibilityLabel, adjustsFontSizeToFit = false, allowFontScaling = true, iconNameLeft, iconNameRight, maxFontSizeMultiplier = MAX_FONT_SIZE_MULTIPLIER_LANDMARK, minimumFontScale, title, style, hapticFeedback = true, onPress, ...props }) {
10
+ const hasTitle = Boolean(title);
10
11
  const styles = useStyles({ active, maxFontSizeMultiplier });
11
12
  const { colors } = useTheme();
12
13
  const overrideStyles = StyleSheet.flatten(style); // Ensures the pressed styles still get applied
@@ -21,11 +22,11 @@ export function ToggleButton({ active, adjustsFontSizeToFit = false, allowFontSc
21
22
  ...styles.pressable,
22
23
  ...(pressed ? platformPressedOpacityStyle : null),
23
24
  ...overrideStyles,
24
- })} accessibilityRole="togglebutton" accessibilityState={{ checked: active }} android_ripple={{ color: androidRippleColor, borderless: false, foreground: true }} onPress={handlePress} accessibilityShowsLargeContentViewer accessibilityLargeContentTitle={title} {...props}>
25
+ })} accessibilityRole="togglebutton" accessibilityLabel={accessibilityLabel} accessibilityState={{ checked: active }} android_ripple={{ color: androidRippleColor, borderless: false, foreground: true }} onPress={handlePress} accessibilityShowsLargeContentViewer accessibilityLargeContentTitle={accessibilityLabel} {...props}>
25
26
  {iconNameLeft && (<Icon name={iconNameLeft} style={styles.icon} maxFontSizeMultiplier={maxFontSizeMultiplier}/>)}
26
- <Text allowFontScaling={allowFontScaling} minimumFontScale={minimumFontScale} maxFontSizeMultiplier={maxFontSizeMultiplier} adjustsFontSizeToFit={adjustsFontSizeToFit} numberOfLines={1} style={styles.text} variant="tertiary">
27
- {title}
28
- </Text>
27
+ {hasTitle && (<Text allowFontScaling={allowFontScaling} minimumFontScale={minimumFontScale} maxFontSizeMultiplier={maxFontSizeMultiplier} adjustsFontSizeToFit={adjustsFontSizeToFit} numberOfLines={1} style={styles.text} variant="tertiary">
28
+ {title}
29
+ </Text>)}
29
30
  {iconNameRight && (<Icon name={iconNameRight} style={styles.icon} maxFontSizeMultiplier={maxFontSizeMultiplier}/>)}
30
31
  </Pressable>);
31
32
  }
@@ -1 +1 @@
1
- {"version":3,"file":"toggle_button.js","sourceRoot":"","sources":["../../../src/components/display/toggle_button.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AACzB,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AAEpD,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAA;AAC7B,OAAO,EACL,QAAQ,EACR,YAAY,EACZ,2BAA2B,EAC3B,kCAAkC,GACnC,MAAM,aAAa,CAAA;AACpB,OAAO,EACL,iCAAiC,EACjC,sBAAsB,EACtB,2BAA2B,GAC5B,MAAM,aAAa,CAAA;AACpB,OAAO,EAAE,IAAI,EAAc,MAAM,QAAQ,CAAA;AACzC,OAAO,EAAE,MAAM,EAAE,MAAM,8BAA8B,CAAA;AACrD,OAAO,EAAE,MAAM,EAAE,MAAM,2CAA2C,CAAA;AA0DlE,MAAM,UAAU,YAAY,CAAC,EAC3B,MAAM,EACN,oBAAoB,GAAG,KAAK,EAC5B,gBAAgB,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;IAE5E,OAAO,UAAU,CAAC,MAAM,CAAC;QACvB,SAAS,EAAE;YACT,YAAY,EAAE,MAAM,CAAC,YAAY,GAAG,SAAS;YAC7C,WAAW,EAAE,CAAC;YACd,WAAW,EAAE,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC,CAAC,MAAM,CAAC,sBAAsB;YACxE,eAAe,EAAE,MAAM,CAAC,CAAC,CAAC,qBAAqB,CAAC,CAAC,CAAC,aAAa;YAC/D,iBAAiB,EAAE,EAAE,GAAG,SAAS;YACjC,aAAa,EAAE,KAAK;YACpB,UAAU,EAAE,QAAQ;YACpB,cAAc,EAAE,QAAQ;YACxB,MAAM,EAAE,EAAE,GAAG,SAAS;YACtB,GAAG,EAAE,CAAC,GAAG,SAAS;YAClB,QAAQ,EAAE,QAAQ;SACnB;QACD,IAAI,EAAE;YACJ,SAAS,EAAE,QAAQ;YACnB,iBAAiB,EAAE,QAAQ;YAC3B,kBAAkB,EAAE,KAAK;YACzB,UAAU,EAAE,sBAAsB;YAClC,KAAK;SACN;QACD,IAAI,EAAE;YACJ,QAAQ,EAAE,MAAM,CAAC,UAAU,GAAG,SAAS;YACvC,KAAK;SACN;KACF,CAAC,CAAA;AACJ,CAAC,CAAA","sourcesContent":["import React from 'react'\nimport { Pressable, StyleSheet } from 'react-native'\nimport type { PressableProps, GestureResponderEvent } from 'react-native'\nimport { Text } from './text'\nimport {\n useTheme,\n useFontScale,\n useCreateAndroidRippleColor,\n useInteractionGhostBackgroundColor,\n} from '../../hooks'\nimport {\n MAX_FONT_SIZE_MULTIPLIER_LANDMARK,\n platformFontWeightBold,\n platformPressedOpacityStyle,\n} from '../../utils'\nimport { Icon, IconString } from './icon'\nimport { tokens } from '../../vendor/tapestry/tokens'\nimport { Haptic } from '../../utils/native_adapters/configuration'\n\n// =================================\n// ====== Constants ================\n// =================================\n\n// We are omitting `onLongPress` because we are instead supporting `accessibilityShowsLargeContentViewer`.\n// This is triggered by an `onLongPress` event when an iOS device is in Apple's accessible font scale range.\n// Triggering this prop will display an almost full screen iOS a11y button.\ntype RestrictedPressableProps = Omit<PressableProps, 'onLongPress'>\n\n// =================================\n// ====== Component ================\n// =================================\n\nexport interface ToggleButtonProps extends RestrictedPressableProps {\n /**\n * Pressable container styles\n */\n active: boolean\n /**\n * Specifies whether fonts should be scaled down automatically to fit given style constraints.\n */\n adjustsFontSizeToFit?: boolean\n /**\n * Specifies whether fonts should scale to respect the device's text size accessibility settings. The default is true.\n */\n allowFontScaling?: boolean\n /**\n * Generates an icon to the left of the button text\n */\n iconNameLeft?: IconString\n /**\n * Generates an icon to the right of the button text\n */\n iconNameRight?: IconString\n /**\n * Specifies the maximum size a font can reach when allowFontScaling is enabled.\n */\n maxFontSizeMultiplier?: number\n /**\n * Specifies smallest possible scale a font can reach when adjustsFontSizeToFit is enabled. (values 0.01-1.0).\n */\n minimumFontScale?: number\n /**\n * Renders as text within the button\n */\n title: string\n /**\n * Pressable container styles\n */\n style?: PressableProps['style']\n /**\n * Specifies whether haptic feedback should be enabled.\n */\n hapticFeedback?: boolean\n}\n\nexport function ToggleButton({\n active,\n adjustsFontSizeToFit = false,\n allowFontScaling = true,\n iconNameLeft,\n iconNameRight,\n maxFontSizeMultiplier = MAX_FONT_SIZE_MULTIPLIER_LANDMARK,\n minimumFontScale,\n title,\n style,\n hapticFeedback = true,\n onPress,\n ...props\n}: ToggleButtonProps) {\n const styles = useStyles({ active, maxFontSizeMultiplier })\n const { colors } = useTheme()\n const overrideStyles = StyleSheet.flatten(style) // Ensures the pressed styles still get applied\n\n const baseRippleColor = active ? colors.interaction : colors.fillColorNeutral050Base\n const androidRippleColor = useCreateAndroidRippleColor({ color: baseRippleColor })\n\n const handlePress = (event: GestureResponderEvent) => {\n if (hapticFeedback) Haptic.impactLight()\n\n onPress?.(event)\n }\n\n return (\n <Pressable\n style={({ pressed }) => ({\n ...styles.pressable,\n ...(pressed ? platformPressedOpacityStyle : null),\n ...overrideStyles,\n })}\n accessibilityRole=\"togglebutton\"\n accessibilityState={{ checked: active }}\n android_ripple={{ color: androidRippleColor, borderless: false, foreground: true }}\n onPress={handlePress}\n accessibilityShowsLargeContentViewer\n accessibilityLargeContentTitle={title}\n {...props}\n >\n {iconNameLeft && (\n <Icon\n name={iconNameLeft}\n style={styles.icon}\n maxFontSizeMultiplier={maxFontSizeMultiplier}\n />\n )}\n <Text\n allowFontScaling={allowFontScaling}\n minimumFontScale={minimumFontScale}\n maxFontSizeMultiplier={maxFontSizeMultiplier}\n adjustsFontSizeToFit={adjustsFontSizeToFit}\n numberOfLines={1}\n style={styles.text}\n variant=\"tertiary\"\n >\n {title}\n </Text>\n {iconNameRight && (\n <Icon\n name={iconNameRight}\n style={styles.icon}\n maxFontSizeMultiplier={maxFontSizeMultiplier}\n />\n )}\n </Pressable>\n )\n}\n\n// =================================\n// ====== Styles ===================\n// =================================\n\nconst useStyles = ({ active, maxFontSizeMultiplier }: Partial<ToggleButtonProps>) => {\n const { colors, button } = useTheme()\n const fontScale = useFontScale({ maxFontSizeMultiplier })\n\n const activeBackgroundColor = useInteractionGhostBackgroundColor()\n\n const color = active ? colors.interaction : colors.textColorDefaultSecondary\n\n return StyleSheet.create({\n pressable: {\n borderRadius: button.borderRadius * fontScale,\n borderWidth: 1,\n borderColor: active ? colors.interaction : colors.borderColorDefaultBase,\n backgroundColor: active ? activeBackgroundColor : 'transparent',\n paddingHorizontal: 16 * fontScale,\n flexDirection: 'row',\n alignItems: 'center',\n justifyContent: 'center',\n height: 32 * fontScale,\n gap: 6 * fontScale,\n overflow: 'hidden',\n },\n text: {\n textAlign: 'center',\n textAlignVertical: 'center',\n includeFontPadding: false,\n fontWeight: platformFontWeightBold,\n color,\n },\n icon: {\n fontSize: tokens.fontSizeSm * fontScale,\n color,\n },\n })\n}\n"]}
1
+ {"version":3,"file":"toggle_button.js","sourceRoot":"","sources":["../../../src/components/display/toggle_button.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;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,iBAAiB,EAAE,QAAQ;YAC3B,kBAAkB,EAAE,KAAK;YACzB,UAAU,EAAE,sBAAsB;YAClC,KAAK;SACN;QACD,IAAI,EAAE;YACJ,QAAQ,EAAE,MAAM,CAAC,UAAU,GAAG,SAAS;YACvC,KAAK;SACN;KACF,CAAC,CAAA;AACJ,CAAC,CAAA","sourcesContent":["import React from 'react'\nimport { Pressable, StyleSheet } from 'react-native'\nimport type { PressableProps, GestureResponderEvent } from 'react-native'\nimport { Text } from './text'\nimport {\n useTheme,\n useFontScale,\n useCreateAndroidRippleColor,\n useInteractionGhostBackgroundColor,\n} from '../../hooks'\nimport {\n MAX_FONT_SIZE_MULTIPLIER_LANDMARK,\n platformFontWeightBold,\n platformPressedOpacityStyle,\n} from '../../utils'\nimport { Icon, IconString } from './icon'\nimport { tokens } from '../../vendor/tapestry/tokens'\nimport { Haptic } from '../../utils/native_adapters/configuration'\n\n// =================================\n// ====== Constants ================\n// =================================\n\n// We are omitting `onLongPress` because we are instead supporting `accessibilityShowsLargeContentViewer`.\n// This is triggered by an `onLongPress` event when an iOS device is in Apple's accessible font scale range.\n// Triggering this prop will display an almost full screen iOS a11y button.\ntype RestrictedPressableProps = Omit<PressableProps, 'onLongPress'>\n\n// =================================\n// ====== Component ================\n// =================================\n\nexport interface ToggleButtonProps extends RestrictedPressableProps {\n /**\n * Whether the toggle button is active/checked\n */\n active: boolean\n /**\n * Required accessibility label for screen readers.\n * When title is provided, this provides additional context.\n * When title is omitted (icon-only mode), this is the primary label.\n */\n accessibilityLabel: string\n /**\n * Specifies whether fonts should be scaled down automatically to fit given style constraints.\n */\n adjustsFontSizeToFit?: boolean\n /**\n * Specifies whether fonts should scale to respect the device's text size accessibility settings. The default is true.\n */\n allowFontScaling?: boolean\n /**\n * Generates an icon to the left of the button text\n */\n iconNameLeft?: IconString\n /**\n * Generates an icon to the right of the button text\n */\n iconNameRight?: IconString\n /**\n * Specifies the maximum size a font can reach when allowFontScaling is enabled.\n */\n maxFontSizeMultiplier?: number\n /**\n * Specifies smallest possible scale a font can reach when adjustsFontSizeToFit is enabled. (values 0.01-1.0).\n */\n minimumFontScale?: number\n /**\n * Renders as text within the button.\n * When omitted, button displays in icon-only mode.\n */\n title?: string\n /**\n * Pressable container styles\n */\n style?: PressableProps['style']\n /**\n * Specifies whether haptic feedback should be enabled.\n */\n hapticFeedback?: boolean\n}\n\nexport function ToggleButton({\n active,\n accessibilityLabel,\n adjustsFontSizeToFit = false,\n allowFontScaling = true,\n iconNameLeft,\n iconNameRight,\n maxFontSizeMultiplier = MAX_FONT_SIZE_MULTIPLIER_LANDMARK,\n minimumFontScale,\n title,\n style,\n hapticFeedback = true,\n onPress,\n ...props\n}: ToggleButtonProps) {\n const hasTitle = Boolean(title)\n const styles = useStyles({ active, maxFontSizeMultiplier })\n const { colors } = useTheme()\n const overrideStyles = StyleSheet.flatten(style) // Ensures the pressed styles still get applied\n\n const baseRippleColor = active ? colors.interaction : colors.fillColorNeutral050Base\n const androidRippleColor = useCreateAndroidRippleColor({ color: baseRippleColor })\n\n const handlePress = (event: GestureResponderEvent) => {\n if (hapticFeedback) Haptic.impactLight()\n\n onPress?.(event)\n }\n\n return (\n <Pressable\n style={({ pressed }) => ({\n ...styles.pressable,\n ...(pressed ? platformPressedOpacityStyle : null),\n ...overrideStyles,\n })}\n accessibilityRole=\"togglebutton\"\n accessibilityLabel={accessibilityLabel}\n accessibilityState={{ checked: active }}\n android_ripple={{ color: androidRippleColor, borderless: false, foreground: true }}\n onPress={handlePress}\n accessibilityShowsLargeContentViewer\n accessibilityLargeContentTitle={accessibilityLabel}\n {...props}\n >\n {iconNameLeft && (\n <Icon\n name={iconNameLeft}\n style={styles.icon}\n maxFontSizeMultiplier={maxFontSizeMultiplier}\n />\n )}\n {hasTitle && (\n <Text\n allowFontScaling={allowFontScaling}\n minimumFontScale={minimumFontScale}\n maxFontSizeMultiplier={maxFontSizeMultiplier}\n adjustsFontSizeToFit={adjustsFontSizeToFit}\n numberOfLines={1}\n style={styles.text}\n variant=\"tertiary\"\n >\n {title}\n </Text>\n )}\n {iconNameRight && (\n <Icon\n name={iconNameRight}\n style={styles.icon}\n maxFontSizeMultiplier={maxFontSizeMultiplier}\n />\n )}\n </Pressable>\n )\n}\n\n// =================================\n// ====== Styles ===================\n// =================================\n\nconst useStyles = ({ active, maxFontSizeMultiplier }: Partial<ToggleButtonProps>) => {\n const { colors, button } = useTheme()\n const fontScale = useFontScale({ maxFontSizeMultiplier })\n\n const activeBackgroundColor = useInteractionGhostBackgroundColor()\n\n const color = active ? colors.interaction : colors.textColorDefaultSecondary\n\n return StyleSheet.create({\n pressable: {\n borderRadius: button.borderRadius * fontScale,\n borderWidth: 1,\n borderColor: active ? colors.interaction : colors.borderColorDefaultBase,\n backgroundColor: active ? activeBackgroundColor : 'transparent',\n paddingHorizontal: 16 * fontScale,\n flexDirection: 'row',\n alignItems: 'center',\n justifyContent: 'center',\n height: 32 * fontScale,\n gap: 6 * fontScale,\n overflow: 'hidden',\n },\n text: {\n textAlign: 'center',\n textAlignVertical: 'center',\n includeFontPadding: false,\n fontWeight: platformFontWeightBold,\n color,\n },\n icon: {\n fontSize: tokens.fontSizeSm * fontScale,\n color,\n },\n })\n}\n"]}
@@ -55,7 +55,7 @@ declare const FORM_SHEET_ACTION_APPEARANCES: {
55
55
  type FormSheetActionAppearanceUnion = (typeof FORM_SHEET_ACTION_APPEARANCES)[keyof typeof FORM_SHEET_ACTION_APPEARANCES];
56
56
  interface FormSheetActionProps {
57
57
  title: string;
58
- iconName: IconString;
58
+ iconName?: IconString;
59
59
  onPress: () => void;
60
60
  accessibilityLabel?: string;
61
61
  accessibilityHint?: string;
@@ -1 +1 @@
1
- {"version":3,"file":"form_sheet.d.ts","sourceRoot":"","sources":["../../../src/components/primitive/form_sheet.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,4BAA4B,EAAE,MAAM,gCAAgC,CAAA;AAC7E,OAAO,KAAK,EAAE,EAAE,SAAS,EAAE,MAAM,OAAO,CA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,CAAC,SAAS,CAAC,CAAA;CAC7B;AAkBD,UAAU,yBAAyB;IACjC,QAAQ,EAAE,SAAS,CAAA;CACpB;AAsBD,UAAU,2BAA2B;IACnC,QAAQ,EAAE,SAAS,CAAA;CACpB;AAiBD,UAAU,8BACR,SAAQ,IAAI,CAAC,eAAe,EAAE,uBAAuB,GAAG,aAAa,CAAC;IACtE,QAAQ,EAAE,MAAM,CAAA;CACjB;AAoBD,UAAU,0BACR,SAAQ,IAAI,CAAC,WAAW,EAAE,uBAAuB,GAAG,aAAa,CAAC;CAAG;AAmBvE,QAAA,MAAM,6BAA6B;;;CAGzB,CAAA;AAEV,KAAK,8BAA8B,GACjC,CAAC,OAAO,6BAA6B,CAAC,CAAC,MAAM,OAAO,6BAA6B,CAAC,CAAA;AAEpF,UAAU,oBAAoB;IAC5B,KAAK,EAAE,MAAM,CAAA;IACb,QAAQ,CAAC,EAAE,UAAU,CAAA;IACrB,OAAO,EAAE,MAAM,IAAI,CAAA;IACnB,kBAAkB,CAAC,EAAE,MAAM,CAAA;IAC3B,iBAAiB,CAAC,EAAE,MAAM,CAAA;IAC1B,iBAAiB,CAAC,EAAE,iBAAiB,CAAA;IACrC,UAAU,CAAC,EAAE,8BAA8B,CAAA;IAC3C,QAAQ,CAAC,EAAE,OAAO,CAAA;CACnB"}
@@ -89,7 +89,7 @@ const FORM_SHEET_ACTION_APPEARANCES = {
89
89
  function FormSheetAction({ title, iconName, onPress, accessibilityLabel, accessibilityHint, accessibilityRole = 'button', appearance = 'neutral', disabled = false, }) {
90
90
  const styles = useStyles({ appearance });
91
91
  return (<PlatformPressable onPress={onPress} accessibilityLabel={accessibilityLabel} accessibilityHint={accessibilityHint} accessibilityRole={accessibilityRole} style={styles.actionPressable} disabled={disabled}>
92
- <Icon name={iconName} size={16} accessibilityElementsHidden style={styles.actionIcon}/>
92
+ {iconName && (<Icon name={iconName} size={16} accessibilityElementsHidden style={styles.actionIcon}/>)}
93
93
  <Text style={styles.actionTitle}>{title}</Text>
94
94
  </PlatformPressable>);
95
95
  }
@@ -1 +1 @@
1
- {"version":3,"file":"form_sheet.js","sourceRoot":"","sources":["../../../src/components/primitive/form_sheet.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAA;AAE/E,OAAO,KAAoB,MAAM,OAAO,CAAA;AACxC,OAAO,EACL,QAAQ,EACR,UAAU,EACV,IAAI,EACJ,mBAAmB,GAIpB,MAAM,cAAc,CAAA;AACrB,OAAO,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAA;AAClE,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAA;AAEtC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAc,IAAI,EAAE,UAAU,EAAE,MAAM,YAAY,CAAA;AAChF,OAAO,EAAE,iCAAiC,EAAE,MAAM,aAAa,CAAA;AAE/D,oCAAoC;AACpC,oCAAoC;AACpC,oCAAoC;AAEpC;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,yBAAyB,GAAG,CAAC,EACxC,WAAW,EACX,mBAAmB,GAAG,CAAC,IAAI,CAAC,EAC5B,GAAG,IAAI,KACyB,EAAE,EAAgC,EAAE,CAAC,CAAC;IACtE,YAAY,EAAE,WAAW;IACzB,WAAW,EAAE,KAAK;IAClB,mBAAmB;IACnB,iBAAiB,EAAE,EAAE;IACrB,mBAAmB,EAAE,IAAI;IACzB,WAAW;IACX,GAAG,IAAI;CACR,CAAC,CAAA;AAEF,MAAM,SAAS,GAAG;IAChB,IAAI,EAAE,aAAa;IACnB,MAAM,EAAE,eAAe;IACvB,MAAM,EAAE,eAAe;IACvB,WAAW,EAAE,oBAAoB;IACjC,aAAa,EAAE,sBAAsB;IACrC,gBAAgB,EAAE,yBAAyB;IAC3C,YAAY,EAAE,qBAAqB;CAC3B,CAAA;AAYV,eAAe,SAAgC,CAAA;AAsB/C,MAAM,UAAU,aAAa,CAAC,EAC5B,QAAQ,E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,GAAG,EAAE,EAAE;YACP,iBAAiB,EAAE,CAAC;YACpB,iBAAiB,EAAE,MAAM,CAAC,sBAAsB;SACjD;QACD,aAAa,EAAE;YACb,aAAa,EAAE,KAAK;YACpB,UAAU,EAAE,QAAQ;YACpB,cAAc,EAAE,eAAe;SAChC;QACD,WAAW,EAAE;YACX,SAAS,EAAE,MAAM;YACjB,IAAI,EAAE,CAAC;SACR;QACD,aAAa,EAAE;YACb,aAAa,EAAE,KAAK;YACpB,UAAU,EAAE,QAAQ;YACpB,GAAG,EAAE,EAAE;SACR;QACD,eAAe,EAAE;YACf,aAAa,EAAE,KAAK;YACpB,UAAU,EAAE,QAAQ;YACpB,eAAe,EAAE,EAAE;YACnB,iBAAiB,EAAE,EAAE;YACrB,GAAG,EAAE,CAAC;SACP;QACD,UAAU,EAAE;YACV,KAAK,EAAE,mBAAmB,CAAC,UAAU,CAAC,CAAC,SAAS;SACjD;QACD,WAAW,EAAE;YACX,KAAK,EAAE,mBAAmB,CAAC,UAAU,CAAC,CAAC,SAAS;SACjD;KACF,CAAC,CAAA;AACJ,CAAC,CAAA","sourcesContent":["import { PlatformPressable, useHeaderHeight } from '@react-navigation/elements'\nimport { NativeStackNavigationOptions } from '@react-navigation/native-stack'\nimport React, { ReactNode } from 'react'\nimport {\n Platform,\n StyleSheet,\n View,\n useWindowDimensions,\n type AccessibilityRole,\n type StyleProp,\n type ViewStyle,\n} from 'react-native'\nimport { useSafeAreaInsets } from 'react-native-safe-area-context'\nimport { useTheme } from '../../hooks'\nimport type { ButtonProps, TextButtonProps } from '../display'\nimport { Button, Heading, Icon, IconString, Text, TextButton } from '../display'\nimport { MAX_FONT_SIZE_MULTIPLIER_LANDMARK } from '../../utils'\n\n// =================================\n// ====== Exports ==================\n// =================================\n\n/**\n * Screen options for the formsheet's NativeStackNavigation route\n * @param {string} options.headerTitle - Doesn't show in UI but good to have for semantic reasons.\n * @param {number[]} [options.sheetAllowedDetents] - Controls the height increments the sheet grows to. To prevent bugs in Android, do not specify more then two values and use [0.94] instead of [1] to go full screen.\n * @param {NativeStackNavigationOptions} [options.rest] - Adds or overrides any valid NativeStackNavigationOptions\n * @returns {NativeStackNavigationOptions} Merged NativeStackNavigationOptions\n */\nexport const getFormSheetScreenOptions = ({\n headerTitle,\n sheetAllowedDetents = [0.25],\n ...rest\n}: NativeStackNavigationOptions = {}): NativeStackNavigationOptions => ({\n presentation: 'formSheet',\n headerShown: false,\n sheetAllowedDetents,\n sheetCornerRadius: 16,\n sheetGrabberVisible: true,\n headerTitle,\n ...rest,\n})\n\nconst FormSheet = {\n Root: FormSheetRoot,\n Action: FormSheetAction,\n Header: FormSheetHeader,\n HeaderTitle: FormSheetHeaderTitle,\n HeaderActions: FormSheetHeaderActions,\n HeaderTextButton: FormSheetHeaderTextButton,\n HeaderButton: FormSheetHeaderButton,\n} as const\n\ntype FormSheetComponents = {\n Root: React.FC<FormSheetRootProps>\n Action: React.FC<FormSheetActionProps>\n Header: React.FC<FormSheetHeaderProps>\n HeaderTitle: React.FC<FormSheetHeaderTitleProps>\n HeaderActions: React.FC<FormSheetHeaderActionsProps>\n HeaderTextButton: React.FC<FormSheetHeaderTextButtonProps>\n HeaderButton: React.FC<FormSheetHeaderButtonProps>\n}\n\nexport default FormSheet as FormSheetComponents\nexport type {\n FormSheetActionProps,\n FormSheetHeaderActionsProps,\n FormSheetHeaderButtonProps,\n FormSheetHeaderProps,\n FormSheetHeaderTextButtonProps,\n FormSheetHeaderTitleProps,\n FormSheetRootProps,\n}\n\n// ====================================\n// ====== ActionsFormSheetRoot ========\n// ====================================\n\ninterface FormSheetRootProps {\n children: ReactNode\n style?: StyleProp<ViewStyle>\n contentStyle?: StyleProp<ViewStyle>\n showAndroidSheetGrabber?: boolean\n}\n\nexport function FormSheetRoot({\n children,\n style,\n contentStyle,\n showAndroidSheetGrabber = true,\n}: FormSheetRootProps) {\n const styles = useStyles()\n\n return (\n <View style={[styles.container, style]} collapsable={false}>\n <View style={[styles.content, contentStyle]}>{children}</View>\n {showAndroidSheetGrabber && <AndroidSheetGrabber />}\n </View>\n )\n}\n\nFormSheetRoot.displayName = 'FormSheet.Root'\n\n// ====================================\n// ====== AndroidSheetGrabber =========\n// ====================================\n\nfunction AndroidSheetGrabber() {\n const styles = useStyles()\n\n return Platform.select({\n android: <View style={styles.androidSheetGrabber} />,\n ios: null,\n })\n}\n\n// ====================================\n// ====== FormSheetHeader =============\n// ====================================\n\ninterface FormSheetHeaderProps {\n children: ReactNode\n style?: StyleProp<ViewStyle>\n}\n\nfunction FormSheetHeader({ children, style }: FormSheetHeaderProps) {\n const styles = useStyles()\n\n return (\n <View style={[styles.header, style]}>\n <View style={styles.headerContent}>{children}</View>\n </View>\n )\n}\n\nFormSheetHeader.displayName = 'FormSheet.Header'\n\n// ====================================\n// ====== FormSheetHeaderTitle ========\n// ====================================\n\ninterface FormSheetHeaderTitleProps {\n children: ReactNode\n}\n\nfunction FormSheetHeaderTitle({ children }: FormSheetHeaderTitleProps) {\n const styles = useStyles()\n\n return (\n <Heading\n variant=\"h3\"\n style={styles.headerTitle}\n maxFontSizeMultiplier={MAX_FONT_SIZE_MULTIPLIER_LANDMARK}\n >\n {children}\n </Heading>\n )\n}\n\nFormSheetHeaderTitle.displayName = 'FormSheet.HeaderTitle'\n\n// ====================================\n// ====== FormSheetHeaderActions ======\n// ====================================\n\ninterface FormSheetHeaderActionsProps {\n children: ReactNode\n}\n\nfunction FormSheetHeaderActions({ children }: FormSheetHeaderActionsProps) {\n const styles = useStyles()\n\n return <View style={styles.headerActions}>{children}</View>\n}\n\nFormSheetHeaderActions.displayName = 'FormSheet.HeaderActions'\n\n// ===========================================\n// ====== FormSheetHeaderTextButton ==========\n// ===========================================\n\n// We are omitting `onLongPress` because we are instead supporting `accessibilityShowsLargeContentViewer`.\n// This is triggered by an `onLongPress` event when an iOS device is in Apple's accessible font scale range.\n// Triggering this prop will display an almost full screen iOS a11y button.\ninterface FormSheetHeaderTextButtonProps\n extends Omit<TextButtonProps, 'maxFontSizeMultiplier' | 'onLongPress'> {\n children: string\n}\n\nfunction FormSheetHeaderTextButton(props: FormSheetHeaderTextButtonProps) {\n return (\n <TextButton\n {...props}\n maxFontSizeMultiplier={MAX_FONT_SIZE_MULTIPLIER_LANDMARK}\n accessibilityShowsLargeContentViewer\n accessibilityLargeContentTitle={props.children}\n />\n )\n}\n\nFormSheetHeaderTextButton.displayName = 'FormSheet.HeaderTextButton'\n\n// =========================================\n// ====== FormSheetHeaderButton ============\n// =========================================\n\n// Same `onLongPress`note as `FormSheetHeaderTextButtonProps`\ninterface FormSheetHeaderButtonProps\n extends Omit<ButtonProps, 'maxFontSizeMultiplier' | 'onLongPress'> {}\n\nfunction FormSheetHeaderButton(props: FormSheetHeaderButtonProps) {\n return (\n <Button\n {...props}\n maxFontSizeMultiplier={MAX_FONT_SIZE_MULTIPLIER_LANDMARK}\n accessibilityShowsLargeContentViewer\n accessibilityLargeContentTitle={props.title}\n />\n )\n}\n\nFormSheetHeaderButton.displayName = 'FormSheet.HeaderButton'\n\n// ====================================\n// ====== ActionsFormSheetAction ======\n// ====================================\n\nconst FORM_SHEET_ACTION_APPEARANCES = {\n neutral: 'neutral',\n danger: 'danger',\n} as const\n\ntype FormSheetActionAppearanceUnion =\n (typeof FORM_SHEET_ACTION_APPEARANCES)[keyof typeof FORM_SHEET_ACTION_APPEARANCES]\n\ninterface FormSheetActionProps {\n title: string\n iconName: IconString\n onPress: () => void\n accessibilityLabel?: string\n accessibilityHint?: string\n accessibilityRole?: AccessibilityRole\n appearance?: FormSheetActionAppearanceUnion\n disabled?: boolean\n}\n\nfunction FormSheetAction({\n title,\n iconName,\n onPress,\n accessibilityLabel,\n accessibilityHint,\n accessibilityRole = 'button',\n appearance = 'neutral',\n disabled = false,\n}: FormSheetActionProps) {\n const styles = useStyles({ appearance })\n\n return (\n <PlatformPressable\n onPress={onPress}\n accessibilityLabel={accessibilityLabel}\n accessibilityHint={accessibilityHint}\n accessibilityRole={accessibilityRole}\n style={styles.actionPressable}\n disabled={disabled}\n >\n <Icon name={iconName} size={16} accessibilityElementsHidden style={styles.actionIcon} />\n <Text style={styles.actionTitle}>{title}</Text>\n </PlatformPressable>\n )\n}\n\nFormSheetAction.displayName = 'FormSheet.Action'\n\n// ==================================\n// ====== Styles ====================\n// ==================================\n\ninterface Styles {\n appearance?: FormSheetActionAppearanceUnion\n}\n\nconst useStyles = ({ appearance = 'neutral' }: Styles = {}) => {\n const { colors } = useTheme()\n const { height } = useWindowDimensions()\n const { bottom, top } = useSafeAreaInsets()\n const headerHeight = useHeaderHeight()\n\n const containerHeight = Platform.select({\n ios: height - top - headerHeight,\n default: null,\n })\n\n const appearanceColorsMap = {\n neutral: {\n iconColor: colors.iconColorDefaultPrimary,\n textColor: colors.textColorDefaultPrimary,\n },\n danger: {\n iconColor: colors.fillColorStatusErrorMedium,\n textColor: colors.fillColorStatusErrorMedium,\n },\n }\n\n return StyleSheet.create({\n container: {\n justifyContent: 'flex-start',\n paddingBottom: bottom,\n width: '100%',\n backgroundColor: colors.fillColorNeutral100Inverted,\n height: containerHeight,\n ...Platform.select({\n ios: {\n flexGrow: 1, // Ensures the FormSheet children respond to the formsheet height changing on iOS\n },\n android: {\n maxHeight: '100%', // Ensures lists to scroll on Android\n },\n }),\n },\n androidSheetGrabber: {\n position: 'absolute',\n top: 5,\n width: 34,\n height: 5,\n backgroundColor: colors.fillColorNeutral040,\n borderRadius: 100,\n alignSelf: 'center',\n },\n content: {\n ...Platform.select({\n android: {\n maxHeight: '100%', // Ensures content above a list (e.g. FormSheet.Header) don't subtract from the FormSheet's height\n },\n }),\n },\n header: {\n paddingHorizontal: 16,\n paddingTop: 20,\n paddingBottom: 16,\n backgroundColor: colors.fillColorNeutral100Inverted,\n gap: 16,\n borderBottomWidth: 1,\n borderBottomColor: colors.borderColorDefaultBase,\n },\n headerContent: {\n flexDirection: 'row',\n alignItems: 'center',\n justifyContent: 'space-between',\n },\n headerTitle: {\n textAlign: 'left',\n flex: 1,\n },\n headerActions: {\n flexDirection: 'row',\n alignItems: 'center',\n gap: 16,\n },\n actionPressable: {\n flexDirection: 'row',\n alignItems: 'center',\n paddingVertical: 12,\n paddingHorizontal: 16,\n gap: 8,\n },\n actionIcon: {\n color: appearanceColorsMap[appearance].iconColor,\n },\n actionTitle: {\n color: appearanceColorsMap[appearance].textColor,\n },\n })\n}\n"]}
1
+ {"version":3,"file":"form_sheet.js","sourceRoot":"","sources":["../../../src/components/primitive/form_sheet.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAA;AAE/E,OAAO,KAAoB,MAAM,OAAO,CAAA;AACxC,OAAO,EACL,QAAQ,EACR,UAAU,EACV,IAAI,EACJ,mBAAmB,GAIpB,MAAM,cAAc,CAAA;AACrB,OAAO,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAA;AAClE,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAA;AAEtC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAc,IAAI,EAAE,UAAU,EAAE,MAAM,YAAY,CAAA;AAChF,OAAO,EAAE,iCAAiC,EAAE,MAAM,aAAa,CAAA;AAE/D,oCAAoC;AACpC,oCAAoC;AACpC,oCAAoC;AAEpC;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,yBAAyB,GAAG,CAAC,EACxC,WAAW,EACX,mBAAmB,GAAG,CAAC,IAAI,CAAC,EAC5B,GAAG,IAAI,KACyB,EAAE,EAAgC,EAAE,CAAC,CAAC;IACtE,YAAY,EAAE,WAAW;IACzB,WAAW,EAAE,KAAK;IAClB,mBAAmB;IACnB,iBAAiB,EAAE,EAAE;IACrB,mBAAmB,EAAE,IAAI;IACzB,WAAW;IACX,GAAG,IAAI;CACR,CAAC,CAAA;AAEF,MAAM,SAAS,GAAG;IAChB,IAAI,EAAE,aAAa;IACnB,MAAM,EAAE,eAAe;IACvB,MAAM,EAAE,eAAe;IACvB,WAAW,EAAE,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gBACjB,OAAO,EAAE;oBACP,SAAS,EAAE,MAAM,EAAE,kGAAkG;iBACtH;aACF,CAAC;SACH;QACD,MAAM,EAAE;YACN,iBAAiB,EAAE,EAAE;YACrB,UAAU,EAAE,EAAE;YACd,aAAa,EAAE,EAAE;YACjB,eAAe,EAAE,MAAM,CAAC,2BAA2B;YACnD,GAAG,EAAE,EAAE;YACP,iBAAiB,EAAE,CAAC;YACpB,iBAAiB,EAAE,MAAM,CAAC,sBAAsB;SACjD;QACD,aAAa,EAAE;YACb,aAAa,EAAE,KAAK;YACpB,UAAU,EAAE,QAAQ;YACpB,cAAc,EAAE,eAAe;SAChC;QACD,WAAW,EAAE;YACX,SAAS,EAAE,MAAM;YACjB,IAAI,EAAE,CAAC;SACR;QACD,aAAa,EAAE;YACb,aAAa,EAAE,KAAK;YACpB,UAAU,EAAE,QAAQ;YACpB,GAAG,EAAE,EAAE;SACR;QACD,eAAe,EAAE;YACf,aAAa,EAAE,KAAK;YACpB,UAAU,EAAE,QAAQ;YACpB,eAAe,EAAE,EAAE;YACnB,iBAAiB,EAAE,EAAE;YACrB,GAAG,EAAE,CAAC;SACP;QACD,UAAU,EAAE;YACV,KAAK,EAAE,mBAAmB,CAAC,UAAU,CAAC,CAAC,SAAS;SACjD;QACD,WAAW,EAAE;YACX,KAAK,EAAE,mBAAmB,CAAC,UAAU,CAAC,CAAC,SAAS;SACjD;KACF,CAAC,CAAA;AACJ,CAAC,CAAA","sourcesContent":["import { PlatformPressable, useHeaderHeight } from '@react-navigation/elements'\nimport { NativeStackNavigationOptions } from '@react-navigation/native-stack'\nimport React, { ReactNode } from 'react'\nimport {\n Platform,\n StyleSheet,\n View,\n useWindowDimensions,\n type AccessibilityRole,\n type StyleProp,\n type ViewStyle,\n} from 'react-native'\nimport { useSafeAreaInsets } from 'react-native-safe-area-context'\nimport { useTheme } from '../../hooks'\nimport type { ButtonProps, TextButtonProps } from '../display'\nimport { Button, Heading, Icon, IconString, Text, TextButton } from '../display'\nimport { MAX_FONT_SIZE_MULTIPLIER_LANDMARK } from '../../utils'\n\n// =================================\n// ====== Exports ==================\n// =================================\n\n/**\n * Screen options for the formsheet's NativeStackNavigation route\n * @param {string} options.headerTitle - Doesn't show in UI but good to have for semantic reasons.\n * @param {number[]} [options.sheetAllowedDetents] - Controls the height increments the sheet grows to. To prevent bugs in Android, do not specify more then two values and use [0.94] instead of [1] to go full screen.\n * @param {NativeStackNavigationOptions} [options.rest] - Adds or overrides any valid NativeStackNavigationOptions\n * @returns {NativeStackNavigationOptions} Merged NativeStackNavigationOptions\n */\nexport const getFormSheetScreenOptions = ({\n headerTitle,\n sheetAllowedDetents = [0.25],\n ...rest\n}: NativeStackNavigationOptions = {}): NativeStackNavigationOptions => ({\n presentation: 'formSheet',\n headerShown: false,\n sheetAllowedDetents,\n sheetCornerRadius: 16,\n sheetGrabberVisible: true,\n headerTitle,\n ...rest,\n})\n\nconst FormSheet = {\n Root: FormSheetRoot,\n Action: FormSheetAction,\n Header: FormSheetHeader,\n HeaderTitle: FormSheetHeaderTitle,\n HeaderActions: FormSheetHeaderActions,\n HeaderTextButton: FormSheetHeaderTextButton,\n HeaderButton: FormSheetHeaderButton,\n} as const\n\ntype FormSheetComponents = {\n Root: React.FC<FormSheetRootProps>\n Action: React.FC<FormSheetActionProps>\n Header: React.FC<FormSheetHeaderProps>\n HeaderTitle: React.FC<FormSheetHeaderTitleProps>\n HeaderActions: React.FC<FormSheetHeaderActionsProps>\n HeaderTextButton: React.FC<FormSheetHeaderTextButtonProps>\n HeaderButton: React.FC<FormSheetHeaderButtonProps>\n}\n\nexport default FormSheet as FormSheetComponents\nexport type {\n FormSheetActionProps,\n FormSheetHeaderActionsProps,\n FormSheetHeaderButtonProps,\n FormSheetHeaderProps,\n FormSheetHeaderTextButtonProps,\n FormSheetHeaderTitleProps,\n FormSheetRootProps,\n}\n\n// ====================================\n// ====== ActionsFormSheetRoot ========\n// ====================================\n\ninterface FormSheetRootProps {\n children: ReactNode\n style?: StyleProp<ViewStyle>\n contentStyle?: StyleProp<ViewStyle>\n showAndroidSheetGrabber?: boolean\n}\n\nexport function FormSheetRoot({\n children,\n style,\n contentStyle,\n showAndroidSheetGrabber = true,\n}: FormSheetRootProps) {\n const styles = useStyles()\n\n return (\n <View style={[styles.container, style]} collapsable={false}>\n <View style={[styles.content, contentStyle]}>{children}</View>\n {showAndroidSheetGrabber && <AndroidSheetGrabber />}\n </View>\n )\n}\n\nFormSheetRoot.displayName = 'FormSheet.Root'\n\n// ====================================\n// ====== AndroidSheetGrabber =========\n// ====================================\n\nfunction AndroidSheetGrabber() {\n const styles = useStyles()\n\n return Platform.select({\n android: <View style={styles.androidSheetGrabber} />,\n ios: null,\n })\n}\n\n// ====================================\n// ====== FormSheetHeader =============\n// ====================================\n\ninterface FormSheetHeaderProps {\n children: ReactNode\n style?: StyleProp<ViewStyle>\n}\n\nfunction FormSheetHeader({ children, style }: FormSheetHeaderProps) {\n const styles = useStyles()\n\n return (\n <View style={[styles.header, style]}>\n <View style={styles.headerContent}>{children}</View>\n </View>\n )\n}\n\nFormSheetHeader.displayName = 'FormSheet.Header'\n\n// ====================================\n// ====== FormSheetHeaderTitle ========\n// ====================================\n\ninterface FormSheetHeaderTitleProps {\n children: ReactNode\n}\n\nfunction FormSheetHeaderTitle({ children }: FormSheetHeaderTitleProps) {\n const styles = useStyles()\n\n return (\n <Heading\n variant=\"h3\"\n style={styles.headerTitle}\n maxFontSizeMultiplier={MAX_FONT_SIZE_MULTIPLIER_LANDMARK}\n >\n {children}\n </Heading>\n )\n}\n\nFormSheetHeaderTitle.displayName = 'FormSheet.HeaderTitle'\n\n// ====================================\n// ====== FormSheetHeaderActions ======\n// ====================================\n\ninterface FormSheetHeaderActionsProps {\n children: ReactNode\n}\n\nfunction FormSheetHeaderActions({ children }: FormSheetHeaderActionsProps) {\n const styles = useStyles()\n\n return <View style={styles.headerActions}>{children}</View>\n}\n\nFormSheetHeaderActions.displayName = 'FormSheet.HeaderActions'\n\n// ===========================================\n// ====== FormSheetHeaderTextButton ==========\n// ===========================================\n\n// We are omitting `onLongPress` because we are instead supporting `accessibilityShowsLargeContentViewer`.\n// This is triggered by an `onLongPress` event when an iOS device is in Apple's accessible font scale range.\n// Triggering this prop will display an almost full screen iOS a11y button.\ninterface FormSheetHeaderTextButtonProps\n extends Omit<TextButtonProps, 'maxFontSizeMultiplier' | 'onLongPress'> {\n children: string\n}\n\nfunction FormSheetHeaderTextButton(props: FormSheetHeaderTextButtonProps) {\n return (\n <TextButton\n {...props}\n maxFontSizeMultiplier={MAX_FONT_SIZE_MULTIPLIER_LANDMARK}\n accessibilityShowsLargeContentViewer\n accessibilityLargeContentTitle={props.children}\n />\n )\n}\n\nFormSheetHeaderTextButton.displayName = 'FormSheet.HeaderTextButton'\n\n// =========================================\n// ====== FormSheetHeaderButton ============\n// =========================================\n\n// Same `onLongPress`note as `FormSheetHeaderTextButtonProps`\ninterface FormSheetHeaderButtonProps\n extends Omit<ButtonProps, 'maxFontSizeMultiplier' | 'onLongPress'> {}\n\nfunction FormSheetHeaderButton(props: FormSheetHeaderButtonProps) {\n return (\n <Button\n {...props}\n maxFontSizeMultiplier={MAX_FONT_SIZE_MULTIPLIER_LANDMARK}\n accessibilityShowsLargeContentViewer\n accessibilityLargeContentTitle={props.title}\n />\n )\n}\n\nFormSheetHeaderButton.displayName = 'FormSheet.HeaderButton'\n\n// ====================================\n// ====== ActionsFormSheetAction ======\n// ====================================\n\nconst FORM_SHEET_ACTION_APPEARANCES = {\n neutral: 'neutral',\n danger: 'danger',\n} as const\n\ntype FormSheetActionAppearanceUnion =\n (typeof FORM_SHEET_ACTION_APPEARANCES)[keyof typeof FORM_SHEET_ACTION_APPEARANCES]\n\ninterface FormSheetActionProps {\n title: string\n iconName?: IconString\n onPress: () => void\n accessibilityLabel?: string\n accessibilityHint?: string\n accessibilityRole?: AccessibilityRole\n appearance?: FormSheetActionAppearanceUnion\n disabled?: boolean\n}\n\nfunction FormSheetAction({\n title,\n iconName,\n onPress,\n accessibilityLabel,\n accessibilityHint,\n accessibilityRole = 'button',\n appearance = 'neutral',\n disabled = false,\n}: FormSheetActionProps) {\n const styles = useStyles({ appearance })\n\n return (\n <PlatformPressable\n onPress={onPress}\n accessibilityLabel={accessibilityLabel}\n accessibilityHint={accessibilityHint}\n accessibilityRole={accessibilityRole}\n style={styles.actionPressable}\n disabled={disabled}\n >\n {iconName && (\n <Icon name={iconName} size={16} accessibilityElementsHidden style={styles.actionIcon} />\n )}\n <Text style={styles.actionTitle}>{title}</Text>\n </PlatformPressable>\n )\n}\n\nFormSheetAction.displayName = 'FormSheet.Action'\n\n// ==================================\n// ====== Styles ====================\n// ==================================\n\ninterface Styles {\n appearance?: FormSheetActionAppearanceUnion\n}\n\nconst useStyles = ({ appearance = 'neutral' }: Styles = {}) => {\n const { colors } = useTheme()\n const { height } = useWindowDimensions()\n const { bottom, top } = useSafeAreaInsets()\n const headerHeight = useHeaderHeight()\n\n const containerHeight = Platform.select({\n ios: height - top - headerHeight,\n default: null,\n })\n\n const appearanceColorsMap = {\n neutral: {\n iconColor: colors.iconColorDefaultPrimary,\n textColor: colors.textColorDefaultPrimary,\n },\n danger: {\n iconColor: colors.fillColorStatusErrorMedium,\n textColor: colors.fillColorStatusErrorMedium,\n },\n }\n\n return StyleSheet.create({\n container: {\n justifyContent: 'flex-start',\n paddingBottom: bottom,\n width: '100%',\n backgroundColor: colors.fillColorNeutral100Inverted,\n height: containerHeight,\n ...Platform.select({\n ios: {\n flexGrow: 1, // Ensures the FormSheet children respond to the formsheet height changing on iOS\n },\n android: {\n maxHeight: '100%', // Ensures lists to scroll on Android\n },\n }),\n },\n androidSheetGrabber: {\n position: 'absolute',\n top: 5,\n width: 34,\n height: 5,\n backgroundColor: colors.fillColorNeutral040,\n borderRadius: 100,\n alignSelf: 'center',\n },\n content: {\n ...Platform.select({\n android: {\n maxHeight: '100%', // Ensures content above a list (e.g. FormSheet.Header) don't subtract from the FormSheet's height\n },\n }),\n },\n header: {\n paddingHorizontal: 16,\n paddingTop: 20,\n paddingBottom: 16,\n backgroundColor: colors.fillColorNeutral100Inverted,\n gap: 16,\n borderBottomWidth: 1,\n borderBottomColor: colors.borderColorDefaultBase,\n },\n headerContent: {\n flexDirection: 'row',\n alignItems: 'center',\n justifyContent: 'space-between',\n },\n headerTitle: {\n textAlign: 'left',\n flex: 1,\n },\n headerActions: {\n flexDirection: 'row',\n alignItems: 'center',\n gap: 16,\n },\n actionPressable: {\n flexDirection: 'row',\n alignItems: 'center',\n paddingVertical: 12,\n paddingHorizontal: 16,\n gap: 8,\n },\n actionIcon: {\n color: appearanceColorsMap[appearance].iconColor,\n },\n actionTitle: {\n color: appearanceColorsMap[appearance].textColor,\n },\n })\n}\n"]}
@@ -21,4 +21,5 @@ export * from './use_submit_age_check';
21
21
  export * from './use_organization';
22
22
  export * from './use_product_analytics';
23
23
  export * from './use_people_person';
24
+ export * from './use_new_conversation_entry';
24
25
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/hooks/index.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAA;AACnC,cAAc,yCAAyC,CAAA;AACvD,cAAc,aAAa,CAAA;AAC3B,cAAc,oBAAoB,CAAA;AAClC,cAAc,sBAAsB,CAAA;AACpC,cAAc,oBAAoB,CAAA;AAClC,cAAc,kBAAkB,CAAA;AAChC,cAAc,mCAAmC,CAAA;AACjD,cAAc,wBAAwB,CAAA;AACtC,cAAc,kBAAkB,CAAA;AAChC,cAAc,qBAAqB,CAAA;AACnC,cAAc,cAAc,CAAA;AAC5B,cAAc,WAAW,CAAA;AACzB,cAAc,kBAAkB,CAAA;AAChC,cAAc,+BAA+B,CAAA;AAC7C,cAAc,+BAA+B,CAAA;AAC7C,cAAc,gCAAgC,CAAA;AAC9C,cAAc,wBAAwB,CAAA;AACtC,cAAc,gCAAgC,CAAA;AAC9C,cAAc,wBAAwB,CAAA;AACtC,cAAc,oBAAoB,CAAA;AAClC,cAAc,yBAAyB,CAAA;AACvC,cAAc,qBAAqB,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/hooks/index.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAA;AACnC,cAAc,yCAAyC,CAAA;AACvD,cAAc,aAAa,CAAA;AAC3B,cAAc,oBAAoB,CAAA;AAClC,cAAc,sBAAsB,CAAA;AACpC,cAAc,oBAAoB,CAAA;AAClC,cAAc,kBAAkB,CAAA;AAChC,cAAc,mCAAmC,CAAA;AACjD,cAAc,wBAAwB,CAAA;AACtC,cAAc,kBAAkB,CAAA;AAChC,cAAc,qBAAqB,CAAA;AACnC,cAAc,cAAc,CAAA;AAC5B,cAAc,WAAW,CAAA;AACzB,cAAc,kBAAkB,CAAA;AAChC,cAAc,+BAA+B,CAAA;AAC7C,cAAc,+BAA+B,CAAA;AAC7C,cAAc,gCAAgC,CAAA;AAC9C,cAAc,wBAAwB,CAAA;AACtC,cAAc,gCAAgC,CAAA;AAC9C,cAAc,wBAAwB,CAAA;AACtC,cAAc,oBAAoB,CAAA;AAClC,cAAc,yBAAyB,CAAA;AACvC,cAAc,qBAAqB,CAAA;AACnC,cAAc,8BAA8B,CAAA"}
@@ -21,4 +21,5 @@ export * from './use_submit_age_check';
21
21
  export * from './use_organization';
22
22
  export * from './use_product_analytics';
23
23
  export * from './use_people_person';
24
+ export * from './use_new_conversation_entry';
24
25
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/hooks/index.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAA;AACnC,cAAc,yCAAyC,CAAA;AACvD,cAAc,aAAa,CAAA;AAC3B,cAAc,oBAAoB,CAAA;AAClC,cAAc,sBAAsB,CAAA;AACpC,cAAc,oBAAoB,CAAA;AAClC,cAAc,kBAAkB,CAAA;AAChC,cAAc,mCAAmC,CAAA;AACjD,cAAc,wBAAwB,CAAA;AACtC,cAAc,kBAAkB,CAAA;AAChC,cAAc,qBAAqB,CAAA;AACnC,cAAc,cAAc,CAAA;AAC5B,cAAc,WAAW,CAAA;AACzB,cAAc,kBAAkB,CAAA;AAChC,cAAc,+BAA+B,CAAA;AAC7C,cAAc,+BAA+B,CAAA;AAC7C,cAAc,gCAAgC,CAAA;AAC9C,cAAc,wBAAwB,CAAA;AACtC,cAAc,gCAAgC,CAAA;AAC9C,cAAc,wBAAwB,CAAA;AACtC,cAAc,oBAAoB,CAAA;AAClC,cAAc,yBAAyB,CAAA;AACvC,cAAc,qBAAqB,CAAA","sourcesContent":["export * from './use_async_storage'\nexport * from './use_animated_message_background_color'\nexport * from './use_theme'\nexport * from './use_suspense_api'\nexport * from './use_current_person'\nexport * from './use_deleting_ids'\nexport * from './use_font_scale'\nexport * from './use_create_android_ripple_color'\nexport * from './use_chat_permissions'\nexport * from './use_api_client'\nexport * from './use_groups_groups'\nexport * from './use_groups'\nexport * from './use_api'\nexport * from './use_api_client'\nexport * from './use_message_reaction_toggle'\nexport * from './use_interaction_ghost_color'\nexport * from './use_at_font_scale_breakpoint'\nexport * from './use_qualified_by_age'\nexport * from './use_scalable_number_of_lines'\nexport * from './use_submit_age_check'\nexport * from './use_organization'\nexport * from './use_product_analytics'\nexport * from './use_people_person'\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/hooks/index.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAA;AACnC,cAAc,yCAAyC,CAAA;AACvD,cAAc,aAAa,CAAA;AAC3B,cAAc,oBAAoB,CAAA;AAClC,cAAc,sBAAsB,CAAA;AACpC,cAAc,oBAAoB,CAAA;AAClC,cAAc,kBAAkB,CAAA;AAChC,cAAc,mCAAmC,CAAA;AACjD,cAAc,wBAAwB,CAAA;AACtC,cAAc,kBAAkB,CAAA;AAChC,cAAc,qBAAqB,CAAA;AACnC,cAAc,cAAc,CAAA;AAC5B,cAAc,WAAW,CAAA;AACzB,cAAc,kBAAkB,CAAA;AAChC,cAAc,+BAA+B,CAAA;AAC7C,cAAc,+BAA+B,CAAA;AAC7C,cAAc,gCAAgC,CAAA;AAC9C,cAAc,wBAAwB,CAAA;AACtC,cAAc,gCAAgC,CAAA;AAC9C,cAAc,wBAAwB,CAAA;AACtC,cAAc,oBAAoB,CAAA;AAClC,cAAc,yBAAyB,CAAA;AACvC,cAAc,qBAAqB,CAAA;AACnC,cAAc,8BAA8B,CAAA","sourcesContent":["export * from './use_async_storage'\nexport * from './use_animated_message_background_color'\nexport * from './use_theme'\nexport * from './use_suspense_api'\nexport * from './use_current_person'\nexport * from './use_deleting_ids'\nexport * from './use_font_scale'\nexport * from './use_create_android_ripple_color'\nexport * from './use_chat_permissions'\nexport * from './use_api_client'\nexport * from './use_groups_groups'\nexport * from './use_groups'\nexport * from './use_api'\nexport * from './use_api_client'\nexport * from './use_message_reaction_toggle'\nexport * from './use_interaction_ghost_color'\nexport * from './use_at_font_scale_breakpoint'\nexport * from './use_qualified_by_age'\nexport * from './use_scalable_number_of_lines'\nexport * from './use_submit_age_check'\nexport * from './use_organization'\nexport * from './use_product_analytics'\nexport * from './use_people_person'\nexport * from './use_new_conversation_entry'\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"use_conversation.d.ts","sourceRoot":"","sources":["../../src/hooks/use_conversation.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAA;AAO5D,eAAO,MAAM,0BAA0B,wBAAyB;IAAE,eAAe,EAAE,MAAM,CAAA;CAAE;;;;;;;;;;;;;CA2CzF,CAAA;AAEF,eAAO,MAAM,eAAe,wBAAyB;IAAE,eAAe,EAAE,MAAM,CAAA;CAAE;;;;;;;;;;;;;;;;;;;;;;;;;;CAI/E,CAAA;AAED,eAAO,MAAM,mBAAmB,wBAAyB;IAAE,eAAe,EAAE,MAAM,CAAA;CAAE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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;;;;;;;;;;;;;CA6C7F,CAAA"}
@@ -36,7 +36,12 @@ export const getConversationRequestArgs = ({ conversation_id }) => ({
36
36
  'can_reply',
37
37
  'can_delete_non_authored_messages',
38
38
  ],
39
- ConversationMembership: ['last_read_message_sort_key'],
39
+ ConversationMembership: [
40
+ 'last_read_message_sort_key',
41
+ 'notification_level',
42
+ 'notification_level_description',
43
+ 'notification_level_options',
44
+ ],
40
45
  ConversationBadge: ['app_name', 'pco_resource_type', 'text'],
41
46
  Group: ['type', 'id', 'links', 'name', 'source_app_name', 'source_type'],
42
47
  },
@@ -1 +1 @@
1
- {"version":3,"file":"use_conversation.js","sourceRoot":"","sources":["../../src/hooks/use_conversation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAA;AACnE,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AAEhC,OAAO,EAAE,kBAAkB,EAAE,MAAM,iCAAiC,CAAA;AACpE,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAA;AAC/C,OAAO,EAAE,kBAAkB,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAA;AACvE,OAAO,EAAE,2BAA2B,EAAE,MAAM,+BAA+B,CAAA;AAC3E,OAAO,EAAE,MAAM,EAAE,MAAM,0BAA0B,CAAA;AAEjD,MAAM,CAAC,MAAM,0BAA0B,GAAG,CAAC,EAAE,eAAe,EAA+B,EAAE,EAAE,CAAC,CAAC;IAC/F,GAAG,EAAE,qBAAqB,eAAe,EAAE;IAC3C,IAAI,EAAE;QACJ,MAAM,EAAE;YACN,YAAY,EAAE;gBACZ,oBAAoB;gBACpB,YAAY;gBACZ,QAAQ;gBACR,yBAAyB;gBACzB,QAAQ;gBACR,wBAAwB;gBACxB,0BAA0B;gBAC1B,yBAAyB;gBACzB,2BAA2B;gBAC3B,8BAA8B;gBAC9B,qBAAqB;gBACrB,gBAAgB;gBAChB,OAAO;gBACP,kBAAkB;gB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Q,EAAE,CAAA;AACpE,CAAC,CAAA","sourcesContent":["import { useMutation, useQueryClient } from '@tanstack/react-query'\nimport { useState } from 'react'\nimport { ApiResource, ConversationResource } from '../types'\nimport { transformGetToPost } from '../utils/client/request_helpers'\nimport { useApiClient } from './use_api_client'\nimport { getRequestQueryKey, useSuspenseGet } from './use_suspense_api'\nimport { getConversationsRequestArgs } from '../utils/request/conversation'\nimport { Haptic } from '../utils/native_adapters'\n\nexport const getConversationRequestArgs = ({ conversation_id }: { conversation_id: number }) => ({\n url: `/me/conversations/${conversation_id}`,\n data: {\n fields: {\n Conversation: [\n 'analytics_metadata',\n 'created_at',\n 'badges',\n 'conversation_membership',\n 'groups',\n 'last_message_author_id',\n 'last_message_author_name',\n 'last_message_created_at',\n 'last_message_text_preview',\n 'latest_read_message_sort_key',\n 'preview_avatar_urls',\n 'member_ability',\n 'muted',\n 'replies_disabled',\n 'title',\n 'unread_count',\n 'updated_at',\n ],\n AnalyticsMetadata: ['metadata'],\n MemberAbility: [\n 'can_update',\n 'can_delete',\n 'leader',\n 'can_reply',\n 'can_delete_non_authored_messages',\n ],\n ConversationMembership: ['last_read_message_sort_key'],\n ConversationBadge: ['app_name', 'pco_resource_type', 'text'],\n Group: ['type', 'id', 'links', 'name', 'source_app_name', 'source_type'],\n },\n include: [\n 'badges',\n 'conversation_membership',\n 'member_ability',\n 'groups',\n 'analytics_metadata',\n ],\n },\n})\n\nexport const useConversation = ({ conversation_id }: { conversation_id: number }) => {\n const args = getConversationRequestArgs({ conversation_id })\n\n return useSuspenseGet<ConversationResource>(args)\n}\n\nexport const useConversationMute = ({ conversation_id }: { conversation_id: number }) => {\n const apiClient = useApiClient()\n const queryClient = useQueryClient()\n const requestArgs = getConversationRequestArgs({ conversation_id })\n const queryKey = getRequestQueryKey(requestArgs)\n const { data: conversation } = useConversation({ conversation_id })\n const [value, setValue] = useState<boolean>(conversation.muted)\n\n const { mutate: setMuted, ...mutation } = useMutation({\n onMutate: async (muted: boolean) => {\n return queryClient.setQueryData<ApiResource<ConversationResource>>(queryKey, prev => {\n if (!prev?.data) return prev\n setValue(muted)\n prev.data.muted = muted\n\n return prev\n })\n },\n mutationKey: ['muteConversation'],\n mutationFn: async (muted: boolean) => {\n const action = muted ? 'mute' : 'unmute'\n\n return apiClient.chat.post<ApiResource<ConversationResource>>({\n url: `/me/conversations/${conversation_id}/${action}`,\n data: { data: { type: '', attributes: {} }, fields: { Conversation: 'muted' } },\n })\n },\n onSuccess: (response: ApiResource<ConversationResource>) => {\n queryClient.invalidateQueries({ queryKey: ['/me/conversations'] })\n queryClient.setQueryData<ApiResource<ConversationResource>>(queryKey, prev => {\n if (!prev?.data) return prev\n\n // Posting to the mute action endpoint can't return all the fields\n // so we need to set only the fields we require\n prev.data.muted = response.data.muted\n setValue(response.data.muted)\n\n return prev\n })\n },\n })\n\n return { muted: value, setMuted, ...mutation }\n}\n\nexport const useConversationUpdate = ({ conversation_id }: { conversation_id: number }) => {\n const apiClient = useApiClient()\n const queryClient = useQueryClient()\n const requestArgs = getConversationRequestArgs({ conversation_id })\n const queryKey = getRequestQueryKey(requestArgs)\n\n return useMutation({\n onMutate: async (update: Partial<ConversationResource>) => {\n queryClient.setQueryData<ApiResource<ConversationResource>>(queryKey, prev => {\n if (prev?.data) {\n prev.data = {\n ...prev.data,\n ...update,\n }\n }\n\n return prev\n })\n },\n mutationKey: ['mutateConversation'],\n mutationFn: async (update: Partial<ConversationResource>) => {\n const postArgs = transformGetToPost(requestArgs).data\n return apiClient.chat.patch<ApiResource<ConversationResource>>({\n url: `/me/conversations/${conversation_id}/`,\n data: { data: { type: '', attributes: update }, ...postArgs },\n })\n },\n onSuccess: response => {\n queryClient.setQueryData<ApiResource<ConversationResource>>(queryKey, () => response)\n },\n })\n}\n\nexport const useConversationDelete = ({ conversation_id }: { conversation_id: number }) => {\n const apiClient = useApiClient()\n const queryClient = useQueryClient()\n const { url } = getConversationsRequestArgs()\n\n return useMutation({\n mutationKey: ['deleteConversation'],\n mutationFn: async () => {\n return apiClient.chat.delete({\n url: `/me/conversations/${conversation_id}`,\n })\n },\n onSuccess: () => {\n queryClient.invalidateQueries({ queryKey: [url] })\n Haptic.notificationSuccess()\n },\n })\n}\n\nexport const useConversationDisableReplies = ({ conversation_id }: { conversation_id: number }) => {\n const apiClient = useApiClient()\n const queryClient = useQueryClient()\n const requestArgs = getConversationRequestArgs({ conversation_id })\n const queryKey = getRequestQueryKey(requestArgs)\n const { data: conversation } = useConversation({ conversation_id })\n const [value, setValue] = useState<boolean>(conversation.repliesDisabled)\n\n const { mutate: setRepliesDisabled, ...mutation } = useMutation({\n onMutate: async (repliesDisabled: boolean) => {\n return queryClient.setQueryData<ApiResource<ConversationResource>>(queryKey, prev => {\n if (!prev?.data) return prev\n setValue(repliesDisabled)\n prev.data.repliesDisabled = repliesDisabled\n\n return prev\n })\n },\n mutationKey: ['disableRepliesConversation'],\n mutationFn: async (repliesDisabled: boolean) => {\n return apiClient.chat.patch<ApiResource<ConversationResource>>({\n url: `/me/conversations/${conversation_id}`,\n data: {\n data: {\n type: 'Conversation',\n attributes: {\n replies_disabled: repliesDisabled,\n },\n },\n },\n })\n },\n onSuccess: (response: ApiResource<ConversationResource>) => {\n queryClient.setQueryData<ApiResource<ConversationResource>>(queryKey, prev => {\n if (!prev?.data) return prev\n\n prev.data.repliesDisabled = response.data.repliesDisabled\n setValue(response.data.repliesDisabled)\n\n return prev\n })\n },\n })\n\n return { repliesDisabled: value, setRepliesDisabled, ...mutation }\n}\n"]}
1
+ {"version":3,"file":"use_conversation.js","sourceRoot":"","sources":["../../src/hooks/use_conversation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAA;AACnE,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AAEhC,OAAO,EAAE,kBAAkB,EAAE,MAAM,iCAAiC,CAAA;AACpE,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAA;AAC/C,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,IAAI,EAAE;oBACJ,IAAI,EAAE;wBACJ,IAAI,EAAE,cAAc;wBACpB,UAAU,EAAE;4BACV,gBAAgB,EAAE,eAAe;yBAClC;qBACF;iBACF;aACF,CAAC,CAAA;QACJ,CAAC;QACD,SAAS,EAAE,CAAC,QAA2C,EAAE,EAAE;YACzD,WAAW,CAAC,YAAY,CAAoC,QAAQ,EAAE,IAAI,CAAC,EAAE;gBAC3E,IAAI,CAAC,IAAI,EAAE,IAAI;oBAAE,OAAO,IAAI,CAAA;gBAE5B,IAAI,CAAC,IAAI,CAAC,eAAe,GAAG,QAAQ,CAAC,IAAI,CAAC,eAAe,CAAA;gBACzD,QAAQ,CAAC,QAAQ,CAAC,IAAI,CAAC,eAAe,CAAC,CAAA;gBAEvC,OAAO,IAAI,CAAA;YACb,CAAC,CAAC,CAAA;QACJ,CAAC;KACF,CAAC,CAAA;IAEF,OAAO,EAAE,eAAe,EAAE,KAAK,EAAE,kBAAkB,EAAE,GAAG,QAAQ,EAAE,CAAA;AACpE,CAAC,CAAA","sourcesContent":["import { useMutation, useQueryClient } from '@tanstack/react-query'\nimport { useState } from 'react'\nimport { ApiResource, ConversationResource } from '../types'\nimport { transformGetToPost } from '../utils/client/request_helpers'\nimport { useApiClient } from './use_api_client'\nimport { getRequestQueryKey, useSuspenseGet } from './use_suspense_api'\nimport { getConversationsRequestArgs } from '../utils/request/conversation'\nimport { Haptic } from '../utils/native_adapters'\n\nexport const getConversationRequestArgs = ({ conversation_id }: { conversation_id: number }) => ({\n url: `/me/conversations/${conversation_id}`,\n data: {\n fields: {\n Conversation: [\n 'analytics_metadata',\n 'created_at',\n 'badges',\n 'conversation_membership',\n 'groups',\n 'last_message_author_id',\n 'last_message_author_name',\n 'last_message_created_at',\n 'last_message_text_preview',\n 'latest_read_message_sort_key',\n 'preview_avatar_urls',\n 'member_ability',\n 'muted',\n 'replies_disabled',\n 'title',\n 'unread_count',\n 'updated_at',\n ],\n AnalyticsMetadata: ['metadata'],\n MemberAbility: [\n 'can_update',\n 'can_delete',\n 'leader',\n 'can_reply',\n 'can_delete_non_authored_messages',\n ],\n ConversationMembership: [\n 'last_read_message_sort_key',\n 'notification_level',\n 'notification_level_description',\n 'notification_level_options',\n ],\n ConversationBadge: ['app_name', 'pco_resource_type', 'text'],\n Group: ['type', 'id', 'links', 'name', 'source_app_name', 'source_type'],\n },\n include: [\n 'badges',\n 'conversation_membership',\n 'member_ability',\n 'groups',\n 'analytics_metadata',\n ],\n },\n})\n\nexport const useConversation = ({ conversation_id }: { conversation_id: number }) => {\n const args = getConversationRequestArgs({ conversation_id })\n\n return useSuspenseGet<ConversationResource>(args)\n}\n\nexport const useConversationMute = ({ conversation_id }: { conversation_id: number }) => {\n const apiClient = useApiClient()\n const queryClient = useQueryClient()\n const requestArgs = getConversationRequestArgs({ conversation_id })\n const queryKey = getRequestQueryKey(requestArgs)\n const { data: conversation } = useConversation({ conversation_id })\n const [value, setValue] = useState<boolean>(conversation.muted)\n\n const { mutate: setMuted, ...mutation } = useMutation({\n onMutate: async (muted: boolean) => {\n return queryClient.setQueryData<ApiResource<ConversationResource>>(queryKey, prev => {\n if (!prev?.data) return prev\n setValue(muted)\n prev.data.muted = muted\n\n return prev\n })\n },\n mutationKey: ['muteConversation'],\n mutationFn: async (muted: boolean) => {\n const action = muted ? 'mute' : 'unmute'\n\n return apiClient.chat.post<ApiResource<ConversationResource>>({\n url: `/me/conversations/${conversation_id}/${action}`,\n data: { data: { type: '', attributes: {} }, fields: { Conversation: 'muted' } },\n })\n },\n onSuccess: (response: ApiResource<ConversationResource>) => {\n queryClient.invalidateQueries({ queryKey: ['/me/conversations'] })\n queryClient.setQueryData<ApiResource<ConversationResource>>(queryKey, prev => {\n if (!prev?.data) return prev\n\n // Posting to the mute action endpoint can't return all the fields\n // so we need to set only the fields we require\n prev.data.muted = response.data.muted\n setValue(response.data.muted)\n\n return prev\n })\n },\n })\n\n return { muted: value, setMuted, ...mutation }\n}\n\nexport const useConversationUpdate = ({ conversation_id }: { conversation_id: number }) => {\n const apiClient = useApiClient()\n const queryClient = useQueryClient()\n const requestArgs = getConversationRequestArgs({ conversation_id })\n const queryKey = getRequestQueryKey(requestArgs)\n\n return useMutation({\n onMutate: async (update: Partial<ConversationResource>) => {\n queryClient.setQueryData<ApiResource<ConversationResource>>(queryKey, prev => {\n if (prev?.data) {\n prev.data = {\n ...prev.data,\n ...update,\n }\n }\n\n return prev\n })\n },\n mutationKey: ['mutateConversation'],\n mutationFn: async (update: Partial<ConversationResource>) => {\n const postArgs = transformGetToPost(requestArgs).data\n return apiClient.chat.patch<ApiResource<ConversationResource>>({\n url: `/me/conversations/${conversation_id}/`,\n data: { data: { type: '', attributes: update }, ...postArgs },\n })\n },\n onSuccess: response => {\n queryClient.setQueryData<ApiResource<ConversationResource>>(queryKey, () => response)\n },\n })\n}\n\nexport const useConversationDelete = ({ conversation_id }: { conversation_id: number }) => {\n const apiClient = useApiClient()\n const queryClient = useQueryClient()\n const { url } = getConversationsRequestArgs()\n\n return useMutation({\n mutationKey: ['deleteConversation'],\n mutationFn: async () => {\n return apiClient.chat.delete({\n url: `/me/conversations/${conversation_id}`,\n })\n },\n onSuccess: () => {\n queryClient.invalidateQueries({ queryKey: [url] })\n Haptic.notificationSuccess()\n },\n })\n}\n\nexport const useConversationDisableReplies = ({ conversation_id }: { conversation_id: number }) => {\n const apiClient = useApiClient()\n const queryClient = useQueryClient()\n const requestArgs = getConversationRequestArgs({ conversation_id })\n const queryKey = getRequestQueryKey(requestArgs)\n const { data: conversation } = useConversation({ conversation_id })\n const [value, setValue] = useState<boolean>(conversation.repliesDisabled)\n\n const { mutate: setRepliesDisabled, ...mutation } = useMutation({\n onMutate: async (repliesDisabled: boolean) => {\n return queryClient.setQueryData<ApiResource<ConversationResource>>(queryKey, prev => {\n if (!prev?.data) return prev\n setValue(repliesDisabled)\n prev.data.repliesDisabled = repliesDisabled\n\n return prev\n })\n },\n mutationKey: ['disableRepliesConversation'],\n mutationFn: async (repliesDisabled: boolean) => {\n return apiClient.chat.patch<ApiResource<ConversationResource>>({\n url: `/me/conversations/${conversation_id}`,\n data: {\n data: {\n type: 'Conversation',\n attributes: {\n replies_disabled: repliesDisabled,\n },\n },\n },\n })\n },\n onSuccess: (response: ApiResource<ConversationResource>) => {\n queryClient.setQueryData<ApiResource<ConversationResource>>(queryKey, prev => {\n if (!prev?.data) return prev\n\n prev.data.repliesDisabled = response.data.repliesDisabled\n setValue(response.data.repliesDisabled)\n\n return prev\n })\n },\n })\n\n return { repliesDisabled: value, setRepliesDisabled, ...mutation }\n}\n"]}
@@ -0,0 +1,5 @@
1
+ import { ApiResource, ConversationMembershipResource } from '../types';
2
+ export declare const useConversationMembershipUpdate: ({ conversation_id, }: {
3
+ conversation_id: number;
4
+ }) => import("@tanstack/react-query").UseMutationResult<ApiResource<ConversationMembershipResource>, Error, Partial<ConversationMembershipResource>, void>;
5
+ //# sourceMappingURL=use_conversation_membership.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use_conversation_membership.d.ts","sourceRoot":"","sources":["../../src/hooks/use_conversation_membership.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,8BAA8B,EAAwB,MAAM,UAAU,CAAA;AAO5F,eAAO,MAAM,+BAA+B,yBAEzC;IACD,eAAe,EAAE,MAAM,CAAA;CACxB,yJAyCA,CAAA"}
@@ -0,0 +1,54 @@
1
+ import { useMutation, useQueryClient } from '@tanstack/react-query';
2
+ import { useApiClient } from './use_api_client';
3
+ import { getConversationRequestArgs } from './use_conversation';
4
+ import { getRequestQueryKey } from './use_suspense_api';
5
+ import { deepSnakeCaseKeys } from '../utils/deep_snake_case_keys';
6
+ import { throwResponseError } from '../utils/response_error';
7
+ export const useConversationMembershipUpdate = ({ conversation_id, }) => {
8
+ const apiClient = useApiClient();
9
+ const queryClient = useQueryClient();
10
+ const requestArgs = getConversationRequestArgs({ conversation_id });
11
+ const conversationMembershipFields = requestArgs.data.fields.ConversationMembership.join(',');
12
+ const queryKey = getRequestQueryKey(requestArgs);
13
+ return useMutation({
14
+ throwOnError: true,
15
+ onMutate: async (attributes) => {
16
+ queryClient.setQueryData(queryKey, updateConversationMembershipAttributes(attributes));
17
+ },
18
+ mutationKey: ['updateConversationMembership', conversation_id],
19
+ mutationFn: async (attributes) => {
20
+ return apiClient.chat
21
+ .patch({
22
+ url: `/me/conversation/${conversation_id}/conversation_membership`,
23
+ data: {
24
+ data: {
25
+ type: 'ConversationMembership',
26
+ attributes: deepSnakeCaseKeys(attributes),
27
+ },
28
+ fields: {
29
+ ConversationMembership: conversationMembershipFields,
30
+ },
31
+ },
32
+ })
33
+ .catch(throwResponseError);
34
+ },
35
+ onSuccess: response => {
36
+ const membership = response.data;
37
+ queryClient.setQueryData(queryKey, updateConversationMembershipAttributes(membership));
38
+ },
39
+ });
40
+ };
41
+ const updateConversationMembershipAttributes = (membership) => conversationData => mergeConversationMembership(conversationData, membership);
42
+ const mergeConversationMembership = (conversationData, membership) => {
43
+ if (!conversationData)
44
+ return undefined;
45
+ const previousMembership = conversationData.data.conversationMembership || {};
46
+ return {
47
+ ...conversationData,
48
+ conversationMembership: {
49
+ ...previousMembership,
50
+ ...membership,
51
+ },
52
+ };
53
+ };
54
+ //# sourceMappingURL=use_conversation_membership.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use_conversation_membership.js","sourceRoot":"","sources":["../../src/hooks/use_conversation_membership.ts"],"names":[],"mappings":"AAAA,OAAO,EAAW,WAAW,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAA;AAE5E,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAA;AAC/C,OAAO,EAAE,0BAA0B,EAAE,MAAM,oBAAoB,CAAA;AAC/D,OAAO,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAA;AACvD,OAAO,EAAE,iBAAiB,EAAE,MAAM,+BAA+B,CAAA;AACjE,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAA;AAE5D,MAAM,CAA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CAAsC,GAC1C,CACE,UAAmD,EAInD,EAAE,CACJ,gBAAgB,CAAC,EAAE,CACjB,2BAA2B,CAAC,gBAAgB,EAAE,UAAU,CAAC,CAAA;AAE7D,MAAM,2BAA2B,GAAG,CAClC,gBAA+D,EAC/D,UAAmD,EACnD,EAAE;IACF,IAAI,CAAC,gBAAgB;QAAE,OAAO,SAAS,CAAA;IAEvC,MAAM,kBAAkB,GACtB,gBAAgB,CAAC,IAAI,CAAC,sBAAsB,IAAI,EAAE,CAAA;IAEpD,OAAO;QACL,GAAG,gBAAgB;QACnB,sBAAsB,EAAE;YACtB,GAAG,kBAAkB;YACrB,GAAG,UAAU;SACd;KACF,CAAA;AACH,CAAC,CAAA","sourcesContent":["import { Updater, useMutation, useQueryClient } from '@tanstack/react-query'\nimport { ApiResource, ConversationMembershipResource, ConversationResource } from '../types'\nimport { useApiClient } from './use_api_client'\nimport { getConversationRequestArgs } from './use_conversation'\nimport { getRequestQueryKey } from './use_suspense_api'\nimport { deepSnakeCaseKeys } from '../utils/deep_snake_case_keys'\nimport { throwResponseError } from '../utils/response_error'\n\nexport const useConversationMembershipUpdate = ({\n conversation_id,\n}: {\n conversation_id: number\n}) => {\n const apiClient = useApiClient()\n const queryClient = useQueryClient()\n const requestArgs = getConversationRequestArgs({ conversation_id })\n const conversationMembershipFields = requestArgs.data.fields.ConversationMembership.join(',')\n const queryKey = getRequestQueryKey(requestArgs)\n\n return useMutation({\n throwOnError: true,\n onMutate: async (attributes: Partial<ConversationMembershipResource>) => {\n queryClient.setQueryData<ApiResource<ConversationResource>>(\n queryKey,\n updateConversationMembershipAttributes(attributes)\n )\n },\n mutationKey: ['updateConversationMembership', conversation_id],\n mutationFn: async (attributes: Partial<ConversationMembershipResource>) => {\n return apiClient.chat\n .patch<ApiResource<ConversationMembershipResource>>({\n url: `/me/conversation/${conversation_id}/conversation_membership`,\n data: {\n data: {\n type: 'ConversationMembership',\n attributes: deepSnakeCaseKeys(attributes),\n },\n fields: {\n ConversationMembership: conversationMembershipFields,\n },\n },\n })\n .catch(throwResponseError)\n },\n onSuccess: response => {\n const membership = response.data\n\n queryClient.setQueryData<ApiResource<ConversationResource>>(\n queryKey,\n updateConversationMembershipAttributes(membership)\n )\n },\n })\n}\n\nconst updateConversationMembershipAttributes =\n (\n membership: Partial<ConversationMembershipResource>\n ): Updater<\n ApiResource<ConversationResource> | undefined,\n ApiResource<ConversationResource> | undefined\n > =>\n conversationData =>\n mergeConversationMembership(conversationData, membership)\n\nconst mergeConversationMembership = (\n conversationData: ApiResource<ConversationResource> | undefined,\n membership: Partial<ConversationMembershipResource>\n) => {\n if (!conversationData) return undefined\n\n const previousMembership: Partial<ConversationMembershipResource> =\n conversationData.data.conversationMembership || {}\n\n return {\n ...conversationData,\n conversationMembership: {\n ...previousMembership,\n ...membership,\n },\n }\n}\n"]}
@@ -5,5 +5,6 @@ export declare function useFeatures(): {
5
5
  };
6
6
  export declare const availableFeatures: {
7
7
  threaded_replies: string;
8
+ message_reporting: string;
8
9
  };
9
10
  //# sourceMappingURL=use_features.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"use_features.d.ts","sourceRoot":"","sources":["../../src/hooks/use_features.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qCAAqC,CAAA;AAG1E,wBAAgB,WAAW;;kCAiBT,MAAM;EASvB;AAED,eAAO,MAAM,iBAAiB;;CAE7B,CAAA"}
1
+ {"version":3,"file":"use_features.d.ts","sourceRoot":"","sources":["../../src/hooks/use_features.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qCAAqC,CAAA;AAG1E,wBAAgB,WAAW;;kCAiBT,MAAM;EASvB;AAED,eAAO,MAAM,iBAAiB;;;CAG7B,CAAA"}
@@ -23,6 +23,7 @@ export function useFeatures() {
23
23
  }
24
24
  export const availableFeatures = {
25
25
  threaded_replies: 'ROLLOUT_MOBILE_threaded_replies_v1',
26
+ message_reporting: 'ROLLOUT_MOBILE_message_reporting',
26
27
  };
27
28
  const stableEmptyFeatures = {
28
29
  data: [],
@@ -1 +1 @@
1
- {"version":3,"file":"use_features.js","sourceRoot":"","sources":["../../src/hooks/use_features.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAA;AACxD,OAAO,EAAE,WAAW,EAAE,MAAM,OAAO,CAAA;AACnC,OAAO,EAAE,sBAAsB,EAAE,mBAAmB,EAAE,MAAM,+BAA+B,CAAA;AAC3F,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAA;AAI/C,MAAM,UAAU,WAAW;IACzB,MAAM,SAAS,GAAG,YAAY,EAAE,CAAA;IAChC,MAAM,WAAW,GAAG,sBAAsB,EAAE,CAAA;IAE5C,MAAM,EAAE,IAAI,EAAE,GAAG,gBAAgB,CAAC;QAChC,QAAQ,EAAE,mBAAmB,EAAE;QAC/B,OAAO,EAAE,GAAG,EAAE;YACZ,OAAO,SAAS,CAAC,IAAI;iBAClB,GAAG,CAAiC,WAAW,CAAC;iBAChD,KAAK,CAAC,GAAG,EAAE,CAAC,mBAAmB,CAAC,CAAA;QACrC,CAAC;QACD,SAAS,EAAE,IAAI,GAAG,EAAE,GAAG,CAAC,EAAE,YAAY;KACvC,CAAC,CAAA;IAEF,MAAM,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAA;IAE1B,MAAM,cAAc,GAAG,WAAW,CAChC,CAAC,WAAmB,EAAE,EAAE,CACtB,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC,OAAO,CAAC,IAAI,KAAK,WAAW,IAAI,OAAO,CAAC,OAAO,CAAC,EAC3E,CAAC,QAAQ,CAAC,CACX,CAAA;IAED,OAAO;QACL,QAAQ;QACR,cAAc;KACf,CAAA;AACH,CAAC;AAED,MAAM,CAAC,MAAM,iBAAiB,GAAG;IAC/B,gBAAgB,EAAE,oCAAoC;CACvD,CAAA;AAED,MAAM,mBAAmB,GAAmC;IAC1D,IAAI,EAAE,EAAE;IACR,KAAK,EAAE,EAAE;IACT,IAAI,EAAE;QACJ,KAAK,EAAE,CAAC;QACR,UAAU,EAAE,CAAC;KACd;CACF,CAAA","sourcesContent":["import { useSuspenseQuery } from '@tanstack/react-query'\nimport { useCallback } from 'react'\nimport { getFeaturesRequestArgs, getFeaturesQueryKey } from '../utils/request/get_features'\nimport { useApiClient } from './use_api_client'\nimport type { FeatureResource } from '../types/resources/feature_resource'\nimport { ApiCollection } from '../types'\n\nexport function useFeatures() {\n const apiClient = useApiClient()\n const requestArgs = getFeaturesRequestArgs()\n\n const { data } = useSuspenseQuery({\n queryKey: getFeaturesQueryKey(),\n queryFn: () => {\n return apiClient.chat\n .get<ApiCollection<FeatureResource>>(requestArgs)\n .catch(() => stableEmptyFeatures)\n },\n staleTime: 1000 * 60 * 5, // 5 minutes\n })\n\n const features = data.data\n\n const featureEnabled = useCallback(\n (featureName: string) =>\n features.some(feature => feature.name === featureName && feature.enabled),\n [features]\n )\n\n return {\n features,\n featureEnabled,\n }\n}\n\nexport const availableFeatures = {\n threaded_replies: 'ROLLOUT_MOBILE_threaded_replies_v1',\n}\n\nconst stableEmptyFeatures: ApiCollection<FeatureResource> = {\n data: [],\n links: {},\n meta: {\n count: 0,\n totalCount: 0,\n },\n}\n"]}
1
+ {"version":3,"file":"use_features.js","sourceRoot":"","sources":["../../src/hooks/use_features.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAA;AACxD,OAAO,EAAE,WAAW,EAAE,MAAM,OAAO,CAAA;AACnC,OAAO,EAAE,sBAAsB,EAAE,mBAAmB,EAAE,MAAM,+BAA+B,CAAA;AAC3F,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAA;AAI/C,MAAM,UAAU,WAAW;IACzB,MAAM,SAAS,GAAG,YAAY,EAAE,CAAA;IAChC,MAAM,WAAW,GAAG,sBAAsB,EAAE,CAAA;IAE5C,MAAM,EAAE,IAAI,EAAE,GAAG,gBAAgB,CAAC;QAChC,QAAQ,EAAE,mBAAmB,EAAE;QAC/B,OAAO,EAAE,GAAG,EAAE;YACZ,OAAO,SAAS,CAAC,IAAI;iBAClB,GAAG,CAAiC,WAAW,CAAC;iBAChD,KAAK,CAAC,GAAG,EAAE,CAAC,mBAAmB,CAAC,CAAA;QACrC,CAAC;QACD,SAAS,EAAE,IAAI,GAAG,EAAE,GAAG,CAAC,EAAE,YAAY;KACvC,CAAC,CAAA;IAEF,MAAM,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAA;IAE1B,MAAM,cAAc,GAAG,WAAW,CAChC,CAAC,WAAmB,EAAE,EAAE,CACtB,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC,OAAO,CAAC,IAAI,KAAK,WAAW,IAAI,OAAO,CAAC,OAAO,CAAC,EAC3E,CAAC,QAAQ,CAAC,CACX,CAAA;IAED,OAAO;QACL,QAAQ;QACR,cAAc;KACf,CAAA;AACH,CAAC;AAED,MAAM,CAAC,MAAM,iBAAiB,GAAG;IAC/B,gBAAgB,EAAE,oCAAoC;IACtD,iBAAiB,EAAE,kCAAkC;CACtD,CAAA;AAED,MAAM,mBAAmB,GAAmC;IAC1D,IAAI,EAAE,EAAE;IACR,KAAK,EAAE,EAAE;IACT,IAAI,EAAE;QACJ,KAAK,EAAE,CAAC;QACR,UAAU,EAAE,CAAC;KACd;CACF,CAAA","sourcesContent":["import { useSuspenseQuery } from '@tanstack/react-query'\nimport { useCallback } from 'react'\nimport { getFeaturesRequestArgs, getFeaturesQueryKey } from '../utils/request/get_features'\nimport { useApiClient } from './use_api_client'\nimport type { FeatureResource } from '../types/resources/feature_resource'\nimport { ApiCollection } from '../types'\n\nexport function useFeatures() {\n const apiClient = useApiClient()\n const requestArgs = getFeaturesRequestArgs()\n\n const { data } = useSuspenseQuery({\n queryKey: getFeaturesQueryKey(),\n queryFn: () => {\n return apiClient.chat\n .get<ApiCollection<FeatureResource>>(requestArgs)\n .catch(() => stableEmptyFeatures)\n },\n staleTime: 1000 * 60 * 5, // 5 minutes\n })\n\n const features = data.data\n\n const featureEnabled = useCallback(\n (featureName: string) =>\n features.some(feature => feature.name === featureName && feature.enabled),\n [features]\n )\n\n return {\n features,\n featureEnabled,\n }\n}\n\nexport const availableFeatures = {\n threaded_replies: 'ROLLOUT_MOBILE_threaded_replies_v1',\n message_reporting: 'ROLLOUT_MOBILE_message_reporting',\n}\n\nconst stableEmptyFeatures: ApiCollection<FeatureResource> = {\n data: [],\n links: {},\n meta: {\n count: 0,\n totalCount: 0,\n },\n}\n"]}
@@ -0,0 +1,3 @@
1
+ export type NewConversationEntryMode = 'select_type' | 'groups' | 'teams' | 'none';
2
+ export declare function useNewConversationEntry(): NewConversationEntryMode;
3
+ //# sourceMappingURL=use_new_conversation_entry.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use_new_conversation_entry.d.ts","sourceRoot":"","sources":["../../src/hooks/use_new_conversation_entry.ts"],"names":[],"mappings":"AAGA,MAAM,MAAM,wBAAwB,GAAG,aAAa,GAAG,QAAQ,GAAG,OAAO,GAAG,MAAM,CAAA;AAElF,wBAAgB,uBAAuB,IAAI,wBAAwB,CAyBlE"}
@@ -0,0 +1,20 @@
1
+ import { useMemo } from 'react';
2
+ import { useAppGrants } from './use_chat_permissions';
3
+ export function useNewConversationEntry() {
4
+ const appGrants = useAppGrants();
5
+ return useMemo(() => {
6
+ const canCreateGroupsConversations = appGrants.data?.some(g => g.createConversations && g.appName === 'Groups');
7
+ const canCreateServicesConversations = appGrants.data?.some(g => g.createConversations && g.appName === 'Services');
8
+ if (canCreateGroupsConversations && canCreateServicesConversations) {
9
+ return 'select_type';
10
+ }
11
+ if (canCreateGroupsConversations) {
12
+ return 'groups';
13
+ }
14
+ if (canCreateServicesConversations) {
15
+ return 'teams';
16
+ }
17
+ return 'none';
18
+ }, [appGrants.data]);
19
+ }
20
+ //# sourceMappingURL=use_new_conversation_entry.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use_new_conversation_entry.js","sourceRoot":"","sources":["../../src/hooks/use_new_conversation_entry.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,OAAO,CAAA;AAC/B,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAA;AAIrD,MAAM,UAAU,uBAAuB;IACrC,MAAM,SAAS,GAAG,YAAY,EAAE,CAAA;IAEhC,OAAO,OAAO,CAAC,GAAG,EAAE;QAClB,MAAM,4BAA4B,GAAG,SAAS,CAAC,IAAI,EAAE,IAAI,CACvD,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,mBAAmB,IAAI,CAAC,CAAC,OAAO,KAAK,QAAQ,CACrD,CAAA;QACD,MAAM,8BAA8B,GAAG,SAAS,CAAC,IAAI,EAAE,IAAI,CACzD,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,mBAAmB,IAAI,CAAC,CAAC,OAAO,KAAK,UAAU,CACvD,CAAA;QAED,IAAI,4BAA4B,IAAI,8BAA8B,EAAE,CAAC;YACnE,OAAO,aAAa,CAAA;QACtB,CAAC;QAED,IAAI,4BAA4B,EAAE,CAAC;YACjC,OAAO,QAAQ,CAAA;QACjB,CAAC;QAED,IAAI,8BAA8B,EAAE,CAAC;YACnC,OAAO,OAAO,CAAA;QAChB,CAAC;QAED,OAAO,MAAM,CAAA;IACf,CAAC,EAAE,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAA;AACtB,CAAC","sourcesContent":["import { useMemo } from 'react'\nimport { useAppGrants } from './use_chat_permissions'\n\nexport type NewConversationEntryMode = 'select_type' | 'groups' | 'teams' | 'none'\n\nexport function useNewConversationEntry(): NewConversationEntryMode {\n const appGrants = useAppGrants()\n\n return useMemo(() => {\n const canCreateGroupsConversations = appGrants.data?.some(\n g => g.createConversations && g.appName === 'Groups'\n )\n const canCreateServicesConversations = appGrants.data?.some(\n g => g.createConversations && g.appName === 'Services'\n )\n\n if (canCreateGroupsConversations && canCreateServicesConversations) {\n return 'select_type'\n }\n\n if (canCreateGroupsConversations) {\n return 'groups'\n }\n\n if (canCreateServicesConversations) {\n return 'teams'\n }\n\n return 'none'\n }, [appGrants.data])\n}\n"]}
@@ -0,0 +1,6 @@
1
+ import { MessageReportReason } from '../types/resources/message_report';
2
+ export declare const useReportMessage: (conversationId: number, messageId: string) => import("@tanstack/react-query").UseMutationResult<import("..").ApiCollection | import("..").ApiResource, Error, {
3
+ reason: MessageReportReason;
4
+ reasonDetail?: string;
5
+ }, unknown>;
6
+ //# sourceMappingURL=use_report_message.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use_report_message.d.ts","sourceRoot":"","sources":["../../src/hooks/use_report_message.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,mBAAmB,EAAwB,MAAM,mCAAmC,CAAA;AAE7F,eAAO,MAAM,gBAAgB,mBAAoB,MAAM,aAAa,MAAM;YAQ5D,mBAAmB;mBACZ,MAAM;WAsB1B,CAAA"}
@@ -0,0 +1,28 @@
1
+ import { useMutation } from '@tanstack/react-query';
2
+ import { useApiClient } from './use_api_client';
3
+ import { Haptic } from '../utils/native_adapters';
4
+ export const useReportMessage = (conversationId, messageId) => {
5
+ const apiClient = useApiClient();
6
+ return useMutation({
7
+ mutationFn: async ({ reason, reasonDetail, }) => {
8
+ const url = `/me/conversations/${conversationId}/messages/${messageId}/report`;
9
+ const data = {
10
+ data: {
11
+ type: 'MessageReport',
12
+ attributes: {
13
+ reason,
14
+ ...(reasonDetail && { reason_detail: reasonDetail }),
15
+ },
16
+ },
17
+ };
18
+ return apiClient.chat.post({ url, data });
19
+ },
20
+ onSuccess: () => {
21
+ Haptic.notificationSuccess();
22
+ },
23
+ onError: () => {
24
+ Haptic.notificationError();
25
+ },
26
+ });
27
+ };
28
+ //# sourceMappingURL=use_report_message.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use_report_message.js","sourceRoot":"","sources":["../../src/hooks/use_report_message.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAA;AACnD,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAA;AAC/C,OAAO,EAAE,MAAM,EAAE,MAAM,0BAA0B,CAAA;AAGjD,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,cAAsB,EAAE,SAAiB,EAAE,EAAE;IAC5E,MAAM,SAAS,GAAG,YAAY,EAAE,CAAA;IAEhC,OAAO,WAAW,CAAC;QACjB,UAAU,EAAE,KAAK,EAAE,EACjB,MAAM,EACN,YAAY,GAIb,EAAE,EAAE;YACH,MAAM,GAAG,GAAG,qBAAqB,cAAc,aAAa,SAAS,SAAS,CAAA;YAC9E,MAAM,IAAI,GAAyB;gBACjC,IAAI,EAAE;oBACJ,IAAI,EAAE,eAAe;oBACrB,UAAU,EAAE;wBACV,MAAM;wBACN,GAAG,CAAC,YAAY,IAAI,EAAE,aAAa,EAAE,YAAY,EAAE,CAAC;qBACrD;iBACF;aACF,CAAA;YAED,OAAO,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,GAAG,EAAE,IAAI,EAAE,CAAC,CAAA;QAC3C,CAAC;QACD,SAAS,EAAE,GAAG,EAAE;YACd,MAAM,CAAC,mBAAmB,EAAE,CAAA;QAC9B,CAAC;QACD,OAAO,EAAE,GAAG,EAAE;YACZ,MAAM,CAAC,iBAAiB,EAAE,CAAA;QAC5B,CAAC;KACF,CAAC,CAAA;AACJ,CAAC,CAAA","sourcesContent":["import { useMutation } from '@tanstack/react-query'\nimport { useApiClient } from './use_api_client'\nimport { Haptic } from '../utils/native_adapters'\nimport { MessageReportReason, MessageReportPayload } from '../types/resources/message_report'\n\nexport const useReportMessage = (conversationId: number, messageId: string) => {\n const apiClient = useApiClient()\n\n return useMutation({\n mutationFn: async ({\n reason,\n reasonDetail,\n }: {\n reason: MessageReportReason\n reasonDetail?: string\n }) => {\n const url = `/me/conversations/${conversationId}/messages/${messageId}/report`\n const data: MessageReportPayload = {\n data: {\n type: 'MessageReport',\n attributes: {\n reason,\n ...(reasonDetail && { reason_detail: reasonDetail }),\n },\n },\n }\n\n return apiClient.chat.post({ url, data })\n },\n onSuccess: () => {\n Haptic.notificationSuccess()\n },\n onError: () => {\n Haptic.notificationError()\n },\n })\n}\n"]}