@onlynative/components 0.0.0-alpha.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/README.md ADDED
@@ -0,0 +1,105 @@
1
+ # @onlynative/components
2
+
3
+ Material Design 3 UI components for React Native, part of [OnlyNative UI](https://github.com/onlynative/ui).
4
+
5
+ ## Install
6
+
7
+ ```bash
8
+ pnpm add @onlynative/core @onlynative/components react-native-safe-area-context
9
+ ```
10
+
11
+ **Optional** — only needed if you plan to use icons in your app:
12
+
13
+ ```bash
14
+ pnpm add @expo/vector-icons
15
+ ```
16
+
17
+ Wrap your app with `ThemeProvider` from `@onlynative/core` (see [@onlynative/core](https://www.npmjs.com/package/@onlynative/core)).
18
+
19
+ ## Import
20
+
21
+ Subpath imports (preferred for tree-shaking):
22
+
23
+ ```tsx
24
+ import { Button } from '@onlynative/components/button'
25
+ import { Card } from '@onlynative/components/card'
26
+ ```
27
+
28
+ Root import:
29
+
30
+ ```tsx
31
+ import { Button, Card } from '@onlynative/components'
32
+ ```
33
+
34
+ ## Components
35
+
36
+ | Component | Subpath | Variants |
37
+ |-----------|---------|----------|
38
+ | Typography | `./typography` | displayLarge..labelSmall (15 MD3 type scale roles) |
39
+ | Button | `./button` | filled, elevated, outlined, text, tonal |
40
+ | IconButton | `./icon-button` | filled, tonal, outlined, standard |
41
+ | AppBar | `./appbar` | small, center-aligned, medium, large |
42
+ | Card | `./card` | elevated, filled, outlined |
43
+ | Chip | `./chip` | assist, filter, input, suggestion |
44
+ | Checkbox | `./checkbox` | — |
45
+ | Radio | `./radio` | — |
46
+ | Switch | `./switch` | — |
47
+ | TextField | `./text-field` | filled, outlined |
48
+ | Layout | `./layout` | Layout, Box, Row, Column, Grid |
49
+ | List | `./list` | List, ListItem, ListDivider |
50
+
51
+ ## Quick examples
52
+
53
+ ```tsx
54
+ import { Button } from '@onlynative/components/button'
55
+ import { TextField } from '@onlynative/components/text-field'
56
+ import { Card } from '@onlynative/components/card'
57
+ import { Typography } from '@onlynative/components/typography'
58
+ import { Row, Column } from '@onlynative/components/layout'
59
+
60
+ // Button with icon
61
+ <Button variant="filled" leadingIcon="plus" onPress={handleCreate}>Create</Button>
62
+
63
+ // Text field
64
+ <TextField label="Email" variant="outlined" value={email} onChangeText={setEmail} />
65
+
66
+ // Card
67
+ <Card variant="elevated" onPress={handlePress}>
68
+ <Typography variant="titleMedium">Card Title</Typography>
69
+ </Card>
70
+
71
+ // Layout
72
+ <Column gap="md">
73
+ <Row gap="sm" align="center">
74
+ <Button variant="filled">Save</Button>
75
+ <Button variant="outlined">Cancel</Button>
76
+ </Row>
77
+ </Column>
78
+ ```
79
+
80
+ ## Override pattern
81
+
82
+ All interactive components support a 3-tier override system (theme → variant → props):
83
+
84
+ - `containerColor` — Background color (state-layer colors auto-derived)
85
+ - `contentColor` — Content (label + icons) color
86
+ - `labelStyle` — Text-specific style (does not affect icons)
87
+ - `style` — Root container style
88
+
89
+ ```tsx
90
+ <Button containerColor="#006A6A" contentColor="#FFFFFF">Custom</Button>
91
+ ```
92
+
93
+ ## Icons
94
+
95
+ All icon props accept [MaterialCommunityIcons](https://pictogrammers.com/library/mdi/) names from `@expo/vector-icons`.
96
+
97
+ ## Docs
98
+
99
+ Full API reference: https://onlynative.github.io/ui/
100
+
101
+ LLM-optimized reference: https://onlynative.github.io/ui/llms-full.txt
102
+
103
+ ## License
104
+
105
+ MIT
@@ -0,0 +1,90 @@
1
+ import * as react_jsx_runtime from 'react/jsx-runtime';
2
+ import { ReactNode } from 'react';
3
+ import { StyleProp, TextStyle, ViewStyle } from 'react-native';
4
+ import { I as IconButtonProps } from '../types-D3hlyvz-.js';
5
+ import '@expo/vector-icons/MaterialCommunityIcons';
6
+
7
+ /** Size/layout variant of the AppBar. */
8
+ type AppBarVariant = 'small' | 'center-aligned' | 'medium' | 'large';
9
+ /**
10
+ * Color scheme that determines the default container and content colors.
11
+ *
12
+ * - `'surface'` — `surface` / `onSurface` (default, elevated uses `surfaceContainer`)
13
+ * - `'surfaceContainerLowest'` — `surfaceContainerLowest` / `onSurface`
14
+ * - `'surfaceContainerLow'` — `surfaceContainerLow` / `onSurface`
15
+ * - `'surfaceContainer'` — `surfaceContainer` / `onSurface`
16
+ * - `'surfaceContainerHigh'` — `surfaceContainerHigh` / `onSurface`
17
+ * - `'surfaceContainerHighest'` — `surfaceContainerHighest` / `onSurface`
18
+ * - `'primary'` — `primary` / `onPrimary`
19
+ * - `'primaryContainer'` — `primaryContainer` / `onPrimaryContainer`
20
+ */
21
+ type AppBarColorScheme = 'surface' | 'surfaceContainerLowest' | 'surfaceContainerLow' | 'surfaceContainer' | 'surfaceContainerHigh' | 'surfaceContainerHighest' | 'primary' | 'primaryContainer';
22
+ /** A single action item rendered in the AppBar trailing slot. */
23
+ interface AppBarAction {
24
+ /** MaterialCommunityIcons icon name to render. */
25
+ icon: IconButtonProps['icon'];
26
+ /** Accessibility label for screen readers (required). */
27
+ accessibilityLabel: string;
28
+ /** Called when the action icon is pressed. */
29
+ onPress?: () => void;
30
+ /**
31
+ * Disables the action icon.
32
+ * @default false
33
+ */
34
+ disabled?: boolean;
35
+ }
36
+ interface AppBarProps {
37
+ /** Title text displayed in the bar. */
38
+ title: string;
39
+ /**
40
+ * Layout variant.
41
+ * @default 'small'
42
+ */
43
+ variant?: AppBarVariant;
44
+ /**
45
+ * Color scheme that determines the default container and content colors.
46
+ * `containerColor` and `contentColor` props override these defaults.
47
+ * @default 'surface'
48
+ */
49
+ colorScheme?: AppBarColorScheme;
50
+ /**
51
+ * When `true`, renders a back button in the leading slot.
52
+ * @default false
53
+ */
54
+ canGoBack?: boolean;
55
+ /** Called when the auto-rendered back button is pressed. */
56
+ onBackPress?: () => void;
57
+ /**
58
+ * When `true`, wraps the bar in a SafeAreaView that handles the top inset.
59
+ * @default false
60
+ */
61
+ insetTop?: boolean;
62
+ /**
63
+ * When `true`, adds shadow/elevation to indicate the bar is scrolled.
64
+ * @default false
65
+ */
66
+ elevated?: boolean;
67
+ /** Custom leading content. When provided, overrides `canGoBack`. */
68
+ leading?: ReactNode;
69
+ /** Custom trailing content. When provided, overrides `actions`. */
70
+ trailing?: ReactNode;
71
+ /** Array of icon-button actions rendered in the trailing slot. */
72
+ actions?: AppBarAction[];
73
+ /**
74
+ * Override the container (background) color.
75
+ * Applied to both normal and elevated states.
76
+ */
77
+ containerColor?: string;
78
+ /**
79
+ * Override the content (title and icon) color.
80
+ */
81
+ contentColor?: string;
82
+ /** Additional style applied to the title text. */
83
+ titleStyle?: StyleProp<TextStyle>;
84
+ /** Custom style applied to the root container. */
85
+ style?: StyleProp<ViewStyle>;
86
+ }
87
+
88
+ declare function AppBar({ title, variant, colorScheme, canGoBack, onBackPress, insetTop, elevated, leading, trailing, actions, containerColor, contentColor, titleStyle, style, }: AppBarProps): react_jsx_runtime.JSX.Element;
89
+
90
+ export { AppBar, type AppBarAction, type AppBarColorScheme, type AppBarProps, type AppBarVariant };