@developer_tribe/react-native-comnyx 0.14.0 → 0.16.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/Comnyx.podspec +10 -2
- package/README.md +50 -0
- package/android/build.gradle +1 -0
- package/android/consumer-rules.pro +23 -0
- package/android/generated/java/com/comnyx/NativeComnyxSpec.java +46 -0
- package/android/generated/jni/RNComnyxSpec-generated.cpp +23 -1
- package/android/generated/jni/RNComnyxSpec.h +7 -0
- package/android/generated/jni/react/renderer/components/RNComnyxSpec/RNComnyxSpecJSI-generated.cpp +21 -0
- package/android/generated/jni/react/renderer/components/RNComnyxSpec/RNComnyxSpecJSI.h +70 -0
- package/android/src/main/AndroidManifest.xml +11 -1
- package/android/src/main/AndroidManifestNew.xml +11 -1
- package/android/src/main/java/com/comnyx/ComnyxMediaPickerModule.kt +105 -19
- package/android/src/main/java/com/comnyx/ComnyxModule.kt +7 -0
- package/android/src/main/java/com/comnyx/src/messaging/firebase/FirebaseMessagingService.kt +4 -6
- package/android/src/main/res/xml/comnyx_file_paths.xml +12 -0
- package/ios/APNService.swift +9 -9
- package/ios/Comnyx.swift +17 -8
- package/ios/ComnyxMediaPicker.m +6 -0
- package/ios/ComnyxMediaPicker.swift +106 -26
- package/ios/ComnyxMessaging.swift +2 -0
- package/ios/PrivacyInfo.xcprivacy +32 -0
- package/ios/comnyx_post_install.rb +25 -0
- package/ios/generated/RCTAppDependencyProvider.h +25 -0
- package/ios/generated/RCTAppDependencyProvider.mm +55 -0
- package/ios/generated/RCTModulesConformingToProtocolsProvider.h +18 -0
- package/ios/generated/RCTModulesConformingToProtocolsProvider.mm +33 -0
- package/ios/generated/RCTThirdPartyComponentsProvider.h +16 -0
- package/ios/generated/RCTThirdPartyComponentsProvider.mm +23 -0
- package/ios/generated/RNComnyxSpec/RNComnyxSpec-generated.mm +53 -0
- package/ios/generated/RNComnyxSpec/RNComnyxSpec.h +67 -0
- package/ios/generated/RNComnyxSpecJSI-generated.cpp +38 -0
- package/ios/generated/RNComnyxSpecJSI.h +89 -0
- package/ios/generated/ReactAppDependencyProvider.podspec +34 -0
- package/lib/commonjs/NativeComnyxMediaPicker.js +46 -6
- package/lib/commonjs/NativeComnyxMediaPicker.js.map +1 -1
- package/lib/commonjs/api/conversations.js +6 -6
- package/lib/commonjs/api/conversations.js.map +1 -1
- package/lib/commonjs/api/customers.js +3 -2
- package/lib/commonjs/api/customers.js.map +1 -1
- package/lib/commonjs/api/media.js +20 -6
- package/lib/commonjs/api/media.js.map +1 -1
- package/lib/commonjs/api/messages.js +3 -2
- package/lib/commonjs/api/messages.js.map +1 -1
- package/lib/commonjs/assets/gallery.png +0 -0
- package/lib/commonjs/assets/video-play.png +0 -0
- package/lib/commonjs/components/ChatList.js +93 -45
- package/lib/commonjs/components/ChatList.js.map +1 -1
- package/lib/commonjs/components/ComnyxErrorBoundary.js +92 -0
- package/lib/commonjs/components/ComnyxErrorBoundary.js.map +1 -0
- package/lib/commonjs/components/CustomerForm.js +2 -2
- package/lib/commonjs/components/CustomerForm.js.map +1 -1
- package/lib/commonjs/components/MediaMessageItem.js +4 -3
- package/lib/commonjs/components/MediaMessageItem.js.map +1 -1
- package/lib/commonjs/components/MediaPickerButton.js +211 -14
- package/lib/commonjs/components/MediaPickerButton.js.map +1 -1
- package/lib/commonjs/components/MediaViewerModal.js +7 -0
- package/lib/commonjs/components/MediaViewerModal.js.map +1 -1
- package/lib/commonjs/components/MessageInput.js +63 -13
- package/lib/commonjs/components/MessageInput.js.map +1 -1
- package/lib/commonjs/components/MessageItem.js +1 -2
- package/lib/commonjs/components/MessageItem.js.map +1 -1
- package/lib/commonjs/constants/translations.js +87 -116
- package/lib/commonjs/constants/translations.js.map +1 -1
- package/lib/commonjs/hooks/usePolling.js +25 -21
- package/lib/commonjs/hooks/usePolling.js.map +1 -1
- package/lib/commonjs/hooks/useThemeColors.js +12 -1
- package/lib/commonjs/hooks/useThemeColors.js.map +1 -1
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/notifications/initializeNotifications.js +19 -16
- package/lib/commonjs/notifications/initializeNotifications.js.map +1 -1
- package/lib/commonjs/register/Accumulator.js +19 -6
- package/lib/commonjs/register/Accumulator.js.map +1 -1
- package/lib/commonjs/register/collectData.js +1 -1
- package/lib/commonjs/register/collectData.js.map +1 -1
- package/lib/commonjs/store/store.js +6 -0
- package/lib/commonjs/store/store.js.map +1 -1
- package/lib/commonjs/support/ComnyxSupport.js +60 -15
- package/lib/commonjs/support/ComnyxSupport.js.map +1 -1
- package/lib/commonjs/support/SupportConfigContext.js +24 -0
- package/lib/commonjs/support/SupportConfigContext.js.map +1 -0
- package/lib/commonjs/types/Theme.js +30 -2
- package/lib/commonjs/types/Theme.js.map +1 -1
- package/lib/commonjs/version.js +1 -1
- package/lib/module/NativeComnyxMediaPicker.js +43 -6
- package/lib/module/NativeComnyxMediaPicker.js.map +1 -1
- package/lib/module/api/conversations.js +6 -6
- package/lib/module/api/conversations.js.map +1 -1
- package/lib/module/api/customers.js +3 -2
- package/lib/module/api/customers.js.map +1 -1
- package/lib/module/api/media.js +21 -6
- package/lib/module/api/media.js.map +1 -1
- package/lib/module/api/messages.js +3 -2
- package/lib/module/api/messages.js.map +1 -1
- package/lib/module/assets/gallery.png +0 -0
- package/lib/module/assets/video-play.png +0 -0
- package/lib/module/components/ChatList.js +94 -46
- package/lib/module/components/ChatList.js.map +1 -1
- package/lib/module/components/ComnyxErrorBoundary.js +87 -0
- package/lib/module/components/ComnyxErrorBoundary.js.map +1 -0
- package/lib/module/components/CustomerForm.js +2 -2
- package/lib/module/components/CustomerForm.js.map +1 -1
- package/lib/module/components/MediaMessageItem.js +4 -3
- package/lib/module/components/MediaMessageItem.js.map +1 -1
- package/lib/module/components/MediaPickerButton.js +215 -18
- package/lib/module/components/MediaPickerButton.js.map +1 -1
- package/lib/module/components/MediaViewerModal.js +8 -1
- package/lib/module/components/MediaViewerModal.js.map +1 -1
- package/lib/module/components/MessageInput.js +64 -14
- package/lib/module/components/MessageInput.js.map +1 -1
- package/lib/module/components/MessageItem.js +1 -2
- package/lib/module/components/MessageItem.js.map +1 -1
- package/lib/module/constants/translations.js +87 -116
- package/lib/module/constants/translations.js.map +1 -1
- package/lib/module/hooks/usePolling.js +25 -21
- package/lib/module/hooks/usePolling.js.map +1 -1
- package/lib/module/hooks/useThemeColors.js +13 -2
- package/lib/module/hooks/useThemeColors.js.map +1 -1
- package/lib/module/index.js +0 -1
- package/lib/module/index.js.map +1 -1
- package/lib/module/notifications/initializeNotifications.js +19 -16
- package/lib/module/notifications/initializeNotifications.js.map +1 -1
- package/lib/module/register/Accumulator.js +19 -6
- package/lib/module/register/Accumulator.js.map +1 -1
- package/lib/module/register/collectData.js +1 -1
- package/lib/module/register/collectData.js.map +1 -1
- package/lib/module/store/store.js +6 -0
- package/lib/module/store/store.js.map +1 -1
- package/lib/module/support/ComnyxSupport.js +61 -16
- package/lib/module/support/ComnyxSupport.js.map +1 -1
- package/lib/module/support/SupportConfigContext.js +19 -0
- package/lib/module/support/SupportConfigContext.js.map +1 -0
- package/lib/module/types/Theme.js +30 -2
- package/lib/module/types/Theme.js.map +1 -1
- package/lib/module/version.js +1 -1
- package/lib/typescript/src/NativeComnyxMediaPicker.d.ts +11 -0
- package/lib/typescript/src/NativeComnyxMediaPicker.d.ts.map +1 -1
- package/lib/typescript/src/api/conversations.d.ts +2 -2
- package/lib/typescript/src/api/conversations.d.ts.map +1 -1
- package/lib/typescript/src/api/customers.d.ts +1 -1
- package/lib/typescript/src/api/customers.d.ts.map +1 -1
- package/lib/typescript/src/api/media.d.ts +3 -3
- package/lib/typescript/src/api/media.d.ts.map +1 -1
- package/lib/typescript/src/api/messages.d.ts +1 -1
- package/lib/typescript/src/api/messages.d.ts.map +1 -1
- package/lib/typescript/src/components/ChatList.d.ts.map +1 -1
- package/lib/typescript/src/components/ComnyxErrorBoundary.d.ts +18 -0
- package/lib/typescript/src/components/ComnyxErrorBoundary.d.ts.map +1 -0
- package/lib/typescript/src/components/MediaMessageItem.d.ts.map +1 -1
- package/lib/typescript/src/components/MediaPickerButton.d.ts.map +1 -1
- package/lib/typescript/src/components/MediaViewerModal.d.ts.map +1 -1
- package/lib/typescript/src/components/MessageInput.d.ts.map +1 -1
- package/lib/typescript/src/components/MessageItem.d.ts.map +1 -1
- package/lib/typescript/src/constants/translations.d.ts.map +1 -1
- package/lib/typescript/src/hooks/usePolling.d.ts.map +1 -1
- package/lib/typescript/src/hooks/useThemeColors.d.ts.map +1 -1
- package/lib/typescript/src/index.d.ts +2 -0
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/lib/typescript/src/notifications/initializeNotifications.d.ts.map +1 -1
- package/lib/typescript/src/register/Accumulator.d.ts.map +1 -1
- package/lib/typescript/src/register/collectData.d.ts +4 -1
- package/lib/typescript/src/register/collectData.d.ts.map +1 -1
- package/lib/typescript/src/store/store.d.ts +6 -2
- package/lib/typescript/src/store/store.d.ts.map +1 -1
- package/lib/typescript/src/support/ComnyxSupport.d.ts +56 -2
- package/lib/typescript/src/support/ComnyxSupport.d.ts.map +1 -1
- package/lib/typescript/src/support/SupportConfigContext.d.ts +58 -0
- package/lib/typescript/src/support/SupportConfigContext.d.ts.map +1 -0
- package/lib/typescript/src/support/index.d.ts +1 -0
- package/lib/typescript/src/support/index.d.ts.map +1 -1
- package/lib/typescript/src/types/Conversation.d.ts +2 -2
- package/lib/typescript/src/types/Conversation.d.ts.map +1 -1
- package/lib/typescript/src/types/Customer.d.ts +1 -1
- package/lib/typescript/src/types/Customer.d.ts.map +1 -1
- package/lib/typescript/src/types/LocalizationKeys.d.ts +0 -1
- package/lib/typescript/src/types/LocalizationKeys.d.ts.map +1 -1
- package/lib/typescript/src/types/MessageResponse.d.ts +7 -4
- package/lib/typescript/src/types/MessageResponse.d.ts.map +1 -1
- package/lib/typescript/src/types/Theme.d.ts +26 -0
- package/lib/typescript/src/types/Theme.d.ts.map +1 -1
- package/lib/typescript/src/version.d.ts +1 -1
- package/package.json +12 -25
- package/src/NativeComnyxMediaPicker.ts +46 -7
- package/src/api/conversations.ts +6 -4
- package/src/api/customers.ts +3 -1
- package/src/api/media.ts +32 -10
- package/src/api/messages.ts +3 -1
- package/src/assets/gallery.png +0 -0
- package/src/assets/video-play.png +0 -0
- package/src/components/ChatList.tsx +115 -55
- package/src/components/ComnyxErrorBoundary.tsx +91 -0
- package/src/components/CustomerForm.tsx +2 -2
- package/src/components/MediaMessageItem.tsx +10 -3
- package/src/components/MediaPickerButton.tsx +238 -17
- package/src/components/MediaViewerModal.tsx +8 -1
- package/src/components/MessageInput.tsx +89 -16
- package/src/components/MessageItem.tsx +12 -14
- package/src/constants/translations.ts +87 -116
- package/src/hooks/usePolling.ts +21 -11
- package/src/hooks/useThemeColors.ts +11 -2
- package/src/index.ts +12 -0
- package/src/notifications/initializeNotifications.ts +22 -20
- package/src/register/Accumulator.ts +26 -9
- package/src/register/collectData.ts +10 -2
- package/src/store/store.ts +11 -3
- package/src/support/ComnyxSupport.tsx +128 -22
- package/src/support/SupportConfigContext.tsx +79 -0
- package/src/support/index.ts +7 -0
- package/src/types/Conversation.ts +2 -2
- package/src/types/Customer.ts +1 -2
- package/src/types/LocalizationKeys.ts +0 -1
- package/src/types/MessageResponse.ts +4 -4
- package/src/types/Theme.ts +38 -0
- package/src/version.ts +1 -1
package/src/store/store.ts
CHANGED
|
@@ -6,6 +6,8 @@ import type { AppConversationMessage } from '../types/Conversation';
|
|
|
6
6
|
import type { LanguageCode } from '../types/Language';
|
|
7
7
|
import type { Customer } from '../types/Customer';
|
|
8
8
|
import type { LocalizationKeys } from '../types/LocalizationKeys';
|
|
9
|
+
import type { GlobalTheme } from '../types/GlobalTheme';
|
|
10
|
+
import type { ThemeOverrideConfig } from '../types/Theme';
|
|
9
11
|
import { mmkvStorage } from '../utils/mmkvStorage';
|
|
10
12
|
|
|
11
13
|
interface AppStoreState {
|
|
@@ -16,7 +18,8 @@ interface AppStoreState {
|
|
|
16
18
|
language: LanguageCode;
|
|
17
19
|
theme: 'light' | 'dark';
|
|
18
20
|
fake: boolean;
|
|
19
|
-
themes:
|
|
21
|
+
themes: GlobalTheme;
|
|
22
|
+
themeOverride: ThemeOverrideConfig;
|
|
20
23
|
firstMessage: AppConversationMessage | null;
|
|
21
24
|
setData: (
|
|
22
25
|
cb: (
|
|
@@ -28,7 +31,8 @@ interface AppStoreState {
|
|
|
28
31
|
setLanguage: (language: LanguageCode) => void;
|
|
29
32
|
setTheme: (theme: 'light' | 'dark') => void;
|
|
30
33
|
setFake: (fake: boolean) => void;
|
|
31
|
-
setThemes: (themes:
|
|
34
|
+
setThemes: (themes: GlobalTheme) => void;
|
|
35
|
+
setThemeOverride: (themeOverride: ThemeOverrideConfig) => void;
|
|
32
36
|
updateBaseDimensions: (config: {
|
|
33
37
|
baseHeight: number;
|
|
34
38
|
baseWidth: number;
|
|
@@ -57,6 +61,7 @@ export const storeCreator: StateCreator<AppStoreState> = (set, get) => ({
|
|
|
57
61
|
theme: 'light',
|
|
58
62
|
fake: false,
|
|
59
63
|
themes: {},
|
|
64
|
+
themeOverride: {},
|
|
60
65
|
firstMessage: null,
|
|
61
66
|
formSubmitted: false,
|
|
62
67
|
setData: (cb) => {
|
|
@@ -81,9 +86,12 @@ export const storeCreator: StateCreator<AppStoreState> = (set, get) => ({
|
|
|
81
86
|
setFake: (fake: boolean) => {
|
|
82
87
|
set({ fake });
|
|
83
88
|
},
|
|
84
|
-
setThemes: (themes:
|
|
89
|
+
setThemes: (themes: GlobalTheme) => {
|
|
85
90
|
set({ themes });
|
|
86
91
|
},
|
|
92
|
+
setThemeOverride: (themeOverride: ThemeOverrideConfig) => {
|
|
93
|
+
set({ themeOverride });
|
|
94
|
+
},
|
|
87
95
|
updateBaseDimensions: ({ baseWidth, baseHeight }) => {
|
|
88
96
|
set({ baseWidth, baseHeight });
|
|
89
97
|
},
|
|
@@ -5,35 +5,100 @@ import {
|
|
|
5
5
|
type ViewStyle,
|
|
6
6
|
type StyleProp,
|
|
7
7
|
} from 'react-native';
|
|
8
|
+
import { useSafeAreaInsets } from 'react-native-safe-area-context';
|
|
8
9
|
import { ChatList } from '../components/ChatList';
|
|
9
10
|
import { CustomerForm } from '../components/CustomerForm';
|
|
10
11
|
import type { LanguageCode } from '../types/Language';
|
|
11
|
-
import {
|
|
12
|
+
import type { GlobalTheme } from '../types/GlobalTheme';
|
|
13
|
+
import type { ThemeOverrideConfig } from '../types/Theme';
|
|
14
|
+
import { useEffect, useMemo, useState, type ReactElement } from 'react';
|
|
12
15
|
import { AppText } from '../components/AppText';
|
|
13
16
|
import { useThemeColors } from '../hooks/useThemeColors';
|
|
14
17
|
import { usePolling } from '../hooks/usePolling';
|
|
15
18
|
import { useAppStore } from '../store/store';
|
|
16
19
|
import { ScaledSheet } from '../components/ScaledSheet';
|
|
17
20
|
import { accumulator } from '../register/Accumulator';
|
|
21
|
+
import {
|
|
22
|
+
SupportConfigProvider,
|
|
23
|
+
type SupportConfig,
|
|
24
|
+
} from './SupportConfigContext';
|
|
25
|
+
import { ComnyxErrorBoundary } from '../components/ComnyxErrorBoundary';
|
|
18
26
|
const closeIcon = require('../assets/x-close.png');
|
|
19
27
|
|
|
20
28
|
interface SupportComnyxProps {
|
|
29
|
+
/** Language code used for localised UI strings. Defaults to `'en'`. */
|
|
21
30
|
language?: LanguageCode;
|
|
31
|
+
/** Colour palette mode. Defaults to `'dark'`. */
|
|
22
32
|
theme?: 'light' | 'dark';
|
|
33
|
+
/** Render the chat in fake/demo mode (no network). */
|
|
23
34
|
fake?: boolean;
|
|
35
|
+
/** Called when the user taps the close button. */
|
|
24
36
|
onBack: () => void;
|
|
25
|
-
|
|
37
|
+
/**
|
|
38
|
+
* Font-family provider. Shape: `{ family: (languageCode) => FamilyWeight }`.
|
|
39
|
+
* Not related to colour theming — use `themeOverride` for colours.
|
|
40
|
+
*/
|
|
41
|
+
themes?: GlobalTheme;
|
|
42
|
+
/**
|
|
43
|
+
* Partial override for the built-in colour palette. Only the tokens you
|
|
44
|
+
* specify are replaced; the rest fall back to the default light/dark theme.
|
|
45
|
+
*
|
|
46
|
+
* @example
|
|
47
|
+
* <ComnyxSupport
|
|
48
|
+
* themeOverride={{
|
|
49
|
+
* light: { primary: '#FF6B6B', link: '#FF9999' },
|
|
50
|
+
* dark: { primary: '#FF9999' },
|
|
51
|
+
* }}
|
|
52
|
+
* />
|
|
53
|
+
*/
|
|
54
|
+
themeOverride?: ThemeOverrideConfig;
|
|
55
|
+
/**
|
|
56
|
+
* @deprecated No longer consumed. Kept for backward compatibility and will
|
|
57
|
+
* be removed in a future major release.
|
|
58
|
+
*/
|
|
26
59
|
rtlFix?: boolean;
|
|
60
|
+
/** Additional style merged onto the root container. */
|
|
27
61
|
containerStyle?: StyleProp<ViewStyle>;
|
|
62
|
+
/**
|
|
63
|
+
* Replace the built-in header. Receives `{ onBack }`. Return `null` to hide
|
|
64
|
+
* the header entirely.
|
|
65
|
+
*/
|
|
66
|
+
renderHeader?: SupportConfig['renderHeader'];
|
|
67
|
+
/** Replace the built-in empty-state card shown when there are no messages. */
|
|
68
|
+
renderEmptyState?: SupportConfig['renderEmptyState'];
|
|
69
|
+
/**
|
|
70
|
+
* Replace the built-in init-failed screen. Receives `{ retry }` to trigger a
|
|
71
|
+
* first-page refetch.
|
|
72
|
+
*/
|
|
73
|
+
renderErrorState?: SupportConfig['renderErrorState'];
|
|
74
|
+
/**
|
|
75
|
+
* Wrap or replace individual message bubbles. Receives
|
|
76
|
+
* `{ message, defaultNode }` — return `defaultNode` as-is for no change,
|
|
77
|
+
* wrap it for decorations (reactions, swipe actions), or render a fully
|
|
78
|
+
* custom bubble.
|
|
79
|
+
*/
|
|
80
|
+
renderMessage?: SupportConfig['renderMessage'];
|
|
81
|
+
/**
|
|
82
|
+
* Called immediately before a message is dispatched. Throw or reject to
|
|
83
|
+
* cancel the send — the user's input and any pending media are preserved.
|
|
84
|
+
* Use for analytics, rate limiting, moderation or injecting extra context.
|
|
85
|
+
*/
|
|
86
|
+
onBeforeSend?: SupportConfig['onBeforeSend'];
|
|
28
87
|
}
|
|
29
88
|
|
|
30
|
-
|
|
89
|
+
function ComnyxSupportInner({
|
|
31
90
|
language = 'en',
|
|
32
91
|
theme = 'dark',
|
|
33
92
|
fake = false,
|
|
34
93
|
onBack,
|
|
35
94
|
themes,
|
|
95
|
+
themeOverride,
|
|
36
96
|
containerStyle,
|
|
97
|
+
renderHeader,
|
|
98
|
+
renderEmptyState,
|
|
99
|
+
renderErrorState,
|
|
100
|
+
renderMessage,
|
|
101
|
+
onBeforeSend,
|
|
37
102
|
}: SupportComnyxProps) {
|
|
38
103
|
const { customer, formSubmitted } = useAppStore((s) => ({
|
|
39
104
|
customer: s.customer,
|
|
@@ -41,15 +106,39 @@ export function ComnyxSupport({
|
|
|
41
106
|
}));
|
|
42
107
|
const [initLoading, setInitLoading] = useState(true);
|
|
43
108
|
const themeColors = useThemeColors();
|
|
109
|
+
const insets = useSafeAreaInsets();
|
|
44
110
|
usePolling();
|
|
45
111
|
|
|
112
|
+
const supportConfig = useMemo<SupportConfig>(
|
|
113
|
+
() => ({
|
|
114
|
+
renderHeader,
|
|
115
|
+
renderEmptyState,
|
|
116
|
+
renderErrorState,
|
|
117
|
+
renderMessage,
|
|
118
|
+
onBeforeSend,
|
|
119
|
+
}),
|
|
120
|
+
[
|
|
121
|
+
renderHeader,
|
|
122
|
+
renderEmptyState,
|
|
123
|
+
renderErrorState,
|
|
124
|
+
renderMessage,
|
|
125
|
+
onBeforeSend,
|
|
126
|
+
]
|
|
127
|
+
);
|
|
128
|
+
|
|
46
129
|
useEffect(() => {
|
|
47
130
|
if (!accumulator.isListenerCalledOnce()) {
|
|
48
|
-
accumulator
|
|
49
|
-
|
|
131
|
+
accumulator
|
|
132
|
+
.flush()
|
|
133
|
+
.then(() => {
|
|
134
|
+
setTimeout(() => {
|
|
135
|
+
setInitLoading(false);
|
|
136
|
+
}, 100);
|
|
137
|
+
})
|
|
138
|
+
.catch((err) => {
|
|
139
|
+
console.error('[Comnyx] accumulator.flush failed', err);
|
|
50
140
|
setInitLoading(false);
|
|
51
|
-
}
|
|
52
|
-
});
|
|
141
|
+
});
|
|
53
142
|
} else {
|
|
54
143
|
setInitLoading(false);
|
|
55
144
|
}
|
|
@@ -62,25 +151,31 @@ export function ComnyxSupport({
|
|
|
62
151
|
}, [customer, customer?.external_id]);
|
|
63
152
|
|
|
64
153
|
useEffect(() => {
|
|
65
|
-
//TOOD: getState().initApp({language,theme,fake,rtlFix,themes})
|
|
66
154
|
useAppStore.getState().setLanguage(language);
|
|
67
155
|
useAppStore.getState().setTheme(theme);
|
|
68
156
|
useAppStore.getState().setFake(fake);
|
|
69
157
|
if (themes) {
|
|
70
158
|
useAppStore.getState().setThemes(themes);
|
|
71
159
|
}
|
|
72
|
-
|
|
160
|
+
if (themeOverride) {
|
|
161
|
+
useAppStore.getState().setThemeOverride(themeOverride);
|
|
162
|
+
}
|
|
163
|
+
}, [language, theme, fake, themes, themeOverride]);
|
|
73
164
|
|
|
165
|
+
let body: ReactElement;
|
|
74
166
|
if (!customer) {
|
|
75
167
|
//NOTE: customer yoksa register hiç çalışmamış
|
|
76
|
-
|
|
168
|
+
body = (
|
|
77
169
|
<View
|
|
78
170
|
style={[styles.container, { backgroundColor: themeColors.background }]}
|
|
79
171
|
>
|
|
80
172
|
<TouchableOpacity
|
|
81
173
|
activeOpacity={1}
|
|
82
|
-
style={[styles.iconContainer]}
|
|
174
|
+
style={[styles.iconContainer, { top: Math.max(insets.top, 16) + 16 }]}
|
|
83
175
|
onPress={onBack}
|
|
176
|
+
accessibilityRole="button"
|
|
177
|
+
accessibilityLabel="Close support"
|
|
178
|
+
hitSlop={{ top: 12, bottom: 12, left: 12, right: 12 }}
|
|
84
179
|
>
|
|
85
180
|
<Image
|
|
86
181
|
source={closeIcon}
|
|
@@ -95,25 +190,37 @@ export function ComnyxSupport({
|
|
|
95
190
|
);
|
|
96
191
|
} else if (!formSubmitted) {
|
|
97
192
|
//NOTE: customer var ama forSubmitted false (name===null)
|
|
98
|
-
|
|
193
|
+
body = (
|
|
99
194
|
<CustomerForm
|
|
100
195
|
loading={initLoading}
|
|
101
196
|
onBack={onBack}
|
|
102
197
|
containerStyle={containerStyle}
|
|
103
198
|
/>
|
|
104
199
|
);
|
|
200
|
+
} else {
|
|
201
|
+
body = (
|
|
202
|
+
<View
|
|
203
|
+
style={[
|
|
204
|
+
styles.container,
|
|
205
|
+
{ backgroundColor: themeColors.background },
|
|
206
|
+
containerStyle,
|
|
207
|
+
]}
|
|
208
|
+
>
|
|
209
|
+
<ChatList initLoading={initLoading} onBack={onBack} />
|
|
210
|
+
</View>
|
|
211
|
+
);
|
|
105
212
|
}
|
|
106
213
|
|
|
107
214
|
return (
|
|
108
|
-
<
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
>
|
|
115
|
-
<
|
|
116
|
-
</
|
|
215
|
+
<SupportConfigProvider value={supportConfig}>{body}</SupportConfigProvider>
|
|
216
|
+
);
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
export function ComnyxSupport(props: SupportComnyxProps) {
|
|
220
|
+
return (
|
|
221
|
+
<ComnyxErrorBoundary onBack={props.onBack}>
|
|
222
|
+
<ComnyxSupportInner {...props} />
|
|
223
|
+
</ComnyxErrorBoundary>
|
|
117
224
|
);
|
|
118
225
|
}
|
|
119
226
|
|
|
@@ -124,7 +231,6 @@ const styles = ScaledSheet.create({
|
|
|
124
231
|
},
|
|
125
232
|
iconContainer: {
|
|
126
233
|
position: 'absolute',
|
|
127
|
-
top: '60@vs',
|
|
128
234
|
left: '24@s',
|
|
129
235
|
},
|
|
130
236
|
closeIcon: {
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { createContext, useContext, type ReactNode } from 'react';
|
|
2
|
+
import type { AppConversationMessage } from '../types/Conversation';
|
|
3
|
+
|
|
4
|
+
export interface SupportHeaderRenderProps {
|
|
5
|
+
/** Invoke to close the support screen — same callback passed to `onBack`. */
|
|
6
|
+
onBack?: () => void;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export interface SupportErrorRenderProps {
|
|
10
|
+
/** Trigger a retry. Safe to call multiple times. */
|
|
11
|
+
retry: () => void;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export interface SupportMessageRenderProps {
|
|
15
|
+
message: AppConversationMessage;
|
|
16
|
+
/** The built-in bubble node — render it as-is, wrap it, or ignore it. */
|
|
17
|
+
defaultNode: ReactNode;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export interface SupportSendPayload {
|
|
21
|
+
/** Plain text content the user is sending. Empty when only media is attached. */
|
|
22
|
+
content: string;
|
|
23
|
+
/** Number of media attachments. 0 for text-only messages. */
|
|
24
|
+
mediaCount: number;
|
|
25
|
+
/** Types of the attached media. Empty for text-only messages. */
|
|
26
|
+
mediaTypes: Array<'image' | 'video'>;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export interface SupportConfig {
|
|
30
|
+
/**
|
|
31
|
+
* Replace the built-in top header (close button + "Support team / Live" row).
|
|
32
|
+
* Return any React node; returning `null` hides the header entirely.
|
|
33
|
+
*/
|
|
34
|
+
renderHeader?: (props: SupportHeaderRenderProps) => ReactNode;
|
|
35
|
+
/** Replace the built-in empty-state card shown when there are no messages. */
|
|
36
|
+
renderEmptyState?: () => ReactNode;
|
|
37
|
+
/**
|
|
38
|
+
* Replace the built-in init-failed screen. The `retry` callback re-runs the
|
|
39
|
+
* first-page fetch.
|
|
40
|
+
*/
|
|
41
|
+
renderErrorState?: (props: SupportErrorRenderProps) => ReactNode;
|
|
42
|
+
/**
|
|
43
|
+
* Replace or wrap individual message bubbles. `defaultNode` is the
|
|
44
|
+
* built-in `<MessageItem />` — return it for no change, wrap it to add
|
|
45
|
+
* decorations (reactions, swipe actions), or substitute a fully custom
|
|
46
|
+
* bubble.
|
|
47
|
+
*/
|
|
48
|
+
renderMessage?: (props: SupportMessageRenderProps) => ReactNode;
|
|
49
|
+
/**
|
|
50
|
+
* Called immediately before a message is dispatched to the backend. Throw
|
|
51
|
+
* (or reject the returned promise) to cancel the send — the user's input
|
|
52
|
+
* and any pending media are preserved and the UI re-enables.
|
|
53
|
+
*
|
|
54
|
+
* Use for analytics, rate limiting, moderation, or injecting extra context.
|
|
55
|
+
*/
|
|
56
|
+
onBeforeSend?: (payload: SupportSendPayload) => void | Promise<void>;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
const EMPTY_CONFIG: SupportConfig = {};
|
|
60
|
+
|
|
61
|
+
const SupportConfigContext = createContext<SupportConfig>(EMPTY_CONFIG);
|
|
62
|
+
|
|
63
|
+
export function SupportConfigProvider({
|
|
64
|
+
value,
|
|
65
|
+
children,
|
|
66
|
+
}: {
|
|
67
|
+
value: SupportConfig;
|
|
68
|
+
children: ReactNode;
|
|
69
|
+
}) {
|
|
70
|
+
return (
|
|
71
|
+
<SupportConfigContext.Provider value={value}>
|
|
72
|
+
{children}
|
|
73
|
+
</SupportConfigContext.Provider>
|
|
74
|
+
);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
export function useSupportConfig(): SupportConfig {
|
|
78
|
+
return useContext(SupportConfigContext);
|
|
79
|
+
}
|
package/src/support/index.ts
CHANGED
|
@@ -2,8 +2,8 @@ export interface ConversationMessage {
|
|
|
2
2
|
id: number;
|
|
3
3
|
content: string;
|
|
4
4
|
created_at: string;
|
|
5
|
-
user?:
|
|
6
|
-
bot?:
|
|
5
|
+
user?: unknown | null;
|
|
6
|
+
bot?: unknown | null;
|
|
7
7
|
customer?: { name: string; profile_photo_url: null } | null;
|
|
8
8
|
files?: Array<{
|
|
9
9
|
id: number;
|
package/src/types/Customer.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
export interface CustomParameter {
|
|
2
2
|
name: string;
|
|
3
|
-
|
|
4
|
-
value: any;
|
|
3
|
+
value: string | number | boolean | null;
|
|
5
4
|
}
|
|
6
5
|
|
|
7
6
|
export interface OneSignalIntegrationParameters {
|
|
@@ -6,9 +6,9 @@ export interface MessageResponse {
|
|
|
6
6
|
updated_at: string;
|
|
7
7
|
created_at: string;
|
|
8
8
|
id: number;
|
|
9
|
-
user: null |
|
|
10
|
-
customer: null |
|
|
11
|
-
bot: null |
|
|
9
|
+
user: null | unknown;
|
|
10
|
+
customer: null | { name: string; profile_photo_url: null };
|
|
11
|
+
bot: null | unknown;
|
|
12
12
|
conversation: {
|
|
13
13
|
id: number;
|
|
14
14
|
project_id: number;
|
|
@@ -55,6 +55,6 @@ export interface MessageResponse {
|
|
|
55
55
|
};
|
|
56
56
|
};
|
|
57
57
|
};
|
|
58
|
-
events:
|
|
58
|
+
events: unknown[];
|
|
59
59
|
};
|
|
60
60
|
}
|
package/src/types/Theme.ts
CHANGED
|
@@ -18,6 +18,11 @@ export interface ThemeColors {
|
|
|
18
18
|
navy: string;
|
|
19
19
|
lavender: string;
|
|
20
20
|
silver: string;
|
|
21
|
+
link: string;
|
|
22
|
+
toastBackground: string;
|
|
23
|
+
toastText: string;
|
|
24
|
+
playIcon: string;
|
|
25
|
+
videoPlaceholder: string;
|
|
21
26
|
}
|
|
22
27
|
|
|
23
28
|
export const lightTheme: ThemeColors = {
|
|
@@ -40,6 +45,11 @@ export const lightTheme: ThemeColors = {
|
|
|
40
45
|
navy: '#191A21',
|
|
41
46
|
lavender: '#E0E0E0',
|
|
42
47
|
silver: '#C7C7C7',
|
|
48
|
+
link: '#0066CC',
|
|
49
|
+
toastBackground: '#333333',
|
|
50
|
+
toastText: '#FFFFFF',
|
|
51
|
+
playIcon: '#FFFFFF',
|
|
52
|
+
videoPlaceholder: '#1A1A2E',
|
|
43
53
|
};
|
|
44
54
|
|
|
45
55
|
export const darkTheme: ThemeColors = {
|
|
@@ -62,9 +72,37 @@ export const darkTheme: ThemeColors = {
|
|
|
62
72
|
navy: '#F5F5F5',
|
|
63
73
|
lavender: '#262730',
|
|
64
74
|
silver: '#44454D',
|
|
75
|
+
link: '#4D9FFF',
|
|
76
|
+
toastBackground: '#2A2A2A',
|
|
77
|
+
toastText: '#FFFFFF',
|
|
78
|
+
playIcon: '#FFFFFF',
|
|
79
|
+
videoPlaceholder: '#1A1A2E',
|
|
65
80
|
};
|
|
66
81
|
|
|
67
82
|
export interface Theme {
|
|
68
83
|
light: ThemeColors;
|
|
69
84
|
dark: ThemeColors;
|
|
70
85
|
}
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* Partial override for a single theme mode. Consumers can change one or more
|
|
89
|
+
* tokens without redeclaring the whole palette.
|
|
90
|
+
*/
|
|
91
|
+
export type ThemeColorsOverride = Partial<ThemeColors>;
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* Full override map accepted by `ComnyxSupport.themeOverride`. Any token not
|
|
95
|
+
* provided falls back to the built-in light/dark palette.
|
|
96
|
+
*
|
|
97
|
+
* @example
|
|
98
|
+
* <ComnyxSupport
|
|
99
|
+
* themeOverride={{
|
|
100
|
+
* light: { primary: '#FF6B6B', link: '#FF9999' },
|
|
101
|
+
* dark: { primary: '#FF9999' },
|
|
102
|
+
* }}
|
|
103
|
+
* />
|
|
104
|
+
*/
|
|
105
|
+
export interface ThemeOverrideConfig {
|
|
106
|
+
light?: ThemeColorsOverride;
|
|
107
|
+
dark?: ThemeColorsOverride;
|
|
108
|
+
}
|
package/src/version.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// This file is auto-generated. Do not edit manually.
|
|
2
|
-
export const VERSION = '0.
|
|
2
|
+
export const VERSION = '0.16.0';
|