@usechat/react-native 1.0.13 → 1.0.15

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.mts CHANGED
@@ -496,6 +496,136 @@ interface MessageListRef {
496
496
  scrollToIndex: (index: number, animated?: boolean) => void;
497
497
  }
498
498
 
499
+ /**
500
+ * Translation keys for the chat SDK
501
+ * These keys define all user-facing text that can be translated
502
+ */
503
+ interface TranslationKeys {
504
+ 'input.placeholder': string;
505
+ 'search.placeholder': string;
506
+ 'status.online': string;
507
+ 'status.offline': string;
508
+ 'status.typing': string;
509
+ 'message.deleted': string;
510
+ 'message.sending': string;
511
+ 'message.sent': string;
512
+ 'message.delivered': string;
513
+ 'message.read': string;
514
+ 'message.failed': string;
515
+ 'action.reply': string;
516
+ 'action.copy': string;
517
+ 'action.delete': string;
518
+ 'action.cancel': string;
519
+ 'action.send': string;
520
+ 'action.clear': string;
521
+ 'action.clearAll': string;
522
+ 'attachment.add': string;
523
+ 'attachment.remove': string;
524
+ 'attachment.clear': string;
525
+ 'attachment.attachments': string;
526
+ 'accessibility.back': string;
527
+ 'accessibility.send': string;
528
+ 'accessibility.attach': string;
529
+ 'accessibility.emoji': string;
530
+ 'accessibility.videoCall': string;
531
+ 'accessibility.voiceCall': string;
532
+ 'accessibility.info': string;
533
+ 'accessibility.search': string;
534
+ 'accessibility.typing': string;
535
+ 'error.fileTooLarge': string;
536
+ 'error.invalidFileType': string;
537
+ 'error.maxAttachments': string;
538
+ 'error.networkError': string;
539
+ 'time.justNow': string;
540
+ 'time.minutesAgo': string;
541
+ 'time.hoursAgo': string;
542
+ 'time.daysAgo': string;
543
+ 'time.weeksAgo': string;
544
+ 'time.monthsAgo': string;
545
+ 'time.yearsAgo': string;
546
+ 'date.today': string;
547
+ 'date.yesterday': string;
548
+ 'date.todayWithTime': string;
549
+ 'date.yesterdayWithTime': string;
550
+ }
551
+ /**
552
+ * Supported locales
553
+ */
554
+ type SupportedLocale = 'en' | 'pl';
555
+ /**
556
+ * Translation function type
557
+ */
558
+ type TranslationFunction = (key: keyof TranslationKeys, params?: Record<string, string | number>) => string;
559
+ /**
560
+ * I18n context value
561
+ */
562
+ interface I18nContextValue {
563
+ t: TranslationFunction;
564
+ locale: SupportedLocale;
565
+ setLocale: (locale: SupportedLocale) => void;
566
+ }
567
+ /**
568
+ * Default i18n configuration
569
+ */
570
+ interface I18nConfig {
571
+ locale: SupportedLocale;
572
+ fallbackLocale: SupportedLocale;
573
+ }
574
+
575
+ /**
576
+ * Props for I18nProvider
577
+ */
578
+ interface I18nProviderProps {
579
+ children: ReactNode;
580
+ locale?: SupportedLocale;
581
+ fallbackLocale?: SupportedLocale;
582
+ }
583
+ /**
584
+ * I18nProvider component that provides translation context
585
+ *
586
+ * @example
587
+ * ```tsx
588
+ * <I18nProvider locale="pl">
589
+ * <Chat messages={messages} />
590
+ * </I18nProvider>
591
+ * ```
592
+ */
593
+ declare const I18nProvider: React__default.FC<I18nProviderProps>;
594
+ /**
595
+ * Hook to use translation context
596
+ *
597
+ * @example
598
+ * ```tsx
599
+ * const { t, locale, setLocale } = useTranslation();
600
+ * const placeholder = t('input.placeholder');
601
+ * ```
602
+ */
603
+ declare const useTranslation: () => I18nContextValue;
604
+ /**
605
+ * Hook to get just the translation function
606
+ * Returns a fallback function if not in I18nProvider context
607
+ *
608
+ * @example
609
+ * ```tsx
610
+ * const t = useTranslationFunction();
611
+ * const placeholder = t('input.placeholder');
612
+ * ```
613
+ */
614
+ declare const useTranslationFunction: () => TranslationFunction;
615
+
616
+ /**
617
+ * All default translations
618
+ */
619
+ declare const defaultTranslations: Record<SupportedLocale, TranslationKeys>;
620
+ /**
621
+ * Get translation for a specific locale
622
+ */
623
+ declare const getTranslation: (locale: SupportedLocale) => TranslationKeys;
624
+ /**
625
+ * Check if a locale is supported
626
+ */
627
+ declare const isSupportedLocale: (locale: string) => locale is SupportedLocale;
628
+
499
629
  interface ChatConfig {
500
630
  keyboardBehavior?: 'padding' | 'height' | 'position';
501
631
  keyboardVerticalOffset?: number;
@@ -510,6 +640,7 @@ interface ChatConfig {
510
640
  interface ChatProviderProps {
511
641
  children: ReactNode;
512
642
  config?: ChatConfig;
643
+ locale?: SupportedLocale;
513
644
  }
514
645
 
515
646
  interface ChatInitConfig {
@@ -660,5 +791,12 @@ declare const useMessageReactions: (config?: MessageListConfig | undefined) => {
660
791
  };
661
792
  declare const useAttachments: (options?: UseAttachmentsOptions | undefined) => UseAttachmentsReturn;
662
793
  declare const useMessageInput: <T = string>(config?: MessageInputConfig<T> | undefined) => UseMessageInputReturn<T>;
794
+ declare const useDateFormatter: () => {
795
+ formatDate: (dateStr: string) => string;
796
+ formatTime: (timestamp: string) => string;
797
+ formatRelative: (timestamp: string) => string;
798
+ formatDateTimeWithTime: (timestamp: string) => string;
799
+ groupMessages: (messages: Message[]) => MessageListItem[];
800
+ };
663
801
 
664
- export { AttachmentMenu, type AttachmentResult, Chat, ChatAvatar, type ChatConfig, ChatHeader, type ChatHeaderProps, type ChatInitConfig, type ChatInitResponse, ChatItem, ChatList, ChatListSearchBar, type ChatListSearchBarProps, type ChatProps, ChatProvider, ChatScreenHeader, type Message$1 as Message, MessageInput, type MessageInputRef, MessageList, type MessageListRef, type Theme, type ThemeBorderRadius, type ThemeColors, ThemeProvider, type ThemeProviderProps, type ThemeSpacing, type ThemeTypography, TypingIndicator, type TypingIndicatorProps, defaultTheme, getAuthState, getProjectId, initChat, isInitialized, useAttachments, useChatConfig, useChatMessages, useChatSDK, useMessageActions, useMessageInput, useMessageList, useMessageReactions, useTheme };
802
+ export { AttachmentMenu, type AttachmentResult, Chat, ChatAvatar, type ChatConfig, ChatHeader, type ChatHeaderProps, type ChatInitConfig, type ChatInitResponse, ChatItem, ChatList, ChatListSearchBar, type ChatListSearchBarProps, type ChatProps, ChatProvider, ChatScreenHeader, type I18nConfig, type I18nContextValue, I18nProvider, type Message$1 as Message, MessageInput, type MessageInputRef, MessageList, type MessageListRef, type SupportedLocale, type Theme, type ThemeBorderRadius, type ThemeColors, ThemeProvider, type ThemeProviderProps, type ThemeSpacing, type ThemeTypography, type TranslationFunction, type TranslationKeys, TypingIndicator, type TypingIndicatorProps, defaultTheme, defaultTranslations, getAuthState, getProjectId, getTranslation, initChat, isInitialized, isSupportedLocale, useAttachments, useChatConfig, useChatMessages, useChatSDK, useDateFormatter, useMessageActions, useMessageInput, useMessageList, useMessageReactions, useTheme, useTranslation, useTranslationFunction };
package/dist/index.d.ts CHANGED
@@ -496,6 +496,136 @@ interface MessageListRef {
496
496
  scrollToIndex: (index: number, animated?: boolean) => void;
497
497
  }
498
498
 
499
+ /**
500
+ * Translation keys for the chat SDK
501
+ * These keys define all user-facing text that can be translated
502
+ */
503
+ interface TranslationKeys {
504
+ 'input.placeholder': string;
505
+ 'search.placeholder': string;
506
+ 'status.online': string;
507
+ 'status.offline': string;
508
+ 'status.typing': string;
509
+ 'message.deleted': string;
510
+ 'message.sending': string;
511
+ 'message.sent': string;
512
+ 'message.delivered': string;
513
+ 'message.read': string;
514
+ 'message.failed': string;
515
+ 'action.reply': string;
516
+ 'action.copy': string;
517
+ 'action.delete': string;
518
+ 'action.cancel': string;
519
+ 'action.send': string;
520
+ 'action.clear': string;
521
+ 'action.clearAll': string;
522
+ 'attachment.add': string;
523
+ 'attachment.remove': string;
524
+ 'attachment.clear': string;
525
+ 'attachment.attachments': string;
526
+ 'accessibility.back': string;
527
+ 'accessibility.send': string;
528
+ 'accessibility.attach': string;
529
+ 'accessibility.emoji': string;
530
+ 'accessibility.videoCall': string;
531
+ 'accessibility.voiceCall': string;
532
+ 'accessibility.info': string;
533
+ 'accessibility.search': string;
534
+ 'accessibility.typing': string;
535
+ 'error.fileTooLarge': string;
536
+ 'error.invalidFileType': string;
537
+ 'error.maxAttachments': string;
538
+ 'error.networkError': string;
539
+ 'time.justNow': string;
540
+ 'time.minutesAgo': string;
541
+ 'time.hoursAgo': string;
542
+ 'time.daysAgo': string;
543
+ 'time.weeksAgo': string;
544
+ 'time.monthsAgo': string;
545
+ 'time.yearsAgo': string;
546
+ 'date.today': string;
547
+ 'date.yesterday': string;
548
+ 'date.todayWithTime': string;
549
+ 'date.yesterdayWithTime': string;
550
+ }
551
+ /**
552
+ * Supported locales
553
+ */
554
+ type SupportedLocale = 'en' | 'pl';
555
+ /**
556
+ * Translation function type
557
+ */
558
+ type TranslationFunction = (key: keyof TranslationKeys, params?: Record<string, string | number>) => string;
559
+ /**
560
+ * I18n context value
561
+ */
562
+ interface I18nContextValue {
563
+ t: TranslationFunction;
564
+ locale: SupportedLocale;
565
+ setLocale: (locale: SupportedLocale) => void;
566
+ }
567
+ /**
568
+ * Default i18n configuration
569
+ */
570
+ interface I18nConfig {
571
+ locale: SupportedLocale;
572
+ fallbackLocale: SupportedLocale;
573
+ }
574
+
575
+ /**
576
+ * Props for I18nProvider
577
+ */
578
+ interface I18nProviderProps {
579
+ children: ReactNode;
580
+ locale?: SupportedLocale;
581
+ fallbackLocale?: SupportedLocale;
582
+ }
583
+ /**
584
+ * I18nProvider component that provides translation context
585
+ *
586
+ * @example
587
+ * ```tsx
588
+ * <I18nProvider locale="pl">
589
+ * <Chat messages={messages} />
590
+ * </I18nProvider>
591
+ * ```
592
+ */
593
+ declare const I18nProvider: React__default.FC<I18nProviderProps>;
594
+ /**
595
+ * Hook to use translation context
596
+ *
597
+ * @example
598
+ * ```tsx
599
+ * const { t, locale, setLocale } = useTranslation();
600
+ * const placeholder = t('input.placeholder');
601
+ * ```
602
+ */
603
+ declare const useTranslation: () => I18nContextValue;
604
+ /**
605
+ * Hook to get just the translation function
606
+ * Returns a fallback function if not in I18nProvider context
607
+ *
608
+ * @example
609
+ * ```tsx
610
+ * const t = useTranslationFunction();
611
+ * const placeholder = t('input.placeholder');
612
+ * ```
613
+ */
614
+ declare const useTranslationFunction: () => TranslationFunction;
615
+
616
+ /**
617
+ * All default translations
618
+ */
619
+ declare const defaultTranslations: Record<SupportedLocale, TranslationKeys>;
620
+ /**
621
+ * Get translation for a specific locale
622
+ */
623
+ declare const getTranslation: (locale: SupportedLocale) => TranslationKeys;
624
+ /**
625
+ * Check if a locale is supported
626
+ */
627
+ declare const isSupportedLocale: (locale: string) => locale is SupportedLocale;
628
+
499
629
  interface ChatConfig {
500
630
  keyboardBehavior?: 'padding' | 'height' | 'position';
501
631
  keyboardVerticalOffset?: number;
@@ -510,6 +640,7 @@ interface ChatConfig {
510
640
  interface ChatProviderProps {
511
641
  children: ReactNode;
512
642
  config?: ChatConfig;
643
+ locale?: SupportedLocale;
513
644
  }
514
645
 
515
646
  interface ChatInitConfig {
@@ -660,5 +791,12 @@ declare const useMessageReactions: (config?: MessageListConfig | undefined) => {
660
791
  };
661
792
  declare const useAttachments: (options?: UseAttachmentsOptions | undefined) => UseAttachmentsReturn;
662
793
  declare const useMessageInput: <T = string>(config?: MessageInputConfig<T> | undefined) => UseMessageInputReturn<T>;
794
+ declare const useDateFormatter: () => {
795
+ formatDate: (dateStr: string) => string;
796
+ formatTime: (timestamp: string) => string;
797
+ formatRelative: (timestamp: string) => string;
798
+ formatDateTimeWithTime: (timestamp: string) => string;
799
+ groupMessages: (messages: Message[]) => MessageListItem[];
800
+ };
663
801
 
664
- export { AttachmentMenu, type AttachmentResult, Chat, ChatAvatar, type ChatConfig, ChatHeader, type ChatHeaderProps, type ChatInitConfig, type ChatInitResponse, ChatItem, ChatList, ChatListSearchBar, type ChatListSearchBarProps, type ChatProps, ChatProvider, ChatScreenHeader, type Message$1 as Message, MessageInput, type MessageInputRef, MessageList, type MessageListRef, type Theme, type ThemeBorderRadius, type ThemeColors, ThemeProvider, type ThemeProviderProps, type ThemeSpacing, type ThemeTypography, TypingIndicator, type TypingIndicatorProps, defaultTheme, getAuthState, getProjectId, initChat, isInitialized, useAttachments, useChatConfig, useChatMessages, useChatSDK, useMessageActions, useMessageInput, useMessageList, useMessageReactions, useTheme };
802
+ export { AttachmentMenu, type AttachmentResult, Chat, ChatAvatar, type ChatConfig, ChatHeader, type ChatHeaderProps, type ChatInitConfig, type ChatInitResponse, ChatItem, ChatList, ChatListSearchBar, type ChatListSearchBarProps, type ChatProps, ChatProvider, ChatScreenHeader, type I18nConfig, type I18nContextValue, I18nProvider, type Message$1 as Message, MessageInput, type MessageInputRef, MessageList, type MessageListRef, type SupportedLocale, type Theme, type ThemeBorderRadius, type ThemeColors, ThemeProvider, type ThemeProviderProps, type ThemeSpacing, type ThemeTypography, type TranslationFunction, type TranslationKeys, TypingIndicator, type TypingIndicatorProps, defaultTheme, defaultTranslations, getAuthState, getProjectId, getTranslation, initChat, isInitialized, isSupportedLocale, useAttachments, useChatConfig, useChatMessages, useChatSDK, useDateFormatter, useMessageActions, useMessageInput, useMessageList, useMessageReactions, useTheme, useTranslation, useTranslationFunction };