@codella-software/react 2.0.0 → 2.0.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 +92 -0
- package/package.json +1 -1
package/README.md
ADDED
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
# @codella-software/react
|
|
2
|
+
|
|
3
|
+
React hooks for Codella core services - FormBuilder, TableBuilder, FiltersAndSort, TabsService, APIService, and LiveUpdatesService.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- **useFormBuilder** - Manage form state, validation, and submission
|
|
8
|
+
- **useTableService** - Manage dynamic table data, filtering, and sorting
|
|
9
|
+
- **useFiltersAndSort** - Handle complex filtering and sorting logic
|
|
10
|
+
- **useTabsService** - Manage tab state and navigation
|
|
11
|
+
- **useAPIService** - RESTful API client with authentication
|
|
12
|
+
- **useLiveUpdates** - Real-time data updates via WebSocket or Server-Sent Events
|
|
13
|
+
|
|
14
|
+
## Installation
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
npm install @codella-software/utils @codella-software/react
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
## Quick Start
|
|
21
|
+
|
|
22
|
+
### useFormBuilder
|
|
23
|
+
|
|
24
|
+
```typescript
|
|
25
|
+
import { useFormBuilder } from '@codella-software/react';
|
|
26
|
+
|
|
27
|
+
function MyForm() {
|
|
28
|
+
const { values, errors, submit } = useFormBuilder({
|
|
29
|
+
fields: [
|
|
30
|
+
{ name: 'email', type: 'text', validators: ['required', 'email'] },
|
|
31
|
+
{ name: 'password', type: 'password', validators: ['required'] }
|
|
32
|
+
],
|
|
33
|
+
onSubmit: (data) => console.log(data)
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
return (
|
|
37
|
+
<form onSubmit={submit}>
|
|
38
|
+
{/* Form fields */}
|
|
39
|
+
</form>
|
|
40
|
+
);
|
|
41
|
+
}
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
### useTableService
|
|
45
|
+
|
|
46
|
+
```typescript
|
|
47
|
+
import { useTableService } from '@codella-software/react';
|
|
48
|
+
|
|
49
|
+
function MyTable() {
|
|
50
|
+
const {
|
|
51
|
+
data,
|
|
52
|
+
filteredData,
|
|
53
|
+
sort,
|
|
54
|
+
filter
|
|
55
|
+
} = useTableService({
|
|
56
|
+
data: users,
|
|
57
|
+
columns: userColumns
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
return (
|
|
61
|
+
<table>
|
|
62
|
+
{/* Table content */}
|
|
63
|
+
</table>
|
|
64
|
+
);
|
|
65
|
+
}
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
### useAPIService
|
|
69
|
+
|
|
70
|
+
```typescript
|
|
71
|
+
import { useAPIService } from '@codella-software/react';
|
|
72
|
+
|
|
73
|
+
function UsersList() {
|
|
74
|
+
const api = useAPIService({
|
|
75
|
+
baseURL: 'https://api.example.com'
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
useEffect(() => {
|
|
79
|
+
api.get('/users').then(setUsers);
|
|
80
|
+
}, [api]);
|
|
81
|
+
|
|
82
|
+
return <div>{/* Display users */}</div>;
|
|
83
|
+
}
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
## Documentation
|
|
87
|
+
|
|
88
|
+
For full API documentation, visit [https://CodellaSoftware.github.io/codella-utils/](https://CodellaSoftware.github.io/codella-utils/)
|
|
89
|
+
|
|
90
|
+
## License
|
|
91
|
+
|
|
92
|
+
MIT
|