@planningcenter/chat-react-native 2.1.1 → 2.2.0-rc.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/components/conversation/message_form.d.ts.map +1 -1
- package/build/components/conversation/message_form.js +4 -4
- package/build/components/conversation/message_form.js.map +1 -1
- package/build/components/display/badge.d.ts +2 -9
- package/build/components/display/badge.d.ts.map +1 -1
- package/build/components/display/badge.js +8 -40
- package/build/components/display/badge.js.map +1 -1
- package/build/components/display/banner.d.ts +29 -0
- package/build/components/display/banner.d.ts.map +1 -0
- package/build/components/display/banner.js +16 -0
- package/build/components/display/banner.js.map +1 -0
- package/build/components/display/button.d.ts +1 -1
- package/build/components/display/button.d.ts.map +1 -1
- package/build/components/display/button.js +1 -1
- package/build/components/display/button.js.map +1 -1
- package/build/components/display/icon_button.d.ts +1 -1
- package/build/components/display/icon_button.d.ts.map +1 -1
- package/build/components/display/icon_button.js +1 -1
- package/build/components/display/icon_button.js.map +1 -1
- package/build/components/display/index.d.ts +1 -0
- package/build/components/display/index.d.ts.map +1 -1
- package/build/components/display/index.js +1 -0
- package/build/components/display/index.js.map +1 -1
- package/build/components/display/text_button.d.ts +1 -1
- package/build/components/display/text_button.d.ts.map +1 -1
- package/build/components/display/text_button.js +1 -1
- package/build/components/display/text_button.js.map +1 -1
- package/build/components/display/text_inline_button.d.ts +2 -2
- package/build/components/display/text_inline_button.d.ts.map +1 -1
- package/build/components/display/text_inline_button.js +3 -2
- package/build/components/display/text_inline_button.js.map +1 -1
- package/build/components/display/{button_color_utils.d.ts → utils/button_colors.d.ts} +1 -1
- package/build/components/display/utils/button_colors.d.ts.map +1 -0
- package/build/components/display/{button_color_utils.js → utils/button_colors.js} +2 -2
- package/build/components/display/utils/button_colors.js.map +1 -0
- package/build/components/display/utils/status_colors.d.ts +17 -0
- package/build/components/display/utils/status_colors.d.ts.map +1 -0
- package/build/components/display/utils/status_colors.js +49 -0
- package/build/components/display/utils/status_colors.js.map +1 -0
- package/build/components/primitive/banner_primitive.d.ts +38 -0
- package/build/components/primitive/banner_primitive.d.ts.map +1 -0
- package/build/components/primitive/banner_primitive.js +112 -0
- package/build/components/primitive/banner_primitive.js.map +1 -0
- package/build/contexts/api_provider.js +4 -3
- package/build/contexts/api_provider.js.map +1 -1
- package/build/contexts/chat_context.d.ts +2 -2
- package/build/contexts/chat_context.d.ts.map +1 -1
- package/build/contexts/chat_context.js +3 -15
- package/build/contexts/chat_context.js.map +1 -1
- package/build/hooks/use_api_client.d.ts +6 -0
- package/build/hooks/use_api_client.d.ts.map +1 -0
- package/build/hooks/use_api_client.js +18 -0
- package/build/hooks/use_api_client.js.map +1 -0
- package/build/hooks/use_conversation.d.ts +122 -0
- package/build/hooks/use_conversation.d.ts.map +1 -0
- package/build/hooks/use_conversation.js +103 -0
- package/build/hooks/use_conversation.js.map +1 -0
- package/build/hooks/use_conversation_jolt_events.d.ts.map +1 -1
- package/build/hooks/use_conversation_jolt_events.js +3 -4
- package/build/hooks/use_conversation_jolt_events.js.map +1 -1
- package/build/hooks/use_font_scale.d.ts +1 -1
- package/build/hooks/use_font_scale.d.ts.map +1 -1
- package/build/hooks/use_font_scale.js +1 -1
- package/build/hooks/use_font_scale.js.map +1 -1
- package/build/hooks/use_jolt.d.ts +1 -1
- package/build/hooks/use_jolt.d.ts.map +1 -1
- package/build/hooks/use_jolt.js +6 -6
- package/build/hooks/use_jolt.js.map +1 -1
- package/build/hooks/use_suspense_api.d.ts.map +1 -1
- package/build/hooks/use_suspense_api.js +3 -4
- package/build/hooks/use_suspense_api.js.map +1 -1
- package/build/navigation/header.d.ts +10 -0
- package/build/navigation/header.d.ts.map +1 -0
- package/build/navigation/header.js +16 -0
- package/build/navigation/header.js.map +1 -0
- package/build/navigation/index.d.ts +17 -4
- package/build/navigation/index.d.ts.map +1 -1
- package/build/navigation/index.js +18 -6
- package/build/navigation/index.js.map +1 -1
- package/build/screens/conversation_details_screen.d.ts +7 -0
- package/build/screens/conversation_details_screen.d.ts.map +1 -0
- package/build/screens/conversation_details_screen.js +155 -0
- package/build/screens/conversation_details_screen.js.map +1 -0
- package/build/screens/conversation_screen.d.ts +5 -3
- package/build/screens/conversation_screen.d.ts.map +1 -1
- package/build/screens/conversation_screen.js +43 -15
- package/build/screens/conversation_screen.js.map +1 -1
- package/build/screens/design_system_screen.d.ts.map +1 -1
- package/build/screens/design_system_screen.js +24 -1
- package/build/screens/design_system_screen.js.map +1 -1
- package/build/screens/message_actions_screen.d.ts.map +1 -1
- package/build/screens/message_actions_screen.js +7 -7
- package/build/screens/message_actions_screen.js.map +1 -1
- package/build/utils/client/request_helpers.d.ts +2 -1
- package/build/utils/client/request_helpers.d.ts.map +1 -1
- package/build/utils/client/request_helpers.js +17 -0
- package/build/utils/client/request_helpers.js.map +1 -1
- package/package.json +2 -2
- package/src/components/conversation/message_form.tsx +4 -4
- package/src/components/display/badge.tsx +9 -53
- package/src/components/display/banner.tsx +56 -0
- package/src/components/display/button.tsx +2 -2
- package/src/components/display/icon_button.tsx +2 -2
- package/src/components/display/index.ts +1 -0
- package/src/components/display/text_button.tsx +2 -2
- package/src/components/display/text_inline_button.tsx +4 -2
- package/src/components/display/{button_color_utils.ts → utils/button_colors.ts} +1 -1
- package/src/components/display/utils/status_colors.ts +85 -0
- package/src/components/primitive/banner_primitive.tsx +247 -0
- package/src/contexts/api_provider.tsx +5 -5
- package/src/contexts/chat_context.tsx +4 -21
- package/src/hooks/use_api_client.ts +29 -0
- package/src/hooks/use_conversation.ts +113 -0
- package/src/hooks/use_conversation_jolt_events.ts +3 -4
- package/src/hooks/use_font_scale.ts +3 -1
- package/src/hooks/use_jolt.ts +9 -9
- package/src/hooks/use_suspense_api.ts +3 -4
- package/src/navigation/header.tsx +24 -0
- package/src/navigation/index.tsx +20 -6
- package/src/screens/conversation_details_screen.tsx +205 -0
- package/src/screens/conversation_screen.tsx +65 -20
- package/src/screens/design_system_screen.tsx +56 -0
- package/src/screens/message_actions_screen.tsx +7 -7
- package/src/utils/client/request_helpers.ts +21 -1
- package/build/components/display/button_color_utils.d.ts.map +0 -1
- package/build/components/display/button_color_utils.js.map +0 -1
|
@@ -6,6 +6,7 @@ import {
|
|
|
6
6
|
Avatar,
|
|
7
7
|
AvatarGroup,
|
|
8
8
|
Badge,
|
|
9
|
+
Banner,
|
|
9
10
|
Button,
|
|
10
11
|
Heading,
|
|
11
12
|
Icon,
|
|
@@ -23,6 +24,7 @@ import {
|
|
|
23
24
|
platformPressedOpacityStyle,
|
|
24
25
|
platformFontWeightMedium,
|
|
25
26
|
} from '../utils'
|
|
27
|
+
import BannerPrimitive from '../components/primitive/banner_primitive'
|
|
26
28
|
|
|
27
29
|
// =================================
|
|
28
30
|
// ====== Docs Utils ===============
|
|
@@ -756,6 +758,47 @@ function StatusComponentsSection({ isLast }: SectionProps) {
|
|
|
756
758
|
<Badge variant="metaSubtle" productLogoName="services" label="Team" />
|
|
757
759
|
</Row>
|
|
758
760
|
</Group>
|
|
761
|
+
<Group
|
|
762
|
+
title="Banner"
|
|
763
|
+
description="Banners that can convey a status with color and an optional icon. They render a description and optional heading. A `Banner.Link` can be used by wrapping it in `Banner.Text` and passing it to `description`. Target products can change colors via theming."
|
|
764
|
+
>
|
|
765
|
+
<Column>
|
|
766
|
+
<Banner
|
|
767
|
+
appearance="neutral"
|
|
768
|
+
showIcon={false}
|
|
769
|
+
description="Et sint Quis non excepturi enim et conseq atur porro est galisum labore ea volupt."
|
|
770
|
+
/>
|
|
771
|
+
<Banner
|
|
772
|
+
appearance="info"
|
|
773
|
+
heading="Banner heading"
|
|
774
|
+
description="Et sint Quis non excepturi enim et conseq atur porro est galisum labore ea volupt."
|
|
775
|
+
/>
|
|
776
|
+
<Banner
|
|
777
|
+
appearance="success"
|
|
778
|
+
heading="Banner heading"
|
|
779
|
+
description={
|
|
780
|
+
<BannerPrimitive.Text>
|
|
781
|
+
Et sint Quis non excepturi{' '}
|
|
782
|
+
<BannerPrimitive.Link onPress={buttonPress}>
|
|
783
|
+
enim et conseq atur porro est
|
|
784
|
+
</BannerPrimitive.Link>{' '}
|
|
785
|
+
galisum labore ea volupt.
|
|
786
|
+
</BannerPrimitive.Text>
|
|
787
|
+
}
|
|
788
|
+
/>
|
|
789
|
+
<Banner
|
|
790
|
+
appearance="warning"
|
|
791
|
+
iconName="general.shieldExclamation"
|
|
792
|
+
heading="13 members under age 13"
|
|
793
|
+
description="Et sint Quis non excepturi enim et conseq atur porro est galisum labore ea volupt."
|
|
794
|
+
/>
|
|
795
|
+
<Banner
|
|
796
|
+
appearance="error"
|
|
797
|
+
heading="Banner heading"
|
|
798
|
+
description="Et sint Quis non excepturi enim et conseq atur porro est galisum labore ea volupt."
|
|
799
|
+
/>
|
|
800
|
+
</Column>
|
|
801
|
+
</Group>
|
|
759
802
|
</CollapsableSection>
|
|
760
803
|
)
|
|
761
804
|
}
|
|
@@ -818,6 +861,16 @@ function Row({ children, style }: RowProps) {
|
|
|
818
861
|
return <View style={[styles.row, style]}>{children}</View>
|
|
819
862
|
}
|
|
820
863
|
|
|
864
|
+
interface ColumnProps {
|
|
865
|
+
children: React.ReactNode
|
|
866
|
+
style?: ViewStyle
|
|
867
|
+
}
|
|
868
|
+
|
|
869
|
+
function Column({ children, style }: ColumnProps) {
|
|
870
|
+
const styles = useStyles()
|
|
871
|
+
return <View style={[styles.column, style]}>{children}</View>
|
|
872
|
+
}
|
|
873
|
+
|
|
821
874
|
function TextGroup({ children }: { children: React.ReactNode }) {
|
|
822
875
|
const styles = useStyles()
|
|
823
876
|
return <View style={styles.textGroup}>{children}</View>
|
|
@@ -893,6 +946,9 @@ const useStyles = () => {
|
|
|
893
946
|
justifyContent: 'center',
|
|
894
947
|
flexWrap: 'wrap',
|
|
895
948
|
},
|
|
949
|
+
column: {
|
|
950
|
+
gap: space(2),
|
|
951
|
+
},
|
|
896
952
|
textRow: {
|
|
897
953
|
gap: space(1.5),
|
|
898
954
|
},
|
|
@@ -2,13 +2,13 @@ import { PlatformPressable } from '@react-navigation/elements'
|
|
|
2
2
|
import { StaticScreenProps, useNavigation } from '@react-navigation/native'
|
|
3
3
|
import { NativeStackNavigationOptions } from '@react-navigation/native-stack'
|
|
4
4
|
import { InfiniteData, useMutation, useQueryClient } from '@tanstack/react-query'
|
|
5
|
-
import React, { useCallback
|
|
5
|
+
import React, { useCallback } from 'react'
|
|
6
6
|
import { Alert, Platform, StyleSheet, useWindowDimensions, View } from 'react-native'
|
|
7
7
|
import { useSafeAreaInsets } from 'react-native-safe-area-context'
|
|
8
8
|
import { Text, TextButton } from '../components'
|
|
9
9
|
import { REACTION_EMOJIS, useReactionStyles } from '../components/conversation/message_reaction'
|
|
10
|
-
import { ChatContext } from '../contexts'
|
|
11
10
|
import { useTheme } from '../hooks'
|
|
11
|
+
import { useApiClient } from '../hooks/use_api_client'
|
|
12
12
|
import { getMessagesRequestArgs, useConversationMessages } from '../hooks/use_conversation_messages'
|
|
13
13
|
import { ApiCollection, ApiResource, MessageResource } from '../types'
|
|
14
14
|
import { ReactionCountResource } from '../types/resources/reaction'
|
|
@@ -31,7 +31,7 @@ export function MessageActionsScreen({ route }: ReactionScreenProps) {
|
|
|
31
31
|
const navigation = useNavigation()
|
|
32
32
|
const { conversation_id, message_id } = route.params
|
|
33
33
|
|
|
34
|
-
const
|
|
34
|
+
const apiClient = useApiClient()
|
|
35
35
|
const queryClient = useQueryClient()
|
|
36
36
|
const styles = useStyles()
|
|
37
37
|
|
|
@@ -68,7 +68,7 @@ export function MessageActionsScreen({ route }: ReactionScreenProps) {
|
|
|
68
68
|
Object.entries(requestParams.data.fields).map(([k, v]) => [k, v.join(',')])
|
|
69
69
|
)
|
|
70
70
|
|
|
71
|
-
return
|
|
71
|
+
return apiClient.chat.post({
|
|
72
72
|
url,
|
|
73
73
|
data: {
|
|
74
74
|
...requestParams.data,
|
|
@@ -80,14 +80,14 @@ export function MessageActionsScreen({ route }: ReactionScreenProps) {
|
|
|
80
80
|
},
|
|
81
81
|
})
|
|
82
82
|
},
|
|
83
|
-
[
|
|
83
|
+
[apiClient, conversation_id, message_id]
|
|
84
84
|
)
|
|
85
85
|
|
|
86
86
|
const deleteMessage = useCallback(() => {
|
|
87
87
|
const url = `/me/conversations/${conversation_id}/messages/${message_id}/`
|
|
88
88
|
|
|
89
|
-
return
|
|
90
|
-
}, [
|
|
89
|
+
return apiClient.chat.delete({ url })
|
|
90
|
+
}, [apiClient, conversation_id, message_id])
|
|
91
91
|
|
|
92
92
|
const { mutate: handleReaction, isPending } = useMutation({
|
|
93
93
|
mutationFn: handleReactionPress,
|
|
@@ -2,7 +2,7 @@ import _ from 'lodash'
|
|
|
2
2
|
import URI from 'urijs'
|
|
3
3
|
import { transformRequestData } from './transform_request_data'
|
|
4
4
|
import transformResponse from './transform_response'
|
|
5
|
-
import { Accumulator, RequestData } from './types'
|
|
5
|
+
import { Accumulator, GetRequest, PostRequest, RequestData } from './types'
|
|
6
6
|
|
|
7
7
|
export type MakeRequestArgs = {
|
|
8
8
|
action: 'GET' | 'POST' | 'PATCH' | 'DELETE'
|
|
@@ -112,3 +112,23 @@ export const throwErrorIfQueryParams = url => {
|
|
|
112
112
|
|
|
113
113
|
return Promise.resolve()
|
|
114
114
|
}
|
|
115
|
+
|
|
116
|
+
export const transformGetToPost = (args: GetRequest): PostRequest => {
|
|
117
|
+
const { data, ...rest } = args
|
|
118
|
+
const { fields, include } = data
|
|
119
|
+
const fieldsArray = Object.entries(fields).map(([key, value]) => {
|
|
120
|
+
if (Array.isArray(value)) {
|
|
121
|
+
return [key, value.join(',')]
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
return [key, value]
|
|
125
|
+
})
|
|
126
|
+
|
|
127
|
+
return {
|
|
128
|
+
...rest,
|
|
129
|
+
data: {
|
|
130
|
+
fields: Object.fromEntries(fieldsArray),
|
|
131
|
+
include,
|
|
132
|
+
},
|
|
133
|
+
}
|
|
134
|
+
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"button_color_utils.d.ts","sour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,yBAAyB;KAC1C,CAAA;AACH,CAAC;AAGD,SAAS,mBAAmB;IAC1B,MAAM,EAAE,MAAM,EAAE,GAAG,QAAQ,EAAE,CAAA;IAE7B,MAAM,iBAAiB,GAAG,MAAM,CAAC,WAAW,IAAI,MAAM,CAAC,WAAW,CAAA;IAClE,MAAM,eAAe,GAAG,MAAM,CAAC,SAAS,IAAI,MAAM,CAAC,WAAW,CAAA;IAE9D,OAAO;QACL,WAAW,EAAE,CAAC,iBAAiB,EAAE,eAAe,CAAC;QACjD,MAAM,EAAE,CAAC,MAAM,CAAC,0BAA0B,EAAE,MAAM,CAAC,0BAA0B,CAAC;QAC9E,QAAQ,EAAE;YACR,MAAM,CAAC,mCAAmC;YAC1C,MAAM,CAAC,mCAAmC;SAC3C;KACF,CAAA;AACH,CAAC;AAWD,SAAS,WAAW,CAAC,EAAE,QAAQ,EAAE,OAAO,EAAE,UAAU,EAAmB;IACrE,IAAI,QAAQ,IAAI,OAAO;QAAE,OAAO,UAAU,CAAA;IAC1C,OAAO,UAAU,CAAA;AACnB,CAAC","sourcesContent":["import { useTheme } from '../../hooks'\n\n// =================================\n// ====== Exports ==================\n// =================================\n\nexport { getColorKey, useButtonColorOptionMap, useGradientColorMap, useIconButtonColorOptionMap }\nexport type { ButtonAppearanceUnion, IconButtonAppearanceUnion }\n\n// =================================\n// ====== Constants ================\n// =================================\n\nconst BUTTON_APPEARANCES = {\n danger: 'danger',\n interaction: 'interaction',\n} as const\n\ntype ButtonAppearanceUnion = (typeof BUTTON_APPEARANCES)[keyof typeof BUTTON_APPEARANCES]\n\nconst ICON_BUTTON_APPEARANCES = {\n ...BUTTON_APPEARANCES,\n neutral: 'neutral',\n} as const\n\ntype IconButtonAppearanceUnion =\n (typeof ICON_BUTTON_APPEARANCES)[keyof typeof ICON_BUTTON_APPEARANCES]\n\nconst BUTTON_COLOR_OPTIONS = {\n ...BUTTON_APPEARANCES,\n disabled: 'disabled',\n} as const\n\ntype ButtonColorOptionUnion = (typeof BUTTON_COLOR_OPTIONS)[keyof typeof BUTTON_COLOR_OPTIONS]\n\nconst ICON_BUTTON_COLOR_OPTIONS = {\n ...BUTTON_COLOR_OPTIONS,\n ...ICON_BUTTON_APPEARANCES,\n} as const\n\ntype IconButtonColorOptionUnion =\n (typeof ICON_BUTTON_COLOR_OPTIONS)[keyof typeof ICON_BUTTON_COLOR_OPTIONS]\n\n// =================================\n// ====== Hooks ====================\n// =================================\n\ntype ButtonColorOptionMap = Record<ButtonColorOptionUnion, string>\nfunction useButtonColorOptionMap(): ButtonColorOptionMap {\n const { colors } = useTheme()\n\n return {\n interaction: colors.interaction,\n danger: colors.fillColorStatusErrorMedium,\n disabled: colors.textColorDefaultDisabled,\n }\n}\n\ntype IconButtonColorOptionMap = Record<IconButtonColorOptionUnion, string>\nfunction useIconButtonColorOptionMap(): IconButtonColorOptionMap {\n const { colors } = useTheme()\n\n return {\n danger: colors.fillColorStatusErrorMedium,\n disabled: colors.textColorDefaultDisabled,\n interaction: colors.interaction,\n neutral: colors.iconColorDefaultSecondary,\n }\n}\n\ntype GradientColorMap = Record<ButtonColorOptionUnion, [string, string]>\nfunction useGradientColorMap(): GradientColorMap {\n const { colors } = useTheme()\n\n const defaultColorStart = colors.buttonStart || colors.interaction\n const defaultColorEnd = colors.buttonEnd || colors.interaction\n\n return {\n interaction: [defaultColorStart, defaultColorEnd],\n danger: [colors.fillColorStatusErrorMedium, colors.fillColorStatusErrorMedium],\n disabled: [\n colors.fillColorButtonNeutralSolidDisabled,\n colors.fillColorButtonNeutralSolidDisabled,\n ],\n }\n}\n\n// =================================\n// ====== Functions ================\n// =================================\n\ninterface GetColorKeyArgs {\n disabled: boolean | null\n loading?: boolean\n appearance: ButtonAppearanceUnion | IconButtonAppearanceUnion\n}\nfunction getColorKey({ disabled, loading, appearance }: GetColorKeyArgs) {\n if (disabled || loading) return 'disabled'\n return appearance\n}\n"]}
|