@lunar-kit/core 0.1.0 → 0.1.1
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 +295 -0
- package/package.json +1 -1
package/README.MD
ADDED
|
@@ -0,0 +1,295 @@
|
|
|
1
|
+
# @lunar-kit/core
|
|
2
|
+
|
|
3
|
+
Core package for Lunar Kit - Shared registry and component definitions for React Native with NativeWind.
|
|
4
|
+
|
|
5
|
+
## Overview
|
|
6
|
+
|
|
7
|
+
`@lunar-kit/core` is the foundational package that powers the Lunar Kit ecosystem. It contains:
|
|
8
|
+
|
|
9
|
+
- **Component Registry**: Metadata and definitions for all available components
|
|
10
|
+
- **Component Source Files**: Pre-built React Native components styled with NativeWind
|
|
11
|
+
- **Shared Constants**: Paths and configuration used across the CLI and projects
|
|
12
|
+
- **Type Definitions**: TypeScript types for components and registry
|
|
13
|
+
|
|
14
|
+
## Installation
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
npm install @lunar-kit/core
|
|
18
|
+
# or
|
|
19
|
+
pnpm add @lunar-kit/core
|
|
20
|
+
# or
|
|
21
|
+
yarn add @lunar-kit/core
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
> **Note**: This package is typically installed automatically as a dependency of `@lunar-kit/cli` and doesn't need to be installed manually in most cases.
|
|
25
|
+
|
|
26
|
+
## What's Inside
|
|
27
|
+
|
|
28
|
+
### Component Registry
|
|
29
|
+
|
|
30
|
+
The registry defines metadata for each component including:
|
|
31
|
+
|
|
32
|
+
```typescript
|
|
33
|
+
{
|
|
34
|
+
name: "button",
|
|
35
|
+
type: "ui",
|
|
36
|
+
description: "A versatile button component",
|
|
37
|
+
files: [
|
|
38
|
+
{
|
|
39
|
+
path: "components/ui/button.tsx",
|
|
40
|
+
type: "ui"
|
|
41
|
+
}
|
|
42
|
+
],
|
|
43
|
+
dependencies: ["clsx", "tailwind-merge"],
|
|
44
|
+
registryDependencies: []
|
|
45
|
+
}
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
### Components Library
|
|
49
|
+
|
|
50
|
+
Pre-built, production-ready components for React Native:
|
|
51
|
+
|
|
52
|
+
#### Form Components
|
|
53
|
+
- **Button** - Versatile button with variants (default, destructive, outline, ghost, link)
|
|
54
|
+
- **Input** - Text input with label and error states
|
|
55
|
+
- **Textarea** - Multi-line text input
|
|
56
|
+
- **Checkbox** - Checkbox with label support
|
|
57
|
+
- **Radio** / **Radio Group** - Radio button components
|
|
58
|
+
- **Select** / **Select Sheet** - Dropdown and bottom sheet pickers
|
|
59
|
+
|
|
60
|
+
#### Layout Components
|
|
61
|
+
- **Card** - Container with header, content, and footer
|
|
62
|
+
- **Dialog** - Modal dialog with overlay
|
|
63
|
+
- **Bottom Sheet** - Sliding bottom panel
|
|
64
|
+
- **Banner** - Alert/notification banner
|
|
65
|
+
|
|
66
|
+
#### Display Components
|
|
67
|
+
- **Avatar** - User avatar with fallback
|
|
68
|
+
- **Badge** - Label/tag component with variants
|
|
69
|
+
- **Text** - Styled text component with variants
|
|
70
|
+
|
|
71
|
+
#### Data Components
|
|
72
|
+
- **Calendar** - Date selection calendar
|
|
73
|
+
- **Date Picker** - Date input with calendar
|
|
74
|
+
- **Date Range Picker** - Select date ranges
|
|
75
|
+
|
|
76
|
+
#### Navigation
|
|
77
|
+
- **Tabs** - Tab navigation component
|
|
78
|
+
|
|
79
|
+
#### Advanced
|
|
80
|
+
- **Accordion** - Collapsible content sections
|
|
81
|
+
- **Form** - Form wrapper with validation support
|
|
82
|
+
|
|
83
|
+
### Styling
|
|
84
|
+
|
|
85
|
+
All components are built with:
|
|
86
|
+
|
|
87
|
+
- **NativeWind** - Tailwind CSS for React Native
|
|
88
|
+
- **Consistent Design System** - Following design tokens and patterns
|
|
89
|
+
- **Dark Mode Support** - Built-in theme switching capabilities
|
|
90
|
+
- **Accessibility** - ARIA labels and accessible components
|
|
91
|
+
|
|
92
|
+
## Usage
|
|
93
|
+
|
|
94
|
+
### For CLI Tool Developers
|
|
95
|
+
|
|
96
|
+
```typescript
|
|
97
|
+
import {
|
|
98
|
+
LOCAL_REGISTRY_PATH,
|
|
99
|
+
LOCAL_COMPONENTS_PATH
|
|
100
|
+
} from '@lunar-kit/core';
|
|
101
|
+
|
|
102
|
+
// Access registry metadata
|
|
103
|
+
const registryPath = LOCAL_REGISTRY_PATH;
|
|
104
|
+
|
|
105
|
+
// Access component source files
|
|
106
|
+
const componentsPath = LOCAL_COMPONENTS_PATH;
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
### For App Developers
|
|
110
|
+
|
|
111
|
+
After using `lunar-kit add <component>`, import components directly:
|
|
112
|
+
|
|
113
|
+
```typescript
|
|
114
|
+
import { Button } from '@/components/ui/button';
|
|
115
|
+
import { Card } from '@/components/ui/card';
|
|
116
|
+
import { Dialog } from '@/components/ui/dialog';
|
|
117
|
+
|
|
118
|
+
export default function MyScreen() {
|
|
119
|
+
return (
|
|
120
|
+
<Card>
|
|
121
|
+
<Button variant="default">
|
|
122
|
+
Click Me
|
|
123
|
+
</Button>
|
|
124
|
+
</Card>
|
|
125
|
+
);
|
|
126
|
+
}
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
## Component Examples
|
|
130
|
+
|
|
131
|
+
### Button Component
|
|
132
|
+
|
|
133
|
+
```typescript
|
|
134
|
+
import { Button } from '@/components/ui/button';
|
|
135
|
+
|
|
136
|
+
<Button variant="default" size="default">
|
|
137
|
+
Default Button
|
|
138
|
+
</Button>
|
|
139
|
+
|
|
140
|
+
<Button variant="destructive">
|
|
141
|
+
Delete
|
|
142
|
+
</Button>
|
|
143
|
+
|
|
144
|
+
<Button variant="outline">
|
|
145
|
+
Cancel
|
|
146
|
+
</Button>
|
|
147
|
+
|
|
148
|
+
<Button variant="ghost">
|
|
149
|
+
Ghost Button
|
|
150
|
+
</Button>
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
### Card Component
|
|
154
|
+
|
|
155
|
+
```typescript
|
|
156
|
+
import { Card } from '@/components/ui/card';
|
|
157
|
+
import { Text } from '@/components/ui/text';
|
|
158
|
+
|
|
159
|
+
<Card>
|
|
160
|
+
<Card.Header>
|
|
161
|
+
<Card.Title>Card Title</Card.Title>
|
|
162
|
+
<Card.Description>Card description goes here</Card.Description>
|
|
163
|
+
</Card.Header>
|
|
164
|
+
<Card.Content>
|
|
165
|
+
<Text>Main content</Text>
|
|
166
|
+
</Card.Content>
|
|
167
|
+
<Card.Footer>
|
|
168
|
+
<Button>Action</Button>
|
|
169
|
+
</Card.Footer>
|
|
170
|
+
</Card>
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
### Dialog Component
|
|
174
|
+
|
|
175
|
+
```typescript
|
|
176
|
+
import { Dialog } from '@/components/ui/dialog';
|
|
177
|
+
import { Button } from '@/components/ui/button';
|
|
178
|
+
|
|
179
|
+
const [open, setOpen] = useState(false);
|
|
180
|
+
|
|
181
|
+
<Dialog open={open} onOpenChange={setOpen}>
|
|
182
|
+
<Dialog.Trigger asChild>
|
|
183
|
+
<Button>Open Dialog</Button>
|
|
184
|
+
</Dialog.Trigger>
|
|
185
|
+
<Dialog.Content>
|
|
186
|
+
<Dialog.Header>
|
|
187
|
+
<Dialog.Title>Dialog Title</Dialog.Title>
|
|
188
|
+
<Dialog.Description>
|
|
189
|
+
Dialog description
|
|
190
|
+
</Dialog.Description>
|
|
191
|
+
</Dialog.Header>
|
|
192
|
+
{/* Dialog content */}
|
|
193
|
+
<Dialog.Footer>
|
|
194
|
+
<Button onPress={() => setOpen(false)}>Close</Button>
|
|
195
|
+
</Dialog.Footer>
|
|
196
|
+
</Dialog.Content>
|
|
197
|
+
</Dialog>
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
## Registry Structure
|
|
201
|
+
|
|
202
|
+
The registry is organized as JSON files in `src/registry/`:
|
|
203
|
+
|
|
204
|
+
```
|
|
205
|
+
registry/
|
|
206
|
+
├── index.json # Main registry index
|
|
207
|
+
└── ui/
|
|
208
|
+
├── button.json
|
|
209
|
+
├── card.json
|
|
210
|
+
├── dialog.json
|
|
211
|
+
└── ... (other components)
|
|
212
|
+
```
|
|
213
|
+
|
|
214
|
+
Each component has a registry entry that defines:
|
|
215
|
+
- Component metadata
|
|
216
|
+
- File paths
|
|
217
|
+
- Dependencies (npm packages)
|
|
218
|
+
- Registry dependencies (other Lunar Kit components)
|
|
219
|
+
|
|
220
|
+
## Exports
|
|
221
|
+
|
|
222
|
+
### Constants
|
|
223
|
+
|
|
224
|
+
```typescript
|
|
225
|
+
// Registry path
|
|
226
|
+
export const LOCAL_REGISTRY_PATH: string;
|
|
227
|
+
|
|
228
|
+
// Components source path
|
|
229
|
+
export const LOCAL_COMPONENTS_PATH: string;
|
|
230
|
+
```
|
|
231
|
+
|
|
232
|
+
### Types
|
|
233
|
+
|
|
234
|
+
```typescript
|
|
235
|
+
export interface ComponentRegistry {
|
|
236
|
+
name: string;
|
|
237
|
+
type: string;
|
|
238
|
+
description?: string;
|
|
239
|
+
files: Array<{
|
|
240
|
+
path: string;
|
|
241
|
+
type: string;
|
|
242
|
+
}>;
|
|
243
|
+
dependencies: string[];
|
|
244
|
+
devDependencies?: string[];
|
|
245
|
+
registryDependencies: string[];
|
|
246
|
+
}
|
|
247
|
+
```
|
|
248
|
+
|
|
249
|
+
## Design Principles
|
|
250
|
+
|
|
251
|
+
1. **Composition First** - Components are designed to be composed together
|
|
252
|
+
2. **Unstyled Base** - Core functionality without opinionated styles
|
|
253
|
+
3. **NativeWind Integration** - Leverage Tailwind utility classes
|
|
254
|
+
4. **TypeScript** - Full type safety throughout
|
|
255
|
+
5. **Accessibility** - WCAG compliant components
|
|
256
|
+
6. **Performance** - Optimized for mobile performance
|
|
257
|
+
|
|
258
|
+
## Customization
|
|
259
|
+
|
|
260
|
+
Components are designed to be customized. You can:
|
|
261
|
+
|
|
262
|
+
1. **Override Styles**: Use NativeWind classes
|
|
263
|
+
2. **Extend Components**: Wrap or extend existing components
|
|
264
|
+
3. **Theme**: Use theme context for global styling
|
|
265
|
+
4. **Variants**: Use built-in variants or create your own
|
|
266
|
+
|
|
267
|
+
## Requirements
|
|
268
|
+
|
|
269
|
+
- **React Native**: >= 0.70.0
|
|
270
|
+
- **React**: >= 18.0.0
|
|
271
|
+
- **NativeWind**: >= 4.0.0
|
|
272
|
+
- **TypeScript**: >= 5.0.0 (recommended)
|
|
273
|
+
|
|
274
|
+
## Versioning
|
|
275
|
+
|
|
276
|
+
This package follows [Semantic Versioning](https://semver.org/):
|
|
277
|
+
|
|
278
|
+
- **Major**: Breaking changes to component APIs
|
|
279
|
+
- **Minor**: New components or non-breaking features
|
|
280
|
+
- **Patch**: Bug fixes and improvements
|
|
281
|
+
|
|
282
|
+
## Contributing
|
|
283
|
+
|
|
284
|
+
Components and registry entries can be contributed to the project. See the main [CONTRIBUTING.md](../../CONTRIBUTING.md) for guidelines.
|
|
285
|
+
|
|
286
|
+
## Links
|
|
287
|
+
|
|
288
|
+
- [Main Repository](https://github.com/dimsmaul/lunar-kit)
|
|
289
|
+
- [CLI Package](@lunar-kit/cli)
|
|
290
|
+
- [Create Lunar Kit](create-lunar-kit)
|
|
291
|
+
- [Documentation](https://github.com/dimsmaul/lunar-kit#readme)
|
|
292
|
+
|
|
293
|
+
## License
|
|
294
|
+
|
|
295
|
+
MIT © Dimas Maulana
|