@planningcenter/chat-react-native 3.42.3-qa-staging.7 → 3.42.3-qa-858.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/components/conversation/messages_disabled_banners.d.ts +3 -2
- package/build/components/conversation/messages_disabled_banners.d.ts.map +1 -1
- package/build/components/conversation/messages_disabled_banners.js +7 -2
- package/build/components/conversation/messages_disabled_banners.js.map +1 -1
- package/build/components/display/adult_requirement_notice.js +1 -1
- package/build/components/display/adult_requirement_notice.js.map +1 -1
- package/build/components/display/platform_modal_header_buttons.d.ts +45 -7
- package/build/components/display/platform_modal_header_buttons.d.ts.map +1 -1
- package/build/components/display/platform_modal_header_buttons.js +108 -9
- package/build/components/display/platform_modal_header_buttons.js.map +1 -1
- package/build/components/primitive/form_sheet.js +2 -2
- package/build/components/primitive/form_sheet.js.map +1 -1
- package/build/hooks/use_conversation.d.ts.map +1 -1
- package/build/hooks/use_conversation.js +0 -1
- package/build/hooks/use_conversation.js.map +1 -1
- package/build/hooks/use_conversation_jolt_events.d.ts.map +1 -1
- package/build/hooks/use_conversation_jolt_events.js +2 -10
- package/build/hooks/use_conversation_jolt_events.js.map +1 -1
- package/build/navigation/index.d.ts +76 -149
- package/build/navigation/index.d.ts.map +1 -1
- package/build/navigation/index.js +67 -79
- package/build/navigation/index.js.map +1 -1
- package/build/screens/bug_report_screen.d.ts.map +1 -1
- package/build/screens/bug_report_screen.js +10 -13
- package/build/screens/bug_report_screen.js.map +1 -1
- package/build/screens/conversation_details_screen.d.ts.map +1 -1
- package/build/screens/conversation_details_screen.js +11 -12
- package/build/screens/conversation_details_screen.js.map +1 -1
- package/build/screens/conversation_filters/components/rows.js +1 -1
- package/build/screens/conversation_filters/components/rows.js.map +1 -1
- package/build/screens/conversation_filters_screen.d.ts.map +1 -1
- package/build/screens/conversation_filters_screen.js +15 -2
- package/build/screens/conversation_filters_screen.js.map +1 -1
- package/build/screens/conversation_screen.d.ts.map +1 -1
- package/build/screens/conversation_screen.js +7 -3
- package/build/screens/conversation_screen.js.map +1 -1
- package/build/screens/conversation_select_recipients/components/groups_recipient_row.js +1 -1
- package/build/screens/conversation_select_recipients/components/groups_recipient_row.js.map +1 -1
- package/build/screens/conversation_select_recipients/components/restricted_group_row.js +1 -1
- package/build/screens/conversation_select_recipients/components/restricted_group_row.js.map +1 -1
- package/build/screens/message_report_screen.d.ts.map +1 -1
- package/build/screens/message_report_screen.js +14 -18
- package/build/screens/message_report_screen.js.map +1 -1
- package/build/screens/notification_settings_screen.d.ts.map +1 -1
- package/build/screens/notification_settings_screen.js +0 -14
- package/build/screens/notification_settings_screen.js.map +1 -1
- package/build/types/jolt_events/conversation_events.d.ts +2 -2
- package/build/types/jolt_events/conversation_events.d.ts.map +1 -1
- package/build/types/jolt_events/conversation_events.js.map +1 -1
- package/build/types/resources/conversation.d.ts +2 -2
- package/build/types/resources/conversation.d.ts.map +1 -1
- package/build/types/resources/conversation.js.map +1 -1
- package/build/utils/conversation_safety_constants.d.ts +1 -1
- package/build/utils/conversation_safety_constants.d.ts.map +1 -1
- package/build/utils/conversation_safety_constants.js +1 -1
- package/build/utils/conversation_safety_constants.js.map +1 -1
- package/build/utils/request/conversation.d.ts.map +1 -1
- package/build/utils/request/conversation.js +0 -1
- package/build/utils/request/conversation.js.map +1 -1
- package/package.json +4 -3
- package/src/components/conversation/messages_disabled_banners.tsx +11 -3
- package/src/components/display/adult_requirement_notice.tsx +1 -1
- package/src/components/display/platform_modal_header_buttons.tsx +209 -13
- package/src/components/primitive/form_sheet.tsx +2 -2
- package/src/hooks/use_conversation.ts +0 -1
- package/src/hooks/use_conversation_jolt_events.ts +3 -16
- package/src/navigation/index.tsx +138 -156
- package/src/screens/bug_report_screen.tsx +16 -15
- package/src/screens/conversation_details_screen.tsx +11 -17
- package/src/screens/conversation_filters/components/rows.tsx +2 -2
- package/src/screens/conversation_filters_screen.tsx +22 -2
- package/src/screens/conversation_screen.tsx +8 -3
- package/src/screens/conversation_select_recipients/components/groups_recipient_row.tsx +1 -1
- package/src/screens/conversation_select_recipients/components/restricted_group_row.tsx +2 -2
- package/src/screens/message_report_screen.tsx +20 -21
- package/src/screens/notification_settings_screen.tsx +1 -21
- package/src/types/jolt_events/conversation_events.ts +2 -2
- package/src/types/resources/conversation.ts +3 -2
- package/src/utils/conversation_safety_constants.ts +1 -1
- package/src/utils/request/conversation.ts +0 -1
|
@@ -1,12 +1,13 @@
|
|
|
1
|
+
import type { ConversationDisabledReason } from '../../types';
|
|
1
2
|
export declare const LeaderMessagesDisabledBanner: () => import("react/jsx-runtime").JSX.Element;
|
|
2
3
|
export declare const MemberMessagesDisabledBanner: () => import("react/jsx-runtime").JSX.Element;
|
|
3
4
|
interface ConversationDisabledBannerProps {
|
|
4
|
-
|
|
5
|
+
disabledReason?: ConversationDisabledReason;
|
|
5
6
|
messageLink?: {
|
|
6
7
|
label: string;
|
|
7
8
|
onPress: () => void;
|
|
8
9
|
};
|
|
9
10
|
}
|
|
10
|
-
export declare const ConversationDisabledBanner: ({
|
|
11
|
+
export declare const ConversationDisabledBanner: ({ disabledReason, messageLink, }: ConversationDisabledBannerProps) => import("react/jsx-runtime").JSX.Element;
|
|
11
12
|
export {};
|
|
12
13
|
//# sourceMappingURL=messages_disabled_banners.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"messages_disabled_banners.d.ts","sourceRoot":"","sources":["../../../src/components/conversation/messages_disabled_banners.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"messages_disabled_banners.d.ts","sourceRoot":"","sources":["../../../src/components/conversation/messages_disabled_banners.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,aAAa,CAAA;AAI7D,eAAO,MAAM,4BAA4B,+CAIxC,CAAA;AAED,eAAO,MAAM,4BAA4B,+CASxC,CAAA;AASD,UAAU,+BAA+B;IACvC,cAAc,CAAC,EAAE,0BAA0B,CAAA;IAC3C,WAAW,CAAC,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,IAAI,CAAA;KAAE,CAAA;CACrD;AAED,eAAO,MAAM,0BAA0B,GAAI,kCAGxC,+BAA+B,4CAYjC,CAAA"}
|
|
@@ -2,6 +2,7 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
2
2
|
import { StyleSheet, View } from 'react-native';
|
|
3
3
|
import { useSafeAreaInsets } from 'react-native-safe-area-context';
|
|
4
4
|
import { useTheme } from '../../hooks';
|
|
5
|
+
import { ADULT_REQUIREMENT_BODY } from '../../utils';
|
|
5
6
|
import { Button, Text } from '../display';
|
|
6
7
|
export const LeaderMessagesDisabledBanner = () => {
|
|
7
8
|
return (_jsx(MessagesDisabledBanner, { description: "Only leaders can send messages in this conversation." }));
|
|
@@ -10,10 +11,14 @@ export const MemberMessagesDisabledBanner = () => {
|
|
|
10
11
|
const styles = useStyles();
|
|
11
12
|
return (_jsx(MessagesDisabledBanner, { description: "Only leaders can send messages, but you can still add reactions.", style: styles.memberBanner }));
|
|
12
13
|
};
|
|
14
|
+
const DISABLED_REASON_TEXT = {
|
|
15
|
+
safety_check: ADULT_REQUIREMENT_BODY,
|
|
16
|
+
direct_messages_disabled: 'Direct messages have been turned off by someone in this conversation.',
|
|
17
|
+
};
|
|
13
18
|
const DEFAULT_DISABLED_TEXT = 'This conversation has been disabled.';
|
|
14
|
-
export const ConversationDisabledBanner = ({
|
|
19
|
+
export const ConversationDisabledBanner = ({ disabledReason, messageLink, }) => {
|
|
15
20
|
const styles = useStyles();
|
|
16
|
-
const description =
|
|
21
|
+
const description = (disabledReason && DISABLED_REASON_TEXT[disabledReason]) ?? DEFAULT_DISABLED_TEXT;
|
|
17
22
|
return (_jsx(MessagesDisabledBanner, { description: description, style: styles.memberBanner, messageLink: messageLink }));
|
|
18
23
|
};
|
|
19
24
|
const MessagesDisabledBanner = ({ description, style, messageLink, }) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"messages_disabled_banners.js","sourceRoot":"","sources":["../../../src/components/conversation/messages_disabled_banners.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAE,IAAI,EAAkB,MAAM,cAAc,CAAA;AAC/D,OAAO,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAA;AAClE,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAA;
|
|
1
|
+
{"version":3,"file":"messages_disabled_banners.js","sourceRoot":"","sources":["../../../src/components/conversation/messages_disabled_banners.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAE,IAAI,EAAkB,MAAM,cAAc,CAAA;AAC/D,OAAO,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAA;AAClE,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAA;AAEtC,OAAO,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAA;AACpD,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,YAAY,CAAA;AAEzC,MAAM,CAAC,MAAM,4BAA4B,GAAG,GAAG,EAAE;IAC/C,OAAO,CACL,KAAC,sBAAsB,IAAC,WAAW,EAAC,sDAAsD,GAAG,CAC9F,CAAA;AACH,CAAC,CAAA;AAED,MAAM,CAAC,MAAM,4BAA4B,GAAG,GAAG,EAAE;IAC/C,MAAM,MAAM,GAAG,SAAS,EAAE,CAAA;IAE1B,OAAO,CACL,KAAC,sBAAsB,IACrB,WAAW,EAAC,kEAAkE,EAC9E,KAAK,EAAE,MAAM,CAAC,YAAY,GAC1B,CACH,CAAA;AACH,CAAC,CAAA;AAED,MAAM,oBAAoB,GAA+C;IACvE,YAAY,EAAE,sBAAsB;IACpC,wBAAwB,EAAE,uEAAuE;CAClG,CAAA;AAED,MAAM,qBAAqB,GAAG,sCAAsC,CAAA;AAOpE,MAAM,CAAC,MAAM,0BAA0B,GAAG,CAAC,EACzC,cAAc,EACd,WAAW,GACqB,EAAE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AAE,QAAQ;SACpB;QACD,YAAY,EAAE;YACZ,UAAU,EAAE,EAAE;YACd,aAAa,EAAE,EAAE,GAAG,MAAM;YAC1B,YAAY,EAAE,CAAC,MAAM;SACtB;QACD,aAAa,EAAE;YACb,SAAS,EAAE,EAAE;SACd;KACF,CAAC,CAAA;AACJ,CAAC,CAAA","sourcesContent":["import { StyleSheet, View, type ViewStyle } from 'react-native'\nimport { useSafeAreaInsets } from 'react-native-safe-area-context'\nimport { useTheme } from '../../hooks'\nimport type { ConversationDisabledReason } from '../../types'\nimport { ADULT_REQUIREMENT_BODY } from '../../utils'\nimport { Button, Text } from '../display'\n\nexport const LeaderMessagesDisabledBanner = () => {\n return (\n <MessagesDisabledBanner description=\"Only leaders can send messages in this conversation.\" />\n )\n}\n\nexport const MemberMessagesDisabledBanner = () => {\n const styles = useStyles()\n\n return (\n <MessagesDisabledBanner\n description=\"Only leaders can send messages, but you can still add reactions.\"\n style={styles.memberBanner}\n />\n )\n}\n\nconst DISABLED_REASON_TEXT: Record<ConversationDisabledReason, string> = {\n safety_check: ADULT_REQUIREMENT_BODY,\n direct_messages_disabled: 'Direct messages have been turned off by someone in this conversation.',\n}\n\nconst DEFAULT_DISABLED_TEXT = 'This conversation has been disabled.'\n\ninterface ConversationDisabledBannerProps {\n disabledReason?: ConversationDisabledReason\n messageLink?: { label: string; onPress: () => void }\n}\n\nexport const ConversationDisabledBanner = ({\n disabledReason,\n messageLink,\n}: ConversationDisabledBannerProps) => {\n const styles = useStyles()\n const description =\n (disabledReason && DISABLED_REASON_TEXT[disabledReason]) ?? DEFAULT_DISABLED_TEXT\n\n return (\n <MessagesDisabledBanner\n description={description}\n style={styles.memberBanner}\n messageLink={messageLink}\n />\n )\n}\n\ninterface MessagesDisabledBannerProps {\n description: string\n style?: ViewStyle\n messageLink?: { label: string; onPress: () => void }\n}\n\nconst MessagesDisabledBanner = ({\n description,\n style,\n messageLink,\n}: MessagesDisabledBannerProps) => {\n const styles = useStyles()\n\n return (\n <View style={[styles.baseBanner, style]}>\n <Text style={styles.text} variant=\"tertiary\">\n {description}\n </Text>\n {messageLink && (\n <Button\n variant=\"fill\"\n size=\"lg\"\n title={messageLink.label}\n onPress={messageLink.onPress}\n style={styles.messageButton}\n />\n )}\n </View>\n )\n}\n\nconst useStyles = () => {\n const { colors } = useTheme()\n const { bottom } = useSafeAreaInsets()\n\n return StyleSheet.create({\n baseBanner: {\n paddingHorizontal: 16,\n paddingVertical: 4,\n backgroundColor: colors.statusNeutralComposedBackground,\n borderTopWidth: 1,\n borderTopColor: colors.borderColorDefaultBase,\n },\n text: {\n textAlign: 'center',\n },\n memberBanner: {\n paddingTop: 16,\n paddingBottom: 16 + bottom,\n marginBottom: -bottom,\n },\n messageButton: {\n marginTop: 12,\n },\n })\n}\n"]}
|
|
@@ -3,6 +3,6 @@ import { ADULT_REQUIREMENT_BODY } from '../../utils';
|
|
|
3
3
|
import BannerPrimitive from '../primitive/banner_primitive';
|
|
4
4
|
import { BannerCollapsible } from './banner_collapsible';
|
|
5
5
|
export function AdultRequirementNotice({ style }) {
|
|
6
|
-
return (_jsx(BannerCollapsible, { appearance: "warning", iconName: "general.shieldExclamation", heading: "
|
|
6
|
+
return (_jsx(BannerCollapsible, { appearance: "warning", iconName: "general.shieldExclamation", heading: "2 adults required to chat", style: style, children: _jsx(BannerPrimitive.Text, { children: ADULT_REQUIREMENT_BODY }) }));
|
|
7
7
|
}
|
|
8
8
|
//# sourceMappingURL=adult_requirement_notice.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"adult_requirement_notice.js","sourceRoot":"","sources":["../../../src/components/display/adult_requirement_notice.tsx"],"names":[],"mappings":";AAEA,OAAO,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAA;AACpD,OAAO,eAAe,MAAM,+BAA+B,CAAA;AAC3D,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAA;AAMxD,MAAM,UAAU,sBAAsB,CAAC,EAAE,KAAK,EAA+B;IAC3E,OAAO,CACL,KAAC,iBAAiB,IAChB,UAAU,EAAC,SAAS,EACpB,QAAQ,EAAC,2BAA2B,EACpC,OAAO,EAAC,
|
|
1
|
+
{"version":3,"file":"adult_requirement_notice.js","sourceRoot":"","sources":["../../../src/components/display/adult_requirement_notice.tsx"],"names":[],"mappings":";AAEA,OAAO,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAA;AACpD,OAAO,eAAe,MAAM,+BAA+B,CAAA;AAC3D,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAA;AAMxD,MAAM,UAAU,sBAAsB,CAAC,EAAE,KAAK,EAA+B;IAC3E,OAAO,CACL,KAAC,iBAAiB,IAChB,UAAU,EAAC,SAAS,EACpB,QAAQ,EAAC,2BAA2B,EACpC,OAAO,EAAC,2BAA2B,EACnC,KAAK,EAAE,KAAK,YAEZ,KAAC,eAAe,CAAC,IAAI,cAAE,sBAAsB,GAAwB,GACnD,CACrB,CAAA;AACH,CAAC","sourcesContent":["import React from 'react'\nimport type { ViewStyle } from 'react-native'\nimport { ADULT_REQUIREMENT_BODY } from '../../utils'\nimport BannerPrimitive from '../primitive/banner_primitive'\nimport { BannerCollapsible } from './banner_collapsible'\n\ninterface AdultRequirementNoticeProps {\n style?: ViewStyle\n}\n\nexport function AdultRequirementNotice({ style }: AdultRequirementNoticeProps) {\n return (\n <BannerCollapsible\n appearance=\"warning\"\n iconName=\"general.shieldExclamation\"\n heading=\"2 adults required to chat\"\n style={style}\n >\n <BannerPrimitive.Text>{ADULT_REQUIREMENT_BODY}</BannerPrimitive.Text>\n </BannerCollapsible>\n )\n}\n"]}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { NativeStackNavigationOptions } from '@react-navigation/native-stack';
|
|
2
2
|
import { ColorValue } from 'react-native';
|
|
3
|
+
import { type IconString } from './icon';
|
|
3
4
|
interface HeaderTextButtonProps {
|
|
4
5
|
onPress: () => void;
|
|
5
6
|
title?: string;
|
|
@@ -12,12 +13,49 @@ interface HeaderDismissButtonProps {
|
|
|
12
13
|
tintColor?: ColorValue;
|
|
13
14
|
}
|
|
14
15
|
export declare const HeaderDismissButton: ({ onPress, title, tintColor, ...props }: HeaderDismissButtonProps) => import("react/jsx-runtime").JSX.Element;
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
16
|
+
export type OptionsDecorator = (options: NativeStackNavigationOptions) => NativeStackNavigationOptions;
|
|
17
|
+
export declare const composeOptions: (base: NativeStackNavigationOptions, ...decorators: OptionsDecorator[]) => NativeStackNavigationOptions;
|
|
18
|
+
interface TextButtonDecoratorProps {
|
|
19
|
+
text: string;
|
|
20
|
+
onPress: () => void;
|
|
21
|
+
disabled?: boolean;
|
|
22
|
+
}
|
|
23
|
+
export declare const withRightText: ({ text, onPress, disabled }: TextButtonDecoratorProps) => OptionsDecorator;
|
|
24
|
+
export declare const useHeaderSlotReserve: () => number;
|
|
25
|
+
export interface HeaderIconProps {
|
|
26
|
+
icon: IconString;
|
|
27
|
+
accessibilityLabel: string;
|
|
28
|
+
onPress: () => void;
|
|
29
|
+
disabled?: boolean;
|
|
30
|
+
prominent?: boolean;
|
|
31
|
+
tintColor?: ColorValue;
|
|
20
32
|
}
|
|
21
|
-
export declare const
|
|
33
|
+
export declare const withRightIcon: (props: HeaderIconProps) => OptionsDecorator;
|
|
34
|
+
export declare const withLeftIcon: (props: HeaderIconProps) => OptionsDecorator;
|
|
35
|
+
export declare const withRightClose: ({ onPress }: {
|
|
36
|
+
onPress: () => void;
|
|
37
|
+
}) => OptionsDecorator;
|
|
38
|
+
export declare const withLeftClose: ({ onPress }: {
|
|
39
|
+
onPress: () => void;
|
|
40
|
+
}) => OptionsDecorator;
|
|
41
|
+
export declare const withRightDone: ({ onPress }: {
|
|
42
|
+
onPress: () => void;
|
|
43
|
+
}) => OptionsDecorator;
|
|
44
|
+
export declare const withMinimalBack: ({ onPress }: {
|
|
45
|
+
onPress: () => void;
|
|
46
|
+
}) => OptionsDecorator;
|
|
47
|
+
type UseHeaderRightOptions = {
|
|
48
|
+
onPress: () => void;
|
|
49
|
+
disabled?: boolean;
|
|
50
|
+
enabled?: boolean;
|
|
51
|
+
} & ((Omit<HeaderIconProps, 'tintColor'> & {
|
|
52
|
+
title?: never;
|
|
53
|
+
}) | {
|
|
54
|
+
title: string;
|
|
55
|
+
icon?: never;
|
|
56
|
+
accessibilityLabel?: never;
|
|
57
|
+
prominent?: never;
|
|
58
|
+
});
|
|
59
|
+
export declare const useHeaderRight: (options: UseHeaderRightOptions) => void;
|
|
22
60
|
export {};
|
|
23
61
|
//# sourceMappingURL=platform_modal_header_buttons.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"platform_modal_header_buttons.d.ts","sourceRoot":"","sources":["../../../src/components/display/platform_modal_header_buttons.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"platform_modal_header_buttons.d.ts","sourceRoot":"","sources":["../../../src/components/display/platform_modal_header_buttons.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAEV,4BAA4B,EAC7B,MAAM,gCAAgC,CAAA;AAEvC,OAAO,EAAE,UAAU,EAAwB,MAAM,cAAc,CAAA;AAI/D,OAAO,EAAQ,KAAK,UAAU,EAAE,MAAM,QAAQ,CAAA;AAG9C,UAAU,qBAAqB;IAC7B,OAAO,EAAE,MAAM,IAAI,CAAA;IACnB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,QAAQ,CAAC,EAAE,OAAO,CAAA;CACnB;AAED,eAAO,MAAM,gBAAgB,GAAI,8BAI9B,qBAAqB,4CAavB,CAAA;AAED,UAAU,wBAAwB;IAChC,OAAO,EAAE,MAAM,IAAI,CAAA;IACnB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,SAAS,CAAC,EAAE,UAAU,CAAA;CACvB;AAED,eAAO,MAAM,mBAAmB,GAAI,yCAKjC,wBAAwB,4CAoB1B,CAAA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A;IACnB,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,OAAO,CAAC,EAAE,OAAO,CAAA;CAClB,GAAG,CACA,CAAC,IAAI,CAAC,eAAe,EAAE,WAAW,CAAC,GAAG;IAAE,KAAK,CAAC,EAAE,KAAK,CAAA;CAAE,CAAC,GACxD;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,IAAI,CAAC,EAAE,KAAK,CAAC;IAAC,kBAAkB,CAAC,EAAE,KAAK,CAAC;IAAC,SAAS,CAAC,EAAE,KAAK,CAAA;CAAE,CACjF,CAAA;AAED,eAAO,MAAM,cAAc,GAAI,SAAS,qBAAqB,SA2B5D,CAAA"}
|
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { HeaderButton } from '@react-navigation/elements';
|
|
2
|
+
import { HeaderBackButton, HeaderButton, PlatformPressable } from '@react-navigation/elements';
|
|
3
|
+
import { useNavigation } from '@react-navigation/native';
|
|
4
|
+
import { useLayoutEffect } from 'react';
|
|
3
5
|
import { Platform, StyleSheet } from 'react-native';
|
|
4
|
-
import { useTheme } from '../../hooks';
|
|
6
|
+
import { useFontScale, useTheme } from '../../hooks';
|
|
7
|
+
import { MAX_FONT_SIZE_MULTIPLIER_LANDMARK } from '../../utils';
|
|
5
8
|
import { Icon } from './icon';
|
|
6
9
|
import { TextButton } from './text_button';
|
|
7
10
|
export const HeaderTextButton = ({ onPress, title = 'Submit', ...props }) => {
|
|
@@ -15,13 +18,109 @@ export const HeaderDismissButton = ({ onPress, title = 'Cancel', tintColor, ...p
|
|
|
15
18
|
default: (_jsx(HeaderButton, { onPress: onPress, style: [styles.androidCancelButton], ...props, children: _jsx(Icon, { name: "general.x", size: 16, color: tintColor }) })),
|
|
16
19
|
});
|
|
17
20
|
};
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
}
|
|
24
|
-
|
|
21
|
+
const createTextHeaderRight = ({ onPress, title, disabled }) => (props) => (_jsx(HeaderTextButton, { ...props, onPress: onPress, title: title, disabled: disabled }));
|
|
22
|
+
export const composeOptions = (base, ...decorators) => decorators.reduce((options, decorate) => decorate(options), base);
|
|
23
|
+
export const withRightText = ({ text, onPress, disabled }) => options => ({
|
|
24
|
+
...options,
|
|
25
|
+
headerRight: createTextHeaderRight({ onPress, title: text, disabled }),
|
|
26
|
+
unstable_headerRightItems: () => [{ type: 'button', label: text, onPress, disabled }],
|
|
27
|
+
});
|
|
28
|
+
const HEADER_ICON_SIZE = 17;
|
|
29
|
+
const HEADER_GLASS_BUTTON_SIZE = 44;
|
|
30
|
+
const HEADER_BAR_INSET = 16;
|
|
31
|
+
const HEADER_SLOT_GAP = 12;
|
|
32
|
+
export const useHeaderSlotReserve = () => {
|
|
33
|
+
const fontScale = useFontScale({ maxFontSizeMultiplier: MAX_FONT_SIZE_MULTIPLIER_LANDMARK });
|
|
34
|
+
return HEADER_BAR_INSET + HEADER_GLASS_BUTTON_SIZE * fontScale + HEADER_SLOT_GAP;
|
|
35
|
+
};
|
|
36
|
+
const HEADER_FALLBACK_HIT_SLOP = 14;
|
|
37
|
+
const iconStyles = StyleSheet.create({
|
|
38
|
+
disabled: {
|
|
39
|
+
opacity: 0.4,
|
|
40
|
+
},
|
|
41
|
+
fallbackButton: {
|
|
42
|
+
alignItems: 'center',
|
|
43
|
+
justifyContent: 'center',
|
|
44
|
+
paddingHorizontal: 8,
|
|
45
|
+
},
|
|
46
|
+
fallbackButtonLeft: {
|
|
47
|
+
marginRight: Platform.select({ android: 16, default: 0 }),
|
|
48
|
+
},
|
|
49
|
+
});
|
|
50
|
+
const SF_SYMBOL_NAMES = {
|
|
51
|
+
'general.x': 'xmark',
|
|
52
|
+
'general.check': 'checkmark',
|
|
53
|
+
'general.upArrow': 'arrow.up',
|
|
54
|
+
'general.leftChevron': 'chevron.left',
|
|
55
|
+
};
|
|
56
|
+
const sfSymbolFor = (icon) => {
|
|
57
|
+
const name = SF_SYMBOL_NAMES[icon];
|
|
58
|
+
if (!name)
|
|
59
|
+
throw new Error(`No SF Symbol mapped for icon "${icon}" — add one to SF_SYMBOL_NAMES.`);
|
|
60
|
+
return name;
|
|
61
|
+
};
|
|
62
|
+
const createHeaderIconItem = ({ icon, accessibilityLabel, onPress, disabled, prominent, tintColor, }) => ({
|
|
63
|
+
type: 'button',
|
|
64
|
+
label: '',
|
|
65
|
+
accessibilityLabel,
|
|
66
|
+
onPress,
|
|
67
|
+
disabled,
|
|
68
|
+
icon: { type: 'sfSymbol', name: sfSymbolFor(icon) },
|
|
69
|
+
...(prominent ? { variant: 'prominent', tintColor } : {}),
|
|
70
|
+
});
|
|
71
|
+
const createHeaderIconElement = (position) => ({ icon, accessibilityLabel, onPress, disabled, tintColor }) => () => (_jsx(PlatformPressable, { onPress: onPress, disabled: disabled, hitSlop: HEADER_FALLBACK_HIT_SLOP, accessibilityRole: "button", accessibilityLabel: accessibilityLabel, style: [
|
|
72
|
+
iconStyles.fallbackButton,
|
|
73
|
+
position === 'left' && iconStyles.fallbackButtonLeft,
|
|
74
|
+
disabled && iconStyles.disabled,
|
|
75
|
+
], children: _jsx(Icon, { name: icon, size: HEADER_ICON_SIZE, color: tintColor }) }));
|
|
76
|
+
export const withRightIcon = (props) => options => ({
|
|
77
|
+
...options,
|
|
78
|
+
headerRight: createHeaderIconElement('right')(props),
|
|
79
|
+
unstable_headerRightItems: () => [createHeaderIconItem(props)],
|
|
80
|
+
});
|
|
81
|
+
export const withLeftIcon = (props) => options => ({
|
|
82
|
+
...options,
|
|
83
|
+
headerLeft: createHeaderIconElement('left')(props),
|
|
84
|
+
unstable_headerLeftItems: () => [createHeaderIconItem(props)],
|
|
85
|
+
});
|
|
86
|
+
export const withRightClose = ({ onPress }) => withRightIcon({ icon: 'general.x', accessibilityLabel: 'Close', onPress });
|
|
87
|
+
export const withLeftClose = ({ onPress }) => withLeftIcon({ icon: 'general.x', accessibilityLabel: 'Close', onPress });
|
|
88
|
+
export const withRightDone = ({ onPress }) => withRightIcon({ icon: 'general.check', accessibilityLabel: 'Done', onPress });
|
|
89
|
+
const createMinimalHeaderBackElement = ({ onPress }) => (props) => (_jsx(HeaderBackButton, { style: Platform.select({
|
|
90
|
+
ios: { marginLeft: -8 },
|
|
91
|
+
default: { marginLeft: -3, marginRight: 30 },
|
|
92
|
+
}), displayMode: "minimal", onPress: onPress, ...props }));
|
|
93
|
+
export const withMinimalBack = ({ onPress }) => options => ({
|
|
94
|
+
...options,
|
|
95
|
+
headerLeft: createMinimalHeaderBackElement({ onPress }),
|
|
96
|
+
unstable_headerLeftItems: () => [
|
|
97
|
+
createHeaderIconItem({ icon: 'general.leftChevron', accessibilityLabel: 'Back', onPress }),
|
|
98
|
+
],
|
|
99
|
+
});
|
|
100
|
+
export const useHeaderRight = (options) => {
|
|
101
|
+
const navigation = useNavigation();
|
|
102
|
+
const { colors } = useTheme();
|
|
103
|
+
const { onPress, disabled, enabled = true } = options;
|
|
104
|
+
const icon = options.icon;
|
|
105
|
+
const label = options.icon !== undefined ? options.accessibilityLabel : options.title;
|
|
106
|
+
const prominent = options.icon !== undefined ? options.prominent : undefined;
|
|
107
|
+
useLayoutEffect(() => {
|
|
108
|
+
if (!enabled) {
|
|
109
|
+
navigation.setOptions({ headerRight: () => null, unstable_headerRightItems: undefined });
|
|
110
|
+
return;
|
|
111
|
+
}
|
|
112
|
+
const decorate = icon
|
|
113
|
+
? withRightIcon({
|
|
114
|
+
icon,
|
|
115
|
+
accessibilityLabel: label,
|
|
116
|
+
onPress,
|
|
117
|
+
disabled,
|
|
118
|
+
prominent,
|
|
119
|
+
tintColor: prominent ? colors.interaction : undefined,
|
|
120
|
+
})
|
|
121
|
+
: withRightText({ text: label, onPress, disabled });
|
|
122
|
+
navigation.setOptions(decorate({}));
|
|
123
|
+
}, [colors.interaction, disabled, enabled, icon, label, navigation, onPress, prominent]);
|
|
25
124
|
};
|
|
26
125
|
const useStyles = () => {
|
|
27
126
|
const { colors } = useTheme();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"platform_modal_header_buttons.js","sourceRoot":"","sources":["../../../src/components/display/platform_modal_header_buttons.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAA;AAEzD,OAAO,EAAc,QAAQ,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AAC/D,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAA;AACtC,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAA;AAC7B,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAA;AAQ1C,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,EAC/B,OAAO,EACP,KAAK,GAAG,QAAQ,EAChB,GAAG,KAAK,EACc,EAAE,EAAE;IAC1B,MAAM,MAAM,GAAG,SAAS,EAAE,CAAA;IAE1B,OAAO,CACL,KAAC,UAAU,IACT,qBAAqB,EAAE,CAAC,EACxB,OAAO,EAAE,OAAO,EAChB,SAAS,EAAE,CAAC,MAAM,CAAC,gBAAgB,EAAE,KAAK,CAAC,QAAQ,IAAI,MAAM,CAAC,aAAa,CAAC,KACxE,KAAK,YAER,KAAK,GACK,CACd,CAAA;AACH,CAAC,CAAA;AAQD,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,EAClC,OAAO,EACP,KAAK,GAAG,QAAQ,EAChB,SAAS,EACT,GAAG,KAAK,EACiB,EAAE,EAAE;IAC7B,MAAM,MAAM,GAAG,SAAS,EAAE,CAAA;IAE1B,OAAO,QAAQ,CAAC,MAAM,CAAC;QACrB,GAAG,EAAE,CACH,KAAC,UAAU,IACT,qBAAqB,EAAE,CAAC,EACxB,OAAO,EAAE,OAAO,EAChB,SAAS,EAAE,CAAC,MAAM,CAAC,gBAAgB,EAAE,MAAM,CAAC,eAAe,CAAC,KACxD,KAAK,YAER,KAAK,GACK,CACd;QACD,OAAO,EAAE,CACP,KAAC,YAAY,IAAC,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC,MAAM,CAAC,mBAAmB,CAAC,KAAM,KAAK,YAC5E,KAAC,IAAI,IAAC,IAAI,EAAC,WAAW,EAAC,IAAI,EAAE,EAAE,EAAE,KAAK,EAAE,SAAS,GAAI,GACxC,CAChB;KACF,CAAC,CAAA;AACJ,CAAC,CAAA;AAMD,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,EAAE,UAAU,EAAE,GAAG,KAAK,EAAyB,EAAE,EAAE;IAClF,MAAM,KAAK,GAAG,UAAU,CAAC,QAAQ,EAAE,CAAA;IACnC,MAAM,aAAa,GAAG,KAAK,CAAC,KAAK,KAAK,CAAC,CAAA;IAEvC,IAAI,CAAC,aAAa,EAAE,CAAC;QACnB,OAAO,IAAI,CAAA;IACb,CAAC;IAED,OAAO,KAAC,gBAAgB,OAAK,KAAK,EAAE,OAAO,EAAE,UAAU,CAAC,MAAM,EAAE,KAAK,EAAC,MAAM,GAAG,CAAA;AACjF,CAAC,CAAA;AAED,MAAM,SAAS,GAAG,GAAG,EAAE;IACrB,MAAM,EAAE,MAAM,EAAE,GAAG,QAAQ,EAAE,CAAA;IAE7B,OAAO,UAAU,CAAC,MAAM,CAAC;QACvB,gBAAgB,EAAE;YAChB,KAAK,EAAE,QAAQ,CAAC,MAAM,CAAC;gBACrB,GAAG,EAAE,MAAM,CAAC,6BAA6B;gBACzC,OAAO,EAAE,MAAM,CAAC,iCAAiC;aAClD,CAAC;SACH;QACD,mBAAmB,EAAE;YACnB,WAAW,EAAE,EAAE;SAChB;QACD,eAAe,EAAE;YACf,UAAU,EAAE,QAAQ;SACrB;QACD,aAAa,EAAE;YACb,KAAK,EAAE,MAAM,CAAC,wBAAwB;SACvC;KACF,CAAC,CAAA;AACJ,CAAC,CAAA","sourcesContent":["import { HeaderButton } from '@react-navigation/elements'\nimport type { NativeStackHeaderRightProps } from '@react-navigation/native-stack'\nimport { ColorValue, Platform, StyleSheet } from 'react-native'\nimport { useTheme } from '../../hooks'\nimport { Icon } from './icon'\nimport { TextButton } from './text_button'\n\ninterface HeaderTextButtonProps {\n onPress: () => void\n title?: string\n disabled?: boolean\n}\n\nexport const HeaderTextButton = ({\n onPress,\n title = 'Submit',\n ...props\n}: HeaderTextButtonProps) => {\n const styles = useStyles()\n\n return (\n <TextButton\n maxFontSizeMultiplier={1}\n onPress={onPress}\n textStyle={[styles.interactionColor, props.disabled && styles.disabledColor]}\n {...props}\n >\n {title}\n </TextButton>\n )\n}\n\ninterface HeaderDismissButtonProps {\n onPress: () => void\n title?: string\n tintColor?: ColorValue\n}\n\nexport const HeaderDismissButton = ({\n onPress,\n title = 'Cancel',\n tintColor,\n ...props\n}: HeaderDismissButtonProps) => {\n const styles = useStyles()\n\n return Platform.select({\n ios: (\n <TextButton\n maxFontSizeMultiplier={1}\n onPress={onPress}\n textStyle={[styles.interactionColor, styles.iosCancelButton]}\n {...props}\n >\n {title}\n </TextButton>\n ),\n default: (\n <HeaderButton onPress={onPress} style={[styles.androidCancelButton]} {...props}>\n <Icon name=\"general.x\" size={16} color={tintColor} />\n </HeaderButton>\n ),\n })\n}\n\ninterface HeaderDoneButtonProps extends NativeStackHeaderRightProps {\n navigation: { goBack: () => void; getState: () => any }\n}\n\nexport const HeaderDoneButton = ({ navigation, ...props }: HeaderDoneButtonProps) => {\n const state = navigation.getState()\n const isFirstScreen = state.index === 0\n\n if (!isFirstScreen) {\n return null\n }\n\n return <HeaderTextButton {...props} onPress={navigation.goBack} title=\"Done\" />\n}\n\nconst useStyles = () => {\n const { colors } = useTheme()\n\n return StyleSheet.create({\n interactionColor: {\n color: Platform.select({\n ios: colors.iOSModalHeaderButtonTextColor,\n android: colors.androidModalHeaderButtonTextColor,\n }),\n },\n androidCancelButton: {\n marginRight: 16,\n },\n iosCancelButton: {\n fontWeight: 'normal',\n },\n disabledColor: {\n color: colors.textColorDefaultDisabled,\n },\n })\n}\n"]}
|
|
1
|
+
{"version":3,"file":"platform_modal_header_buttons.js","sourceR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C,aAAa,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,CAAC,CAAA;QAErD,UAAU,CAAC,UAAU,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,CAAA;IACrC,CAAC,EAAE,CAAC,MAAM,CAAC,WAAW,EAAE,QAAQ,EAAE,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,UAAU,EAAE,OAAO,EAAE,SAAS,CAAC,CAAC,CAAA;AAC1F,CAAC,CAAA;AAED,MAAM,SAAS,GAAG,GAAG,EAAE;IACrB,MAAM,EAAE,MAAM,EAAE,GAAG,QAAQ,EAAE,CAAA;IAE7B,OAAO,UAAU,CAAC,MAAM,CAAC;QACvB,gBAAgB,EAAE;YAChB,KAAK,EAAE,QAAQ,CAAC,MAAM,CAAC;gBACrB,GAAG,EAAE,MAAM,CAAC,6BAA6B;gBACzC,OAAO,EAAE,MAAM,CAAC,iCAAiC;aAClD,CAAC;SACH;QACD,mBAAmB,EAAE;YACnB,WAAW,EAAE,EAAE;SAChB;QACD,eAAe,EAAE;YACf,UAAU,EAAE,QAAQ;SACrB;QACD,aAAa,EAAE;YACb,KAAK,EAAE,MAAM,CAAC,wBAAwB;SACvC;KACF,CAAC,CAAA;AACJ,CAAC,CAAA","sourcesContent":["import { HeaderBackButton, HeaderButton, PlatformPressable } from '@react-navigation/elements'\nimport { useNavigation } from '@react-navigation/native'\nimport type {\n NativeStackHeaderItemProps,\n NativeStackNavigationOptions,\n} from '@react-navigation/native-stack'\nimport { useLayoutEffect } from 'react'\nimport { ColorValue, Platform, StyleSheet } from 'react-native'\nimport type { SFSymbol } from 'sf-symbols-typescript'\nimport { useFontScale, useTheme } from '../../hooks'\nimport { MAX_FONT_SIZE_MULTIPLIER_LANDMARK } from '../../utils'\nimport { Icon, type IconString } from './icon'\nimport { TextButton } from './text_button'\n\ninterface HeaderTextButtonProps {\n onPress: () => void\n title?: string\n disabled?: boolean\n}\n\nexport const HeaderTextButton = ({\n onPress,\n title = 'Submit',\n ...props\n}: HeaderTextButtonProps) => {\n const styles = useStyles()\n\n return (\n <TextButton\n maxFontSizeMultiplier={1}\n onPress={onPress}\n textStyle={[styles.interactionColor, props.disabled && styles.disabledColor]}\n {...props}\n >\n {title}\n </TextButton>\n )\n}\n\ninterface HeaderDismissButtonProps {\n onPress: () => void\n title?: string\n tintColor?: ColorValue\n}\n\nexport const HeaderDismissButton = ({\n onPress,\n title = 'Cancel',\n tintColor,\n ...props\n}: HeaderDismissButtonProps) => {\n const styles = useStyles()\n\n return Platform.select({\n ios: (\n <TextButton\n maxFontSizeMultiplier={1}\n onPress={onPress}\n textStyle={[styles.interactionColor, styles.iosCancelButton]}\n {...props}\n >\n {title}\n </TextButton>\n ),\n default: (\n <HeaderButton onPress={onPress} style={[styles.androidCancelButton]} {...props}>\n <Icon name=\"general.x\" size={16} color={tintColor} />\n </HeaderButton>\n ),\n })\n}\n\nconst createTextHeaderRight =\n ({ onPress, title, disabled }: HeaderTextButtonProps) =>\n (props: NativeStackHeaderItemProps) => (\n <HeaderTextButton {...props} onPress={onPress} title={title} disabled={disabled} />\n )\n\nexport type OptionsDecorator = (\n options: NativeStackNavigationOptions\n) => NativeStackNavigationOptions\n\nexport const composeOptions = (\n base: NativeStackNavigationOptions,\n ...decorators: OptionsDecorator[]\n): NativeStackNavigationOptions => decorators.reduce((options, decorate) => decorate(options), base)\n\ninterface TextButtonDecoratorProps {\n text: string\n onPress: () => void\n disabled?: boolean\n}\n\nexport const withRightText =\n ({ text, onPress, disabled }: TextButtonDecoratorProps): OptionsDecorator =>\n options => ({\n ...options,\n headerRight: createTextHeaderRight({ onPress, title: text, disabled }),\n unstable_headerRightItems: () => [{ type: 'button' as const, label: text, onPress, disabled }],\n })\n\nconst HEADER_ICON_SIZE = 17\nconst HEADER_GLASS_BUTTON_SIZE = 44\nconst HEADER_BAR_INSET = 16\nconst HEADER_SLOT_GAP = 12\n\nexport const useHeaderSlotReserve = (): number => {\n const fontScale = useFontScale({ maxFontSizeMultiplier: MAX_FONT_SIZE_MULTIPLIER_LANDMARK })\n\n return HEADER_BAR_INSET + HEADER_GLASS_BUTTON_SIZE * fontScale + HEADER_SLOT_GAP\n}\n\nconst HEADER_FALLBACK_HIT_SLOP = 14\n\nconst iconStyles = StyleSheet.create({\n disabled: {\n opacity: 0.4,\n },\n fallbackButton: {\n alignItems: 'center',\n justifyContent: 'center',\n paddingHorizontal: 8,\n },\n fallbackButtonLeft: {\n marginRight: Platform.select({ android: 16, default: 0 }),\n },\n})\n\nconst SF_SYMBOL_NAMES: Partial<Record<IconString, SFSymbol>> = {\n 'general.x': 'xmark',\n 'general.check': 'checkmark',\n 'general.upArrow': 'arrow.up',\n 'general.leftChevron': 'chevron.left',\n}\n\nconst sfSymbolFor = (icon: IconString): SFSymbol => {\n const name = SF_SYMBOL_NAMES[icon]\n\n if (!name) throw new Error(`No SF Symbol mapped for icon \"${icon}\" — add one to SF_SYMBOL_NAMES.`)\n\n return name\n}\n\nexport interface HeaderIconProps {\n icon: IconString\n accessibilityLabel: string\n onPress: () => void\n disabled?: boolean\n prominent?: boolean\n tintColor?: ColorValue\n}\n\nconst createHeaderIconItem = ({\n icon,\n accessibilityLabel,\n onPress,\n disabled,\n prominent,\n tintColor,\n}: HeaderIconProps) => ({\n type: 'button' as const,\n label: '',\n accessibilityLabel,\n onPress,\n disabled,\n icon: { type: 'sfSymbol' as const, name: sfSymbolFor(icon) },\n ...(prominent ? { variant: 'prominent' as const, tintColor } : {}),\n})\n\nconst createHeaderIconElement =\n (position: 'left' | 'right') =>\n ({ icon, accessibilityLabel, onPress, disabled, tintColor }: HeaderIconProps) =>\n () => (\n <PlatformPressable\n onPress={onPress}\n disabled={disabled}\n hitSlop={HEADER_FALLBACK_HIT_SLOP}\n accessibilityRole=\"button\"\n accessibilityLabel={accessibilityLabel}\n style={[\n iconStyles.fallbackButton,\n position === 'left' && iconStyles.fallbackButtonLeft,\n disabled && iconStyles.disabled,\n ]}\n >\n <Icon name={icon} size={HEADER_ICON_SIZE} color={tintColor} />\n </PlatformPressable>\n )\n\nexport const withRightIcon =\n (props: HeaderIconProps): OptionsDecorator =>\n options => ({\n ...options,\n headerRight: createHeaderIconElement('right')(props),\n unstable_headerRightItems: () => [createHeaderIconItem(props)],\n })\n\nexport const withLeftIcon =\n (props: HeaderIconProps): OptionsDecorator =>\n options => ({\n ...options,\n headerLeft: createHeaderIconElement('left')(props),\n unstable_headerLeftItems: () => [createHeaderIconItem(props)],\n })\n\nexport const withRightClose = ({ onPress }: { onPress: () => void }) =>\n withRightIcon({ icon: 'general.x', accessibilityLabel: 'Close', onPress })\n\nexport const withLeftClose = ({ onPress }: { onPress: () => void }) =>\n withLeftIcon({ icon: 'general.x', accessibilityLabel: 'Close', onPress })\n\nexport const withRightDone = ({ onPress }: { onPress: () => void }) =>\n withRightIcon({ icon: 'general.check', accessibilityLabel: 'Done', onPress })\n\nconst createMinimalHeaderBackElement =\n ({ onPress }: { onPress: () => void }) =>\n (props: NativeStackHeaderItemProps) => (\n <HeaderBackButton\n style={Platform.select({\n ios: { marginLeft: -8 },\n default: { marginLeft: -3, marginRight: 30 },\n })}\n displayMode=\"minimal\"\n onPress={onPress}\n {...props}\n />\n )\n\nexport const withMinimalBack =\n ({ onPress }: { onPress: () => void }): OptionsDecorator =>\n options => ({\n ...options,\n headerLeft: createMinimalHeaderBackElement({ onPress }),\n unstable_headerLeftItems: () => [\n createHeaderIconItem({ icon: 'general.leftChevron', accessibilityLabel: 'Back', onPress }),\n ],\n })\n\ntype UseHeaderRightOptions = {\n onPress: () => void\n disabled?: boolean\n enabled?: boolean\n} & (\n | (Omit<HeaderIconProps, 'tintColor'> & { title?: never })\n | { title: string; icon?: never; accessibilityLabel?: never; prominent?: never }\n)\n\nexport const useHeaderRight = (options: UseHeaderRightOptions) => {\n const navigation = useNavigation()\n const { colors } = useTheme()\n const { onPress, disabled, enabled = true } = options\n const icon = options.icon\n const label = options.icon !== undefined ? options.accessibilityLabel : options.title\n const prominent = options.icon !== undefined ? options.prominent : undefined\n\n useLayoutEffect(() => {\n if (!enabled) {\n navigation.setOptions({ headerRight: () => null, unstable_headerRightItems: undefined })\n return\n }\n\n const decorate = icon\n ? withRightIcon({\n icon,\n accessibilityLabel: label,\n onPress,\n disabled,\n prominent,\n tintColor: prominent ? colors.interaction : undefined,\n })\n : withRightText({ text: label, onPress, disabled })\n\n navigation.setOptions(decorate({}))\n }, [colors.interaction, disabled, enabled, icon, label, navigation, onPress, prominent])\n}\n\nconst useStyles = () => {\n const { colors } = useTheme()\n\n return StyleSheet.create({\n interactionColor: {\n color: Platform.select({\n ios: colors.iOSModalHeaderButtonTextColor,\n android: colors.androidModalHeaderButtonTextColor,\n }),\n },\n androidCancelButton: {\n marginRight: 16,\n },\n iosCancelButton: {\n fontWeight: 'normal',\n },\n disabledColor: {\n color: colors.textColorDefaultDisabled,\n },\n })\n}\n"]}
|
|
@@ -3,7 +3,7 @@ import { PlatformPressable, useHeaderHeight } from '@react-navigation/elements';
|
|
|
3
3
|
import { Platform, StyleSheet, View, useWindowDimensions, } from 'react-native';
|
|
4
4
|
import { useSafeAreaInsets } from 'react-native-safe-area-context';
|
|
5
5
|
import { useTheme } from '../../hooks';
|
|
6
|
-
import { MAX_FONT_SIZE_MULTIPLIER_LANDMARK } from '../../utils';
|
|
6
|
+
import { isLiquidGlassEnabled, MAX_FONT_SIZE_MULTIPLIER_LANDMARK } from '../../utils';
|
|
7
7
|
import { Button, Heading, Icon, Text, TextButton } from '../display';
|
|
8
8
|
// =================================
|
|
9
9
|
// ====== Exports ==================
|
|
@@ -19,7 +19,7 @@ export const getFormSheetScreenOptions = ({ headerTitle, sheetAllowedDetents = [
|
|
|
19
19
|
presentation: 'formSheet',
|
|
20
20
|
headerShown: false,
|
|
21
21
|
sheetAllowedDetents,
|
|
22
|
-
sheetCornerRadius: 16,
|
|
22
|
+
sheetCornerRadius: isLiquidGlassEnabled() ? undefined : 16,
|
|
23
23
|
sheetGrabberVisible: true,
|
|
24
24
|
headerTitle,
|
|
25
25
|
...rest,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"form_sheet.js","sourceRoot":"","sources":["../../../src/components/primitive/form_sheet.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,iBAAiB,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAA;AAG/E,OAAO,EACL,QAAQ,EACR,UAAU,EACV,IAAI,EACJ,mBAAmB,GAIpB,MAAM,cAAc,CAAA;AACrB,OAAO,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAA;AAClE,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAA;AACtC,OAAO,EAAE,iCAAiC,EAAE,MAAM,aAAa,CAAA;AAE/D,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAc,IAAI,EAAE,UAAU,EAAE,MAAM,YAAY,CAAA;AAEhF,oCAAoC;AACpC,oCAAoC;AACpC,oCAAoC;AAEpC;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,yBAAyB,GAAG,CAAC,EACxC,WAAW,EACX,mBAAmB,GAAG,CAAC,IAAI,CAAC,EAC5B,GAAG,IAAI,KACyB,EAAE,EAAgC,EAAE,CAAC,CAAC;IACtE,YAAY,EAAE,WAAW;IACzB,WAAW,EAAE,KAAK;IAClB,mBAAmB;IACnB,iBAAiB,EAAE,EAAE;IACrB,mBAAmB,EAAE,IAAI;IACzB,WAAW;IACX,GAAG,IAAI;CACR,CAAC,CAAA;AAEF,MAAM,SAAS,GAAG;IAChB,IAAI,EAAE,aAAa;IACnB,MAAM,EAAE,eAAe;IACvB,MAAM,EAAE,eAAe;IACvB,WAAW,EAAE,oBAAoB;IACjC,aAAa,EAAE,sBAAsB;IACrC,gBAAgB,EAAE,yBAAyB;IAC3C,YAAY,EAAE,qBAAqB;CAC3B,CAAA;AAYV,eAAe,SAAgC,CAAA;AAsB/C,MAAM,UAAU,aAAa,CAAC,EAC5B,QAAQ,EACR,KAAK,EACL,YAAY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,EAAE,MAAM;YACjB,IAAI,EAAE,CAAC;SACR;QACD,aAAa,EAAE;YACb,aAAa,EAAE,KAAK;YACpB,UAAU,EAAE,QAAQ;YACpB,GAAG,EAAE,EAAE;SACR;QACD,eAAe,EAAE;YACf,aAAa,EAAE,KAAK;YACpB,UAAU,EAAE,QAAQ;YACpB,eAAe,EAAE,EAAE;YACnB,iBAAiB,EAAE,EAAE;YACrB,GAAG,EAAE,CAAC;SACP;QACD,UAAU,EAAE;YACV,KAAK,EAAE,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,wBAAwB,CAAC,CAAC,CAAC,mBAAmB,CAAC,UAAU,CAAC,CAAC,SAAS;SAC9F;QACD,eAAe,EAAE;YACf,IAAI,EAAE,CAAC;SACR;QACD,WAAW,EAAE;YACX,KAAK,EAAE,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,wBAAwB,CAAC,CAAC,CAAC,mBAAmB,CAAC,UAAU,CAAC,CAAC,SAAS;SAC9F;QACD,oBAAoB,EAAE;YACpB,KAAK,EAAE,MAAM,CAAC,wBAAwB;YACtC,QAAQ,EAAE,EAAE;SACb;KACF,CAAC,CAAA;AACJ,CAAC,CAAA","sourcesContent":["import { PlatformPressable, useHeaderHeight } from '@react-navigation/elements'\nimport { NativeStackNavigationOptions } from '@react-navigation/native-stack'\nimport React, { ReactNode } from 'react'\nimport {\n Platform,\n StyleSheet,\n View,\n useWindowDimensions,\n type AccessibilityRole,\n type StyleProp,\n type ViewStyle,\n} from 'react-native'\nimport { useSafeAreaInsets } from 'react-native-safe-area-context'\nimport { useTheme } from '../../hooks'\nimport { MAX_FONT_SIZE_MULTIPLIER_LANDMARK } from '../../utils'\nimport type { ButtonProps, TextButtonProps } from '../display'\nimport { Button, Heading, Icon, IconString, Text, TextButton } from '../display'\n\n// =================================\n// ====== Exports ==================\n// =================================\n\n/**\n * Screen options for the formsheet's NativeStackNavigation route\n * @param {string} options.headerTitle - Doesn't show in UI but good to have for semantic reasons.\n * @param {number[]} [options.sheetAllowedDetents] - Controls the height increments the sheet grows to. To prevent bugs in Android, do not specify more then two values and use [0.94] instead of [1] to go full screen.\n * @param {NativeStackNavigationOptions} [options.rest] - Adds or overrides any valid NativeStackNavigationOptions\n * @returns {NativeStackNavigationOptions} Merged NativeStackNavigationOptions\n */\nexport const getFormSheetScreenOptions = ({\n headerTitle,\n sheetAllowedDetents = [0.25],\n ...rest\n}: NativeStackNavigationOptions = {}): NativeStackNavigationOptions => ({\n presentation: 'formSheet',\n headerShown: false,\n sheetAllowedDetents,\n sheetCornerRadius: 16,\n sheetGrabberVisible: true,\n headerTitle,\n ...rest,\n})\n\nconst FormSheet = {\n Root: FormSheetRoot,\n Action: FormSheetAction,\n Header: FormSheetHeader,\n HeaderTitle: FormSheetHeaderTitle,\n HeaderActions: FormSheetHeaderActions,\n HeaderTextButton: FormSheetHeaderTextButton,\n HeaderButton: FormSheetHeaderButton,\n} as const\n\ntype FormSheetComponents = {\n Root: React.FC<FormSheetRootProps>\n Action: React.FC<FormSheetActionProps>\n Header: React.FC<FormSheetHeaderProps>\n HeaderTitle: React.FC<FormSheetHeaderTitleProps>\n HeaderActions: React.FC<FormSheetHeaderActionsProps>\n HeaderTextButton: React.FC<FormSheetHeaderTextButtonProps>\n HeaderButton: React.FC<FormSheetHeaderButtonProps>\n}\n\nexport default FormSheet as FormSheetComponents\nexport type {\n FormSheetActionProps,\n FormSheetHeaderActionsProps,\n FormSheetHeaderButtonProps,\n FormSheetHeaderProps,\n FormSheetHeaderTextButtonProps,\n FormSheetHeaderTitleProps,\n FormSheetRootProps,\n}\n\n// ====================================\n// ====== ActionsFormSheetRoot ========\n// ====================================\n\ninterface FormSheetRootProps {\n children: ReactNode\n style?: StyleProp<ViewStyle>\n contentStyle?: StyleProp<ViewStyle>\n showAndroidSheetGrabber?: boolean\n}\n\nexport function FormSheetRoot({\n children,\n style,\n contentStyle,\n showAndroidSheetGrabber = true,\n}: FormSheetRootProps) {\n const styles = useStyles()\n\n return (\n <View style={[styles.container, style]} collapsable={false}>\n <View style={[styles.content, contentStyle]}>{children}</View>\n {showAndroidSheetGrabber && <AndroidSheetGrabber />}\n </View>\n )\n}\n\nFormSheetRoot.displayName = 'FormSheet.Root'\n\n// ====================================\n// ====== AndroidSheetGrabber =========\n// ====================================\n\nfunction AndroidSheetGrabber() {\n const styles = useStyles()\n\n return Platform.select({\n android: <View style={styles.androidSheetGrabber} />,\n ios: null,\n })\n}\n\n// ====================================\n// ====== FormSheetHeader =============\n// ====================================\n\ninterface FormSheetHeaderProps {\n children: ReactNode\n style?: StyleProp<ViewStyle>\n}\n\nfunction FormSheetHeader({ children, style }: FormSheetHeaderProps) {\n const styles = useStyles()\n\n return (\n <View style={[styles.header, style]}>\n <View style={styles.headerContent}>{children}</View>\n </View>\n )\n}\n\nFormSheetHeader.displayName = 'FormSheet.Header'\n\n// ====================================\n// ====== FormSheetHeaderTitle ========\n// ====================================\n\ninterface FormSheetHeaderTitleProps {\n children: ReactNode\n}\n\nfunction FormSheetHeaderTitle({ children }: FormSheetHeaderTitleProps) {\n const styles = useStyles()\n\n return (\n <Heading\n variant=\"h3\"\n style={styles.headerTitle}\n maxFontSizeMultiplier={MAX_FONT_SIZE_MULTIPLIER_LANDMARK}\n >\n {children}\n </Heading>\n )\n}\n\nFormSheetHeaderTitle.displayName = 'FormSheet.HeaderTitle'\n\n// ====================================\n// ====== FormSheetHeaderActions ======\n// ====================================\n\ninterface FormSheetHeaderActionsProps {\n children: ReactNode\n}\n\nfunction FormSheetHeaderActions({ children }: FormSheetHeaderActionsProps) {\n const styles = useStyles()\n\n return <View style={styles.headerActions}>{children}</View>\n}\n\nFormSheetHeaderActions.displayName = 'FormSheet.HeaderActions'\n\n// ===========================================\n// ====== FormSheetHeaderTextButton ==========\n// ===========================================\n\n// We are omitting `onLongPress` because we are instead supporting `accessibilityShowsLargeContentViewer`.\n// This is triggered by an `onLongPress` event when an iOS device is in Apple's accessible font scale range.\n// Triggering this prop will display an almost full screen iOS a11y button.\ninterface FormSheetHeaderTextButtonProps\n extends Omit<TextButtonProps, 'maxFontSizeMultiplier' | 'onLongPress'> {\n children: string\n}\n\nfunction FormSheetHeaderTextButton(props: FormSheetHeaderTextButtonProps) {\n return (\n <TextButton\n {...props}\n maxFontSizeMultiplier={MAX_FONT_SIZE_MULTIPLIER_LANDMARK}\n accessibilityShowsLargeContentViewer\n accessibilityLargeContentTitle={props.children}\n />\n )\n}\n\nFormSheetHeaderTextButton.displayName = 'FormSheet.HeaderTextButton'\n\n// =========================================\n// ====== FormSheetHeaderButton ============\n// =========================================\n\n// Same `onLongPress`note as `FormSheetHeaderTextButtonProps`\ninterface FormSheetHeaderButtonProps\n extends Omit<ButtonProps, 'maxFontSizeMultiplier' | 'onLongPress'> {}\n\nfunction FormSheetHeaderButton(props: FormSheetHeaderButtonProps) {\n return (\n <Button\n {...props}\n maxFontSizeMultiplier={MAX_FONT_SIZE_MULTIPLIER_LANDMARK}\n accessibilityShowsLargeContentViewer\n accessibilityLargeContentTitle={props.title}\n />\n )\n}\n\nFormSheetHeaderButton.displayName = 'FormSheet.HeaderButton'\n\n// ====================================\n// ====== ActionsFormSheetAction ======\n// ====================================\n\nconst FORM_SHEET_ACTION_APPEARANCES = {\n neutral: 'neutral',\n danger: 'danger',\n} as const\n\ntype FormSheetActionAppearanceUnion =\n (typeof FORM_SHEET_ACTION_APPEARANCES)[keyof typeof FORM_SHEET_ACTION_APPEARANCES]\n\ninterface FormSheetActionProps {\n title: string\n iconName?: IconString\n onPress: () => void\n accessibilityLabel?: string\n accessibilityHint?: string\n accessibilityRole?: AccessibilityRole\n appearance?: FormSheetActionAppearanceUnion\n disabled?: boolean\n disabledReason?: string\n}\n\nfunction FormSheetAction({\n title,\n iconName,\n onPress,\n accessibilityLabel,\n accessibilityHint,\n accessibilityRole = 'button',\n appearance = 'neutral',\n disabled = false,\n disabledReason,\n}: FormSheetActionProps) {\n const styles = useStyles({ appearance, disabled })\n\n return (\n <PlatformPressable\n onPress={onPress}\n accessibilityLabel={accessibilityLabel}\n accessibilityHint={\n accessibilityHint ?? (disabled && disabledReason ? disabledReason : undefined)\n }\n accessibilityRole={accessibilityRole}\n style={styles.actionPressable}\n disabled={disabled}\n >\n {iconName && (\n <Icon name={iconName} size={16} accessibilityElementsHidden style={styles.actionIcon} />\n )}\n <View style={styles.actionTextBlock}>\n <Text style={styles.actionTitle}>{title}</Text>\n {disabled && disabledReason && (\n <Text style={styles.actionDisabledReason}>{disabledReason}</Text>\n )}\n </View>\n </PlatformPressable>\n )\n}\n\nFormSheetAction.displayName = 'FormSheet.Action'\n\n// ==================================\n// ====== Styles ====================\n// ==================================\n\ninterface Styles {\n appearance?: FormSheetActionAppearanceUnion\n disabled?: boolean\n}\n\nconst useStyles = ({ appearance = 'neutral', disabled = false }: Styles = {}) => {\n const { colors } = useTheme()\n const { height } = useWindowDimensions()\n const { bottom, top } = useSafeAreaInsets()\n const headerHeight = useHeaderHeight()\n\n const containerHeight = Platform.select({\n ios: height - top - headerHeight,\n default: null,\n })\n\n const appearanceColorsMap = {\n neutral: {\n iconColor: colors.iconColorDefaultPrimary,\n textColor: colors.textColorDefaultPrimary,\n },\n danger: {\n iconColor: colors.fillColorStatusErrorMedium,\n textColor: colors.fillColorStatusErrorMedium,\n },\n }\n\n return StyleSheet.create({\n container: {\n justifyContent: 'flex-start',\n paddingBottom: bottom,\n width: '100%',\n backgroundColor: colors.fillColorNeutral100Inverted,\n height: containerHeight,\n ...Platform.select({\n ios: {\n flexGrow: 1, // Ensures the FormSheet children respond to the formsheet height changing on iOS\n },\n android: {\n maxHeight: '100%', // Ensures lists to scroll on Android\n },\n }),\n },\n androidSheetGrabber: {\n position: 'absolute',\n top: 5,\n width: 34,\n height: 5,\n backgroundColor: colors.fillColorNeutral040,\n borderRadius: 100,\n alignSelf: 'center',\n },\n content: {\n ...Platform.select({\n android: {\n maxHeight: '100%', // Ensures content above a list (e.g. FormSheet.Header) don't subtract from the FormSheet's height\n },\n }),\n },\n header: {\n paddingHorizontal: 16,\n paddingTop: 20,\n paddingBottom: 16,\n backgroundColor: colors.fillColorNeutral100Inverted,\n gap: 16,\n borderBottomWidth: 1,\n borderBottomColor: colors.borderColorDefaultBase,\n },\n headerContent: {\n flexDirection: 'row',\n alignItems: 'center',\n justifyContent: 'space-between',\n },\n headerTitle: {\n textAlign: 'left',\n flex: 1,\n },\n headerActions: {\n flexDirection: 'row',\n alignItems: 'center',\n gap: 16,\n },\n actionPressable: {\n flexDirection: 'row',\n alignItems: 'center',\n paddingVertical: 12,\n paddingHorizontal: 16,\n gap: 8,\n },\n actionIcon: {\n color: disabled ? colors.textColorDefaultDisabled : appearanceColorsMap[appearance].iconColor,\n },\n actionTextBlock: {\n flex: 1,\n },\n actionTitle: {\n color: disabled ? colors.textColorDefaultDisabled : appearanceColorsMap[appearance].textColor,\n },\n actionDisabledReason: {\n color: colors.textColorDefaultDisabled,\n fontSize: 12,\n },\n })\n}\n"]}
|
|
1
|
+
{"version":3,"file":"form_sheet.js","sourceRoot":"","sources":["../../../src/components/primitive/form_sheet.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,iBAAiB,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAA;AAG/E,OAAO,EACL,QAAQ,EACR,UAAU,EACV,IAAI,EACJ,mBAAmB,GAIpB,MAAM,cAAc,CAAA;AACrB,OAAO,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAA;AAClE,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAA;AACtC,OAAO,EAAE,oBAAoB,EAAE,iCAAiC,EAAE,MAAM,aAAa,CAAA;AAErF,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAc,IAAI,EAAE,UAAU,EAAE,MAAM,YAAY,CAAA;AAEhF,oCAAoC;AACpC,oCAAoC;AACpC,oCAAoC;AAEpC;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,yBAAyB,GAAG,CAAC,EACxC,WAAW,EACX,mBAAmB,GAAG,CAAC,IA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,KAAK,EAAE,MAAM,CAAC,wBAAwB;YACtC,QAAQ,EAAE,EAAE;SACb;KACF,CAAC,CAAA;AACJ,CAAC,CAAA","sourcesContent":["import { PlatformPressable, useHeaderHeight } from '@react-navigation/elements'\nimport { NativeStackNavigationOptions } from '@react-navigation/native-stack'\nimport React, { ReactNode } from 'react'\nimport {\n Platform,\n StyleSheet,\n View,\n useWindowDimensions,\n type AccessibilityRole,\n type StyleProp,\n type ViewStyle,\n} from 'react-native'\nimport { useSafeAreaInsets } from 'react-native-safe-area-context'\nimport { useTheme } from '../../hooks'\nimport { isLiquidGlassEnabled, MAX_FONT_SIZE_MULTIPLIER_LANDMARK } from '../../utils'\nimport type { ButtonProps, TextButtonProps } from '../display'\nimport { Button, Heading, Icon, IconString, Text, TextButton } from '../display'\n\n// =================================\n// ====== Exports ==================\n// =================================\n\n/**\n * Screen options for the formsheet's NativeStackNavigation route\n * @param {string} options.headerTitle - Doesn't show in UI but good to have for semantic reasons.\n * @param {number[]} [options.sheetAllowedDetents] - Controls the height increments the sheet grows to. To prevent bugs in Android, do not specify more then two values and use [0.94] instead of [1] to go full screen.\n * @param {NativeStackNavigationOptions} [options.rest] - Adds or overrides any valid NativeStackNavigationOptions\n * @returns {NativeStackNavigationOptions} Merged NativeStackNavigationOptions\n */\nexport const getFormSheetScreenOptions = ({\n headerTitle,\n sheetAllowedDetents = [0.25],\n ...rest\n}: NativeStackNavigationOptions = {}): NativeStackNavigationOptions => ({\n presentation: 'formSheet',\n headerShown: false,\n sheetAllowedDetents,\n sheetCornerRadius: isLiquidGlassEnabled() ? undefined : 16,\n sheetGrabberVisible: true,\n headerTitle,\n ...rest,\n})\n\nconst FormSheet = {\n Root: FormSheetRoot,\n Action: FormSheetAction,\n Header: FormSheetHeader,\n HeaderTitle: FormSheetHeaderTitle,\n HeaderActions: FormSheetHeaderActions,\n HeaderTextButton: FormSheetHeaderTextButton,\n HeaderButton: FormSheetHeaderButton,\n} as const\n\ntype FormSheetComponents = {\n Root: React.FC<FormSheetRootProps>\n Action: React.FC<FormSheetActionProps>\n Header: React.FC<FormSheetHeaderProps>\n HeaderTitle: React.FC<FormSheetHeaderTitleProps>\n HeaderActions: React.FC<FormSheetHeaderActionsProps>\n HeaderTextButton: React.FC<FormSheetHeaderTextButtonProps>\n HeaderButton: React.FC<FormSheetHeaderButtonProps>\n}\n\nexport default FormSheet as FormSheetComponents\nexport type {\n FormSheetActionProps,\n FormSheetHeaderActionsProps,\n FormSheetHeaderButtonProps,\n FormSheetHeaderProps,\n FormSheetHeaderTextButtonProps,\n FormSheetHeaderTitleProps,\n FormSheetRootProps,\n}\n\n// ====================================\n// ====== ActionsFormSheetRoot ========\n// ====================================\n\ninterface FormSheetRootProps {\n children: ReactNode\n style?: StyleProp<ViewStyle>\n contentStyle?: StyleProp<ViewStyle>\n showAndroidSheetGrabber?: boolean\n}\n\nexport function FormSheetRoot({\n children,\n style,\n contentStyle,\n showAndroidSheetGrabber = true,\n}: FormSheetRootProps) {\n const styles = useStyles()\n\n return (\n <View style={[styles.container, style]} collapsable={false}>\n <View style={[styles.content, contentStyle]}>{children}</View>\n {showAndroidSheetGrabber && <AndroidSheetGrabber />}\n </View>\n )\n}\n\nFormSheetRoot.displayName = 'FormSheet.Root'\n\n// ====================================\n// ====== AndroidSheetGrabber =========\n// ====================================\n\nfunction AndroidSheetGrabber() {\n const styles = useStyles()\n\n return Platform.select({\n android: <View style={styles.androidSheetGrabber} />,\n ios: null,\n })\n}\n\n// ====================================\n// ====== FormSheetHeader =============\n// ====================================\n\ninterface FormSheetHeaderProps {\n children: ReactNode\n style?: StyleProp<ViewStyle>\n}\n\nfunction FormSheetHeader({ children, style }: FormSheetHeaderProps) {\n const styles = useStyles()\n\n return (\n <View style={[styles.header, style]}>\n <View style={styles.headerContent}>{children}</View>\n </View>\n )\n}\n\nFormSheetHeader.displayName = 'FormSheet.Header'\n\n// ====================================\n// ====== FormSheetHeaderTitle ========\n// ====================================\n\ninterface FormSheetHeaderTitleProps {\n children: ReactNode\n}\n\nfunction FormSheetHeaderTitle({ children }: FormSheetHeaderTitleProps) {\n const styles = useStyles()\n\n return (\n <Heading\n variant=\"h3\"\n style={styles.headerTitle}\n maxFontSizeMultiplier={MAX_FONT_SIZE_MULTIPLIER_LANDMARK}\n >\n {children}\n </Heading>\n )\n}\n\nFormSheetHeaderTitle.displayName = 'FormSheet.HeaderTitle'\n\n// ====================================\n// ====== FormSheetHeaderActions ======\n// ====================================\n\ninterface FormSheetHeaderActionsProps {\n children: ReactNode\n}\n\nfunction FormSheetHeaderActions({ children }: FormSheetHeaderActionsProps) {\n const styles = useStyles()\n\n return <View style={styles.headerActions}>{children}</View>\n}\n\nFormSheetHeaderActions.displayName = 'FormSheet.HeaderActions'\n\n// ===========================================\n// ====== FormSheetHeaderTextButton ==========\n// ===========================================\n\n// We are omitting `onLongPress` because we are instead supporting `accessibilityShowsLargeContentViewer`.\n// This is triggered by an `onLongPress` event when an iOS device is in Apple's accessible font scale range.\n// Triggering this prop will display an almost full screen iOS a11y button.\ninterface FormSheetHeaderTextButtonProps\n extends Omit<TextButtonProps, 'maxFontSizeMultiplier' | 'onLongPress'> {\n children: string\n}\n\nfunction FormSheetHeaderTextButton(props: FormSheetHeaderTextButtonProps) {\n return (\n <TextButton\n {...props}\n maxFontSizeMultiplier={MAX_FONT_SIZE_MULTIPLIER_LANDMARK}\n accessibilityShowsLargeContentViewer\n accessibilityLargeContentTitle={props.children}\n />\n )\n}\n\nFormSheetHeaderTextButton.displayName = 'FormSheet.HeaderTextButton'\n\n// =========================================\n// ====== FormSheetHeaderButton ============\n// =========================================\n\n// Same `onLongPress`note as `FormSheetHeaderTextButtonProps`\ninterface FormSheetHeaderButtonProps\n extends Omit<ButtonProps, 'maxFontSizeMultiplier' | 'onLongPress'> {}\n\nfunction FormSheetHeaderButton(props: FormSheetHeaderButtonProps) {\n return (\n <Button\n {...props}\n maxFontSizeMultiplier={MAX_FONT_SIZE_MULTIPLIER_LANDMARK}\n accessibilityShowsLargeContentViewer\n accessibilityLargeContentTitle={props.title}\n />\n )\n}\n\nFormSheetHeaderButton.displayName = 'FormSheet.HeaderButton'\n\n// ====================================\n// ====== ActionsFormSheetAction ======\n// ====================================\n\nconst FORM_SHEET_ACTION_APPEARANCES = {\n neutral: 'neutral',\n danger: 'danger',\n} as const\n\ntype FormSheetActionAppearanceUnion =\n (typeof FORM_SHEET_ACTION_APPEARANCES)[keyof typeof FORM_SHEET_ACTION_APPEARANCES]\n\ninterface FormSheetActionProps {\n title: string\n iconName?: IconString\n onPress: () => void\n accessibilityLabel?: string\n accessibilityHint?: string\n accessibilityRole?: AccessibilityRole\n appearance?: FormSheetActionAppearanceUnion\n disabled?: boolean\n disabledReason?: string\n}\n\nfunction FormSheetAction({\n title,\n iconName,\n onPress,\n accessibilityLabel,\n accessibilityHint,\n accessibilityRole = 'button',\n appearance = 'neutral',\n disabled = false,\n disabledReason,\n}: FormSheetActionProps) {\n const styles = useStyles({ appearance, disabled })\n\n return (\n <PlatformPressable\n onPress={onPress}\n accessibilityLabel={accessibilityLabel}\n accessibilityHint={\n accessibilityHint ?? (disabled && disabledReason ? disabledReason : undefined)\n }\n accessibilityRole={accessibilityRole}\n style={styles.actionPressable}\n disabled={disabled}\n >\n {iconName && (\n <Icon name={iconName} size={16} accessibilityElementsHidden style={styles.actionIcon} />\n )}\n <View style={styles.actionTextBlock}>\n <Text style={styles.actionTitle}>{title}</Text>\n {disabled && disabledReason && (\n <Text style={styles.actionDisabledReason}>{disabledReason}</Text>\n )}\n </View>\n </PlatformPressable>\n )\n}\n\nFormSheetAction.displayName = 'FormSheet.Action'\n\n// ==================================\n// ====== Styles ====================\n// ==================================\n\ninterface Styles {\n appearance?: FormSheetActionAppearanceUnion\n disabled?: boolean\n}\n\nconst useStyles = ({ appearance = 'neutral', disabled = false }: Styles = {}) => {\n const { colors } = useTheme()\n const { height } = useWindowDimensions()\n const { bottom, top } = useSafeAreaInsets()\n const headerHeight = useHeaderHeight()\n\n const containerHeight = Platform.select({\n ios: height - top - headerHeight,\n default: null,\n })\n\n const appearanceColorsMap = {\n neutral: {\n iconColor: colors.iconColorDefaultPrimary,\n textColor: colors.textColorDefaultPrimary,\n },\n danger: {\n iconColor: colors.fillColorStatusErrorMedium,\n textColor: colors.fillColorStatusErrorMedium,\n },\n }\n\n return StyleSheet.create({\n container: {\n justifyContent: 'flex-start',\n paddingBottom: bottom,\n width: '100%',\n backgroundColor: colors.fillColorNeutral100Inverted,\n height: containerHeight,\n ...Platform.select({\n ios: {\n flexGrow: 1, // Ensures the FormSheet children respond to the formsheet height changing on iOS\n },\n android: {\n maxHeight: '100%', // Ensures lists to scroll on Android\n },\n }),\n },\n androidSheetGrabber: {\n position: 'absolute',\n top: 5,\n width: 34,\n height: 5,\n backgroundColor: colors.fillColorNeutral040,\n borderRadius: 100,\n alignSelf: 'center',\n },\n content: {\n ...Platform.select({\n android: {\n maxHeight: '100%', // Ensures content above a list (e.g. FormSheet.Header) don't subtract from the FormSheet's height\n },\n }),\n },\n header: {\n paddingHorizontal: 16,\n paddingTop: 20,\n paddingBottom: 16,\n backgroundColor: colors.fillColorNeutral100Inverted,\n gap: 16,\n borderBottomWidth: 1,\n borderBottomColor: colors.borderColorDefaultBase,\n },\n headerContent: {\n flexDirection: 'row',\n alignItems: 'center',\n justifyContent: 'space-between',\n },\n headerTitle: {\n textAlign: 'left',\n flex: 1,\n },\n headerActions: {\n flexDirection: 'row',\n alignItems: 'center',\n gap: 16,\n },\n actionPressable: {\n flexDirection: 'row',\n alignItems: 'center',\n paddingVertical: 12,\n paddingHorizontal: 16,\n gap: 8,\n },\n actionIcon: {\n color: disabled ? colors.textColorDefaultDisabled : appearanceColorsMap[appearance].iconColor,\n },\n actionTextBlock: {\n flex: 1,\n },\n actionTitle: {\n color: disabled ? colors.textColorDefaultDisabled : appearanceColorsMap[appearance].textColor,\n },\n actionDisabledReason: {\n color: colors.textColorDefaultDisabled,\n fontSize: 12,\n },\n })\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use_conversation.d.ts","sourceRoot":"","sources":["../../src/hooks/use_conversation.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAA;AAO5D,eAAO,MAAM,0BAA0B,GAAI,qBAAqB;IAAE,eAAe,EAAE,MAAM,CAAA;CAAE;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"use_conversation.d.ts","sourceRoot":"","sources":["../../src/hooks/use_conversation.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAA;AAO5D,eAAO,MAAM,0BAA0B,GAAI,qBAAqB;IAAE,eAAe,EAAE,MAAM,CAAA;CAAE;;;;;;;;;;;;;CA4DzF,CAAA;AAEF,eAAO,MAAM,eAAe,GAAI,qBAAqB;IAAE,eAAe,EAAE,MAAM,CAAA;CAAE;;;;;;;;;;;;;;;;;;;;;;;;;;CAI/E,CAAA;AAED,eAAO,MAAM,mBAAmB,GAAI,qBAAqB;IAAE,eAAe,EAAE,MAAM,CAAA;CAAE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAiDnF,CAAA;AAED,eAAO,MAAM,qBAAqB,GAAI,qBAAqB;IAAE,eAAe,EAAE,MAAM,CAAA;CAAE,+JA+BrF,CAAA;AAED,eAAO,MAAM,qBAAqB,GAAI,qBAAqB;IAAE,eAAe,EAAE,MAAM,CAAA;CAAE,iFAiBrF,CAAA;AAED,eAAO,MAAM,6BAA6B,GAAI,qBAAqB;IAAE,eAAe,EAAE,MAAM,CAAA;CAAE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA6C7F,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use_conversation.js","sourceRoot":"","sources":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AAO,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 { Haptic } from '../utils/native_adapters'\nimport { getConversationsRequestArgs } from '../utils/request/conversation'\nimport { useApiClient } from './use_api_client'\nimport { getRequestQueryKey, useSuspenseGet } from './use_suspense_api'\n\nexport const getConversationRequestArgs = ({ conversation_id }: { conversation_id: number }) => ({\n url: `/me/conversations/${conversation_id}`,\n data: {\n fields: {\n Conversation: [\n 'analytics_metadata',\n 'created_at',\n 'badges',\n 'conversation_membership',\n 'conversation_preview',\n 'gender_option',\n 'groups',\n 'last_message_author_id',\n 'last_message_author_name',\n 'last_message_created_at',\n 'last_message_text_preview',\n 'latest_read_message_sort_key',\n 'preview_avatar_urls',\n 'custom_avatar_type',\n 'custom_avatar_key',\n 'custom_avatar_color',\n 'custom_avatar_image_url',\n 'direct_message',\n 'disabled',\n 'disabled_reason',\n 'disabled_message',\n 'member_ability',\n 'muted',\n 'replies_disabled',\n 'title',\n 'unread_count',\n 'unread_reaction',\n 'updated_at',\n ],\n AnalyticsMetadata: ['metadata'],\n MemberAbility: [\n 'can_update',\n 'can_delete',\n 'leader',\n 'can_reply',\n 'can_delete_non_authored_messages',\n 'can_message_available_members',\n ],\n ConversationMembership: [\n 'last_read_message_sort_key',\n 'notification_level',\n 'notification_level_description',\n 'notification_level_options',\n 'muted',\n ],\n ConversationBadge: ['app_name', 'pco_resource_type', 'text'],\n Group: ['type', 'id', 'links', 'name', 'source_app_name', 'source_type'],\n },\n include: [\n 'badges',\n 'conversation_membership',\n 'member_ability',\n 'groups',\n 'analytics_metadata',\n ],\n },\n})\n\nexport const useConversation = ({ conversation_id }: { conversation_id: number }) => {\n const args = getConversationRequestArgs({ conversation_id })\n\n return useSuspenseGet<ConversationResource>(args)\n}\n\nexport const useConversationMute = ({ conversation_id }: { conversation_id: number }) => {\n const apiClient = useApiClient()\n const queryClient = useQueryClient()\n const requestArgs = getConversationRequestArgs({ conversation_id })\n const queryKey = getRequestQueryKey(requestArgs)\n const { data: conversation } = useConversation({ conversation_id })\n const [value, setValue] = useState<boolean>(conversation.muted)\n\n const { mutate: setMuted, ...mutation } = useMutation({\n onMutate: async (muted: boolean) => {\n return queryClient.setQueryData<ApiResource<ConversationResource>>(queryKey, prev => {\n if (!prev?.data) return prev\n setValue(muted)\n prev.data.muted = muted\n if (prev.data.conversationMembership) {\n prev.data.conversationMembership.muted = muted\n }\n\n return prev\n })\n },\n mutationKey: ['muteConversation'],\n mutationFn: async (muted: boolean) => {\n const action = muted ? 'mute' : 'unmute'\n\n return apiClient.chat.post<ApiResource<ConversationResource>>({\n url: `/me/conversations/${conversation_id}/${action}`,\n data: { data: { type: '', attributes: {} }, fields: { Conversation: 'muted' } },\n })\n },\n onSuccess: (response: ApiResource<ConversationResource>) => {\n queryClient.invalidateQueries({ queryKey: ['/me/conversations'] })\n queryClient.setQueryData<ApiResource<ConversationResource>>(queryKey, prev => {\n if (!prev?.data) return prev\n\n // Posting to the mute action endpoint can't return all the fields\n // so we need to set only the fields we require\n prev.data.muted = response.data.muted\n if (prev.data.conversationMembership) {\n prev.data.conversationMembership.muted = response.data.muted\n }\n setValue(response.data.muted)\n\n return prev\n })\n },\n })\n\n return { muted: value, setMuted, ...mutation }\n}\n\nexport const useConversationUpdate = ({ conversation_id }: { conversation_id: number }) => {\n const apiClient = useApiClient()\n const queryClient = useQueryClient()\n const requestArgs = getConversationRequestArgs({ conversation_id })\n const queryKey = getRequestQueryKey(requestArgs)\n\n return useMutation({\n onMutate: async (update: Partial<ConversationResource>) => {\n queryClient.setQueryData<ApiResource<ConversationResource>>(queryKey, prev => {\n if (prev?.data) {\n prev.data = {\n ...prev.data,\n ...update,\n }\n }\n\n return prev\n })\n },\n mutationKey: ['mutateConversation'],\n mutationFn: async (update: Partial<ConversationResource>) => {\n const postArgs = transformGetToPost(requestArgs).data\n return apiClient.chat.patch<ApiResource<ConversationResource>>({\n url: `/me/conversations/${conversation_id}/`,\n data: { data: { type: '', attributes: update }, ...postArgs },\n })\n },\n onSuccess: response => {\n queryClient.setQueryData<ApiResource<ConversationResource>>(queryKey, () => response)\n },\n })\n}\n\nexport const useConversationDelete = ({ conversation_id }: { conversation_id: number }) => {\n const apiClient = useApiClient()\n const queryClient = useQueryClient()\n const { url } = getConversationsRequestArgs()\n\n return useMutation({\n mutationKey: ['deleteConversation'],\n mutationFn: async () => {\n return apiClient.chat.delete({\n url: `/me/conversations/${conversation_id}`,\n })\n },\n onSuccess: () => {\n queryClient.invalidateQueries({ queryKey: [url] })\n Haptic.notificationSuccess()\n },\n })\n}\n\nexport const useConversationDisableReplies = ({ conversation_id }: { conversation_id: number }) => {\n const apiClient = useApiClient()\n const queryClient = useQueryClient()\n const requestArgs = getConversationRequestArgs({ conversation_id })\n const queryKey = getRequestQueryKey(requestArgs)\n const { data: conversation } = useConversation({ conversation_id })\n const [value, setValue] = useState<boolean>(conversation.repliesDisabled)\n\n const { mutate: setRepliesDisabled, ...mutation } = useMutation({\n onMutate: async (repliesDisabled: boolean) => {\n return queryClient.setQueryData<ApiResource<ConversationResource>>(queryKey, prev => {\n if (!prev?.data) return prev\n setValue(repliesDisabled)\n prev.data.repliesDisabled = repliesDisabled\n\n return prev\n })\n },\n mutationKey: ['disableRepliesConversation'],\n mutationFn: async (repliesDisabled: boolean) => {\n return apiClient.chat.patch<ApiResource<ConversationResource>>({\n url: `/me/conversations/${conversation_id}`,\n data: {\n data: {\n type: 'Conversation',\n attributes: {\n replies_disabled: repliesDisabled,\n },\n },\n },\n })\n },\n onSuccess: (response: ApiResource<ConversationResource>) => {\n queryClient.setQueryData<ApiResource<ConversationResource>>(queryKey, prev => {\n if (!prev?.data) return prev\n\n prev.data.repliesDisabled = response.data.repliesDisabled\n setValue(response.data.repliesDisabled)\n\n return prev\n })\n },\n })\n\n return { repliesDisabled: value, setRepliesDisabled, ...mutation }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"use_conversation.js","sourceRoot":"","sources":["../../src/hooks/use_conversation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAA;AACnE,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AAEhC,OAAO,EAAE,kBAAkB,EAAE,MAAM,iCAAiC,CAAA;AACpE,OAAO,EAAE,MAAM,EAAE,MAAM,0BAA0B,CAAA;AACjD,OAAO,EAAE,2BAA2B,EAAE,MAAM,+BAA+B,CAAA;AAC3E,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAA;AAC/C,OAAO,EAAE,kBAAkB,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAA;AAEvE,MAAM,CAAC,MAAM,0BAA0B,GAAG,CAAC,EAAE,eAAe,EAA+B,EAAE,EAAE,CAAC,CAAC;IAC/F,GAAG,EAAE,qBAAqB,eAAe,EAAE;IAC3C,IAAI,EAAE;QACJ,MAAM,EAAE;YACN,YAAY,EAAE;gBACZ,oBAAoB;gBACpB,YAAY;gBACZ,QAAQ;gBACR,yBAAyB;gBACzB,sBAAsB;gBACtB,eAAe;gBACf,QAAQ;gBACR,wBAAwB;gBACxB,0BAA0B;gBAC1B,yBAAyB;gBACzB,2BAA2B;gBAC3B,8BAA8B;gBAC9B,qBAAqB;gBACrB,oBAAoB;gBACpB,mBAAmB;gBACnB,qBAAqB;gBACrB,yBAAyB;gBACzB,gBAAgB;gBAChB,UAAU;gBACV,iBAAiB;gBACjB,gBAAgB;gBAChB,OAAO;gBACP,kBAAkB;gBAClB,OAAO;gBACP,cAAc;gBACd,iBAAiB;gBACjB,YAAY;aACb;YACD,iBAAiB,EAAE,CAAC,U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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 { Haptic } from '../utils/native_adapters'\nimport { getConversationsRequestArgs } from '../utils/request/conversation'\nimport { useApiClient } from './use_api_client'\nimport { getRequestQueryKey, useSuspenseGet } from './use_suspense_api'\n\nexport const getConversationRequestArgs = ({ conversation_id }: { conversation_id: number }) => ({\n url: `/me/conversations/${conversation_id}`,\n data: {\n fields: {\n Conversation: [\n 'analytics_metadata',\n 'created_at',\n 'badges',\n 'conversation_membership',\n 'conversation_preview',\n 'gender_option',\n 'groups',\n 'last_message_author_id',\n 'last_message_author_name',\n 'last_message_created_at',\n 'last_message_text_preview',\n 'latest_read_message_sort_key',\n 'preview_avatar_urls',\n 'custom_avatar_type',\n 'custom_avatar_key',\n 'custom_avatar_color',\n 'custom_avatar_image_url',\n 'direct_message',\n 'disabled',\n 'disabled_reason',\n 'member_ability',\n 'muted',\n 'replies_disabled',\n 'title',\n 'unread_count',\n 'unread_reaction',\n 'updated_at',\n ],\n AnalyticsMetadata: ['metadata'],\n MemberAbility: [\n 'can_update',\n 'can_delete',\n 'leader',\n 'can_reply',\n 'can_delete_non_authored_messages',\n 'can_message_available_members',\n ],\n ConversationMembership: [\n 'last_read_message_sort_key',\n 'notification_level',\n 'notification_level_description',\n 'notification_level_options',\n 'muted',\n ],\n ConversationBadge: ['app_name', 'pco_resource_type', 'text'],\n Group: ['type', 'id', 'links', 'name', 'source_app_name', 'source_type'],\n },\n include: [\n 'badges',\n 'conversation_membership',\n 'member_ability',\n 'groups',\n 'analytics_metadata',\n ],\n },\n})\n\nexport const useConversation = ({ conversation_id }: { conversation_id: number }) => {\n const args = getConversationRequestArgs({ conversation_id })\n\n return useSuspenseGet<ConversationResource>(args)\n}\n\nexport const useConversationMute = ({ conversation_id }: { conversation_id: number }) => {\n const apiClient = useApiClient()\n const queryClient = useQueryClient()\n const requestArgs = getConversationRequestArgs({ conversation_id })\n const queryKey = getRequestQueryKey(requestArgs)\n const { data: conversation } = useConversation({ conversation_id })\n const [value, setValue] = useState<boolean>(conversation.muted)\n\n const { mutate: setMuted, ...mutation } = useMutation({\n onMutate: async (muted: boolean) => {\n return queryClient.setQueryData<ApiResource<ConversationResource>>(queryKey, prev => {\n if (!prev?.data) return prev\n setValue(muted)\n prev.data.muted = muted\n if (prev.data.conversationMembership) {\n prev.data.conversationMembership.muted = muted\n }\n\n return prev\n })\n },\n mutationKey: ['muteConversation'],\n mutationFn: async (muted: boolean) => {\n const action = muted ? 'mute' : 'unmute'\n\n return apiClient.chat.post<ApiResource<ConversationResource>>({\n url: `/me/conversations/${conversation_id}/${action}`,\n data: { data: { type: '', attributes: {} }, fields: { Conversation: 'muted' } },\n })\n },\n onSuccess: (response: ApiResource<ConversationResource>) => {\n queryClient.invalidateQueries({ queryKey: ['/me/conversations'] })\n queryClient.setQueryData<ApiResource<ConversationResource>>(queryKey, prev => {\n if (!prev?.data) return prev\n\n // Posting to the mute action endpoint can't return all the fields\n // so we need to set only the fields we require\n prev.data.muted = response.data.muted\n if (prev.data.conversationMembership) {\n prev.data.conversationMembership.muted = response.data.muted\n }\n setValue(response.data.muted)\n\n return prev\n })\n },\n })\n\n return { muted: value, setMuted, ...mutation }\n}\n\nexport const useConversationUpdate = ({ conversation_id }: { conversation_id: number }) => {\n const apiClient = useApiClient()\n const queryClient = useQueryClient()\n const requestArgs = getConversationRequestArgs({ conversation_id })\n const queryKey = getRequestQueryKey(requestArgs)\n\n return useMutation({\n onMutate: async (update: Partial<ConversationResource>) => {\n queryClient.setQueryData<ApiResource<ConversationResource>>(queryKey, prev => {\n if (prev?.data) {\n prev.data = {\n ...prev.data,\n ...update,\n }\n }\n\n return prev\n })\n },\n mutationKey: ['mutateConversation'],\n mutationFn: async (update: Partial<ConversationResource>) => {\n const postArgs = transformGetToPost(requestArgs).data\n return apiClient.chat.patch<ApiResource<ConversationResource>>({\n url: `/me/conversations/${conversation_id}/`,\n data: { data: { type: '', attributes: update }, ...postArgs },\n })\n },\n onSuccess: response => {\n queryClient.setQueryData<ApiResource<ConversationResource>>(queryKey, () => response)\n },\n })\n}\n\nexport const useConversationDelete = ({ conversation_id }: { conversation_id: number }) => {\n const apiClient = useApiClient()\n const queryClient = useQueryClient()\n const { url } = getConversationsRequestArgs()\n\n return useMutation({\n mutationKey: ['deleteConversation'],\n mutationFn: async () => {\n return apiClient.chat.delete({\n url: `/me/conversations/${conversation_id}`,\n })\n },\n onSuccess: () => {\n queryClient.invalidateQueries({ queryKey: [url] })\n Haptic.notificationSuccess()\n },\n })\n}\n\nexport const useConversationDisableReplies = ({ conversation_id }: { conversation_id: number }) => {\n const apiClient = useApiClient()\n const queryClient = useQueryClient()\n const requestArgs = getConversationRequestArgs({ conversation_id })\n const queryKey = getRequestQueryKey(requestArgs)\n const { data: conversation } = useConversation({ conversation_id })\n const [value, setValue] = useState<boolean>(conversation.repliesDisabled)\n\n const { mutate: setRepliesDisabled, ...mutation } = useMutation({\n onMutate: async (repliesDisabled: boolean) => {\n return queryClient.setQueryData<ApiResource<ConversationResource>>(queryKey, prev => {\n if (!prev?.data) return prev\n setValue(repliesDisabled)\n prev.data.repliesDisabled = repliesDisabled\n\n return prev\n })\n },\n mutationKey: ['disableRepliesConversation'],\n mutationFn: async (repliesDisabled: boolean) => {\n return apiClient.chat.patch<ApiResource<ConversationResource>>({\n url: `/me/conversations/${conversation_id}`,\n data: {\n data: {\n type: 'Conversation',\n attributes: {\n replies_disabled: repliesDisabled,\n },\n },\n },\n })\n },\n onSuccess: (response: ApiResource<ConversationResource>) => {\n queryClient.setQueryData<ApiResource<ConversationResource>>(queryKey, prev => {\n if (!prev?.data) return prev\n\n prev.data.repliesDisabled = response.data.repliesDisabled\n setValue(response.data.repliesDisabled)\n\n return prev\n })\n },\n })\n\n return { repliesDisabled: value, setRepliesDisabled, ...mutation }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use_conversation_jolt_events.d.ts","sourceRoot":"","sources":["../../src/hooks/use_conversation_jolt_events.ts"],"names":[],"mappings":"AAWA,UAAU,KAAK;IACb,cAAc,EAAE,MAAM,CAAA;CACvB;AAED,wBAAgB,yBAAyB,CAAC,EAAE,cAAc,EAAE,EAAE,KAAK,
|
|
1
|
+
{"version":3,"file":"use_conversation_jolt_events.d.ts","sourceRoot":"","sources":["../../src/hooks/use_conversation_jolt_events.ts"],"names":[],"mappings":"AAWA,UAAU,KAAK;IACb,cAAc,EAAE,MAAM,CAAA;CACvB;AAED,wBAAgB,yBAAyB,CAAC,EAAE,cAAc,EAAE,EAAE,KAAK,QA0FlE"}
|
|
@@ -14,7 +14,7 @@ export function useConversationJoltEvents({ conversationId }) {
|
|
|
14
14
|
const apiClient = useApiClient();
|
|
15
15
|
const queryKey = useMemo(() => getRequestQueryKey(getConversationRequestArgs({ conversation_id: conversationId })), [conversationId]);
|
|
16
16
|
const handleUpdatedConversation = useCallback((e) => {
|
|
17
|
-
const { last_message_idempotent_key, last_message_author_id, disabled, disabled_reason
|
|
17
|
+
const { last_message_idempotent_key, last_message_author_id, disabled, disabled_reason } = e.data.data;
|
|
18
18
|
if (last_message_idempotent_key && last_message_author_id === currentPersonId) {
|
|
19
19
|
completeMessageCreationConversationTracking({
|
|
20
20
|
apiClient,
|
|
@@ -24,15 +24,7 @@ export function useConversationJoltEvents({ conversationId }) {
|
|
|
24
24
|
queryClient.setQueryData(queryKey, prev => {
|
|
25
25
|
if (!prev?.data)
|
|
26
26
|
return prev;
|
|
27
|
-
return {
|
|
28
|
-
...prev,
|
|
29
|
-
data: {
|
|
30
|
-
...prev.data,
|
|
31
|
-
disabled,
|
|
32
|
-
disabledReason: disabled_reason,
|
|
33
|
-
disabledMessage: disabled_message,
|
|
34
|
-
},
|
|
35
|
-
};
|
|
27
|
+
return { ...prev, data: { ...prev.data, disabled, disabledReason: disabled_reason } };
|
|
36
28
|
});
|
|
37
29
|
queryClient.invalidateQueries({ queryKey });
|
|
38
30
|
}, [queryClient, queryKey, currentPersonId, apiClient]);
|