@onlynative/components 0.1.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 +99 -0
- package/dist/appbar/index.d.ts +71 -0
- package/dist/appbar/index.js +952 -0
- package/dist/button/index.d.ts +41 -0
- package/dist/button/index.js +454 -0
- package/dist/card/index.d.ts +31 -0
- package/dist/card/index.js +264 -0
- package/dist/checkbox/index.d.ts +25 -0
- package/dist/checkbox/index.js +291 -0
- package/dist/chip/index.d.ts +62 -0
- package/dist/chip/index.js +452 -0
- package/dist/icon-button/index.d.ts +10 -0
- package/dist/icon-button/index.js +575 -0
- package/dist/index.d.ts +19 -0
- package/dist/index.js +3374 -0
- package/dist/layout/index.d.ts +98 -0
- package/dist/layout/index.js +282 -0
- package/dist/list/index.d.ts +60 -0
- package/dist/list/index.js +300 -0
- package/dist/radio/index.d.ts +25 -0
- package/dist/radio/index.js +250 -0
- package/dist/switch/index.d.ts +37 -0
- package/dist/switch/index.js +315 -0
- package/dist/text-field/index.d.ts +52 -0
- package/dist/text-field/index.js +496 -0
- package/dist/types-D3hlyvz-.d.ts +51 -0
- package/dist/typography/index.d.ts +28 -0
- package/dist/typography/index.js +69 -0
- package/package.json +166 -0
- package/src/appbar/AppBar.tsx +302 -0
- package/src/appbar/index.ts +2 -0
- package/src/appbar/styles.ts +92 -0
- package/src/appbar/types.ts +67 -0
- package/src/button/Button.tsx +130 -0
- package/src/button/index.ts +2 -0
- package/src/button/styles.ts +288 -0
- package/src/button/types.ts +42 -0
- package/src/card/Card.tsx +69 -0
- package/src/card/index.ts +2 -0
- package/src/card/styles.ts +151 -0
- package/src/card/types.ts +27 -0
- package/src/checkbox/Checkbox.tsx +109 -0
- package/src/checkbox/index.ts +2 -0
- package/src/checkbox/styles.ts +155 -0
- package/src/checkbox/types.ts +20 -0
- package/src/chip/Chip.tsx +182 -0
- package/src/chip/index.ts +2 -0
- package/src/chip/styles.ts +240 -0
- package/src/chip/types.ts +58 -0
- package/src/icon-button/IconButton.tsx +358 -0
- package/src/icon-button/index.ts +6 -0
- package/src/icon-button/styles.ts +259 -0
- package/src/icon-button/types.ts +55 -0
- package/src/index.ts +51 -0
- package/src/layout/Box.tsx +99 -0
- package/src/layout/Column.tsx +16 -0
- package/src/layout/Grid.tsx +49 -0
- package/src/layout/Layout.tsx +81 -0
- package/src/layout/Row.tsx +22 -0
- package/src/layout/index.ts +13 -0
- package/src/layout/resolveSpacing.ts +11 -0
- package/src/layout/types.ts +82 -0
- package/src/list/List.tsx +17 -0
- package/src/list/ListDivider.tsx +20 -0
- package/src/list/ListItem.tsx +128 -0
- package/src/list/index.ts +9 -0
- package/src/list/styles.ts +132 -0
- package/src/list/types.ts +54 -0
- package/src/radio/Radio.tsx +103 -0
- package/src/radio/index.ts +2 -0
- package/src/radio/styles.ts +139 -0
- package/src/radio/types.ts +20 -0
- package/src/switch/Switch.tsx +118 -0
- package/src/switch/index.ts +2 -0
- package/src/switch/styles.ts +172 -0
- package/src/switch/types.ts +32 -0
- package/src/test-utils/render-with-theme.tsx +13 -0
- package/src/text-field/TextField.tsx +298 -0
- package/src/text-field/index.ts +2 -0
- package/src/text-field/styles.ts +240 -0
- package/src/text-field/types.ts +49 -0
- package/src/typography/Typography.tsx +65 -0
- package/src/typography/index.ts +3 -0
- package/src/typography/types.ts +17 -0
- package/src/utils/color.ts +64 -0
- package/src/utils/elevation.ts +33 -0
- package/src/utils/rtl.ts +19 -0
package/README.md
ADDED
|
@@ -0,0 +1,99 @@
|
|
|
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 @expo/vector-icons react-native-safe-area-context
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
Wrap your app with `MaterialProvider` from `@onlynative/core` (see [@onlynative/core](https://www.npmjs.com/package/@onlynative/core)).
|
|
12
|
+
|
|
13
|
+
## Import
|
|
14
|
+
|
|
15
|
+
Subpath imports (preferred for tree-shaking):
|
|
16
|
+
|
|
17
|
+
```tsx
|
|
18
|
+
import { Button } from '@onlynative/components/button'
|
|
19
|
+
import { Card } from '@onlynative/components/card'
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
Root import:
|
|
23
|
+
|
|
24
|
+
```tsx
|
|
25
|
+
import { Button, Card } from '@onlynative/components'
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
## Components
|
|
29
|
+
|
|
30
|
+
| Component | Subpath | Variants |
|
|
31
|
+
|-----------|---------|----------|
|
|
32
|
+
| Typography | `./typography` | displayLarge..labelSmall (15 MD3 type scale roles) |
|
|
33
|
+
| Button | `./button` | filled, elevated, outlined, text, tonal |
|
|
34
|
+
| IconButton | `./icon-button` | filled, tonal, outlined, standard |
|
|
35
|
+
| AppBar | `./appbar` | small, center-aligned, medium, large |
|
|
36
|
+
| Card | `./card` | elevated, filled, outlined |
|
|
37
|
+
| Chip | `./chip` | assist, filter, input, suggestion |
|
|
38
|
+
| Checkbox | `./checkbox` | — |
|
|
39
|
+
| Radio | `./radio` | — |
|
|
40
|
+
| Switch | `./switch` | — |
|
|
41
|
+
| TextField | `./text-field` | filled, outlined |
|
|
42
|
+
| Layout | `./layout` | Layout, Box, Row, Column, Grid |
|
|
43
|
+
| List | `./list` | List, ListItem, ListDivider |
|
|
44
|
+
|
|
45
|
+
## Quick examples
|
|
46
|
+
|
|
47
|
+
```tsx
|
|
48
|
+
import { Button } from '@onlynative/components/button'
|
|
49
|
+
import { TextField } from '@onlynative/components/text-field'
|
|
50
|
+
import { Card } from '@onlynative/components/card'
|
|
51
|
+
import { Typography } from '@onlynative/components/typography'
|
|
52
|
+
import { Row, Column } from '@onlynative/components/layout'
|
|
53
|
+
|
|
54
|
+
// Button with icon
|
|
55
|
+
<Button variant="filled" leadingIcon="plus" onPress={handleCreate}>Create</Button>
|
|
56
|
+
|
|
57
|
+
// Text field
|
|
58
|
+
<TextField label="Email" variant="outlined" value={email} onChangeText={setEmail} />
|
|
59
|
+
|
|
60
|
+
// Card
|
|
61
|
+
<Card variant="elevated" onPress={handlePress}>
|
|
62
|
+
<Typography variant="titleMedium">Card Title</Typography>
|
|
63
|
+
</Card>
|
|
64
|
+
|
|
65
|
+
// Layout
|
|
66
|
+
<Column gap="md">
|
|
67
|
+
<Row gap="sm" align="center">
|
|
68
|
+
<Button variant="filled">Save</Button>
|
|
69
|
+
<Button variant="outlined">Cancel</Button>
|
|
70
|
+
</Row>
|
|
71
|
+
</Column>
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
## Override pattern
|
|
75
|
+
|
|
76
|
+
All interactive components support a 3-tier override system (theme → variant → props):
|
|
77
|
+
|
|
78
|
+
- `containerColor` — Background color (state-layer colors auto-derived)
|
|
79
|
+
- `contentColor` — Content (label + icons) color
|
|
80
|
+
- `labelStyle` — Text-specific style (does not affect icons)
|
|
81
|
+
- `style` — Root container style
|
|
82
|
+
|
|
83
|
+
```tsx
|
|
84
|
+
<Button containerColor="#006A6A" contentColor="#FFFFFF">Custom</Button>
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
## Icons
|
|
88
|
+
|
|
89
|
+
All icon props accept [MaterialCommunityIcons](https://pictogrammers.com/library/mdi/) names from `@expo/vector-icons`.
|
|
90
|
+
|
|
91
|
+
## Docs
|
|
92
|
+
|
|
93
|
+
Full API reference: https://onlynative.github.io/ui/
|
|
94
|
+
|
|
95
|
+
LLM-optimized reference: https://onlynative.github.io/ui/llms-full.txt
|
|
96
|
+
|
|
97
|
+
## License
|
|
98
|
+
|
|
99
|
+
MIT
|
|
@@ -0,0 +1,71 @@
|
|
|
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
|
+
/** A single action item rendered in the AppBar trailing slot. */
|
|
10
|
+
interface AppBarAction {
|
|
11
|
+
/** MaterialCommunityIcons icon name to render. */
|
|
12
|
+
icon: IconButtonProps['icon'];
|
|
13
|
+
/** Accessibility label for screen readers (required). */
|
|
14
|
+
accessibilityLabel: string;
|
|
15
|
+
/** Called when the action icon is pressed. */
|
|
16
|
+
onPress?: () => void;
|
|
17
|
+
/**
|
|
18
|
+
* Disables the action icon.
|
|
19
|
+
* @default false
|
|
20
|
+
*/
|
|
21
|
+
disabled?: boolean;
|
|
22
|
+
}
|
|
23
|
+
interface AppBarProps {
|
|
24
|
+
/** Title text displayed in the bar. */
|
|
25
|
+
title: string;
|
|
26
|
+
/**
|
|
27
|
+
* Layout variant.
|
|
28
|
+
* @default 'small'
|
|
29
|
+
*/
|
|
30
|
+
variant?: AppBarVariant;
|
|
31
|
+
/**
|
|
32
|
+
* When `true`, renders a back button in the leading slot.
|
|
33
|
+
* @default false
|
|
34
|
+
*/
|
|
35
|
+
canGoBack?: boolean;
|
|
36
|
+
/** Called when the auto-rendered back button is pressed. */
|
|
37
|
+
onBackPress?: () => void;
|
|
38
|
+
/**
|
|
39
|
+
* When `true`, wraps the bar in a SafeAreaView that handles the top inset.
|
|
40
|
+
* @default false
|
|
41
|
+
*/
|
|
42
|
+
insetTop?: boolean;
|
|
43
|
+
/**
|
|
44
|
+
* When `true`, adds shadow/elevation to indicate the bar is scrolled.
|
|
45
|
+
* @default false
|
|
46
|
+
*/
|
|
47
|
+
elevated?: boolean;
|
|
48
|
+
/** Custom leading content. When provided, overrides `canGoBack`. */
|
|
49
|
+
leading?: ReactNode;
|
|
50
|
+
/** Custom trailing content. When provided, overrides `actions`. */
|
|
51
|
+
trailing?: ReactNode;
|
|
52
|
+
/** Array of icon-button actions rendered in the trailing slot. */
|
|
53
|
+
actions?: AppBarAction[];
|
|
54
|
+
/**
|
|
55
|
+
* Override the container (background) color.
|
|
56
|
+
* Applied to both normal and elevated states.
|
|
57
|
+
*/
|
|
58
|
+
containerColor?: string;
|
|
59
|
+
/**
|
|
60
|
+
* Override the content (title and icon) color.
|
|
61
|
+
*/
|
|
62
|
+
contentColor?: string;
|
|
63
|
+
/** Additional style applied to the title text. */
|
|
64
|
+
titleStyle?: StyleProp<TextStyle>;
|
|
65
|
+
/** Custom style applied to the root container. */
|
|
66
|
+
style?: StyleProp<ViewStyle>;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
declare function AppBar({ title, variant, canGoBack, onBackPress, insetTop, elevated, leading, trailing, actions, containerColor, contentColor, titleStyle, style, }: AppBarProps): react_jsx_runtime.JSX.Element;
|
|
70
|
+
|
|
71
|
+
export { AppBar, type AppBarAction, type AppBarProps, type AppBarVariant };
|