@rebasepro/cms-types 0.17.0-canary.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/dist/admin_collection.d.ts +650 -0
- package/dist/augment.d.ts +81 -0
- package/dist/collections.d.ts +282 -0
- package/dist/controllers/analytics_controller.d.ts +7 -0
- package/dist/controllers/auth.d.ts +111 -0
- package/dist/controllers/customization_controller.d.ts +69 -0
- package/dist/controllers/dialogs_controller.d.ts +36 -0
- package/dist/controllers/index.d.ts +10 -0
- package/dist/controllers/local_config_persistence.d.ts +20 -0
- package/dist/controllers/navigation.d.ts +248 -0
- package/dist/controllers/registry.d.ts +96 -0
- package/dist/controllers/side_dialogs_controller.d.ts +67 -0
- package/dist/controllers/side_panel_controller.d.ts +97 -0
- package/dist/controllers/snackbar.d.ts +45 -0
- package/dist/index.d.ts +18 -0
- package/dist/index.es.js +154 -0
- package/dist/index.es.js.map +1 -0
- package/dist/react_component_ref.d.ts +43 -0
- package/dist/rebase_context.d.ts +68 -0
- package/dist/types/breadcrumbs.d.ts +15 -0
- package/dist/types/builders.d.ts +15 -0
- package/dist/types/collection_views.d.ts +105 -0
- package/dist/types/component_overrides.d.ts +196 -0
- package/dist/types/entity_actions.d.ts +112 -0
- package/dist/types/entity_display.d.ts +148 -0
- package/dist/types/entity_link_builder.d.ts +7 -0
- package/dist/types/entity_views.d.ts +115 -0
- package/dist/types/export_import.d.ts +21 -0
- package/dist/types/form_layout.d.ts +126 -0
- package/dist/types/formex.d.ts +40 -0
- package/dist/types/index.d.ts +18 -0
- package/dist/types/locales.d.ts +4 -0
- package/dist/types/modify_collections.d.ts +5 -0
- package/dist/types/plugins.d.ts +277 -0
- package/dist/types/property_config.d.ts +74 -0
- package/dist/types/property_options.d.ts +255 -0
- package/dist/types/slots.d.ts +279 -0
- package/dist/types/translations.d.ts +989 -0
- package/dist/types/user_management_delegate.d.ts +22 -0
- package/package.json +103 -0
- package/src/admin_collection.ts +775 -0
- package/src/augment.ts +79 -0
- package/src/collections.ts +312 -0
- package/src/controllers/analytics_controller.tsx +57 -0
- package/src/controllers/auth.ts +122 -0
- package/src/controllers/customization_controller.tsx +81 -0
- package/src/controllers/dialogs_controller.tsx +37 -0
- package/src/controllers/index.ts +10 -0
- package/src/controllers/local_config_persistence.tsx +22 -0
- package/src/controllers/navigation.ts +288 -0
- package/src/controllers/registry.ts +114 -0
- package/src/controllers/side_dialogs_controller.tsx +82 -0
- package/src/controllers/side_panel_controller.tsx +112 -0
- package/src/controllers/snackbar.ts +51 -0
- package/src/index.ts +20 -0
- package/src/react_component_ref.ts +52 -0
- package/src/rebase_context.ts +81 -0
- package/src/types/breadcrumbs.ts +16 -0
- package/src/types/builders.ts +18 -0
- package/src/types/collection_views.tsx +125 -0
- package/src/types/component_overrides.ts +244 -0
- package/src/types/entity_actions.tsx +134 -0
- package/src/types/entity_display.ts +182 -0
- package/src/types/entity_link_builder.ts +8 -0
- package/src/types/entity_views.tsx +135 -0
- package/src/types/export_import.ts +26 -0
- package/src/types/form_layout.ts +137 -0
- package/src/types/formex.ts +45 -0
- package/src/types/index.ts +18 -0
- package/src/types/locales.ts +81 -0
- package/src/types/modify_collections.tsx +6 -0
- package/src/types/plugins.tsx +346 -0
- package/src/types/property_config.tsx +97 -0
- package/src/types/property_options.ts +300 -0
- package/src/types/slots.tsx +334 -0
- package/src/types/translations.ts +1104 -0
- package/src/types/user_management_delegate.ts +23 -0
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export * from "./analytics_controller";
|
|
2
|
+
export * from "./auth";
|
|
3
|
+
export * from "./customization_controller";
|
|
4
|
+
export * from "./dialogs_controller";
|
|
5
|
+
export * from "./local_config_persistence";
|
|
6
|
+
export * from "./navigation";
|
|
7
|
+
export * from "./registry";
|
|
8
|
+
export * from "./side_dialogs_controller";
|
|
9
|
+
export * from "./side_panel_controller";
|
|
10
|
+
export * from "./snackbar";
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { AdminCollection } from "@rebasepro/cms-types";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @group Models
|
|
5
|
+
*/
|
|
6
|
+
export type PartialCollectionConfig<M extends Record<string, unknown> = Record<string, unknown>> = Partial<AdminCollection<M>>;
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* This interface is in charge of defining the controller that persists
|
|
10
|
+
* modifications to a collection or collection, and retrieves them back from
|
|
11
|
+
* a data source, such as local storage or Firestore.
|
|
12
|
+
*/
|
|
13
|
+
export interface UserConfigurationPersistence {
|
|
14
|
+
onCollectionModified: <M extends Record<string, unknown> = Record<string, unknown>>(path: string, partialCollection: PartialCollectionConfig<M>) => void;
|
|
15
|
+
getCollectionConfig: <M extends Record<string, unknown> = Record<string, unknown>>(path: string) => PartialCollectionConfig<M>;
|
|
16
|
+
recentlyVisitedPaths: string[];
|
|
17
|
+
setRecentlyVisitedPaths: (paths: string[]) => void;
|
|
18
|
+
favouritePaths: string[];
|
|
19
|
+
setFavouritePaths: (paths: string[]) => void;
|
|
20
|
+
collapsedGroups: string[];
|
|
21
|
+
setCollapsedGroups: (paths: string[]) => void;
|
|
22
|
+
}
|
|
@@ -0,0 +1,288 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import type { EntityReference } from "@rebasepro/types";
|
|
3
|
+
import type { AdminCollection } from "@rebasepro/cms-types";
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Controller that handles URL path building and resolution.
|
|
7
|
+
* @group Models
|
|
8
|
+
*/
|
|
9
|
+
export type UrlController = {
|
|
10
|
+
/**
|
|
11
|
+
* Default path under the navigation routes of the admin will be created.
|
|
12
|
+
* Defaults to '/'. You may want to change this `basepath` to 'admin' for example.
|
|
13
|
+
*/
|
|
14
|
+
basePath: string;
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Default path under the collection routes of the admin will be created.
|
|
18
|
+
* It defaults to '/c'
|
|
19
|
+
*/
|
|
20
|
+
baseCollectionPath: string;
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Convert a URL path to a collection or entity path
|
|
24
|
+
* `/c/products` => `products`
|
|
25
|
+
* `/my_cms/c/products/B34SAP8Z` => `products/B34SAP8Z`
|
|
26
|
+
* `/my_cms/my_view` => `my_view`
|
|
27
|
+
* @param cmsPath
|
|
28
|
+
*/
|
|
29
|
+
urlPathToDataPath: (cmsPath: string) => string;
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Base url path for the home screen
|
|
33
|
+
*/
|
|
34
|
+
homeUrl: string;
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Check if a url path belongs to a collection
|
|
38
|
+
* @param path
|
|
39
|
+
*/
|
|
40
|
+
isUrlCollectionPath: (urlPath: string) => boolean;
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Build a URL collection path from a data path
|
|
44
|
+
* `products` => `/c/products`
|
|
45
|
+
* `products/B34SAP8Z` => `/c/products/B34SAP8Z`
|
|
46
|
+
* @param path
|
|
47
|
+
*/
|
|
48
|
+
buildUrlCollectionPath: (path: string) => string;
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Build a URL path for the admin (e.g. for custom views)
|
|
52
|
+
* @param path
|
|
53
|
+
*/
|
|
54
|
+
buildAppUrlPath: (path: string) => string;
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Turn a path with collection ids into a resolved path.
|
|
58
|
+
* The ids (typically used in urls) will be replaced with relative paths (typically used in database paths)
|
|
59
|
+
* @param path
|
|
60
|
+
*/
|
|
61
|
+
resolveDatabasePathsFrom: (path: string) => string;
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* A function to navigate to a specified route or URL.
|
|
65
|
+
*
|
|
66
|
+
* @param {string} to - The target route or URL to navigate to.
|
|
67
|
+
* @param {NavigateOptions} [options] - Optional configuration settings for navigation, such as replace behavior or state data.
|
|
68
|
+
*/
|
|
69
|
+
navigate: (to: string, options?: NavigateOptions) => void;
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* Controller that manages the state of the navigation menu,
|
|
74
|
+
* including resolved views and top-level grouping.
|
|
75
|
+
* @group Models
|
|
76
|
+
*/
|
|
77
|
+
export type NavigationStateController = {
|
|
78
|
+
/**
|
|
79
|
+
* Custom additional views created by the developer, added to the main
|
|
80
|
+
* navigation
|
|
81
|
+
*/
|
|
82
|
+
views?: AppView[];
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* Custom additional views created by the developer, added to the admin
|
|
86
|
+
* navigation
|
|
87
|
+
*/
|
|
88
|
+
adminViews?: AppView[];
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* Configuration for the views that should be displayed at the top
|
|
92
|
+
* level of the navigation (e.g. in the home page or the navigation
|
|
93
|
+
* drawer)
|
|
94
|
+
*/
|
|
95
|
+
topLevelNavigation?: NavigationResult;
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* Is the navigation loading (the configuration persistence has not
|
|
99
|
+
* loaded yet, or a specified navigation builder has not completed)
|
|
100
|
+
*/
|
|
101
|
+
loading: boolean;
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* Was there an error while loading the navigation data
|
|
105
|
+
*/
|
|
106
|
+
navigationLoadingError?: Error;
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* Call this method to recalculate the navigation
|
|
110
|
+
*/
|
|
111
|
+
refreshNavigation: () => void;
|
|
112
|
+
};
|
|
113
|
+
|
|
114
|
+
export interface NavigateOptions {
|
|
115
|
+
replace?: boolean;
|
|
116
|
+
state?: unknown;
|
|
117
|
+
preventScrollReset?: boolean;
|
|
118
|
+
relative?: "route" | "path";
|
|
119
|
+
flushSync?: boolean;
|
|
120
|
+
viewTransition?: boolean;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
/**
|
|
124
|
+
* Custom additional views created by the developer, added to the main
|
|
125
|
+
* navigation.
|
|
126
|
+
* @group Models
|
|
127
|
+
*/
|
|
128
|
+
export interface AppView {
|
|
129
|
+
|
|
130
|
+
/**
|
|
131
|
+
* admin Path you can reach this view from.
|
|
132
|
+
*/
|
|
133
|
+
slug: string;
|
|
134
|
+
|
|
135
|
+
/**
|
|
136
|
+
* Name of this view
|
|
137
|
+
*/
|
|
138
|
+
name: string;
|
|
139
|
+
|
|
140
|
+
/**
|
|
141
|
+
* Optional description of this view. You can use Markdown
|
|
142
|
+
*/
|
|
143
|
+
description?: string;
|
|
144
|
+
|
|
145
|
+
/**
|
|
146
|
+
* Icon key to use in this view.
|
|
147
|
+
* You can use any of the icons in the Lucide specs:
|
|
148
|
+
* https://lucide.dev/icons/
|
|
149
|
+
* e.g. 'ShoppingCart' or 'User'
|
|
150
|
+
* Find all the icons in https://rebase.pro/docs/icons
|
|
151
|
+
*/
|
|
152
|
+
icon?: string | React.ReactNode;
|
|
153
|
+
|
|
154
|
+
/**
|
|
155
|
+
* Should this view be hidden from the main navigation panel.
|
|
156
|
+
* It will still be accessible if you reach the specified path
|
|
157
|
+
*/
|
|
158
|
+
hideFromNavigation?: boolean;
|
|
159
|
+
|
|
160
|
+
/**
|
|
161
|
+
* Navigation group for this view.
|
|
162
|
+
* Views sharing the same group name will be visually grouped
|
|
163
|
+
* together in the drawer and home page. If not set, the view
|
|
164
|
+
* falls into the default "Views" group.
|
|
165
|
+
*
|
|
166
|
+
* Two names are special: a group called `"Admin"` or `"Settings"` sinks to
|
|
167
|
+
* the bottom of the drawer, by string comparison on the name. That predates
|
|
168
|
+
* {@link pinToBottom} and still works, but rename the group — translate the
|
|
169
|
+
* label, say — and the ordering silently stops happening. Use
|
|
170
|
+
* `pinToBottom` for anything that is not literally one of those two words.
|
|
171
|
+
*/
|
|
172
|
+
group?: string;
|
|
173
|
+
|
|
174
|
+
/**
|
|
175
|
+
* Sink this view's group to the bottom of the drawer, below the ordinary
|
|
176
|
+
* groups.
|
|
177
|
+
*
|
|
178
|
+
* What `group: "Settings"` has always done, said out loud. Setting it on
|
|
179
|
+
* any one view in a group pins the whole group, since the drawer orders
|
|
180
|
+
* groups and not individual views.
|
|
181
|
+
*/
|
|
182
|
+
pinToBottom?: boolean;
|
|
183
|
+
|
|
184
|
+
/**
|
|
185
|
+
* Component to be rendered. This can be any React component, and can use
|
|
186
|
+
* any of the provided hooks.
|
|
187
|
+
*
|
|
188
|
+
* Pass a `ComponentType` to enable lazy rendering — the component will
|
|
189
|
+
* only be instantiated when the route is visited. This is recommended
|
|
190
|
+
* for dynamic views generated from database data.
|
|
191
|
+
*/
|
|
192
|
+
view: React.ReactNode | React.ComponentType;
|
|
193
|
+
|
|
194
|
+
/**
|
|
195
|
+
* If true, a wildcard route (slug/*) is automatically registered
|
|
196
|
+
* alongside the base route, enabling nested navigation within this view.
|
|
197
|
+
*/
|
|
198
|
+
nestedRoutes?: boolean;
|
|
199
|
+
|
|
200
|
+
/**
|
|
201
|
+
* Restrict this view to users with at least one of the listed roles.
|
|
202
|
+
* When omitted or empty, the view is visible to all authenticated users.
|
|
203
|
+
* Applied during view resolution — the view is filtered out entirely
|
|
204
|
+
* (not just hidden from nav) if the user lacks a matching role.
|
|
205
|
+
*/
|
|
206
|
+
roles?: string[];
|
|
207
|
+
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
/**
|
|
211
|
+
* A composable section that can be rendered on the home page.
|
|
212
|
+
* Use this to add custom content alongside the auto-generated
|
|
213
|
+
* navigation groups.
|
|
214
|
+
* @group Models
|
|
215
|
+
*/
|
|
216
|
+
export interface HomePageSection {
|
|
217
|
+
/**
|
|
218
|
+
* Unique key for this section.
|
|
219
|
+
*/
|
|
220
|
+
key: string;
|
|
221
|
+
|
|
222
|
+
/**
|
|
223
|
+
* Title displayed as the section header.
|
|
224
|
+
*/
|
|
225
|
+
title: string;
|
|
226
|
+
|
|
227
|
+
/**
|
|
228
|
+
* Arbitrary React content rendered inside the section.
|
|
229
|
+
*/
|
|
230
|
+
children: React.ReactNode;
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
/**
|
|
234
|
+
* Used to group navigation entries in the main navigation.
|
|
235
|
+
*/
|
|
236
|
+
export interface NavigationGroupMapping {
|
|
237
|
+
/**
|
|
238
|
+
* Name of the group, used to display the group header in the UI
|
|
239
|
+
*/
|
|
240
|
+
name: string;
|
|
241
|
+
/**
|
|
242
|
+
* List of collection ids or view paths that belong to this group.
|
|
243
|
+
*/
|
|
244
|
+
entries: string[];
|
|
245
|
+
/**
|
|
246
|
+
* Icon for the group header, as a Lucide icon name (`"Users"`, `"CreditCard"`).
|
|
247
|
+
*
|
|
248
|
+
* It labels the group header and nothing more — the entries below keep their own
|
|
249
|
+
* icons either way. Only shown while the drawer is expanded, since a drawer
|
|
250
|
+
* collapsed to a rail hides the headers entirely.
|
|
251
|
+
*/
|
|
252
|
+
icon?: string;
|
|
253
|
+
/**
|
|
254
|
+
* Configure which groups start collapsed.
|
|
255
|
+
* Set to `true` to collapse in both drawer and home page,
|
|
256
|
+
* or use an object to control each independently.
|
|
257
|
+
*
|
|
258
|
+
* @defaultValue false (expanded)
|
|
259
|
+
*/
|
|
260
|
+
collapsedByDefault?: boolean | {
|
|
261
|
+
drawer?: boolean;
|
|
262
|
+
home?: boolean;
|
|
263
|
+
};
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
export interface NavigationEntry {
|
|
267
|
+
id: string;
|
|
268
|
+
url: string;
|
|
269
|
+
name: string;
|
|
270
|
+
slug: string;
|
|
271
|
+
type: "collection" | "view" | "admin";
|
|
272
|
+
collection?: AdminCollection;
|
|
273
|
+
view?: AppView;
|
|
274
|
+
description?: string;
|
|
275
|
+
group: string;
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
export type NavigationResult = {
|
|
279
|
+
|
|
280
|
+
allowDragAndDrop: boolean;
|
|
281
|
+
|
|
282
|
+
navigationEntries: NavigationEntry[],
|
|
283
|
+
|
|
284
|
+
groups: string[],
|
|
285
|
+
|
|
286
|
+
onNavigationEntriesUpdate: (entries: NavigationGroupMapping[]) => void;
|
|
287
|
+
};
|
|
288
|
+
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import { ReactNode } from "react";
|
|
2
|
+
|
|
3
|
+
import type { CollectionConfigsBuilder, AppViewsBuilder } from "../types/builders";
|
|
4
|
+
import type { EntityCustomView } from "../types/entity_views";
|
|
5
|
+
import type { CollectionCustomView } from "../types/collection_views";
|
|
6
|
+
import type { EntityAction } from "../types/entity_actions";
|
|
7
|
+
import type { AppView, NavigationGroupMapping } from "./navigation";
|
|
8
|
+
import type { AdminCollection } from "@rebasepro/cms-types";
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Options to enable the built-in collection editor.
|
|
12
|
+
* When provided to `<RebaseCMS>`, the editor is auto-wired as a native feature.
|
|
13
|
+
*/
|
|
14
|
+
export interface CollectionEditorOptions {
|
|
15
|
+
/**
|
|
16
|
+
* Function that returns an auth token for schema-editor API calls.
|
|
17
|
+
* Falls back to `authController.getAuthToken` when omitted.
|
|
18
|
+
*/
|
|
19
|
+
getAuthToken?: () => Promise<string | null>;
|
|
20
|
+
/** Mark the editor as read-only (disable mutations). */
|
|
21
|
+
readOnly?: boolean;
|
|
22
|
+
/** Suggested base paths shown when creating new collections. */
|
|
23
|
+
pathSuggestions?: string[];
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export interface RebaseCMSConfig<EC extends AdminCollection = AdminCollection> {
|
|
27
|
+
collections?: EC[] | CollectionConfigsBuilder<EC>;
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Custom top-level views added to the main navigation.
|
|
31
|
+
* Accepts a static array of views or an async builder function
|
|
32
|
+
* that receives the current user/auth context for role-based views.
|
|
33
|
+
*/
|
|
34
|
+
views?: AppView[] | AppViewsBuilder;
|
|
35
|
+
|
|
36
|
+
homePage?: ReactNode;
|
|
37
|
+
entityViews?: EntityCustomView[];
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Custom collection view modes available to every collection by `key`.
|
|
41
|
+
* A collection opts into one by naming that key in `admin.customViews`,
|
|
42
|
+
* the same way `entityViews` works.
|
|
43
|
+
*/
|
|
44
|
+
collectionViews?: CollectionCustomView[];
|
|
45
|
+
|
|
46
|
+
entityActions?: EntityAction[];
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Centralized configuration for how collections and views are grouped
|
|
50
|
+
* in the navigation sidebar and home page.
|
|
51
|
+
* Each mapping defines a named group and the collection/view slugs
|
|
52
|
+
* that belong to it. The array order determines group display order.
|
|
53
|
+
* Entry order within each group determines card order.
|
|
54
|
+
*/
|
|
55
|
+
navigationGroupMappings?: NavigationGroupMapping[];
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Enable the built-in visual collection/schema editor.
|
|
59
|
+
* Pass `true` for zero-config, or an options object for fine-grained control.
|
|
60
|
+
* When enabled, the editor slots, provider, and Studio schema view
|
|
61
|
+
* are all auto-wired — no plugin or manual view injection needed.
|
|
62
|
+
*/
|
|
63
|
+
collectionEditor?: boolean | CollectionEditorOptions;
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* URL path prefix the admin is mounted under, when it does not live at the
|
|
67
|
+
* site root. Set this when the admin is rendered inside a path-prefixed
|
|
68
|
+
* route (e.g. `<Route path="/admin/*">`) so URL⇄collection resolution
|
|
69
|
+
* accounts for the prefix — otherwise the current path won't be recognized
|
|
70
|
+
* as a collection path and views hang on a spinner with no data fetch.
|
|
71
|
+
*
|
|
72
|
+
* Do NOT set this when mounting via a react-router `basename` — react-router
|
|
73
|
+
* already strips the prefix from the location, so the default (`/`) is correct.
|
|
74
|
+
*
|
|
75
|
+
* @default "/"
|
|
76
|
+
*/
|
|
77
|
+
basePath?: string;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
export interface RebaseStudioConfig {
|
|
81
|
+
tools?: ("sql" | "js" | "rls" | "schema" | "storage" | "cron" | "schema-visualizer" | "branches" | "backups" | "api" | "logs" | "api-keys")[];
|
|
82
|
+
homePage?: ReactNode;
|
|
83
|
+
devViews?: AppView[];
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* Props of the `<RebaseAuth>` front-end route — what the sign-in screen renders.
|
|
88
|
+
*
|
|
89
|
+
* Named `RebaseAuthConfig` until it collided head-on with `RebaseAuthConfig` in
|
|
90
|
+
* `@rebasepro/server`, which is the *backend* auth configuration: JWT secrets,
|
|
91
|
+
* OAuth providers, password hooks, the users collection. Two unrelated shapes
|
|
92
|
+
* under one name, one of them exported from a package whose whole job is to be
|
|
93
|
+
* imported alongside the other.
|
|
94
|
+
*/
|
|
95
|
+
export interface RebaseAuthViewConfig {
|
|
96
|
+
loginView?: ReactNode;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
export interface RebaseRegistryController {
|
|
100
|
+
// Current state
|
|
101
|
+
cmsConfig: RebaseCMSConfig | null;
|
|
102
|
+
studioConfig: RebaseStudioConfig | null;
|
|
103
|
+
authConfig: RebaseAuthViewConfig | null;
|
|
104
|
+
|
|
105
|
+
// Registration functions
|
|
106
|
+
registerAdmin: (config: RebaseCMSConfig) => void;
|
|
107
|
+
unregisterAdmin: () => void;
|
|
108
|
+
|
|
109
|
+
registerStudio: (config: RebaseStudioConfig) => void;
|
|
110
|
+
unregisterStudio: () => void;
|
|
111
|
+
|
|
112
|
+
registerAuth: (config: RebaseAuthViewConfig) => void;
|
|
113
|
+
unregisterAuth: () => void;
|
|
114
|
+
}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Controller to open the side dialog
|
|
5
|
+
* @group Hooks and utilities
|
|
6
|
+
*/
|
|
7
|
+
export interface SideDialogsController {
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Close the last panel
|
|
11
|
+
*/
|
|
12
|
+
close: () => void;
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* List of side panels currently open
|
|
16
|
+
*/
|
|
17
|
+
sidePanels: SideDialogPanelProps[];
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Override the current side panels
|
|
21
|
+
* @param panels
|
|
22
|
+
*/
|
|
23
|
+
setSidePanels: (panels: SideDialogPanelProps[]) => void;
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Open one or multiple side panels
|
|
27
|
+
* @param props
|
|
28
|
+
*/
|
|
29
|
+
open: (panelProps: SideDialogPanelProps | SideDialogPanelProps[]) => void;
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Replace the last open panel with the given one
|
|
33
|
+
* @param props
|
|
34
|
+
*/
|
|
35
|
+
replace: (panelProps: SideDialogPanelProps | SideDialogPanelProps[]) => void;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Props used to open a side dialog
|
|
40
|
+
* @group Hooks and utilities
|
|
41
|
+
*/
|
|
42
|
+
export interface SideDialogPanelProps {
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* A key that identifies this panel
|
|
46
|
+
*/
|
|
47
|
+
key: string;
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* The component type that will be rendered
|
|
51
|
+
*/
|
|
52
|
+
component: React.ReactNode;
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Optional width of the panel
|
|
56
|
+
*/
|
|
57
|
+
width?: string;
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* When open, change the URL to this path.
|
|
61
|
+
* Note that if you want to restore state from a URL you need to add the
|
|
62
|
+
* logic yourself by listening to URL updates, and probably call `open`.
|
|
63
|
+
*/
|
|
64
|
+
urlPath?: string;
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* If the navigation stack is empty (you landed in the `urlPath` url), what
|
|
68
|
+
* url path to change to when the panel gets closed.
|
|
69
|
+
*/
|
|
70
|
+
parentUrlPath?: string;
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* Callback when the panel is closed
|
|
74
|
+
*/
|
|
75
|
+
onClose?: () => void;
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Use this prop to store additional data in the panel
|
|
79
|
+
*/
|
|
80
|
+
additional?: unknown;
|
|
81
|
+
|
|
82
|
+
}
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import type { Entity } from "@rebasepro/types";
|
|
2
|
+
import type { AdminCollection } from "@rebasepro/cms-types";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Props used to open a side dialog
|
|
6
|
+
* @group Hooks and utilities
|
|
7
|
+
*/
|
|
8
|
+
export interface SidePanelBindingProps<M extends Record<string, unknown> = Record<string, unknown>> {
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Absolute path of the entity
|
|
12
|
+
*/
|
|
13
|
+
path: string;
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* ID of the entity, if not set, it means we are creating a new entity
|
|
17
|
+
*/
|
|
18
|
+
entityId?: string | number;
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Set this flag to true if you want to make a copy of an existing entity
|
|
22
|
+
*/
|
|
23
|
+
copy?: boolean;
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Open the entity with a selected sub-collection view. If the panel for this
|
|
27
|
+
* entity was already open, it is replaced.
|
|
28
|
+
*/
|
|
29
|
+
selectedTab?: string;
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Use this prop to override the width of the form view.
|
|
33
|
+
* e.g. "600px"
|
|
34
|
+
*/
|
|
35
|
+
width?: number | string;
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Collection representing the entities of this view.
|
|
39
|
+
* If you leave it blank it will be induced by your navigation
|
|
40
|
+
*/
|
|
41
|
+
collection?: AdminCollection<M>;
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Should update the URL when opening the dialog.
|
|
45
|
+
* Consider that if the collection that you provide is not defined in the base
|
|
46
|
+
* config of your `Rebase` component, you will not be able to recreate
|
|
47
|
+
* the state if copying the URL to a different window.
|
|
48
|
+
*/
|
|
49
|
+
updateUrl?: boolean;
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Callback when the entity is updated
|
|
53
|
+
* @param params
|
|
54
|
+
*/
|
|
55
|
+
onUpdate?: (params: { entity: Entity<M> }) => void;
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Callback when the dialog is closed
|
|
59
|
+
*/
|
|
60
|
+
onClose?: () => void;
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Should this panel close when saving
|
|
64
|
+
*/
|
|
65
|
+
closeOnSave?: boolean;
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Override some form properties
|
|
69
|
+
*/
|
|
70
|
+
formProps?: Record<string, unknown>;
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* Allow the user to open the entity fullscreen
|
|
74
|
+
*/
|
|
75
|
+
allowFullScreen?: boolean;
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Pre-populate the form with these values when creating a new entity.
|
|
79
|
+
* Only applied when `entityId` is not set (i.e. the form is in "new" mode).
|
|
80
|
+
* Useful for actions that fetch data from an external source (e.g. a URL)
|
|
81
|
+
* and want to pre-fill the document before the user saves.
|
|
82
|
+
*/
|
|
83
|
+
defaultValues?: Partial<M>;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* Controller to open the side dialog displaying entity forms
|
|
88
|
+
* @group Hooks and utilities
|
|
89
|
+
*/
|
|
90
|
+
export interface SidePanelController {
|
|
91
|
+
/**
|
|
92
|
+
* Close the last panel
|
|
93
|
+
*/
|
|
94
|
+
close: () => void;
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* Open a new entity sideDialog. By default, the collection and configuration
|
|
98
|
+
* of the view is fetched from the collections you have specified in the
|
|
99
|
+
* navigation.
|
|
100
|
+
* At least you need to pass the path of the entity you would like
|
|
101
|
+
* to edit. You can set a entityId if you would like to edit and existing one
|
|
102
|
+
* (or a new one with that id).
|
|
103
|
+
* @param props
|
|
104
|
+
*/
|
|
105
|
+
open: <M extends Record<string, unknown> = Record<string, unknown>>(props: SidePanelBindingProps<M>) => void;
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* Replace the last open entity panel with the given one.
|
|
109
|
+
* @param props
|
|
110
|
+
*/
|
|
111
|
+
replace: <M extends Record<string, unknown> = Record<string, unknown>>(props: SidePanelBindingProps<M>) => void;
|
|
112
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
|
|
2
|
+
/**
|
|
3
|
+
* Possible snackbar types
|
|
4
|
+
* @group Hooks and utilities
|
|
5
|
+
*/
|
|
6
|
+
export type SnackbarMessageType = "success" | "info" | "warning" | "error";
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* A single button rendered inside a snackbar.
|
|
10
|
+
*
|
|
11
|
+
* The reason snackbars have one: undo-after-mutation is the core interaction of
|
|
12
|
+
* any queue or triage screen, and the window in which "undo" means anything is
|
|
13
|
+
* exactly the window the snackbar is on screen. Without a slot here every such
|
|
14
|
+
* view has to build its own strip somewhere else on the page, at which point the
|
|
15
|
+
* confirmation and the way to reverse it are two different pieces of UI.
|
|
16
|
+
*
|
|
17
|
+
* The snackbar dismisses itself after `onClick`, since the action it was
|
|
18
|
+
* offering has been taken.
|
|
19
|
+
*
|
|
20
|
+
* @group Hooks and utilities
|
|
21
|
+
*/
|
|
22
|
+
export interface SnackbarAction {
|
|
23
|
+
label: string;
|
|
24
|
+
onClick: () => void;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Controller to display snackbars
|
|
29
|
+
* @group Hooks and utilities
|
|
30
|
+
*/
|
|
31
|
+
export interface SnackbarController {
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Close the currently open snackbar
|
|
35
|
+
*/
|
|
36
|
+
close: () => void;
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Display a new snackbar. You need to specify the type and message.
|
|
40
|
+
* You can optionally specify a title
|
|
41
|
+
*/
|
|
42
|
+
open: (props: {
|
|
43
|
+
type: SnackbarMessageType;
|
|
44
|
+
title?: string;
|
|
45
|
+
message: React.ReactNode;
|
|
46
|
+
autoHideDuration?: number;
|
|
47
|
+
/** A button rendered alongside the message — typically "Undo". */
|
|
48
|
+
action?: SnackbarAction;
|
|
49
|
+
}) => void;
|
|
50
|
+
|
|
51
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @rebasepro/cms-types — the React-flavoured half of the Rebase type surface.
|
|
3
|
+
*
|
|
4
|
+
* Everything here describes the admin panel: what a collection looks like on
|
|
5
|
+
* screen, the controllers the panel runs on, the props a custom field or view
|
|
6
|
+
* receives. It depends on @rebasepro/types and nothing in @rebasepro/types
|
|
7
|
+
* depends on it, which is what lets a BaaS install exist without React.
|
|
8
|
+
*
|
|
9
|
+
* If you are building a backend, you want @rebasepro/types.
|
|
10
|
+
*/
|
|
11
|
+
// Side-effect import: this is what adds `admin` back onto the core types.
|
|
12
|
+
import "./augment";
|
|
13
|
+
|
|
14
|
+
export * from "./types/property_options";
|
|
15
|
+
export * from "./react_component_ref";
|
|
16
|
+
export * from "./collections";
|
|
17
|
+
export * from "./admin_collection";
|
|
18
|
+
export * from "./rebase_context";
|
|
19
|
+
export * from "./types";
|
|
20
|
+
export * from "./controllers";
|