@metacells/mcellui-core 0.1.2 → 0.2.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/dist/index-DtYPPizh.d.ts +682 -0
- package/dist/index.d.ts +3851 -0
- package/dist/index.js +7191 -0
- package/dist/index.js.map +1 -0
- package/dist/shadows-CwlbfJco.d.ts +194 -0
- package/dist/tokens/index.d.ts +17 -0
- package/dist/tokens/index.js +176 -0
- package/dist/tokens/index.js.map +1 -0
- package/dist/utils/index.d.ts +2 -0
- package/dist/utils/index.js +4150 -0
- package/dist/utils/index.js.map +1 -0
- package/package.json +18 -11
- package/src/components/ErrorBoundary.tsx +0 -188
- package/src/components/index.ts +0 -6
- package/src/config/ConfigProvider.tsx +0 -145
- package/src/config/defineConfig.ts +0 -75
- package/src/config/index.ts +0 -42
- package/src/config/types.ts +0 -185
- package/src/constants.ts +0 -203
- package/src/index.ts +0 -144
- package/src/primitives/Portal.tsx +0 -185
- package/src/primitives/Pressable.tsx +0 -114
- package/src/primitives/Slot.tsx +0 -177
- package/src/primitives/index.ts +0 -19
- package/src/theme/ThemeProvider.tsx +0 -506
- package/src/theme/animations.ts +0 -381
- package/src/theme/colors.ts +0 -266
- package/src/theme/components.ts +0 -267
- package/src/theme/index.ts +0 -130
- package/src/theme/presets.ts +0 -341
- package/src/theme/radius.ts +0 -175
- package/src/theme/shadows.ts +0 -166
- package/src/theme/spacing.ts +0 -41
- package/src/theme/typography.ts +0 -389
- package/src/tokens/colors.ts +0 -67
- package/src/tokens/index.ts +0 -29
- package/src/tokens/radius.ts +0 -18
- package/src/tokens/shadows.ts +0 -38
- package/src/tokens/spacing.ts +0 -45
- package/src/tokens/typography.ts +0 -70
- package/src/utils/accessibility.ts +0 -112
- package/src/utils/cn.ts +0 -58
- package/src/utils/expoGo.ts +0 -72
- package/src/utils/haptics.ts +0 -125
- package/src/utils/index.ts +0 -33
- package/src/utils/platform.ts +0 -66
|
@@ -0,0 +1,682 @@
|
|
|
1
|
+
import { TextStyle, ViewStyle, ImageStyle, AccessibilityRole, AccessibilityState } from 'react-native';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Typography Tokens
|
|
5
|
+
*
|
|
6
|
+
* Consistent typography scale for all text elements.
|
|
7
|
+
* Based on iOS Human Interface Guidelines with
|
|
8
|
+
* consideration for React Native defaults.
|
|
9
|
+
*
|
|
10
|
+
* Supports Geist font family when loaded, falls back to system fonts.
|
|
11
|
+
*
|
|
12
|
+
* Usage:
|
|
13
|
+
* ```tsx
|
|
14
|
+
* const { typography, fontFamily } = useTheme();
|
|
15
|
+
* <Text style={typography.body} />
|
|
16
|
+
* <Text style={{ fontFamily: fontFamily.sans, fontSize: fontSize.lg }} />
|
|
17
|
+
* ```
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
declare const fontSize: {
|
|
21
|
+
/** 10px - fine print */
|
|
22
|
+
readonly '2xs': 10;
|
|
23
|
+
/** 11px - captions, labels */
|
|
24
|
+
readonly xs: 11;
|
|
25
|
+
/** 12px - small text, badges */
|
|
26
|
+
readonly sm: 12;
|
|
27
|
+
/** 14px - secondary text */
|
|
28
|
+
readonly base: 14;
|
|
29
|
+
/** 16px - body text (default) */
|
|
30
|
+
readonly md: 16;
|
|
31
|
+
/** 18px - emphasized body */
|
|
32
|
+
readonly lg: 18;
|
|
33
|
+
/** 20px - small headings */
|
|
34
|
+
readonly xl: 20;
|
|
35
|
+
/** 24px - section headings */
|
|
36
|
+
readonly '2xl': 24;
|
|
37
|
+
/** 30px - page headings */
|
|
38
|
+
readonly '3xl': 30;
|
|
39
|
+
/** 36px - large headings */
|
|
40
|
+
readonly '4xl': 36;
|
|
41
|
+
/** 48px - display */
|
|
42
|
+
readonly '5xl': 48;
|
|
43
|
+
};
|
|
44
|
+
type FontSizeKey = keyof typeof fontSize;
|
|
45
|
+
declare const fontWeight: {
|
|
46
|
+
/** 100 */
|
|
47
|
+
readonly thin: "100";
|
|
48
|
+
/** 200 */
|
|
49
|
+
readonly extralight: "200";
|
|
50
|
+
/** 300 */
|
|
51
|
+
readonly light: "300";
|
|
52
|
+
/** 400 - body text */
|
|
53
|
+
readonly normal: "400";
|
|
54
|
+
/** 500 - slightly emphasized */
|
|
55
|
+
readonly medium: "500";
|
|
56
|
+
/** 600 - buttons, labels */
|
|
57
|
+
readonly semibold: "600";
|
|
58
|
+
/** 700 - headings */
|
|
59
|
+
readonly bold: "700";
|
|
60
|
+
/** 800 */
|
|
61
|
+
readonly extrabold: "800";
|
|
62
|
+
/** 900 */
|
|
63
|
+
readonly black: "900";
|
|
64
|
+
};
|
|
65
|
+
type FontWeightKey = keyof typeof fontWeight;
|
|
66
|
+
declare const lineHeight: {
|
|
67
|
+
/** Tight: 1.0 */
|
|
68
|
+
readonly none: 1;
|
|
69
|
+
/** Tight: 1.25 */
|
|
70
|
+
readonly tight: 1.25;
|
|
71
|
+
/** Snug: 1.375 */
|
|
72
|
+
readonly snug: 1.375;
|
|
73
|
+
/** Normal: 1.5 (default) */
|
|
74
|
+
readonly normal: 1.5;
|
|
75
|
+
/** Relaxed: 1.625 */
|
|
76
|
+
readonly relaxed: 1.625;
|
|
77
|
+
/** Loose: 2.0 */
|
|
78
|
+
readonly loose: 2;
|
|
79
|
+
};
|
|
80
|
+
type LineHeightKey = keyof typeof lineHeight;
|
|
81
|
+
declare const letterSpacing: {
|
|
82
|
+
readonly tighter: -0.8;
|
|
83
|
+
readonly tight: -0.4;
|
|
84
|
+
readonly normal: 0;
|
|
85
|
+
readonly wide: 0.4;
|
|
86
|
+
readonly wider: 0.8;
|
|
87
|
+
readonly widest: 1.6;
|
|
88
|
+
};
|
|
89
|
+
type LetterSpacingKey = keyof typeof letterSpacing;
|
|
90
|
+
/**
|
|
91
|
+
* System font fallbacks for when custom fonts aren't loaded.
|
|
92
|
+
*/
|
|
93
|
+
declare const systemFonts: {
|
|
94
|
+
/** Sans-serif system font */
|
|
95
|
+
readonly sans: string;
|
|
96
|
+
/** Monospace system font */
|
|
97
|
+
readonly mono: string;
|
|
98
|
+
};
|
|
99
|
+
/**
|
|
100
|
+
* Semantic font tokens.
|
|
101
|
+
*
|
|
102
|
+
* Three fonts cover all use cases:
|
|
103
|
+
* - `sans`: Body text, UI elements (default)
|
|
104
|
+
* - `heading`: Headlines h1-h4 (can be display/serif font)
|
|
105
|
+
* - `mono`: Code blocks, monospace text
|
|
106
|
+
*
|
|
107
|
+
* @example
|
|
108
|
+
* ```tsx
|
|
109
|
+
* // Use defaults (Geist)
|
|
110
|
+
* <ThemeProvider>
|
|
111
|
+
*
|
|
112
|
+
* // Custom fonts
|
|
113
|
+
* <ThemeProvider fonts={{
|
|
114
|
+
* sans: 'Inter_400Regular',
|
|
115
|
+
* heading: 'PlayfairDisplay_700Bold',
|
|
116
|
+
* mono: 'FiraCode_400Regular',
|
|
117
|
+
* }}>
|
|
118
|
+
* ```
|
|
119
|
+
*/
|
|
120
|
+
interface Fonts {
|
|
121
|
+
/** Body text, UI elements */
|
|
122
|
+
sans: string;
|
|
123
|
+
/** Headlines (h1-h4) - defaults to bold variant of sans */
|
|
124
|
+
heading: string;
|
|
125
|
+
/** Code, monospace text */
|
|
126
|
+
mono: string;
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* Default fonts using Geist font family.
|
|
130
|
+
* Used when no custom fonts are provided to ThemeProvider.
|
|
131
|
+
*/
|
|
132
|
+
declare const defaultFonts: Fonts;
|
|
133
|
+
/**
|
|
134
|
+
* Legacy fontFamily export for backwards compatibility.
|
|
135
|
+
* @deprecated Use `fonts` from useTheme() instead
|
|
136
|
+
*/
|
|
137
|
+
declare const fontFamily: {
|
|
138
|
+
/** Sans-serif: Geist or system default */
|
|
139
|
+
readonly sans: string;
|
|
140
|
+
/** Monospace: Geist Mono or system default */
|
|
141
|
+
readonly mono: string;
|
|
142
|
+
/** System font - always available */
|
|
143
|
+
readonly system: string;
|
|
144
|
+
};
|
|
145
|
+
/**
|
|
146
|
+
* Font family with weight suffix for Geist.
|
|
147
|
+
* Use these when Geist fonts are loaded.
|
|
148
|
+
*/
|
|
149
|
+
declare const geistFontFamily: {
|
|
150
|
+
readonly 'sans-thin': "Geist_100Thin";
|
|
151
|
+
readonly 'sans-extralight': "Geist_200ExtraLight";
|
|
152
|
+
readonly 'sans-light': "Geist_300Light";
|
|
153
|
+
readonly 'sans-regular': "Geist_400Regular";
|
|
154
|
+
readonly 'sans-medium': "Geist_500Medium";
|
|
155
|
+
readonly 'sans-semibold': "Geist_600SemiBold";
|
|
156
|
+
readonly 'sans-bold': "Geist_700Bold";
|
|
157
|
+
readonly 'sans-extrabold': "Geist_800ExtraBold";
|
|
158
|
+
readonly 'sans-black': "Geist_900Black";
|
|
159
|
+
readonly 'mono-thin': "GeistMono_100Thin";
|
|
160
|
+
readonly 'mono-extralight': "GeistMono_200ExtraLight";
|
|
161
|
+
readonly 'mono-light': "GeistMono_300Light";
|
|
162
|
+
readonly 'mono-regular': "GeistMono_400Regular";
|
|
163
|
+
readonly 'mono-medium': "GeistMono_500Medium";
|
|
164
|
+
readonly 'mono-semibold': "GeistMono_600SemiBold";
|
|
165
|
+
readonly 'mono-bold': "GeistMono_700Bold";
|
|
166
|
+
readonly 'mono-extrabold': "GeistMono_800ExtraBold";
|
|
167
|
+
readonly 'mono-black': "GeistMono_900Black";
|
|
168
|
+
};
|
|
169
|
+
type FontFamilyKey = keyof typeof fontFamily;
|
|
170
|
+
type GeistFontFamilyKey = keyof typeof geistFontFamily;
|
|
171
|
+
/**
|
|
172
|
+
* Typography preset styles type.
|
|
173
|
+
*/
|
|
174
|
+
interface Typography {
|
|
175
|
+
display: TextStyle;
|
|
176
|
+
h1: TextStyle;
|
|
177
|
+
h2: TextStyle;
|
|
178
|
+
h3: TextStyle;
|
|
179
|
+
h4: TextStyle;
|
|
180
|
+
h5: TextStyle;
|
|
181
|
+
h6: TextStyle;
|
|
182
|
+
bodyLg: TextStyle;
|
|
183
|
+
body: TextStyle;
|
|
184
|
+
bodySm: TextStyle;
|
|
185
|
+
label: TextStyle;
|
|
186
|
+
labelSm: TextStyle;
|
|
187
|
+
button: TextStyle;
|
|
188
|
+
buttonSm: TextStyle;
|
|
189
|
+
buttonLg: TextStyle;
|
|
190
|
+
caption: TextStyle;
|
|
191
|
+
overline: TextStyle;
|
|
192
|
+
badge: TextStyle;
|
|
193
|
+
code: TextStyle;
|
|
194
|
+
}
|
|
195
|
+
type TypographyKey = keyof Typography;
|
|
196
|
+
/**
|
|
197
|
+
* Creates typography presets with the given fonts.
|
|
198
|
+
* Used internally by ThemeProvider to generate typography styles.
|
|
199
|
+
*/
|
|
200
|
+
declare function createTypography(fonts: Fonts): Typography;
|
|
201
|
+
/**
|
|
202
|
+
* Default typography presets using default fonts.
|
|
203
|
+
* @deprecated Use typography from useTheme() for font customization support
|
|
204
|
+
*/
|
|
205
|
+
declare const typography: Typography;
|
|
206
|
+
|
|
207
|
+
/**
|
|
208
|
+
* cn() - Class Name / Style Merger
|
|
209
|
+
*
|
|
210
|
+
* The core utility for merging styles in mcellui.
|
|
211
|
+
* Inspired by shadcn/ui's cn() but adapted for React Native StyleSheet.
|
|
212
|
+
*/
|
|
213
|
+
|
|
214
|
+
type Style = ViewStyle | TextStyle | ImageStyle;
|
|
215
|
+
type StyleInput = Style | Style[] | null | undefined | false;
|
|
216
|
+
/**
|
|
217
|
+
* Merges multiple style objects into a single flattened style.
|
|
218
|
+
*
|
|
219
|
+
* Handles undefined, null, false, and nested arrays. React Native equivalent
|
|
220
|
+
* of clsx/cn for web.
|
|
221
|
+
*
|
|
222
|
+
* @param inputs - Style objects or falsy values to merge
|
|
223
|
+
* @returns Merged and flattened style object
|
|
224
|
+
*
|
|
225
|
+
* @example
|
|
226
|
+
* ```tsx
|
|
227
|
+
* const styles = cn(
|
|
228
|
+
* baseStyles.container,
|
|
229
|
+
* isActive && activeStyles,
|
|
230
|
+
* { padding: 16 }
|
|
231
|
+
* );
|
|
232
|
+
* ```
|
|
233
|
+
*/
|
|
234
|
+
declare function cn(...inputs: StyleInput[]): Style;
|
|
235
|
+
/**
|
|
236
|
+
* Creates a style object from conditional styles.
|
|
237
|
+
*
|
|
238
|
+
* More explicit alternative to cn() for complex conditions.
|
|
239
|
+
*
|
|
240
|
+
* @param styles - Object mapping condition names to style values
|
|
241
|
+
* @returns Merged and flattened style object
|
|
242
|
+
*
|
|
243
|
+
* @example
|
|
244
|
+
* ```tsx
|
|
245
|
+
* const styles = mergeStyles({
|
|
246
|
+
* base: baseStyle,
|
|
247
|
+
* active: isActive && activeStyle,
|
|
248
|
+
* disabled: isDisabled && disabledStyle,
|
|
249
|
+
* });
|
|
250
|
+
* ```
|
|
251
|
+
*/
|
|
252
|
+
declare function mergeStyles(styles: Record<string, StyleInput>): Style;
|
|
253
|
+
|
|
254
|
+
/**
|
|
255
|
+
* Platform Utilities
|
|
256
|
+
*
|
|
257
|
+
* Helpers for platform-specific behavior
|
|
258
|
+
*/
|
|
259
|
+
/** True if running on iOS */
|
|
260
|
+
declare const isIOS: boolean;
|
|
261
|
+
/** True if running on Android */
|
|
262
|
+
declare const isAndroid: boolean;
|
|
263
|
+
/** True if running on web */
|
|
264
|
+
declare const isWeb: boolean;
|
|
265
|
+
/** iOS version number (returns 0 on non-iOS platforms) */
|
|
266
|
+
declare const iosVersion: number;
|
|
267
|
+
/** Android API level (returns 0 on non-Android platforms) */
|
|
268
|
+
declare const androidApiLevel: number;
|
|
269
|
+
/**
|
|
270
|
+
* Check if device is a tablet.
|
|
271
|
+
*
|
|
272
|
+
* Uses screen dimensions heuristic (600dp minimum, aspect ratio < 1.6).
|
|
273
|
+
*
|
|
274
|
+
* @returns True if device is likely a tablet
|
|
275
|
+
*/
|
|
276
|
+
declare function isTablet(): boolean;
|
|
277
|
+
/** Device pixel ratio for crisp rendering */
|
|
278
|
+
declare const pixelRatio: number;
|
|
279
|
+
/**
|
|
280
|
+
* Round to nearest pixel for crisp lines and borders.
|
|
281
|
+
*
|
|
282
|
+
* @param value - Value in logical pixels
|
|
283
|
+
* @returns Value rounded to nearest physical pixel
|
|
284
|
+
*/
|
|
285
|
+
declare function roundToNearestPixel(value: number): number;
|
|
286
|
+
/**
|
|
287
|
+
* Get safe font scale (clamped for accessibility).
|
|
288
|
+
*
|
|
289
|
+
* Prevents excessively large text from breaking layouts when users enable
|
|
290
|
+
* large text accessibility settings.
|
|
291
|
+
*
|
|
292
|
+
* @param maxScale - Maximum scale to allow (defaults to 1.3)
|
|
293
|
+
* @returns Clamped font scale factor
|
|
294
|
+
*/
|
|
295
|
+
declare function getFontScale(maxScale?: number): number;
|
|
296
|
+
|
|
297
|
+
/**
|
|
298
|
+
* Accessibility Utilities
|
|
299
|
+
*
|
|
300
|
+
* Helpers for building accessible components
|
|
301
|
+
*/
|
|
302
|
+
|
|
303
|
+
interface A11yProps {
|
|
304
|
+
accessible?: boolean;
|
|
305
|
+
accessibilityLabel?: string;
|
|
306
|
+
accessibilityHint?: string;
|
|
307
|
+
accessibilityRole?: AccessibilityRole;
|
|
308
|
+
accessibilityState?: AccessibilityState;
|
|
309
|
+
}
|
|
310
|
+
/**
|
|
311
|
+
* Creates accessibility props for a button.
|
|
312
|
+
*
|
|
313
|
+
* @param label - Accessible label for the button
|
|
314
|
+
* @param options - Optional button state (hint, disabled, selected)
|
|
315
|
+
* @returns Accessibility props to spread onto component
|
|
316
|
+
*
|
|
317
|
+
* @example
|
|
318
|
+
* ```tsx
|
|
319
|
+
* <Pressable {...buttonA11y('Submit', { disabled: isLoading })} />
|
|
320
|
+
* ```
|
|
321
|
+
*/
|
|
322
|
+
declare function buttonA11y(label: string, options?: {
|
|
323
|
+
hint?: string;
|
|
324
|
+
disabled?: boolean;
|
|
325
|
+
selected?: boolean;
|
|
326
|
+
}): A11yProps;
|
|
327
|
+
/**
|
|
328
|
+
* Creates accessibility props for a checkbox/switch.
|
|
329
|
+
*
|
|
330
|
+
* @param label - Accessible label for the toggle
|
|
331
|
+
* @param checked - Whether the toggle is checked
|
|
332
|
+
* @param options - Optional toggle state (hint, disabled)
|
|
333
|
+
* @returns Accessibility props to spread onto component
|
|
334
|
+
*
|
|
335
|
+
* @example
|
|
336
|
+
* ```tsx
|
|
337
|
+
* <Pressable {...toggleA11y('Dark Mode', isDark, { disabled: false })} />
|
|
338
|
+
* ```
|
|
339
|
+
*/
|
|
340
|
+
declare function toggleA11y(label: string, checked: boolean, options?: {
|
|
341
|
+
hint?: string;
|
|
342
|
+
disabled?: boolean;
|
|
343
|
+
}): A11yProps;
|
|
344
|
+
/**
|
|
345
|
+
* Creates accessibility props for a link.
|
|
346
|
+
*
|
|
347
|
+
* @param label - Accessible label for the link
|
|
348
|
+
* @param options - Optional hint text
|
|
349
|
+
* @returns Accessibility props to spread onto component
|
|
350
|
+
*
|
|
351
|
+
* @example
|
|
352
|
+
* ```tsx
|
|
353
|
+
* <Pressable {...linkA11y('View Details', { hint: 'Opens product page' })} />
|
|
354
|
+
* ```
|
|
355
|
+
*/
|
|
356
|
+
declare function linkA11y(label: string, options?: {
|
|
357
|
+
hint?: string;
|
|
358
|
+
}): A11yProps;
|
|
359
|
+
/**
|
|
360
|
+
* Creates accessibility props for an image.
|
|
361
|
+
*
|
|
362
|
+
* @param label - Accessible label describing the image
|
|
363
|
+
* @param options - Optional decorative flag (hides from screen readers)
|
|
364
|
+
* @returns Accessibility props to spread onto Image component
|
|
365
|
+
*
|
|
366
|
+
* @example
|
|
367
|
+
* ```tsx
|
|
368
|
+
* <Image {...imageA11y('Profile photo')} />
|
|
369
|
+
* <Image {...imageA11y('', { decorative: true })} />
|
|
370
|
+
* ```
|
|
371
|
+
*/
|
|
372
|
+
declare function imageA11y(label: string, options?: {
|
|
373
|
+
decorative?: boolean;
|
|
374
|
+
}): A11yProps;
|
|
375
|
+
/**
|
|
376
|
+
* Creates accessibility props for a heading.
|
|
377
|
+
*
|
|
378
|
+
* @param label - Accessible label for the heading
|
|
379
|
+
* @returns Accessibility props to spread onto Text component
|
|
380
|
+
*
|
|
381
|
+
* @example
|
|
382
|
+
* ```tsx
|
|
383
|
+
* <Text {...headingA11y('Dashboard')} style={typography.h1}>Dashboard</Text>
|
|
384
|
+
* ```
|
|
385
|
+
*/
|
|
386
|
+
declare function headingA11y(label: string): A11yProps;
|
|
387
|
+
|
|
388
|
+
/**
|
|
389
|
+
* Haptics Utilities
|
|
390
|
+
*
|
|
391
|
+
* Unified haptic feedback interface.
|
|
392
|
+
* Falls back gracefully when expo-haptics is not available.
|
|
393
|
+
*
|
|
394
|
+
* Design Philosophy:
|
|
395
|
+
* - Every interactive element should provide tactile feedback
|
|
396
|
+
* - Haptics should be subtle and purposeful
|
|
397
|
+
* - Respect user's haptic preferences
|
|
398
|
+
*/
|
|
399
|
+
/** Available haptic feedback styles */
|
|
400
|
+
type HapticStyle = 'light' | 'medium' | 'heavy' | 'success' | 'warning' | 'error' | 'selection';
|
|
401
|
+
/**
|
|
402
|
+
* Haptic presets for common interactions
|
|
403
|
+
*/
|
|
404
|
+
declare const hapticPresets: {
|
|
405
|
+
/** For button presses, checkbox toggles */
|
|
406
|
+
readonly buttonPress: HapticStyle;
|
|
407
|
+
/** For switch toggles */
|
|
408
|
+
readonly toggle: HapticStyle;
|
|
409
|
+
/** For successful actions */
|
|
410
|
+
readonly success: HapticStyle;
|
|
411
|
+
/** For errors */
|
|
412
|
+
readonly error: HapticStyle;
|
|
413
|
+
/** For selection changes (radio, picker) */
|
|
414
|
+
readonly selection: HapticStyle;
|
|
415
|
+
/** For destructive actions */
|
|
416
|
+
readonly destructive: HapticStyle;
|
|
417
|
+
};
|
|
418
|
+
/**
|
|
419
|
+
* Enable or disable haptic feedback globally.
|
|
420
|
+
*
|
|
421
|
+
* Use this to respect user preferences or accessibility settings.
|
|
422
|
+
*
|
|
423
|
+
* @param enabled - Whether to enable haptic feedback
|
|
424
|
+
*
|
|
425
|
+
* @example
|
|
426
|
+
* ```tsx
|
|
427
|
+
* // In ThemeProvider or app setup
|
|
428
|
+
* setHapticsEnabled(false);
|
|
429
|
+
*
|
|
430
|
+
* // Or via config
|
|
431
|
+
* <ThemeProvider haptics={false}>
|
|
432
|
+
* ```
|
|
433
|
+
*/
|
|
434
|
+
declare function setHapticsEnabled(enabled: boolean): void;
|
|
435
|
+
/**
|
|
436
|
+
* Check if haptics are currently enabled.
|
|
437
|
+
*
|
|
438
|
+
* @returns True if haptics are enabled and expo-haptics is available
|
|
439
|
+
*/
|
|
440
|
+
declare function isHapticsEnabled(): boolean;
|
|
441
|
+
/**
|
|
442
|
+
* Trigger haptic feedback.
|
|
443
|
+
*
|
|
444
|
+
* Respects the global haptics enabled state. Disabled via:
|
|
445
|
+
* - `setHapticsEnabled(false)`
|
|
446
|
+
* - `<ThemeProvider haptics={false}>`
|
|
447
|
+
*
|
|
448
|
+
* @param style - Haptic feedback style (defaults to 'light')
|
|
449
|
+
* @returns Promise that resolves when haptic completes
|
|
450
|
+
*
|
|
451
|
+
* @example
|
|
452
|
+
* ```tsx
|
|
453
|
+
* onPress={() => {
|
|
454
|
+
* haptic('light');
|
|
455
|
+
* // ... rest of handler
|
|
456
|
+
* }}
|
|
457
|
+
* ```
|
|
458
|
+
*/
|
|
459
|
+
declare function haptic(style?: HapticStyle): Promise<void>;
|
|
460
|
+
/**
|
|
461
|
+
* Check if haptics are available.
|
|
462
|
+
*
|
|
463
|
+
* @returns True if expo-haptics is installed and can be used
|
|
464
|
+
*/
|
|
465
|
+
declare function hapticsAvailable(): boolean;
|
|
466
|
+
|
|
467
|
+
/**
|
|
468
|
+
* Expo Go Detection Utility
|
|
469
|
+
*
|
|
470
|
+
* Provides detection for Expo Go environment to gracefully disable
|
|
471
|
+
* Reanimated animations when running in Expo Go client.
|
|
472
|
+
*
|
|
473
|
+
* @example
|
|
474
|
+
* ```tsx
|
|
475
|
+
* import { isExpoGo, areAnimationsDisabled } from '@metacells/mcellui-core';
|
|
476
|
+
*
|
|
477
|
+
* // Check environment
|
|
478
|
+
* if (isExpoGo()) {
|
|
479
|
+
* console.log('Running in Expo Go');
|
|
480
|
+
* }
|
|
481
|
+
*
|
|
482
|
+
* // Check if animations should be disabled
|
|
483
|
+
* if (areAnimationsDisabled()) {
|
|
484
|
+
* // Skip animation, use static styles
|
|
485
|
+
* }
|
|
486
|
+
* ```
|
|
487
|
+
*/
|
|
488
|
+
/**
|
|
489
|
+
* Check if the app is running in Expo Go client.
|
|
490
|
+
*
|
|
491
|
+
* Returns false in development builds, production builds, or non-Expo environments.
|
|
492
|
+
*
|
|
493
|
+
* @returns True if running in Expo Go client
|
|
494
|
+
*/
|
|
495
|
+
declare function isExpoGo(): boolean;
|
|
496
|
+
/**
|
|
497
|
+
* Manually override the animation disabled state.
|
|
498
|
+
*
|
|
499
|
+
* Set to `true` to force disable animations, `false` to force enable,
|
|
500
|
+
* or `null` to use automatic detection (Expo Go = disabled).
|
|
501
|
+
*
|
|
502
|
+
* @param disabled - Override value (true/false) or null for automatic detection
|
|
503
|
+
*/
|
|
504
|
+
declare function setAnimationsDisabled(disabled: boolean | null): void;
|
|
505
|
+
/**
|
|
506
|
+
* Check if animations should be disabled.
|
|
507
|
+
*
|
|
508
|
+
* Returns true if:
|
|
509
|
+
* - Manually overridden to true via setAnimationsDisabled(true)
|
|
510
|
+
* - Running in Expo Go (automatic detection)
|
|
511
|
+
*
|
|
512
|
+
* Returns false if:
|
|
513
|
+
* - Manually overridden to false via setAnimationsDisabled(false)
|
|
514
|
+
* - Running in development/production build
|
|
515
|
+
*
|
|
516
|
+
* @returns True if animations should be disabled
|
|
517
|
+
*/
|
|
518
|
+
declare function areAnimationsDisabled(): boolean;
|
|
519
|
+
|
|
520
|
+
/**
|
|
521
|
+
* Typography Utilities
|
|
522
|
+
*
|
|
523
|
+
* Helper functions for working with typography tokens in React Native.
|
|
524
|
+
* React Native requires absolute lineHeight values (in pixels), not CSS
|
|
525
|
+
* multipliers like web.
|
|
526
|
+
*
|
|
527
|
+
* @example
|
|
528
|
+
* ```tsx
|
|
529
|
+
* import { getLineHeight, lineHeight, fontSize } from '@metacells/mcellui-core';
|
|
530
|
+
*
|
|
531
|
+
* // Instead of inline calculations:
|
|
532
|
+
* // lineHeight: fontSize.base * 1.5
|
|
533
|
+
*
|
|
534
|
+
* // Use the helper:
|
|
535
|
+
* lineHeight: getLineHeight(fontSize.base, lineHeight.normal)
|
|
536
|
+
* // or with shorthand:
|
|
537
|
+
* lineHeight: getLineHeight(14, 'normal')
|
|
538
|
+
* ```
|
|
539
|
+
*/
|
|
540
|
+
|
|
541
|
+
/**
|
|
542
|
+
* Calculates absolute lineHeight for React Native.
|
|
543
|
+
*
|
|
544
|
+
* React Native requires lineHeight as absolute pixel values, not CSS multipliers.
|
|
545
|
+
* This helper converts fontSize + multiplier into the correct absolute value.
|
|
546
|
+
*
|
|
547
|
+
* @param size - Font size in pixels (e.g., fontSize.base = 14)
|
|
548
|
+
* @param multiplier - Either a numeric multiplier (1.5) or a lineHeight key ('normal')
|
|
549
|
+
* @returns Absolute lineHeight in pixels
|
|
550
|
+
*
|
|
551
|
+
* @example
|
|
552
|
+
* ```tsx
|
|
553
|
+
* // Using numeric multiplier
|
|
554
|
+
* getLineHeight(14, 1.5) // => 21
|
|
555
|
+
*
|
|
556
|
+
* // Using lineHeight token key
|
|
557
|
+
* getLineHeight(fontSize.base, 'normal') // => 21
|
|
558
|
+
*
|
|
559
|
+
* // Using lineHeight token value directly
|
|
560
|
+
* getLineHeight(fontSize.base, lineHeight.normal) // => 21
|
|
561
|
+
* ```
|
|
562
|
+
*/
|
|
563
|
+
declare function getLineHeight(size: number, multiplier: number | LineHeightKey): number;
|
|
564
|
+
/**
|
|
565
|
+
* Pre-computed lineHeight values for common fontSize + lineHeight combinations.
|
|
566
|
+
*
|
|
567
|
+
* Use these when you want consistent, pre-calculated values without calling
|
|
568
|
+
* getLineHeight() each time.
|
|
569
|
+
*
|
|
570
|
+
* @example
|
|
571
|
+
* ```tsx
|
|
572
|
+
* import { computedLineHeight } from '@metacells/mcellui-core';
|
|
573
|
+
*
|
|
574
|
+
* <Text style={{ fontSize: 14, lineHeight: computedLineHeight.base.normal }}>
|
|
575
|
+
* Body text with normal line height
|
|
576
|
+
* </Text>
|
|
577
|
+
* ```
|
|
578
|
+
*/
|
|
579
|
+
declare const computedLineHeight: {
|
|
580
|
+
/** fontSize['2xs'] = 10 */
|
|
581
|
+
readonly '2xs': {
|
|
582
|
+
readonly none: number;
|
|
583
|
+
readonly tight: number;
|
|
584
|
+
readonly snug: number;
|
|
585
|
+
readonly normal: number;
|
|
586
|
+
readonly relaxed: number;
|
|
587
|
+
readonly loose: number;
|
|
588
|
+
};
|
|
589
|
+
/** fontSize.xs = 11 */
|
|
590
|
+
readonly xs: {
|
|
591
|
+
readonly none: number;
|
|
592
|
+
readonly tight: number;
|
|
593
|
+
readonly snug: number;
|
|
594
|
+
readonly normal: number;
|
|
595
|
+
readonly relaxed: number;
|
|
596
|
+
readonly loose: number;
|
|
597
|
+
};
|
|
598
|
+
/** fontSize.sm = 12 */
|
|
599
|
+
readonly sm: {
|
|
600
|
+
readonly none: number;
|
|
601
|
+
readonly tight: number;
|
|
602
|
+
readonly snug: number;
|
|
603
|
+
readonly normal: number;
|
|
604
|
+
readonly relaxed: number;
|
|
605
|
+
readonly loose: number;
|
|
606
|
+
};
|
|
607
|
+
/** fontSize.base = 14 */
|
|
608
|
+
readonly base: {
|
|
609
|
+
readonly none: number;
|
|
610
|
+
readonly tight: number;
|
|
611
|
+
readonly snug: number;
|
|
612
|
+
readonly normal: number;
|
|
613
|
+
readonly relaxed: number;
|
|
614
|
+
readonly loose: number;
|
|
615
|
+
};
|
|
616
|
+
/** fontSize.md = 16 */
|
|
617
|
+
readonly md: {
|
|
618
|
+
readonly none: number;
|
|
619
|
+
readonly tight: number;
|
|
620
|
+
readonly snug: number;
|
|
621
|
+
readonly normal: number;
|
|
622
|
+
readonly relaxed: number;
|
|
623
|
+
readonly loose: number;
|
|
624
|
+
};
|
|
625
|
+
/** fontSize.lg = 18 */
|
|
626
|
+
readonly lg: {
|
|
627
|
+
readonly none: number;
|
|
628
|
+
readonly tight: number;
|
|
629
|
+
readonly snug: number;
|
|
630
|
+
readonly normal: number;
|
|
631
|
+
readonly relaxed: number;
|
|
632
|
+
readonly loose: number;
|
|
633
|
+
};
|
|
634
|
+
/** fontSize.xl = 20 */
|
|
635
|
+
readonly xl: {
|
|
636
|
+
readonly none: number;
|
|
637
|
+
readonly tight: number;
|
|
638
|
+
readonly snug: number;
|
|
639
|
+
readonly normal: number;
|
|
640
|
+
readonly relaxed: number;
|
|
641
|
+
readonly loose: number;
|
|
642
|
+
};
|
|
643
|
+
/** fontSize['2xl'] = 24 */
|
|
644
|
+
readonly '2xl': {
|
|
645
|
+
readonly none: number;
|
|
646
|
+
readonly tight: number;
|
|
647
|
+
readonly snug: number;
|
|
648
|
+
readonly normal: number;
|
|
649
|
+
readonly relaxed: number;
|
|
650
|
+
readonly loose: number;
|
|
651
|
+
};
|
|
652
|
+
/** fontSize['3xl'] = 30 */
|
|
653
|
+
readonly '3xl': {
|
|
654
|
+
readonly none: number;
|
|
655
|
+
readonly tight: number;
|
|
656
|
+
readonly snug: number;
|
|
657
|
+
readonly normal: number;
|
|
658
|
+
readonly relaxed: number;
|
|
659
|
+
readonly loose: number;
|
|
660
|
+
};
|
|
661
|
+
/** fontSize['4xl'] = 36 */
|
|
662
|
+
readonly '4xl': {
|
|
663
|
+
readonly none: number;
|
|
664
|
+
readonly tight: number;
|
|
665
|
+
readonly snug: number;
|
|
666
|
+
readonly normal: number;
|
|
667
|
+
readonly relaxed: number;
|
|
668
|
+
readonly loose: number;
|
|
669
|
+
};
|
|
670
|
+
/** fontSize['5xl'] = 48 */
|
|
671
|
+
readonly '5xl': {
|
|
672
|
+
readonly none: number;
|
|
673
|
+
readonly tight: number;
|
|
674
|
+
readonly snug: number;
|
|
675
|
+
readonly normal: number;
|
|
676
|
+
readonly relaxed: number;
|
|
677
|
+
readonly loose: number;
|
|
678
|
+
};
|
|
679
|
+
};
|
|
680
|
+
type ComputedLineHeightKey = keyof typeof computedLineHeight;
|
|
681
|
+
|
|
682
|
+
export { buttonA11y as A, toggleA11y as B, linkA11y as C, imageA11y as D, headingA11y as E, type Fonts as F, type GeistFontFamilyKey as G, type A11yProps as H, haptic as I, hapticsAvailable as J, setHapticsEnabled as K, type LineHeightKey as L, isHapticsEnabled as M, hapticPresets as N, type HapticStyle as O, isExpoGo as P, setAnimationsDisabled as Q, areAnimationsDisabled as R, getLineHeight as S, type Typography as T, computedLineHeight as U, type ComputedLineHeightKey as V, fontWeight as a, letterSpacing as b, fontFamily as c, defaultFonts as d, createTypography as e, fontSize as f, geistFontFamily as g, type FontSizeKey as h, type FontWeightKey as i, type LetterSpacingKey as j, type FontFamilyKey as k, lineHeight as l, type TypographyKey as m, cn as n, mergeStyles as o, isIOS as p, isAndroid as q, isWeb as r, systemFonts as s, typography as t, iosVersion as u, androidApiLevel as v, isTablet as w, pixelRatio as x, roundToNearestPixel as y, getFontScale as z };
|