@invana/forms 0.0.27 → 0.0.28
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 +75 -0
- package/package.json +5 -5
package/README.md
ADDED
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
# @invana/forms
|
|
2
|
+
|
|
3
|
+
Composable form building blocks for Invana products — `FormField` with an `ObjectField`, plus the
|
|
4
|
+
leaf inputs.
|
|
5
|
+
|
|
6
|
+
```bash
|
|
7
|
+
pnpm add @invana/forms
|
|
8
|
+
```
|
|
9
|
+
|
|
10
|
+
Peer dependencies: `@invana/ui`, `@invana/styling`, `react`, `react-dom`, `react-hook-form`.
|
|
11
|
+
|
|
12
|
+
## This is not a form renderer
|
|
13
|
+
|
|
14
|
+
There is no `FormRenderer` and no `FormSchema` tree. **You own `useForm`** and you compose your own
|
|
15
|
+
chrome — Card, Tabs, Accordion, a footer, a submit button. This package supplies the fields.
|
|
16
|
+
|
|
17
|
+
## Usage
|
|
18
|
+
|
|
19
|
+
`FormField.ObjectField` is the primary building block. Fields render as `${name}.${field.name}`,
|
|
20
|
+
so several ObjectFields in one `useForm` all write into a single shared data object.
|
|
21
|
+
|
|
22
|
+
```tsx
|
|
23
|
+
import { useForm } from 'react-hook-form';
|
|
24
|
+
import { Form, FormField } from '@invana/forms';
|
|
25
|
+
import { Button } from '@invana/ui';
|
|
26
|
+
|
|
27
|
+
export function ShapeSettings() {
|
|
28
|
+
const form = useForm({ defaultValues: { shape: { fill: '#2563eb', radius: 4, visible: true } } });
|
|
29
|
+
|
|
30
|
+
return (
|
|
31
|
+
<Form {...form}>
|
|
32
|
+
<form onSubmit={form.handleSubmit(console.log)}>
|
|
33
|
+
<FormField.ObjectField
|
|
34
|
+
control={form.control}
|
|
35
|
+
name="shape"
|
|
36
|
+
labelPosition="top"
|
|
37
|
+
fields={[
|
|
38
|
+
{ name: 'fill', type: 'color', label: 'Fill' },
|
|
39
|
+
{ name: 'radius', type: 'number', label: 'Radius', min: 0, max: 32 },
|
|
40
|
+
{ name: 'visible', type: 'boolean', label: 'Visible' },
|
|
41
|
+
]}
|
|
42
|
+
rowConfig={[{ fields: ['fill', 'radius'] }]}
|
|
43
|
+
/>
|
|
44
|
+
<Button type="submit">Save</Button>
|
|
45
|
+
</form>
|
|
46
|
+
</Form>
|
|
47
|
+
);
|
|
48
|
+
}
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
A field with a `group` property is auto-wrapped in an Accordion; ungrouped fields render flat.
|
|
52
|
+
`rowConfig` puts named fields side by side in one row.
|
|
53
|
+
|
|
54
|
+
## Exports
|
|
55
|
+
|
|
56
|
+
**Fields** — `FormField` (augmented with `.ObjectField`, `.Color`, `.Number`, `.Select`,
|
|
57
|
+
`.Boolean`, `.Input`, `.Icon`), and the standalone `Field`, `ObjectField`, `InputField`,
|
|
58
|
+
`PasswordField`, `TextareaField`, `SelectField`, `BooleanField`, `RadioField`,
|
|
59
|
+
`CheckboxGroupField`, `ColorField`, `NumberField`, `IconField`.
|
|
60
|
+
|
|
61
|
+
**Controls** — `ColorSwatches`, `SliderNumber`, `IconInput`, and `SettingsPanel`.
|
|
62
|
+
|
|
63
|
+
**Types** — `FieldConfig`, `RowConfig`, `GroupConfig`, `ObjectFieldProps`, `FieldType`,
|
|
64
|
+
`LabelPosition`, `FieldOrientation`, `FieldSize`, `FieldBadge`, `BooleanControl`, `ColorPreset`.
|
|
65
|
+
|
|
66
|
+
React Hook Form's `Control`, `FieldValues`, `SubmitHandler`, `UseFormReturn`, `DefaultValues` and
|
|
67
|
+
`Mode` are re-exported so consumers need not import them separately.
|
|
68
|
+
|
|
69
|
+
## Icons
|
|
70
|
+
|
|
71
|
+
Pass icons in as props. This package does not bind you to an icon set.
|
|
72
|
+
|
|
73
|
+
## License
|
|
74
|
+
|
|
75
|
+
MIT © Ravi Raja Merugu
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@invana/forms",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.28",
|
|
4
4
|
"description": "Invana Design System - Composable form building blocks (FormField + ObjectField + leaf inputs)",
|
|
5
5
|
"homepage": "https://github.com/invana/design-kit#readme",
|
|
6
6
|
"type": "module",
|
|
@@ -43,8 +43,8 @@
|
|
|
43
43
|
"react": "^18 || ^19",
|
|
44
44
|
"react-dom": "^18 || ^19",
|
|
45
45
|
"react-hook-form": "^7",
|
|
46
|
-
"@invana/
|
|
47
|
-
"@invana/
|
|
46
|
+
"@invana/ui": "0.0.28",
|
|
47
|
+
"@invana/styling": "0.0.28"
|
|
48
48
|
},
|
|
49
49
|
"dependencies": {
|
|
50
50
|
"@radix-ui/react-checkbox": "^1.3.7",
|
|
@@ -65,8 +65,8 @@
|
|
|
65
65
|
"react-hook-form": "^7.81.0",
|
|
66
66
|
"tsup": "^8.5.1",
|
|
67
67
|
"typescript": "~5.9.3",
|
|
68
|
-
"@invana/styling": "0.0.
|
|
69
|
-
"@invana/ui": "0.0.
|
|
68
|
+
"@invana/styling": "0.0.28",
|
|
69
|
+
"@invana/ui": "0.0.28"
|
|
70
70
|
},
|
|
71
71
|
"scripts": {
|
|
72
72
|
"build": "tsup",
|