@rebasepro/core 0.3.0 → 0.5.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/README.md +142 -210
- package/dist/components/LoginView/LoginView.d.ts +9 -1
- package/dist/components/common/types.d.ts +3 -3
- package/dist/hooks/data/useCollectionFetch.d.ts +12 -1
- package/dist/index.es.js +162 -126
- package/dist/index.es.js.map +1 -1
- package/dist/index.umd.js +162 -126
- package/dist/index.umd.js.map +1 -1
- package/package.json +6 -7
- package/src/components/LoginView/LoginView.tsx +27 -5
- package/src/components/common/types.tsx +3 -3
- package/src/components/common/useDataTableController.tsx +49 -37
- package/src/hooks/data/useCollectionFetch.tsx +27 -4
- package/src/hooks/data/useUserSelector.tsx +1 -1
- package/src/hooks/useResolvedComponent.tsx +3 -3
- package/src/locales/en.ts +2 -2
- package/src/util/previews.ts +9 -1
package/README.md
CHANGED
|
@@ -1,242 +1,174 @@
|
|
|
1
|
-
|
|
2
|
-
<a href="https://rebase.pro">
|
|
3
|
-
<img src="https://rebase.pro/img/logo_small.png" width="240px" alt="Rebase logo" />
|
|
4
|
-
</a>
|
|
5
|
-
</p>
|
|
1
|
+
# @rebasepro/core
|
|
6
2
|
|
|
7
|
-
|
|
8
|
-
<h3 align="center">The Open-Source Headless CMS & Admin Panel for Postgres</h3>
|
|
9
|
-
<p align="center">
|
|
10
|
-
<strong>Ship production-ready backends and radically extensible back-office apps in minutes.</strong><br/>
|
|
11
|
-
Own your data, own your code. The absolute easiest way to build on PostgreSQL.
|
|
12
|
-
</p>
|
|
3
|
+
Framework-agnostic runtime for data-driven admin panels — React hooks, providers, contexts, and shared components used by `@rebasepro/admin` and `@rebasepro/studio`.
|
|
13
4
|
|
|
14
|
-
|
|
15
|
-
<a href="https://demo.rebase.pro">Live Demo</a> •
|
|
16
|
-
<a href="https://rebase.pro/docs">Documentation</a> •
|
|
17
|
-
<a href="https://rebase.pro/features">Features</a> •
|
|
18
|
-
<a href="https://github.com/rebasepro/rebase">GitHub</a> •
|
|
19
|
-
<a href="https://discord.gg/fxy7xsQm3m">Discord</a>
|
|
20
|
-
</p>
|
|
21
|
-
|
|
22
|
-
<p align="center">
|
|
23
|
-
<a href="https://www.npmjs.com/package/@rebasepro/core"><img src="https://img.shields.io/npm/v/@rebasepro/core.svg?style=flat-square&color=orange" alt="NPM Version" /></a>
|
|
24
|
-
<a href="https://opensource.org/licenses/MIT"><img src="https://img.shields.io/badge/license-MIT-purple.svg?style=flat-square" alt="License: MIT" /></a>
|
|
25
|
-
<a href="https://www.npmjs.com/package/@rebasepro/core"><img src="https://img.shields.io/npm/dw/@rebasepro/core?style=flat-square&color=blue" alt="NPM Downloads" /></a>
|
|
26
|
-
<a href="https://discord.gg/fxy7xsQm3m"><img src="https://img.shields.io/discord/1013768502458470442?style=flat-square&logo=discord&logoColor=white&label=Discord" alt="Discord" /></a>
|
|
27
|
-
</p>
|
|
28
|
-
|
|
29
|
-
<br/>
|
|
30
|
-
|
|
31
|
-
<p align="center">
|
|
32
|
-
<img src="https://rebase.pro/img/demo_products.png" width="800px" alt="Rebase Dashboard" />
|
|
33
|
-
</p>
|
|
34
|
-
|
|
35
|
-
---
|
|
36
|
-
|
|
37
|
-
## What is Rebase?
|
|
38
|
-
|
|
39
|
-
Rebase is a **developer-first**, open-source headless CMS and admin panel framework built with **React** and **TypeScript**. It gives you a complete backend-as-a-service layer on top of PostgreSQL — including authentication, S3-compatible storage, a full admin UI, and auto-generated APIs — while letting you extend every layer with custom React components, serverless functions, and scripts.
|
|
40
|
-
|
|
41
|
-
### ✨ Key Highlights
|
|
42
|
-
|
|
43
|
-
- 🔓 **No Vendor Lock-in** — Self-host anywhere. Full control over your infrastructure, code, and database.
|
|
44
|
-
- ⚡ **Instant Setup** — `npx @rebasepro/cli init` scaffolds a production-ready project in seconds.
|
|
45
|
-
- 🗄️ **PostgreSQL First** — First-class Postgres support with Drizzle ORM, schema introspection, and automatic migrations.
|
|
46
|
-
- 🧩 **Radical Extensibility** — Not constrained to pre-built widgets. If you can build it in React, you can build it in Rebase.
|
|
47
|
-
- 🎨 **Premium UI** — Fast, accessible design system built on Tailwind CSS v4 and Radix UI.
|
|
48
|
-
- 🤖 **AI-Ready** — MCP server for AI-assisted database management, plus data enhancement and insights plugins.
|
|
49
|
-
|
|
50
|
-
---
|
|
51
|
-
|
|
52
|
-
## ⚡ Quick Start
|
|
53
|
-
|
|
54
|
-
Scaffold a complete, self-hosted Rebase application connected to your database:
|
|
55
|
-
|
|
56
|
-
```bash
|
|
57
|
-
npx @rebasepro/cli init my-rebase-app
|
|
58
|
-
```
|
|
59
|
-
|
|
60
|
-
Configure your database in `.env`, then start everything:
|
|
5
|
+
## Installation
|
|
61
6
|
|
|
62
7
|
```bash
|
|
63
|
-
|
|
64
|
-
npm run dev
|
|
8
|
+
pnpm add @rebasepro/core
|
|
65
9
|
```
|
|
66
10
|
|
|
67
|
-
|
|
11
|
+
**Peer dependencies:** `react >= 19`, `react-dom >= 19`, `react-router ^7`, `react-router-dom ^7`
|
|
68
12
|
|
|
69
|
-
|
|
13
|
+
## What This Package Does
|
|
70
14
|
|
|
71
|
-
|
|
15
|
+
`@rebasepro/core` is the shared runtime layer that powers the Rebase CMS. It provides:
|
|
72
16
|
|
|
73
|
-
|
|
17
|
+
- **App bootstrapping** — `Rebase`, `RebaseRouter`, `RebaseRoutes`, `PluginProviderStack`
|
|
18
|
+
- **React contexts** — auth, data driver, storage, snackbar, dialogs, mode, admin mode, role, analytics, customization
|
|
19
|
+
- **Hooks** — data fetching (`useData`, `useCollectionFetch`, `useEntityFetch`), data mutation (`save`, `delete`), auth (`useAuthController`), storage, permissions, i18n, and more
|
|
20
|
+
- **UI components** — `LoginView`, `RebaseAuth`, `ConfirmationDialog`, `ErrorView`, `UserSettingsView`, `BootstrapAdminBanner`, etc.
|
|
21
|
+
- **Utilities** — icon system, entity caching, storage upload controller, enums, constants
|
|
22
|
+
- **i18n** — built-in English and Spanish locales via `react-i18next`
|
|
23
|
+
- **Studio Bridge** — shared context for optional CMS↔Studio integration
|
|
74
24
|
|
|
75
|
-
|
|
25
|
+
This package is **framework-agnostic** in the sense that it doesn't depend on any specific data backend — it works with any `DataDriver` implementation (PostgreSQL, Firebase, MongoDB, etc.).
|
|
76
26
|
|
|
77
|
-
|
|
78
|
-
- **Card grid** — Visual overview with image previews
|
|
79
|
-
- **List view** — Compact, scannable layout
|
|
80
|
-
- **Custom views** — Build any React component as a collection view
|
|
27
|
+
## Key Exports
|
|
81
28
|
|
|
82
|
-
###
|
|
29
|
+
### App Bootstrapping
|
|
83
30
|
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
### 🔐 Authentication & Access Control
|
|
87
|
-
|
|
88
|
-
Built-in authentication with multiple providers:
|
|
89
|
-
|
|
90
|
-
- **Email/Password** — With password reset flow
|
|
91
|
-
- **Google OAuth** — One-click sign-in
|
|
92
|
-
- **Anonymous** — For guest access
|
|
93
|
-
|
|
94
|
-
Granular **role-based access control (RBAC)** with customizable permissions per collection, field, and action.
|
|
95
|
-
|
|
96
|
-
### 📦 S3-Compatible Storage
|
|
97
|
-
|
|
98
|
-
Native S3-compatible file storage with:
|
|
99
|
-
|
|
100
|
-
- Drag-and-drop uploads with progress tracking
|
|
101
|
-
- Automatic image resizing and optimization
|
|
102
|
-
- File metadata management
|
|
103
|
-
- Storage browser in Studio
|
|
104
|
-
|
|
105
|
-
### 🛠️ Studio — Developer Toolbox
|
|
106
|
-
|
|
107
|
-
A full developer environment built into the admin panel:
|
|
108
|
-
|
|
109
|
-
| Tool | Description |
|
|
31
|
+
| Export | Description |
|
|
110
32
|
|---|---|
|
|
111
|
-
|
|
|
112
|
-
|
|
|
113
|
-
|
|
|
114
|
-
|
|
|
115
|
-
| **API Explorer** | Browse and test your auto-generated REST API endpoints |
|
|
116
|
-
| **Cron Jobs** | Schedule and monitor recurring tasks |
|
|
117
|
-
| **Storage Browser** | Browse and manage files in your S3-compatible storage |
|
|
118
|
-
|
|
119
|
-
### ⚡ Extensible API & Edge Functions
|
|
120
|
-
|
|
121
|
-
Drop custom Hono routes or scheduled tasks into the `functions/` and `crons/` directories. Rebase auto-loads them with database access and JWT authentication middleware injected automatically.
|
|
33
|
+
| `Rebase` | Root component — accepts collections, auth, data source config and renders the app |
|
|
34
|
+
| `RebaseRouter` | Router wrapper for react-router integration |
|
|
35
|
+
| `RebaseRoutes` | Route definitions |
|
|
36
|
+
| `PluginProviderStack` | Wraps children with plugin-provided context providers |
|
|
122
37
|
|
|
123
|
-
###
|
|
38
|
+
### Hooks — Data
|
|
124
39
|
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
```bash
|
|
128
|
-
npx @rebasepro/cli generate-sdk
|
|
129
|
-
```
|
|
130
|
-
|
|
131
|
-
### 🤖 MCP Server
|
|
132
|
-
|
|
133
|
-
A built-in **Model Context Protocol** server that enables AI assistants to:
|
|
134
|
-
|
|
135
|
-
- Query and manage your database schema
|
|
136
|
-
- Create, read, update, and delete documents
|
|
137
|
-
- Manage users and roles
|
|
138
|
-
- Introspect your data model
|
|
139
|
-
|
|
140
|
-
### 🔍 Schema Inference & Introspection
|
|
141
|
-
|
|
142
|
-
Point Rebase at an existing PostgreSQL database and automatically generate collection definitions from your tables — including types, relations, validation constraints, and more.
|
|
143
|
-
|
|
144
|
-
### 📥📤 Import & Export
|
|
145
|
-
|
|
146
|
-
Import data from **CSV, JSON, and Excel** with an intuitive field mapper. Export your data in multiple formats with configurable column selection.
|
|
147
|
-
|
|
148
|
-
### 🧩 Plugins
|
|
149
|
-
|
|
150
|
-
Extend the admin experience with first-party plugins:
|
|
151
|
-
|
|
152
|
-
- **Data Enhancement** — AI-powered field suggestions and auto-fill
|
|
153
|
-
- **Insights** — Analytics dashboards and usage metrics
|
|
154
|
-
|
|
155
|
-
### 📜 Standalone Scripting
|
|
156
|
-
|
|
157
|
-
Write standalone data manipulation scripts that connect directly to your running backend using the `@rebasepro/client` SDK. The CLI persists the dev server URL to `.rebase-dev-url` for zero-config local development.
|
|
158
|
-
|
|
159
|
-
### 🧩 Custom Views & React Extensibility
|
|
160
|
-
|
|
161
|
-
Build entirely custom views — dashboards, previews, charts — and drop them into the main navigation or as entity-level tabs. Use built-in hooks to interact with Rebase's internal state.
|
|
162
|
-
|
|
163
|
-
---
|
|
164
|
-
|
|
165
|
-
## 🛠️ Core Technologies
|
|
166
|
-
|
|
167
|
-
Built entirely on modern, battle-tested web standards:
|
|
168
|
-
|
|
169
|
-
| Technology | What we use it for |
|
|
40
|
+
| Export | Description |
|
|
170
41
|
|---|---|
|
|
171
|
-
|
|
|
172
|
-
|
|
|
173
|
-
|
|
|
174
|
-
|
|
|
175
|
-
|
|
|
176
|
-
|
|
|
177
|
-
|
|
|
178
|
-
| 🌐 **Hono** | Ultrafast HTTP server framework |
|
|
42
|
+
| `useData` | Access the data driver from context |
|
|
43
|
+
| `useCollectionFetch` | Fetch a collection with filters, pagination, and realtime |
|
|
44
|
+
| `useEntityFetch` | Fetch a single entity by ID |
|
|
45
|
+
| `useRelationSelector` | Relation field selector state |
|
|
46
|
+
| `useUserSelector` | User selector state |
|
|
47
|
+
| `save` utilities | Entity save helpers |
|
|
48
|
+
| `delete` utilities | Entity delete helpers |
|
|
179
49
|
|
|
180
|
-
|
|
50
|
+
### Hooks — Auth & Permissions
|
|
181
51
|
|
|
182
|
-
|
|
52
|
+
| Export | Description |
|
|
53
|
+
|---|---|
|
|
54
|
+
| `useAuthController` | Access the current auth controller from context |
|
|
55
|
+
| `useAuthSubscription` | Subscribe to auth state changes |
|
|
56
|
+
| `usePermissions` | Check permissions for collections/actions |
|
|
57
|
+
| `useAdminModeController` / `useBuildAdminModeController` | Admin mode toggle |
|
|
58
|
+
| `useEffectiveRoleController` / `useBuildEffectiveRoleController` | Current user's effective role |
|
|
183
59
|
|
|
184
|
-
|
|
60
|
+
### Hooks — UI & State
|
|
185
61
|
|
|
186
|
-
|
|
|
62
|
+
| Export | Description |
|
|
187
63
|
|---|---|
|
|
188
|
-
|
|
|
189
|
-
|
|
|
190
|
-
|
|
|
191
|
-
|
|
|
192
|
-
|
|
|
193
|
-
|
|
|
194
|
-
|
|
|
195
|
-
|
|
|
196
|
-
|
|
|
197
|
-
|
|
|
198
|
-
|
|
|
199
|
-
|
|
|
200
|
-
|
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
|
205
|
-
|
|
206
|
-
|
|
|
207
|
-
|
|
|
208
|
-
| `@rebasepro/plugin-insights` | Analytics and insights plugin |
|
|
209
|
-
|
|
210
|
-
---
|
|
211
|
-
|
|
212
|
-
## 🎨 Standalone UI Library
|
|
213
|
-
|
|
214
|
-
Rebase exposes its design system as a completely independent library. Fully typed, accessible, and customizable via Tailwind CSS v4:
|
|
215
|
-
|
|
216
|
-
```bash
|
|
217
|
-
npm install @rebasepro/ui
|
|
218
|
-
```
|
|
64
|
+
| `useRebaseContext` | Access the top-level Rebase context |
|
|
65
|
+
| `useDialogsController` | Programmatic dialog management |
|
|
66
|
+
| `useSnackbarController` | Show snackbar notifications |
|
|
67
|
+
| `useModeController` / `useBuildModeController` | Light/dark mode |
|
|
68
|
+
| `useStorageSource` / `useBackendStorageSource` | Storage source from context |
|
|
69
|
+
| `useRebaseClient` | Access the `RebaseClient` instance |
|
|
70
|
+
| `useLargeLayout` | Responsive layout breakpoint hook |
|
|
71
|
+
| `useClipboard` | Copy-to-clipboard |
|
|
72
|
+
| `useUnsavedChangesDialog` | Prompt user about unsaved changes |
|
|
73
|
+
| `useCustomizationController` | UI customization overrides |
|
|
74
|
+
| `useRebaseRegistry` | Access the collection/plugin registry |
|
|
75
|
+
| `useTranslation` | i18n translation hook |
|
|
76
|
+
| `useAnalyticsController` | Analytics event tracking |
|
|
77
|
+
|
|
78
|
+
### Hooks — Studio Bridge
|
|
79
|
+
|
|
80
|
+
| Export | Description |
|
|
81
|
+
|---|---|
|
|
82
|
+
| `useStudioBridge` | Access bridge context for CMS↔Studio communication |
|
|
83
|
+
| `useBridgeRegistration` | Register bridge callbacks (self-assembling) |
|
|
219
84
|
|
|
220
|
-
|
|
85
|
+
### Components
|
|
221
86
|
|
|
222
|
-
|
|
87
|
+
| Export | Description |
|
|
88
|
+
|---|---|
|
|
89
|
+
| `LoginView` | Pre-built login/register form UI |
|
|
90
|
+
| `RebaseAuth` | Auth gate component — handles login flow rendering |
|
|
91
|
+
| `ErrorView` | Error display component |
|
|
92
|
+
| `ConfirmationDialog` | Configurable confirmation dialog |
|
|
93
|
+
| `UnsavedChangesDialog` | "Discard changes?" dialog |
|
|
94
|
+
| `NotFoundPage` | 404 page |
|
|
95
|
+
| `UserSettingsView` | User profile settings page |
|
|
96
|
+
| `UserSelectPopover` / `UserDisplay` | User avatar/name display |
|
|
97
|
+
| `LanguageToggle` | i18n language switcher |
|
|
98
|
+
| `BootstrapAdminBanner` | First-user setup banner |
|
|
99
|
+
| `RebaseLogo` | Rebase branding logo |
|
|
100
|
+
| `UIStyleGuide` / `UIReferenceView` | Debug/reference components |
|
|
101
|
+
|
|
102
|
+
### Contexts
|
|
103
|
+
|
|
104
|
+
| Export | Description |
|
|
105
|
+
|---|---|
|
|
106
|
+
| `SnackbarProvider` | Snackbar notification context |
|
|
107
|
+
| `ModeController` | Light/dark mode context |
|
|
108
|
+
| `AdminModeController` | Admin mode context |
|
|
109
|
+
| `EffectiveRoleController` | User role context |
|
|
110
|
+
| `AuthControllerContext` | Auth controller context |
|
|
111
|
+
| `DataDriverContext` | Data driver context |
|
|
112
|
+
| `StorageSourceContext` | Storage source context |
|
|
113
|
+
| `DialogsProvider` | Dialog management context |
|
|
114
|
+
| `RebaseClientInstanceContext` | Client instance context |
|
|
115
|
+
| `CustomizationControllerContext` | UI customization context |
|
|
116
|
+
| `AnalyticsContext` | Analytics context |
|
|
117
|
+
|
|
118
|
+
### Utilities
|
|
119
|
+
|
|
120
|
+
| Export | Description |
|
|
121
|
+
|---|---|
|
|
122
|
+
| `iconList` / icon helpers | Full icon set and lookup |
|
|
123
|
+
| `createFormexStub` | Create a form stub for testing |
|
|
124
|
+
| `entityCache` | Entity LRU cache |
|
|
125
|
+
| `useStorageUploadController` | File upload progress controller |
|
|
126
|
+
| `previews` | Preview rendering utilities |
|
|
127
|
+
| `enums` / `constants` | Shared enums and constant values |
|
|
223
128
|
|
|
224
|
-
|
|
129
|
+
### i18n
|
|
225
130
|
|
|
226
|
-
|
|
131
|
+
| Export | Description |
|
|
132
|
+
|---|---|
|
|
133
|
+
| `RebaseI18nProvider` | i18n context provider |
|
|
134
|
+
| `en` locale | English translations |
|
|
135
|
+
| `es` locale | Spanish translations |
|
|
227
136
|
|
|
228
|
-
|
|
137
|
+
### Vite Plugin
|
|
229
138
|
|
|
230
|
-
|
|
139
|
+
Available as a separate entry point:
|
|
231
140
|
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
- 📝 [Changelog](./CHANGELOG.md)
|
|
141
|
+
```ts
|
|
142
|
+
import { rebaseVitePlugin } from "@rebasepro/core/vitePlugin";
|
|
143
|
+
```
|
|
236
144
|
|
|
237
|
-
|
|
145
|
+
## Quick Start
|
|
146
|
+
|
|
147
|
+
```tsx
|
|
148
|
+
import { Rebase, useAuthController, useCollectionFetch } from "@rebasepro/core";
|
|
149
|
+
|
|
150
|
+
function App() {
|
|
151
|
+
return (
|
|
152
|
+
<Rebase
|
|
153
|
+
collections={collections}
|
|
154
|
+
authController={authController}
|
|
155
|
+
dataSource={dataSource}
|
|
156
|
+
/>
|
|
157
|
+
);
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
// Inside any child component:
|
|
161
|
+
function ProductList() {
|
|
162
|
+
const { data, loading } = useCollectionFetch("products", { limit: 20 });
|
|
163
|
+
// ...
|
|
164
|
+
}
|
|
165
|
+
```
|
|
238
166
|
|
|
239
|
-
##
|
|
167
|
+
## Related Packages
|
|
240
168
|
|
|
241
|
-
|
|
242
|
-
|
|
169
|
+
- [`@rebasepro/admin`](../admin) — CMS views, forms, and routing (built on top of core)
|
|
170
|
+
- [`@rebasepro/ui`](../ui) — Design system components
|
|
171
|
+
- [`@rebasepro/common`](../common) — Shared utilities and collection registry
|
|
172
|
+
- [`@rebasepro/types`](../types) — TypeScript type definitions
|
|
173
|
+
- [`@rebasepro/formex`](../formex) — Form state management
|
|
174
|
+
- [`@rebasepro/client`](../client) — HTTP client SDK
|
|
@@ -92,10 +92,18 @@ export interface LoginViewProps {
|
|
|
92
92
|
* If not set, derived from `authController.capabilities.registration`.
|
|
93
93
|
*/
|
|
94
94
|
registrationEnabled?: boolean;
|
|
95
|
+
/**
|
|
96
|
+
* Pre-fill the email field (e.g. for demo or testing environments).
|
|
97
|
+
*/
|
|
98
|
+
defaultEmail?: string;
|
|
99
|
+
/**
|
|
100
|
+
* Pre-fill the password field (e.g. for demo or testing environments).
|
|
101
|
+
*/
|
|
102
|
+
defaultPassword?: string;
|
|
95
103
|
}
|
|
96
104
|
/**
|
|
97
105
|
* Generic login view component that works with any AuthControllerExtended.
|
|
98
106
|
* Feature-detects capabilities to show/hide login methods.
|
|
99
107
|
* @group Core
|
|
100
108
|
*/
|
|
101
|
-
export declare function LoginView({ logo, authController, noUserComponent, disableSignupScreen, disabled, notAllowedError, googleClientId, githubClientId, linkedinClientId, title, subtitle, needsSetup, registrationEnabled, additionalComponent }: LoginViewProps): import("react/jsx-runtime").JSX.Element;
|
|
109
|
+
export declare function LoginView({ logo, authController, noUserComponent, disableSignupScreen, disabled, notAllowedError, googleClientId, githubClientId, linkedinClientId, title, subtitle, needsSetup, registrationEnabled, additionalComponent, defaultEmail, defaultPassword }: LoginViewProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Property } from "@rebasepro/types";
|
|
1
|
+
import type { Property, Entity } from "@rebasepro/types";
|
|
2
2
|
import { CollectionSize, SelectedCellProps } from "@rebasepro/types";
|
|
3
3
|
export type EntityCollectionTableController<M extends Record<string, unknown>> = {
|
|
4
4
|
/**
|
|
@@ -26,7 +26,7 @@ export type EntityCollectionTableController<M extends Record<string, unknown>> =
|
|
|
26
26
|
* Callback used when the value of a cell has changed.
|
|
27
27
|
* @param params
|
|
28
28
|
*/
|
|
29
|
-
onValueChange?: (params: OnCellValueChangeParams<unknown, M
|
|
29
|
+
onValueChange?: (params: OnCellValueChangeParams<unknown, Entity<M>>) => void;
|
|
30
30
|
/**
|
|
31
31
|
* Size of the elements in the collection
|
|
32
32
|
*/
|
|
@@ -56,7 +56,7 @@ export type UniqueFieldValidator = (props: {
|
|
|
56
56
|
* Callback when a cell has changed in a table
|
|
57
57
|
* @group Collection components
|
|
58
58
|
*/
|
|
59
|
-
export type OnCellValueChange<T, M extends Record<string, unknown>> = (params: OnCellValueChangeParams<T, M
|
|
59
|
+
export type OnCellValueChange<T, M extends Record<string, unknown>> = (params: OnCellValueChangeParams<T, Entity<M>>) => Promise<void> | void;
|
|
60
60
|
/**
|
|
61
61
|
* @group Collection components
|
|
62
62
|
*/
|
|
@@ -16,6 +16,14 @@ export interface CollectionFetchProps<M extends Record<string, any>> {
|
|
|
16
16
|
* Number of entities to fetch
|
|
17
17
|
*/
|
|
18
18
|
itemCount?: number;
|
|
19
|
+
/**
|
|
20
|
+
* Number of items to skip
|
|
21
|
+
*/
|
|
22
|
+
offset?: number;
|
|
23
|
+
/**
|
|
24
|
+
* Page number (1-indexed), alternative to offset
|
|
25
|
+
*/
|
|
26
|
+
page?: number;
|
|
19
27
|
/**
|
|
20
28
|
* Filter the fetched data by the property
|
|
21
29
|
*/
|
|
@@ -37,6 +45,7 @@ export interface CollectionFetchResult<M extends Record<string, any>> {
|
|
|
37
45
|
dataLoading: boolean;
|
|
38
46
|
noMoreToLoad: boolean;
|
|
39
47
|
dataLoadingError?: Error;
|
|
48
|
+
totalCount?: number;
|
|
40
49
|
}
|
|
41
50
|
/**
|
|
42
51
|
* This hook is used to fetch collections using a given collection
|
|
@@ -45,7 +54,9 @@ export interface CollectionFetchResult<M extends Record<string, any>> {
|
|
|
45
54
|
* @param filterValues
|
|
46
55
|
* @param sortBy
|
|
47
56
|
* @param itemCount
|
|
57
|
+
* @param offset
|
|
58
|
+
* @param page
|
|
48
59
|
* @param searchString
|
|
49
60
|
* @group Hooks and utilities
|
|
50
61
|
*/
|
|
51
|
-
export declare function useCollectionFetch<M extends Record<string, any>, USER extends User>({ path, collection, filterValues, sortBy, itemCount, searchString }: CollectionFetchProps<M>): CollectionFetchResult<M>;
|
|
62
|
+
export declare function useCollectionFetch<M extends Record<string, any>, USER extends User>({ path, collection, filterValues, sortBy, itemCount, offset, page, searchString }: CollectionFetchProps<M>): CollectionFetchResult<M>;
|