@nubitio/crud 0.1.0
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/LICENSE +21 -0
- package/README.md +78 -0
- package/dist/index.cjs +7966 -0
- package/dist/index.d.cts +1869 -0
- package/dist/index.d.mts +1869 -0
- package/dist/index.mjs +7875 -0
- package/dist/style.css +3331 -0
- package/package.json +65 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Johan Guerreros
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
# @nubitio/crud
|
|
2
|
+
|
|
3
|
+
The Nubit CRUD engine: declarative resource pages with a data grid, dialog form, field DSL, RBAC, conditional rules, URL routing, audit trail, and pluggable backend adapters.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @nubitio/crud @nubitio/core @nubitio/ui
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Peer dependencies
|
|
12
|
+
|
|
13
|
+
```json
|
|
14
|
+
"@tanstack/react-query": "^5",
|
|
15
|
+
"i18next": "^23",
|
|
16
|
+
"luxon": "^3",
|
|
17
|
+
"react": "^19",
|
|
18
|
+
"react-dom": "^19",
|
|
19
|
+
"react-i18next": "^14",
|
|
20
|
+
"react-router-dom": "^6"
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## Setup
|
|
24
|
+
|
|
25
|
+
```ts
|
|
26
|
+
import '@nubitio/ui/tokens.css'; // design tokens
|
|
27
|
+
import '@nubitio/ui/style.css'; // UI primitives styles
|
|
28
|
+
import '@nubitio/crud/style.css'; // grid + form styles
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
## Quick start
|
|
32
|
+
|
|
33
|
+
```tsx
|
|
34
|
+
import { SmartCrudPage, defineResource, textField, numberField } from '@nubitio/crud';
|
|
35
|
+
import { HydraAdapter } from '@nubitio/crud';
|
|
36
|
+
|
|
37
|
+
const products = defineResource('/api/products', {
|
|
38
|
+
title: 'Products',
|
|
39
|
+
adapter: HydraAdapter,
|
|
40
|
+
fields: [
|
|
41
|
+
textField('name').label('Name').required(),
|
|
42
|
+
numberField('price').label('Price').format('currency'),
|
|
43
|
+
],
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
export function ProductsPage() {
|
|
47
|
+
return <SmartCrudPage resource={products} />;
|
|
48
|
+
}
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
## Key exports
|
|
52
|
+
|
|
53
|
+
### Engine
|
|
54
|
+
| Export | Description |
|
|
55
|
+
|--------|-------------|
|
|
56
|
+
| `SmartCrudPage` | Main component — resolves schema, applies rules, renders grid + form |
|
|
57
|
+
| `CrudPage` | Lower-level page if you manage fields manually |
|
|
58
|
+
| `defineResource` | Create a typed `ResourceConfig` for a REST/Hydra resource |
|
|
59
|
+
|
|
60
|
+
### Field DSL
|
|
61
|
+
`textField`, `numberField`, `dateField`, `datetimeField`, `entityField`, `enumField`, `selectField`, `checkboxField`, `switchField`, `currencyField`, `imageField`, `textareaField`, `passwordField`
|
|
62
|
+
|
|
63
|
+
Each returns a chainable `FieldBuilder` with `.label()`, `.required()`, `.visibleWhen()`, `.disabledWhen()`, `.onChange()`, `.formatter()`, and more.
|
|
64
|
+
|
|
65
|
+
### Backend adapters
|
|
66
|
+
| Export | Description |
|
|
67
|
+
|--------|-------------|
|
|
68
|
+
| `HydraAdapter` | API Platform / JSON-LD + Hydra (default) |
|
|
69
|
+
| `RestAdapter` | Plain REST with `{ data, total }` or array responses |
|
|
70
|
+
| `BackendAdapter` | Interface to implement a custom adapter |
|
|
71
|
+
|
|
72
|
+
### Extension points
|
|
73
|
+
| Export | Description |
|
|
74
|
+
|--------|-------------|
|
|
75
|
+
| `ResourceSchemaProvider` | Supply a custom field schema for a resource |
|
|
76
|
+
| `ResourceStoreProvider` | Supply a custom data store factory |
|
|
77
|
+
| `SmartCrudRolesProvider` | Inject RBAC role claims for field-level permissions |
|
|
78
|
+
| `defineFieldContract` | Type-safe field contract for `SmartCrudPage` |
|