@planningcenter/chat-react-native 1.6.2-rc.2 → 1.7.0-rc.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 (75) hide show
  1. package/build/components/conversation/message_reaction.d.ts +8 -0
  2. package/build/components/conversation/message_reaction.d.ts.map +1 -0
  3. package/build/components/conversation/message_reaction.js +44 -0
  4. package/build/components/conversation/message_reaction.js.map +1 -0
  5. package/build/components/display/badge.d.ts +58 -0
  6. package/build/components/display/badge.d.ts.map +1 -0
  7. package/build/components/display/badge.js +186 -0
  8. package/build/components/display/badge.js.map +1 -0
  9. package/build/components/display/button_color_utils.d.ts +1 -1
  10. package/build/components/display/index.d.ts +1 -0
  11. package/build/components/display/index.d.ts.map +1 -1
  12. package/build/components/display/index.js +1 -0
  13. package/build/components/display/index.js.map +1 -1
  14. package/build/hooks/use_conversation_messages.d.ts +45 -0
  15. package/build/hooks/use_conversation_messages.d.ts.map +1 -0
  16. package/build/hooks/use_conversation_messages.js +33 -0
  17. package/build/hooks/use_conversation_messages.js.map +1 -0
  18. package/build/hooks/use_suspense_api.d.ts +3 -2
  19. package/build/hooks/use_suspense_api.d.ts.map +1 -1
  20. package/build/hooks/use_suspense_api.js +3 -2
  21. package/build/hooks/use_suspense_api.js.map +1 -1
  22. package/build/navigation/index.d.ts +5 -0
  23. package/build/navigation/index.d.ts.map +1 -1
  24. package/build/navigation/index.js +9 -3
  25. package/build/navigation/index.js.map +1 -1
  26. package/build/screens/conversation_screen.d.ts.map +1 -1
  27. package/build/screens/conversation_screen.js +91 -37
  28. package/build/screens/conversation_screen.js.map +1 -1
  29. package/build/screens/design_system_screen.d.ts.map +1 -1
  30. package/build/screens/design_system_screen.js +407 -338
  31. package/build/screens/design_system_screen.js.map +1 -1
  32. package/build/screens/message_actions_screen.d.ts +10 -0
  33. package/build/screens/message_actions_screen.d.ts.map +1 -0
  34. package/build/screens/message_actions_screen.js +128 -0
  35. package/build/screens/message_actions_screen.js.map +1 -0
  36. package/build/types/api_primitives.d.ts +1 -2
  37. package/build/types/api_primitives.d.ts.map +1 -1
  38. package/build/types/api_primitives.js.map +1 -1
  39. package/build/utils/cache/index.d.ts +2 -0
  40. package/build/utils/cache/index.d.ts.map +1 -0
  41. package/build/utils/cache/index.js +2 -0
  42. package/build/utils/cache/index.js.map +1 -0
  43. package/build/utils/cache/page_mutations.d.ts +37 -0
  44. package/build/utils/cache/page_mutations.d.ts.map +1 -0
  45. package/build/utils/cache/page_mutations.js +42 -0
  46. package/build/utils/cache/page_mutations.js.map +1 -0
  47. package/build/utils/index.d.ts +1 -0
  48. package/build/utils/index.d.ts.map +1 -1
  49. package/build/utils/index.js +1 -0
  50. package/build/utils/index.js.map +1 -1
  51. package/build/utils/theme.d.ts +16 -0
  52. package/build/utils/theme.d.ts.map +1 -1
  53. package/build/utils/theme.js +31 -0
  54. package/build/utils/theme.js.map +1 -1
  55. package/build/vendor/tapestry/tokens.d.ts +30 -0
  56. package/build/vendor/tapestry/tokens.d.ts.map +1 -1
  57. package/build/vendor/tapestry/tokens.js +30 -0
  58. package/build/vendor/tapestry/tokens.js.map +1 -1
  59. package/package.json +3 -2
  60. package/src/__tests__/utils/cache/page_mutations.ts +206 -0
  61. package/src/components/conversation/message_reaction.tsx +57 -0
  62. package/src/components/display/badge.tsx +323 -0
  63. package/src/components/display/index.ts +1 -0
  64. package/src/hooks/use_conversation_messages.ts +43 -0
  65. package/src/hooks/use_suspense_api.ts +16 -2
  66. package/src/navigation/index.tsx +9 -3
  67. package/src/screens/conversation_screen.tsx +111 -40
  68. package/src/screens/design_system_screen.tsx +712 -580
  69. package/src/screens/message_actions_screen.tsx +167 -0
  70. package/src/types/api_primitives.ts +1 -1
  71. package/src/utils/cache/index.ts +1 -0
  72. package/src/utils/cache/page_mutations.ts +66 -0
  73. package/src/utils/index.ts +1 -0
  74. package/src/utils/theme.ts +47 -0
  75. package/src/vendor/tapestry/tokens.ts +30 -0
@@ -0,0 +1,8 @@
1
+ import React from 'react';
2
+ import { ReactionCountResource } from '../../types/resources/reaction';
3
+ export declare const REACTION_EMOJIS: Record<ReactionCountResource['value'], string>;
4
+ export declare function MessageReaction({ reaction, onPress, }: {
5
+ reaction: ReactionCountResource;
6
+ onPress: () => void;
7
+ }): React.JSX.Element;
8
+ //# sourceMappingURL=message_reaction.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"message_reaction.d.ts","sourceRoot":"","sources":["../../../src/components/conversation/message_reaction.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,MAAM,OAAO,CAAA;AAIzB,OAAO,EAAE,qBAAqB,EAAE,MAAM,gCAAgC,CAAA;AAEtE,eAAO,MAAM,eAAe,EAAE,MAAM,CAAC,qBAAqB,CAAC,OAAO,CAAC,EAAE,MAAM,CAM1E,CAAA;AAED,wBAAgB,eAAe,CAAC,EAC9B,QAAQ,EACR,OAAO,GACR,EAAE;IACD,QAAQ,EAAE,qBAAqB,CAAA;IAC/B,OAAO,EAAE,MAAM,IAAI,CAAA;CACpB,qBASA"}
@@ -0,0 +1,44 @@
1
+ import { PlatformPressable } from '@react-navigation/elements';
2
+ import colorFunction from 'color';
3
+ import React from 'react';
4
+ import { StyleSheet } from 'react-native';
5
+ import { Text } from '../../components/display';
6
+ import { useTheme } from '../../hooks';
7
+ export const REACTION_EMOJIS = {
8
+ thumbs_up: '👍',
9
+ thumbs_down: '👎',
10
+ pray: '🙏',
11
+ laugh: '😂',
12
+ heart: '❤️',
13
+ };
14
+ export function MessageReaction({ reaction, onPress, }) {
15
+ const styles = useReactionStyles(reaction);
16
+ return (<PlatformPressable key={reaction.value} style={styles.reaction} onPress={onPress}>
17
+ <Text style={styles.reactionEmoji}>{REACTION_EMOJIS[reaction.value]}</Text>
18
+ <Text style={styles.reactionText}>{reaction.count}</Text>
19
+ </PlatformPressable>);
20
+ }
21
+ const useReactionStyles = ({ mine }) => {
22
+ const { colors } = useTheme();
23
+ const activeBorderColor = colorFunction(colors.interaction).alpha(0.8).string();
24
+ const activeColor = colorFunction(colors.interaction).alpha(0.2).string();
25
+ return StyleSheet.create({
26
+ reaction: {
27
+ borderWidth: 1,
28
+ borderColor: mine ? activeBorderColor : colors.fillColorNeutral040,
29
+ backgroundColor: mine ? activeColor : colors.fillColorNeutral050Base,
30
+ borderRadius: 16,
31
+ paddingVertical: 2,
32
+ paddingHorizontal: 12,
33
+ flexDirection: 'row',
34
+ alignItems: 'center',
35
+ gap: 4,
36
+ },
37
+ reactionEmoji: { fontSize: 12, paddingTop: 0 },
38
+ reactionText: { fontSize: 12, color: colors.textColorDefaultPrimary },
39
+ pressed: {
40
+ opacity: 0.5,
41
+ },
42
+ });
43
+ };
44
+ //# sourceMappingURL=message_reaction.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"message_reaction.js","sourceRoot":"","sources":["../../../src/components/conversation/message_reaction.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAA;AAC9D,OAAO,aAAa,MAAM,OAAO,CAAA;AACjC,OAAO,KAAK,MAAM,OAAO,CAAA;AACzB,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AACzC,OAAO,EAAE,IAAI,EAAE,MAAM,0BAA0B,CAAA;AAC/C,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAA;AAGtC,MAAM,CAAC,MAAM,eAAe,GAAmD;IAC7E,SAAS,EAAE,IAAI;IACf,WAAW,EAAE,IAAI;IACjB,IAAI,EAAE,IAAI;IACV,KAAK,EAAE,IAAI;IACX,KAAK,EAAE,IAAI;CACZ,CAAA;AAED,MAAM,UAAU,eAAe,CAAC,EAC9B,QAAQ,EACR,OAAO,GAIR;IACC,MAAM,MAAM,GAAG,iBAAiB,CAAC,QAAQ,CAAC,CAAA;IAE1C,OAAO,CACL,CAAC,iBAAiB,CAAC,GAAG,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,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EAAE,EAAE,EAAE,KAAK,EAAE,MAAM,CAAC,uBAAuB,EAAE;QACrE,OAAO,EAAE;YACP,OAAO,EAAE,GAAG;SACb;KACF,CAAC,CAAA;AACJ,CAAC,CAAA","sourcesContent":["import { PlatformPressable } from '@react-navigation/elements'\nimport colorFunction from 'color'\nimport React from 'react'\nimport { StyleSheet } from 'react-native'\nimport { Text } from '../../components/display'\nimport { useTheme } from '../../hooks'\nimport { ReactionCountResource } from '../../types/resources/reaction'\n\nexport const REACTION_EMOJIS: Record<ReactionCountResource['value'], string> = {\n thumbs_up: '👍',\n thumbs_down: '👎',\n pray: '🙏',\n laugh: '😂',\n heart: '❤️',\n}\n\nexport function MessageReaction({\n reaction,\n onPress,\n}: {\n reaction: ReactionCountResource\n onPress: () => void\n}) {\n const styles = useReactionStyles(reaction)\n\n return (\n <PlatformPressable key={reaction.value} style={styles.reaction} onPress={onPress}>\n <Text style={styles.reactionEmoji}>{REACTION_EMOJIS[reaction.value]}</Text>\n <Text style={styles.reactionText}>{reaction.count}</Text>\n </PlatformPressable>\n )\n}\n\nconst useReactionStyles = ({ mine }: { mine: number }) => {\n const { colors } = useTheme()\n const activeBorderColor = colorFunction(colors.interaction).alpha(0.8).string()\n const activeColor = colorFunction(colors.interaction).alpha(0.2).string()\n\n return StyleSheet.create({\n reaction: {\n borderWidth: 1,\n borderColor: mine ? activeBorderColor : colors.fillColorNeutral040,\n backgroundColor: mine ? activeColor : colors.fillColorNeutral050Base,\n borderRadius: 16,\n paddingVertical: 2,\n paddingHorizontal: 12,\n flexDirection: 'row',\n alignItems: 'center',\n gap: 4,\n },\n reactionEmoji: { fontSize: 12, paddingTop: 0 },\n reactionText: { fontSize: 12, color: colors.textColorDefaultPrimary },\n pressed: {\n opacity: 0.5,\n },\n })\n}\n"]}
@@ -0,0 +1,58 @@
1
+ import React from 'react';
2
+ import type { ViewStyle } from 'react-native';
3
+ declare const APPEARANCES: {
4
+ readonly error: "error";
5
+ readonly info: "info";
6
+ readonly neutral: "neutral";
7
+ readonly success: "success";
8
+ readonly warning: "warning";
9
+ };
10
+ type AppearanceUnion = (typeof APPEARANCES)[keyof typeof APPEARANCES];
11
+ declare const VARIANTS: {
12
+ readonly default: "default";
13
+ readonly meta: "meta";
14
+ readonly metaSubtle: "metaSubtle";
15
+ };
16
+ type VariantUnion = (typeof VARIANTS)[keyof typeof VARIANTS];
17
+ declare const LOGO_NAMES: {
18
+ readonly groups: "groups";
19
+ readonly services: "services";
20
+ };
21
+ type PoductLogoNameUnion = (typeof LOGO_NAMES)[keyof typeof LOGO_NAMES];
22
+ interface BadgeProps {
23
+ /**
24
+ * Renders the main text.
25
+ */
26
+ label: string;
27
+ /**
28
+ * Renders secondary meta text to the right of the label.
29
+ */
30
+ metaLabel?: string;
31
+ /**
32
+ * Changes the status color for the badge and icon.
33
+ */
34
+ appearance?: AppearanceUnion;
35
+ /**
36
+ * Changes form of the logo to support a meta label and badge
37
+ */
38
+ variant?: VariantUnion;
39
+ /**
40
+ * Adds a product logo to the left of the text.
41
+ */
42
+ productLogoName?: PoductLogoNameUnion;
43
+ /**
44
+ * Shows an icon of the user choice to the left of the text.
45
+ */
46
+ iconName?: string;
47
+ /**
48
+ * Styles badge wrapper.
49
+ */
50
+ style?: ViewStyle;
51
+ /**
52
+ * Specifies the maximum size a font can reach when allowFontScaling is enabled.
53
+ */
54
+ maxFontSizeMultiplier?: number;
55
+ }
56
+ export declare function Badge({ appearance, metaLabel, style, iconName, label, productLogoName, variant, maxFontSizeMultiplier, }: BadgeProps): React.JSX.Element;
57
+ export {};
58
+ //# sourceMappingURL=badge.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"badge.d.ts","sourceRoot":"","sources":["../../../src/components/display/badge.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AAEzB,OAAO,KAAK,EAAE,SAAS,EAAa,MAAM,cAAc,CAAA;AAYxD,QAAA,MAAM,WAAW;;;;;;CAMP,CAAA;AAEV,KAAK,eAAe,GAAG,CAAC,OAAO,WAAW,CAAC,CAAC,MAAM,OAAO,WAAW,CAAC,CAAA;AAWrE,QAAA,MAAM,QAAQ;;;;CAIJ,CAAA;AAEV,KAAK,YAAY,GAAG,CAAC,OAAO,QAAQ,CAAC,CAAC,MAAM,OAAO,QAAQ,CAAC,CAAA;AAiB5D,QAAA,MAAM,UAAU;;;CAGN,CAAA;AAEV,KAAK,mBAAmB,GAAG,CAAC,OAAO,UAAU,CAAC,CAAC,MAAM,OAAO,UAAU,CAAC,CAAA;AAWvE,UAAU,UAAU;IAClB;;OAEG;IACH,KAAK,EAAE,MAAM,CAAA;IACb;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB;;OAEG;IACH,UAAU,CAAC,EAAE,eAAe,CAAA;IAC5B;;OAEG;IACH,OAAO,CAAC,EAAE,YAAY,CAAA;IACtB;;OAEG;IACH,eAAe,CAAC,EAAE,mBAAmB,CAAA;IACrC;;OAEG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB;;OAEG;IACH,KAAK,CAAC,EAAE,SAAS,CAAA;IACjB;;OAEG;IACH,qBAAqB,CAAC,EAAE,MAAM,CAAA;CAC/B;AAED,wBAAgB,KAAK,CAAC,EACpB,UAAsB,EACtB,SAAS,EACT,KAAK,EACL,QAAQ,EACR,KAAK,EACL,eAAe,EACf,OAAmB,EACnB,qBAAqB,GACtB,EAAE,UAAU,qBA4BZ"}
@@ -0,0 +1,186 @@
1
+ import React from 'react';
2
+ import { StyleSheet, View } from 'react-native';
3
+ import Svg, { Path, Defs, LinearGradient, Stop } from 'react-native-svg';
4
+ import { useFontScale, useTheme } from '../../hooks';
5
+ import { Icon } from './icon';
6
+ import { Text } from './text';
7
+ import { platformFontWeightMedium, space } from '../../utils';
8
+ import { tokens } from '../../vendor/tapestry/tokens';
9
+ // =================================
10
+ // ====== Constants ================
11
+ // =================================
12
+ const APPEARANCES = {
13
+ error: 'error',
14
+ info: 'info',
15
+ neutral: 'neutral',
16
+ success: 'success',
17
+ warning: 'warning',
18
+ };
19
+ const VARIANTS = {
20
+ default: 'default',
21
+ meta: 'meta',
22
+ metaSubtle: 'metaSubtle',
23
+ };
24
+ const LOGO_NAMES = {
25
+ groups: 'groups',
26
+ services: 'services',
27
+ };
28
+ const PRODUCT_LOGO_COMPONENT_MAP = {
29
+ groups: GroupsLogo,
30
+ services: ServicesIcon,
31
+ };
32
+ export function Badge({ appearance = 'neutral', metaLabel, style, iconName, label, productLogoName, variant = 'default', maxFontSizeMultiplier, }) {
33
+ const styles = useStyles({ appearance, maxFontSizeMultiplier, variant });
34
+ const { showBadgeLogo } = useTheme();
35
+ const isMetaSubtle = variant === 'metaSubtle';
36
+ const isMeta = variant === 'meta';
37
+ const hasMetaLabel = Boolean(metaLabel);
38
+ const showLogo = showBadgeLogo && productLogoName && isMeta;
39
+ const ProductLogoSvg = showLogo && PRODUCT_LOGO_COMPONENT_MAP[productLogoName];
40
+ const badgeLabel = isMetaSubtle && hasMetaLabel ? `${label}:` : label;
41
+ return (<View style={[styles.badgeWrapper, style]}>
42
+ <View style={styles.badge}>
43
+ {showLogo && ProductLogoSvg && <ProductLogoSvg logoSize={styles.logo.fontSize}/>}
44
+ {iconName && <Icon name={iconName} style={styles.icon}/>}
45
+ <Text variant="footnote" style={styles.label}>
46
+ {badgeLabel}
47
+ </Text>
48
+ </View>
49
+ {hasMetaLabel && (<Text variant="footnote" style={styles.metaLabel} numberOfLines={1}>
50
+ {metaLabel}
51
+ </Text>)}
52
+ </View>);
53
+ }
54
+ // =================================
55
+ // ====== Styles ===================
56
+ // =================================
57
+ const useStyles = ({ appearance = 'neutral', maxFontSizeMultiplier, variant = 'default', }) => {
58
+ const { colors } = useTheme();
59
+ const fontScale = useFontScale({ maxFontSizeMultiplier });
60
+ const apparenceColorMap = {
61
+ error: {
62
+ background: colors.statusErrorBackground,
63
+ text: colors.statusErrorText,
64
+ icon: colors.statusErrorIcon,
65
+ },
66
+ info: {
67
+ background: colors.statusInfoBackground,
68
+ text: colors.statusInfoText,
69
+ icon: colors.statusInfoIcon,
70
+ },
71
+ neutral: {
72
+ background: colors.statusNeutralBackground,
73
+ text: colors.statusNeutralText,
74
+ icon: colors.statusNeutralIcon,
75
+ },
76
+ success: {
77
+ background: colors.statusSuccessBackground,
78
+ text: colors.statusSuccessText,
79
+ icon: colors.statusSuccessIcon,
80
+ },
81
+ warning: {
82
+ background: colors.statusWarningBackground,
83
+ text: colors.statusWarningText,
84
+ icon: colors.statusWarningIcon,
85
+ },
86
+ };
87
+ const badgePaddingHorizontal = space(1) * fontScale;
88
+ const badgePaddingVertical = space(0.5) * fontScale;
89
+ const badgeGap = space(0.5) * fontScale;
90
+ const badgeFontSize = 12;
91
+ const variantStylesMap = {
92
+ default: {
93
+ gap: badgeGap,
94
+ backgroundColor: apparenceColorMap[appearance].background,
95
+ metaLabelPaddingLeft: badgePaddingHorizontal,
96
+ paddingHorizontal: badgePaddingHorizontal,
97
+ paddingVertical: badgePaddingVertical,
98
+ borderWidth: tokens.borderSizeDefault * fontScale,
99
+ borderRadius: tokens.borderRadiusMd,
100
+ textColor: apparenceColorMap[appearance].text,
101
+ fontWeight: 'normal',
102
+ },
103
+ meta: {
104
+ gap: badgeGap,
105
+ backgroundColor: apparenceColorMap[appearance].background,
106
+ metaLabelPaddingLeft: badgePaddingHorizontal,
107
+ paddingHorizontal: badgePaddingHorizontal,
108
+ paddingVertical: badgePaddingVertical,
109
+ borderWidth: tokens.borderSizeDefault * fontScale,
110
+ borderRadius: tokens.borderRadiusMd,
111
+ textColor: apparenceColorMap[appearance].text,
112
+ fontWeight: platformFontWeightMedium,
113
+ },
114
+ metaSubtle: {
115
+ gap: badgeGap,
116
+ backgroundColor: 'transparent',
117
+ metaLabelPaddingLeft: badgeGap,
118
+ paddingHorizontal: 0,
119
+ paddingVertical: 0,
120
+ borderWidth: 0,
121
+ borderRadius: 0,
122
+ textColor: colors.textColorDefaultSecondary,
123
+ fontWeight: platformFontWeightMedium,
124
+ },
125
+ };
126
+ return StyleSheet.create({
127
+ badgeWrapper: {
128
+ flexDirection: 'row',
129
+ alignItems: 'center',
130
+ justifyContent: 'center',
131
+ borderRadius: variantStylesMap[variant].borderRadius,
132
+ borderWidth: variantStylesMap[variant].borderWidth,
133
+ borderColor: apparenceColorMap[appearance].background,
134
+ },
135
+ badge: {
136
+ flexDirection: 'row',
137
+ alignItems: 'center',
138
+ gap: variantStylesMap[variant].gap,
139
+ paddingVertical: variantStylesMap[variant].paddingVertical,
140
+ paddingHorizontal: variantStylesMap[variant].paddingHorizontal,
141
+ backgroundColor: variantStylesMap[variant].backgroundColor,
142
+ borderRadius: variantStylesMap[variant].borderRadius - 2,
143
+ },
144
+ icon: {
145
+ color: apparenceColorMap[appearance].icon,
146
+ fontSize: badgeFontSize,
147
+ },
148
+ logo: {
149
+ fontSize: badgeFontSize * fontScale,
150
+ },
151
+ label: {
152
+ color: variantStylesMap[variant].textColor,
153
+ fontWeight: variantStylesMap[variant].fontWeight,
154
+ fontSize: badgeFontSize,
155
+ },
156
+ metaLabel: {
157
+ paddingHorizontal: variantStylesMap[variant].paddingHorizontal,
158
+ fontSize: badgeFontSize,
159
+ flexShrink: 1,
160
+ paddingLeft: variantStylesMap[variant].metaLabelPaddingLeft,
161
+ },
162
+ });
163
+ };
164
+ function GroupsLogo({ logoSize }) {
165
+ return (<Svg width={logoSize} height={logoSize} viewBox="0 0 16 16" fill="none">
166
+ <Path d="M9.06 6.14H6.94c-.152.36-.438.646-.797.798v2.12c.359.152.645.438.797.797h2.117c.152-.359.437-.645.796-.797V6.94a1.502 1.502 0 01-.793-.8zM8 0C1.6 0 0 1.595 0 8s1.6 8 8 8 8-1.595 8-8-1.595-8-8-8zm3.939 10.44a1.5 1.5 0 01-2.882.585H6.94a1.5 1.5 0 11-1.963-1.963v-2.12A1.501 1.501 0 116.94 4.98h2.12a1.5 1.5 0 111.963 1.968v2.11a1.501 1.501 0 01.916 1.383z" fill="url(#paint0_linear_2632_26363)"/>
167
+ <Defs>
168
+ <LinearGradient id="paint0_linear_2632_26363" x1={-5.6338} y1={5.6338} x2={5.6338} y2={16.9014} gradientUnits="userSpaceOnUse">
169
+ <Stop stopColor="#FF962D"/>
170
+ <Stop offset={1} stopColor="#FC7638"/>
171
+ </LinearGradient>
172
+ </Defs>
173
+ </Svg>);
174
+ }
175
+ function ServicesIcon({ logoSize }) {
176
+ return (<Svg width={logoSize} height={logoSize} viewBox="0 0 16 16" fill="none">
177
+ <Path fillRule="evenodd" clipRule="evenodd" d="M.116 8c0-6.4 1.6-8 8-8s8 1.6 8 8-1.6 8-8 8-8-1.6-8-8zm4.123 3.464a.848.848 0 10.943-1.41.848.848 0 00-.943 1.41zm.001-2.76a.848.848 0 10.948-1.408.848.848 0 00-.948 1.407zm0-2.759a.849.849 0 10.948-1.408.849.849 0 00-.948 1.408zm8.1 5.34a.388.388 0 00.03-.149v-.755a.39.39 0 00-.39-.39H6.87a.39.39 0 00-.39.39v.755a.39.39 0 00.39.39h5.11a.39.39 0 00.36-.24zm0-2.758a.388.388 0 00.03-.149v-.757a.387.387 0 00-.39-.388H6.87a.388.388 0 00-.39.388v.757a.388.388 0 00.39.388h5.11a.388.388 0 00.36-.24zm0-2.76a.388.388 0 00.03-.148v-.754a.39.39 0 00-.39-.389H6.87a.39.39 0 00-.39.387v.756a.39.39 0 00.39.39h5.11a.389.389 0 00.36-.241z" fill="url(#paint0_linear_2632_56586)"/>
178
+ <Defs>
179
+ <LinearGradient id="paint0_linear_2632_56586" x1={-5.51759} y1={5.6338} x2={5.75001} y2={16.9014} gradientUnits="userSpaceOnUse">
180
+ <Stop stopColor="#6BB23D"/>
181
+ <Stop offset={1} stopColor="#659630"/>
182
+ </LinearGradient>
183
+ </Defs>
184
+ </Svg>);
185
+ }
186
+ //# sourceMappingURL=badge.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"badge.js","sourceRoot":"","sources":["../../../src/components/display/badge.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK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AI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,SAAS,EACtC;QAAA,EAAE,cAAc,CAClB;MAAA,EAAE,IAAI,CACR;IAAA,EAAE,GAAG,CAAC,CACP,CAAA;AACH,CAAC","sourcesContent":["import React from 'react'\nimport { StyleSheet, View } from 'react-native'\nimport type { ViewStyle, TextStyle } from 'react-native'\nimport Svg, { Path, Defs, LinearGradient, Stop } from 'react-native-svg'\nimport { useFontScale, useTheme } from '../../hooks'\nimport { Icon } from './icon'\nimport { Text } from './text'\nimport { platformFontWeightMedium, space } from '../../utils'\nimport { tokens } from '../../vendor/tapestry/tokens'\n\n// =================================\n// ====== Constants ================\n// =================================\n\nconst APPEARANCES = {\n error: 'error',\n info: 'info',\n neutral: 'neutral',\n success: 'success',\n warning: 'warning',\n} as const\n\ntype AppearanceUnion = (typeof APPEARANCES)[keyof typeof APPEARANCES]\n\ntype AppearanceColors = Record<\n AppearanceUnion,\n {\n background: string\n text: string\n icon: string\n }\n>\n\nconst VARIANTS = {\n default: 'default',\n meta: 'meta',\n metaSubtle: 'metaSubtle',\n} as const\n\ntype VariantUnion = (typeof VARIANTS)[keyof typeof VARIANTS]\n\ntype VariantStyles = Record<\n VariantUnion,\n {\n backgroundColor: string\n paddingHorizontal: number\n paddingVertical: number\n borderWidth: number\n borderRadius: number\n textColor: string\n gap: number\n metaLabelPaddingLeft: number\n fontWeight: TextStyle['fontWeight']\n }\n>\n\nconst LOGO_NAMES = {\n groups: 'groups',\n services: 'services',\n} as const\n\ntype PoductLogoNameUnion = (typeof LOGO_NAMES)[keyof typeof LOGO_NAMES]\n\nconst PRODUCT_LOGO_COMPONENT_MAP = {\n groups: GroupsLogo,\n services: ServicesIcon,\n} as const\n\n// =================================\n// ====== Component ================\n// =================================\n\ninterface BadgeProps {\n /**\n * Renders the main text.\n */\n label: string\n /**\n * Renders secondary meta text to the right of the label.\n */\n metaLabel?: string\n /**\n * Changes the status color for the badge and icon.\n */\n appearance?: AppearanceUnion\n /**\n * Changes form of the logo to support a meta label and badge\n */\n variant?: VariantUnion\n /**\n * Adds a product logo to the left of the text.\n */\n productLogoName?: PoductLogoNameUnion\n /**\n * Shows an icon of the user choice to the left of the text.\n */\n iconName?: string\n /**\n * Styles badge wrapper.\n */\n style?: ViewStyle\n /**\n * Specifies the maximum size a font can reach when allowFontScaling is enabled.\n */\n maxFontSizeMultiplier?: number\n}\n\nexport function Badge({\n appearance = 'neutral',\n metaLabel,\n style,\n iconName,\n label,\n productLogoName,\n variant = 'default',\n maxFontSizeMultiplier,\n}: BadgeProps) {\n const styles = useStyles({ appearance, maxFontSizeMultiplier, variant })\n const { showBadgeLogo } = useTheme()\n\n const isMetaSubtle = variant === 'metaSubtle'\n const isMeta = variant === 'meta'\n const hasMetaLabel = Boolean(metaLabel)\n\n const showLogo = showBadgeLogo && productLogoName && isMeta\n const ProductLogoSvg = showLogo && PRODUCT_LOGO_COMPONENT_MAP[productLogoName]\n const badgeLabel = isMetaSubtle && hasMetaLabel ? `${label}:` : label\n\n return (\n <View style={[styles.badgeWrapper, style]}>\n <View style={styles.badge}>\n {showLogo && ProductLogoSvg && <ProductLogoSvg logoSize={styles.logo.fontSize} />}\n {iconName && <Icon name={iconName} style={styles.icon} />}\n <Text variant=\"footnote\" style={styles.label}>\n {badgeLabel}\n </Text>\n </View>\n {hasMetaLabel && (\n <Text variant=\"footnote\" style={styles.metaLabel} numberOfLines={1}>\n {metaLabel}\n </Text>\n )}\n </View>\n )\n}\n\n// =================================\n// ====== Styles ===================\n// =================================\n\nconst useStyles = ({\n appearance = 'neutral',\n maxFontSizeMultiplier,\n variant = 'default',\n}: Partial<BadgeProps>) => {\n const { colors } = useTheme()\n const fontScale = useFontScale({ maxFontSizeMultiplier })\n\n const apparenceColorMap: AppearanceColors = {\n error: {\n background: colors.statusErrorBackground,\n text: colors.statusErrorText,\n icon: colors.statusErrorIcon,\n },\n info: {\n background: colors.statusInfoBackground,\n text: colors.statusInfoText,\n icon: colors.statusInfoIcon,\n },\n neutral: {\n background: colors.statusNeutralBackground,\n text: colors.statusNeutralText,\n icon: colors.statusNeutralIcon,\n },\n success: {\n background: colors.statusSuccessBackground,\n text: colors.statusSuccessText,\n icon: colors.statusSuccessIcon,\n },\n warning: {\n background: colors.statusWarningBackground,\n text: colors.statusWarningText,\n icon: colors.statusWarningIcon,\n },\n }\n\n const badgePaddingHorizontal = space(1) * fontScale\n const badgePaddingVertical = space(0.5) * fontScale\n const badgeGap = space(0.5) * fontScale\n const badgeFontSize = 12\n\n const variantStylesMap: VariantStyles = {\n default: {\n gap: badgeGap,\n backgroundColor: apparenceColorMap[appearance].background,\n metaLabelPaddingLeft: badgePaddingHorizontal,\n paddingHorizontal: badgePaddingHorizontal,\n paddingVertical: badgePaddingVertical,\n borderWidth: tokens.borderSizeDefault * fontScale,\n borderRadius: tokens.borderRadiusMd,\n textColor: apparenceColorMap[appearance].text,\n fontWeight: 'normal',\n },\n meta: {\n gap: badgeGap,\n backgroundColor: apparenceColorMap[appearance].background,\n metaLabelPaddingLeft: badgePaddingHorizontal,\n paddingHorizontal: badgePaddingHorizontal,\n paddingVertical: badgePaddingVertical,\n borderWidth: tokens.borderSizeDefault * fontScale,\n borderRadius: tokens.borderRadiusMd,\n textColor: apparenceColorMap[appearance].text,\n fontWeight: platformFontWeightMedium,\n },\n metaSubtle: {\n gap: badgeGap,\n backgroundColor: 'transparent',\n metaLabelPaddingLeft: badgeGap,\n paddingHorizontal: 0,\n paddingVertical: 0,\n borderWidth: 0,\n borderRadius: 0,\n textColor: colors.textColorDefaultSecondary,\n fontWeight: platformFontWeightMedium,\n },\n }\n\n return StyleSheet.create({\n badgeWrapper: {\n flexDirection: 'row',\n alignItems: 'center',\n justifyContent: 'center',\n borderRadius: variantStylesMap[variant].borderRadius,\n borderWidth: variantStylesMap[variant].borderWidth,\n borderColor: apparenceColorMap[appearance].background,\n },\n badge: {\n flexDirection: 'row',\n alignItems: 'center',\n gap: variantStylesMap[variant].gap,\n paddingVertical: variantStylesMap[variant].paddingVertical,\n paddingHorizontal: variantStylesMap[variant].paddingHorizontal,\n backgroundColor: variantStylesMap[variant].backgroundColor,\n borderRadius: variantStylesMap[variant].borderRadius - 2,\n },\n icon: {\n color: apparenceColorMap[appearance].icon,\n fontSize: badgeFontSize,\n },\n logo: {\n fontSize: badgeFontSize * fontScale,\n },\n label: {\n color: variantStylesMap[variant].textColor,\n fontWeight: variantStylesMap[variant].fontWeight,\n fontSize: badgeFontSize,\n },\n metaLabel: {\n paddingHorizontal: variantStylesMap[variant].paddingHorizontal,\n fontSize: badgeFontSize,\n flexShrink: 1,\n paddingLeft: variantStylesMap[variant].metaLabelPaddingLeft,\n },\n })\n}\n\n// =================================\n// ====== Product Logos ============\n// =================================\n\ninterface ProductLogoProps {\n logoSize: number\n}\n\nfunction GroupsLogo({ logoSize }: ProductLogoProps) {\n return (\n <Svg width={logoSize} height={logoSize} viewBox=\"0 0 16 16\" fill=\"none\">\n <Path\n d=\"M9.06 6.14H6.94c-.152.36-.438.646-.797.798v2.12c.359.152.645.438.797.797h2.117c.152-.359.437-.645.796-.797V6.94a1.502 1.502 0 01-.793-.8zM8 0C1.6 0 0 1.595 0 8s1.6 8 8 8 8-1.595 8-8-1.595-8-8-8zm3.939 10.44a1.5 1.5 0 01-2.882.585H6.94a1.5 1.5 0 11-1.963-1.963v-2.12A1.501 1.501 0 116.94 4.98h2.12a1.5 1.5 0 111.963 1.968v2.11a1.501 1.501 0 01.916 1.383z\"\n fill=\"url(#paint0_linear_2632_26363)\"\n />\n <Defs>\n <LinearGradient\n id=\"paint0_linear_2632_26363\"\n x1={-5.6338}\n y1={5.6338}\n x2={5.6338}\n y2={16.9014}\n gradientUnits=\"userSpaceOnUse\"\n >\n <Stop stopColor=\"#FF962D\" />\n <Stop offset={1} stopColor=\"#FC7638\" />\n </LinearGradient>\n </Defs>\n </Svg>\n )\n}\n\nfunction ServicesIcon({ logoSize }: ProductLogoProps) {\n return (\n <Svg width={logoSize} height={logoSize} viewBox=\"0 0 16 16\" fill=\"none\">\n <Path\n fillRule=\"evenodd\"\n clipRule=\"evenodd\"\n d=\"M.116 8c0-6.4 1.6-8 8-8s8 1.6 8 8-1.6 8-8 8-8-1.6-8-8zm4.123 3.464a.848.848 0 10.943-1.41.848.848 0 00-.943 1.41zm.001-2.76a.848.848 0 10.948-1.408.848.848 0 00-.948 1.407zm0-2.759a.849.849 0 10.948-1.408.849.849 0 00-.948 1.408zm8.1 5.34a.388.388 0 00.03-.149v-.755a.39.39 0 00-.39-.39H6.87a.39.39 0 00-.39.39v.755a.39.39 0 00.39.39h5.11a.39.39 0 00.36-.24zm0-2.758a.388.388 0 00.03-.149v-.757a.387.387 0 00-.39-.388H6.87a.388.388 0 00-.39.388v.757a.388.388 0 00.39.388h5.11a.388.388 0 00.36-.24zm0-2.76a.388.388 0 00.03-.148v-.754a.39.39 0 00-.39-.389H6.87a.39.39 0 00-.39.387v.756a.39.39 0 00.39.39h5.11a.389.389 0 00.36-.241z\"\n fill=\"url(#paint0_linear_2632_56586)\"\n />\n <Defs>\n <LinearGradient\n id=\"paint0_linear_2632_56586\"\n x1={-5.51759}\n y1={5.6338}\n x2={5.75001}\n y2={16.9014}\n gradientUnits=\"userSpaceOnUse\"\n >\n <Stop stopColor=\"#6BB23D\" />\n <Stop offset={1} stopColor=\"#659630\" />\n </LinearGradient>\n </Defs>\n </Svg>\n )\n}\n"]}
@@ -35,5 +35,5 @@ interface GetColorKeyArgs {
35
35
  loading?: boolean;
36
36
  appearance: ButtonAppearanceUnion | IconButtonAppearanceUnion;
37
37
  }
38
- declare function getColorKey({ disabled, loading, appearance }: GetColorKeyArgs): "danger" | "interaction" | "neutral" | "disabled";
38
+ declare function getColorKey({ disabled, loading, appearance }: GetColorKeyArgs): "neutral" | "danger" | "interaction" | "disabled";
39
39
  //# sourceMappingURL=button_color_utils.d.ts.map
@@ -1,5 +1,6 @@
1
1
  export * from './avatar';
2
2
  export * from './avatar_group';
3
+ export * from './badge';
3
4
  export * from './button';
4
5
  export * from './heading';
5
6
  export * from './icon';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/display/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAA;AACxB,cAAc,gBAAgB,CAAA;AAC9B,cAAc,UAAU,CAAA;AACxB,cAAc,WAAW,CAAA;AACzB,cAAc,QAAQ,CAAA;AACtB,cAAc,eAAe,CAAA;AAC7B,cAAc,SAAS,CAAA;AACvB,cAAc,WAAW,CAAA;AACzB,cAAc,UAAU,CAAA;AACxB,cAAc,QAAQ,CAAA;AACtB,cAAc,eAAe,CAAA;AAC7B,cAAc,sBAAsB,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/display/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAA;AACxB,cAAc,gBAAgB,CAAA;AAC9B,cAAc,SAAS,CAAA;AACvB,cAAc,UAAU,CAAA;AACxB,cAAc,WAAW,CAAA;AACzB,cAAc,QAAQ,CAAA;AACtB,cAAc,eAAe,CAAA;AAC7B,cAAc,SAAS,CAAA;AACvB,cAAc,WAAW,CAAA;AACzB,cAAc,UAAU,CAAA;AACxB,cAAc,QAAQ,CAAA;AACtB,cAAc,eAAe,CAAA;AAC7B,cAAc,sBAAsB,CAAA"}
@@ -1,5 +1,6 @@
1
1
  export * from './avatar';
2
2
  export * from './avatar_group';
3
+ export * from './badge';
3
4
  export * from './button';
4
5
  export * from './heading';
5
6
  export * from './icon';
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/display/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAA;AACxB,cAAc,gBAAgB,CAAA;AAC9B,cAAc,UAAU,CAAA;AACxB,cAAc,WAAW,CAAA;AACzB,cAAc,QAAQ,CAAA;AACtB,cAAc,eAAe,CAAA;AAC7B,cAAc,SAAS,CAAA;AACvB,cAAc,WAAW,CAAA;AACzB,cAAc,UAAU,CAAA;AACxB,cAAc,QAAQ,CAAA;AACtB,cAAc,eAAe,CAAA;AAC7B,cAAc,sBAAsB,CAAA","sourcesContent":["export * from './avatar'\nexport * from './avatar_group'\nexport * from './button'\nexport * from './heading'\nexport * from './icon'\nexport * from './icon_button'\nexport * from './image'\nexport * from './spinner'\nexport * from './switch'\nexport * from './text'\nexport * from './text_button'\nexport * from './text_inline_button'\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/display/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAA;AACxB,cAAc,gBAAgB,CAAA;AAC9B,cAAc,SAAS,CAAA;AACvB,cAAc,UAAU,CAAA;AACxB,cAAc,WAAW,CAAA;AACzB,cAAc,QAAQ,CAAA;AACtB,cAAc,eAAe,CAAA;AAC7B,cAAc,SAAS,CAAA;AACvB,cAAc,WAAW,CAAA;AACzB,cAAc,UAAU,CAAA;AACxB,cAAc,QAAQ,CAAA;AACtB,cAAc,eAAe,CAAA;AAC7B,cAAc,sBAAsB,CAAA","sourcesContent":["export * from './avatar'\nexport * from './avatar_group'\nexport * from './badge'\nexport * from './button'\nexport * from './heading'\nexport * from './icon'\nexport * from './icon_button'\nexport * from './image'\nexport * from './spinner'\nexport * from './switch'\nexport * from './text'\nexport * from './text_button'\nexport * from './text_inline_button'\n"]}
@@ -0,0 +1,45 @@
1
+ import { MessageResource } from '../types';
2
+ import { SuspensePaginatorOptions } from './use_suspense_api';
3
+ export declare const useConversationMessages: ({ conversation_id }: {
4
+ conversation_id: string;
5
+ }, opts?: SuspensePaginatorOptions) => {
6
+ messages: MessageResource[];
7
+ refetch: (options?: import("@tanstack/query-core").RefetchOptions) => Promise<import("@tanstack/query-core").QueryObserverResult<import("@tanstack/query-core").InfiniteData<import("../types").ApiCollection<MessageResource>, unknown>, Response>>;
8
+ isRefetching: boolean;
9
+ fetchNextPage: (options?: import("@tanstack/query-core").FetchNextPageOptions) => Promise<import("@tanstack/query-core").InfiniteQueryObserverResult<import("@tanstack/query-core").InfiniteData<import("../types").ApiCollection<MessageResource>, unknown>, Response>>;
10
+ queryKey: (string | {
11
+ perPage: number;
12
+ fields: {
13
+ Message: string[];
14
+ Person: string[];
15
+ ReactionCount: string[];
16
+ };
17
+ include: string[];
18
+ })[];
19
+ };
20
+ export declare const getMessagesRequestArgs: ({ conversation_id }: {
21
+ conversation_id: string;
22
+ }) => {
23
+ url: string;
24
+ data: {
25
+ perPage: number;
26
+ fields: {
27
+ Message: string[];
28
+ Person: string[];
29
+ ReactionCount: string[];
30
+ };
31
+ include: string[];
32
+ };
33
+ };
34
+ export declare const getMessagesQueryKey: ({ conversation_id }: {
35
+ conversation_id: string;
36
+ }) => (string | {
37
+ perPage: number;
38
+ fields: {
39
+ Message: string[];
40
+ Person: string[];
41
+ ReactionCount: string[];
42
+ };
43
+ include: string[];
44
+ })[];
45
+ //# sourceMappingURL=use_conversation_messages.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use_conversation_messages.d.ts","sourceRoot":"","sources":["../../src/hooks/use_conversation_messages.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,UAAU,CAAA;AAC1C,OAAO,EAAE,wBAAwB,EAAwB,MAAM,oBAAoB,CAAA;AAEnF,eAAO,MAAM,uBAAuB,wBACb;IAAE,eAAe,EAAE,MAAM,CAAA;CAAE,SACzC,wBAAwB;;;;;;;;;;;;;;CAUhC,CAAA;AAED,eAAO,MAAM,sBAAsB,wBAAyB;IAAE,eAAe,EAAE,MAAM,CAAA;CAAE;;;;;;;;;;;CAoBrF,CAAA;AAEF,eAAO,MAAM,mBAAmB,wBAAyB;IAAE,eAAe,EAAE,MAAM,CAAA;CAAE;;;;;;;;IAGnF,CAAA"}
@@ -0,0 +1,33 @@
1
+ import { useSuspensePaginator } from './use_suspense_api';
2
+ export const useConversationMessages = ({ conversation_id }, opts) => {
3
+ const { data, refetch, isRefetching, fetchNextPage } = useSuspensePaginator(getMessagesRequestArgs({ conversation_id }), opts);
4
+ const queryKey = getMessagesQueryKey({ conversation_id });
5
+ const messages = data.sort((a, b) => -a.id.localeCompare(b.id));
6
+ return { messages, refetch, isRefetching, fetchNextPage, queryKey };
7
+ };
8
+ export const getMessagesRequestArgs = ({ conversation_id }) => ({
9
+ url: `/me/conversations/${conversation_id}/messages`,
10
+ data: {
11
+ perPage: 25,
12
+ fields: {
13
+ Message: [
14
+ 'text',
15
+ 'text_edited_at',
16
+ 'mine',
17
+ 'attachments',
18
+ 'created_at',
19
+ 'deleted_at',
20
+ 'author',
21
+ 'reaction_counts',
22
+ ],
23
+ Person: ['name', 'avatar'],
24
+ ReactionCount: ['value', 'count', 'mine', 'message_id', 'author_ids'],
25
+ },
26
+ include: ['author', 'reaction_counts'],
27
+ },
28
+ });
29
+ export const getMessagesQueryKey = ({ conversation_id }) => {
30
+ const requestArgs = getMessagesRequestArgs({ conversation_id });
31
+ return [requestArgs.url, requestArgs.data];
32
+ };
33
+ //# sourceMappingURL=use_conversation_messages.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use_conversation_messages.js","sourceRoot":"","sources":["../../src/hooks/use_conversation_messages.ts"],"names":[],"mappings":"AACA,OAAO,EAA4B,oBAAoB,EAAE,MAAM,oBAAoB,CAAA;AAEnF,MAAM,CAAC,MAAM,uBAAuB,GAAG,CACrC,EAAE,eAAe,EAA+B,EAChD,IAA+B,EAC/B,EAAE;IACF,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,GAAG,oBAAoB,CACzE,sBAAsB,CAAC,EAAE,eAAe,EAAE,CAAC,EAC3C,IAAI,CACL,CAAA;IACD,MAAM,QAAQ,GAAG,mBAAmB,CAAC,EAAE,eAAe,EAAE,CAAC,CAAA;IACzD,MAAM,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,aAAa,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAA;IAE/D,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,QAAQ,EAAE,CAAA;AACrE,CAAC,CAAA;AAED,MAAM,CAAC,MAAM,sBAAsB,GAAG,CAAC,EAAE,eAAe,EAA+B,EAAE,EAAE,CAAC,CAAC;IAC3F,GAAG,EAAE,qBAAqB,eAAe,WAAW;IACpD,IAAI,EAAE;QACJ,OAAO,EAAE,EAAE;QACX,MAAM,EAAE;YACN,OAAO,EAAE;gBACP,MAAM;gBACN,gBAAgB;gBAChB,MAAM;gBACN,aAAa;gBACb,YAAY;gBACZ,YAAY;gBACZ,QAAQ;gBACR,iBAAiB;aAClB;YACD,MAAM,EAAE,CAAC,MAAM,EAAE,QAAQ,CAAC;YAC1B,aAAa,EAAE,CAAC,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,YAAY,EAAE,YAAY,CAAC;SACtE;QACD,OAAO,EAAE,CAAC,QAAQ,EAAE,iBAAiB,CAAC;KACvC;CACF,CAAC,CAAA;AAEF,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,EAAE,eAAe,EAA+B,EAAE,EAAE;IACtF,MAAM,WAAW,GAAG,sBAAsB,CAAC,EAAE,eAAe,EAAE,CAAC,CAAA;IAC/D,OAAO,CAAC,WAAW,CAAC,GAAG,EAAE,WAAW,CAAC,IAAI,CAAC,CAAA;AAC5C,CAAC,CAAA","sourcesContent":["import { MessageResource } from '../types'\nimport { SuspensePaginatorOptions, useSuspensePaginator } from './use_suspense_api'\n\nexport const useConversationMessages = (\n { conversation_id }: { conversation_id: string },\n opts?: SuspensePaginatorOptions\n) => {\n const { data, refetch, isRefetching, fetchNextPage } = useSuspensePaginator<MessageResource>(\n getMessagesRequestArgs({ conversation_id }),\n opts\n )\n const queryKey = getMessagesQueryKey({ conversation_id })\n const messages = data.sort((a, b) => -a.id.localeCompare(b.id))\n\n return { messages, refetch, isRefetching, fetchNextPage, queryKey }\n}\n\nexport const getMessagesRequestArgs = ({ conversation_id }: { conversation_id: string }) => ({\n url: `/me/conversations/${conversation_id}/messages`,\n data: {\n perPage: 25,\n fields: {\n Message: [\n 'text',\n 'text_edited_at',\n 'mine',\n 'attachments',\n 'created_at',\n 'deleted_at',\n 'author',\n 'reaction_counts',\n ],\n Person: ['name', 'avatar'],\n ReactionCount: ['value', 'count', 'mine', 'message_id', 'author_ids'],\n },\n include: ['author', 'reaction_counts'],\n },\n})\n\nexport const getMessagesQueryKey = ({ conversation_id }: { conversation_id: string }) => {\n const requestArgs = getMessagesRequestArgs({ conversation_id })\n return [requestArgs.url, requestArgs.data]\n}\n"]}
@@ -1,4 +1,4 @@
1
- import { InfiniteData } from '@tanstack/react-query';
1
+ import { AnyUseSuspenseInfiniteQueryOptions, InfiniteData } from '@tanstack/react-query';
2
2
  import { ApiCollection, ApiResource, ResourceObject } from '../types';
3
3
  import { GetRequest } from '../utils/client/types';
4
4
  export declare const useSuspenseGet: <T extends ResourceObject | ResourceObject[]>(args: GetRequest) => (T extends ResourceObject ? ApiResource<T> : ApiCollection<T>) & {
@@ -25,7 +25,8 @@ export declare const useSuspenseGet: <T extends ResourceObject | ResourceObject[
25
25
  refetch: (options?: import("@tanstack/react-query").RefetchOptions) => Promise<import("@tanstack/react-query").QueryObserverResult<T extends ResourceObject ? ApiResource<T> : ApiCollection<T>, Response>>;
26
26
  fetchStatus: import("@tanstack/react-query").FetchStatus;
27
27
  };
28
- export declare const useSuspensePaginator: <T extends ResourceObject>(args: GetRequest) => {
28
+ export type SuspensePaginatorOptions = Omit<AnyUseSuspenseInfiniteQueryOptions, 'getNextPageParam' | 'initialPageParam' | 'queryFn' | 'queryKey'>;
29
+ export declare const useSuspensePaginator: <T extends ResourceObject>(args: GetRequest, opts?: SuspensePaginatorOptions) => {
29
30
  data: T[];
30
31
  error: Response | null;
31
32
  isError: boolean;
@@ -1 +1 @@
1
- {"version":3,"file":"use_suspense_api.d.ts","sourceRoot":"","sources":["../../src/hooks/use_suspense_api.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAA8C,MAAM,uBAAuB,CAAA;AAGhG,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,UAAU,CAAA;AACrE,OAAO,EAAE,UAAU,EAAe,MAAM,uBAAuB,CAAA;AAE/D,eAAO,MAAM,cAAc,GAAI,CAAC,SAAS,cAAc,GAAG,cAAc,EAAE,QAAQ,UAAU;;;;;;;;;;;;;;;;;;;;;;;CAQ3F,CAAA;AAOD,eAAO,MAAM,oBAAoB,GAAI,CAAC,SAAS,cAAc,QAAQ,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAsC9E,CAAA"}
1
+ {"version":3,"file":"use_suspense_api.d.ts","sourceRoot":"","sources":["../../src/hooks/use_suspense_api.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,kCAAkC,EAClC,YAAY,EAGb,MAAM,uBAAuB,CAAA;AAG9B,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,UAAU,CAAA;AACrE,OAAO,EAAE,UAAU,EAAe,MAAM,uBAAuB,CAAA;AAE/D,eAAO,MAAM,cAAc,GAAI,CAAC,SAAS,cAAc,GAAG,cAAc,EAAE,QAAQ,UAAU;;;;;;;;;;;;;;;;;;;;;;;CAQ3F,CAAA;AAOD,MAAM,MAAM,wBAAwB,GAAG,IAAI,CACzC,kCAAkC,EAClC,kBAAkB,GAAG,kBAAkB,GAAG,SAAS,GAAG,UAAU,CACjE,CAAA;AAED,eAAO,MAAM,oBAAoB,GAAI,CAAC,SAAS,cAAc,QACrD,UAAU,SACT,wBAAwB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAwChC,CAAA"}
@@ -1,4 +1,4 @@
1
- import { useSuspenseInfiniteQuery, useSuspenseQuery } from '@tanstack/react-query';
1
+ import { useSuspenseInfiniteQuery, useSuspenseQuery, } from '@tanstack/react-query';
2
2
  import { useContext } from 'react';
3
3
  import { ChatContext } from '../contexts';
4
4
  export const useSuspenseGet = (args) => {
@@ -7,7 +7,7 @@ export const useSuspenseGet = (args) => {
7
7
  });
8
8
  return { ...data, ...query };
9
9
  };
10
- export const useSuspensePaginator = (args) => {
10
+ export const useSuspensePaginator = (args, opts) => {
11
11
  const { client } = useContext(ChatContext);
12
12
  const query = useSuspenseInfiniteQuery({
13
13
  queryKey: [args.url, args.data],
@@ -32,6 +32,7 @@ export const useSuspensePaginator = (args) => {
32
32
  return { offset: Number(offset) };
33
33
  return undefined;
34
34
  },
35
+ ...(opts || {}),
35
36
  });
36
37
  const data = query.data?.pages.flatMap(page => page.data) || [];
37
38
  return { ...query, data };
@@ -1 +1 @@
1
- {"version":3,"file":"use_suspense_api.js","sourceRoot":"","sources":["../../src/hooks/use_suspense_api.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,wBAAwB,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAA;AAChG,OAAO,EAAE,UAAU,EAAE,MAAM,OAAO,CAAA;AAClC,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAA;AAIzC,MAAM,CAAC,MAAM,cAAc,GAAG,CAA8C,IAAgB,EAAE,EAAE;IAG9F,MAAM,EAAE,IAAI,EAAE,GAAG,KAAK,EAAE,GAAG,gBAAgB,CAAqB;QAC9D,QAAQ,EAAE,CAAC,IAAI,CAAC;KACjB,CAAC,CAAA;IAEF,OAAO,EAAE,GAAG,IAAI,EAAE,GAAG,KAAK,EAAE,CAAA;AAC9B,CAAC,CAAA;AAOD,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAA2B,IAAgB,EAAE,EAAE;IACjF,MAAM,EAAE,MAAM,EAAE,GAAG,UAAU,CAAC,WAAW,CAAC,CAAA;IAC1C,MAAM,KAAK,GAAG,wBAAwB,CAMpC;QACA,QAAQ,EAAE,CAAC,IAAI,CAAC,GAAG,EAAE,IAAI,CAAC,IAAI,CAAC;QAC/B,OAAO,EAAE,CA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'@tanstack/react-query'\nimport { useContext } from 'react'\nimport { ChatContext } from '../contexts'\nimport { ApiCollection, ApiResource, ResourceObject } from '../types'\nimport { GetRequest, RequestData } from '../utils/client/types'\n\nexport const useSuspenseGet = <T extends ResourceObject | ResourceObject[]>(args: GetRequest) => {\n type Resource = T extends ResourceObject ? ApiResource<T> : ApiCollection<T>\n\n const { data, ...query } = useSuspenseQuery<Resource, Response>({\n queryKey: [args],\n })\n\n return { ...data, ...query }\n}\n\ntype NextMeta = Partial<{\n offset: string\n idLt: string\n}>\n\nexport const useSuspensePaginator = <T extends ResourceObject>(args: GetRequest) => {\n const { client } = useContext(ChatContext)\n const query = useSuspenseInfiniteQuery<\n ApiCollection<T>,\n Response,\n InfiniteData<ApiCollection<T>>,\n any,\n Partial<RequestData> | undefined\n >({\n queryKey: [args.url, args.data],\n queryFn: ({ pageParam }) => {\n const pageParmWhere = pageParam?.where || {}\n const argsWhere = args.data.where || {}\n const where = { ...argsWhere, ...pageParmWhere }\n\n const offset = pageParam?.offset || args.data.offset\n const data = { ...args.data, where, offset }\n\n return client.get({\n url: args.url,\n data,\n })\n },\n initialPageParam: {} as Partial<RequestData>,\n getNextPageParam: lastPage => {\n const next: NextMeta = lastPage.meta?.next || {}\n const { offset, idLt } = next\n\n if (idLt) return { where: { id_lt: idLt } }\n if (offset) return { offset: Number(offset) }\n\n return undefined\n },\n })\n\n const data: T[] = query.data?.pages.flatMap(page => page.data) || []\n\n return { ...query, data }\n}\n"]}
1
+ {"version":3,"file":"use_suspense_api.js","sourceRoot":"","sources":["../../src/hooks/use_suspense_api.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,wBAAwB,EACxB,gBAAgB,GACjB,MAAM,uBAAuB,CAAA;AAC9B,OAAO,EAAE,UAAU,EAAE,MAAM,OAAO,CAAA;AAClC,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAA;AAIzC,MAAM,CAAC,MAAM,cAAc,GAAG,CAA8C,IAAgB,EAAE,EAAE;IAG9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gBAAE,OAAO,EAAE,KAAK,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,EAAE,CAAA;YAC3C,IAAI,MAAM;gBAAE,OAAO,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC,EAAE,CAAA;YAE7C,OAAO,SAAS,CAAA;QAClB,CAAC;QACD,GAAG,CAAC,IAAI,IAAI,EAAE,CAAC;KAChB,CAAC,CAAA;IAEF,MAAM,IAAI,GAAQ,KAAK,CAAC,IAAI,EAAE,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,CAAA;IAEpE,OAAO,EAAE,GAAG,KAAK,EAAE,IAAI,EAAE,CAAA;AAC3B,CAAC,CAAA","sourcesContent":["import {\n AnyUseSuspenseInfiniteQueryOptions,\n InfiniteData,\n useSuspenseInfiniteQuery,\n useSuspenseQuery,\n} from '@tanstack/react-query'\nimport { useContext } from 'react'\nimport { ChatContext } from '../contexts'\nimport { ApiCollection, ApiResource, ResourceObject } from '../types'\nimport { GetRequest, RequestData } from '../utils/client/types'\n\nexport const useSuspenseGet = <T extends ResourceObject | ResourceObject[]>(args: GetRequest) => {\n type Resource = T extends ResourceObject ? ApiResource<T> : ApiCollection<T>\n\n const { data, ...query } = useSuspenseQuery<Resource, Response>({\n queryKey: [args],\n })\n\n return { ...data, ...query }\n}\n\ntype NextMeta = Partial<{\n offset: string\n idLt: string\n}>\n\nexport type SuspensePaginatorOptions = Omit<\n AnyUseSuspenseInfiniteQueryOptions,\n 'getNextPageParam' | 'initialPageParam' | 'queryFn' | 'queryKey'\n>\n\nexport const useSuspensePaginator = <T extends ResourceObject>(\n args: GetRequest,\n opts?: SuspensePaginatorOptions\n) => {\n const { client } = useContext(ChatContext)\n const query = useSuspenseInfiniteQuery<\n ApiCollection<T>,\n Response,\n InfiniteData<ApiCollection<T>>,\n any,\n Partial<RequestData> | undefined\n >({\n queryKey: [args.url, args.data],\n queryFn: ({ pageParam }) => {\n const pageParmWhere = pageParam?.where || {}\n const argsWhere = args.data.where || {}\n const where = { ...argsWhere, ...pageParmWhere }\n\n const offset = pageParam?.offset || args.data.offset\n const data = { ...args.data, where, offset }\n\n return client.get({\n url: args.url,\n data,\n })\n },\n initialPageParam: {} as Partial<RequestData>,\n getNextPageParam: lastPage => {\n const next: NextMeta = lastPage.meta?.next || {}\n const { offset, idLt } = next\n\n if (idLt) return { where: { id_lt: idLt } }\n if (offset) return { offset: Number(offset) }\n\n return undefined\n },\n ...(opts || {}),\n })\n\n const data: T[] = query.data?.pages.flatMap(page => page.data) || []\n\n return { ...query, data }\n}\n"]}
@@ -4,6 +4,7 @@ import { NotFound } from '../screens/not_found';
4
4
  import { ScreenLayout } from './screenLayout';
5
5
  import { ConversationsScreen } from '../screens/conversations_screen';
6
6
  import { ConversationScreen } from '../screens/conversation_screen';
7
+ import { MessageActionsScreen } from '../screens/message_actions_screen';
7
8
  export declare const ChatStack: import("@react-navigation/native").TypedNavigator<{
8
9
  ParamList: import("@react-navigation/native").ParamListBase;
9
10
  NavigatorID: undefined;
@@ -32,6 +33,10 @@ export declare const ChatStack: import("@react-navigation/native").TypedNavigato
32
33
  readonly Conversation: {
33
34
  readonly screen: typeof ConversationScreen;
34
35
  };
36
+ readonly MessageActions: {
37
+ readonly screen: typeof MessageActionsScreen;
38
+ readonly options: import("@react-navigation/native-stack").NativeStackNavigationOptions;
39
+ };
35
40
  readonly NotFound: {
36
41
  readonly screen: typeof NotFound;
37
42
  readonly options: {
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/navigation/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AACzB,OAAO,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAA;AAE1D,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAA;AAC/C,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAA;AAC7C,OAAO,EAAE,mBAAmB,EAAE,MAAM,iCAAiC,CAAA;AACrE,OAAO,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAA;AAInE,eAAO,MAAM,SAAS;;;;;;;;;uOAApB,mBAAmB;;;;;;;;;uBA0C+lhB,gBAAiB,KAAK;;;;;;;;;;;;;;;;;;;;EATxohB,CAAA;AAEF,KAAK,kBAAkB,GAAG,eAAe,CAAC,OAAO,SAAS,CAAC,CAAA;AAE3D,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,eAAe,CAAC;QACxB,UAAU,aAAc,SAAQ,kBAAkB;SAAG;KACtD;CACF"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/navigation/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AACzB,OAAO,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAA;AAE1D,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAA;AAC/C,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAA;AAC7C,OAAO,EAAE,mBAAmB,EAAE,MAAM,iCAAiC,CAAA;AACrE,OAAO,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAA;AAGnE,OAAO,EAAE,oBAAoB,EAAsB,MAAM,mCAAmC,CAAA;AAE5F,eAAO,MAAM,SAAS;;;;;;;;;uOAFb,mBAAkB;;;;;;;;;uBAiDq3gB,gBAAiB,KAAK;;;;;;;;;;;;;;;;;;;;;;;;EATp6gB,CAAA;AAEF,KAAK,kBAAkB,GAAG,eAAe,CAAC,OAAO,SAAS,CAAC,CAAA;AAE3D,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,eAAe,CAAC;QACxB,UAAU,aAAc,SAAQ,kBAAkB;SAAG;KACtD;CACF"}
@@ -4,8 +4,9 @@ import { NotFound } from '../screens/not_found';
4
4
  import { ScreenLayout } from './screenLayout';
5
5
  import { ConversationsScreen } from '../screens/conversations_screen';
6
6
  import { ConversationScreen } from '../screens/conversation_screen';
7
- import { HeaderBackButton, PlatformPressable } from '@react-navigation/elements';
7
+ import { HeaderBackButton, HeaderButton } from '@react-navigation/elements';
8
8
  import { Icon } from '../components';
9
+ import { MessageActionsScreen, ReactScreenOptions } from '../screens/message_actions_screen';
9
10
  export const ChatStack = createNativeStackNavigator({
10
11
  screenLayout: ScreenLayout,
11
12
  screens: {
@@ -13,15 +14,20 @@ export const ChatStack = createNativeStackNavigator({
13
14
  screen: ConversationsScreen,
14
15
  options: ({ route, navigation }) => ({
15
16
  headerTitle: route.params?.title ?? 'Chat',
16
- headerLeft: () => (<PlatformPressable onPress={() => null}>
17
+ headerLeft: () => (<HeaderButton>
17
18
  <Icon name="general.threeReducingHorizontalBars" size={18}/>
18
- </PlatformPressable>),
19
+ </HeaderButton>),
19
20
  headerRight: () => (<HeaderBackButton onPress={navigation.goBack} backImage={() => <Icon name="general.x" size={18}/>}/>),
20
21
  }),
21
22
  },
22
23
  Conversation: {
23
24
  screen: ConversationScreen,
24
25
  },
26
+ MessageActions: {
27
+ screen: MessageActionsScreen,
28
+ // Something about sheetAllowedDetents declared inline breaks TS
29
+ options: ReactScreenOptions,
30
+ },
25
31
  NotFound: {
26
32
  screen: NotFound,
27
33
  options: {