@zentrades-ui/components 0.1.7 → 0.2.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/CHANGELOG.md ADDED
@@ -0,0 +1,53 @@
1
+ # @zentrades-ui/components
2
+
3
+ ## 0.2.1
4
+
5
+ ### Patch Changes
6
+
7
+ - Fixed npm package to include README.md and CHANGELOG.md files
8
+
9
+ ## 0.2.0
10
+
11
+ ### Minor Changes
12
+
13
+ - **Standardized form component API**: All form components now share a consistent API for labels, validation, and helper text.
14
+
15
+ Common props across Input, TextArea, Checkbox, and Switch:
16
+ - `label` - Label text displayed with the input
17
+ - `required` - Shows required indicator (*)
18
+ - `helperText` - Helper text displayed below the input
19
+ - `error` - Error state styling
20
+ - `errorMessage` - Error message (replaces helperText when error is true)
21
+
22
+ - **Enhanced Checkbox component**:
23
+ - Added `required`, `error`, `errorMessage`, and `helperText` props
24
+ - Added `aria-invalid` for accessibility
25
+ - Consistent styling with other form components
26
+
27
+ - **Enhanced Switch component**:
28
+ - Added `label` prop for displaying text next to the switch
29
+ - Added `required`, `error`, `errorMessage`, and `helperText` props
30
+ - Improved accessibility with proper label association
31
+
32
+ - **Comprehensive documentation**: Added detailed README with:
33
+ - Usage examples for all components
34
+ - Form component API reference table
35
+ - Code examples for Input, TextArea, Checkbox, Switch, Select
36
+ - Layout components (Stack, Inline, Box)
37
+ - Feedback components (Button, Toast, Dialog)
38
+ - Data display (Avatar, Badge, Chip)
39
+ - Navigation (Tabs, Breadcrumb, Menu)
40
+ - Overlay components (Drawer, Popover, Tooltip)
41
+ - Loading states (Spinner, Skeleton)
42
+ - Accessibility information
43
+
44
+ ### Deprecations
45
+
46
+ - `mandatory` prop on Input and TextArea is deprecated. Use `required` instead.
47
+ - `description` prop on Checkbox is deprecated. Use `helperText` instead.
48
+
49
+ ## 0.1.7
50
+
51
+ - Initial stable release
52
+ - Core component library with Radix UI primitives
53
+ - Vanilla Extract CSS-in-JS styling
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # @zentrades-ui/components
2
2
 
3
- React component library for the Zen UI kit.
3
+ React component library for the Zen UI kit. Built with accessibility in mind using Radix UI primitives.
4
4
 
5
5
  ## Installation
6
6
 
@@ -8,7 +8,7 @@ React component library for the Zen UI kit.
8
8
  pnpm add @zentrades-ui/components @zentrades-ui/theme @zentrades-ui/tokens
9
9
  ```
10
10
 
11
- ## Usage
11
+ ## Quick Start
12
12
 
13
13
  ```tsx
14
14
  import { ThemeProvider } from "@zentrades-ui/theme";
@@ -16,9 +16,9 @@ import { Button, Input, Stack } from "@zentrades-ui/components";
16
16
 
17
17
  export function Example() {
18
18
  return (
19
- <ThemeProvider>
19
+ <ThemeProvider theme="light">
20
20
  <Stack gap="md">
21
- <Input placeholder="Email" />
21
+ <Input label="Email" placeholder="Enter your email" />
22
22
  <Button>Submit</Button>
23
23
  </Stack>
24
24
  </ThemeProvider>
@@ -26,14 +26,460 @@ export function Example() {
26
26
  }
27
27
  ```
28
28
 
29
+ ## Components
30
+
31
+ ### Form Components
32
+
33
+ All form components share a consistent API:
34
+
35
+ | Prop | Type | Description |
36
+ |------|------|-------------|
37
+ | `label` | `string` | Label text displayed above/beside the input |
38
+ | `required` | `boolean` | Shows required indicator (*) |
39
+ | `helperText` | `string` | Helper text displayed below the input |
40
+ | `error` | `boolean` | Error state styling |
41
+ | `errorMessage` | `string` | Error message (replaces helperText when error is true) |
42
+ | `disabled` | `boolean` | Disabled state |
43
+
44
+ #### Input
45
+
46
+ ```tsx
47
+ import { Input } from "@zentrades-ui/components";
48
+
49
+ <Input
50
+ label="Email"
51
+ placeholder="Enter your email"
52
+ required
53
+ helperText="We'll never share your email"
54
+ />
55
+
56
+ <Input
57
+ label="Password"
58
+ type="password"
59
+ error
60
+ errorMessage="Password is required"
61
+ />
62
+
63
+ // With icons
64
+ <Input
65
+ label="Search"
66
+ leftIcon={<SearchIcon />}
67
+ icon={<ClearIcon />}
68
+ />
69
+
70
+ // Horizontal layout
71
+ <Input label="Name" horizontal />
72
+
73
+ // Compound input with sections
74
+ <Input
75
+ label="Price"
76
+ leadingSection={<span>$</span>}
77
+ trailingSection={<span>USD</span>}
78
+ />
79
+ ```
80
+
81
+ #### TextArea
82
+
83
+ ```tsx
84
+ import { TextArea } from "@zentrades-ui/components";
85
+
86
+ <TextArea
87
+ label="Description"
88
+ placeholder="Enter description..."
89
+ required
90
+ helperText="Max 500 characters"
91
+ />
92
+
93
+ // View mode (read-only with different styling)
94
+ <TextArea label="Notes" viewMode value="Read-only content" />
95
+
96
+ // Hide resize handle
97
+ <TextArea label="Fixed" showResizeHandle={false} />
98
+ ```
99
+
100
+ #### Checkbox
101
+
102
+ ```tsx
103
+ import { Checkbox } from "@zentrades-ui/components";
104
+
105
+ <Checkbox label="Accept terms" required />
106
+
107
+ <Checkbox
108
+ label="Subscribe to newsletter"
109
+ helperText="You can unsubscribe at any time"
110
+ />
111
+
112
+ <Checkbox
113
+ label="Agree to policy"
114
+ error
115
+ errorMessage="You must accept the policy"
116
+ />
117
+
118
+ // Sizes: xs, sm, md, lg
119
+ <Checkbox label="Small" size="sm" />
120
+
121
+ // Indeterminate state
122
+ <Checkbox label="Select all" partialChecked />
123
+ ```
124
+
125
+ #### Switch
126
+
127
+ ```tsx
128
+ import { Switch } from "@zentrades-ui/components";
129
+
130
+ <Switch label="Enable notifications" />
131
+
132
+ <Switch
133
+ label="Dark mode"
134
+ helperText="Enable dark theme"
135
+ />
136
+
137
+ <Switch
138
+ label="Required setting"
139
+ required
140
+ error
141
+ errorMessage="This must be enabled"
142
+ />
143
+
144
+ // Sizes: sm, md, lg
145
+ <Switch size="lg" />
146
+ ```
147
+
148
+ #### Select
149
+
150
+ ```tsx
151
+ import { Select } from "@zentrades-ui/components";
152
+
153
+ <Select
154
+ label="Country"
155
+ placeholder="Select a country"
156
+ options={[
157
+ { value: "us", label: "United States" },
158
+ { value: "uk", label: "United Kingdom" },
159
+ { value: "ca", label: "Canada" },
160
+ ]}
161
+ />
162
+
163
+ // Multi-select
164
+ <Select
165
+ label="Tags"
166
+ multiple
167
+ options={tags}
168
+ />
169
+
170
+ // Searchable
171
+ <Select
172
+ label="Search users"
173
+ searchable
174
+ options={users}
175
+ />
176
+ ```
177
+
178
+ ### Layout Components
179
+
180
+ #### Stack
181
+
182
+ Vertical layout with consistent spacing:
183
+
184
+ ```tsx
185
+ import { Stack } from "@zentrades-ui/components";
186
+
187
+ <Stack gap="md">
188
+ <div>Item 1</div>
189
+ <div>Item 2</div>
190
+ <div>Item 3</div>
191
+ </Stack>
192
+
193
+ // With alignment
194
+ <Stack gap="lg" alignItems="center">
195
+ <Logo />
196
+ <Title />
197
+ </Stack>
198
+ ```
199
+
200
+ #### Inline
201
+
202
+ Horizontal layout with consistent spacing:
203
+
204
+ ```tsx
205
+ import { Inline } from "@zentrades-ui/components";
206
+
207
+ <Inline gap="sm" alignItems="center">
208
+ <Avatar />
209
+ <Text>Username</Text>
210
+ <Badge>Admin</Badge>
211
+ </Inline>
212
+
213
+ // Wrap items
214
+ <Inline gap="xs" flexWrap="wrap">
215
+ {tags.map(tag => <Chip key={tag}>{tag}</Chip>)}
216
+ </Inline>
217
+ ```
218
+
219
+ #### Box
220
+
221
+ Base layout primitive with full styling props:
222
+
223
+ ```tsx
224
+ import { Box } from "@zentrades-ui/components";
225
+
226
+ <Box
227
+ padding="md"
228
+ backgroundColor="backgroundSecondary"
229
+ borderRadius="md"
230
+ borderWidth="xs"
231
+ borderColor="borderTertiary"
232
+ >
233
+ Content
234
+ </Box>
235
+ ```
236
+
237
+ ### Feedback Components
238
+
239
+ #### Button
240
+
241
+ ```tsx
242
+ import { Button } from "@zentrades-ui/components";
243
+
244
+ // Variants
245
+ <Button variant="primary">Primary</Button>
246
+ <Button variant="secondary">Secondary</Button>
247
+ <Button variant="outline">Outline</Button>
248
+ <Button variant="ghost">Ghost</Button>
249
+ <Button variant="danger">Danger</Button>
250
+
251
+ // Sizes
252
+ <Button size="sm">Small</Button>
253
+ <Button size="md">Medium</Button>
254
+ <Button size="lg">Large</Button>
255
+
256
+ // With icons
257
+ <Button leftIcon={<PlusIcon />}>Add Item</Button>
258
+ <Button rightIcon={<ArrowIcon />}>Next</Button>
259
+
260
+ // Loading state
261
+ <Button loading>Submitting...</Button>
262
+
263
+ // Full width
264
+ <Button fullWidth>Submit</Button>
265
+ ```
266
+
267
+ #### Toast
268
+
269
+ ```tsx
270
+ import { toast } from "@zentrades-ui/components";
271
+
272
+ toast.success("Changes saved!");
273
+ toast.error("Something went wrong");
274
+ toast.info("New update available");
275
+ toast.warning("Please review your input");
276
+
277
+ // Custom options
278
+ toast.success("Saved!", {
279
+ duration: 5000,
280
+ position: "top-right",
281
+ });
282
+ ```
283
+
284
+ #### Dialog / AlertDialog
285
+
286
+ ```tsx
287
+ import { Dialog, AlertDialog } from "@zentrades-ui/components";
288
+
289
+ // Controlled dialog
290
+ <Dialog open={open} onOpenChange={setOpen}>
291
+ <Dialog.Content title="Edit Profile">
292
+ <form>...</form>
293
+ </Dialog.Content>
294
+ </Dialog>
295
+
296
+ // Alert dialog (requires confirmation)
297
+ <AlertDialog
298
+ open={open}
299
+ onOpenChange={setOpen}
300
+ title="Delete item?"
301
+ description="This action cannot be undone."
302
+ onConfirm={handleDelete}
303
+ />
304
+ ```
305
+
306
+ ### Data Display
307
+
308
+ #### Avatar
309
+
310
+ ```tsx
311
+ import { Avatar } from "@zentrades-ui/components";
312
+
313
+ <Avatar src="/avatar.jpg" alt="User" />
314
+ <Avatar name="John Doe" /> {/* Shows initials */}
315
+
316
+ // Sizes
317
+ <Avatar size="sm" name="JD" />
318
+ <Avatar size="lg" name="JD" />
319
+ ```
320
+
321
+ #### Badge
322
+
323
+ ```tsx
324
+ import { Badge } from "@zentrades-ui/components";
325
+
326
+ <Badge>Default</Badge>
327
+ <Badge variant="success">Active</Badge>
328
+ <Badge variant="warning">Pending</Badge>
329
+ <Badge variant="error">Failed</Badge>
330
+ <Badge variant="info">New</Badge>
331
+ ```
332
+
333
+ #### Chip
334
+
335
+ ```tsx
336
+ import { Chip } from "@zentrades-ui/components";
337
+
338
+ <Chip>Tag</Chip>
339
+ <Chip onRemove={() => {}}>Removable</Chip>
340
+ <Chip selected>Selected</Chip>
341
+ ```
342
+
343
+ ### Navigation
344
+
345
+ #### Tabs
346
+
347
+ ```tsx
348
+ import { Tabs } from "@zentrades-ui/components";
349
+
350
+ <Tabs defaultValue="tab1">
351
+ <Tabs.List>
352
+ <Tabs.Trigger value="tab1">Overview</Tabs.Trigger>
353
+ <Tabs.Trigger value="tab2">Settings</Tabs.Trigger>
354
+ </Tabs.List>
355
+ <Tabs.Content value="tab1">Overview content</Tabs.Content>
356
+ <Tabs.Content value="tab2">Settings content</Tabs.Content>
357
+ </Tabs>
358
+ ```
359
+
360
+ #### Breadcrumb
361
+
362
+ ```tsx
363
+ import { Breadcrumb } from "@zentrades-ui/components";
364
+
365
+ <Breadcrumb>
366
+ <Breadcrumb.Item href="/">Home</Breadcrumb.Item>
367
+ <Breadcrumb.Item href="/products">Products</Breadcrumb.Item>
368
+ <Breadcrumb.Item>Current Page</Breadcrumb.Item>
369
+ </Breadcrumb>
370
+ ```
371
+
372
+ #### Menu
373
+
374
+ ```tsx
375
+ import { Menu } from "@zentrades-ui/components";
376
+
377
+ <Menu>
378
+ <Menu.Trigger asChild>
379
+ <Button>Options</Button>
380
+ </Menu.Trigger>
381
+ <Menu.Content>
382
+ <Menu.Item onClick={handleEdit}>Edit</Menu.Item>
383
+ <Menu.Item onClick={handleDuplicate}>Duplicate</Menu.Item>
384
+ <Menu.Separator />
385
+ <Menu.Item onClick={handleDelete} destructive>Delete</Menu.Item>
386
+ </Menu.Content>
387
+ </Menu>
388
+ ```
389
+
390
+ ### Overlay Components
391
+
392
+ #### Drawer
393
+
394
+ ```tsx
395
+ import { Drawer } from "@zentrades-ui/components";
396
+
397
+ <Drawer open={open} onOpenChange={setOpen} side="right">
398
+ <Drawer.Header>
399
+ <Drawer.Title>Settings</Drawer.Title>
400
+ </Drawer.Header>
401
+ <Drawer.Body>
402
+ Content here
403
+ </Drawer.Body>
404
+ <Drawer.Footer>
405
+ <Button onClick={() => setOpen(false)}>Close</Button>
406
+ </Drawer.Footer>
407
+ </Drawer>
408
+ ```
409
+
410
+ #### Popover
411
+
412
+ ```tsx
413
+ import { Popover } from "@zentrades-ui/components";
414
+
415
+ <Popover>
416
+ <Popover.Trigger asChild>
417
+ <Button>Info</Button>
418
+ </Popover.Trigger>
419
+ <Popover.Content>
420
+ Additional information here
421
+ </Popover.Content>
422
+ </Popover>
423
+ ```
424
+
425
+ #### Tooltip
426
+
427
+ ```tsx
428
+ import { Tooltip } from "@zentrades-ui/components";
429
+
430
+ <Tooltip content="More information">
431
+ <Button>Hover me</Button>
432
+ </Tooltip>
433
+ ```
434
+
435
+ ### Loading States
436
+
437
+ #### Spinner
438
+
439
+ ```tsx
440
+ import { Spinner } from "@zentrades-ui/components";
441
+
442
+ <Spinner />
443
+ <Spinner size="sm" />
444
+ <Spinner size="lg" />
445
+ ```
446
+
447
+ #### Skeleton
448
+
449
+ ```tsx
450
+ import { Skeleton } from "@zentrades-ui/components";
451
+
452
+ <Skeleton width={200} height={20} />
453
+ <Skeleton width="100%" height={40} />
454
+ <Skeleton variant="circle" width={40} height={40} />
455
+ ```
456
+
29
457
  ## Exports
30
458
 
31
459
  ```ts
32
- import * as Components from "@zentrades-ui/components";
33
- import * as ThemeEntries from "@zentrades-ui/components/theme";
34
- import * as IconEntries from "@zentrades-ui/components/icons";
460
+ // Main entry - all components
461
+ import { Button, Input, ... } from "@zentrades-ui/components";
462
+
463
+ // Icons only
464
+ import { IconName } from "@zentrades-ui/components/icons";
465
+
466
+ // Theme re-exports
467
+ import { ThemeProvider } from "@zentrades-ui/components/theme";
35
468
  ```
36
469
 
470
+ ## Accessibility
471
+
472
+ All components are built with accessibility in mind:
473
+
474
+ - Full keyboard navigation support
475
+ - ARIA attributes properly applied
476
+ - Focus management for overlays and modals
477
+ - Screen reader announcements for dynamic content
478
+
479
+ Components are built on [Radix UI](https://radix-ui.com/) primitives where applicable.
480
+
37
481
  ## Notes
38
- - This package ships compiled output in `dist/`.
39
- - CSS side effects are included for component styles.
482
+
483
+ - This package ships compiled output in `dist/`
484
+ - CSS side effects are included for component styles
485
+ - Requires `@zentrades-ui/theme` for styling to work correctly