@rebasepro/core 0.0.1-canary.94dff14 → 0.0.1-canary.a6becfb
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 +178 -110
- package/dist/components/BootstrapAdminBanner.d.ts +4 -0
- package/dist/components/LoginView/LoginView.d.ts +22 -0
- package/dist/components/common/useDataTableController.d.ts +3 -3
- package/dist/components/index.d.ts +1 -0
- package/dist/hooks/data/useRelationSelector.d.ts +2 -2
- package/dist/hooks/index.d.ts +1 -0
- package/dist/hooks/useCollapsedGroups.d.ts +16 -1
- package/dist/hooks/useResolvedComponent.d.ts +47 -0
- package/dist/index.es.js +337 -121
- package/dist/index.es.js.map +1 -1
- package/dist/index.umd.js +334 -118
- package/dist/index.umd.js.map +1 -1
- package/dist/vitePlugin.d.ts +28 -1
- package/dist/vitePlugin.js +42 -0
- package/package.json +7 -8
- package/src/components/BootstrapAdminBanner.tsx +66 -0
- package/src/components/LoginView/LoginView.tsx +73 -42
- package/src/components/UserSelectPopover.tsx +8 -34
- package/src/components/common/useColumnsIds.tsx +16 -16
- package/src/components/common/useDataTableController.tsx +30 -18
- package/src/components/index.tsx +1 -1
- package/src/core/Rebase.tsx +20 -14
- package/src/hooks/data/useRelationSelector.tsx +6 -6
- package/src/hooks/index.tsx +1 -0
- package/src/hooks/useCollapsedGroups.ts +48 -6
- package/src/hooks/useRebaseContext.tsx +11 -6
- package/src/hooks/useResolvedComponent.tsx +157 -0
- package/src/hooks/useStudioBridge.tsx +2 -1
- package/src/locales/de.ts +4 -0
- package/src/locales/en.ts +12 -0
- package/src/locales/es.ts +4 -0
- package/src/locales/fr.ts +4 -0
- package/src/locales/hi.ts +4 -0
- package/src/locales/it.ts +4 -0
- package/src/locales/pt.ts +4 -0
- package/src/util/previews.ts +16 -7
- package/src/vitePlugin.ts +87 -1
package/README.md
CHANGED
|
@@ -1,7 +1,3 @@
|
|
|
1
|
-
<p align="center">
|
|
2
|
-
<img src="https://rebase.pro/img/dark_mode.webp" alt="Intro video" style="max-width: 100%;"/>
|
|
3
|
-
</p>
|
|
4
|
-
|
|
5
1
|
<p align="center">
|
|
6
2
|
<a href="https://rebase.pro">
|
|
7
3
|
<img src="https://rebase.pro/img/logo_small.png" width="240px" alt="Rebase logo" />
|
|
@@ -9,166 +5,238 @@
|
|
|
9
5
|
</p>
|
|
10
6
|
|
|
11
7
|
<h1 align="center">Rebase</h1>
|
|
12
|
-
<h3 align="center">
|
|
13
|
-
<p align="center"
|
|
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>
|
|
13
|
+
|
|
14
|
+
<p align="center">
|
|
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>
|
|
14
21
|
|
|
15
|
-
<
|
|
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>
|
|
16
34
|
|
|
35
|
+
---
|
|
17
36
|
|
|
18
|
-
|
|
37
|
+
## What is Rebase?
|
|
19
38
|
|
|
20
|
-
|
|
21
|
-
that seamlessly integrates with **Firebase and Firestore** by default, but is
|
|
22
|
-
also
|
|
23
|
-
compatible with any backend.
|
|
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.
|
|
24
40
|
|
|
25
|
-
|
|
26
|
-
simple
|
|
27
|
-
to set up for standard cases and easy to extend and customize for more specific
|
|
28
|
-
needs.
|
|
41
|
+
### ✨ Key Highlights
|
|
29
42
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
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.
|
|
34
49
|
|
|
35
|
-
|
|
36
|
-
out-of-the-box experience for any project.
|
|
50
|
+
---
|
|
37
51
|
|
|
38
|
-
|
|
52
|
+
## ⚡ Quick Start
|
|
39
53
|
|
|
40
|
-
Rebase
|
|
54
|
+
Scaffold a complete, self-hosted Rebase application connected to your database:
|
|
41
55
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
- React + React Router 6
|
|
56
|
+
```bash
|
|
57
|
+
npx @rebasepro/cli init my-rebase-app
|
|
58
|
+
```
|
|
46
59
|
|
|
47
|
-
|
|
60
|
+
Configure your database in `.env`, then start everything:
|
|
48
61
|
|
|
49
|
-
|
|
50
|
-
|
|
62
|
+
```bash
|
|
63
|
+
cd my-rebase-app
|
|
64
|
+
npm run dev
|
|
65
|
+
```
|
|
51
66
|
|
|
52
|
-
|
|
67
|
+
Your admin panel is running at `http://localhost:5173` and the API at `http://localhost:3001`.
|
|
53
68
|
|
|
54
|
-
|
|
69
|
+
---
|
|
55
70
|
|
|
56
|
-
|
|
71
|
+
## Features
|
|
57
72
|
|
|
58
|
-
|
|
73
|
+
### 🏓 Full Admin Panel & CMS
|
|
59
74
|
|
|
60
|
-
|
|
75
|
+
An incredibly fast, windowed spreadsheet view to manage your database with inline editing, real-time updates, filtering, sorting, and text search. Switch between multiple view modes:
|
|
61
76
|
|
|
62
|
-
|
|
77
|
+
- **Spreadsheet table** — Inline editing, column reordering, drag-and-drop
|
|
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
|
|
63
81
|
|
|
64
|
-
|
|
82
|
+
### 🔒 Typed Schema & Database Migrations
|
|
65
83
|
|
|
66
|
-
|
|
84
|
+
Define your data models using pure TypeScript collections. Rebase automatically generates your Drizzle ORM schema, handles PostgreSQL migrations, and keeps your live database perfectly in sync using built-in tooling like `rebase doctor`.
|
|
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 |
|
|
110
|
+
|---|---|
|
|
111
|
+
| **SQL Editor** | Write and execute SQL queries directly against your database with schema-aware autocomplete |
|
|
112
|
+
| **RLS Policy Editor** | Visual editor for PostgreSQL Row-Level Security policies |
|
|
113
|
+
| **Schema Visualizer** | Interactive ER diagram of your database with relationship mapping |
|
|
114
|
+
| **JS/TS Editor** | In-browser code editor for scripts and functions |
|
|
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.
|
|
122
|
+
|
|
123
|
+
### 🧬 SDK Generator
|
|
124
|
+
|
|
125
|
+
Auto-generate fully typed **TypeScript SDKs** from your collection definitions. Use them in any frontend, script, or service to interact with your Rebase backend with complete type safety.
|
|
126
|
+
|
|
127
|
+
```bash
|
|
128
|
+
npx @rebasepro/cli generate-sdk
|
|
129
|
+
```
|
|
67
130
|
|
|
68
|
-
|
|
69
|
-
to build a CMS/admin tool while offering an excellent data editing experience
|
|
70
|
-
and a user-friendly interface for marketers and content managers.
|
|
131
|
+
### 🤖 MCP Server
|
|
71
132
|
|
|
72
|
-
|
|
133
|
+
A built-in **Model Context Protocol** server that enables AI assistants to:
|
|
73
134
|
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
135
|
+
- Query and manage your database schema
|
|
136
|
+
- Create, read, update, and delete documents
|
|
137
|
+
- Manage users and roles
|
|
138
|
+
- Introspect your data model
|
|
77
139
|
|
|
78
|
-
|
|
79
|
-
constant updates. It also supports **text search** (through an external provider
|
|
80
|
-
like Algolia, if using Firestore), **filtering and sorting**, and **exporting**
|
|
81
|
-
data.
|
|
140
|
+
### 🔍 Schema Inference & Introspection
|
|
82
141
|
|
|
83
|
-
|
|
142
|
+
Point Rebase at an existing PostgreSQL database and automatically generate collection definitions from your tables — including types, relations, validation constraints, and more.
|
|
84
143
|
|
|
85
|
-
|
|
144
|
+
### 📥📤 Import & Export
|
|
86
145
|
|
|
87
|
-
|
|
88
|
-
navigating through **subcollections** and accessing custom views (such as custom
|
|
89
|
-
forms or blog previews). This functionality can also be accessed
|
|
90
|
-
programmatically using the `useSideEntityController` hook.
|
|
146
|
+
Import data from **CSV, JSON, and Excel** with an intuitive field mapper. Export your data in multiple formats with configurable column selection.
|
|
91
147
|
|
|
92
|
-
|
|
93
|
-
validation options. The components have been carefully designed for an
|
|
94
|
-
outstanding user experience, including advanced features like **references** to
|
|
95
|
-
other collections, **markdown**, and **array reordering**.
|
|
148
|
+
### 🧩 Plugins
|
|
96
149
|
|
|
97
|
-
|
|
98
|
-
component.
|
|
150
|
+
Extend the admin experience with first-party plugins:
|
|
99
151
|
|
|
100
|
-
|
|
101
|
-
|
|
152
|
+
- **Data Enhancement** — AI-powered field suggestions and auto-fill
|
|
153
|
+
- **Insights** — Analytics dashboards and usage metrics
|
|
102
154
|
|
|
103
|
-
###
|
|
155
|
+
### 📜 Standalone Scripting
|
|
104
156
|
|
|
105
|
-
|
|
106
|
-
delete) they can perform based on your role system. You can even configure this
|
|
107
|
-
on a per-entity or collection level.
|
|
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.
|
|
108
158
|
|
|
109
|
-
|
|
110
|
-
implement your own.
|
|
159
|
+
### 🧩 Custom Views & React Extensibility
|
|
111
160
|
|
|
112
|
-
|
|
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.
|
|
113
162
|
|
|
114
|
-
|
|
115
|
-
integrated reference fields and shortcuts.
|
|
163
|
+
---
|
|
116
164
|
|
|
117
|
-
|
|
118
|
-
collection/document/collection model.
|
|
165
|
+
## 🛠️ Core Technologies
|
|
119
166
|
|
|
120
|
-
|
|
167
|
+
Built entirely on modern, battle-tested web standards:
|
|
121
168
|
|
|
122
|
-
|
|
123
|
-
|
|
169
|
+
| Technology | What we use it for |
|
|
170
|
+
|---|---|
|
|
171
|
+
| 💙 **TypeScript 5.x** | End-to-end type safety |
|
|
172
|
+
| ⚛️ **React 19** | Component-driven UI |
|
|
173
|
+
| 🌊 **Tailwind CSS v4** | Utility-first styling |
|
|
174
|
+
| 🔌 **WebSockets** | Real-time synchronization |
|
|
175
|
+
| 🗄️ **Drizzle ORM** | Type-safe SQL migrations and queries |
|
|
176
|
+
| 🧱 **Radix UI** | Accessible UI primitives |
|
|
177
|
+
| 📝 **TipTap v3** | Rich text editing |
|
|
178
|
+
| 🌐 **Hono** | Ultrafast HTTP server framework |
|
|
124
179
|
|
|
125
|
-
|
|
126
|
-
updated in any open form view as long as it hasn't been touched by the user.
|
|
127
|
-
This enables advanced cases where a Cloud Function is triggered after saving an
|
|
128
|
-
entity, modifying some values, and requiring real-time updates.
|
|
180
|
+
---
|
|
129
181
|
|
|
130
|
-
|
|
182
|
+
## 📦 Packages
|
|
131
183
|
|
|
132
|
-
Rebase
|
|
133
|
-
specific fields for handling single and multiple file uploads, as well as
|
|
134
|
-
reordering.
|
|
184
|
+
Rebase is structured as a modular monorepo — install only the layers you need:
|
|
135
185
|
|
|
136
|
-
|
|
186
|
+
| Package | Description |
|
|
187
|
+
|---|---|
|
|
188
|
+
| `@rebasepro/types` | Core TypeScript type definitions |
|
|
189
|
+
| `@rebasepro/utils` | Shared utility functions |
|
|
190
|
+
| `@rebasepro/common` | Common modules shared across packages |
|
|
191
|
+
| `@rebasepro/formex` | Lightweight form management library |
|
|
192
|
+
| `@rebasepro/ui` | Standalone React component library (Tailwind + Radix) |
|
|
193
|
+
| `@rebasepro/core` | Core CMS logic and controllers |
|
|
194
|
+
| `@rebasepro/client` | Client-side data access layer |
|
|
195
|
+
| `@rebasepro/client-postgresql` | PostgreSQL client adapter |
|
|
196
|
+
| `@rebasepro/client-firebase` | Firebase/Firestore client adapter |
|
|
197
|
+
| `@rebasepro/server-core` | Server framework and middleware (Hono) |
|
|
198
|
+
| `@rebasepro/server-postgresql` | PostgreSQL server adapter with Drizzle |
|
|
199
|
+
| `@rebasepro/server-mongodb` | MongoDB server adapter |
|
|
200
|
+
| `@rebasepro/auth` | Authentication controllers and login views |
|
|
201
|
+
| `@rebasepro/admin` | Full admin panel interface |
|
|
202
|
+
| `@rebasepro/studio` | SQL editor, RLS editor, schema visualizer, API explorer |
|
|
203
|
+
| `@rebasepro/cli` | CLI for project scaffolding and management |
|
|
204
|
+
| `@rebasepro/sdk-generator` | TypeScript SDK code generation |
|
|
205
|
+
| `@rebasepro/mcp-server` | MCP server for AI integrations |
|
|
206
|
+
| `@rebasepro/schema-inference` | Database schema introspection and inference |
|
|
207
|
+
| `@rebasepro/plugin-data-enhancement` | AI-powered data enhancement plugin |
|
|
208
|
+
| `@rebasepro/plugin-insights` | Analytics and insights plugin |
|
|
137
209
|
|
|
138
|
-
|
|
210
|
+
---
|
|
139
211
|
|
|
140
|
-
|
|
141
|
-
[`example`](https://github.com/rebasepro/rebase/tree/master/example). It includes
|
|
142
|
-
every feature provided by this CMS.
|
|
212
|
+
## 🎨 Standalone UI Library
|
|
143
213
|
|
|
144
|
-
|
|
145
|
-
use it as it is, without linking it to the library source code. More details in
|
|
146
|
-
its README
|
|
214
|
+
Rebase exposes its design system as a completely independent library. Fully typed, accessible, and customizable via Tailwind CSS v4:
|
|
147
215
|
|
|
148
|
-
|
|
216
|
+
```bash
|
|
217
|
+
npm install @rebasepro/ui
|
|
218
|
+
```
|
|
149
219
|
|
|
150
|
-
|
|
220
|
+
---
|
|
151
221
|
|
|
152
|
-
|
|
153
|
-
happy to help!
|
|
154
|
-
`hello@rebase.pro`
|
|
222
|
+
## Demo
|
|
155
223
|
|
|
156
|
-
|
|
224
|
+
Explore a live interactive sandbox with all features — data resets periodically:
|
|
157
225
|
|
|
158
|
-
|
|
226
|
+
**👉 [demo.rebase.pro](https://demo.rebase.pro)**
|
|
159
227
|
|
|
160
|
-
|
|
161
|
-
There is an example project in the folder `example`.
|
|
228
|
+
---
|
|
162
229
|
|
|
163
|
-
|
|
164
|
-
called `firebase_config.ts`
|
|
165
|
-
in `example/src`.
|
|
230
|
+
## Support & Community
|
|
166
231
|
|
|
167
|
-
|
|
168
|
-
|
|
232
|
+
- 📖 [Documentation](https://rebase.pro/docs)
|
|
233
|
+
- 💬 [Discord Community](https://discord.gg/fxy7xsQm3m)
|
|
234
|
+
- 🐛 [GitHub Issues](https://github.com/rebasepro/rebase/issues)
|
|
235
|
+
- 📝 [Changelog](./CHANGELOG.md)
|
|
169
236
|
|
|
170
|
-
|
|
237
|
+
---
|
|
171
238
|
|
|
172
239
|
## License
|
|
173
240
|
|
|
174
|
-
MIT
|
|
241
|
+
Rebase is open-source and licensed under the **MIT License**.
|
|
242
|
+
See the full [License](https://github.com/rebasepro/rebase/blob/main/LICENSE) for details.
|
|
@@ -1,4 +1,26 @@
|
|
|
1
1
|
import { ReactNode } from "react";
|
|
2
|
+
/** Google Identity Services SDK — injected by the GIS <script> tag. */
|
|
3
|
+
declare global {
|
|
4
|
+
interface Window {
|
|
5
|
+
google?: {
|
|
6
|
+
accounts: {
|
|
7
|
+
oauth2: {
|
|
8
|
+
initCodeClient(config: {
|
|
9
|
+
client_id: string;
|
|
10
|
+
scope: string;
|
|
11
|
+
ux_mode: "popup" | "redirect";
|
|
12
|
+
callback: (response: {
|
|
13
|
+
code?: string;
|
|
14
|
+
error?: string;
|
|
15
|
+
}) => void;
|
|
16
|
+
}): {
|
|
17
|
+
requestCode(): void;
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
};
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
}
|
|
2
24
|
import { AuthControllerExtended } from "@rebasepro/types";
|
|
3
25
|
/**
|
|
4
26
|
* Props for the generic LoginView.
|
|
@@ -20,7 +20,7 @@ export type DataTableControllerProps<M extends Record<string, any> = any> = {
|
|
|
20
20
|
/**
|
|
21
21
|
* Force filter to be applied to the table.
|
|
22
22
|
*/
|
|
23
|
-
|
|
23
|
+
fixedFilter?: FilterValues<string>;
|
|
24
24
|
scrollRestoration?: ScrollRestorationController;
|
|
25
25
|
/**
|
|
26
26
|
* When set to true the filters and sort will be updated in the URL
|
|
@@ -39,7 +39,7 @@ export type DataTableControllerProps<M extends Record<string, any> = any> = {
|
|
|
39
39
|
* @param scrollRestoration
|
|
40
40
|
* @param entitiesDisplayedFirst
|
|
41
41
|
* @param lastDeleteTimestamp
|
|
42
|
-
* @param
|
|
42
|
+
* @param fixedFilterFromProps
|
|
43
43
|
* @param updateUrl
|
|
44
44
|
*/
|
|
45
|
-
export declare function useDataTableController<M extends Record<string, any> = any, USER extends User = User>({ path, collection, scrollRestoration, entitiesDisplayedFirst, lastDeleteTimestamp: _lastDeleteTimestamp,
|
|
45
|
+
export declare function useDataTableController<M extends Record<string, any> = any, USER extends User = User>({ path, collection, scrollRestoration, entitiesDisplayedFirst, lastDeleteTimestamp: _lastDeleteTimestamp, fixedFilter: fixedFilterFromProps, updateUrl }: DataTableControllerProps<M>): EntityTableController<M>;
|
|
@@ -19,7 +19,7 @@ export interface UseRelationSelectorProps<M extends Record<string, any> = any> {
|
|
|
19
19
|
/**
|
|
20
20
|
* Force filter to be applied to the relation search
|
|
21
21
|
*/
|
|
22
|
-
|
|
22
|
+
fixedFilter?: FilterValues<string>;
|
|
23
23
|
/**
|
|
24
24
|
* Page size for pagination
|
|
25
25
|
*/
|
|
@@ -49,4 +49,4 @@ export interface RelationSelectorController {
|
|
|
49
49
|
/**
|
|
50
50
|
* Hook to manage relation selection with data fetching from Rebase data source
|
|
51
51
|
*/
|
|
52
|
-
export declare function useRelationSelector<M extends Record<string, any> = any>({ path, collection,
|
|
52
|
+
export declare function useRelationSelector<M extends Record<string, any> = any>({ path, collection, fixedFilter, pageSize, getLabelFromEntity, getDescriptionFromEntity, descriptionProperty }: UseRelationSelectorProps<M>): RelationSelectorController;
|
package/dist/hooks/index.d.ts
CHANGED
|
@@ -3,10 +3,25 @@
|
|
|
3
3
|
* with localStorage persistence. Automatically cleans up stale group entries
|
|
4
4
|
* when groups are removed from the navigation.
|
|
5
5
|
*
|
|
6
|
+
* Groups that have never been toggled by the user fall back to
|
|
7
|
+
* `defaults[groupName]` (driven by `collapsedByDefault` in config).
|
|
8
|
+
*
|
|
6
9
|
* @param groupNames - Array of group names to track
|
|
7
10
|
* @param namespace - Namespace for localStorage key (e.g., "home", "drawer") to allow independent state
|
|
11
|
+
* @param defaults - Optional map of group name → collapsed boolean from config
|
|
8
12
|
*/
|
|
9
|
-
export declare function useCollapsedGroups(groupNames: string[], namespace?: string): {
|
|
13
|
+
export declare function useCollapsedGroups(groupNames: string[], namespace?: string, defaults?: Record<string, boolean>): {
|
|
10
14
|
isGroupCollapsed: (name: string) => boolean;
|
|
11
15
|
toggleGroupCollapsed: (name: string) => void;
|
|
12
16
|
};
|
|
17
|
+
/**
|
|
18
|
+
* Build a defaults map from navigationGroupMappings for a given namespace.
|
|
19
|
+
* Returns a Record<groupName, collapsed> that can be passed to useCollapsedGroups.
|
|
20
|
+
*/
|
|
21
|
+
export declare function buildCollapsedDefaults(mappings: Array<{
|
|
22
|
+
name: string;
|
|
23
|
+
collapsedByDefault?: boolean | {
|
|
24
|
+
drawer?: boolean;
|
|
25
|
+
home?: boolean;
|
|
26
|
+
};
|
|
27
|
+
}> | undefined, namespace: "drawer" | "home"): Record<string, boolean>;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import type { ComponentRef } from "@rebasepro/types";
|
|
3
|
+
/**
|
|
4
|
+
* Resolves a `ComponentRef` into a renderable `React.ComponentType`.
|
|
5
|
+
*
|
|
6
|
+
* This hook handles all three forms of `ComponentRef`:
|
|
7
|
+
*
|
|
8
|
+
* 1. **`LazyComponentRef`** (produced by the Vite plugin from string paths):
|
|
9
|
+
* Wraps the lazy loader with `React.lazy()` for automatic code-splitting.
|
|
10
|
+
*
|
|
11
|
+
* 2. **`() => Promise<{ default: ComponentType }>`** (manual lazy import):
|
|
12
|
+
* Also wraps with `React.lazy()`. Distinguished from regular components
|
|
13
|
+
* by checking that the function has no parameters and is not a known
|
|
14
|
+
* React internal (no `$$typeof`).
|
|
15
|
+
*
|
|
16
|
+
* 3. **Direct `React.ComponentType`**:
|
|
17
|
+
* Returned as-is.
|
|
18
|
+
*
|
|
19
|
+
* If the ref is `undefined` or a raw string (which should never happen at
|
|
20
|
+
* runtime in the browser since the Vite plugin transforms strings), returns `undefined`.
|
|
21
|
+
*
|
|
22
|
+
* The returned component is stable across re-renders as long as the `ref`
|
|
23
|
+
* is referentially stable.
|
|
24
|
+
*
|
|
25
|
+
* **Usage:** Wrap the rendered component in `<Suspense>` to handle the
|
|
26
|
+
* loading state of lazy components.
|
|
27
|
+
*
|
|
28
|
+
* @example
|
|
29
|
+
* ```tsx
|
|
30
|
+
* const ResolvedField = useResolvedComponent(property.ui?.Field);
|
|
31
|
+
* if (!ResolvedField) return null;
|
|
32
|
+
* return (
|
|
33
|
+
* <Suspense fallback={<CircularProgress />}>
|
|
34
|
+
* <ResolvedField {...fieldProps} />
|
|
35
|
+
* </Suspense>
|
|
36
|
+
* );
|
|
37
|
+
* ```
|
|
38
|
+
*/
|
|
39
|
+
export declare function useResolvedComponent<P = unknown>(ref: ComponentRef<P> | undefined): React.ComponentType<P> | undefined;
|
|
40
|
+
/**
|
|
41
|
+
* Pure function version of the resolver, for use outside React components.
|
|
42
|
+
* Same resolution logic as `useResolvedComponent`.
|
|
43
|
+
*
|
|
44
|
+
* Results are cached per reference identity — calling this multiple times
|
|
45
|
+
* with the same `ref` object returns the same `React.ComponentType`.
|
|
46
|
+
*/
|
|
47
|
+
export declare function resolveComponentRef<P = unknown>(ref: ComponentRef<P> | undefined): React.ComponentType<P> | undefined;
|