@skybin-tech/nebula-ui 0.0.7 → 0.0.10
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 +354 -1
- package/dist/cjs/components/Button/Button.cjs +32 -11
- package/dist/cjs/components/Button/Button.cjs.map +1 -1
- package/dist/cjs/components/Form/Checkbox.cjs +2 -2
- package/dist/cjs/components/Form/Checkbox.cjs.map +1 -1
- package/dist/cjs/components/Form/Form.cjs +49 -34
- package/dist/cjs/components/Form/Form.cjs.map +1 -1
- package/dist/cjs/components/Form/Radio.cjs +2 -2
- package/dist/cjs/components/Form/Radio.cjs.map +1 -1
- package/dist/cjs/components/Form/Select.cjs +4 -17
- package/dist/cjs/components/Form/Select.cjs.map +1 -1
- package/dist/cjs/components/Form/Switch.cjs +2 -2
- package/dist/cjs/components/Form/Switch.cjs.map +1 -1
- package/dist/cjs/components/Form/TextArea.cjs +4 -17
- package/dist/cjs/components/Form/TextArea.cjs.map +1 -1
- package/dist/cjs/components/Form/TextBox.cjs +11 -21
- package/dist/cjs/components/Form/TextBox.cjs.map +1 -1
- package/dist/cjs/components/Form/variants.cjs +16 -0
- package/dist/cjs/components/Form/variants.cjs.map +1 -0
- package/dist/cjs/index.cjs +16 -45
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs/{components/ui → primitives}/avatar.cjs +2 -2
- package/dist/cjs/primitives/avatar.cjs.map +1 -0
- package/dist/cjs/{components/ui → primitives}/badge.cjs +1 -1
- package/dist/cjs/primitives/badge.cjs.map +1 -0
- package/dist/cjs/{components/ui → primitives}/card.cjs +4 -4
- package/dist/cjs/primitives/card.cjs.map +1 -0
- package/dist/cjs/{components/ui → primitives}/checkbox.cjs +3 -3
- package/dist/cjs/primitives/checkbox.cjs.map +1 -0
- package/dist/cjs/{components/ui → primitives}/dropdown-menu.cjs +19 -17
- package/dist/cjs/primitives/dropdown-menu.cjs.map +1 -0
- package/dist/cjs/{components/ui → primitives}/input.cjs +1 -1
- package/dist/cjs/primitives/input.cjs.map +1 -0
- package/dist/cjs/{components/ui → primitives}/label.cjs +1 -1
- package/dist/cjs/primitives/label.cjs.map +1 -0
- package/dist/cjs/{components/ui → primitives}/radio-group.cjs +1 -1
- package/dist/cjs/primitives/radio-group.cjs.map +1 -0
- package/dist/cjs/{components/ui → primitives}/select.cjs +3 -5
- package/dist/cjs/primitives/select.cjs.map +1 -0
- package/dist/cjs/{components/ui → primitives}/separator.cjs +1 -1
- package/dist/cjs/primitives/separator.cjs.map +1 -0
- package/dist/cjs/{components/ui → primitives}/switch.cjs +1 -1
- package/dist/cjs/primitives/switch.cjs.map +1 -0
- package/dist/cjs/{components/ui → primitives}/textarea.cjs +1 -1
- package/dist/cjs/primitives/textarea.cjs.map +1 -0
- package/dist/components/Button/Button.js +32 -11
- package/dist/components/Button/Button.js.map +1 -1
- package/dist/components/Form/Checkbox.js +2 -2
- package/dist/components/Form/Checkbox.js.map +1 -1
- package/dist/components/Form/Form.js +50 -35
- package/dist/components/Form/Form.js.map +1 -1
- package/dist/components/Form/Radio.js +2 -2
- package/dist/components/Form/Radio.js.map +1 -1
- package/dist/components/Form/Select.js +3 -16
- package/dist/components/Form/Select.js.map +1 -1
- package/dist/components/Form/Switch.js +2 -2
- package/dist/components/Form/Switch.js.map +1 -1
- package/dist/components/Form/TextArea.js +3 -16
- package/dist/components/Form/TextArea.js.map +1 -1
- package/dist/components/Form/TextBox.js +10 -20
- package/dist/components/Form/TextBox.js.map +1 -1
- package/dist/components/Form/variants.js +16 -0
- package/dist/components/Form/variants.js.map +1 -0
- package/dist/index.js +8 -34
- package/dist/index.js.map +1 -1
- package/dist/{components/ui → primitives}/avatar.js +2 -2
- package/dist/primitives/avatar.js.map +1 -0
- package/dist/{components/ui → primitives}/badge.js +1 -1
- package/dist/primitives/badge.js.map +1 -0
- package/dist/{components/ui → primitives}/card.js +4 -4
- package/dist/primitives/card.js.map +1 -0
- package/dist/{components/ui → primitives}/checkbox.js +3 -3
- package/dist/primitives/checkbox.js.map +1 -0
- package/dist/{components/ui → primitives}/dropdown-menu.js +19 -17
- package/dist/primitives/dropdown-menu.js.map +1 -0
- package/dist/{components/ui → primitives}/input.js +1 -1
- package/dist/primitives/input.js.map +1 -0
- package/dist/{components/ui → primitives}/label.js +1 -1
- package/dist/primitives/label.js.map +1 -0
- package/dist/{components/ui → primitives}/radio-group.js +1 -1
- package/dist/primitives/radio-group.js.map +1 -0
- package/dist/{components/ui → primitives}/select.js +5 -7
- package/dist/primitives/select.js.map +1 -0
- package/dist/{components/ui → primitives}/separator.js +1 -1
- package/dist/primitives/separator.js.map +1 -0
- package/dist/{components/ui → primitives}/switch.js +1 -1
- package/dist/primitives/switch.js.map +1 -0
- package/dist/{components/ui → primitives}/textarea.js +1 -1
- package/dist/primitives/textarea.js.map +1 -0
- package/package.json +88 -88
- package/dist/cjs/components/Input/Input.cjs +0 -44
- package/dist/cjs/components/Input/Input.cjs.map +0 -1
- package/dist/cjs/components/ui/avatar.cjs.map +0 -1
- package/dist/cjs/components/ui/badge.cjs.map +0 -1
- package/dist/cjs/components/ui/card.cjs.map +0 -1
- package/dist/cjs/components/ui/checkbox.cjs.map +0 -1
- package/dist/cjs/components/ui/dropdown-menu.cjs.map +0 -1
- package/dist/cjs/components/ui/input.cjs.map +0 -1
- package/dist/cjs/components/ui/label.cjs.map +0 -1
- package/dist/cjs/components/ui/radio-group.cjs.map +0 -1
- package/dist/cjs/components/ui/select.cjs.map +0 -1
- package/dist/cjs/components/ui/separator.cjs.map +0 -1
- package/dist/cjs/components/ui/switch.cjs.map +0 -1
- package/dist/cjs/components/ui/textarea.cjs.map +0 -1
- package/dist/cjs/nebula-ui.css +0 -212
- package/dist/components/Input/Input.js +0 -44
- package/dist/components/Input/Input.js.map +0 -1
- package/dist/components/ui/avatar.js.map +0 -1
- package/dist/components/ui/badge.js.map +0 -1
- package/dist/components/ui/card.js.map +0 -1
- package/dist/components/ui/checkbox.js.map +0 -1
- package/dist/components/ui/dropdown-menu.js.map +0 -1
- package/dist/components/ui/input.js.map +0 -1
- package/dist/components/ui/label.js.map +0 -1
- package/dist/components/ui/radio-group.js.map +0 -1
- package/dist/components/ui/select.js.map +0 -1
- package/dist/components/ui/separator.js.map +0 -1
- package/dist/components/ui/switch.js.map +0 -1
- package/dist/components/ui/textarea.js.map +0 -1
- package/dist/nebula-ui.css +0 -212
package/README.md
CHANGED
|
@@ -1 +1,354 @@
|
|
|
1
|
-
# nebula-ui
|
|
1
|
+
# nebula-ui
|
|
2
|
+
|
|
3
|
+
A React component library built on [shadcn/ui](https://ui.shadcn.com/) patterns, providing form-integrated components with automatic Zod validation, accessible primitives, and utility hooks.
|
|
4
|
+
|
|
5
|
+
See [CHANGELOG.md](CHANGELOG.md) for release history.
|
|
6
|
+
|
|
7
|
+
## Installation
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npm install @skybin-tech/nebula-ui
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
### Peer dependencies
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
npm install react react-dom react-hook-form @hookform/resolvers zod \
|
|
17
|
+
@radix-ui/react-avatar @radix-ui/react-checkbox @radix-ui/react-dropdown-menu \
|
|
18
|
+
@radix-ui/react-label @radix-ui/react-radio-group @radix-ui/react-select \
|
|
19
|
+
@radix-ui/react-separator @radix-ui/react-slot @radix-ui/react-switch \
|
|
20
|
+
class-variance-authority clsx tailwind-merge lucide-react tailwindcss
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
### Styles
|
|
24
|
+
|
|
25
|
+
Import the stylesheet once in your app entry point:
|
|
26
|
+
|
|
27
|
+
```ts
|
|
28
|
+
import "@skybin-tech/nebula-ui/styles.css";
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
---
|
|
32
|
+
|
|
33
|
+
## Form system
|
|
34
|
+
|
|
35
|
+
The form system is built around `react-hook-form` and `zod`. Wrap fields in `<Form>` and each field automatically registers its validation rules — no need to define a schema separately.
|
|
36
|
+
|
|
37
|
+
### Form
|
|
38
|
+
|
|
39
|
+
The root form component. Provides context to all child fields and handles validation and submission.
|
|
40
|
+
|
|
41
|
+
```tsx
|
|
42
|
+
import { Form, TextBox, Button } from "@skybin-tech/nebula-ui";
|
|
43
|
+
|
|
44
|
+
<Form
|
|
45
|
+
onSubmit={(data) => console.log(data)}
|
|
46
|
+
defaultValues={{ username: "", email: "" }}
|
|
47
|
+
>
|
|
48
|
+
<TextBox name="username" label="Username" required minLength={3} maxLength={50} />
|
|
49
|
+
<TextBox name="email" label="Email" type="email" required email />
|
|
50
|
+
<Button type="submit">Submit</Button>
|
|
51
|
+
</Form>
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
You can also provide a base Zod schema that gets merged with field-level rules:
|
|
55
|
+
|
|
56
|
+
```tsx
|
|
57
|
+
const baseSchema = z.object({ username: z.string(), email: z.string() });
|
|
58
|
+
|
|
59
|
+
<Form schema={baseSchema} onSubmit={handleSubmit}>
|
|
60
|
+
<TextBox name="username" required minLength={3} />
|
|
61
|
+
<TextBox name="email" required email />
|
|
62
|
+
</Form>
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
**Props**
|
|
66
|
+
|
|
67
|
+
| Prop | Type | Default | Description |
|
|
68
|
+
|------|------|---------|-------------|
|
|
69
|
+
| `onSubmit` | `SubmitHandler` | — | Form submit handler |
|
|
70
|
+
| `onError` | `SubmitErrorHandler` | — | Validation error handler |
|
|
71
|
+
| `defaultValues` | `object` | — | Initial field values |
|
|
72
|
+
| `values` | `object` | — | Controlled field values |
|
|
73
|
+
| `schema` | `ZodType` | — | Base Zod schema (merged with field rules) |
|
|
74
|
+
| `config` | `FormConfig` | — | Form-wide configuration (size, layout, etc.) |
|
|
75
|
+
| `form` | `UseFormReturn` | — | External RHF form instance |
|
|
76
|
+
| `mode` | `string` | `"onBlur"` | When to trigger validation |
|
|
77
|
+
| `reValidateMode` | `string` | `"onChange"` | When to re-validate after first submission |
|
|
78
|
+
|
|
79
|
+
**FormConfig options**
|
|
80
|
+
|
|
81
|
+
| Key | Type | Default | Description |
|
|
82
|
+
|-----|------|---------|-------------|
|
|
83
|
+
| `size` | `"sm" \| "md" \| "lg"` | `"md"` | Default size for all fields |
|
|
84
|
+
| `layout` | `"vertical" \| "horizontal" \| "inline"` | `"vertical"` | Layout direction |
|
|
85
|
+
| `labelWidth` | `string \| number` | — | Label width for horizontal layout |
|
|
86
|
+
| `disabled` | `boolean` | `false` | Disable all fields |
|
|
87
|
+
| `colon` | `boolean` | `true` | Append `:` to labels |
|
|
88
|
+
| `showInlineErrors` | `boolean` | `true` | Show validation errors inline |
|
|
89
|
+
| `validateOnBlur` | `boolean` | `true` | Validate on blur |
|
|
90
|
+
| `validateOnChange` | `boolean` | `false` | Validate on change |
|
|
91
|
+
|
|
92
|
+
---
|
|
93
|
+
|
|
94
|
+
### TextBox
|
|
95
|
+
|
|
96
|
+
Single-line text input with full form integration.
|
|
97
|
+
|
|
98
|
+
```tsx
|
|
99
|
+
<TextBox name="username" label="Username" required minLength={3} maxLength={50} />
|
|
100
|
+
<TextBox name="email" label="Email" type="email" required email />
|
|
101
|
+
<TextBox name="website" label="Website" url />
|
|
102
|
+
<TextBox name="amount" label="Amount" type="number" minValue={0} maxValue={100} />
|
|
103
|
+
<TextBox name="search" label="Search" prefix={<SearchIcon />} allowClear />
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
**Validation props**
|
|
107
|
+
|
|
108
|
+
| Prop | Type | Description |
|
|
109
|
+
|------|------|-------------|
|
|
110
|
+
| `required` | `boolean \| string` | Mark as required; string sets the error message |
|
|
111
|
+
| `minLength` | `number \| { value, message }` | Minimum character count |
|
|
112
|
+
| `maxLength` | `number \| { value, message }` | Maximum character count |
|
|
113
|
+
| `minValue` | `number \| { value, message }` | Minimum numeric value |
|
|
114
|
+
| `maxValue` | `number \| { value, message }` | Maximum numeric value |
|
|
115
|
+
| `pattern` | `RegExp \| { value, message }` | Regex pattern |
|
|
116
|
+
| `email` | `boolean \| string` | Email format validation |
|
|
117
|
+
| `url` | `boolean \| string` | URL format validation |
|
|
118
|
+
| `validate` | `(value) => boolean \| string` | Custom validation function |
|
|
119
|
+
|
|
120
|
+
---
|
|
121
|
+
|
|
122
|
+
### TextArea
|
|
123
|
+
|
|
124
|
+
Multi-line text input with optional character count display.
|
|
125
|
+
|
|
126
|
+
```tsx
|
|
127
|
+
<TextArea name="description" label="Description" required minLength={10} />
|
|
128
|
+
<TextArea name="bio" label="Bio" showCount maxCount={500} maxLength={500} />
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
Supports the same validation props as `TextBox` (except `minValue`, `maxValue`, `email`, `url`, `pattern`).
|
|
132
|
+
|
|
133
|
+
---
|
|
134
|
+
|
|
135
|
+
### Select
|
|
136
|
+
|
|
137
|
+
Dropdown select with support for an `options` array or custom `children`.
|
|
138
|
+
|
|
139
|
+
```tsx
|
|
140
|
+
<Select
|
|
141
|
+
name="country"
|
|
142
|
+
label="Country"
|
|
143
|
+
required
|
|
144
|
+
options={[
|
|
145
|
+
{ label: "USA", value: "us" },
|
|
146
|
+
{ label: "Canada", value: "ca" },
|
|
147
|
+
]}
|
|
148
|
+
/>
|
|
149
|
+
|
|
150
|
+
// Or with custom children
|
|
151
|
+
<Select name="role" label="Role" required>
|
|
152
|
+
<SelectItem value="admin">Admin</SelectItem>
|
|
153
|
+
<SelectItem value="user">User</SelectItem>
|
|
154
|
+
</Select>
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
---
|
|
158
|
+
|
|
159
|
+
### Checkbox
|
|
160
|
+
|
|
161
|
+
Boolean checkbox field. When `required` is set, the checkbox must be checked to pass validation.
|
|
162
|
+
|
|
163
|
+
```tsx
|
|
164
|
+
<Checkbox name="terms" label="I agree to the terms and conditions" required />
|
|
165
|
+
<Checkbox name="newsletter" label="Subscribe to newsletter" />
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
---
|
|
169
|
+
|
|
170
|
+
### RadioGroup
|
|
171
|
+
|
|
172
|
+
A group of mutually exclusive radio buttons. Accepts an `options` array or custom `RadioItem` children.
|
|
173
|
+
|
|
174
|
+
```tsx
|
|
175
|
+
<RadioGroup
|
|
176
|
+
name="gender"
|
|
177
|
+
label="Gender"
|
|
178
|
+
required
|
|
179
|
+
options={[
|
|
180
|
+
{ label: "Male", value: "male" },
|
|
181
|
+
{ label: "Female", value: "female" },
|
|
182
|
+
{ label: "Other", value: "other" },
|
|
183
|
+
]}
|
|
184
|
+
/>
|
|
185
|
+
|
|
186
|
+
// Horizontal layout
|
|
187
|
+
<RadioGroup name="size" label="Size" direction="horizontal" options={[...]} />
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
---
|
|
191
|
+
|
|
192
|
+
### Switch
|
|
193
|
+
|
|
194
|
+
Toggle switch backed by a boolean form field.
|
|
195
|
+
|
|
196
|
+
```tsx
|
|
197
|
+
<Switch name="notifications" label="Enable notifications" />
|
|
198
|
+
<Switch name="terms" label="Accept terms" required="You must accept the terms" />
|
|
199
|
+
<Switch name="darkMode" label="Dark mode" checkedText="On" uncheckedText="Off" />
|
|
200
|
+
```
|
|
201
|
+
|
|
202
|
+
---
|
|
203
|
+
|
|
204
|
+
## Display components
|
|
205
|
+
|
|
206
|
+
### Button
|
|
207
|
+
|
|
208
|
+
A styled button with multiple variants, sizes, and a built-in loading state.
|
|
209
|
+
|
|
210
|
+
```tsx
|
|
211
|
+
import { Button } from "@skybin-tech/nebula-ui";
|
|
212
|
+
|
|
213
|
+
<Button variant="primary" size="md">Save</Button>
|
|
214
|
+
<Button variant="outline" loading>Saving…</Button>
|
|
215
|
+
<Button variant="danger" fullWidth>Delete</Button>
|
|
216
|
+
```
|
|
217
|
+
|
|
218
|
+
| Variant | Description |
|
|
219
|
+
|---------|-------------|
|
|
220
|
+
| `primary` | Filled primary colour (default) |
|
|
221
|
+
| `secondary` | Filled secondary colour |
|
|
222
|
+
| `outline` | Transparent with primary border |
|
|
223
|
+
| `ghost` | Transparent, no border |
|
|
224
|
+
| `danger` | Destructive / red |
|
|
225
|
+
|
|
226
|
+
Sizes: `sm`, `md` (default), `lg`.
|
|
227
|
+
|
|
228
|
+
---
|
|
229
|
+
|
|
230
|
+
### Card
|
|
231
|
+
|
|
232
|
+
Composable card layout components.
|
|
233
|
+
|
|
234
|
+
```tsx
|
|
235
|
+
import { Card, CardHeader, CardTitle, CardDescription, CardContent, CardFooter } from "@skybin-tech/nebula-ui";
|
|
236
|
+
|
|
237
|
+
<Card>
|
|
238
|
+
<CardHeader>
|
|
239
|
+
<CardTitle>Title</CardTitle>
|
|
240
|
+
<CardDescription>Subtitle</CardDescription>
|
|
241
|
+
</CardHeader>
|
|
242
|
+
<CardContent>Content goes here</CardContent>
|
|
243
|
+
<CardFooter>Footer</CardFooter>
|
|
244
|
+
</Card>
|
|
245
|
+
```
|
|
246
|
+
|
|
247
|
+
---
|
|
248
|
+
|
|
249
|
+
### Badge
|
|
250
|
+
|
|
251
|
+
Small status or label indicator.
|
|
252
|
+
|
|
253
|
+
```tsx
|
|
254
|
+
import { Badge } from "@skybin-tech/nebula-ui";
|
|
255
|
+
|
|
256
|
+
<Badge variant="default">New</Badge>
|
|
257
|
+
<Badge variant="secondary">Beta</Badge>
|
|
258
|
+
<Badge variant="destructive">Error</Badge>
|
|
259
|
+
<Badge variant="outline">Draft</Badge>
|
|
260
|
+
```
|
|
261
|
+
|
|
262
|
+
---
|
|
263
|
+
|
|
264
|
+
### Avatar
|
|
265
|
+
|
|
266
|
+
User avatar with image and fallback initials.
|
|
267
|
+
|
|
268
|
+
```tsx
|
|
269
|
+
import { Avatar, AvatarImage, AvatarFallback } from "@skybin-tech/nebula-ui";
|
|
270
|
+
|
|
271
|
+
<Avatar>
|
|
272
|
+
<AvatarImage src="/avatar.jpg" alt="John Doe" />
|
|
273
|
+
<AvatarFallback>JD</AvatarFallback>
|
|
274
|
+
</Avatar>
|
|
275
|
+
```
|
|
276
|
+
|
|
277
|
+
---
|
|
278
|
+
|
|
279
|
+
### DropdownMenu
|
|
280
|
+
|
|
281
|
+
Accessible dropdown built on Radix UI.
|
|
282
|
+
|
|
283
|
+
```tsx
|
|
284
|
+
import {
|
|
285
|
+
DropdownMenu,
|
|
286
|
+
DropdownMenuTrigger,
|
|
287
|
+
DropdownMenuContent,
|
|
288
|
+
DropdownMenuItem,
|
|
289
|
+
DropdownMenuSeparator,
|
|
290
|
+
} from "@skybin-tech/nebula-ui";
|
|
291
|
+
|
|
292
|
+
<DropdownMenu>
|
|
293
|
+
<DropdownMenuTrigger asChild>
|
|
294
|
+
<Button variant="outline">Options</Button>
|
|
295
|
+
</DropdownMenuTrigger>
|
|
296
|
+
<DropdownMenuContent>
|
|
297
|
+
<DropdownMenuItem>Edit</DropdownMenuItem>
|
|
298
|
+
<DropdownMenuItem>Duplicate</DropdownMenuItem>
|
|
299
|
+
<DropdownMenuSeparator />
|
|
300
|
+
<DropdownMenuItem>Delete</DropdownMenuItem>
|
|
301
|
+
</DropdownMenuContent>
|
|
302
|
+
</DropdownMenu>
|
|
303
|
+
```
|
|
304
|
+
|
|
305
|
+
---
|
|
306
|
+
|
|
307
|
+
### Separator
|
|
308
|
+
|
|
309
|
+
A horizontal or vertical divider line.
|
|
310
|
+
|
|
311
|
+
```tsx
|
|
312
|
+
import { Separator } from "@skybin-tech/nebula-ui";
|
|
313
|
+
|
|
314
|
+
<Separator />
|
|
315
|
+
<Separator orientation="vertical" />
|
|
316
|
+
```
|
|
317
|
+
|
|
318
|
+
---
|
|
319
|
+
|
|
320
|
+
## Hooks
|
|
321
|
+
|
|
322
|
+
### useDebounce
|
|
323
|
+
|
|
324
|
+
Debounces a value, returning the latest value only after the specified delay has elapsed with no further changes.
|
|
325
|
+
|
|
326
|
+
```tsx
|
|
327
|
+
import { useDebounce } from "@skybin-tech/nebula-ui";
|
|
328
|
+
|
|
329
|
+
const debouncedSearch = useDebounce(searchTerm, 300);
|
|
330
|
+
```
|
|
331
|
+
|
|
332
|
+
### useToggle
|
|
333
|
+
|
|
334
|
+
Returns a boolean state and a stable toggle function.
|
|
335
|
+
|
|
336
|
+
```tsx
|
|
337
|
+
import { useToggle } from "@skybin-tech/nebula-ui";
|
|
338
|
+
|
|
339
|
+
const [isOpen, toggleOpen] = useToggle(false);
|
|
340
|
+
```
|
|
341
|
+
|
|
342
|
+
---
|
|
343
|
+
|
|
344
|
+
## Utilities
|
|
345
|
+
|
|
346
|
+
### cn
|
|
347
|
+
|
|
348
|
+
Merges Tailwind CSS class names, handling conflicts via `tailwind-merge`.
|
|
349
|
+
|
|
350
|
+
```tsx
|
|
351
|
+
import { cn } from "@skybin-tech/nebula-ui";
|
|
352
|
+
|
|
353
|
+
<div className={cn("p-4 text-sm", isActive && "bg-primary text-white")} />
|
|
354
|
+
```
|
|
@@ -1,8 +1,36 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
3
|
const jsxRuntime = require("react/jsx-runtime");
|
|
4
|
+
const classVarianceAuthority = require("class-variance-authority");
|
|
4
5
|
const cn = require("../../utils/cn.cjs");
|
|
5
|
-
|
|
6
|
+
const buttonVariants = classVarianceAuthority.cva(
|
|
7
|
+
"inline-flex items-center justify-center gap-2 font-medium rounded-md border transition-all cursor-pointer relative disabled:opacity-60 disabled:cursor-not-allowed focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring",
|
|
8
|
+
{
|
|
9
|
+
variants: {
|
|
10
|
+
variant: {
|
|
11
|
+
primary: "bg-primary text-primary-foreground border-primary hover:bg-primary/90 disabled:hover:bg-primary",
|
|
12
|
+
secondary: "bg-secondary text-secondary-foreground border-secondary hover:bg-secondary/80 disabled:hover:bg-secondary",
|
|
13
|
+
outline: "bg-transparent text-primary border-primary hover:bg-primary hover:text-primary-foreground disabled:hover:bg-transparent disabled:hover:text-primary",
|
|
14
|
+
ghost: "bg-transparent text-foreground border-transparent hover:bg-accent hover:text-accent-foreground disabled:hover:bg-transparent",
|
|
15
|
+
danger: "bg-destructive text-destructive-foreground border-destructive hover:bg-destructive/90 disabled:hover:bg-destructive"
|
|
16
|
+
},
|
|
17
|
+
size: {
|
|
18
|
+
sm: "h-8 px-3 text-sm",
|
|
19
|
+
md: "h-10 px-4 text-sm",
|
|
20
|
+
lg: "h-12 px-6 text-base"
|
|
21
|
+
},
|
|
22
|
+
fullWidth: {
|
|
23
|
+
true: "w-full flex",
|
|
24
|
+
false: ""
|
|
25
|
+
}
|
|
26
|
+
},
|
|
27
|
+
defaultVariants: {
|
|
28
|
+
variant: "primary",
|
|
29
|
+
size: "md",
|
|
30
|
+
fullWidth: false
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
);
|
|
6
34
|
function Button({
|
|
7
35
|
children,
|
|
8
36
|
variant = "primary",
|
|
@@ -16,19 +44,12 @@ function Button({
|
|
|
16
44
|
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
17
45
|
"button",
|
|
18
46
|
{
|
|
19
|
-
className: cn.cn(
|
|
20
|
-
"skybin-button",
|
|
21
|
-
`skybin-button--${variant}`,
|
|
22
|
-
`skybin-button--${size}`,
|
|
23
|
-
fullWidth && "skybin-button--full-width",
|
|
24
|
-
loading && "skybin-button--loading",
|
|
25
|
-
className
|
|
26
|
-
),
|
|
47
|
+
className: cn.cn(buttonVariants({ variant, size, fullWidth }), className),
|
|
27
48
|
disabled: disabled || loading,
|
|
28
49
|
...props,
|
|
29
50
|
children: [
|
|
30
|
-
loading && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "
|
|
31
|
-
/* @__PURE__ */ jsxRuntime.jsx("span", { className: cn.cn(
|
|
51
|
+
loading && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "size-4 border-2 border-current border-r-transparent rounded-full animate-spin" }),
|
|
52
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: cn.cn(loading && "invisible"), children })
|
|
32
53
|
]
|
|
33
54
|
}
|
|
34
55
|
);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Button.cjs","sources":["../../../../src/components/Button/Button.tsx"],"sourcesContent":["import type { ButtonHTMLAttributes, ReactNode } from \"react\";\r\nimport {
|
|
1
|
+
{"version":3,"file":"Button.cjs","sources":["../../../../src/components/Button/Button.tsx"],"sourcesContent":["import type { ButtonHTMLAttributes, ReactNode } from \"react\";\r\nimport { cva, type VariantProps } from \"class-variance-authority\";\r\nimport { cn } from \"../../utils/cn\";\r\n\r\nconst buttonVariants = cva(\r\n \"inline-flex items-center justify-center gap-2 font-medium rounded-md border transition-all cursor-pointer relative disabled:opacity-60 disabled:cursor-not-allowed focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring\",\r\n {\r\n variants: {\r\n variant: {\r\n primary:\r\n \"bg-primary text-primary-foreground border-primary hover:bg-primary/90 disabled:hover:bg-primary\",\r\n secondary:\r\n \"bg-secondary text-secondary-foreground border-secondary hover:bg-secondary/80 disabled:hover:bg-secondary\",\r\n outline:\r\n \"bg-transparent text-primary border-primary hover:bg-primary hover:text-primary-foreground disabled:hover:bg-transparent disabled:hover:text-primary\",\r\n ghost:\r\n \"bg-transparent text-foreground border-transparent hover:bg-accent hover:text-accent-foreground disabled:hover:bg-transparent\",\r\n danger:\r\n \"bg-destructive text-destructive-foreground border-destructive hover:bg-destructive/90 disabled:hover:bg-destructive\",\r\n },\r\n size: {\r\n sm: \"h-8 px-3 text-sm\",\r\n md: \"h-10 px-4 text-sm\",\r\n lg: \"h-12 px-6 text-base\",\r\n },\r\n fullWidth: {\r\n true: \"w-full flex\",\r\n false: \"\",\r\n },\r\n },\r\n defaultVariants: {\r\n variant: \"primary\",\r\n size: \"md\",\r\n fullWidth: false,\r\n },\r\n }\r\n);\r\n\r\nexport interface ButtonProps\r\n extends ButtonHTMLAttributes<HTMLButtonElement>,\r\n VariantProps<typeof buttonVariants> {\r\n /** The content of the button */\r\n children: ReactNode;\r\n /** Whether the button is in a loading state */\r\n loading?: boolean;\r\n}\r\n\r\n/**\r\n * A customizable button component with multiple variants and sizes\r\n */\r\nexport function Button({\r\n children,\r\n variant = \"primary\",\r\n size = \"md\",\r\n fullWidth = false,\r\n loading = false,\r\n disabled,\r\n className,\r\n ...props\r\n}: ButtonProps) {\r\n return (\r\n <button\r\n className={cn(buttonVariants({ variant, size, fullWidth }), className)}\r\n disabled={disabled || loading}\r\n {...props}\r\n >\r\n {loading && (\r\n <span className=\"size-4 border-2 border-current border-r-transparent rounded-full animate-spin\" />\r\n )}\r\n <span className={cn(loading && \"invisible\")}>{children}</span>\r\n </button>\r\n );\r\n}\r\n"],"names":["cva","jsxs","cn","jsx"],"mappings":";;;;;AAIA,MAAM,iBAAiBA,uBAAAA;AAAAA,EACrB;AAAA,EACA;AAAA,IACE,UAAU;AAAA,MACR,SAAS;AAAA,QACP,SACE;AAAA,QACF,WACE;AAAA,QACF,SACE;AAAA,QACF,OACE;AAAA,QACF,QACE;AAAA,MAAA;AAAA,MAEJ,MAAM;AAAA,QACJ,IAAI;AAAA,QACJ,IAAI;AAAA,QACJ,IAAI;AAAA,MAAA;AAAA,MAEN,WAAW;AAAA,QACT,MAAM;AAAA,QACN,OAAO;AAAA,MAAA;AAAA,IACT;AAAA,IAEF,iBAAiB;AAAA,MACf,SAAS;AAAA,MACT,MAAM;AAAA,MACN,WAAW;AAAA,IAAA;AAAA,EACb;AAEJ;AAcO,SAAS,OAAO;AAAA,EACrB;AAAA,EACA,UAAU;AAAA,EACV,OAAO;AAAA,EACP,YAAY;AAAA,EACZ,UAAU;AAAA,EACV;AAAA,EACA;AAAA,EACA,GAAG;AACL,GAAgB;AACd,SACEC,2BAAAA;AAAAA,IAAC;AAAA,IAAA;AAAA,MACC,WAAWC,GAAAA,GAAG,eAAe,EAAE,SAAS,MAAM,UAAA,CAAW,GAAG,SAAS;AAAA,MACrE,UAAU,YAAY;AAAA,MACrB,GAAG;AAAA,MAEH,UAAA;AAAA,QAAA,WACCC,2BAAAA,IAAC,QAAA,EAAK,WAAU,gFAAA,CAAgF;AAAA,uCAEjG,QAAA,EAAK,WAAWD,GAAAA,GAAG,WAAW,WAAW,GAAI,SAAA,CAAS;AAAA,MAAA;AAAA,IAAA;AAAA,EAAA;AAG7D;;"}
|
|
@@ -6,8 +6,8 @@ const reactHookForm = require("react-hook-form");
|
|
|
6
6
|
const classVarianceAuthority = require("class-variance-authority");
|
|
7
7
|
const cn = require("../../utils/cn.cjs");
|
|
8
8
|
const context = require("./context.cjs");
|
|
9
|
-
const checkbox = require("
|
|
10
|
-
const label = require("
|
|
9
|
+
const checkbox = require("../../primitives/checkbox.cjs");
|
|
10
|
+
const label = require("../../primitives/label.cjs");
|
|
11
11
|
const checkboxSizeVariants = classVarianceAuthority.cva(
|
|
12
12
|
"",
|
|
13
13
|
{
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Checkbox.cjs","sources":["../../../../src/components/Form/Checkbox.tsx"],"sourcesContent":["import { forwardRef, useId, useContext, useEffect } from \"react\";\r\nimport type { ReactNode, ComponentPropsWithoutRef } from \"react\";\r\nimport { useController, useFormContext as useRHFFormContext, type FieldValues, type FieldPath, type Control } from \"react-hook-form\";\r\nimport { cva, type VariantProps } from \"class-variance-authority\";\r\nimport { cn } from \"../../utils/cn\";\r\nimport { FormConfigContext, type FormConfig, type FieldValidationRules } from \"../Form/context\";\r\nimport { Checkbox as ShadcnCheckbox } from \"../ui/checkbox\";\r\nimport { Label } from \"../ui/label\";\r\nimport type * as CheckboxPrimitive from \"@radix-ui/react-checkbox\";\r\n\r\nconst checkboxSizeVariants = cva(\r\n \"\",\r\n {\r\n variants: {\r\n size: {\r\n sm: \"h-4 w-4\",\r\n md: \"h-5 w-5\",\r\n lg: \"h-6 w-6\",\r\n },\r\n },\r\n defaultVariants: {\r\n size: \"md\",\r\n },\r\n }\r\n);\r\n\r\nconst labelVariants = cva(\r\n \"text-sm font-medium cursor-pointer select-none\",\r\n {\r\n variants: {\r\n required: {\r\n true: \"after:content-['*'] after:ml-0.5 after:text-destructive\",\r\n false: \"\",\r\n },\r\n disabled: {\r\n true: \"cursor-not-allowed opacity-50\",\r\n false: \"\",\r\n },\r\n },\r\n defaultVariants: {\r\n required: false,\r\n disabled: false,\r\n },\r\n }\r\n);\r\n\r\nexport interface CheckboxProps<\r\n TFieldValues extends FieldValues = FieldValues,\r\n TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>\r\n> extends Omit<ComponentPropsWithoutRef<typeof CheckboxPrimitive.Root>, \"name\" | \"checked\" | \"onCheckedChange\" | \"required\">,\r\n VariantProps<typeof checkboxSizeVariants> {\r\n /** Field name - required for form integration */\r\n name: TName;\r\n /** Label text for the checkbox */\r\n label?: ReactNode;\r\n /** Helper text displayed below the checkbox */\r\n helperText?: string;\r\n /** Whether to show the error message */\r\n showError?: boolean;\r\n /** Custom error message (overrides form error) */\r\n error?: string;\r\n /** External control (for use outside Form) */\r\n control?: Control<TFieldValues>;\r\n /** Variant style */\r\n variant?: \"default\" | \"error\";\r\n \r\n // Validation props\r\n /** Field is required (must be checked) */\r\n required?: boolean | string;\r\n /** Custom validation function */\r\n validate?: (value: unknown) => boolean | string | Promise<boolean | string>;\r\n}\r\n\r\n/**\r\n * Checkbox component with form integration\r\n * \r\n * This is a wrapper around the shadcn/ui Checkbox primitive that adds:\r\n * - Form integration with react-hook-form\r\n * - Automatic validation registration\r\n * - Label, helper text, and error message support\r\n * \r\n * @example\r\n * ```tsx\r\n * // Inside a Form component\r\n * <Checkbox name=\"terms\" label=\"I agree to the terms and conditions\" required />\r\n * <Checkbox name=\"newsletter\" label=\"Subscribe to newsletter\" />\r\n * ```\r\n */\r\nfunction CheckboxInner<\r\n TFieldValues extends FieldValues = FieldValues,\r\n TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>\r\n>(\r\n {\r\n name,\r\n label,\r\n helperText,\r\n showError = true,\r\n error: customError,\r\n size,\r\n variant,\r\n className,\r\n disabled,\r\n id: providedId,\r\n control: externalControl,\r\n // Validation props\r\n required,\r\n validate,\r\n ...props\r\n }: CheckboxProps<TFieldValues, TName>,\r\n ref: React.ForwardedRef<React.ElementRef<typeof CheckboxPrimitive.Root>>\r\n) {\r\n const generatedId = useId();\r\n const inputId = providedId ?? generatedId;\r\n \r\n // Try to get form context\r\n const formConfigContext = useContext(FormConfigContext);\r\n const formConfig: FormConfig = formConfigContext ?? {};\r\n \r\n // Get form context from react-hook-form\r\n const rhfContext = useRHFFormContext<TFieldValues>();\r\n const control = externalControl ?? rhfContext?.control;\r\n\r\n // Register validation rules with the form\r\n useEffect(() => {\r\n if (formConfigContext?.registerFieldValidation) {\r\n const rules: FieldValidationRules = {};\r\n \r\n if (required !== undefined) rules.required = required;\r\n if (validate !== undefined) rules.validate = validate;\r\n\r\n formConfigContext.registerFieldValidation({\r\n name: name as string,\r\n type: \"boolean\",\r\n rules,\r\n });\r\n\r\n return () => {\r\n formConfigContext.unregisterFieldValidation(name as string);\r\n };\r\n }\r\n }, [formConfigContext, name, required, validate]);\r\n\r\n // Use controller for form integration\r\n const { field, fieldState } = useController<TFieldValues, TName>({\r\n name,\r\n control,\r\n });\r\n\r\n const fieldError = fieldState.error?.message;\r\n const errorMessage = customError ?? fieldError;\r\n const hasError = !!errorMessage;\r\n \r\n // Merge sizes - prop takes precedence over form config\r\n const effectiveSize = size ?? formConfig.size ?? \"md\";\r\n const effectiveDisabled = disabled ?? formConfig.disabled;\r\n \r\n // Determine variant based on error state\r\n const effectiveVariant = hasError ? \"error\" : variant;\r\n\r\n return (\r\n <div className=\"space-y-1.5\">\r\n <div className=\"flex items-center gap-2\">\r\n <ShadcnCheckbox\r\n {...props}\r\n ref={ref}\r\n id={inputId}\r\n checked={field.value ?? false}\r\n onCheckedChange={(checked) => field.onChange(checked === true)}\r\n onBlur={field.onBlur}\r\n disabled={effectiveDisabled}\r\n aria-invalid={hasError}\r\n aria-describedby={\r\n hasError\r\n ? `${inputId}-error`\r\n : helperText\r\n ? `${inputId}-helper`\r\n : undefined\r\n }\r\n className={cn(\r\n checkboxSizeVariants({ size: effectiveSize }),\r\n effectiveVariant === \"error\" && \"border-destructive\",\r\n className\r\n )}\r\n />\r\n \r\n {label && (\r\n <Label\r\n htmlFor={inputId}\r\n className={labelVariants({ required: !!required, disabled: effectiveDisabled })}\r\n >\r\n {label}\r\n </Label>\r\n )}\r\n </div>\r\n\r\n {showError && hasError && (\r\n <p\r\n id={`${inputId}-error`}\r\n className=\"text-sm text-destructive ml-7\"\r\n role=\"alert\"\r\n >\r\n {errorMessage}\r\n </p>\r\n )}\r\n \r\n {helperText && !hasError && (\r\n <p\r\n id={`${inputId}-helper`}\r\n className=\"text-sm text-muted-foreground ml-7\"\r\n >\r\n {helperText}\r\n </p>\r\n )}\r\n </div>\r\n );\r\n}\r\n\r\n// Use forwardRef with generic support\r\nexport const Checkbox = forwardRef(CheckboxInner) as <\r\n TFieldValues extends FieldValues = FieldValues,\r\n TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>\r\n>(\r\n props: CheckboxProps<TFieldValues, TName> & { ref?: React.ForwardedRef<React.ElementRef<typeof CheckboxPrimitive.Root>> }\r\n) => React.ReactElement;\r\n\r\n(Checkbox as React.FC).displayName = \"Checkbox\";\r\n"],"names":["cva","label","useId","useContext","FormConfigContext","useRHFFormContext","useEffect","useController","jsxs","jsx","ShadcnCheckbox","cn","Label","forwardRef"],"mappings":";;;;;;;;;;AAUA,MAAM,uBAAuBA,uBAAAA;AAAAA,EAC3B;AAAA,EACA;AAAA,IACE,UAAU;AAAA,MACR,MAAM;AAAA,QACJ,IAAI;AAAA,QACJ,IAAI;AAAA,QACJ,IAAI;AAAA,MAAA;AAAA,IACN;AAAA,IAEF,iBAAiB;AAAA,MACf,MAAM;AAAA,IAAA;AAAA,EACR;AAEJ;AAEA,MAAM,gBAAgBA,uBAAAA;AAAAA,EACpB;AAAA,EACA;AAAA,IACE,UAAU;AAAA,MACR,UAAU;AAAA,QACR,MAAM;AAAA,QACN,OAAO;AAAA,MAAA;AAAA,MAET,UAAU;AAAA,QACR,MAAM;AAAA,QACN,OAAO;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,UAAA;AAAA,IAAAA,2BAAAA,KAAC,OAAA,EAAI,WAAU,2BACb,UAAA;AAAA,MAAAC,2BAAAA;AAAAA,QAACC,SAAAA;AAAAA,QAAA;AAAA,UACE,GAAG;AAAA,UACJ;AAAA,UACA,IAAI;AAAA,UACJ,SAAS,MAAM,SAAS;AAAA,UACxB,iBAAiB,CAAC,YAAY,MAAM,SAAS,YAAY,IAAI;AAAA,UAC7D,QAAQ,MAAM;AAAA,UACd,UAAU;AAAA,UACV,gBAAc;AAAA,UACd,oBACE,WACI,GAAG,OAAO,WACV,aACA,GAAG,OAAO,YACV;AAAA,UAEN,WAAWC,GAAAA;AAAAA,YACT,qBAAqB,EAAE,MAAM,eAAe;AAAA,YAC5C,qBAAqB,WAAW;AAAA,YAChC;AAAA,UAAA;AAAA,QACF;AAAA,MAAA;AAAA,MAGDV,WACCQ,2BAAAA;AAAAA,QAACG,MAAAA;AAAAA,QAAA;AAAA,UACC,SAAS;AAAA,UACT,WAAW,cAAc,EAAE,UAAU,CAAC,CAAC,UAAU,UAAU,mBAAmB;AAAA,UAE7E,UAAAX;AAAAA,QAAA;AAAA,MAAA;AAAA,IACH,GAEJ;AAAA,IAEC,aAAa,YACZQ,2BAAAA;AAAAA,MAAC;AAAA,MAAA;AAAA,QACC,IAAI,GAAG,OAAO;AAAA,QACd,WAAU;AAAA,QACV,MAAK;AAAA,QAEJ,UAAA;AAAA,MAAA;AAAA,IAAA;AAAA,IAIJ,cAAc,CAAC,YACdA,2BAAAA;AAAAA,MAAC;AAAA,MAAA;AAAA,QACC,IAAI,GAAG,OAAO;AAAA,QACd,WAAU;AAAA,QAET,UAAA;AAAA,MAAA;AAAA,IAAA;AAAA,EACH,GAEJ;AAEJ;AAGO,MAAM,WAAWI,MAAAA,WAAW,aAAa;AAO/C,SAAsB,cAAc;;"}
|
|
1
|
+
{"version":3,"file":"Checkbox.cjs","sources":["../../../../src/components/Form/Checkbox.tsx"],"sourcesContent":["import { forwardRef, useId, useContext, useEffect } from \"react\";\nimport type { ReactNode, ComponentPropsWithoutRef } from \"react\";\nimport { useController, useFormContext as useRHFFormContext, type FieldValues, type FieldPath, type Control } from \"react-hook-form\";\nimport { cva, type VariantProps } from \"class-variance-authority\";\nimport { cn } from \"../../utils/cn\";\nimport { FormConfigContext, type FormConfig, type FieldValidationRules } from \"../Form/context\";\nimport { Checkbox as ShadcnCheckbox } from \"../../primitives/checkbox\";\nimport { Label } from \"../../primitives/label\";\nimport type * as CheckboxPrimitive from \"@radix-ui/react-checkbox\";\n\nconst checkboxSizeVariants = cva(\n \"\",\n {\n variants: {\n size: {\n sm: \"h-4 w-4\",\n md: \"h-5 w-5\",\n lg: \"h-6 w-6\",\n },\n },\n defaultVariants: {\n size: \"md\",\n },\n }\n);\n\nconst labelVariants = cva(\n \"text-sm font-medium cursor-pointer select-none\",\n {\n variants: {\n required: {\n true: \"after:content-['*'] after:ml-0.5 after:text-destructive\",\n false: \"\",\n },\n disabled: {\n true: \"cursor-not-allowed opacity-50\",\n false: \"\",\n },\n },\n defaultVariants: {\n required: false,\n disabled: false,\n },\n }\n);\n\nexport interface CheckboxProps<\n TFieldValues extends FieldValues = FieldValues,\n TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>\n> extends Omit<ComponentPropsWithoutRef<typeof CheckboxPrimitive.Root>, \"name\" | \"checked\" | \"onCheckedChange\" | \"required\">,\n VariantProps<typeof checkboxSizeVariants> {\n /** Field name - required for form integration */\n name: TName;\n /** Label text for the checkbox */\n label?: ReactNode;\n /** Helper text displayed below the checkbox */\n helperText?: string;\n /** Whether to show the error message */\n showError?: boolean;\n /** Custom error message (overrides form error) */\n error?: string;\n /** External control (for use outside Form) */\n control?: Control<TFieldValues>;\n /** Variant style */\n variant?: \"default\" | \"error\";\n \n // Validation props\n /** Field is required (must be checked) */\n required?: boolean | string;\n /** Custom validation function */\n validate?: (value: unknown) => boolean | string | Promise<boolean | string>;\n}\n\n/**\n * Checkbox component with form integration\n * \n * This is a wrapper around the shadcn/ui Checkbox primitive that adds:\n * - Form integration with react-hook-form\n * - Automatic validation registration\n * - Label, helper text, and error message support\n * \n * @example\n * ```tsx\n * // Inside a Form component\n * <Checkbox name=\"terms\" label=\"I agree to the terms and conditions\" required />\n * <Checkbox name=\"newsletter\" label=\"Subscribe to newsletter\" />\n * ```\n */\nfunction CheckboxInner<\n TFieldValues extends FieldValues = FieldValues,\n TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>\n>(\n {\n name,\n label,\n helperText,\n showError = true,\n error: customError,\n size,\n variant,\n className,\n disabled,\n id: providedId,\n control: externalControl,\n // Validation props\n required,\n validate,\n ...props\n }: CheckboxProps<TFieldValues, TName>,\n ref: React.ForwardedRef<React.ElementRef<typeof CheckboxPrimitive.Root>>\n) {\n const generatedId = useId();\n const inputId = providedId ?? generatedId;\n \n // Try to get form context\n const formConfigContext = useContext(FormConfigContext);\n const formConfig: FormConfig = formConfigContext ?? {};\n \n // Get form context from react-hook-form\n const rhfContext = useRHFFormContext<TFieldValues>();\n const control = externalControl ?? rhfContext?.control;\n\n // Register validation rules with the form\n useEffect(() => {\n if (formConfigContext?.registerFieldValidation) {\n const rules: FieldValidationRules = {};\n \n if (required !== undefined) rules.required = required;\n if (validate !== undefined) rules.validate = validate;\n\n formConfigContext.registerFieldValidation({\n name: name as string,\n type: \"boolean\",\n rules,\n });\n\n return () => {\n formConfigContext.unregisterFieldValidation(name as string);\n };\n }\n }, [formConfigContext, name, required, validate]);\n\n // Use controller for form integration\n const { field, fieldState } = useController<TFieldValues, TName>({\n name,\n control,\n });\n\n const fieldError = fieldState.error?.message;\n const errorMessage = customError ?? fieldError;\n const hasError = !!errorMessage;\n \n // Merge sizes - prop takes precedence over form config\n const effectiveSize = size ?? formConfig.size ?? \"md\";\n const effectiveDisabled = disabled ?? formConfig.disabled;\n \n // Determine variant based on error state\n const effectiveVariant = hasError ? \"error\" : variant;\n\n return (\n <div className=\"space-y-1.5\">\n <div className=\"flex items-center gap-2\">\n <ShadcnCheckbox\n {...props}\n ref={ref}\n id={inputId}\n checked={field.value ?? false}\n onCheckedChange={(checked) => field.onChange(checked === true)}\n onBlur={field.onBlur}\n disabled={effectiveDisabled}\n aria-invalid={hasError}\n aria-describedby={\n hasError\n ? `${inputId}-error`\n : helperText\n ? `${inputId}-helper`\n : undefined\n }\n className={cn(\n checkboxSizeVariants({ size: effectiveSize }),\n effectiveVariant === \"error\" && \"border-destructive\",\n className\n )}\n />\n \n {label && (\n <Label\n htmlFor={inputId}\n className={labelVariants({ required: !!required, disabled: effectiveDisabled })}\n >\n {label}\n </Label>\n )}\n </div>\n\n {showError && hasError && (\n <p\n id={`${inputId}-error`}\n className=\"text-sm text-destructive ml-7\"\n role=\"alert\"\n >\n {errorMessage}\n </p>\n )}\n \n {helperText && !hasError && (\n <p\n id={`${inputId}-helper`}\n className=\"text-sm text-muted-foreground ml-7\"\n >\n {helperText}\n </p>\n )}\n </div>\n );\n}\n\n// Use forwardRef with generic support\nexport const Checkbox = forwardRef(CheckboxInner) as <\n TFieldValues extends FieldValues = FieldValues,\n TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>\n>(\n props: CheckboxProps<TFieldValues, TName> & { ref?: React.ForwardedRef<React.ElementRef<typeof CheckboxPrimitive.Root>> }\n) => React.ReactElement;\n\n(Checkbox as React.FC).displayName = \"Checkbox\";\n"],"names":["cva","label","useId","useContext","FormConfigContext","useRHFFormContext","useEffect","useController","jsxs","jsx","ShadcnCheckbox","cn","Label","forwardRef"],"mappings":";;;;;;;;;;AAUA,MAAM,uBAAuBA,uBAAAA;AAAAA,EAC3B;AAAA,EACA;AAAA,IACE,UAAU;AAAA,MACR,MAAM;AAAA,QACJ,IAAI;AAAA,QACJ,IAAI;AAAA,QACJ,IAAI;AAAA,MAAA;AAAA,IACN;AAAA,IAEF,iBAAiB;AAAA,MACf,MAAM;AAAA,IAAA;AAAA,EACR;AAEJ;AAEA,MAAM,gBAAgBA,uBAAAA;AAAAA,EACpB;AAAA,EACA;AAAA,IAC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,SAAsB,cAAc;;"}
|
|
@@ -22,38 +22,30 @@ function Form({
|
|
|
22
22
|
}) {
|
|
23
23
|
const mergedConfig = { ...context.defaultFormConfig, ...config };
|
|
24
24
|
const {
|
|
25
|
-
registerFieldValidation
|
|
26
|
-
unregisterFieldValidation
|
|
25
|
+
registerFieldValidation,
|
|
26
|
+
unregisterFieldValidation,
|
|
27
27
|
getValidationSchema
|
|
28
28
|
} = context.useFieldValidationRegistry();
|
|
29
|
-
const
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
setSchemaVersion((v) => v + 1);
|
|
37
|
-
}, [baseUnregister]);
|
|
38
|
-
const buildResolver = React.useCallback(() => {
|
|
39
|
-
if (customResolver) {
|
|
40
|
-
return customResolver;
|
|
41
|
-
}
|
|
42
|
-
const fieldSchema = getValidationSchema();
|
|
43
|
-
let finalSchema;
|
|
44
|
-
if (baseSchema) {
|
|
29
|
+
const dynamicResolver = React.useCallback(
|
|
30
|
+
async (vals, context2, options) => {
|
|
31
|
+
if (customResolver) {
|
|
32
|
+
return customResolver(vals, context2, options);
|
|
33
|
+
}
|
|
34
|
+
const fieldSchema = getValidationSchema();
|
|
35
|
+
let finalSchema;
|
|
45
36
|
if (baseSchema instanceof zod.z.ZodObject) {
|
|
46
37
|
finalSchema = baseSchema.merge(fieldSchema);
|
|
47
38
|
} else {
|
|
48
|
-
finalSchema = fieldSchema;
|
|
39
|
+
finalSchema = baseSchema ?? fieldSchema;
|
|
49
40
|
}
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
41
|
+
return zod$1.zodResolver(finalSchema)(vals, context2, options);
|
|
42
|
+
},
|
|
43
|
+
// getValidationSchema reads a ref — always current, intentionally omitted.
|
|
44
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
45
|
+
[baseSchema, customResolver]
|
|
46
|
+
);
|
|
55
47
|
const internalForm = reactHookForm.useForm({
|
|
56
|
-
resolver:
|
|
48
|
+
resolver: dynamicResolver,
|
|
57
49
|
defaultValues,
|
|
58
50
|
values,
|
|
59
51
|
mode,
|
|
@@ -69,20 +61,43 @@ function Form({
|
|
|
69
61
|
form.handleSubmit(onSubmit, onError)(e);
|
|
70
62
|
}
|
|
71
63
|
};
|
|
72
|
-
const contextValue =
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
64
|
+
const contextValue = React.useMemo(
|
|
65
|
+
() => ({
|
|
66
|
+
form,
|
|
67
|
+
registerFieldValidation,
|
|
68
|
+
unregisterFieldValidation,
|
|
69
|
+
getValidationSchema,
|
|
70
|
+
triggerValidation,
|
|
71
|
+
showInlineErrors: mergedConfig.showInlineErrors,
|
|
72
|
+
validateOnBlur: mergedConfig.validateOnBlur,
|
|
73
|
+
validateOnChange: mergedConfig.validateOnChange,
|
|
74
|
+
size: mergedConfig.size,
|
|
75
|
+
layout: mergedConfig.layout,
|
|
76
|
+
labelWidth: mergedConfig.labelWidth,
|
|
77
|
+
disabled: mergedConfig.disabled,
|
|
78
|
+
colon: mergedConfig.colon
|
|
79
|
+
}),
|
|
80
|
+
[
|
|
81
|
+
form,
|
|
82
|
+
registerFieldValidation,
|
|
83
|
+
unregisterFieldValidation,
|
|
84
|
+
getValidationSchema,
|
|
85
|
+
triggerValidation,
|
|
86
|
+
mergedConfig.showInlineErrors,
|
|
87
|
+
mergedConfig.validateOnBlur,
|
|
88
|
+
mergedConfig.validateOnChange,
|
|
89
|
+
mergedConfig.size,
|
|
90
|
+
mergedConfig.layout,
|
|
91
|
+
mergedConfig.labelWidth,
|
|
92
|
+
mergedConfig.disabled,
|
|
93
|
+
mergedConfig.colon
|
|
94
|
+
]
|
|
95
|
+
);
|
|
80
96
|
return /* @__PURE__ */ jsxRuntime.jsx(context.FormConfigContext.Provider, { value: contextValue, children: /* @__PURE__ */ jsxRuntime.jsx(reactHookForm.FormProvider, { ...form, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
81
97
|
"form",
|
|
82
98
|
{
|
|
83
99
|
...formProps,
|
|
84
100
|
onSubmit: handleSubmit,
|
|
85
|
-
className: formProps.className,
|
|
86
101
|
noValidate: true,
|
|
87
102
|
children
|
|
88
103
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Form.cjs","sources":["../../../../src/components/Form/Form.tsx"],"sourcesContent":["import { useCallback,
|
|
1
|
+
{"version":3,"file":"Form.cjs","sources":["../../../../src/components/Form/Form.tsx"],"sourcesContent":["import { useCallback, useMemo, type ReactNode } from \"react\";\r\nimport {\r\n useForm,\r\n FormProvider as RHFFormProvider,\r\n type UseFormReturn,\r\n type FieldValues,\r\n type UseFormProps,\r\n type SubmitHandler,\r\n type SubmitErrorHandler,\r\n type Resolver,\r\n type Path,\r\n} from \"react-hook-form\";\r\nimport { zodResolver } from \"@hookform/resolvers/zod\";\r\nimport { z } from \"zod\";\r\nimport { \r\n FormConfigContext, \r\n defaultFormConfig, \r\n useFieldValidationRegistry,\r\n type FormConfig, \r\n type FormContextValue \r\n} from \"./context\";\r\n\r\n/**\r\n * Props for the Form component\r\n */\r\nexport interface FormProps<\r\n TFieldValues extends FieldValues = FieldValues,\r\n TContext = unknown\r\n> extends Omit<React.FormHTMLAttributes<HTMLFormElement>, \"onSubmit\" | \"onError\"> {\r\n /** Base Zod schema for validation (will be extended by field props) */\r\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\r\n schema?: z.ZodType<TFieldValues, any, any>;\r\n /** Default values for the form */\r\n defaultValues?: UseFormProps<TFieldValues, TContext>[\"defaultValues\"];\r\n /** Values to reset the form to */\r\n values?: UseFormProps<TFieldValues, TContext>[\"values\"];\r\n /** Submit handler */\r\n onSubmit?: SubmitHandler<TFieldValues>;\r\n /** Error handler */\r\n onError?: SubmitErrorHandler<TFieldValues>;\r\n /** Form configuration */\r\n config?: FormConfig;\r\n /** Children */\r\n children?: ReactNode;\r\n /** External form instance (for controlled forms) */\r\n form?: UseFormReturn<TFieldValues>;\r\n /** Validation mode */\r\n mode?: UseFormProps<TFieldValues, TContext>[\"mode\"];\r\n /** Revalidation mode */\r\n reValidateMode?: UseFormProps<TFieldValues, TContext>[\"reValidateMode\"];\r\n /** Custom resolver (overrides schema) */\r\n resolver?: Resolver<TFieldValues>;\r\n}\r\n\r\n/**\r\n * Form component that provides form context and validation\r\n * \r\n * Child components like TextBox can register their validation rules automatically.\r\n * \r\n * @example\r\n * ```tsx\r\n * // Validation is automatically built from component props\r\n * <Form onSubmit={handleSubmit} defaultValues={{ username: \"\", email: \"\" }}>\r\n * <TextBox name=\"username\" label=\"Username\" required minLength={3} maxLength={50} />\r\n * <TextBox name=\"email\" label=\"Email\" type=\"email\" required email />\r\n * <Button type=\"submit\">Submit</Button>\r\n * </Form>\r\n * \r\n * // Or with a base schema that gets extended\r\n * const baseSchema = z.object({\r\n * username: z.string(),\r\n * email: z.string(),\r\n * });\r\n * \r\n * <Form schema={baseSchema} onSubmit={handleSubmit}>\r\n * <TextBox name=\"username\" required minLength={3} /> // Adds required + minLength\r\n * <TextBox name=\"email\" required email /> // Adds required + email validation\r\n * </Form>\r\n * ```\r\n */\r\nexport function Form<\r\n TFieldValues extends FieldValues = FieldValues,\r\n TContext = unknown\r\n>({\r\n schema: baseSchema,\r\n defaultValues,\r\n values,\r\n onSubmit,\r\n onError,\r\n config,\r\n children,\r\n form: externalForm,\r\n mode = \"onBlur\",\r\n reValidateMode = \"onChange\",\r\n resolver: customResolver,\r\n ...formProps\r\n}: FormProps<TFieldValues, TContext>) {\r\n const mergedConfig = { ...defaultFormConfig, ...config };\r\n\r\n const {\r\n registerFieldValidation,\r\n unregisterFieldValidation,\r\n getValidationSchema,\r\n } = useFieldValidationRegistry();\r\n\r\n // Stable resolver that reads from fieldsRef at validation time — no re-renders\r\n // needed on field registration, and no race condition with useEffect timing.\r\n const dynamicResolver = useCallback<Resolver<TFieldValues>>(\r\n async (vals, context, options) => {\r\n if (customResolver) {\r\n return customResolver(vals, context, options);\r\n }\r\n const fieldSchema = getValidationSchema();\r\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\r\n let finalSchema: z.ZodType<any, any, any>;\r\n if (baseSchema instanceof z.ZodObject) {\r\n finalSchema = baseSchema.merge(fieldSchema);\r\n } else {\r\n finalSchema = baseSchema ?? fieldSchema;\r\n }\r\n return zodResolver(finalSchema)(vals, context, options);\r\n },\r\n // getValidationSchema reads a ref — always current, intentionally omitted.\r\n // eslint-disable-next-line react-hooks/exhaustive-deps\r\n [baseSchema, customResolver]\r\n );\r\n\r\n const internalForm = useForm<TFieldValues>({\r\n resolver: dynamicResolver,\r\n defaultValues,\r\n values,\r\n mode,\r\n reValidateMode,\r\n });\r\n\r\n const form = externalForm ?? internalForm;\r\n\r\n // Trigger validation for a specific field\r\n const triggerValidation = useCallback(async (name: string) => {\r\n return form.trigger(name as Path<TFieldValues>);\r\n }, [form]);\r\n\r\n const handleSubmit = (e: React.FormEvent<HTMLFormElement>) => {\r\n e.preventDefault();\r\n if (onSubmit) {\r\n form.handleSubmit(onSubmit, onError)(e);\r\n }\r\n };\r\n\r\n const contextValue = useMemo<FormContextValue<TFieldValues>>(\r\n () => ({\r\n form,\r\n registerFieldValidation,\r\n unregisterFieldValidation,\r\n getValidationSchema,\r\n triggerValidation,\r\n showInlineErrors: mergedConfig.showInlineErrors,\r\n validateOnBlur: mergedConfig.validateOnBlur,\r\n validateOnChange: mergedConfig.validateOnChange,\r\n size: mergedConfig.size,\r\n layout: mergedConfig.layout,\r\n labelWidth: mergedConfig.labelWidth,\r\n disabled: mergedConfig.disabled,\r\n colon: mergedConfig.colon,\r\n }),\r\n [\r\n form,\r\n registerFieldValidation,\r\n unregisterFieldValidation,\r\n getValidationSchema,\r\n triggerValidation,\r\n mergedConfig.showInlineErrors,\r\n mergedConfig.validateOnBlur,\r\n mergedConfig.validateOnChange,\r\n mergedConfig.size,\r\n mergedConfig.layout,\r\n mergedConfig.labelWidth,\r\n mergedConfig.disabled,\r\n mergedConfig.colon,\r\n ]\r\n );\r\n\r\n return (\r\n <FormConfigContext.Provider value={contextValue as FormContextValue}>\r\n <RHFFormProvider {...form}>\r\n <form\r\n {...formProps}\r\n onSubmit={handleSubmit}\r\n noValidate\r\n >\r\n {children}\r\n </form>\r\n </RHFFormProvider>\r\n </FormConfigContext.Provider>\r\n );\r\n}\r\n\r\nForm.displayName = \"Form\";\r\n"],"names":["defaultFormConfig","useFieldValidationRegistry","useCallback","context","z","zodResolver","useForm","useMemo","jsx","FormConfigContext","RHFFormProvider"],"mappings":";;;;;;;;AAgFO,SAAS,KAGd;AAAA,EACA,QAAQ;AAAA,EACR;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,MAAM;AAAA,EACN,OAAO;AAAA,EACP,iBAAiB;AAAA,EACjB,UAAU;AAAA,EACV,GAAG;AACL,GAAsC;AACpC,QAAM,eAAe,EAAE,GAAGA,QAAAA,mBAAmB,GAAG,OAAA;AAEhD,QAAM;AAAA,IACJ;AAAA,IACA;AAAA,IACA;AAAA,EAAA,IACEC,mCAAA;AAIJ,QAAM,kBAAkBC,MAAAA;AAAAA,IACtB,OAAO,MAAMC,UAAS,YAAY;AAChC,UAAI,gBAAgB;AAClB,eAAO,eAAe,MAAMA,UAAS,OAAO;AAAA,MAC9C;AACA,YAAM,cAAc,oBAAA;AAEpB,UAAI;AACJ,UAAI,sBAAsBC,IAAAA,EAAE,WAAW;AACrC,sBAAc,WAAW,MAAM,WAAW;AAAA,MAC5C,OAAO;AACL,sBAAc,cAAc;AAAA,MAC9B;AACA,aAAOC,MAAAA,YAAY,WAAW,EAAE,MAAMF,UAAS,OAAO;AAAA,IACxD;AAAA;AAAA;AAAA,IAGA,CAAC,YAAY,cAAc;AAAA,EAAA;AAG7B,QAAM,eAAeG,cAAAA,QAAsB;AAAA,IACzC,UAAU;AAAA,IACV;AAAA,IACA;AAAA,I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