@voidable/ui-react 0.4.4 → 0.8.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 +64 -8
- package/dist/index.d.ts +1026 -159
- package/dist/index.js +134 -42
- package/package.json +34 -12
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @voidable/ui-react
|
|
2
2
|
|
|
3
|
-
React wrappers for Voidable UI web components.
|
|
3
|
+
React wrappers for [Voidable UI](https://voidable.dev) web components.
|
|
4
4
|
|
|
5
5
|
## Install
|
|
6
6
|
|
|
@@ -8,32 +8,88 @@ React wrappers for Voidable UI web components.
|
|
|
8
8
|
npm install @voidable/ui-react @voidable/ui @voidable/theme react
|
|
9
9
|
```
|
|
10
10
|
|
|
11
|
+
Supports React 18 and 19.
|
|
12
|
+
|
|
11
13
|
## Usage
|
|
12
14
|
|
|
15
|
+
Components ship without any styling. Load the theme once at your app entry:
|
|
16
|
+
|
|
13
17
|
```tsx
|
|
14
|
-
import
|
|
18
|
+
import '@voidable/theme';
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
```tsx
|
|
22
|
+
import { Button, Input, Dialog, DialogTitle, DialogBody, TagsInput, useTheme } from '@voidable/ui-react';
|
|
15
23
|
import '@voidable/theme';
|
|
16
24
|
|
|
17
25
|
function App() {
|
|
18
|
-
const theme = useTheme(); // 'dark' | 'light'
|
|
26
|
+
const theme = useTheme(); // 'dark' | 'light': the scheme the page is in
|
|
19
27
|
|
|
20
28
|
return (
|
|
21
29
|
<div>
|
|
22
|
-
<Button variant="filled" color="
|
|
30
|
+
<Button variant="filled" color="error" onVoidClick={() => {}}>
|
|
23
31
|
Click me
|
|
24
32
|
</Button>
|
|
25
|
-
<Input label="Name" />
|
|
26
|
-
<
|
|
33
|
+
<Input aria-label="Name" placeholder="Name" onVoidChange={(e) => console.log(e.detail.value)} />
|
|
34
|
+
<TagsInput aria-label="Tags" value={['a', 'b']} onVoidChange={(e) => console.log(e.detail.value)} />
|
|
35
|
+
<Dialog open><DialogTitle>Confirm</DialogTitle><DialogBody>Are you sure?</DialogBody></Dialog>
|
|
27
36
|
</div>
|
|
28
37
|
);
|
|
29
38
|
}
|
|
30
39
|
```
|
|
31
40
|
|
|
32
|
-
|
|
41
|
+
Valid `color` values are `default`, `error`, `warning`, `caution`, `success`, `info`, `notice` and `highlight` (not every component supports every value; see the component docs).
|
|
42
|
+
|
|
43
|
+
All Voidable components are available as React components with ref forwarding. Charts (`BarChart`, `LineChart`, `DonutChart`, `Gauge`) take their data through the `data` prop.
|
|
44
|
+
|
|
45
|
+
### Element registration
|
|
46
|
+
|
|
47
|
+
Importing `@voidable/ui-react` also imports `@voidable/ui`, which defines the `<void-*>` custom elements, so you do not need to import the core package yourself. All elements are registered, not only the ones you render.
|
|
48
|
+
|
|
49
|
+
### Props
|
|
50
|
+
|
|
51
|
+
- Booleans, arrays and objects are set as element properties, so `disabled={false}` really is false and `TagsInput` `value` stays an array. This is the same on React 18 and 19. It also means the `hide*` booleans turn off what is drawn by default: `<NavBar hideBorder>`.
|
|
52
|
+
- Native input attributes (`autocomplete`, `minlength`, `maxlength`, `pattern`, `inputMode`, `enterKeyHint`, `autocapitalize`, `spellcheck`) are typed on `Input`, `Textarea` and `ActionInput`.
|
|
53
|
+
- `className` is mapped to `class`.
|
|
54
|
+
- Other attributes such as `aria-*` and `data-*` are passed through.
|
|
55
|
+
|
|
56
|
+
### Events
|
|
57
|
+
|
|
58
|
+
Custom events are exposed as typed `onVoid*` props: `void-change` becomes `onVoidChange`, `void-click` becomes `onVoidClick`, and so on. `event.detail` is typed per component, for example `Switch` `onVoidChange` receives `CustomEvent<{ value: string; checked: boolean }>`.
|
|
59
|
+
|
|
60
|
+
Overlays (`Dialog`, `Drawer`, `Popover`, `DropdownMenu`, `Tooltip`, `HoverCard`, `Combobox`, `Multiselect`, `DatePicker`) take a controlled `open` and fire `onVoidOpen` / `onVoidClose` with `{ reason }` (`OverlayOpenReason`, `OverlayCloseReason`). Set your state to false in `onVoidClose`, or call `event.preventDefault()` there to keep a user-closed overlay open.
|
|
61
|
+
|
|
62
|
+
### Parts
|
|
63
|
+
|
|
64
|
+
Components with regions take explicit parts, exported next to them: `DialogTitle`, `DialogBody`, `DialogActions`, `PopoverTrigger`, `PopoverContent`, `DropdownMenuTrigger`, `DropdownMenuContent`, `TabsList`, `TabsTrigger`, `TabsContent`, `CardHeader`, `CardBody` and so on (generated from the manifest; each renders the matching `void-*` tag). A trigger part wraps exactly one element, the button or link that opens the overlay. React can re-key, reorder or conditionally render the parts freely: the component finds them where they are and never moves them.
|
|
65
|
+
|
|
66
|
+
```tsx
|
|
67
|
+
<DropdownMenu>
|
|
68
|
+
<DropdownMenuTrigger><Button>Actions</Button></DropdownMenuTrigger>
|
|
69
|
+
<DropdownMenuContent>
|
|
70
|
+
<DropdownMenuItem onVoidSelect={edit}>Edit</DropdownMenuItem>
|
|
71
|
+
</DropdownMenuContent>
|
|
72
|
+
</DropdownMenu>
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
Pickers take their options in a content part: `<Combobox name="country"><ComboboxContent><Option value="de">Germany</Option></ComboboxContent></Combobox>`, and the same with `Multiselect` and `MultiselectContent`.
|
|
76
|
+
|
|
77
|
+
### Forms
|
|
78
|
+
|
|
79
|
+
Form controls take `name`, `value`, `required` and `disabled` and take part in a surrounding `<form>` (submission, `form.reset()`, `<fieldset disabled>`), whether they render a native control or are form-associated custom elements. `Select` is the exception: it wraps a native `<select>` you write inside it, and the form attributes go on that select (`<Select><select name="plan" required>...</select></Select>`).
|
|
80
|
+
|
|
81
|
+
### Next.js
|
|
82
|
+
|
|
83
|
+
The package starts with `"use client"`, so the components can be imported from App Router server components. They render on the server as plain custom elements and upgrade on the client.
|
|
84
|
+
|
|
85
|
+
### Theme
|
|
86
|
+
|
|
87
|
+
`useTheme()` returns the colour scheme in force, `'dark'` or `'light'`: what the page shows, not just the attribute. With `<html data-theme>` unset or `"system"` it reports what the theme resolves, so a theme or skin that prefers a scheme (Loft prefers light) is counted, and otherwise the operating system's `prefers-color-scheme`. It updates when the attribute or the operating system preference changes. During server rendering, and on the first render of a hydrating tree, it is `'dark'` (the server cannot know the visitor's preference); React then re-renders with the real value, with no hydration warning. It is read-only: set `data-theme` on `<html>` to change the scheme.
|
|
33
88
|
|
|
34
89
|
## Documentation
|
|
35
90
|
|
|
36
|
-
- [
|
|
91
|
+
- [Documentation](https://voidable.dev)
|
|
92
|
+
- [Storybook](https://voidable.dev/storybook/)
|
|
37
93
|
- [GitHub](https://github.com/VoidableUI/Voidable)
|
|
38
94
|
|
|
39
95
|
## License
|