@cometchat/chat-uikit-react-native 5.2.10 → 5.3.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/android/build.gradle +3 -0
- package/android/src/main/java/com/reactnativecometchatuikit/CometchatUiKitPackage.java +4 -1
- package/android/src/main/java/com/reactnativecometchatuikit/FileManager.java +909 -10
- package/android/src/main/java/com/reactnativecometchatuikit/RichTextEditorPackage.kt +24 -0
- package/android/src/main/java/com/reactnativecometchatuikit/RichTextEditorView.kt +5382 -0
- package/android/src/main/java/com/reactnativecometchatuikit/RichTextEditorViewManager.kt +452 -0
- package/ios/FileManager.m +430 -3
- package/ios/RichTextEditorView.swift +5504 -0
- package/ios/RichTextEditorViewManager.m +66 -0
- package/ios/RichTextEditorViewManager.swift +291 -0
- package/ios/ToolbarIcons.swift +736 -0
- package/package.json +1 -1
- package/react-native-cometchat-ui-kit.podspec +1 -1
- package/src/CometChatCompactMessageComposer/CometChatCompactMessageComposer.tsx +4557 -0
- package/src/CometChatCompactMessageComposer/SingleLineTextComposerConfiguration.tsx +568 -0
- package/src/CometChatCompactMessageComposer/heightUtils.ts +204 -0
- package/src/CometChatCompactMessageComposer/index.ts +56 -0
- package/src/CometChatCompactMessageComposer/resources/index.ts +5 -0
- package/src/CometChatCompactMessageComposer/styles.ts +291 -0
- package/src/CometChatConversations/CometChatConversations.tsx +139 -10
- package/src/CometChatMessageComposer/CometChatMessageComposer.tsx +25 -21
- package/src/CometChatMessageComposer/styles.tsx +0 -1
- package/src/CometChatMessageList/CometChatMessageList.tsx +39 -6
- package/src/CometChatMessageList/components/MessageListItem.tsx +11 -8
- package/src/CometChatRichTextEditor/RichTextEditorViewNativeComponent.ts +105 -0
- package/src/CometChatRichTextEditor/index.tsx +385 -0
- package/src/CometChatRichTextEditor/types.ts +162 -0
- package/src/CometChatSearch/CometChatSearch.tsx +8 -3
- package/src/CometChatSearch/style.ts +3 -3
- package/src/index.ts +48 -1
- package/src/shared/constants/UIKitConstants.ts +12 -1
- package/src/shared/formatters/CometChatMentionsFormatter/CometChatMentionsFormatter.tsx +5 -5
- package/src/shared/formatters/CometChatRichTextFormatter/index.tsx +768 -0
- package/src/shared/formatters/index.ts +3 -0
- package/src/shared/framework/MessageDataSource.tsx +93 -2
- package/src/shared/helper/composerHelpers.ts +553 -0
- package/src/shared/helper/useKeyboard.tsx +7 -17
- package/src/shared/icons/components/code-blocks.tsx +13 -0
- package/src/shared/icons/components/code.tsx +11 -0
- package/src/shared/icons/components/format-bold.tsx +11 -0
- package/src/shared/icons/components/format-italic.tsx +11 -0
- package/src/shared/icons/components/format-list-bulleted.tsx +11 -0
- package/src/shared/icons/components/format-list-numbered.tsx +11 -0
- package/src/shared/icons/components/format-quote.tsx +13 -0
- package/src/shared/icons/components/format-strikethrough.tsx +13 -0
- package/src/shared/icons/components/format-underlined.tsx +11 -0
- package/src/shared/icons/components/smileys-&-people.tsx +1 -1
- package/src/shared/icons/icon-mapping.tsx +18 -0
- package/src/shared/index.ts +54 -2
- package/src/shared/resources/CometChatLocalizeNew/resources/de/translation.json +38 -32
- package/src/shared/resources/CometChatLocalizeNew/resources/en/translation.json +6 -0
- package/src/shared/resources/CometChatLocalizeNew/resources/es/translation.json +18 -12
- package/src/shared/resources/CometChatLocalizeNew/resources/fr/translation.json +505 -499
- package/src/shared/resources/CometChatLocalizeNew/resources/hi/translation.json +19 -13
- package/src/shared/resources/CometChatLocalizeNew/resources/hu/translation.json +18 -12
- package/src/shared/resources/CometChatLocalizeNew/resources/it/translation.json +504 -498
- package/src/shared/resources/CometChatLocalizeNew/resources/ja/translation.json +504 -498
- package/src/shared/resources/CometChatLocalizeNew/resources/ko/translation.json +504 -498
- package/src/shared/resources/CometChatLocalizeNew/resources/lt/translation.json +19 -13
- package/src/shared/resources/CometChatLocalizeNew/resources/ms/translation.json +18 -12
- package/src/shared/resources/CometChatLocalizeNew/resources/nl/translation.json +505 -499
- package/src/shared/resources/CometChatLocalizeNew/resources/pt/translation.json +18 -12
- package/src/shared/resources/CometChatLocalizeNew/resources/ru/translation.json +18 -12
- package/src/shared/resources/CometChatLocalizeNew/resources/sv/translation.json +19 -13
- package/src/shared/resources/CometChatLocalizeNew/resources/tr/translation.json +505 -499
- package/src/shared/resources/CometChatLocalizeNew/resources/zh/translation.json +18 -12
- package/src/shared/resources/CometChatLocalizeNew/resources/zh-tw/translation.json +19 -13
- package/src/shared/utils/CometChatMessagePreview/CometChatMessagePreview.tsx +132 -11
- package/src/shared/utils/CometChatMessagePreview/style.ts +1 -3
- package/src/shared/utils/MarkdownUtils.ts +143 -0
- package/src/shared/utils/MentionUtils.ts +37 -0
- package/src/shared/utils/MessageUtils.tsx +55 -0
- package/src/shared/utils/index.ts +5 -0
- package/src/shared/views/CometChatActionSheet/CometChatActionSheet.tsx +1 -1
- package/src/shared/views/CometChatInlineAudioRecorder/AudioWaveformVisualizer.tsx +417 -0
- package/src/shared/views/CometChatInlineAudioRecorder/CometChatInlineAudioRecorder.tsx +537 -0
- package/src/shared/views/CometChatInlineAudioRecorder/index.ts +34 -0
- package/src/shared/views/CometChatInlineAudioRecorder/style.ts +155 -0
- package/src/shared/views/CometChatInlineAudioRecorder/types.ts +303 -0
- package/src/shared/views/CometChatInlineAudioRecorder/useAudioRecorder.ts +1336 -0
- package/src/shared/views/CometChatLinkConfirmPopup/CometChatLinkConfirmPopup.tsx +183 -0
- package/src/shared/views/CometChatLinkConfirmPopup/index.ts +13 -0
- package/src/shared/views/CometChatLinkConfirmPopup/style.ts +128 -0
- package/src/shared/views/CometChatList/Header.tsx +57 -49
- package/src/shared/views/CometChatMediaRecorder/CometChatMediaRecorder.tsx +0 -1
- package/src/shared/views/CometChatQuickReactions/QuickReactionsStyle.tsx +2 -2
- package/src/shared/views/CometChatReactionList/ReactionListStyle.tsx +3 -2
- package/src/shared/views/CometChatReactions/CometChatReactions.tsx +11 -5
- package/src/shared/views/CometChatReactions/style.ts +35 -8
- package/src/shared/views/CometChatSendButtonView/CometChatSendButtonView.tsx +32 -29
- package/src/shared/views/CometChatTextBubble/CometChatTextBubble.tsx +108 -75
- package/src/shared/views/index.ts +39 -0
- package/src/theme/index.ts +1 -1
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
import { CometChatTheme } from "../../../theme/type";
|
|
2
|
+
import { deepMerge } from "../../helper/helperFunctions";
|
|
3
|
+
import { CometChatInlineAudioRecorderStyle } from "./types";
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Returns the default style configuration for the CometChatInlineAudioRecorder component
|
|
7
|
+
* using theme colors from CometChatThemeHelper.
|
|
8
|
+
*
|
|
9
|
+
* This function provides default styling that integrates with the CometChat theme system,
|
|
10
|
+
* ensuring consistent appearance across the UI Kit.
|
|
11
|
+
*
|
|
12
|
+
* @param color - Theme color configuration from CometChatTheme
|
|
13
|
+
* @param spacing - Theme spacing configuration from CometChatTheme
|
|
14
|
+
* @param typography - Theme typography configuration from CometChatTheme
|
|
15
|
+
* @returns Default style configuration for the inline audio recorder
|
|
16
|
+
*
|
|
17
|
+
* @validates Requirements 8.3, 8.4
|
|
18
|
+
*/
|
|
19
|
+
export const getInlineAudioRecorderStyleLight = (
|
|
20
|
+
color: CometChatTheme["color"],
|
|
21
|
+
spacing: CometChatTheme["spacing"],
|
|
22
|
+
typography: CometChatTheme["typography"]
|
|
23
|
+
): CometChatInlineAudioRecorderStyle => {
|
|
24
|
+
return {
|
|
25
|
+
backgroundColor: color.background1 as string,
|
|
26
|
+
borderRadius: spacing.radius.r2,
|
|
27
|
+
recordingIndicatorColor: color.error as string,
|
|
28
|
+
containerStyle: {
|
|
29
|
+
flexDirection: 'row',
|
|
30
|
+
alignItems: 'center',
|
|
31
|
+
paddingHorizontal: 12,
|
|
32
|
+
paddingVertical: 12,
|
|
33
|
+
gap: 12, // Add spacing between elements to match composer layout
|
|
34
|
+
},
|
|
35
|
+
durationTextStyle: {
|
|
36
|
+
...typography.caption1.medium,
|
|
37
|
+
color: color.textPrimary as string,
|
|
38
|
+
minWidth: 45,
|
|
39
|
+
textAlign: 'center',
|
|
40
|
+
},
|
|
41
|
+
deleteButtonStyle: {
|
|
42
|
+
iconColor: color.iconSecondary as string,
|
|
43
|
+
iconSize: 24,
|
|
44
|
+
},
|
|
45
|
+
sendButtonStyle: {
|
|
46
|
+
iconColor: color.primary as string,
|
|
47
|
+
iconSize: 24,
|
|
48
|
+
},
|
|
49
|
+
recordPlayButtonStyle: {
|
|
50
|
+
iconColor: color.primary as string,
|
|
51
|
+
iconSize: 24,
|
|
52
|
+
},
|
|
53
|
+
pauseButtonStyle: {
|
|
54
|
+
iconColor: color.error as string,
|
|
55
|
+
iconSize: 24,
|
|
56
|
+
},
|
|
57
|
+
micButtonStyle: {
|
|
58
|
+
iconColor: color.primary as string,
|
|
59
|
+
iconSize: 24,
|
|
60
|
+
},
|
|
61
|
+
waveformStyle: {
|
|
62
|
+
recordingBarColor: color.primary as string,
|
|
63
|
+
playedBarColor: color.primary as string,
|
|
64
|
+
unplayedBarColor: color.neutral400 as string,
|
|
65
|
+
barWidth: 3,
|
|
66
|
+
barSpacing: 2,
|
|
67
|
+
minBarHeight: 4,
|
|
68
|
+
maxBarHeight: 32, // Increased to fill more vertical space
|
|
69
|
+
height: 40, // Match the minInputHeight of the text input
|
|
70
|
+
},
|
|
71
|
+
};
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Returns the dark theme style configuration for the CometChatInlineAudioRecorder component.
|
|
76
|
+
*
|
|
77
|
+
* This function extends the light theme styles with dark mode specific overrides,
|
|
78
|
+
* using deepMerge to combine the base styles with dark mode adjustments.
|
|
79
|
+
*
|
|
80
|
+
* @param color - Theme color configuration from CometChatTheme (dark mode)
|
|
81
|
+
* @param spacing - Theme spacing configuration from CometChatTheme
|
|
82
|
+
* @param typography - Theme typography configuration from CometChatTheme
|
|
83
|
+
* @returns Dark theme style configuration for the inline audio recorder
|
|
84
|
+
*
|
|
85
|
+
* @validates Requirements 8.3, 8.4
|
|
86
|
+
*/
|
|
87
|
+
export const getInlineAudioRecorderStyleDark = (
|
|
88
|
+
color: CometChatTheme["color"],
|
|
89
|
+
spacing: CometChatTheme["spacing"],
|
|
90
|
+
typography: CometChatTheme["typography"]
|
|
91
|
+
): CometChatInlineAudioRecorderStyle => {
|
|
92
|
+
return deepMerge(getInlineAudioRecorderStyleLight(color, spacing, typography), {
|
|
93
|
+
backgroundColor: color.background1 as string,
|
|
94
|
+
durationTextStyle: {
|
|
95
|
+
color: color.textPrimary as string,
|
|
96
|
+
},
|
|
97
|
+
waveformStyle: {
|
|
98
|
+
unplayedBarColor: color.neutral500 as string,
|
|
99
|
+
},
|
|
100
|
+
});
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* Merges custom style configuration with default theme-based styles.
|
|
105
|
+
*
|
|
106
|
+
* This function is the primary entry point for getting the complete style configuration
|
|
107
|
+
* for the CometChatInlineAudioRecorder component. It takes the theme parameters and
|
|
108
|
+
* an optional custom style prop, merging them using deepMerge to produce the final
|
|
109
|
+
* style configuration.
|
|
110
|
+
*
|
|
111
|
+
* Usage:
|
|
112
|
+
* ```typescript
|
|
113
|
+
* const theme = useTheme();
|
|
114
|
+
* const mergedStyle = getInlineAudioRecorderStyle(
|
|
115
|
+
* theme.color,
|
|
116
|
+
* theme.spacing,
|
|
117
|
+
* theme.typography,
|
|
118
|
+
* customStyleProp
|
|
119
|
+
* );
|
|
120
|
+
* ```
|
|
121
|
+
*
|
|
122
|
+
* @param color - Theme color configuration from CometChatTheme
|
|
123
|
+
* @param spacing - Theme spacing configuration from CometChatTheme
|
|
124
|
+
* @param typography - Theme typography configuration from CometChatTheme
|
|
125
|
+
* @param customStyle - Optional custom style configuration to merge with defaults
|
|
126
|
+
* @param isDarkMode - Whether to use dark mode styles (default: false)
|
|
127
|
+
* @returns Complete merged style configuration for the inline audio recorder
|
|
128
|
+
*
|
|
129
|
+
* @validates Requirements 8.3, 8.4
|
|
130
|
+
*/
|
|
131
|
+
export const getInlineAudioRecorderStyle = (
|
|
132
|
+
color: CometChatTheme["color"],
|
|
133
|
+
spacing: CometChatTheme["spacing"],
|
|
134
|
+
typography: CometChatTheme["typography"],
|
|
135
|
+
customStyle?: CometChatInlineAudioRecorderStyle,
|
|
136
|
+
isDarkMode: boolean = false
|
|
137
|
+
): CometChatInlineAudioRecorderStyle => {
|
|
138
|
+
// Get the appropriate base style based on theme mode
|
|
139
|
+
const baseStyle = isDarkMode
|
|
140
|
+
? getInlineAudioRecorderStyleDark(color, spacing, typography)
|
|
141
|
+
: getInlineAudioRecorderStyleLight(color, spacing, typography);
|
|
142
|
+
|
|
143
|
+
// If no custom style provided, return the base style
|
|
144
|
+
if (!customStyle) {
|
|
145
|
+
return baseStyle;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
// Merge custom style with base style using deepMerge
|
|
149
|
+
return deepMerge(baseStyle, customStyle);
|
|
150
|
+
};
|
|
151
|
+
|
|
152
|
+
export {
|
|
153
|
+
getInlineAudioRecorderStyleLight as getInlineAudioRecorderStylesLight,
|
|
154
|
+
getInlineAudioRecorderStyleDark as getInlineAudioRecorderStylesDark,
|
|
155
|
+
};
|
|
@@ -0,0 +1,303 @@
|
|
|
1
|
+
import { ImageSourcePropType, ImageStyle, TextStyle, ViewStyle } from "react-native";
|
|
2
|
+
import { JSX } from "react";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* RecorderState union type representing all possible states of the inline audio recorder.
|
|
6
|
+
*
|
|
7
|
+
* States:
|
|
8
|
+
* - idle: Initial state, no recording in progress
|
|
9
|
+
* - recording: Actively recording audio
|
|
10
|
+
* - paused: Recording is paused, can be resumed
|
|
11
|
+
* - completed: Recording finished, ready for playback or send
|
|
12
|
+
* - playing: Playing back the recorded audio
|
|
13
|
+
* - error: An error occurred during recording or playback
|
|
14
|
+
*
|
|
15
|
+
* @validates Requirements 9.1
|
|
16
|
+
*/
|
|
17
|
+
export type RecorderState =
|
|
18
|
+
| 'idle'
|
|
19
|
+
| 'recording'
|
|
20
|
+
| 'paused'
|
|
21
|
+
| 'completed'
|
|
22
|
+
| 'playing'
|
|
23
|
+
| 'error';
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Represents a single audio segment in segment-based recording.
|
|
27
|
+
* Each segment is a separate audio file that can be previewed and merged.
|
|
28
|
+
*
|
|
29
|
+
* @validates Requirements 11.7
|
|
30
|
+
*/
|
|
31
|
+
export interface AudioSegment {
|
|
32
|
+
/** Unique identifier for the segment */
|
|
33
|
+
id: string;
|
|
34
|
+
/** File path to the segment audio file */
|
|
35
|
+
filePath: string;
|
|
36
|
+
/** Duration of this segment in milliseconds */
|
|
37
|
+
duration: number;
|
|
38
|
+
/** Amplitude values recorded during this segment */
|
|
39
|
+
amplitudes: number[];
|
|
40
|
+
/** Timestamp when segment was created */
|
|
41
|
+
createdAt: number;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* State for managing multiple audio segments.
|
|
46
|
+
* Used for WhatsApp-style preview-while-paused functionality.
|
|
47
|
+
*
|
|
48
|
+
* @validates Requirements 11.7
|
|
49
|
+
*/
|
|
50
|
+
export interface SegmentManagerState {
|
|
51
|
+
/** List of all recorded segments */
|
|
52
|
+
segments: AudioSegment[];
|
|
53
|
+
/** Currently recording segment (null if not recording) */
|
|
54
|
+
currentSegment: AudioSegment | null;
|
|
55
|
+
/** Total duration across all segments */
|
|
56
|
+
totalDuration: number;
|
|
57
|
+
/** Combined amplitudes from all segments for waveform display */
|
|
58
|
+
allAmplitudes: number[];
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Style configuration for individual buttons in the recorder.
|
|
63
|
+
*
|
|
64
|
+
* @validates Requirements 8.3
|
|
65
|
+
*/
|
|
66
|
+
export interface ButtonStyle {
|
|
67
|
+
/** Icon tint color */
|
|
68
|
+
iconColor?: string;
|
|
69
|
+
/** Background color */
|
|
70
|
+
backgroundColor?: string;
|
|
71
|
+
/** Icon size */
|
|
72
|
+
iconSize?: number;
|
|
73
|
+
/** Custom icon */
|
|
74
|
+
icon?: JSX.Element | ImageSourcePropType;
|
|
75
|
+
/** Icon image style */
|
|
76
|
+
iconStyle?: ImageStyle;
|
|
77
|
+
/** Container style */
|
|
78
|
+
containerStyle?: ViewStyle;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* Style configuration for the waveform visualizer.
|
|
83
|
+
*
|
|
84
|
+
* @validates Requirements 8.3
|
|
85
|
+
*/
|
|
86
|
+
export interface WaveformStyle {
|
|
87
|
+
/** Color for bars during recording */
|
|
88
|
+
recordingBarColor?: string;
|
|
89
|
+
/** Color for played portion during playback */
|
|
90
|
+
playedBarColor?: string;
|
|
91
|
+
/** Color for unplayed portion during playback */
|
|
92
|
+
unplayedBarColor?: string;
|
|
93
|
+
/** Width of each bar */
|
|
94
|
+
barWidth?: number;
|
|
95
|
+
/** Spacing between bars */
|
|
96
|
+
barSpacing?: number;
|
|
97
|
+
/** Minimum bar height */
|
|
98
|
+
minBarHeight?: number;
|
|
99
|
+
/** Maximum bar height */
|
|
100
|
+
maxBarHeight?: number;
|
|
101
|
+
/** Container height */
|
|
102
|
+
height?: number;
|
|
103
|
+
/** Container style */
|
|
104
|
+
containerStyle?: ViewStyle;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* Style configuration for the CometChatInlineAudioRecorder component.
|
|
109
|
+
* Supports theming through CometChatThemeHelper for default styling.
|
|
110
|
+
*
|
|
111
|
+
* @validates Requirements 8.3, 8.4
|
|
112
|
+
*/
|
|
113
|
+
export interface CometChatInlineAudioRecorderStyle {
|
|
114
|
+
/** Container background color */
|
|
115
|
+
backgroundColor?: string;
|
|
116
|
+
/** Container border style */
|
|
117
|
+
border?: ViewStyle;
|
|
118
|
+
/** Container border radius */
|
|
119
|
+
borderRadius?: number;
|
|
120
|
+
/** Container style */
|
|
121
|
+
containerStyle?: ViewStyle;
|
|
122
|
+
/** Waveform style configuration */
|
|
123
|
+
waveformStyle?: WaveformStyle;
|
|
124
|
+
/** Duration text style */
|
|
125
|
+
durationTextStyle?: TextStyle;
|
|
126
|
+
/** Delete button style */
|
|
127
|
+
deleteButtonStyle?: ButtonStyle;
|
|
128
|
+
/** Send button style */
|
|
129
|
+
sendButtonStyle?: ButtonStyle;
|
|
130
|
+
/** Record/Play button style */
|
|
131
|
+
recordPlayButtonStyle?: ButtonStyle;
|
|
132
|
+
/** Pause button style */
|
|
133
|
+
pauseButtonStyle?: ButtonStyle;
|
|
134
|
+
/** Mic button style */
|
|
135
|
+
micButtonStyle?: ButtonStyle;
|
|
136
|
+
/** Recording indicator color (red pulsing dot) */
|
|
137
|
+
recordingIndicatorColor?: string;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
/**
|
|
141
|
+
* Props for the AudioWaveformVisualizer component.
|
|
142
|
+
* Displays animated waveform bars during recording and playback.
|
|
143
|
+
*
|
|
144
|
+
* @validates Requirements 2.1, 2.2, 2.3, 2.4, 2.5, 4.2, 5.1, 5.2, 5.3, 5.5
|
|
145
|
+
*/
|
|
146
|
+
export interface AudioWaveformVisualizerProps {
|
|
147
|
+
/** Whether waveform should animate (during recording) */
|
|
148
|
+
isAnimating: boolean;
|
|
149
|
+
/** Whether audio is currently playing */
|
|
150
|
+
isPlaying: boolean;
|
|
151
|
+
/** Playback progress (0.0 to 1.0) */
|
|
152
|
+
playbackProgress: number;
|
|
153
|
+
/** Amplitude values for visualization */
|
|
154
|
+
amplitudes: number[];
|
|
155
|
+
/** Callback when user taps/drags to seek (called on release) */
|
|
156
|
+
onSeek?: (progress: number) => void;
|
|
157
|
+
/** Callback when user starts dragging (for smooth UI updates) */
|
|
158
|
+
onSeekStart?: (progress: number) => void;
|
|
159
|
+
/** Callback when user finishes dragging (for smooth UI updates) */
|
|
160
|
+
onSeekEnd?: (progress: number) => void;
|
|
161
|
+
/** Whether seeking is allowed (disabled during recording) */
|
|
162
|
+
allowSeeking: boolean;
|
|
163
|
+
/** Style configuration */
|
|
164
|
+
style?: WaveformStyle;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
/**
|
|
168
|
+
* Props for the CometChatInlineAudioRecorder component.
|
|
169
|
+
* Main component that orchestrates the inline recording experience.
|
|
170
|
+
*
|
|
171
|
+
* @validates Requirements 1.1, 1.2, 1.5, 3.2, 6.1, 6.2, 7.1, 7.3, 8.2, 8.3, 8.5
|
|
172
|
+
*/
|
|
173
|
+
export interface CometChatInlineAudioRecorderProps {
|
|
174
|
+
/** Callback when user sends the recorded audio */
|
|
175
|
+
onSubmit: (filePath: string) => void;
|
|
176
|
+
/** Callback when user cancels/deletes the recording */
|
|
177
|
+
onCancel: () => void;
|
|
178
|
+
/** Custom style configuration */
|
|
179
|
+
style?: CometChatInlineAudioRecorderStyle;
|
|
180
|
+
/** Custom delete button icon */
|
|
181
|
+
deleteIcon?: JSX.Element | ImageSourcePropType;
|
|
182
|
+
/** Custom send button icon */
|
|
183
|
+
sendIcon?: JSX.Element | ImageSourcePropType;
|
|
184
|
+
/** Custom record/play button icon */
|
|
185
|
+
recordIcon?: JSX.Element | ImageSourcePropType;
|
|
186
|
+
/** Custom pause button icon */
|
|
187
|
+
pauseIcon?: JSX.Element | ImageSourcePropType;
|
|
188
|
+
/** Custom mic button icon */
|
|
189
|
+
micIcon?: JSX.Element | ImageSourcePropType;
|
|
190
|
+
/** Custom play button icon */
|
|
191
|
+
playIcon?: JSX.Element | ImageSourcePropType;
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
/**
|
|
195
|
+
* Return type for the useAudioRecorder custom hook.
|
|
196
|
+
* Encapsulates all recording logic and native module interaction.
|
|
197
|
+
*
|
|
198
|
+
* @validates Requirements 9.1, 9.2, 9.3, 10.1, 10.5, 11.7
|
|
199
|
+
*/
|
|
200
|
+
export interface UseAudioRecorderReturn {
|
|
201
|
+
/** Current recorder state */
|
|
202
|
+
state: RecorderState;
|
|
203
|
+
/** Current recording/playback duration in milliseconds */
|
|
204
|
+
duration: number;
|
|
205
|
+
/** Current playback position in milliseconds */
|
|
206
|
+
currentPosition: number;
|
|
207
|
+
/** Recorded file path (available after recording stops) */
|
|
208
|
+
filePath: string | null;
|
|
209
|
+
/** Error message if any */
|
|
210
|
+
error: string | null;
|
|
211
|
+
/** Amplitude values for waveform visualization */
|
|
212
|
+
amplitudes: number[];
|
|
213
|
+
/** List of recorded segments */
|
|
214
|
+
segments: AudioSegment[];
|
|
215
|
+
/** Whether there are multiple segments (user has paused and continued) */
|
|
216
|
+
hasMultipleSegments: boolean;
|
|
217
|
+
/** Start recording */
|
|
218
|
+
startRecording: () => Promise<void>;
|
|
219
|
+
/** Pause recording (finalizes current segment for preview) */
|
|
220
|
+
pauseRecording: () => Promise<void>;
|
|
221
|
+
/** Resume recording (legacy - use continueRecording for segment-based) */
|
|
222
|
+
resumeRecording: () => Promise<void>;
|
|
223
|
+
/** Continue recording (starts new segment after pause) */
|
|
224
|
+
continueRecording: () => Promise<void>;
|
|
225
|
+
/** Stop recording and finalize all segments */
|
|
226
|
+
stopRecording: () => Promise<string | null>;
|
|
227
|
+
/** Start playback of all segments */
|
|
228
|
+
startPlayback: () => Promise<void>;
|
|
229
|
+
/** Start playback preview while paused (plays segments without stopping recording) */
|
|
230
|
+
startPlaybackPreview: () => Promise<void>;
|
|
231
|
+
/** Pause playback */
|
|
232
|
+
pausePlayback: () => Promise<void>;
|
|
233
|
+
/** Resume playback */
|
|
234
|
+
resumePlayback: () => Promise<void>;
|
|
235
|
+
/** Seek to position (0.0 to 1.0) */
|
|
236
|
+
seekTo: (progress: number) => Promise<void>;
|
|
237
|
+
/** Seek to position and start playback (for waveform tap) */
|
|
238
|
+
seekAndPlay: (progress: number) => Promise<void>;
|
|
239
|
+
/** Cancel and cleanup all segments */
|
|
240
|
+
cancel: () => Promise<void>;
|
|
241
|
+
/** Computed state check: is currently recording */
|
|
242
|
+
isRecording: boolean;
|
|
243
|
+
/** Computed state check: is currently paused */
|
|
244
|
+
isPaused: boolean;
|
|
245
|
+
/** Computed state check: is currently playing */
|
|
246
|
+
isPlaying: boolean;
|
|
247
|
+
/** Computed state check: recording is completed */
|
|
248
|
+
isCompleted: boolean;
|
|
249
|
+
/** Computed state check: has a recording (duration > 0) */
|
|
250
|
+
hasRecording: boolean;
|
|
251
|
+
/** Can continue recording (in paused state) */
|
|
252
|
+
canContinueRecording: boolean;
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
/**
|
|
256
|
+
* Action types for the useAudioRecorder reducer.
|
|
257
|
+
* Used for predictable state management across child components.
|
|
258
|
+
*
|
|
259
|
+
* @validates Requirements 9.5, 11.7
|
|
260
|
+
*/
|
|
261
|
+
export type RecorderAction =
|
|
262
|
+
| { type: 'START_RECORDING' }
|
|
263
|
+
| { type: 'PAUSE_RECORDING' }
|
|
264
|
+
| { type: 'RESUME_RECORDING' }
|
|
265
|
+
| { type: 'STOP_RECORDING'; filePath: string }
|
|
266
|
+
| { type: 'START_PLAYBACK' }
|
|
267
|
+
| { type: 'PAUSE_PLAYBACK' }
|
|
268
|
+
| { type: 'RESUME_PLAYBACK' }
|
|
269
|
+
| { type: 'PLAYBACK_COMPLETE' }
|
|
270
|
+
| { type: 'SEEK'; position: number }
|
|
271
|
+
| { type: 'UPDATE_DURATION'; duration: number }
|
|
272
|
+
| { type: 'UPDATE_POSITION'; position: number }
|
|
273
|
+
| { type: 'ADD_AMPLITUDE'; amplitude: number }
|
|
274
|
+
| { type: 'SET_ERROR'; error: string }
|
|
275
|
+
| { type: 'RESET' }
|
|
276
|
+
// Segment-related actions
|
|
277
|
+
| { type: 'FINALIZE_SEGMENT'; segment: AudioSegment }
|
|
278
|
+
| { type: 'START_NEW_SEGMENT' }
|
|
279
|
+
| { type: 'CLEAR_SEGMENTS' };
|
|
280
|
+
|
|
281
|
+
/**
|
|
282
|
+
* State shape for the useAudioRecorder reducer.
|
|
283
|
+
*
|
|
284
|
+
* @validates Requirements 9.1, 9.3, 11.7
|
|
285
|
+
*/
|
|
286
|
+
export interface RecorderReducerState {
|
|
287
|
+
/** Current recorder state */
|
|
288
|
+
state: RecorderState;
|
|
289
|
+
/** Current recording/playback duration in milliseconds */
|
|
290
|
+
duration: number;
|
|
291
|
+
/** Current playback position in milliseconds */
|
|
292
|
+
currentPosition: number;
|
|
293
|
+
/** Recorded file path */
|
|
294
|
+
filePath: string | null;
|
|
295
|
+
/** Error message if any */
|
|
296
|
+
error: string | null;
|
|
297
|
+
/** Amplitude values for waveform visualization */
|
|
298
|
+
amplitudes: number[];
|
|
299
|
+
/** List of recorded segments */
|
|
300
|
+
segments: AudioSegment[];
|
|
301
|
+
/** Whether we're in preview mode (playing from paused state) */
|
|
302
|
+
isPreviewMode?: boolean;
|
|
303
|
+
}
|