@xaui/core 0.1.4
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 +298 -0
- package/dist/index.cjs +36 -0
- package/dist/index.d.cts +9 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.js +9 -0
- package/package.json +69 -0
package/README.md
ADDED
|
@@ -0,0 +1,298 @@
|
|
|
1
|
+
# @xaui/core
|
|
2
|
+
|
|
3
|
+
A modern React Native component library strongly inspired by Flutter. Provides ready-to-use UI components with Flutter-like API, smooth animations powered by React Native Reanimated, and a comprehensive design system.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
pnpm add @xaui/core
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Features
|
|
12
|
+
|
|
13
|
+
- **Flutter-inspired Components**: Ready-to-use UI components with Flutter-like API and intuitive props (`padding`, `margin`, `borderRadius`)
|
|
14
|
+
- **Powerful Theme System**: Dynamic theming with deep customization support
|
|
15
|
+
- **Smooth Animations**: Built on React Native Reanimated for native performance
|
|
16
|
+
- **Design System**: Integrated with @xaui/colors for consistent theming
|
|
17
|
+
- **TypeScript First**: Fully typed for excellent developer experience
|
|
18
|
+
- **Performance**: Optimized for mobile with native animations
|
|
19
|
+
|
|
20
|
+
## Theme System
|
|
21
|
+
|
|
22
|
+
### XUIProvider
|
|
23
|
+
|
|
24
|
+
Wrap your app with `XUIProvider` to enable theming throughout your application.
|
|
25
|
+
|
|
26
|
+
```typescript
|
|
27
|
+
import { XUIProvider } from '@xaui/core/theme'
|
|
28
|
+
|
|
29
|
+
export default function App() {
|
|
30
|
+
return (
|
|
31
|
+
<XUIProvider>
|
|
32
|
+
{/* Your app content */}
|
|
33
|
+
</XUIProvider>
|
|
34
|
+
)
|
|
35
|
+
}
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
### Custom Theme
|
|
39
|
+
|
|
40
|
+
You can provide a custom theme with partial overrides:
|
|
41
|
+
|
|
42
|
+
```typescript
|
|
43
|
+
import { XUIProvider } from '@xaui/core/theme'
|
|
44
|
+
|
|
45
|
+
const customTheme = {
|
|
46
|
+
colors: {
|
|
47
|
+
primary: {
|
|
48
|
+
main: '#FF6B6B',
|
|
49
|
+
foreground: '#FFFFFF',
|
|
50
|
+
background: '#FFE5E5',
|
|
51
|
+
},
|
|
52
|
+
secondary: {
|
|
53
|
+
main: '#4ECDC4',
|
|
54
|
+
foreground: '#FFFFFF',
|
|
55
|
+
background: '#E0F7F6',
|
|
56
|
+
},
|
|
57
|
+
default: {
|
|
58
|
+
main: '#2C3E50',
|
|
59
|
+
foreground: '#FFFFFF',
|
|
60
|
+
background: '#ECF0F1',
|
|
61
|
+
},
|
|
62
|
+
background: '#FFFFFF',
|
|
63
|
+
foreground: '#111827',
|
|
64
|
+
},
|
|
65
|
+
fontFamilies: {
|
|
66
|
+
body: 'Inter',
|
|
67
|
+
heading: 'Poppins',
|
|
68
|
+
default: 'Courier New',
|
|
69
|
+
},
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
export default function App() {
|
|
73
|
+
return (
|
|
74
|
+
<XUIProvider theme={customTheme}>
|
|
75
|
+
{/* Your app content */}
|
|
76
|
+
</XUIProvider>
|
|
77
|
+
)
|
|
78
|
+
}
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
### Automatic Light/Dark Theme Switching
|
|
82
|
+
|
|
83
|
+
The `XUIProvider` automatically switches between light and dark themes based on the system's color scheme:
|
|
84
|
+
|
|
85
|
+
```typescript
|
|
86
|
+
import { XUIProvider, theme, darkTheme } from '@xaui/core/theme'
|
|
87
|
+
|
|
88
|
+
export default function App() {
|
|
89
|
+
return (
|
|
90
|
+
<XUIProvider theme={theme} darkTheme={darkTheme}>
|
|
91
|
+
{/* Your app content will automatically switch between light and dark themes */}
|
|
92
|
+
</XUIProvider>
|
|
93
|
+
)
|
|
94
|
+
}
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
### Custom Light and Dark Themes
|
|
98
|
+
|
|
99
|
+
You can provide custom themes for both light and dark modes:
|
|
100
|
+
|
|
101
|
+
```typescript
|
|
102
|
+
import { XUIProvider } from '@xaui/core/theme'
|
|
103
|
+
|
|
104
|
+
const customLightTheme = {
|
|
105
|
+
colors: {
|
|
106
|
+
primary: {
|
|
107
|
+
main: '#3B82F6',
|
|
108
|
+
foreground: '#FFFFFF',
|
|
109
|
+
background: '#DBEAFE',
|
|
110
|
+
},
|
|
111
|
+
background: '#FFFFFF',
|
|
112
|
+
foreground: '#000000',
|
|
113
|
+
},
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
const customDarkTheme = {
|
|
117
|
+
colors: {
|
|
118
|
+
primary: {
|
|
119
|
+
main: '#60A5FA',
|
|
120
|
+
foreground: '#1F2937',
|
|
121
|
+
background: '#1E3A8A',
|
|
122
|
+
},
|
|
123
|
+
background: '#000000',
|
|
124
|
+
foreground: '#FFFFFF',
|
|
125
|
+
},
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
export default function App() {
|
|
129
|
+
return (
|
|
130
|
+
<XUIProvider theme={customLightTheme} darkTheme={customDarkTheme}>
|
|
131
|
+
{/* Automatically switches between custom light and dark themes */}
|
|
132
|
+
</XUIProvider>
|
|
133
|
+
)
|
|
134
|
+
}
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
### Dark Theme Only
|
|
138
|
+
|
|
139
|
+
To use only dark theme without automatic switching:
|
|
140
|
+
|
|
141
|
+
```typescript
|
|
142
|
+
import { XUIProvider, darkTheme } from '@xaui/core/theme'
|
|
143
|
+
|
|
144
|
+
export default function App() {
|
|
145
|
+
return (
|
|
146
|
+
<XUIProvider theme={darkTheme}>
|
|
147
|
+
{/* Your app content will always use dark theme */}
|
|
148
|
+
</XUIProvider>
|
|
149
|
+
)
|
|
150
|
+
}
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
## useXUITheme Hook
|
|
154
|
+
|
|
155
|
+
Access theme values in your components using the `useXUITheme` hook.
|
|
156
|
+
|
|
157
|
+
### Basic Usage
|
|
158
|
+
|
|
159
|
+
```typescript
|
|
160
|
+
import { useXUITheme } from '@xaui/core/theme'
|
|
161
|
+
import { View, Text } from 'react-native'
|
|
162
|
+
|
|
163
|
+
function MyComponent() {
|
|
164
|
+
const theme = useXUITheme()
|
|
165
|
+
|
|
166
|
+
return (
|
|
167
|
+
<View style={{ backgroundColor: theme.colors.primary.background }}>
|
|
168
|
+
<Text style={{ color: theme.colors.primary.foreground }}>
|
|
169
|
+
Hello World
|
|
170
|
+
</Text>
|
|
171
|
+
</View>
|
|
172
|
+
)
|
|
173
|
+
}
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
### Accessing Theme Properties
|
|
177
|
+
|
|
178
|
+
The theme object provides access to all design tokens:
|
|
179
|
+
|
|
180
|
+
```typescript
|
|
181
|
+
const theme = useXUITheme()
|
|
182
|
+
|
|
183
|
+
// Access colors
|
|
184
|
+
const primaryMain = theme.colors.primary.main
|
|
185
|
+
const primaryForeground = theme.colors.primary.foreground
|
|
186
|
+
const primaryBackground = theme.colors.primary.background
|
|
187
|
+
const appBackground = theme.colors.background
|
|
188
|
+
const appForeground = theme.colors.foreground
|
|
189
|
+
|
|
190
|
+
// Access spacing
|
|
191
|
+
const padding = theme.spacing.md
|
|
192
|
+
|
|
193
|
+
// Access border radius
|
|
194
|
+
const borderRadius = theme.borderRadius.lg
|
|
195
|
+
|
|
196
|
+
// Access border width
|
|
197
|
+
const borderWidth = theme.borderWidth.sm
|
|
198
|
+
|
|
199
|
+
// Access typography
|
|
200
|
+
const fontSize = theme.fontSizes.xl
|
|
201
|
+
const fontFamily = theme.fontFamilies.body
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
### Available Color Roles
|
|
205
|
+
|
|
206
|
+
The theme uses a Material Design-inspired color system with a flat structure. Each color role has three related properties:
|
|
207
|
+
|
|
208
|
+
- Main color (e.g., `primary.main`) - The primary color for this role (string)
|
|
209
|
+
- Foreground color (e.g., `primary.foreground`) - Text/content on the main color (string)
|
|
210
|
+
- Background color (e.g., `primary.background`) - Surfaces/containers for this role (string)
|
|
211
|
+
|
|
212
|
+
#### Brand Colors
|
|
213
|
+
|
|
214
|
+
- `theme.colors.primary.main` - Main primary brand color
|
|
215
|
+
- `theme.colors.primary.foreground` - Text color on primary backgrounds
|
|
216
|
+
- `theme.colors.primary.background` - Primary surface/container color
|
|
217
|
+
|
|
218
|
+
- `theme.colors.secondary.main` - Main secondary brand color
|
|
219
|
+
- `theme.colors.secondary.foreground` - Text color on secondary backgrounds
|
|
220
|
+
- `theme.colors.secondary.background` - Secondary surface/container color
|
|
221
|
+
|
|
222
|
+
- `theme.colors.tertiary.main` - Main tertiary brand color
|
|
223
|
+
- `theme.colors.tertiary.foreground` - Text color on tertiary backgrounds
|
|
224
|
+
- `theme.colors.tertiary.background` - Tertiary surface/container color
|
|
225
|
+
|
|
226
|
+
#### Semantic Colors
|
|
227
|
+
|
|
228
|
+
- `theme.colors.danger.main` - Main danger/error color
|
|
229
|
+
- `theme.colors.danger.foreground` - Text color on danger backgrounds
|
|
230
|
+
- `theme.colors.danger.background` - Danger surface/container color
|
|
231
|
+
|
|
232
|
+
- `theme.colors.warning.main` - Main warning/caution color
|
|
233
|
+
- `theme.colors.warning.foreground` - Text color on warning backgrounds
|
|
234
|
+
- `theme.colors.warning.background` - Warning surface/container color
|
|
235
|
+
|
|
236
|
+
- `theme.colors.success.main` - Main success/positive color
|
|
237
|
+
- `theme.colors.success.foreground` - Text color on success backgrounds
|
|
238
|
+
- `theme.colors.success.background` - Success surface/container color
|
|
239
|
+
|
|
240
|
+
#### Utility Colors
|
|
241
|
+
|
|
242
|
+
- `theme.colors.default.main` - Default text/content color
|
|
243
|
+
- `theme.colors.default.foreground` - Text color on default backgrounds
|
|
244
|
+
- `theme.colors.default.background` - Default surface/container color
|
|
245
|
+
|
|
246
|
+
#### Background
|
|
247
|
+
|
|
248
|
+
- `theme.colors.background` - Main background color
|
|
249
|
+
- `theme.colors.foreground` - Text color on background
|
|
250
|
+
|
|
251
|
+
## useColorMode Hook
|
|
252
|
+
|
|
253
|
+
Access the current color scheme with a hook that works on both native and web:
|
|
254
|
+
|
|
255
|
+
```typescript
|
|
256
|
+
import { useColorMode } from '@xaui/core/theme'
|
|
257
|
+
|
|
258
|
+
const mode = useColorMode() // 'light' | 'dark'
|
|
259
|
+
```
|
|
260
|
+
|
|
261
|
+
## Color Tokens
|
|
262
|
+
|
|
263
|
+
Access the full Tailwind-inspired color palette:
|
|
264
|
+
|
|
265
|
+
```typescript
|
|
266
|
+
import { colors } from '@xaui/core/colors'
|
|
267
|
+
|
|
268
|
+
const blue500 = colors.blue[500]
|
|
269
|
+
const red600 = colors.red[600]
|
|
270
|
+
```
|
|
271
|
+
|
|
272
|
+
## TypeScript Support
|
|
273
|
+
|
|
274
|
+
All exports are fully typed for excellent IntelliSense support:
|
|
275
|
+
|
|
276
|
+
```typescript
|
|
277
|
+
import type { XUITheme } from '@xaui/core/theme'
|
|
278
|
+
```
|
|
279
|
+
|
|
280
|
+
## Theme Structure
|
|
281
|
+
|
|
282
|
+
The default theme includes:
|
|
283
|
+
|
|
284
|
+
- **Colors**: Material Design-inspired color system with a flat structure. Each role has three related properties:
|
|
285
|
+
- Main color (e.g., `primary.main`) - The primary color for this role
|
|
286
|
+
- Foreground color (e.g., `primary.foreground`) - Text color for content on the main color
|
|
287
|
+
- Background color (e.g., `primary.background`) - Color for surfaces/containers using this role
|
|
288
|
+
- **Spacing**: xs, sm, md, lg, xl, 2xl, 3xl (4px to 64px)
|
|
289
|
+
- **Border Radius**: none, sm, md, lg, xl, 2xl, 3xl, full (0px to 9999px)
|
|
290
|
+
- **Border Width**: none, xs, sm, md, lg, xl (0px to 4px)
|
|
291
|
+
- **Font Sizes**: xs to 4xl (12px to 36px)
|
|
292
|
+
- **Font Weights**: light, normal, medium, semibold, bold, extrabold
|
|
293
|
+
- **Font Families**: body, heading, default (defaults to 'System' and 'monospace')
|
|
294
|
+
- **Shadows**: sm, md, lg, xl with React Native shadow properties
|
|
295
|
+
|
|
296
|
+
## License
|
|
297
|
+
|
|
298
|
+
MIT
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/index.ts
|
|
21
|
+
var index_exports = {};
|
|
22
|
+
__export(index_exports, {
|
|
23
|
+
withOpacity: () => withOpacity
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(index_exports);
|
|
26
|
+
|
|
27
|
+
// src/utils/colors-utils.ts
|
|
28
|
+
function withOpacity(color, opacity) {
|
|
29
|
+
const clampedOpacity = Math.max(0, Math.min(1, opacity));
|
|
30
|
+
const alpha = Math.round(clampedOpacity * 255).toString(16).padStart(2, "0");
|
|
31
|
+
return `${color}${alpha}`;
|
|
32
|
+
}
|
|
33
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
34
|
+
0 && (module.exports = {
|
|
35
|
+
withOpacity
|
|
36
|
+
});
|
package/dist/index.d.cts
ADDED
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
// src/utils/colors-utils.ts
|
|
2
|
+
function withOpacity(color, opacity) {
|
|
3
|
+
const clampedOpacity = Math.max(0, Math.min(1, opacity));
|
|
4
|
+
const alpha = Math.round(clampedOpacity * 255).toString(16).padStart(2, "0");
|
|
5
|
+
return `${color}${alpha}`;
|
|
6
|
+
}
|
|
7
|
+
export {
|
|
8
|
+
withOpacity
|
|
9
|
+
};
|
package/package.json
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@xaui/core",
|
|
3
|
+
"version": "0.1.4",
|
|
4
|
+
"description": "A modern React Native UI library with Flutter-inspired API, smooth animations, and comprehensive design system",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"react-native",
|
|
7
|
+
"ui",
|
|
8
|
+
"components",
|
|
9
|
+
"flutter",
|
|
10
|
+
"design-system",
|
|
11
|
+
"typescript",
|
|
12
|
+
"xaui",
|
|
13
|
+
"reanimated",
|
|
14
|
+
"animation"
|
|
15
|
+
],
|
|
16
|
+
"type": "module",
|
|
17
|
+
"main": "./dist/index.js",
|
|
18
|
+
"types": "./dist/index.d.ts",
|
|
19
|
+
"exports": {
|
|
20
|
+
".": {
|
|
21
|
+
"types": "./dist/index.d.ts",
|
|
22
|
+
"import": "./dist/index.js",
|
|
23
|
+
"require": "./dist/index.js"
|
|
24
|
+
},
|
|
25
|
+
"./palette": {
|
|
26
|
+
"types": "./dist/tokens/index.d.ts",
|
|
27
|
+
"import": "./dist/tokens/index.js",
|
|
28
|
+
"require": "./dist/tokens/index.js"
|
|
29
|
+
},
|
|
30
|
+
"./theme": {
|
|
31
|
+
"types": "./dist/theme/index.d.ts",
|
|
32
|
+
"import": "./dist/theme/index.js",
|
|
33
|
+
"require": "./dist/theme/index.js"
|
|
34
|
+
}
|
|
35
|
+
},
|
|
36
|
+
"files": [
|
|
37
|
+
"dist",
|
|
38
|
+
"package.json"
|
|
39
|
+
],
|
|
40
|
+
"repository": {
|
|
41
|
+
"type": "git",
|
|
42
|
+
"url": "git+https://github.com/rygrams/xaui.git",
|
|
43
|
+
"directory": "packages/core"
|
|
44
|
+
},
|
|
45
|
+
"peerDependencies": {
|
|
46
|
+
"react": "^18.0.0 || ^19.0.0",
|
|
47
|
+
"react-native": ">=0.70.0"
|
|
48
|
+
},
|
|
49
|
+
"devDependencies": {
|
|
50
|
+
"@types/react": "^19.1.0",
|
|
51
|
+
"@types/react-native": "^0.73.0",
|
|
52
|
+
"react": "19.1.0",
|
|
53
|
+
"react-native": "^0.81.5",
|
|
54
|
+
"tsup": "^8.5.1",
|
|
55
|
+
"typescript": "^5.9.3"
|
|
56
|
+
},
|
|
57
|
+
"publishConfig": {
|
|
58
|
+
"access": "public"
|
|
59
|
+
},
|
|
60
|
+
"scripts": {
|
|
61
|
+
"build": "tsup src/index.ts --format cjs,esm --dts --external react --external react-native",
|
|
62
|
+
"dev": "tsup src/index.ts --format cjs,esm --dts --external react --external react-native --watch",
|
|
63
|
+
"test": "vitest",
|
|
64
|
+
"test:ui": "vitest --ui",
|
|
65
|
+
"test:coverage": "vitest --coverage",
|
|
66
|
+
"lint": "eslint src/",
|
|
67
|
+
"type-check": "tsc --noEmit"
|
|
68
|
+
}
|
|
69
|
+
}
|