@ethora/chat-component-rn 26.5.19 → 26.5.20
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/lib/commonjs/components/MainComponents/ChatHeader.js +2 -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 +4 -3
- package/lib/commonjs/components/Modals/ChatProfileModal/ChatProfileModal.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 +10 -11
- 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/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 +2 -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 +4 -3
- package/lib/module/components/Modals/ChatProfileModal/ChatProfileModal.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 +10 -11
- 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/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/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/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 +52 -47
- package/lib/typescript/types/types.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/components/MainComponents/ChatHeader.tsx +2 -2
- package/src/components/MessageBubble/Message.tsx +27 -11
- package/src/components/Modals/AttachSheet/AttachSheet.tsx +8 -30
- package/src/components/Modals/ChatProfileModal/ChatProfileModal.tsx +6 -3
- package/src/components/Modals/styledModalComponents.tsx +6 -3
- package/src/components/styled/SendInput.tsx +10 -14
- package/src/components/styled/StyledComponents.ts +6 -3
- package/src/components/styled/StyledInputComponents/StyledInputComponents.tsx +4 -1
- 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 +55 -49
- package/lib/commonjs/helpers/getElementFont.js +0 -29
- package/lib/commonjs/helpers/getElementFont.js.map +0 -1
- package/lib/module/helpers/getElementFont.js +0 -24
- package/lib/module/helpers/getElementFont.js.map +0 -1
- package/lib/typescript/helpers/getElementFont.d.ts +0 -13
- package/lib/typescript/helpers/getElementFont.d.ts.map +0 -1
- package/src/helpers/getElementFont.ts +0 -25
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { useEffect, useState } from 'react';
|
|
2
|
-
import { Text, TextInput } from 'react-native';
|
|
2
|
+
import { StyleSheet, Text, TextInput } from 'react-native';
|
|
3
3
|
import type { TypographyConfig } from '../types/types';
|
|
4
4
|
|
|
5
5
|
/**
|
|
@@ -25,6 +25,8 @@ import type { TypographyConfig } from '../types/types';
|
|
|
25
25
|
export function useChatFonts(typography?: TypographyConfig): boolean {
|
|
26
26
|
const [ready, setReady] = useState(!typography?.fonts?.length);
|
|
27
27
|
|
|
28
|
+
// Apply synchronously on render (not just in the effect) so the factory
|
|
29
|
+
// patch sees the active family/weights before the first child paints.
|
|
28
30
|
applyDefaultFont(typography);
|
|
29
31
|
|
|
30
32
|
useEffect(() => {
|
|
@@ -76,23 +78,78 @@ export function useChatFonts(typography?: TypographyConfig): boolean {
|
|
|
76
78
|
}
|
|
77
79
|
|
|
78
80
|
/**
|
|
79
|
-
* The family currently applied as the chat-wide default. Read at
|
|
80
|
-
* by the patched
|
|
81
|
-
* restyles the whole tree.
|
|
81
|
+
* The family currently applied as the chat-wide default. Read at element-
|
|
82
|
+
* creation time by the patched JSX factories below, so updating it (then
|
|
83
|
+
* triggering a re-render) restyles the whole tree.
|
|
82
84
|
*/
|
|
83
85
|
let activeFamily: string | undefined;
|
|
84
86
|
|
|
87
|
+
/**
|
|
88
|
+
* Per-weight families (regular/medium/semibold/bold). When set, the factory
|
|
89
|
+
* patch maps a Text's effective `fontWeight` to the matching family so custom
|
|
90
|
+
* fonts render intermediate weights correctly — RN can't synthesise 500/600
|
|
91
|
+
* from a single font file (only fake-bold ~700), so each weight needs its own
|
|
92
|
+
* loaded family. This is why a bare `fontWeight: '500'` looked like it did
|
|
93
|
+
* nothing before: there was no medium family to switch to.
|
|
94
|
+
*/
|
|
95
|
+
let activeWeightFamilies: TypographyConfig['weightFamilies'] | undefined;
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* Resolve a desired weight to a configured family variant. Returns undefined
|
|
99
|
+
* when there's no variant for that tier (so we leave the default family /
|
|
100
|
+
* weight untouched rather than guessing).
|
|
101
|
+
*/
|
|
102
|
+
function familyForWeight(weight: unknown): string | undefined {
|
|
103
|
+
const wf = activeWeightFamilies;
|
|
104
|
+
if (!wf || weight == null) {return undefined;}
|
|
105
|
+
let w: number;
|
|
106
|
+
if (typeof weight === 'number') {
|
|
107
|
+
w = weight;
|
|
108
|
+
} else if (weight === 'bold') {
|
|
109
|
+
w = 700;
|
|
110
|
+
} else if (weight === 'normal') {
|
|
111
|
+
w = 400;
|
|
112
|
+
} else {
|
|
113
|
+
const n = parseInt(String(weight), 10);
|
|
114
|
+
w = Number.isFinite(n) ? n : 400;
|
|
115
|
+
}
|
|
116
|
+
if (w >= 700) {return wf.bold;}
|
|
117
|
+
if (w >= 600) {return wf.semibold;}
|
|
118
|
+
if (w >= 500) {return wf.medium;}
|
|
119
|
+
return wf.regular;
|
|
120
|
+
}
|
|
85
121
|
|
|
122
|
+
/**
|
|
123
|
+
* Build the style array for a Text/TextInput element: the default family as the
|
|
124
|
+
* lowest-priority layer (explicit per-component styles still win), and — when
|
|
125
|
+
* per-weight families are configured — the variant family that matches the
|
|
126
|
+
* element's effective `fontWeight` as a top layer (with the numeric weight
|
|
127
|
+
* cleared so the OS doesn't also try to synthesise on top). An explicit
|
|
128
|
+
* per-element `fontFamily` override is respected.
|
|
129
|
+
*/
|
|
130
|
+
function styleForElement(style: any): any {
|
|
131
|
+
const base = [{ fontFamily: activeFamily }, style];
|
|
132
|
+
if (!activeWeightFamilies) {return base;}
|
|
133
|
+
const flat = (StyleSheet.flatten(style) || {}) as any;
|
|
134
|
+
if (flat.fontFamily && flat.fontFamily !== activeFamily) {return base;}
|
|
135
|
+
const fam = familyForWeight(flat.fontWeight);
|
|
136
|
+
if (!fam) {return base;}
|
|
137
|
+
return [{ fontFamily: activeFamily }, style, { fontFamily: fam, fontWeight: 'normal' }];
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
/**
|
|
141
|
+
* Wrap a JSX factory (`jsx`/`jsxs`/`jsxDEV`/`createElement`) so every Text /
|
|
142
|
+
* TextInput it creates gets the chat-wide font injected. We patch the factory
|
|
143
|
+
* rather than `Text.render` because render-wrapping a `forwardRef` component is
|
|
144
|
+
* fragile across React 19 / RN 0.81; intercepting element creation is version-
|
|
145
|
+
* independent and catches styled-components' inner Text elements too.
|
|
146
|
+
*/
|
|
86
147
|
function wrapFactory(orig: any): any {
|
|
87
148
|
if (typeof orig !== 'function') return orig;
|
|
88
149
|
if (orig.__ethoraFontWrapped) return orig;
|
|
89
150
|
const wrapped = function (this: any, type: any, props: any, ...rest: any[]) {
|
|
90
|
-
if (
|
|
91
|
-
|
|
92
|
-
props &&
|
|
93
|
-
(type === Text || type === TextInput)
|
|
94
|
-
) {
|
|
95
|
-
props = { ...props, style: [{ fontFamily: activeFamily }, props.style] };
|
|
151
|
+
if (activeFamily && props && (type === Text || type === TextInput)) {
|
|
152
|
+
props = { ...props, style: styleForElement(props.style) };
|
|
96
153
|
}
|
|
97
154
|
return orig.call(this, type, props, ...rest);
|
|
98
155
|
};
|
|
@@ -145,9 +202,10 @@ function ensurePatched(): void {
|
|
|
145
202
|
}
|
|
146
203
|
|
|
147
204
|
/**
|
|
148
|
-
* Set (or clear) the chat-wide default font family.
|
|
205
|
+
* Set (or clear) the chat-wide default font family + per-weight families.
|
|
149
206
|
*/
|
|
150
207
|
function applyDefaultFont(typography?: TypographyConfig): void {
|
|
151
208
|
activeFamily = typography?.fontFamily;
|
|
209
|
+
activeWeightFamilies = typography?.weightFamilies;
|
|
152
210
|
if (activeFamily) ensurePatched();
|
|
153
211
|
}
|
package/src/main.ts
CHANGED
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,39 @@ 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
|
-
|
|
292
|
-
/** Size/weight override for one chat-UI text element. */
|
|
293
|
-
export interface ElementFontStyle {
|
|
294
|
-
fontSize?: number;
|
|
295
|
-
fontWeight?: TextStyle['fontWeight'];
|
|
296
|
-
}
|
|
297
284
|
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
*/
|
|
302
|
-
|
|
303
|
-
/**
|
|
304
|
-
|
|
305
|
-
/**
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
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
|
+
/** Big room-name title at the top of the profile screen. Default 24 / "400". */
|
|
304
|
+
title?: ChatTextStyle;
|
|
305
|
+
/** Member name rows. Default 16 / "600". */
|
|
306
|
+
memberName?: ChatTextStyle;
|
|
307
|
+
};
|
|
308
|
+
/** Attach (photo/document picker) bottom sheet. */
|
|
309
|
+
attachSheet?: {
|
|
310
|
+
/** "Attach" header label. Default 13 / "600". */
|
|
311
|
+
title?: ChatTextStyle;
|
|
312
|
+
/** Row labels (Camera / Gallery / Document). Default 16 / "500". */
|
|
313
|
+
rowLabel?: ChatTextStyle;
|
|
314
|
+
/** Cancel button. Default 16 / "600". */
|
|
315
|
+
cancelButton?: ChatTextStyle;
|
|
316
|
+
};
|
|
309
317
|
}
|
|
310
318
|
|
|
311
319
|
export interface IConfig {
|
|
@@ -336,8 +344,6 @@ export interface IConfig {
|
|
|
336
344
|
};
|
|
337
345
|
/** Configurable font family / weights for the chat UI. See TypographyConfig. */
|
|
338
346
|
typography?: TypographyConfig;
|
|
339
|
-
/** Input-row geometry (field height, send-button size). See InputLayoutConfig. */
|
|
340
|
-
inputLayout?: InputLayoutConfig;
|
|
341
347
|
messageColor?: {
|
|
342
348
|
backgroundMessage: string;
|
|
343
349
|
backgroundMessageUser: string;
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.getElementFont = void 0;
|
|
7
|
-
/**
|
|
8
|
-
* Per-element font override from `config.typography.elements`, as an RN
|
|
9
|
-
* style object suitable for appending to a component's `style` (so it
|
|
10
|
-
* wins over the built-in size/weight but touches nothing else).
|
|
11
|
-
* Returns undefined when the element isn't configured — appending
|
|
12
|
-
* undefined to a style array is a no-op.
|
|
13
|
-
*/
|
|
14
|
-
const getElementFont = (config, element) => {
|
|
15
|
-
const override = config?.typography?.elements?.[element];
|
|
16
|
-
if (!override) {
|
|
17
|
-
return undefined;
|
|
18
|
-
}
|
|
19
|
-
const style = {};
|
|
20
|
-
if (override.fontSize != null) {
|
|
21
|
-
style.fontSize = override.fontSize;
|
|
22
|
-
}
|
|
23
|
-
if (override.fontWeight != null) {
|
|
24
|
-
style.fontWeight = override.fontWeight;
|
|
25
|
-
}
|
|
26
|
-
return style.fontSize != null || style.fontWeight != null ? style : undefined;
|
|
27
|
-
};
|
|
28
|
-
exports.getElementFont = getElementFont;
|
|
29
|
-
//# sourceMappingURL=getElementFont.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["getElementFont","config","element","override","typography","elements","undefined","style","fontSize","fontWeight","exports"],"sourceRoot":"../../../src","sources":["helpers/getElementFont.ts"],"mappings":";;;;;;AAKA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMA,cAAc,GAAGA,CAC5BC,MAA2B,EAC3BC,OAAmB,KACO;EAC1B,MAAMC,QAAQ,GAAGF,MAAM,EAAEG,UAAU,EAAEC,QAAQ,GAAGH,OAAO,CAAC;EACxD,IAAI,CAACC,QAAQ,EAAE;IAAC,OAAOG,SAAS;EAAC;EACjC,MAAMC,KAAgB,GAAG,CAAC,CAAC;EAC3B,IAAIJ,QAAQ,CAACK,QAAQ,IAAI,IAAI,EAAE;IAACD,KAAK,CAACC,QAAQ,GAAGL,QAAQ,CAACK,QAAQ;EAAC;EACnE,IAAIL,QAAQ,CAACM,UAAU,IAAI,IAAI,EAAE;IAACF,KAAK,CAACE,UAAU,GAAGN,QAAQ,CAACM,UAAU;EAAC;EACzE,OAAOF,KAAK,CAACC,QAAQ,IAAI,IAAI,IAAID,KAAK,CAACE,UAAU,IAAI,IAAI,GACrDF,KAAK,GACLD,SAAS;AACf,CAAC;AAACI,OAAA,CAAAV,cAAA,GAAAA,cAAA","ignoreList":[]}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Per-element font override from `config.typography.elements`, as an RN
|
|
5
|
-
* style object suitable for appending to a component's `style` (so it
|
|
6
|
-
* wins over the built-in size/weight but touches nothing else).
|
|
7
|
-
* Returns undefined when the element isn't configured — appending
|
|
8
|
-
* undefined to a style array is a no-op.
|
|
9
|
-
*/
|
|
10
|
-
export const getElementFont = (config, element) => {
|
|
11
|
-
const override = config?.typography?.elements?.[element];
|
|
12
|
-
if (!override) {
|
|
13
|
-
return undefined;
|
|
14
|
-
}
|
|
15
|
-
const style = {};
|
|
16
|
-
if (override.fontSize != null) {
|
|
17
|
-
style.fontSize = override.fontSize;
|
|
18
|
-
}
|
|
19
|
-
if (override.fontWeight != null) {
|
|
20
|
-
style.fontWeight = override.fontWeight;
|
|
21
|
-
}
|
|
22
|
-
return style.fontSize != null || style.fontWeight != null ? style : undefined;
|
|
23
|
-
};
|
|
24
|
-
//# sourceMappingURL=getElementFont.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["getElementFont","config","element","override","typography","elements","undefined","style","fontSize","fontWeight"],"sourceRoot":"../../../src","sources":["helpers/getElementFont.ts"],"mappings":";;AAKA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMA,cAAc,GAAGA,CAC5BC,MAA2B,EAC3BC,OAAmB,KACO;EAC1B,MAAMC,QAAQ,GAAGF,MAAM,EAAEG,UAAU,EAAEC,QAAQ,GAAGH,OAAO,CAAC;EACxD,IAAI,CAACC,QAAQ,EAAE;IAAC,OAAOG,SAAS;EAAC;EACjC,MAAMC,KAAgB,GAAG,CAAC,CAAC;EAC3B,IAAIJ,QAAQ,CAACK,QAAQ,IAAI,IAAI,EAAE;IAACD,KAAK,CAACC,QAAQ,GAAGL,QAAQ,CAACK,QAAQ;EAAC;EACnE,IAAIL,QAAQ,CAACM,UAAU,IAAI,IAAI,EAAE;IAACF,KAAK,CAACE,UAAU,GAAGN,QAAQ,CAACM,UAAU;EAAC;EACzE,OAAOF,KAAK,CAACC,QAAQ,IAAI,IAAI,IAAID,KAAK,CAACE,UAAU,IAAI,IAAI,GACrDF,KAAK,GACLD,SAAS;AACf,CAAC","ignoreList":[]}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import type { TextStyle } from 'react-native';
|
|
2
|
-
import type { IConfig, TypographyConfig } from '../types/types';
|
|
3
|
-
type ElementKey = keyof NonNullable<TypographyConfig['elements']>;
|
|
4
|
-
/**
|
|
5
|
-
* Per-element font override from `config.typography.elements`, as an RN
|
|
6
|
-
* style object suitable for appending to a component's `style` (so it
|
|
7
|
-
* wins over the built-in size/weight but touches nothing else).
|
|
8
|
-
* Returns undefined when the element isn't configured — appending
|
|
9
|
-
* undefined to a style array is a no-op.
|
|
10
|
-
*/
|
|
11
|
-
export declare const getElementFont: (config: IConfig | undefined, element: ElementKey) => TextStyle | undefined;
|
|
12
|
-
export {};
|
|
13
|
-
//# sourceMappingURL=getElementFont.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"getElementFont.d.ts","sourceRoot":"","sources":["../../../src/helpers/getElementFont.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,KAAK,EAAE,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAEhE,KAAK,UAAU,GAAG,MAAM,WAAW,CAAC,gBAAgB,CAAC,UAAU,CAAC,CAAC,CAAC;AAElE;;;;;;GAMG;AACH,eAAO,MAAM,cAAc,GACzB,QAAQ,OAAO,GAAG,SAAS,EAC3B,SAAS,UAAU,KAClB,SAAS,GAAG,SASd,CAAC"}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import type { TextStyle } from 'react-native';
|
|
2
|
-
import type { IConfig, TypographyConfig } from '../types/types';
|
|
3
|
-
|
|
4
|
-
type ElementKey = keyof NonNullable<TypographyConfig['elements']>;
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Per-element font override from `config.typography.elements`, as an RN
|
|
8
|
-
* style object suitable for appending to a component's `style` (so it
|
|
9
|
-
* wins over the built-in size/weight but touches nothing else).
|
|
10
|
-
* Returns undefined when the element isn't configured — appending
|
|
11
|
-
* undefined to a style array is a no-op.
|
|
12
|
-
*/
|
|
13
|
-
export const getElementFont = (
|
|
14
|
-
config: IConfig | undefined,
|
|
15
|
-
element: ElementKey
|
|
16
|
-
): TextStyle | undefined => {
|
|
17
|
-
const override = config?.typography?.elements?.[element];
|
|
18
|
-
if (!override) {return undefined;}
|
|
19
|
-
const style: TextStyle = {};
|
|
20
|
-
if (override.fontSize != null) {style.fontSize = override.fontSize;}
|
|
21
|
-
if (override.fontWeight != null) {style.fontWeight = override.fontWeight;}
|
|
22
|
-
return style.fontSize != null || style.fontWeight != null
|
|
23
|
-
? style
|
|
24
|
-
: undefined;
|
|
25
|
-
};
|