@muja-ui/native 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/LICENSE +21 -0
- package/README.md +102 -0
- package/dist/index.cjs +2487 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +1039 -0
- package/dist/index.d.ts +1039 -0
- package/dist/index.js +2399 -0
- package/dist/index.js.map +1 -0
- package/package.json +71 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 muja-ui contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
# @muja-ui/native
|
|
2
|
+
|
|
3
|
+
React Native / Expo components for muja-ui. Same design tokens, same theme
|
|
4
|
+
engine and the same prop vocabulary as [`@muja-ui/web`](../web) — one design
|
|
5
|
+
system, two renderers.
|
|
6
|
+
|
|
7
|
+
```sh
|
|
8
|
+
pnpm add @muja-ui/native @muja-ui/theme-sdu
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
Peer dependencies: `react`, `react-native`, `react-native-safe-area-context`,
|
|
12
|
+
`react-native-svg`.
|
|
13
|
+
|
|
14
|
+
## Setup
|
|
15
|
+
|
|
16
|
+
Wrap the app once. `SafeAreaProvider` must be outside `ThemeProvider`, because
|
|
17
|
+
`Screen`, `BottomSheet`, `Drawer` and `ToastProvider` all read safe-area insets.
|
|
18
|
+
|
|
19
|
+
```tsx
|
|
20
|
+
import { sduDarkTheme, sduLightTheme } from '@muja-ui/theme-sdu';
|
|
21
|
+
import { ThemeProvider, ToastProvider } from '@muja-ui/native';
|
|
22
|
+
import { SafeAreaProvider } from 'react-native-safe-area-context';
|
|
23
|
+
|
|
24
|
+
export default function RootLayout() {
|
|
25
|
+
return (
|
|
26
|
+
<SafeAreaProvider>
|
|
27
|
+
<ThemeProvider theme={sduLightTheme} darkTheme={sduDarkTheme}>
|
|
28
|
+
<ToastProvider>
|
|
29
|
+
<Stack />
|
|
30
|
+
</ToastProvider>
|
|
31
|
+
</ThemeProvider>
|
|
32
|
+
</SafeAreaProvider>
|
|
33
|
+
);
|
|
34
|
+
}
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
`colorMode` defaults to `'system'` and follows the OS through
|
|
38
|
+
`useColorScheme()`. React Native has no synchronous storage, so persistence is
|
|
39
|
+
the app's job — pass the stored value as `colorMode` and save from
|
|
40
|
+
`onColorModeChange`.
|
|
41
|
+
|
|
42
|
+
## How it differs from the web package
|
|
43
|
+
|
|
44
|
+
Both packages take the same props for the same concepts (`variant`, `size`,
|
|
45
|
+
`tone`, `loading`, `fullWidth`, `invalid`, and the token style props `p`, `px`,
|
|
46
|
+
`bg`, `radius`, `shadow`, `w`, `h`, …). The differences are all forced by the
|
|
47
|
+
platform:
|
|
48
|
+
|
|
49
|
+
| | Web | Native |
|
|
50
|
+
|---|---|---|
|
|
51
|
+
| Styling | `mj-*` classes + `var(--mj-*)` | `useTheme()` resolves tokens to a `StyleSheet` object |
|
|
52
|
+
| Entry points | `.` (RSC-safe) + `./client` | one entry — there are no Server Components |
|
|
53
|
+
| Change handlers | DOM events (`onChange(event)`) | value callbacks (`onChange(nextValue)`) |
|
|
54
|
+
| `Select` | `<option>` children | an `options` array |
|
|
55
|
+
| Anchored menus | `DropdownMenu`, `Popover` | `ActionSheet` — a dropdown anchored to a tap target is wrong on a phone |
|
|
56
|
+
| `Table` | semantic `<table>` | not provided; use `ListRow` or a `FlatList` |
|
|
57
|
+
| Tooltip | hover | long-press, and the label doubles as the accessibility hint |
|
|
58
|
+
| `Tabs` | `TabList` / `Tab` / `TabPanel` | an `items` array; the screen renders the panel for the active value |
|
|
59
|
+
|
|
60
|
+
Native-only additions, for things every screen needs: `Screen` (safe-area page
|
|
61
|
+
shell with pull-to-refresh), `ListRow`, `EmptyState`, `FormField`, `HStack`.
|
|
62
|
+
|
|
63
|
+
## Components
|
|
64
|
+
|
|
65
|
+
**Primitives** — `Box`, `Flex`, `Stack`, `HStack`, `Spacer`, `Divider`, `Text`,
|
|
66
|
+
`Heading`, `Icon`
|
|
67
|
+
|
|
68
|
+
**Form** — `Button`, `IconButton`, `Input`, `Textarea`, `Label`, `FormField`,
|
|
69
|
+
`Checkbox`, `Switch`, `RadioGroup` / `Radio`, `Select`
|
|
70
|
+
|
|
71
|
+
**Feedback** — `Spinner`, `Skeleton`, `Progress`, `EmptyState`,
|
|
72
|
+
`ToastProvider` / `useToast`
|
|
73
|
+
|
|
74
|
+
**Layout & data** — `Screen`, `Container`, `Section`, `Card` (+ `CardHeader`,
|
|
75
|
+
`CardTitle`, `CardDescription`, `CardContent`, `CardFooter`), `ListRow`,
|
|
76
|
+
`Badge`, `Chip`, `Avatar`, `Tabs`, `Accordion` / `Collapse`, `Calendar`,
|
|
77
|
+
`Carousel`, `Tooltip`
|
|
78
|
+
|
|
79
|
+
**Overlays** — `Modal` (+ `ModalHeader`, `ModalTitle`, `ModalBody`,
|
|
80
|
+
`ModalFooter`), `BottomSheet`, `Drawer`, `ActionSheet`
|
|
81
|
+
|
|
82
|
+
## Conventions
|
|
83
|
+
|
|
84
|
+
- Every colour comes from a semantic token (`theme.colors.*`). No component
|
|
85
|
+
contains a raw colour value, so brand themes and dark mode apply for free.
|
|
86
|
+
- Sizes come from `sizeMetrics` and variants from `variantColors`
|
|
87
|
+
(`src/system/variants.ts`), so a `size="lg"` Button, Input and Select all
|
|
88
|
+
agree on height.
|
|
89
|
+
- Interactive components carry `accessibilityRole` and `accessibilityState`;
|
|
90
|
+
`IconButton` requires `accessibilityLabel` at the type level.
|
|
91
|
+
|
|
92
|
+
## Testing
|
|
93
|
+
|
|
94
|
+
React Native can't load under vitest/jsdom (untranspiled Flow, native
|
|
95
|
+
runtime), so `test/react-native-stub.tsx` renders each RN primitive as a host
|
|
96
|
+
element and maps `accessibility*` props to their ARIA equivalents. Tests then
|
|
97
|
+
query by role and label, and read resolved styles via `styleOf()`. The stub is
|
|
98
|
+
test-only and never ships.
|
|
99
|
+
|
|
100
|
+
```sh
|
|
101
|
+
pnpm test
|
|
102
|
+
```
|