@ethora/chat-component-rn 26.5.19 → 26.5.21
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/README.md +40 -0
- package/lib/commonjs/components/MainComponents/ChatHeader.js +15 -2
- package/lib/commonjs/components/MainComponents/ChatHeader.js.map +1 -1
- package/lib/commonjs/components/MessageBubble/Message.js +24 -9
- package/lib/commonjs/components/MessageBubble/Message.js.map +1 -1
- package/lib/commonjs/components/Modals/AttachSheet/AttachSheet.js +11 -7
- package/lib/commonjs/components/Modals/AttachSheet/AttachSheet.js.map +1 -1
- package/lib/commonjs/components/Modals/ChatProfileModal/ChatProfileModal.js +10 -3
- package/lib/commonjs/components/Modals/ChatProfileModal/ChatProfileModal.js.map +1 -1
- package/lib/commonjs/components/Modals/FilePreviewModal/FilePreviewModal.js +23 -5
- package/lib/commonjs/components/Modals/FilePreviewModal/FilePreviewModal.js.map +1 -1
- package/lib/commonjs/components/Modals/ModalHeaderComponent.js +15 -1
- package/lib/commonjs/components/Modals/ModalHeaderComponent.js.map +1 -1
- package/lib/commonjs/components/Modals/styledModalComponents.js +6 -2
- package/lib/commonjs/components/Modals/styledModalComponents.js.map +1 -1
- package/lib/commonjs/components/styled/SendInput.js +34 -9
- package/lib/commonjs/components/styled/SendInput.js.map +1 -1
- package/lib/commonjs/components/styled/StyledComponents.js +6 -2
- package/lib/commonjs/components/styled/StyledComponents.js.map +1 -1
- package/lib/commonjs/components/styled/StyledInputComponents/StyledInputComponents.js +6 -1
- package/lib/commonjs/components/styled/StyledInputComponents/StyledInputComponents.js.map +1 -1
- package/lib/commonjs/helpers/headerLayout.js +35 -0
- package/lib/commonjs/helpers/headerLayout.js.map +1 -0
- package/lib/commonjs/helpers/parseMessageBody.js +12 -5
- package/lib/commonjs/helpers/parseMessageBody.js.map +1 -1
- package/lib/commonjs/helpers/typography.js +28 -0
- package/lib/commonjs/helpers/typography.js.map +1 -0
- package/lib/commonjs/hooks/useChatFonts.js +91 -7
- package/lib/commonjs/hooks/useChatFonts.js.map +1 -1
- package/lib/module/components/MainComponents/ChatHeader.js +15 -2
- package/lib/module/components/MainComponents/ChatHeader.js.map +1 -1
- package/lib/module/components/MessageBubble/Message.js +24 -9
- package/lib/module/components/MessageBubble/Message.js.map +1 -1
- package/lib/module/components/Modals/AttachSheet/AttachSheet.js +11 -7
- package/lib/module/components/Modals/AttachSheet/AttachSheet.js.map +1 -1
- package/lib/module/components/Modals/ChatProfileModal/ChatProfileModal.js +10 -3
- package/lib/module/components/Modals/ChatProfileModal/ChatProfileModal.js.map +1 -1
- package/lib/module/components/Modals/FilePreviewModal/FilePreviewModal.js +24 -6
- package/lib/module/components/Modals/FilePreviewModal/FilePreviewModal.js.map +1 -1
- package/lib/module/components/Modals/ModalHeaderComponent.js +15 -1
- package/lib/module/components/Modals/ModalHeaderComponent.js.map +1 -1
- package/lib/module/components/Modals/styledModalComponents.js +6 -2
- package/lib/module/components/Modals/styledModalComponents.js.map +1 -1
- package/lib/module/components/styled/SendInput.js +35 -10
- package/lib/module/components/styled/SendInput.js.map +1 -1
- package/lib/module/components/styled/StyledComponents.js +6 -2
- package/lib/module/components/styled/StyledComponents.js.map +1 -1
- package/lib/module/components/styled/StyledInputComponents/StyledInputComponents.js +6 -1
- package/lib/module/components/styled/StyledInputComponents/StyledInputComponents.js.map +1 -1
- package/lib/module/helpers/headerLayout.js +30 -0
- package/lib/module/helpers/headerLayout.js.map +1 -0
- package/lib/module/helpers/parseMessageBody.js +12 -5
- package/lib/module/helpers/parseMessageBody.js.map +1 -1
- package/lib/module/helpers/typography.js +23 -0
- package/lib/module/helpers/typography.js.map +1 -0
- package/lib/module/hooks/useChatFonts.js +92 -8
- package/lib/module/hooks/useChatFonts.js.map +1 -1
- package/lib/typescript/components/MainComponents/ChatHeader.d.ts.map +1 -1
- package/lib/typescript/components/MessageBubble/Message.d.ts.map +1 -1
- package/lib/typescript/components/Modals/AttachSheet/AttachSheet.d.ts +0 -3
- package/lib/typescript/components/Modals/AttachSheet/AttachSheet.d.ts.map +1 -1
- package/lib/typescript/components/Modals/ChatProfileModal/ChatProfileModal.d.ts.map +1 -1
- package/lib/typescript/components/Modals/FilePreviewModal/FilePreviewModal.d.ts.map +1 -1
- package/lib/typescript/components/Modals/ModalHeaderComponent.d.ts +3 -0
- package/lib/typescript/components/Modals/ModalHeaderComponent.d.ts.map +1 -1
- package/lib/typescript/components/Modals/styledModalComponents.d.ts +7 -1
- package/lib/typescript/components/Modals/styledModalComponents.d.ts.map +1 -1
- package/lib/typescript/components/styled/SendInput.d.ts.map +1 -1
- package/lib/typescript/components/styled/StyledComponents.d.ts +7 -1
- package/lib/typescript/components/styled/StyledComponents.d.ts.map +1 -1
- package/lib/typescript/components/styled/StyledInputComponents/StyledInputComponents.d.ts +6 -2
- package/lib/typescript/components/styled/StyledInputComponents/StyledInputComponents.d.ts.map +1 -1
- package/lib/typescript/helpers/headerLayout.d.ts +26 -0
- package/lib/typescript/helpers/headerLayout.d.ts.map +1 -0
- package/lib/typescript/helpers/parseMessageBody.d.ts +2 -1
- package/lib/typescript/helpers/parseMessageBody.d.ts.map +1 -1
- package/lib/typescript/helpers/typography.d.ts +14 -0
- package/lib/typescript/helpers/typography.d.ts.map +1 -0
- package/lib/typescript/hooks/useChatFonts.d.ts.map +1 -1
- package/lib/typescript/main.d.ts +1 -1
- package/lib/typescript/main.d.ts.map +1 -1
- package/lib/typescript/types/types.d.ts +82 -47
- package/lib/typescript/types/types.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/components/MainComponents/ChatHeader.tsx +15 -3
- package/src/components/MessageBubble/Message.tsx +27 -11
- package/src/components/Modals/AttachSheet/AttachSheet.tsx +8 -32
- package/src/components/Modals/ChatProfileModal/ChatProfileModal.tsx +16 -7
- package/src/components/Modals/FilePreviewModal/FilePreviewModal.tsx +22 -5
- package/src/components/Modals/ModalHeaderComponent.tsx +20 -3
- package/src/components/Modals/styledModalComponents.tsx +6 -3
- package/src/components/styled/SendInput.tsx +31 -8
- package/src/components/styled/StyledComponents.ts +6 -3
- package/src/components/styled/StyledInputComponents/StyledInputComponents.tsx +4 -1
- package/src/helpers/headerLayout.ts +30 -0
- package/src/helpers/parseMessageBody.tsx +13 -4
- package/src/helpers/typography.ts +19 -0
- package/src/hooks/useChatFonts.ts +69 -11
- package/src/main.ts +1 -0
- package/src/types/types.ts +90 -48
package/src/types/types.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ViewStyle,
|
|
1
|
+
import type { ViewStyle, ImageSourcePropType, TextStyle } from 'react-native';
|
|
2
2
|
import type { Iso639_1Codes } from './models/language.model';
|
|
3
3
|
import type { IMessage, IReply } from './models/message.model';
|
|
4
4
|
import type { RoomMember } from './models/room.model';
|
|
@@ -248,10 +248,31 @@ export interface RNFontSource {
|
|
|
248
248
|
* itself (e.g. via `@expo-google-fonts/*` or its own `useFonts`), pass only
|
|
249
249
|
* `fontFamily` and leave `fonts` empty.
|
|
250
250
|
*/
|
|
251
|
+
/**
|
|
252
|
+
* Per-element font size / weight override.
|
|
253
|
+
*
|
|
254
|
+
* `fontWeight` is honoured even with a custom `fontFamily`: when
|
|
255
|
+
* `weightFamilies` is configured, the chat maps the requested weight to the
|
|
256
|
+
* matching family variant at render time (a single font file can't synthesise
|
|
257
|
+
* 500/600 — only fake-bold ~700 — so the variant family is what actually
|
|
258
|
+
* renders medium/semibold). Omit a field to keep the component default.
|
|
259
|
+
*/
|
|
260
|
+
export interface ChatTextStyle {
|
|
261
|
+
/** Point size. */
|
|
262
|
+
fontSize?: number;
|
|
263
|
+
/** '400' | '500' | '600' | '700' | 'normal' | 'bold' | number. */
|
|
264
|
+
fontWeight?: TextStyle['fontWeight'];
|
|
265
|
+
}
|
|
266
|
+
|
|
251
267
|
export interface TypographyConfig {
|
|
252
268
|
/** Family applied across the chat UI. Must be loaded (via `fonts` or by the host). */
|
|
253
269
|
fontFamily?: string;
|
|
254
|
-
/**
|
|
270
|
+
/**
|
|
271
|
+
* Optional per-weight families. REQUIRED for `fontWeight` overrides to take
|
|
272
|
+
* visible effect when a custom `fontFamily` is set — RN can't synthesise
|
|
273
|
+
* intermediate weights from one font file, so each weight needs its own
|
|
274
|
+
* loaded family (and a matching entry in `fonts`).
|
|
275
|
+
*/
|
|
255
276
|
weightFamilies?: {
|
|
256
277
|
regular?: string;
|
|
257
278
|
medium?: string;
|
|
@@ -260,52 +281,61 @@ export interface TypographyConfig {
|
|
|
260
281
|
};
|
|
261
282
|
/** Fonts for the SDK to load with expo-font before applying `fontFamily`. */
|
|
262
283
|
fonts?: RNFontSource[];
|
|
263
|
-
/** Per-element size / weight overrides. Each entry replaces only the
|
|
264
|
-
* properties it sets; everything else keeps the built-in style. */
|
|
265
|
-
elements?: {
|
|
266
|
-
/** Message body text inside bubbles (default 16). */
|
|
267
|
-
messageText?: ElementFontStyle;
|
|
268
|
-
/** Sender's name above incoming bubbles (default 14 / 500). */
|
|
269
|
-
senderName?: ElementFontStyle;
|
|
270
|
-
/** Room title in the chat header (default 16 / 600). */
|
|
271
|
-
chatHeaderTitle?: ElementFontStyle;
|
|
272
|
-
/** Typed text AND the "Type message" placeholder (default 16).
|
|
273
|
-
* Pair larger sizes with `inputLayout.minHeight` so glyphs aren't
|
|
274
|
-
* clipped vertically. */
|
|
275
|
-
input?: ElementFontStyle;
|
|
276
|
-
/** Room name on the chat-profile screen (default 24 / 400). */
|
|
277
|
-
chatProfileTitle?: ElementFontStyle;
|
|
278
|
-
/** Member names in the chat-profile list (default 16 / 600). */
|
|
279
|
-
chatProfileMemberName?: ElementFontStyle;
|
|
280
|
-
/** "ATTACH" caption of the attachment sheet (default 13 / 600). */
|
|
281
|
-
attachSheetTitle?: ElementFontStyle;
|
|
282
|
-
/** Row labels in the attachment sheet — "Take photo", "Photo or
|
|
283
|
-
* video", "Document" (default 16 / 500). */
|
|
284
|
-
attachSheetRowLabel?: ElementFontStyle;
|
|
285
|
-
/** Row hints under each label (default 12). */
|
|
286
|
-
attachSheetRowHint?: ElementFontStyle;
|
|
287
|
-
/** "Cancel" button of the attachment sheet (default 16 / 600). */
|
|
288
|
-
attachSheetCancel?: ElementFontStyle;
|
|
289
|
-
};
|
|
290
|
-
}
|
|
291
284
|
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
285
|
+
// ----- per-element size / weight overrides -----
|
|
286
|
+
/** Message body text inside chat bubbles. Default 16. */
|
|
287
|
+
messageText?: ChatTextStyle;
|
|
288
|
+
/** Sender name shown above incoming messages. Default 14 / "500". */
|
|
289
|
+
senderName?: ChatTextStyle;
|
|
290
|
+
/** Room title in the chat header. Default 16 / "600". */
|
|
291
|
+
headerTitle?: ChatTextStyle;
|
|
292
|
+
/** Message composer: the input/placeholder text plus its layout sizing. */
|
|
293
|
+
input?: ChatTextStyle & {
|
|
294
|
+
/** Min height of the input box in px. Default 40. */
|
|
295
|
+
minHeight?: number;
|
|
296
|
+
/** Max height before the input scrolls in px. Default 120. */
|
|
297
|
+
maxHeight?: number;
|
|
298
|
+
/** Width & height of the round send button in px. Default 40. */
|
|
299
|
+
sendButtonSize?: number;
|
|
300
|
+
};
|
|
301
|
+
/** Chat profile screen (opens when tapping the room name in the header). */
|
|
302
|
+
profile?: {
|
|
303
|
+
/** The "Chat Profile" bar title at the very top of the profile screen. Default ~system (small). */
|
|
304
|
+
screenTitle?: ChatTextStyle;
|
|
305
|
+
/** Big room-name title at the top of the profile screen. Default 24 / "400". */
|
|
306
|
+
title?: ChatTextStyle;
|
|
307
|
+
/** Member name rows. Default 16 / "600". */
|
|
308
|
+
memberName?: ChatTextStyle;
|
|
309
|
+
};
|
|
310
|
+
/** Attach (photo/document picker) bottom sheet. */
|
|
311
|
+
attachSheet?: {
|
|
312
|
+
/** "Attach" header label. Default 13 / "600". */
|
|
313
|
+
title?: ChatTextStyle;
|
|
314
|
+
/** Row labels (Camera / Gallery / Document). Default 16 / "500". */
|
|
315
|
+
rowLabel?: ChatTextStyle;
|
|
316
|
+
/** Grey hint under each row. Default 12. */
|
|
317
|
+
rowHint?: ChatTextStyle;
|
|
318
|
+
/** Cancel button. Default 16 / "600". */
|
|
319
|
+
cancelButton?: ChatTextStyle;
|
|
320
|
+
};
|
|
297
321
|
|
|
298
|
-
/**
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
322
|
+
/**
|
|
323
|
+
* Generic per-element font overrides addressed by key, applied via the
|
|
324
|
+
* `getElementFont` helper as the highest-priority style layer. These target
|
|
325
|
+
* smaller text elements that don't have a dedicated key above:
|
|
326
|
+
* - `headerSubtitle` — the "N users" / typing line in the chat header
|
|
327
|
+
* - `inputText` — the message composer input (overrides `input`)
|
|
328
|
+
* - `profileStatus` — the "N members" line on the profile screen
|
|
329
|
+
* - `profileSectionLabel` — profile field labels ("Description", "Chat
|
|
330
|
+
* type") and the member last-active line
|
|
331
|
+
* When both this and a dedicated key target the same element, this wins.
|
|
332
|
+
*/
|
|
333
|
+
elements?: Partial<
|
|
334
|
+
Record<
|
|
335
|
+
'headerSubtitle' | 'inputText' | 'profileStatus' | 'profileSectionLabel',
|
|
336
|
+
ChatTextStyle
|
|
337
|
+
>
|
|
338
|
+
>;
|
|
309
339
|
}
|
|
310
340
|
|
|
311
341
|
export interface IConfig {
|
|
@@ -336,8 +366,6 @@ export interface IConfig {
|
|
|
336
366
|
};
|
|
337
367
|
/** Configurable font family / weights for the chat UI. See TypographyConfig. */
|
|
338
368
|
typography?: TypographyConfig;
|
|
339
|
-
/** Input-row geometry (field height, send-button size). See InputLayoutConfig. */
|
|
340
|
-
inputLayout?: InputLayoutConfig;
|
|
341
369
|
messageColor?: {
|
|
342
370
|
backgroundMessage: string;
|
|
343
371
|
backgroundMessageUser: string;
|
|
@@ -352,6 +380,20 @@ export interface IConfig {
|
|
|
352
380
|
headerLogo?: string | React.ReactElement;
|
|
353
381
|
|
|
354
382
|
// ----- header / nav -----
|
|
383
|
+
/**
|
|
384
|
+
* Sizing for BOTH headers (the in-chat header and the full-screen modal
|
|
385
|
+
* headers like Chat Profile), kept in sync so they render at the same
|
|
386
|
+
* visible height.
|
|
387
|
+
*/
|
|
388
|
+
headerLayout?: {
|
|
389
|
+
/**
|
|
390
|
+
* Height in px of the header bar (the band below the status bar).
|
|
391
|
+
* Default 64. Acts as a floor too: values at or below the default are
|
|
392
|
+
* ignored so a too-small number can't collapse the bar — only a larger
|
|
393
|
+
* value takes effect.
|
|
394
|
+
*/
|
|
395
|
+
height?: number;
|
|
396
|
+
};
|
|
355
397
|
disableHeader?: boolean;
|
|
356
398
|
disableMedia?: boolean;
|
|
357
399
|
/**
|