@planningcenter/chat-react-native 3.1.0-rc.13 → 3.1.0-rc.15
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/attachments/attachment_card.d.ts +9 -0
- package/build/components/conversation/attachments/attachment_card.d.ts.map +1 -0
- package/build/components/conversation/attachments/attachment_card.js +35 -0
- package/build/components/conversation/attachments/attachment_card.js.map +1 -0
- package/build/components/conversation/attachments/audio_attachment.d.ts +6 -0
- package/build/components/conversation/attachments/audio_attachment.d.ts.map +1 -0
- package/build/components/conversation/attachments/audio_attachment.js +84 -0
- package/build/components/conversation/attachments/audio_attachment.js.map +1 -0
- package/build/components/conversation/attachments/constants.d.ts +3 -0
- package/build/components/conversation/attachments/constants.d.ts.map +1 -0
- package/build/components/conversation/attachments/constants.js +4 -0
- package/build/components/conversation/attachments/constants.js.map +1 -0
- package/build/components/conversation/attachments/download_attachment_button.d.ts +9 -0
- package/build/components/conversation/attachments/download_attachment_button.d.ts.map +1 -0
- package/build/components/conversation/attachments/download_attachment_button.js +29 -0
- package/build/components/conversation/attachments/download_attachment_button.js.map +1 -0
- package/build/components/conversation/attachments/expanded_link.d.ts +5 -0
- package/build/components/conversation/attachments/expanded_link.d.ts.map +1 -0
- package/build/components/conversation/attachments/expanded_link.js +44 -0
- package/build/components/conversation/attachments/expanded_link.js.map +1 -0
- package/build/components/conversation/attachments/generic_file_attachment.d.ts +7 -0
- package/build/components/conversation/attachments/generic_file_attachment.d.ts.map +1 -0
- package/build/components/conversation/attachments/generic_file_attachment.js +63 -0
- package/build/components/conversation/attachments/generic_file_attachment.js.map +1 -0
- package/build/components/conversation/attachments/giphy_attachment.d.ts +6 -0
- package/build/components/conversation/attachments/giphy_attachment.d.ts.map +1 -0
- package/build/components/conversation/attachments/giphy_attachment.js +42 -0
- package/build/components/conversation/attachments/giphy_attachment.js.map +1 -0
- package/build/components/conversation/attachments/image_attachment.d.ts +5 -0
- package/build/components/conversation/attachments/image_attachment.d.ts.map +1 -0
- package/build/components/conversation/attachments/image_attachment.js +24 -0
- package/build/components/conversation/attachments/image_attachment.js.map +1 -0
- package/build/components/conversation/attachments/video_attachment.d.ts +6 -0
- package/build/components/conversation/attachments/video_attachment.d.ts.map +1 -0
- package/build/components/conversation/attachments/video_attachment.js +64 -0
- package/build/components/conversation/attachments/video_attachment.js.map +1 -0
- package/build/components/conversation/message.d.ts +1 -1
- package/build/components/conversation/message.d.ts.map +1 -1
- package/build/components/conversation/message.js +13 -7
- package/build/components/conversation/message.js.map +1 -1
- package/build/components/conversation/message_attachments.d.ts +6 -0
- package/build/components/conversation/message_attachments.d.ts.map +1 -0
- package/build/components/conversation/message_attachments.js +52 -0
- package/build/components/conversation/message_attachments.js.map +1 -0
- package/build/components/conversation/message_markdown.d.ts +7 -0
- package/build/components/conversation/message_markdown.d.ts.map +1 -0
- package/build/components/conversation/message_markdown.js +38 -0
- package/build/components/conversation/message_markdown.js.map +1 -0
- package/build/components/conversations/conversation_preview.d.ts +9 -0
- package/build/components/conversations/conversation_preview.d.ts.map +1 -0
- package/build/components/conversations/conversation_preview.js +58 -0
- package/build/components/conversations/conversation_preview.js.map +1 -0
- package/build/components/conversations/conversations.d.ts +8 -0
- package/build/components/conversations/conversations.d.ts.map +1 -0
- package/build/components/conversations/conversations.js +40 -0
- package/build/components/conversations/conversations.js.map +1 -0
- package/build/components/conversations/unread_count_badge.d.ts +5 -0
- package/build/components/conversations/unread_count_badge.d.ts.map +1 -0
- package/build/components/conversations/unread_count_badge.js +33 -0
- package/build/components/conversations/unread_count_badge.js.map +1 -0
- package/build/components/display/badge.d.ts +9 -1
- package/build/components/display/badge.d.ts.map +1 -1
- package/build/components/display/badge.js +22 -10
- package/build/components/display/badge.js.map +1 -1
- 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.map +1 -1
- package/build/components/display/child_notice.js +2 -2
- package/build/components/display/child_notice.js.map +1 -1
- package/build/components/display/icon.d.ts.map +1 -1
- package/build/components/display/icon.js +10 -8
- package/build/components/display/icon.js.map +1 -1
- package/build/components/display/text.js +2 -8
- package/build/components/display/text.js.map +1 -1
- package/build/components/index.d.ts +1 -1
- package/build/components/index.d.ts.map +1 -1
- package/build/components/index.js +1 -1
- package/build/components/index.js.map +1 -1
- package/build/components/page/error_boundary.d.ts +1 -1
- package/build/hooks/use_api.d.ts +6 -4
- package/build/hooks/use_api.d.ts.map +1 -1
- package/build/hooks/use_api.js +5 -2
- package/build/hooks/use_api.js.map +1 -1
- package/build/hooks/use_api_client.d.ts +1 -2
- package/build/hooks/use_api_client.d.ts.map +1 -1
- package/build/hooks/use_api_client.js.map +1 -1
- package/build/hooks/use_conversation.js +1 -1
- package/build/hooks/use_conversation.js.map +1 -1
- package/build/hooks/use_conversation_jolt_events.js +1 -1
- package/build/hooks/use_conversation_jolt_events.js.map +1 -1
- package/build/hooks/use_conversation_messages_jolt_events.js +1 -1
- package/build/hooks/use_conversation_messages_jolt_events.js.map +1 -1
- package/build/hooks/use_conversations.d.ts +2 -3
- package/build/hooks/use_conversations.d.ts.map +1 -1
- package/build/hooks/use_conversations.js +3 -29
- package/build/hooks/use_conversations.js.map +1 -1
- package/build/hooks/use_groups.d.ts +214 -0
- package/build/hooks/use_groups.d.ts.map +1 -0
- package/build/hooks/use_groups.js +22 -0
- package/build/hooks/use_groups.js.map +1 -0
- package/build/hooks/use_groups_groups.d.ts +208 -0
- package/build/hooks/use_groups_groups.d.ts.map +1 -0
- package/build/hooks/use_groups_groups.js +18 -0
- package/build/hooks/use_groups_groups.js.map +1 -0
- package/build/hooks/use_services_team.d.ts +4 -0
- package/build/hooks/use_services_team.d.ts.map +1 -0
- package/build/hooks/use_services_team.js +22 -0
- package/build/hooks/use_services_team.js.map +1 -0
- package/build/hooks/use_suspense_api.d.ts +2 -1
- package/build/hooks/use_suspense_api.d.ts.map +1 -1
- package/build/hooks/use_suspense_api.js +2 -1
- package/build/hooks/use_suspense_api.js.map +1 -1
- package/build/hooks/use_teams.d.ts +208 -0
- package/build/hooks/use_teams.d.ts.map +1 -0
- package/build/hooks/use_teams.js +22 -0
- package/build/hooks/use_teams.js.map +1 -0
- package/build/navigation/index.d.ts +11 -0
- package/build/navigation/index.d.ts.map +1 -1
- package/build/navigation/index.js +5 -0
- package/build/navigation/index.js.map +1 -1
- package/build/screens/conversation_details_screen.d.ts.map +1 -1
- package/build/screens/conversation_details_screen.js +86 -62
- package/build/screens/conversation_details_screen.js.map +1 -1
- package/build/screens/conversation_filters_screen.d.ts +13 -0
- package/build/screens/conversation_filters_screen.d.ts.map +1 -0
- package/build/screens/conversation_filters_screen.js +346 -0
- package/build/screens/conversation_filters_screen.js.map +1 -0
- package/build/screens/conversation_screen.js +2 -1
- package/build/screens/conversation_screen.js.map +1 -1
- package/build/screens/conversations_screen.d.ts +4 -2
- package/build/screens/conversations_screen.d.ts.map +1 -1
- package/build/screens/conversations_screen.js +139 -11
- package/build/screens/conversations_screen.js.map +1 -1
- package/build/screens/create/conversation_select_recipients_screen.d.ts.map +1 -1
- package/build/screens/create/conversation_select_recipients_screen.js +3 -11
- package/build/screens/create/conversation_select_recipients_screen.js.map +1 -1
- package/build/types/resources/group_resource.d.ts +4 -2
- package/build/types/resources/group_resource.d.ts.map +1 -1
- package/build/types/resources/group_resource.js.map +1 -1
- package/build/types/resources/index.d.ts +1 -0
- package/build/types/resources/index.d.ts.map +1 -1
- package/build/types/resources/index.js +1 -0
- package/build/types/resources/index.js.map +1 -1
- package/build/types/resources/services/index.d.ts +2 -0
- package/build/types/resources/services/index.d.ts.map +1 -0
- package/build/types/resources/services/index.js +2 -0
- package/build/types/resources/services/index.js.map +1 -0
- package/build/types/resources/services/team_resource.d.ts +48 -0
- package/build/types/resources/services/team_resource.d.ts.map +1 -0
- package/build/types/resources/services/team_resource.js +7 -0
- package/build/types/resources/services/team_resource.js.map +1 -0
- package/build/utils/index.d.ts +1 -0
- package/build/utils/index.d.ts.map +1 -1
- package/build/utils/index.js +1 -0
- package/build/utils/index.js.map +1 -1
- package/build/utils/native_adapters/audio.d.ts +13 -0
- package/build/utils/native_adapters/audio.d.ts.map +1 -0
- package/build/utils/native_adapters/audio.js +7 -0
- package/build/utils/native_adapters/audio.js.map +1 -0
- package/build/utils/native_adapters/configuration.d.ts +7 -1
- package/build/utils/native_adapters/configuration.d.ts.map +1 -1
- package/build/utils/native_adapters/configuration.js +17 -1
- package/build/utils/native_adapters/configuration.js.map +1 -1
- package/build/utils/native_adapters/index.d.ts +2 -0
- package/build/utils/native_adapters/index.d.ts.map +1 -1
- package/build/utils/native_adapters/index.js +2 -0
- package/build/utils/native_adapters/index.js.map +1 -1
- package/build/utils/native_adapters/video.d.ts +25 -0
- package/build/utils/native_adapters/video.d.ts.map +1 -0
- package/build/utils/native_adapters/video.js +7 -0
- package/build/utils/native_adapters/video.js.map +1 -0
- package/build/utils/parse_simple_markdown.d.ts +7 -0
- package/build/utils/parse_simple_markdown.d.ts.map +1 -0
- package/build/utils/parse_simple_markdown.js +32 -0
- package/build/utils/parse_simple_markdown.js.map +1 -0
- package/build/utils/pluralize.d.ts +2 -0
- package/build/utils/pluralize.d.ts.map +1 -0
- package/build/utils/pluralize.js +10 -0
- package/build/utils/pluralize.js.map +1 -0
- package/build/utils/request/conversation.d.ts +10 -0
- package/build/utils/request/conversation.d.ts.map +1 -0
- package/build/utils/request/conversation.js +32 -0
- package/build/utils/request/conversation.js.map +1 -0
- package/build/utils/request/messages.d.ts +15 -0
- package/build/utils/request/messages.d.ts.map +1 -0
- package/build/utils/request/messages.js +22 -0
- package/build/utils/request/messages.js.map +1 -0
- package/build/utils/theme.d.ts +1 -1
- package/build/utils/theme.d.ts.map +1 -1
- package/build/utils/theme.js +1 -1
- package/build/utils/theme.js.map +1 -1
- package/package.json +2 -2
- package/src/__tests__/utils/parse_simple_markdown.ts +93 -0
- package/src/__tests__/utils/pluralize.tsx +17 -0
- package/src/components/conversation/attachments/attachment_card.tsx +46 -0
- package/src/components/conversation/attachments/audio_attachment.tsx +102 -0
- package/src/components/conversation/attachments/constants.ts +5 -0
- package/src/components/conversation/attachments/download_attachment_button.tsx +46 -0
- package/src/components/conversation/attachments/expanded_link.tsx +54 -0
- package/src/components/conversation/attachments/generic_file_attachment.tsx +75 -0
- package/src/components/conversation/attachments/giphy_attachment.tsx +56 -0
- package/src/components/conversation/attachments/image_attachment.tsx +31 -0
- package/src/components/conversation/attachments/video_attachment.tsx +92 -0
- package/src/components/conversation/message.tsx +15 -6
- package/src/components/conversation/message_attachments.tsx +61 -0
- package/src/components/conversation/message_markdown.tsx +52 -0
- package/src/components/conversations/conversation_preview.tsx +84 -0
- package/src/components/conversations/conversations.tsx +79 -0
- package/src/components/conversations/unread_count_badge.tsx +38 -0
- package/src/components/display/badge.tsx +41 -10
- package/src/components/display/button.tsx +1 -1
- package/src/components/display/child_notice.tsx +2 -2
- package/src/components/display/icon.tsx +10 -8
- package/src/components/display/text.tsx +1 -7
- package/src/components/index.tsx +1 -1
- package/src/hooks/use_api.ts +11 -10
- package/src/hooks/use_api_client.ts +1 -1
- package/src/hooks/use_conversation.ts +1 -1
- package/src/hooks/use_conversation_jolt_events.ts +1 -1
- package/src/hooks/use_conversation_messages_jolt_events.ts +1 -1
- package/src/hooks/use_conversations.ts +3 -31
- package/src/hooks/use_groups.ts +31 -0
- package/src/hooks/use_groups_groups.ts +20 -0
- package/src/hooks/use_services_team.ts +30 -0
- package/src/hooks/use_suspense_api.ts +4 -4
- package/src/hooks/use_teams.ts +25 -0
- package/src/navigation/index.tsx +8 -0
- package/src/screens/conversation_details_screen.tsx +149 -117
- package/src/screens/conversation_filters_screen.tsx +488 -0
- package/src/screens/conversation_screen.tsx +8 -1
- package/src/screens/conversations_screen.tsx +210 -13
- package/src/screens/create/conversation_select_recipients_screen.tsx +3 -11
- package/src/types/resources/group_resource.ts +5 -2
- package/src/types/resources/index.ts +1 -0
- package/src/types/resources/services/index.ts +1 -0
- package/src/types/resources/services/team_resource.ts +60 -0
- package/src/utils/client/types.d.ts +2 -1
- package/src/utils/index.ts +1 -0
- package/src/utils/native_adapters/audio.ts +15 -0
- package/src/utils/native_adapters/configuration.ts +24 -1
- package/src/utils/native_adapters/index.ts +2 -0
- package/src/utils/native_adapters/video.ts +30 -0
- package/src/utils/parse_simple_markdown.ts +40 -0
- package/src/utils/pluralize.ts +11 -0
- package/src/utils/request/conversation.ts +46 -0
- package/src/utils/request/messages.ts +21 -0
- package/src/utils/theme.ts +2 -2
- package/build/components/conversations.d.ts +0 -3
- package/build/components/conversations.d.ts.map +0 -1
- package/build/components/conversations.js +0 -100
- package/build/components/conversations.js.map +0 -1
- package/src/components/conversations.tsx +0 -144
|
@@ -12,7 +12,7 @@ declare const VARIANTS: {
|
|
|
12
12
|
readonly outline: "outline";
|
|
13
13
|
};
|
|
14
14
|
type VariantUnion = (typeof VARIANTS)[keyof typeof VARIANTS];
|
|
15
|
-
interface ButtonProps extends PressableProps {
|
|
15
|
+
export interface ButtonProps extends PressableProps {
|
|
16
16
|
/**
|
|
17
17
|
* Specifies whether fonts should be scaled down automatically to fit given style constraints.
|
|
18
18
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"button.d.ts","sourceRoot":"","sources":["../../../src/components/display/button.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AAEzB,OAAO,KAAK,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,cAAc,CAAA;AAQ7D,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,uBAAuB,CAAA;AAMlE,QAAA,MAAM,KAAK;;;;CAID,CAAA;AAEV,KAAK,SAAS,GAAG,CAAC,OAAO,KAAK,CAAC,CAAC,MAAM,OAAO,KAAK,CAAC,CAAA;AAYnD,QAAA,MAAM,QAAQ;;;CAGJ,CAAA;AAEV,KAAK,YAAY,GAAG,CAAC,OAAO,QAAQ,CAAC,CAAC,MAAM,OAAO,QAAQ,CAAC,CAAA;AAa5D,
|
|
1
|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C,CAAC,eAAe;YACzD,iBAAiB,EAAE,YAAY,CAAC,IAAI,CAAC,CAAC,iBAAiB;SACxD;QACD,IAAI,EAAE;YACJ,SAAS,EAAE,QAAQ;YACnB,iBAAiB,EAAE,QAAQ;YAC3B,kBAAkB,EAAE,KAAK;YACzB,UAAU,EAAE,sBAAsB;YAClC,QAAQ,EAAE,YAAY,CAAC,IAAI,CAAC,CAAC,QAAQ;YACrC,KAAK,EAAE,eAAe,CAAC,OAAO,CAAC,CAAC,KAAK;SACtC;QACD,YAAY,EAAE;YACZ,KAAK,EAAE,MAAM,CAAC,wBAAwB;SACvC;QACD,WAAW,EAAE;YACX,OAAO,EAAE,CAAC;SACX;QACD,IAAI,EAAE;YACJ,QAAQ,EAAE,YAAY,CAAC,IAAI,CAAC,CAAC,QAAQ;YACrC,KAAK,EAAE,eAAe,CAAC,OAAO,CAAC,CAAC,KAAK;SACtC;QACD,YAAY,EAAE;YACZ,KAAK,EAAE,MAAM,CAAC,wBAAwB;SACvC;QACD,WAAW,EAAE;YACX,OAAO,EAAE,CAAC;SACX;QACD,OAAO,EAAE;YACP,QAAQ,EAAE,YAAY,CAAC,IAAI,CAAC,CAAC,QAAQ;SACtC;KACF,CAAC,CAAA;AACJ,CAAC,CAAA","sourcesContent":["import React from 'react'\nimport { Pressable, StyleSheet, Text, View } from 'react-native'\nimport type { PressableProps, ViewStyle } from 'react-native'\nimport LinearGradient from 'react-native-linear-gradient'\nimport { Icon } from './icon'\nimport { useTheme, useFontScale, useCreateAndroidRippleColor } from '../../hooks'\nimport { tokens } from '../../vendor/tapestry/tokens'\nimport { platformFontWeightBold, platformPressedOpacityStyle } from '../../utils'\nimport { Spinner } from './spinner'\nimport { getColorKey, useButtonColorOptionMap, useGradientColorMap } from './utils/button_colors'\nimport type { ButtonAppearanceUnion } from './utils/button_colors'\n\n// =================================\n// ====== Constants ================\n// =================================\n\nconst SIZES = {\n sm: 'sm',\n md: 'md',\n lg: 'lg',\n} as const\n\ntype SizeUnion = (typeof SIZES)[keyof typeof SIZES]\ntype SizeStyle = Record<\n SizeUnion,\n {\n fontSize: number\n paddingHorizontal: number\n height: number\n borderRadius: number\n gap: number\n }\n>\n\nconst VARIANTS = {\n fill: 'fill',\n outline: 'outline',\n} as const\n\ntype VariantUnion = (typeof VARIANTS)[keyof typeof VARIANTS]\ntype VariantColors = Record<\n VariantUnion,\n {\n backgroundColor: string\n color: string\n }\n>\n\n// =================================\n// ====== Component ================\n// =================================\n\ninterface ButtonProps extends PressableProps {\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 * Updates the button's colors\n */\n appearance?: ButtonAppearanceUnion\n /**\n * Styles the inner View that wraps the button's content\n */\n buttonInnerStyles?: ViewStyle\n /**\n * Styles the outer LinearGradient that gives the button it's backgrounnd and outline color\n */\n buttonOuterStyles?: ViewStyle\n /**\n * Generates an icon to the left of the button text\n */\n iconNameLeft?: string\n /**\n * Generates an icon to the right of the button text\n */\n iconNameRight?: string\n /**\n * Disables the button and replaces its content with a spinner\n */\n loading?: boolean\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 * Changes the overall size of the button and its contents\n */\n size?: SizeUnion\n /**\n * Renders as text within the button\n */\n title: string\n /**\n * Fill buttons are visually more propmonitent then outline buttons\n */\n variant?: VariantUnion\n}\n\nexport function Button({\n adjustsFontSizeToFit = false,\n allowFontScaling = true,\n appearance = 'interaction',\n buttonInnerStyles,\n buttonOuterStyles,\n disabled = false,\n iconNameLeft,\n iconNameRight,\n loading,\n maxFontSizeMultiplier,\n minimumFontScale,\n size = 'md',\n title,\n variant = 'fill',\n ...props\n}: ButtonProps) {\n const styles = useStyles({ appearance, disabled, loading, maxFontSizeMultiplier, size, variant })\n const gradientOptionsMap = useGradientColorMap()\n const colorKey = getColorKey({ disabled, loading, appearance })\n\n const textStyles = [styles.text, disabled && styles.textDisabled, loading && styles.iconLoading]\n const iconStyles = [styles.icon, disabled && styles.iconDisabled, loading && styles.textLoading]\n\n const androidRippleColor = useCreateAndroidRippleColor({ color: gradientOptionsMap[colorKey][0] })\n\n return (\n <Pressable\n style={({ pressed }) => [styles.pressable, pressed && platformPressedOpacityStyle]}\n accessibilityRole=\"button\"\n disabled={disabled || loading}\n accessibilityState={{ busy: loading }}\n android_ripple={{ color: androidRippleColor, borderless: false, foreground: true }}\n {...props}\n >\n <LinearGradient\n start={{ x: 0.1, y: 0.1 }}\n end={{ x: 0.9, y: 0.9 }}\n colors={gradientOptionsMap[colorKey]}\n style={[styles.colorWrapper, buttonOuterStyles]}\n >\n {loading && (\n <Spinner\n size={styles.spinner.fontSize}\n maxFontSizeMultiplier={maxFontSizeMultiplier || 0}\n />\n )}\n <View style={[styles.innerWrapper, buttonInnerStyles]}>\n {iconNameLeft && (\n <Icon\n name={iconNameLeft}\n style={iconStyles}\n maxFontSizeMultiplier={maxFontSizeMultiplier}\n />\n )}\n <Text\n allowFontScaling={allowFontScaling}\n minimumFontScale={minimumFontScale}\n maxFontSizeMultiplier={maxFontSizeMultiplier}\n adjustsFontSizeToFit={adjustsFontSizeToFit}\n numberOfLines={1}\n style={textStyles}\n >\n {title}\n </Text>\n {iconNameRight && (\n <Icon\n name={iconNameRight}\n style={iconStyles}\n maxFontSizeMultiplier={maxFontSizeMultiplier}\n />\n )}\n </View>\n </LinearGradient>\n </Pressable>\n )\n}\n\n// =================================\n// ====== Styles ===================\n// =================================\n\nconst useStyles = ({\n appearance = 'interaction',\n disabled = false,\n loading = false,\n maxFontSizeMultiplier,\n size = 'md',\n variant = 'fill',\n}: Partial<ButtonProps>) => {\n const { colors, button } = useTheme()\n const fontScale = useFontScale({ maxFontSizeMultiplier })\n const colorOptionMap = useButtonColorOptionMap()\n\n const outlineHeightOffset = size === 'sm' ? 2 : 4\n const outlineMarginOffset = size === 'sm' ? 1 : 2\n\n const sizeStyleMap: SizeStyle = {\n [SIZES.sm]: {\n fontSize: 12,\n paddingHorizontal: 12 * fontScale,\n borderRadius: button.borderRadius * fontScale,\n height: 24 * fontScale - outlineHeightOffset,\n gap: 4 * fontScale,\n },\n [SIZES.md]: {\n fontSize: 14,\n paddingHorizontal: 16 * fontScale,\n borderRadius: button.borderRadius * fontScale,\n height: 32 * fontScale - outlineHeightOffset,\n gap: 6 * fontScale,\n },\n [SIZES.lg]: {\n fontSize: 16,\n paddingHorizontal: 24 * fontScale,\n borderRadius: button.borderRadius * fontScale,\n height: 40 * fontScale - outlineHeightOffset,\n gap: 8 * fontScale,\n },\n }\n\n const variantOutlineColor =\n disabled || loading ? colors.fillColorNeutral090 : colors.fillColorNeutral100Inverted\n\n const variantStyleMap: VariantColors = {\n fill: {\n backgroundColor: 'transparent',\n color: tokens.colorNeutral100White,\n },\n outline: {\n backgroundColor: variantOutlineColor,\n color: colorOptionMap[appearance],\n },\n }\n\n return StyleSheet.create({\n pressable: {\n borderRadius: sizeStyleMap[size].borderRadius,\n overflow: 'hidden',\n },\n colorWrapper: {\n flexDirection: 'row',\n justifyContent: 'center',\n alignItems: 'center',\n borderRadius: sizeStyleMap[size].borderRadius,\n },\n innerWrapper: {\n flexDirection: 'row',\n justifyContent: 'center',\n alignItems: 'center',\n margin: outlineMarginOffset,\n gap: sizeStyleMap[size].gap,\n borderRadius: sizeStyleMap[size].borderRadius - outlineMarginOffset,\n height: sizeStyleMap[size].height,\n backgroundColor: variantStyleMap[variant].backgroundColor,\n paddingHorizontal: sizeStyleMap[size].paddingHorizontal,\n },\n text: {\n textAlign: 'center',\n textAlignVertical: 'center',\n includeFontPadding: false,\n fontWeight: platformFontWeightBold,\n fontSize: sizeStyleMap[size].fontSize,\n color: variantStyleMap[variant].color,\n },\n textDisabled: {\n color: colors.textColorDefaultDisabled,\n },\n textLoading: {\n opacity: 0,\n },\n icon: {\n fontSize: sizeStyleMap[size].fontSize,\n color: variantStyleMap[variant].color,\n },\n iconDisabled: {\n color: colors.iconColorDefaultDisabled,\n },\n iconLoading: {\n opacity: 0,\n },\n spinner: {\n fontSize: sizeStyleMap[size].fontSize,\n },\n })\n}\n"]}
|
|
1
|
+
{"version":3,"file":"button.js","sourceRoot":"","sources":["../../../src/components/display/button.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AACzB,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,cAAc,CAAA;AAEhE,OAAO,cAAc,MAAM,8BAA8B,CAAA;AACzD,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAA;AAC7B,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,2BAA2B,EAAE,MAAM,aAAa,CAAA;AACjF,OAAO,EAAE,MAAM,EAAE,MAAM,8BAA8B,CAAA;AACrD,OAAO,EAAE,sBAAsB,EAAE,2BAA2B,EAAE,MAAM,aAAa,CAAA;AACjF,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AACnC,OAAO,EAAE,WAAW,EAAE,uBAAuB,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAA;AAGjG,oCAAoC;AACpC,oCAAoC;AACpC,oCAAoC;AAEpC,MAAM,KAAK,GAAG;IACZ,EAAE,EAAE,IAAI;IACR,EAAE,EAAE,IAAI;IACR,EAAE,EAAE,IAAI;CACA,CAAA;AAcV,MAAM,QAAQ,GAAG;IACf,IAAI,EAAE,MAAM;IACZ,OAAO,EAAE,SAAS;CACV,CAAA;AAsEV,MAAM,UAAU,MAAM,CAAC,EACrB,oBAAoB,GAAG,KAAK,EAC5B,gBAAgB,GAAG,IAAI,EACvB,UAAU,GAAG,aAAa,EAC1B,iBAAiB,EACjB,iBAAiB,EACjB,QAAQ,GAAG,KAAK,EAChB,YAAY,EACZ,aA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;YACzD,iBAAiB,EAAE,YAAY,CAAC,IAAI,CAAC,CAAC,iBAAiB;SACxD;QACD,IAAI,EAAE;YACJ,SAAS,EAAE,QAAQ;YACnB,iBAAiB,EAAE,QAAQ;YAC3B,kBAAkB,EAAE,KAAK;YACzB,UAAU,EAAE,sBAAsB;YAClC,QAAQ,EAAE,YAAY,CAAC,IAAI,CAAC,CAAC,QAAQ;YACrC,KAAK,EAAE,eAAe,CAAC,OAAO,CAAC,CAAC,KAAK;SACtC;QACD,YAAY,EAAE;YACZ,KAAK,EAAE,MAAM,CAAC,wBAAwB;SACvC;QACD,WAAW,EAAE;YACX,OAAO,EAAE,CAAC;SACX;QACD,IAAI,EAAE;YACJ,QAAQ,EAAE,YAAY,CAAC,IAAI,CAAC,CAAC,QAAQ;YACrC,KAAK,EAAE,eAAe,CAAC,OAAO,CAAC,CAAC,KAAK;SACtC;QACD,YAAY,EAAE;YACZ,KAAK,EAAE,MAAM,CAAC,wBAAwB;SACvC;QACD,WAAW,EAAE;YACX,OAAO,EAAE,CAAC;SACX;QACD,OAAO,EAAE;YACP,QAAQ,EAAE,YAAY,CAAC,IAAI,CAAC,CAAC,QAAQ;SACtC;KACF,CAAC,CAAA;AACJ,CAAC,CAAA","sourcesContent":["import React from 'react'\nimport { Pressable, StyleSheet, Text, View } from 'react-native'\nimport type { PressableProps, ViewStyle } from 'react-native'\nimport LinearGradient from 'react-native-linear-gradient'\nimport { Icon } from './icon'\nimport { useTheme, useFontScale, useCreateAndroidRippleColor } from '../../hooks'\nimport { tokens } from '../../vendor/tapestry/tokens'\nimport { platformFontWeightBold, platformPressedOpacityStyle } from '../../utils'\nimport { Spinner } from './spinner'\nimport { getColorKey, useButtonColorOptionMap, useGradientColorMap } from './utils/button_colors'\nimport type { ButtonAppearanceUnion } from './utils/button_colors'\n\n// =================================\n// ====== Constants ================\n// =================================\n\nconst SIZES = {\n sm: 'sm',\n md: 'md',\n lg: 'lg',\n} as const\n\ntype SizeUnion = (typeof SIZES)[keyof typeof SIZES]\ntype SizeStyle = Record<\n SizeUnion,\n {\n fontSize: number\n paddingHorizontal: number\n height: number\n borderRadius: number\n gap: number\n }\n>\n\nconst VARIANTS = {\n fill: 'fill',\n outline: 'outline',\n} as const\n\ntype VariantUnion = (typeof VARIANTS)[keyof typeof VARIANTS]\ntype VariantColors = Record<\n VariantUnion,\n {\n backgroundColor: string\n color: string\n }\n>\n\n// =================================\n// ====== Component ================\n// =================================\n\nexport interface ButtonProps extends PressableProps {\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 * Updates the button's colors\n */\n appearance?: ButtonAppearanceUnion\n /**\n * Styles the inner View that wraps the button's content\n */\n buttonInnerStyles?: ViewStyle\n /**\n * Styles the outer LinearGradient that gives the button it's backgrounnd and outline color\n */\n buttonOuterStyles?: ViewStyle\n /**\n * Generates an icon to the left of the button text\n */\n iconNameLeft?: string\n /**\n * Generates an icon to the right of the button text\n */\n iconNameRight?: string\n /**\n * Disables the button and replaces its content with a spinner\n */\n loading?: boolean\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 * Changes the overall size of the button and its contents\n */\n size?: SizeUnion\n /**\n * Renders as text within the button\n */\n title: string\n /**\n * Fill buttons are visually more propmonitent then outline buttons\n */\n variant?: VariantUnion\n}\n\nexport function Button({\n adjustsFontSizeToFit = false,\n allowFontScaling = true,\n appearance = 'interaction',\n buttonInnerStyles,\n buttonOuterStyles,\n disabled = false,\n iconNameLeft,\n iconNameRight,\n loading,\n maxFontSizeMultiplier,\n minimumFontScale,\n size = 'md',\n title,\n variant = 'fill',\n ...props\n}: ButtonProps) {\n const styles = useStyles({ appearance, disabled, loading, maxFontSizeMultiplier, size, variant })\n const gradientOptionsMap = useGradientColorMap()\n const colorKey = getColorKey({ disabled, loading, appearance })\n\n const textStyles = [styles.text, disabled && styles.textDisabled, loading && styles.iconLoading]\n const iconStyles = [styles.icon, disabled && styles.iconDisabled, loading && styles.textLoading]\n\n const androidRippleColor = useCreateAndroidRippleColor({ color: gradientOptionsMap[colorKey][0] })\n\n return (\n <Pressable\n style={({ pressed }) => [styles.pressable, pressed && platformPressedOpacityStyle]}\n accessibilityRole=\"button\"\n disabled={disabled || loading}\n accessibilityState={{ busy: loading }}\n android_ripple={{ color: androidRippleColor, borderless: false, foreground: true }}\n {...props}\n >\n <LinearGradient\n start={{ x: 0.1, y: 0.1 }}\n end={{ x: 0.9, y: 0.9 }}\n colors={gradientOptionsMap[colorKey]}\n style={[styles.colorWrapper, buttonOuterStyles]}\n >\n {loading && (\n <Spinner\n size={styles.spinner.fontSize}\n maxFontSizeMultiplier={maxFontSizeMultiplier || 0}\n />\n )}\n <View style={[styles.innerWrapper, buttonInnerStyles]}>\n {iconNameLeft && (\n <Icon\n name={iconNameLeft}\n style={iconStyles}\n maxFontSizeMultiplier={maxFontSizeMultiplier}\n />\n )}\n <Text\n allowFontScaling={allowFontScaling}\n minimumFontScale={minimumFontScale}\n maxFontSizeMultiplier={maxFontSizeMultiplier}\n adjustsFontSizeToFit={adjustsFontSizeToFit}\n numberOfLines={1}\n style={textStyles}\n >\n {title}\n </Text>\n {iconNameRight && (\n <Icon\n name={iconNameRight}\n style={iconStyles}\n maxFontSizeMultiplier={maxFontSizeMultiplier}\n />\n )}\n </View>\n </LinearGradient>\n </Pressable>\n )\n}\n\n// =================================\n// ====== Styles ===================\n// =================================\n\nconst useStyles = ({\n appearance = 'interaction',\n disabled = false,\n loading = false,\n maxFontSizeMultiplier,\n size = 'md',\n variant = 'fill',\n}: Partial<ButtonProps>) => {\n const { colors, button } = useTheme()\n const fontScale = useFontScale({ maxFontSizeMultiplier })\n const colorOptionMap = useButtonColorOptionMap()\n\n const outlineHeightOffset = size === 'sm' ? 2 : 4\n const outlineMarginOffset = size === 'sm' ? 1 : 2\n\n const sizeStyleMap: SizeStyle = {\n [SIZES.sm]: {\n fontSize: 12,\n paddingHorizontal: 12 * fontScale,\n borderRadius: button.borderRadius * fontScale,\n height: 24 * fontScale - outlineHeightOffset,\n gap: 4 * fontScale,\n },\n [SIZES.md]: {\n fontSize: 14,\n paddingHorizontal: 16 * fontScale,\n borderRadius: button.borderRadius * fontScale,\n height: 32 * fontScale - outlineHeightOffset,\n gap: 6 * fontScale,\n },\n [SIZES.lg]: {\n fontSize: 16,\n paddingHorizontal: 24 * fontScale,\n borderRadius: button.borderRadius * fontScale,\n height: 40 * fontScale - outlineHeightOffset,\n gap: 8 * fontScale,\n },\n }\n\n const variantOutlineColor =\n disabled || loading ? colors.fillColorNeutral090 : colors.fillColorNeutral100Inverted\n\n const variantStyleMap: VariantColors = {\n fill: {\n backgroundColor: 'transparent',\n color: tokens.colorNeutral100White,\n },\n outline: {\n backgroundColor: variantOutlineColor,\n color: colorOptionMap[appearance],\n },\n }\n\n return StyleSheet.create({\n pressable: {\n borderRadius: sizeStyleMap[size].borderRadius,\n overflow: 'hidden',\n },\n colorWrapper: {\n flexDirection: 'row',\n justifyContent: 'center',\n alignItems: 'center',\n borderRadius: sizeStyleMap[size].borderRadius,\n },\n innerWrapper: {\n flexDirection: 'row',\n justifyContent: 'center',\n alignItems: 'center',\n margin: outlineMarginOffset,\n gap: sizeStyleMap[size].gap,\n borderRadius: sizeStyleMap[size].borderRadius - outlineMarginOffset,\n height: sizeStyleMap[size].height,\n backgroundColor: variantStyleMap[variant].backgroundColor,\n paddingHorizontal: sizeStyleMap[size].paddingHorizontal,\n },\n text: {\n textAlign: 'center',\n textAlignVertical: 'center',\n includeFontPadding: false,\n fontWeight: platformFontWeightBold,\n fontSize: sizeStyleMap[size].fontSize,\n color: variantStyleMap[variant].color,\n },\n textDisabled: {\n color: colors.textColorDefaultDisabled,\n },\n textLoading: {\n opacity: 0,\n },\n icon: {\n fontSize: sizeStyleMap[size].fontSize,\n color: variantStyleMap[variant].color,\n },\n iconDisabled: {\n color: colors.iconColorDefaultDisabled,\n },\n iconLoading: {\n opacity: 0,\n },\n spinner: {\n fontSize: sizeStyleMap[size].fontSize,\n },\n })\n}\n"]}
|
|
@@ -3,11 +3,11 @@ import { BannerCollapsible } from './banner_collapsible';
|
|
|
3
3
|
import BannerPrimitive from '../primitive/banner_primitive';
|
|
4
4
|
import { View, StyleSheet } from 'react-native';
|
|
5
5
|
import { Avatar } from './avatar';
|
|
6
|
-
import { platformFontWeightMedium } from '../../utils';
|
|
6
|
+
import { platformFontWeightMedium, pluralize } from '../../utils';
|
|
7
7
|
import { Text } from './text';
|
|
8
8
|
export function ChildNotice({ childMembers }) {
|
|
9
9
|
const styles = useStyles();
|
|
10
|
-
const heading = `${childMembers.length}
|
|
10
|
+
const heading = `${pluralize(childMembers.length, 'member')} under age 13`;
|
|
11
11
|
return (<BannerCollapsible appearance="warning" iconName="general.shieldExclamation" heading={heading}>
|
|
12
12
|
<BannerPrimitive.Text>
|
|
13
13
|
Under age members cannot chat. They won't see conversations or notifications.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"child_notice.js","sourceRoot":"","sources":["../../../src/components/display/child_notice.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AAEzB,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAA;AACxD,OAAO,eAAe,MAAM,+BAA+B,CAAA;AAC3D,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AAC/C,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAA;AACjC,OAAO,EAAE,wBAAwB,EAAE,MAAM,aAAa,CAAA;
|
|
1
|
+
{"version":3,"file":"child_notice.js","sourceRoot":"","sources":["../../../src/components/display/child_notice.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,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AAC,KAAK,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,IAAI,EAC1C;MAAA,CAAC,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,CAC1C;QAAA,CAAC,KAAK,CAAC,IAAI,CACb;MAAA,EAAE,IAAI,CACR;IAAA,EAAE,IAAI,CAAC,CACR,CAAA;AACH,CAAC;AAED,oCAAoC;AACpC,oCAAoC;AACpC,oCAAoC;AAEpC,MAAM,SAAS,GAAG,GAAG,EAAE;IACrB,OAAO,UAAU,CAAC,MAAM,CAAC;QACvB,eAAe,EAAE;YACf,SAAS,EAAE,CAAC;YACZ,GAAG,EAAE,CAAC;SACP;QACD,KAAK,EAAE;YACL,aAAa,EAAE,KAAK;YACpB,UAAU,EAAE,QAAQ;YACpB,GAAG,EAAE,CAAC;SACP;QACD,IAAI,EAAE;YACJ,UAAU,EAAE,wBAAwB;SACrC;KACF,CAAC,CAAA;AACJ,CAAC,CAAA","sourcesContent":["import React from 'react'\nimport { MemberResource } from '../../types'\nimport { BannerCollapsible } from './banner_collapsible'\nimport BannerPrimitive from '../primitive/banner_primitive'\nimport { View, StyleSheet } from 'react-native'\nimport { Avatar } from './avatar'\nimport { platformFontWeightMedium, pluralize } from '../../utils'\nimport { Text } from './text'\n\n// =================================\n// ====== Component ================\n// =================================\n\ninterface ChildNoticeProps {\n childMembers: MemberResource[]\n}\n\nexport function ChildNotice({ childMembers }: ChildNoticeProps) {\n const styles = useStyles()\n const heading = `${pluralize(childMembers.length, 'member')} under age 13`\n\n return (\n <BannerCollapsible appearance=\"warning\" iconName=\"general.shieldExclamation\" heading={heading}>\n <BannerPrimitive.Text>\n Under age members cannot chat. They won't see conversations or notifications.\n </BannerPrimitive.Text>\n <View style={styles.childrenWrapper}>\n {childMembers?.map(child => <Child key={child.id} child={child} />)}\n </View>\n </BannerCollapsible>\n )\n}\n\nfunction Child({ child }: { child: MemberResource }) {\n const styles = useStyles()\n return (\n <View style={styles.child}>\n <Avatar sourceUri={child.avatar} size=\"sm\" />\n <Text variant=\"tertiary\" style={styles.name}>\n {child.name}\n </Text>\n </View>\n )\n}\n\n// =================================\n// ====== Styles ===================\n// =================================\n\nconst useStyles = () => {\n return StyleSheet.create({\n childrenWrapper: {\n marginTop: 8,\n gap: 8,\n },\n child: {\n flexDirection: 'row',\n alignItems: 'center',\n gap: 8,\n },\n name: {\n fontWeight: platformFontWeightMedium,\n },\n })\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"icon.d.ts","sourceRoot":"","sources":["../../../src/components/display/icon.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AAEzB,OAAO,KAAK,EAAE,UAAU,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,cAAc,CAAA;AAEpE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAA;
|
|
1
|
+
{"version":3,"file":"icon.d.ts","sourceRoot":"","sources":["../../../src/components/display/icon.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AAEzB,OAAO,KAAK,EAAE,UAAU,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,cAAc,CAAA;AAEpE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAA;AA8BhD,KAAK,SAAS,GAAG,SAAS,GAAG;IAC3B,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,KAAK,CAAC,EAAE,MAAM,CAAA;CACf,CAAA;AAMD,MAAM,WAAW,SAAU,SAAQ,IAAI,CAAC,QAAQ,EAAE,KAAK,GAAG,UAAU,CAAC;IACnE;;;OAGG;IACH,IAAI,EAAE,MAAM,CAAA;IACZ;;;OAGG;IACH,IAAI,CAAC,EAAE,MAAM,CAAA;IACb;;OAEG;IACH,qBAAqB,CAAC,EAAE,MAAM,CAAA;IAC9B;;OAEG;IACH,KAAK,CAAC,EAAE,UAAU,CAAA;IAClB;;OAEG;IACH,KAAK,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAA;CAC7B;AAED,wBAAgB,IAAI,CAAC,EACnB,KAAK,EACL,IAAI,EACJ,IAAI,EACJ,KAAK,EACL,2BAA2B,EAC3B,kBAAkB,EAClB,qBAAqB,EACrB,GAAG,KAAK,EACT,EAAE,SAAS,qBA0BX"}
|
|
@@ -2,27 +2,29 @@ import React from 'react';
|
|
|
2
2
|
import { StyleSheet, View } from 'react-native';
|
|
3
3
|
import { SvgXml } from 'react-native-svg';
|
|
4
4
|
import { useFontScale, useTheme } from '../../hooks';
|
|
5
|
-
import * as
|
|
6
|
-
import * as
|
|
5
|
+
import * as api from '@planningcenter/icons/paths/api';
|
|
6
|
+
import * as brand from '@planningcenter/icons/paths/brand';
|
|
7
7
|
import * as calendar from '@planningcenter/icons/paths/calendar';
|
|
8
|
-
import * as people from '@planningcenter/icons/paths/people';
|
|
9
8
|
import * as churchCenter from '@planningcenter/icons/paths/church-center';
|
|
9
|
+
import * as general from '@planningcenter/icons/paths/general';
|
|
10
|
+
import * as groups from '@planningcenter/icons/paths/groups';
|
|
10
11
|
import * as logomark from '@planningcenter/icons/paths/logomark';
|
|
11
|
-
import * as
|
|
12
|
-
import * as
|
|
12
|
+
import * as people from '@planningcenter/icons/paths/people';
|
|
13
|
+
import * as services from '@planningcenter/icons/paths/services';
|
|
13
14
|
// =================================
|
|
14
15
|
// ====== Constants ================
|
|
15
16
|
// =================================
|
|
16
17
|
const FALLBACK_SIZE = 12;
|
|
17
18
|
const ICONS = {
|
|
18
19
|
api,
|
|
20
|
+
brand,
|
|
19
21
|
calendar,
|
|
20
|
-
people,
|
|
21
22
|
churchCenter,
|
|
22
|
-
groups,
|
|
23
23
|
general,
|
|
24
|
+
groups,
|
|
24
25
|
logomark,
|
|
25
|
-
|
|
26
|
+
people,
|
|
27
|
+
services,
|
|
26
28
|
};
|
|
27
29
|
export function Icon({ color, name, size, style, accessibilityElementsHidden, accessibilityLabel, maxFontSizeMultiplier, ...props }) {
|
|
28
30
|
const flattenStyles = StyleSheet.flatten(style);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"icon.js","sourceRoot":"","sources":["../../../src/components/display/icon.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AACzB,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,cAAc,CAAA;AAE/C,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAA;AAEzC,OAAO,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAA;AACpD,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"icon.js","sourceRoot":"","sources":["../../../src/components/display/icon.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AACzB,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,cAAc,CAAA;AAE/C,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAA;AAEzC,OAAO,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAA;AACpD,OAAO,KAAK,GAAG,MAAM,iCAAiC,CAAA;AACtD,OAAO,KAAK,KAAK,MAAM,mCAAmC,CAAA;AAC1D,OAAO,KAAK,QAAQ,MAAM,sCAAsC,CAAA;AAChE,OAAO,KAAK,YAAY,MAAM,2CAA2C,CAAA;AACzE,OAAO,KAAK,OAAO,MAAM,qCAAqC,CAAA;AAC9D,OAAO,KAAK,MAAM,MAAM,oCAAoC,CAAA;AAC5D,OAAO,KAAK,QAAQ,MAAM,sCAAsC,CAAA;AAChE,OAAO,KAAK,MAAM,MAAM,oCAAoC,CAAA;AAC5D,OAAO,KAAK,QAAQ,MAAM,sCAAsC,CAAA;AAEhE,oCAAoC;AACpC,oCAAoC;AACpC,oCAAoC;AAEpC,MAAM,aAAa,GAAG,EAAE,CAAA;AAExB,MAAM,KAAK,GAAG;IACZ,GAAG;IACH,KAAK;IACL,Q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,YAAY,CAAC,EAAE,qBAAqB,EAAE,CAAC,CAAA;IAEzD,IAAI,QAAQ;QAAE,OAAO,QAAQ,GAAG,SAAS,CAAA;IAEzC,OAAO,IAAI,IAAI,aAAa,CAAA;AAC9B,CAAC,CAAA;AAED,MAAM,WAAW,GAAG,CAAC,IAAY,EAAU,EAAE;IAC3C,MAAM,CAAC,OAAO,EAAE,QAAQ,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAA;IAE3C,OAAO,KAAK,CAAC,OAAO,CAAC,EAAE,CAAC,QAAQ,CAAC,CAAA;AACnC,CAAC,CAAA;AAED,oCAAoC;AACpC,oCAAoC;AACpC,oCAAoC;AAEpC,MAAM,SAAS,GAAG,CAAC,EAAE,KAAK,EAAE,QAAQ,EAA4C,EAAE,EAAE;IAClF,MAAM,EAAE,MAAM,EAAE,GAAG,QAAQ,EAAE,CAAA;IAE7B,OAAO,UAAU,CAAC,MAAM,CAAC;QACvB,MAAM,EAAE;YACN,eAAe,EAAE,MAAM,CAAC,wBAAwB;YAChD,KAAK,EAAE,QAAQ;YACf,MAAM,EAAE,QAAQ;YAChB,YAAY,EAAE,QAAQ,GAAG,CAAC;SAC3B;QACD,IAAI,EAAE;YACJ,KAAK,EAAE,KAAK,IAAI,MAAM,CAAC,uBAAuB;SAC/C;KACF,CAAC,CAAA;AACJ,CAAC,CAAA","sourcesContent":["import React from 'react'\nimport { StyleSheet, View } from 'react-native'\nimport type { ColorValue, StyleProp, ViewStyle } from 'react-native'\nimport { SvgXml } from 'react-native-svg'\nimport type { XmlProps } from 'react-native-svg'\nimport { useFontScale, useTheme } from '../../hooks'\nimport * as api from '@planningcenter/icons/paths/api'\nimport * as brand from '@planningcenter/icons/paths/brand'\nimport * as calendar from '@planningcenter/icons/paths/calendar'\nimport * as churchCenter from '@planningcenter/icons/paths/church-center'\nimport * as general from '@planningcenter/icons/paths/general'\nimport * as groups from '@planningcenter/icons/paths/groups'\nimport * as logomark from '@planningcenter/icons/paths/logomark'\nimport * as people from '@planningcenter/icons/paths/people'\nimport * as services from '@planningcenter/icons/paths/services'\n\n// =================================\n// ====== Constants ================\n// =================================\n\nconst FALLBACK_SIZE = 12\n\nconst ICONS = {\n api,\n brand,\n calendar,\n churchCenter,\n general,\n groups,\n logomark,\n people,\n services,\n} as const\n\ntype IconStyle = ViewStyle & {\n fontSize?: number\n color?: string\n}\n\n// =================================\n// ====== Component ================\n// =================================\n\nexport interface IconProps extends Omit<XmlProps, 'xml' | 'fontSize'> {\n /**\n * Made up of the set.iconName.\n * Example: \"general.textMessage\"\n */\n name: string\n /**\n * This sets a static size for the icon.\n * Providing a fontSize style will allow the icon to scale with the device's text a11y size.\n */\n size?: number\n /**\n * Specifies the maximum size a font can reach when allowFontScaling is enabled.\n */\n maxFontSizeMultiplier?: number\n /**\n * Changes the color of the icon. Most cases should use a theme color to support light/dark mode.\n */\n color?: ColorValue\n /**\n * Icon can handle ViewStyle, color, and fontSize.\n */\n style?: StyleProp<IconStyle>\n}\n\nexport function Icon({\n color,\n name,\n size,\n style,\n accessibilityElementsHidden,\n accessibilityLabel,\n maxFontSizeMultiplier,\n ...props\n}: IconProps) {\n const flattenStyles = StyleSheet.flatten(style)\n const iconSize = useGetIconSize(size, flattenStyles, maxFontSizeMultiplier)\n const path = getIconPath(name)\n const styles = useStyles({ color, iconSize })\n\n if (!path) {\n console.warn(`No icon available named ${name}. Remember to use the format \"set.iconName\"`)\n return <View style={styles.noIcon} />\n }\n\n return (\n <SvgXml\n accessibilityElementsHidden={accessibilityElementsHidden}\n accessibilityLabel={accessibilityLabel}\n xml={`\n <svg viewBox=\"0 0 16 16\">\n <path d=\"${path}\" fill=\"currentColor\" />\n </svg>\n `}\n height={iconSize}\n width={iconSize}\n style={{ ...styles.icon, ...flattenStyles }}\n {...props}\n />\n )\n}\n\nconst useGetIconSize = (size?: number, style?: IconStyle, maxFontSizeMultiplier?: number) => {\n const fontSize = style?.fontSize\n const fontScale = useFontScale({ maxFontSizeMultiplier })\n\n if (fontSize) return fontSize * fontScale\n\n return size || FALLBACK_SIZE\n}\n\nconst getIconPath = (name: string): string => {\n const [setName, iconName] = name.split('.')\n\n return ICONS[setName]?.[iconName]\n}\n\n// =================================\n// ====== Styles ===================\n// =================================\n\nconst useStyles = ({ color, iconSize }: { color?: ColorValue; iconSize: number }) => {\n const { colors } = useTheme()\n\n return StyleSheet.create({\n noIcon: {\n backgroundColor: colors.iconColorDefaultDisabled,\n width: iconSize,\n height: iconSize,\n borderRadius: iconSize / 2,\n },\n icon: {\n color: color || colors.iconColorDefaultPrimary,\n },\n })\n}\n"]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { useTheme } from '../../hooks';
|
|
2
2
|
import React from 'react';
|
|
3
|
-
import {
|
|
3
|
+
import { StyleSheet, Text as ReactNativeText } from 'react-native';
|
|
4
4
|
import { tokens } from '../../vendor/tapestry/tokens';
|
|
5
5
|
// =================================
|
|
6
6
|
// ====== Constants ================
|
|
@@ -19,7 +19,7 @@ export function Text({ style, variant = 'plain', children, ...props }) {
|
|
|
19
19
|
[VARIANTS.tertiary]: styles.tertiary,
|
|
20
20
|
[VARIANTS.footnote]: styles.footnote,
|
|
21
21
|
};
|
|
22
|
-
return (<ReactNativeText style={[
|
|
22
|
+
return (<ReactNativeText style={[variantStyleMap[variant], style]} {...props}>
|
|
23
23
|
{children}
|
|
24
24
|
</ReactNativeText>);
|
|
25
25
|
}
|
|
@@ -29,12 +29,6 @@ export function Text({ style, variant = 'plain', children, ...props }) {
|
|
|
29
29
|
const useStyles = () => {
|
|
30
30
|
const { colors } = useTheme();
|
|
31
31
|
return StyleSheet.create({
|
|
32
|
-
global: {
|
|
33
|
-
fontFamily: Platform.select({
|
|
34
|
-
ios: 'System',
|
|
35
|
-
android: 'normal',
|
|
36
|
-
}),
|
|
37
|
-
},
|
|
38
32
|
plain: {
|
|
39
33
|
color: colors.textColorDefaultPrimary,
|
|
40
34
|
fontSize: tokens.fontSizeMd,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"text.js","sourceRoot":"","sources":["../../../src/components/display/text.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAA;AACtC,OAAO,KAAK,MAAM,OAAO,CAAA;AACzB,OAAO,
|
|
1
|
+
{"version":3,"file":"text.js","sourceRoot":"","sources":["../../../src/components/display/text.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAA;AACtC,OAAO,KAAK,MAAM,OAAO,CAAA;AACzB,OAAO,EAAY,UAAU,EAAE,IAAI,IAAI,eAAe,EAAE,MAAM,cAAc,CAAA;AAE5E,OAAO,EAAE,MAAM,EAAE,MAAM,8BAA8B,CAAA;AAErD,oCAAoC;AACpC,oCAAoC;AACpC,oCAAoC;AAEpC,MAAM,QAAQ,GAAG;IACf,KAAK,EAAE,OAAO;IACd,SAAS,EAAE,WAAW;IACtB,QAAQ,EAAE,UAAU;IACpB,QAAQ,EAAE,UAAU;CACZ,CAAA;AAgBV,MAAM,UAAU,IAAI,CAAC,EAAE,KAAK,EAAE,OAAO,GAAG,OAAO,EAAE,QAAQ,EAAE,GAAG,KAAK,EAAa;IAC9E,MAAM,MAAM,GAAG,SAAS,EAAE,CAAA;IAC1B,MAAM,eAAe,GAAkB;QACrC,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC,KAAK;QAC9B,CAAC,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC,SAAS;QACtC,CAAC,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC,QAAQ;QACpC,CAAC,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC,QAAQ;KACrC,CAAA;IAED,OAAO,CACL,CAAC,eAAe,CAAC,KAAK,CAAC,CAAC,CAAC,eAAe,CAAC,OAAO,CAAC,EAAE,KAAK,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC,CACnE;MAAA,CAAC,QAAQ,CACX;IAAA,EAAE,eAAe,CAAC,CACnB,CAAA;AACH,CAAC;AAED,oCAAoC;AACpC,oCAAoC;AACpC,oCAAoC;AAEpC,MAAM,SAAS,GAAG,GAAG,EAAE;IACrB,MAAM,EAAE,MAAM,EAAE,GAAG,QAAQ,EAAE,CAAA;IAC7B,OAAO,UAAU,CAAC,MAAM,CAAC;QACvB,KAAK,EAAE;YACL,KAAK,EAAE,MAAM,CAAC,uBAAuB;YACrC,QAAQ,EAAE,MAAM,CAAC,UAAU;SAC5B;QACD,iEAAiE;QACjE,4DAA4D;QAC5D,gGAAgG;QAChG,SAAS,EAAE;YACT,KAAK,EAAE,MAAM,CAAC,uBAAuB;YACrC,QAAQ,EAAE,MAAM,CAAC,UAAU;SAC5B;QACD,QAAQ,EAAE;YACR,KAAK,EAAE,MAAM,CAAC,yBAAyB;YACvC,QAAQ,EAAE,MAAM,CAAC,UAAU;SAC5B;QACD,QAAQ,EAAE;YACR,KAAK,EAAE,MAAM,CAAC,yBAAyB;YACvC,QAAQ,EAAE,MAAM,CAAC,UAAU;SAC5B;KACF,CAAC,CAAA;AACJ,CAAC,CAAA","sourcesContent":["import { useTheme } from '../../hooks'\nimport React from 'react'\nimport { Platform, StyleSheet, Text as ReactNativeText } from 'react-native'\nimport type { TextStyle, TextProps as ReactNativeTextProps } from 'react-native'\nimport { tokens } from '../../vendor/tapestry/tokens'\n\n// =================================\n// ====== Constants ================\n// =================================\n\nconst VARIANTS = {\n plain: 'plain',\n secondary: 'secondary',\n tertiary: 'tertiary',\n footnote: 'footnote',\n} as const\n\ntype VariantUnion = (typeof VARIANTS)[keyof typeof VARIANTS]\ntype VariantStyles = Record<VariantUnion, TextStyle>\n\n// =================================\n// ====== Component ================\n// =================================\n\nexport interface TextProps extends ReactNativeTextProps {\n /**\n * Changes the styles and size of the text.\n */\n variant?: VariantUnion\n}\n\nexport function Text({ style, variant = 'plain', children, ...props }: TextProps) {\n const styles = useStyles()\n const variantStyleMap: VariantStyles = {\n [VARIANTS.plain]: styles.plain,\n [VARIANTS.secondary]: styles.secondary,\n [VARIANTS.tertiary]: styles.tertiary,\n [VARIANTS.footnote]: styles.footnote,\n }\n\n return (\n <ReactNativeText style={[variantStyleMap[variant], style]} {...props}>\n {children}\n </ReactNativeText>\n )\n}\n\n// =================================\n// ====== Styles ===================\n// =================================\n\nconst useStyles = () => {\n const { colors } = useTheme()\n return StyleSheet.create({\n plain: {\n color: colors.textColorDefaultPrimary,\n fontSize: tokens.fontSizeMd,\n },\n // This is a dupe of the plain variant to support the legacy API.\n // Once we move to the new Doxy font scale we can remove it.\n // See: https://www.figma.com/design/ZR0ZP6FdbOBOK3fUSpRr0Q/CC-Redux-2025?node-id=156-1069&m=dev\n secondary: {\n color: colors.textColorDefaultPrimary,\n fontSize: tokens.fontSizeMd,\n },\n tertiary: {\n color: colors.textColorDefaultSecondary,\n fontSize: tokens.fontSizeSm,\n },\n footnote: {\n color: colors.textColorDefaultSecondary,\n fontSize: tokens.fontSizeXs,\n },\n })\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/components/index.tsx"],"names":[],"mappings":"AAAA,cAAc,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/components/index.tsx"],"names":[],"mappings":"AAAA,cAAc,+BAA+B,CAAA;AAC7C,cAAc,uBAAuB,CAAA;AACrC,cAAc,WAAW,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/components/index.tsx"],"names":[],"mappings":"AAAA,cAAc,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/components/index.tsx"],"names":[],"mappings":"AAAA,cAAc,+BAA+B,CAAA;AAC7C,cAAc,uBAAuB,CAAA;AACrC,cAAc,WAAW,CAAA","sourcesContent":["export * from './conversations/conversations'\nexport * from './page/error_boundary'\nexport * from './display'\n"]}
|
|
@@ -10,7 +10,7 @@ declare class ErrorBoundary extends React.Component<PropsWithChildren<{
|
|
|
10
10
|
componentDidCatch(error: any): void;
|
|
11
11
|
handleError(error: any): void;
|
|
12
12
|
handleReset: () => void;
|
|
13
|
-
render(): string | number | boolean | React.
|
|
13
|
+
render(): string | number | boolean | Iterable<React.ReactNode> | React.JSX.Element | null | undefined;
|
|
14
14
|
}
|
|
15
15
|
export default ErrorBoundary;
|
|
16
16
|
//# sourceMappingURL=error_boundary.d.ts.map
|
package/build/hooks/use_api.d.ts
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
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
|
-
|
|
5
|
-
|
|
4
|
+
import { App } from './use_api_client';
|
|
5
|
+
interface ApiGetOptions extends GetRequest {
|
|
6
|
+
app?: App;
|
|
7
|
+
enabled?: boolean;
|
|
6
8
|
}
|
|
7
|
-
export declare const useApiGet: <T extends ResourceObject | ResourceObject[]>(args:
|
|
9
|
+
export declare const useApiGet: <T extends ResourceObject | ResourceObject[]>(args: ApiGetOptions) => {
|
|
8
10
|
error: Response;
|
|
9
11
|
isError: true;
|
|
10
12
|
isPending: false;
|
|
@@ -174,7 +176,7 @@ export declare const useApiGet: <T extends ResourceObject | ResourceObject[]>(ar
|
|
|
174
176
|
meta?: Record<string, unknown> | undefined;
|
|
175
177
|
};
|
|
176
178
|
export type SuspensePaginatorOptions = Omit<AnyUseSuspenseInfiniteQueryOptions, 'getNextPageParam' | 'initialPageParam' | 'queryFn' | 'queryKey'>;
|
|
177
|
-
export declare const useApiPaginator: <T extends ResourceObject>(args:
|
|
179
|
+
export declare const useApiPaginator: <T extends ResourceObject>(args: ApiGetOptions, opts?: SuspensePaginatorOptions) => {
|
|
178
180
|
data: T[];
|
|
179
181
|
error: Response;
|
|
180
182
|
isError: true;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use_api.d.ts","sourceRoot":"","sources":["../../src/hooks/use_api.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,kCAAkC,EAClC,YAAY,EAGb,MAAM,uBAAuB,CAAA;AAC9B,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,UAAU,CAAA;AACrE,OAAO,EAAE,UAAU,EAAe,MAAM,uBAAuB,CAAA;
|
|
1
|
+
{"version":3,"file":"use_api.d.ts","sourceRoot":"","sources":["../../src/hooks/use_api.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,kCAAkC,EAClC,YAAY,EAGb,MAAM,uBAAuB,CAAA;AAC9B,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,UAAU,CAAA;AACrE,OAAO,EAAE,UAAU,EAAe,MAAM,uBAAuB,CAAA;AAC/D,OAAO,EAAE,GAAG,EAAgB,MAAM,kBAAkB,CAAA;AAGpD,UAAU,aAAc,SAAQ,UAAU;IACxC,GAAG,CAAC,EAAE,GAAG,CAAA;IACT,OAAO,CAAC,EAAE,OAAO,CAAA;CAClB;AAED,eAAO,MAAM,SAAS,GAAI,CAAC,SAAS,cAAc,GAAG,cAAc,EAAE,QAAQ,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CASzF,CAAA;AAOD,MAAM,MAAM,wBAAwB,GAAG,IAAI,CACzC,kCAAkC,EAClC,kBAAkB,GAAG,kBAAkB,GAAG,SAAS,GAAG,UAAU,CACjE,CAAA;AAED,eAAO,MAAM,eAAe,GAAI,CAAC,SAAS,cAAc,QAChD,aAAa,SACZ,wBAAwB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAyChC,CAAA"}
|
package/build/hooks/use_api.js
CHANGED
|
@@ -4,6 +4,7 @@ import { getRequestQueryKey } from './use_suspense_api';
|
|
|
4
4
|
export const useApiGet = (args) => {
|
|
5
5
|
const { data, ...query } = useQuery({
|
|
6
6
|
queryKey: getRequestQueryKey(args),
|
|
7
|
+
enabled: args.enabled,
|
|
7
8
|
});
|
|
8
9
|
return { ...data, ...query };
|
|
9
10
|
};
|
|
@@ -15,9 +16,10 @@ export const useApiPaginator = (args, opts) => {
|
|
|
15
16
|
const pageParmWhere = pageParam?.where || {};
|
|
16
17
|
const argsWhere = args.data.where || {};
|
|
17
18
|
const where = { ...argsWhere, ...pageParmWhere };
|
|
19
|
+
const app = args.app || 'chat';
|
|
18
20
|
const offset = pageParam?.offset || args.data.offset;
|
|
19
21
|
const data = { ...args.data, where, offset };
|
|
20
|
-
return apiClient.
|
|
22
|
+
return apiClient[app].get({
|
|
21
23
|
url: args.url,
|
|
22
24
|
data,
|
|
23
25
|
});
|
|
@@ -32,9 +34,10 @@ export const useApiPaginator = (args, opts) => {
|
|
|
32
34
|
return { offset: Number(offset) };
|
|
33
35
|
return undefined;
|
|
34
36
|
},
|
|
37
|
+
enabled: args.enabled,
|
|
35
38
|
...(opts || {}),
|
|
36
39
|
});
|
|
37
|
-
const data = query.data?.pages
|
|
40
|
+
const data = query.data?.pages?.flatMap(page => page.data) || [];
|
|
38
41
|
return { ...query, data };
|
|
39
42
|
};
|
|
40
43
|
//# sourceMappingURL=use_api.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use_api.js","sourceRoot":"","sources":["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,MAAM,IAAI,IAAI,CAAC,IAAI,CAAC,MAAM,CAAA;YACpD,MAAM,IAAI,GAAG,EAAE,GAAG,IAAI,CAAC,IAAI,EAAE,KAAK,EAAE,MAAM,EAAE,CAAA;YAE5C,OAAO,SAAS,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC;gBACxB,GAAG,EAAE,IAAI,CAAC,GAAG;gBACb,IAAI;aACL,CAAC,CAAA;QACJ,CAAC;QACD,gBAAgB,EAAE,EAA0B;QAC5C,gBAAgB,EAAE,QAAQ,CAAC,EAAE;YAC3B,MAAM,IAAI,GAAa,QAAQ,CAAC,IAAI,EAAE,IAAI,IAAI,EAAE,CAAA;YAChD,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,IAAI,CAAA;YAE7B,IAAI,IAAI;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,OAAO,EAAE,IAAI,CAAC,OAAO;QACrB,GAAG,CAAC,IAAI,IAAI,EAAE,CAAC;KAChB,CAAC,CAAA;IAEF,MAAM,IAAI,GAAQ,KAAK,CAAC,IAAI,EAAE,KAAK,EAAE,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,CAAA;IAErE,OAAO,EAAE,GAAG,KAAK,EAAE,IAAI,EAAE,CAAA;AAC3B,CAAC,CAAA","sourcesContent":["import {\n AnyUseSuspenseInfiniteQueryOptions,\n InfiniteData,\n useInfiniteQuery,\n useQuery,\n} from '@tanstack/react-query'\nimport { ApiCollection, ApiResource, ResourceObject } from '../types'\nimport { GetRequest, RequestData } from '../utils/client/types'\nimport { App, useApiClient } from './use_api_client'\nimport { getRequestQueryKey } from './use_suspense_api'\n\ninterface ApiGetOptions extends GetRequest {\n app?: App\n enabled?: boolean\n}\n\nexport const useApiGet = <T extends ResourceObject | ResourceObject[]>(args: ApiGetOptions) => {\n type Resource = ApiResource<T>\n\n const { data, ...query } = useQuery<Resource, Response>({\n queryKey: getRequestQueryKey(args),\n enabled: args.enabled,\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 useApiPaginator = <T extends ResourceObject>(\n args: ApiGetOptions,\n opts?: SuspensePaginatorOptions\n) => {\n const apiClient = useApiClient()\n const query = useInfiniteQuery<\n ApiCollection<T>,\n Response,\n InfiniteData<ApiCollection<T>>,\n any,\n Partial<RequestData> | undefined\n >({\n queryKey: getRequestQueryKey(args),\n queryFn: ({ pageParam }) => {\n const pageParmWhere = pageParam?.where || {}\n const argsWhere = args.data.where || {}\n const where = { ...argsWhere, ...pageParmWhere }\n const app = args.app || 'chat'\n const offset = pageParam?.offset || args.data.offset\n const data = { ...args.data, where, offset }\n\n return apiClient[app].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 enabled: args.enabled,\n ...(opts || {}),\n })\n\n const data: T[] = query.data?.pages?.flatMap(page => page.data) || []\n\n return { ...query, data }\n}\n"]}
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { Client } from '../utils/client';
|
|
2
|
-
type App = 'chat' | 'groups' | 'services';
|
|
2
|
+
export type App = 'chat' | 'groups' | 'services';
|
|
3
3
|
export type ApiClient = {
|
|
4
4
|
[_K in App]: Client;
|
|
5
5
|
};
|
|
6
6
|
export declare const useApiClient: () => ApiClient;
|
|
7
|
-
export {};
|
|
8
7
|
//# sourceMappingURL=use_api_client.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use_api_client.d.ts","sourceRoot":"","sources":["../../src/hooks/use_api_client.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAA;AAExC,
|
|
1
|
+
{"version":3,"file":"use_api_client.d.ts","sourceRoot":"","sources":["../../src/hooks/use_api_client.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAA;AAExC,MAAM,MAAM,GAAG,GAAG,MAAM,GAAG,QAAQ,GAAG,UAAU,CAAA;AAGhD,MAAM,MAAM,SAAS,GAAG;KAAG,EAAE,IAAI,GAAG,GAAG,MAAM;CAAE,CAAA;AAE/C,eAAO,MAAM,YAAY,iBAiBxB,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use_api_client.js","sourceRoot":"","sources":["../../src/hooks/use_api_client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,OAAO,CAAA;AAC3C,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAA;AACtD,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAA;AAGxC,MAAM,IAAI,GAAU,CAAC,MAAM,EAAE,QAAQ,EAAE,UAAU,CAAC,CAAA;AAIlD,MAAM,CAAC,MAAM,YAAY,GAAG,GAAG,EAAE;IAC/B,MAAM,EAAE,OAAO,EAAE,sBAAsB,EAAE,GAAG,UAAU,CAAC,WAAW,CAAC,CAAA;IACnE,MAAM,GAAG,GAAG,OAAO,CACjB,GAAG,EAAE,CACH,IAAI,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE;QACvB,GAAG,CAAC,GAAG,CAAC,GAAG,IAAI,MAAM,CAAC;YACpB,GAAG;YACH,OAAO;YACP,OAAO,EAAE,YAAY;YACrB,sBAAsB;SACvB,CAAC,CAAA;QACF,OAAO,GAAG,CAAA;IACZ,CAAC,EAAE,EAAe,CAAC,EACrB,CAAC,OAAO,EAAE,sBAAsB,CAAC,CAClC,CAAA;IAED,OAAO,GAAG,CAAA;AACZ,CAAC,CAAA","sourcesContent":["import { useContext, useMemo } from 'react'\nimport { ChatContext } from '../contexts/chat_context'\nimport { Client } from '../utils/client'\n\
|
|
1
|
+
{"version":3,"file":"use_api_client.js","sourceRoot":"","sources":["../../src/hooks/use_api_client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,OAAO,CAAA;AAC3C,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAA;AACtD,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAA;AAGxC,MAAM,IAAI,GAAU,CAAC,MAAM,EAAE,QAAQ,EAAE,UAAU,CAAC,CAAA;AAIlD,MAAM,CAAC,MAAM,YAAY,GAAG,GAAG,EAAE;IAC/B,MAAM,EAAE,OAAO,EAAE,sBAAsB,EAAE,GAAG,UAAU,CAAC,WAAW,CAAC,CAAA;IACnE,MAAM,GAAG,GAAG,OAAO,CACjB,GAAG,EAAE,CACH,IAAI,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE;QACvB,GAAG,CAAC,GAAG,CAAC,GAAG,IAAI,MAAM,CAAC;YACpB,GAAG;YACH,OAAO;YACP,OAAO,EAAE,YAAY;YACrB,sBAAsB;SACvB,CAAC,CAAA;QACF,OAAO,GAAG,CAAA;IACZ,CAAC,EAAE,EAAe,CAAC,EACrB,CAAC,OAAO,EAAE,sBAAsB,CAAC,CAClC,CAAA;IAED,OAAO,GAAG,CAAA;AACZ,CAAC,CAAA","sourcesContent":["import { useContext, useMemo } from 'react'\nimport { ChatContext } from '../contexts/chat_context'\nimport { Client } from '../utils/client'\n\nexport type App = 'chat' | 'groups' | 'services'\nconst apps: App[] = ['chat', 'groups', 'services']\n\nexport type ApiClient = { [_K in App]: Client }\n\nexport const useApiClient = () => {\n const { session, onUnauthorizedResponse } = useContext(ChatContext)\n const api = useMemo(\n () =>\n apps.reduce((acc, app) => {\n acc[app] = new Client({\n app,\n session,\n version: '2018-11-01',\n onUnauthorizedResponse,\n })\n return acc\n }, {} as ApiClient),\n [session, onUnauthorizedResponse]\n )\n\n return api\n}\n"]}
|
|
@@ -3,7 +3,7 @@ import { useState } from 'react';
|
|
|
3
3
|
import { transformGetToPost } from '../utils/client/request_helpers';
|
|
4
4
|
import { useApiClient } from './use_api_client';
|
|
5
5
|
import { getRequestQueryKey, useSuspenseGet } from './use_suspense_api';
|
|
6
|
-
import { getConversationsRequestArgs } from '
|
|
6
|
+
import { getConversationsRequestArgs } from '../utils/request/conversation';
|
|
7
7
|
export const getConversationRequestArgs = ({ conversation_id }) => ({
|
|
8
8
|
url: `/me/conversations/${conversation_id}`,
|
|
9
9
|
data: {
|
|
@@ -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,qBAAqB,CAAA;AAEjE,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,YAAY;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E;YAC3C,OAAO,WAAW,CAAC,YAAY,CAAoC,QAAQ,EAAE,IAAI,CAAC,EAAE;gBAClF,IAAI,CAAC,IAAI,EAAE,IAAI;oBAAE,OAAO,IAAI,CAAA;gBAC5B,QAAQ,CAAC,eAAe,CAAC,CAAA;gBACzB,IAAI,CAAC,IAAI,CAAC,eAAe,GAAG,eAAe,CAAA;gBAE3C,OAAO,IAAI,CAAA;YACb,CAAC,CAAC,CAAA;QACJ,CAAC;QACD,WAAW,EAAE,CAAC,4BAA4B,CAAC;QAC3C,UAAU,EAAE,KAAK,EAAE,eAAwB,EAAE,EAAE;YAC7C,OAAO,SAAS,CAAC,IAAI,CAAC,KAAK,CAAC;gBAC1B,GAAG,EAAE,qBAAqB,eAAe,EAAE;gBAC3C,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 './use_conversations'\n\nexport const getConversationRequestArgs = ({ conversation_id }: { conversation_id: number }) => ({\n url: `/me/conversations/${conversation_id}`,\n data: {\n fields: {\n Conversation: [\n 'created_at',\n 'badges',\n 'groups',\n 'last_message_author_id',\n 'last_message_author_name',\n 'last_message_created_at',\n 'last_message_text_preview',\n 'preview_avatar_urls',\n 'member_ability',\n 'muted',\n 'replies_disabled',\n 'title',\n 'unread_count',\n 'updated_at',\n ],\n MemberAbility: ['can_update', 'can_delete', 'leader'],\n ConversationBadge: ['app_name', 'pco_resource_type', 'text'],\n Group: ['type', 'id', 'links', 'name', 'source_app_name', 'source_type'],\n },\n include: ['badges', 'member_ability', 'groups'],\n },\n})\n\nexport const useConversation = ({ conversation_id }) => {\n return useSuspenseGet<ConversationResource>(getConversationRequestArgs({ conversation_id }))\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({\n url: `/me/conversations/${conversation_id}/${action}`,\n data: { data: { type: '', attributes: {} }, fields: { Conversation: 'muted' } },\n })\n },\n onSuccess: (response: ApiResource<ConversationResource>) => {\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({\n url: `/me/conversations/${conversation_id}/`,\n data: { data: { type: '', attributes: update }, ...postArgs },\n })\n },\n onSuccess: (response: ApiResource<ConversationResource>) => {\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 },\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({\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,OAAO,EAAE,kBAAkB,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAA;AACvE,OAAO,EAAE,2BAA2B,EAAE,MAAM,+BAA+B,CAAA;AAE3E,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,YAAY;gBACZ,QAAQ;gBACR,QAAQ;gBACR,wBAAwB;gBACxB,0BAA0B;gBAC1B,yBAAyB;gBACzB,2BAA2B;gBAC3B,qBAAqB;gBACrB,gBAAgB;gBAChB,OAAO;gBACP,kBAAkB;gBAClB,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AAe,CAAC,CAAA;gBACzB,IAAI,CAAC,IAAI,CAAC,eAAe,GAAG,eAAe,CAAA;gBAE3C,OAAO,IAAI,CAAA;YACb,CAAC,CAAC,CAAA;QACJ,CAAC;QACD,WAAW,EAAE,CAAC,4BAA4B,CAAC;QAC3C,UAAU,EAAE,KAAK,EAAE,eAAwB,EAAE,EAAE;YAC7C,OAAO,SAAS,CAAC,IAAI,CAAC,KAAK,CAAC;gBAC1B,GAAG,EAAE,qBAAqB,eAAe,EAAE;gBAC3C,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'\n\nexport const getConversationRequestArgs = ({ conversation_id }: { conversation_id: number }) => ({\n url: `/me/conversations/${conversation_id}`,\n data: {\n fields: {\n Conversation: [\n 'created_at',\n 'badges',\n 'groups',\n 'last_message_author_id',\n 'last_message_author_name',\n 'last_message_created_at',\n 'last_message_text_preview',\n 'preview_avatar_urls',\n 'member_ability',\n 'muted',\n 'replies_disabled',\n 'title',\n 'unread_count',\n 'updated_at',\n ],\n MemberAbility: ['can_update', 'can_delete', 'leader'],\n ConversationBadge: ['app_name', 'pco_resource_type', 'text'],\n Group: ['type', 'id', 'links', 'name', 'source_app_name', 'source_type'],\n },\n include: ['badges', 'member_ability', 'groups'],\n },\n})\n\nexport const useConversation = ({ conversation_id }) => {\n return useSuspenseGet<ConversationResource>(getConversationRequestArgs({ conversation_id }))\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({\n url: `/me/conversations/${conversation_id}/${action}`,\n data: { data: { type: '', attributes: {} }, fields: { Conversation: 'muted' } },\n })\n },\n onSuccess: (response: ApiResource<ConversationResource>) => {\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({\n url: `/me/conversations/${conversation_id}/`,\n data: { data: { type: '', attributes: update }, ...postArgs },\n })\n },\n onSuccess: (response: ApiResource<ConversationResource>) => {\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 },\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({\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,10 +1,10 @@
|
|
|
1
1
|
import { useQueryClient } from '@tanstack/react-query';
|
|
2
2
|
import { deleteRecordInPagesData, updateOrCreateRecordInPagesData } from '../utils';
|
|
3
3
|
import { useApiClient } from './use_api_client';
|
|
4
|
-
import { getConversationsRequestArgs } from './use_conversations';
|
|
5
4
|
import { useCurrentPerson } from './use_current_person';
|
|
6
5
|
import { useJoltChannel, useJoltEvent } from './use_jolt';
|
|
7
6
|
import { getRequestQueryKey } from './use_suspense_api';
|
|
7
|
+
import { getConversationsRequestArgs } from '../utils/request/conversation';
|
|
8
8
|
export function useConversationsJoltEvents() {
|
|
9
9
|
const apiClient = useApiClient();
|
|
10
10
|
const queryClient = useQueryClient();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use_conversation_jolt_events.js","sourceRoot":"","sources":["../../src/hooks/use_conversation_jolt_events.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,cAAc,EAAE,MAAM,uBAAuB,CAAA;AAEpE,OAAO,EAAE,uBAAuB,EAAE,+BAA+B,EAAE,MAAM,UAAU,CAAA;AACnF,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAA;AAC/C,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"use_conversation_jolt_events.js","sourceRoot":"","sources":["../../src/hooks/use_conversation_jolt_events.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,cAAc,EAAE,MAAM,uBAAuB,CAAA;AAEpE,OAAO,EAAE,u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I,CAAC,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAA;QAEzF,WAAW,CAAC,YAAY,CAAY,oBAAoB,EAAE,IAAI,CAAC,EAAE,CAC/D,+BAA+B,CAAC;YAC9B,IAAI,EAAE,IAAI;YACV,MAAM,EAAE,YAAY;YACpB,aAAa,EAAE,CAAC,MAAM,EAAE,OAAO,EAAE,EAAE;gBACjC,OAAO,EAAE,GAAG,OAAO,EAAE,GAAG,MAAM,EAAE,CAAA;YAClC,CAAC;SACF,CAAC,CACH,CAAA;IACH,CAAC,CAAA;IAED,MAAM,yBAAyB,GAAG,CAAC,CAA2B,EAAE,EAAE;QAChE,WAAW,CAAC,YAAY,CAAY,oBAAoB,EAAE,IAAI,CAAC,EAAE,CAC/D,uBAAuB,CAAC;YACtB,IAAI,EAAE,IAAI;YACV,MAAM,EAAE,EAAE,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,EAAE;SAC/B,CAAC,CACH,CAAA;IACH,CAAC,CAAA;IAED,YAAY,CAAC,WAAW,EAAE,sBAAsB,EAAE,gCAAgC,CAAC,CAAA;IACnF,YAAY,CAAC,WAAW,EAAE,sBAAsB,EAAE,gCAAgC,CAAC,CAAA;IACnF,YAAY,CAAC,WAAW,EAAE,wBAAwB,EAAE,yBAAyB,CAAC,CAAA;AAChF,CAAC","sourcesContent":["import { InfiniteData, useQueryClient } from '@tanstack/react-query'\nimport { ApiCollection, ApiResource, ConversationResource } from '../types'\nimport { deleteRecordInPagesData, updateOrCreateRecordInPagesData } from '../utils'\nimport { useApiClient } from './use_api_client'\nimport { useCurrentPerson } from './use_current_person'\nimport { useJoltChannel, useJoltEvent } from './use_jolt'\nimport { getRequestQueryKey } from './use_suspense_api'\nimport { JoltConversationEvent } from '../types/jolt_events'\nimport { ConversationDeletedEvent } from '../types/jolt_events/conversation_events'\nimport { getConversationsRequestArgs } from '../utils/request/conversation'\n\ntype QueryData = InfiniteData<ApiCollection<ConversationResource>>\n\nexport function useConversationsJoltEvents() {\n const apiClient = useApiClient()\n const queryClient = useQueryClient()\n const currentPerson = useCurrentPerson()\n const joltChannel = useJoltChannel(`chat.people.${currentPerson.id}`)\n\n const conversationsRequestArgs = getConversationsRequestArgs()\n const conversationQueryKey = getRequestQueryKey(conversationsRequestArgs)\n\n const fetchConversation = async (id: number) => {\n const { data: argsData } = conversationsRequestArgs\n const { data } = await apiClient.chat.get<ApiResource<ConversationResource>>({\n url: `/me/conversations/${id}`,\n data: {\n fields: argsData.fields,\n include: argsData.include,\n },\n })\n\n return data\n }\n\n const handleConversationUpdateOrCreate = async (e: JoltConversationEvent) => {\n const { data } = e.data\n const conversation: ConversationResource = await fetchConversation(data.id).catch(c => c)\n\n queryClient.setQueryData<QueryData>(conversationQueryKey, prev =>\n updateOrCreateRecordInPagesData({\n data: prev,\n record: conversation,\n processRecord: (record, current) => {\n return { ...current, ...record }\n },\n })\n )\n }\n\n const handleConversationDestroy = (e: ConversationDeletedEvent) => {\n queryClient.setQueryData<QueryData>(conversationQueryKey, prev =>\n deleteRecordInPagesData({\n data: prev,\n record: { id: e.data.data.id },\n })\n )\n }\n\n useJoltEvent(joltChannel, 'conversation.updated', handleConversationUpdateOrCreate)\n useJoltEvent(joltChannel, 'conversation.created', handleConversationUpdateOrCreate)\n useJoltEvent(joltChannel, 'conversation.destroyed', handleConversationDestroy)\n}\n"]}
|
|
@@ -3,9 +3,9 @@ import { deleteRecordInPagesData, updateOrCreateRecordInPagesData, updateRecordI
|
|
|
3
3
|
import { useQueryClient } from '@tanstack/react-query';
|
|
4
4
|
import { useCurrentPerson } from './use_current_person';
|
|
5
5
|
import { transformMessageEventDataToMessageResource } from '../utils/jolt/transform_message_event_data_to_message_resource';
|
|
6
|
-
import { getMessagesRequestArgs } from './use_conversation_messages';
|
|
7
6
|
import { getRequestQueryKey } from './use_suspense_api';
|
|
8
7
|
import { transformReactionEventDataToReactionCountResource } from '../utils/jolt/transform_reaction_event_data_to_reaction_count_resource';
|
|
8
|
+
import { getMessagesRequestArgs } from '../utils/request/messages';
|
|
9
9
|
export function useConversationMessagesJoltEvents({ conversationId }) {
|
|
10
10
|
const queryClient = useQueryClient();
|
|
11
11
|
const currentPerson = useCurrentPerson();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use_conversation_messages_jolt_events.js","sourceRoot":"","sources":["../../src/hooks/use_conversation_messages_jolt_events.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,YAAY,CAAA;AACzD,OAAO,EACL,uBAAuB,EACvB,+BAA+B,EAC/B,uBAAuB,GACxB,MAAM,UAAU,CAAA;AAEjB,OAAO,EAAgB,cAAc,EAAE,MAAM,uBAAuB,CAAA;AACpE,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAA;AACvD,OAAO,EAAE,0CAA0C,EAAE,MAAM,gEAAgE,CAAA;AAC3H,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"use_conversation_messages_jolt_events.js","sourceRoot":"","sources":["../../src/hooks/use_conversation_messages_jolt_events.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,YAAY,CAAA;AACzD,OAAO,EACL,uBAAuB,EACvB,+BAA+B,EAC/B,uBAAuB,GACxB,MAAM,UAAU,CAAA;AAEjB,OAAO,EAAgB,cAAc,EAAE,MAAM,uBAAuB,CAAA;AACpE,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAA;AACvD,OAAO,EAAE,0CAA0C,EAAE,MAAM,gEAAgE,CAAA;AAC3H,OAAO,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAA;AAEvD,OAAO,EAAE,iDAAiD,EAAE,MAAM,wEAAwE,CAAA;AAC1I,OAAO,EAAE,sBAAsB,EAAE,MAAM,2BAA2B,CAAA;AAMlE,MAAM,UAAU,iCAAiC,CAAC,EAAE,cAAc,EAAS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,CAAC;oBAChB,MAAM,gBAAgB,GAAG,iDAAiD,CAAC;wBACzE,IAAI;wBACJ,KAAK,EAAE,CAAC,CAAC,KAAK;wBACd,eAAe,EAAE,aAAa,CAAC,EAAE;qBAClC,CAAC,CAAA;oBAEF,IAAI,gBAAgB,EAAE,KAAK,EAAE,CAAC;wBAC5B,iBAAiB,GAAG,CAAC,GAAG,iBAAiB,EAAE,gBAAgB,CAAC,CAAA;oBAC9D,CAAC;gBACH,CAAC;gBAED,OAAO,EAAE,GAAG,UAAU,EAAE,cAAc,EAAE,iBAAiB,EAAE,CAAA;YAC7D,CAAC;SACF,CAAC,CACH,CAAA;IACH,CAAC,CAAA;IAED,YAAY,CAAC,WAAW,EAAE,iBAAiB,EAAE,2BAA2B,CAAC,CAAA;IACzE,YAAY,CAAC,WAAW,EAAE,iBAAiB,EAAE,2BAA2B,CAAC,CAAA;IACzE,YAAY,CAAC,WAAW,EAAE,mBAAmB,EAAE,oBAAoB,CAAC,CAAA;IACpE,YAAY,CAAC,WAAW,EAAE,YAAY,EAAE,uBAAuB,CAAC,CAAA;AAClE,CAAC","sourcesContent":["import { ApiCollection, MessageResource } from '../types'\nimport { useJoltChannel, useJoltEvent } from './use_jolt'\nimport {\n deleteRecordInPagesData,\n updateOrCreateRecordInPagesData,\n updateRecordInPagesData,\n} from '../utils'\nimport { MessageCreatedEvent, MessageDeletedEvent } from '../types/jolt_events/message_events'\nimport { InfiniteData, useQueryClient } from '@tanstack/react-query'\nimport { useCurrentPerson } from './use_current_person'\nimport { transformMessageEventDataToMessageResource } from '../utils/jolt/transform_message_event_data_to_message_resource'\nimport { getRequestQueryKey } from './use_suspense_api'\nimport { JoltReactionEvent } from '../types/jolt_events'\nimport { transformReactionEventDataToReactionCountResource } from '../utils/jolt/transform_reaction_event_data_to_reaction_count_resource'\nimport { getMessagesRequestArgs } from '../utils/request/messages'\n\ninterface Props {\n conversationId: number\n}\n\nexport function useConversationMessagesJoltEvents({ conversationId }: Props) {\n const queryClient = useQueryClient()\n const currentPerson = useCurrentPerson()\n const joltChannel = useJoltChannel(`chat.conversations.${conversationId}`)\n const messagesRequestArgs = getMessagesRequestArgs({ conversation_id: conversationId })\n const messagesQueryKey = getRequestQueryKey(messagesRequestArgs)\n\n const handleMessageUpdateOrCreate = async (e: MessageCreatedEvent) => {\n const { data } = e.data\n const message = transformMessageEventDataToMessageResource({\n data,\n currentPersonId: currentPerson.id,\n })\n\n queryClient.setQueryData<QueryData>(messagesQueryKey, prev => {\n if (e.event === 'message.created') {\n return updateOrCreateRecordInPagesData({\n data: prev,\n record: message,\n processRecord: (record, current) => {\n return { ...current, ...record }\n },\n })\n } else {\n return updateRecordInPagesData({\n data: prev,\n record: message,\n processRecord: (record, current) => {\n return { ...current, ...record }\n },\n })\n }\n })\n }\n\n const handleMessageDeleted = async (e: MessageDeletedEvent) => {\n const { data } = e.data\n const message = transformMessageEventDataToMessageResource({\n data,\n currentPersonId: currentPerson.id,\n })\n\n queryClient.setQueryData<QueryData>(messagesQueryKey, prev =>\n deleteRecordInPagesData({ data: prev, record: message })\n )\n }\n\n const handleReactionJoltEvent = async (e: JoltReactionEvent) => {\n const { data } = e.data\n const message = { id: data.message_sort_key } as MessageResource\n queryClient.setQueryData<QueryData>(messagesQueryKey, prev =>\n updateRecordInPagesData({\n data: prev,\n record: message,\n processRecord: (record, oldMessage) => {\n const reactionCounts = oldMessage.reactionCounts || []\n let foundMatch = false\n let newReactionCounts = reactionCounts.map(reactionCount => {\n if (reactionCount.value === data.value) {\n foundMatch = true\n return transformReactionEventDataToReactionCountResource({\n data,\n oldData: reactionCount,\n event: e.event,\n currentPersonId: currentPerson.id,\n })\n }\n return reactionCount\n })\n\n if (!foundMatch) {\n const newReactionCount = transformReactionEventDataToReactionCountResource({\n data,\n event: e.event,\n currentPersonId: currentPerson.id,\n })\n\n if (newReactionCount?.count) {\n newReactionCounts = [...newReactionCounts, newReactionCount]\n }\n }\n\n return { ...oldMessage, reactionCounts: newReactionCounts }\n },\n })\n )\n }\n\n useJoltEvent(joltChannel, 'message.created', handleMessageUpdateOrCreate)\n useJoltEvent(joltChannel, 'message.updated', handleMessageUpdateOrCreate)\n useJoltEvent(joltChannel, 'message.destroyed', handleMessageDeleted)\n useJoltEvent(joltChannel, 'reaction.*', handleReactionJoltEvent)\n}\n\ntype QueryData = InfiniteData<ApiCollection<MessageResource>>\n"]}
|