@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.
Files changed (87) hide show
  1. package/README.md +99 -0
  2. package/dist/appbar/index.d.ts +71 -0
  3. package/dist/appbar/index.js +952 -0
  4. package/dist/button/index.d.ts +41 -0
  5. package/dist/button/index.js +454 -0
  6. package/dist/card/index.d.ts +31 -0
  7. package/dist/card/index.js +264 -0
  8. package/dist/checkbox/index.d.ts +25 -0
  9. package/dist/checkbox/index.js +291 -0
  10. package/dist/chip/index.d.ts +62 -0
  11. package/dist/chip/index.js +452 -0
  12. package/dist/icon-button/index.d.ts +10 -0
  13. package/dist/icon-button/index.js +575 -0
  14. package/dist/index.d.ts +19 -0
  15. package/dist/index.js +3374 -0
  16. package/dist/layout/index.d.ts +98 -0
  17. package/dist/layout/index.js +282 -0
  18. package/dist/list/index.d.ts +60 -0
  19. package/dist/list/index.js +300 -0
  20. package/dist/radio/index.d.ts +25 -0
  21. package/dist/radio/index.js +250 -0
  22. package/dist/switch/index.d.ts +37 -0
  23. package/dist/switch/index.js +315 -0
  24. package/dist/text-field/index.d.ts +52 -0
  25. package/dist/text-field/index.js +496 -0
  26. package/dist/types-D3hlyvz-.d.ts +51 -0
  27. package/dist/typography/index.d.ts +28 -0
  28. package/dist/typography/index.js +69 -0
  29. package/package.json +166 -0
  30. package/src/appbar/AppBar.tsx +302 -0
  31. package/src/appbar/index.ts +2 -0
  32. package/src/appbar/styles.ts +92 -0
  33. package/src/appbar/types.ts +67 -0
  34. package/src/button/Button.tsx +130 -0
  35. package/src/button/index.ts +2 -0
  36. package/src/button/styles.ts +288 -0
  37. package/src/button/types.ts +42 -0
  38. package/src/card/Card.tsx +69 -0
  39. package/src/card/index.ts +2 -0
  40. package/src/card/styles.ts +151 -0
  41. package/src/card/types.ts +27 -0
  42. package/src/checkbox/Checkbox.tsx +109 -0
  43. package/src/checkbox/index.ts +2 -0
  44. package/src/checkbox/styles.ts +155 -0
  45. package/src/checkbox/types.ts +20 -0
  46. package/src/chip/Chip.tsx +182 -0
  47. package/src/chip/index.ts +2 -0
  48. package/src/chip/styles.ts +240 -0
  49. package/src/chip/types.ts +58 -0
  50. package/src/icon-button/IconButton.tsx +358 -0
  51. package/src/icon-button/index.ts +6 -0
  52. package/src/icon-button/styles.ts +259 -0
  53. package/src/icon-button/types.ts +55 -0
  54. package/src/index.ts +51 -0
  55. package/src/layout/Box.tsx +99 -0
  56. package/src/layout/Column.tsx +16 -0
  57. package/src/layout/Grid.tsx +49 -0
  58. package/src/layout/Layout.tsx +81 -0
  59. package/src/layout/Row.tsx +22 -0
  60. package/src/layout/index.ts +13 -0
  61. package/src/layout/resolveSpacing.ts +11 -0
  62. package/src/layout/types.ts +82 -0
  63. package/src/list/List.tsx +17 -0
  64. package/src/list/ListDivider.tsx +20 -0
  65. package/src/list/ListItem.tsx +128 -0
  66. package/src/list/index.ts +9 -0
  67. package/src/list/styles.ts +132 -0
  68. package/src/list/types.ts +54 -0
  69. package/src/radio/Radio.tsx +103 -0
  70. package/src/radio/index.ts +2 -0
  71. package/src/radio/styles.ts +139 -0
  72. package/src/radio/types.ts +20 -0
  73. package/src/switch/Switch.tsx +118 -0
  74. package/src/switch/index.ts +2 -0
  75. package/src/switch/styles.ts +172 -0
  76. package/src/switch/types.ts +32 -0
  77. package/src/test-utils/render-with-theme.tsx +13 -0
  78. package/src/text-field/TextField.tsx +298 -0
  79. package/src/text-field/index.ts +2 -0
  80. package/src/text-field/styles.ts +240 -0
  81. package/src/text-field/types.ts +49 -0
  82. package/src/typography/Typography.tsx +65 -0
  83. package/src/typography/index.ts +3 -0
  84. package/src/typography/types.ts +17 -0
  85. package/src/utils/color.ts +64 -0
  86. package/src/utils/elevation.ts +33 -0
  87. 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 };