@rebasepro/admin-types 0.10.1-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 +464 -0
- package/dist/augment.d.ts +66 -0
- package/dist/collections.d.ts +226 -0
- package/dist/controllers/analytics_controller.d.ts +7 -0
- package/dist/controllers/auth.d.ts +110 -0
- package/dist/controllers/customization_controller.d.ts +61 -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 +225 -0
- package/dist/controllers/registry.d.ts +80 -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 +24 -0
- package/dist/index.d.ts +18 -0
- package/dist/index.es.js +92 -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 +26 -0
- package/dist/types/builders.d.ts +15 -0
- package/dist/types/component_overrides.d.ts +196 -0
- package/dist/types/entity_actions.d.ts +105 -0
- package/dist/types/entity_link_builder.d.ts +7 -0
- package/dist/types/entity_views.d.ts +95 -0
- package/dist/types/export_import.d.ts +21 -0
- package/dist/types/formex.d.ts +40 -0
- package/dist/types/index.d.ts +15 -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 +154 -0
- package/dist/types/slots.d.ts +263 -0
- package/dist/types/translations.d.ts +915 -0
- package/dist/types/user_management_delegate.d.ts +22 -0
- package/package.json +103 -0
- package/src/admin_collection.ts +582 -0
- package/src/augment.ts +60 -0
- package/src/collections.ts +256 -0
- package/src/controllers/analytics_controller.tsx +57 -0
- package/src/controllers/auth.ts +121 -0
- package/src/controllers/customization_controller.tsx +72 -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 +264 -0
- package/src/controllers/registry.ts +96 -0
- package/src/controllers/side_dialogs_controller.tsx +82 -0
- package/src/controllers/side_panel_controller.tsx +112 -0
- package/src/controllers/snackbar.ts +29 -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 +27 -0
- package/src/types/builders.ts +18 -0
- package/src/types/component_overrides.ts +244 -0
- package/src/types/entity_actions.tsx +127 -0
- package/src/types/entity_link_builder.ts +8 -0
- package/src/types/entity_views.tsx +114 -0
- package/src/types/export_import.ts +26 -0
- package/src/types/formex.ts +45 -0
- package/src/types/index.ts +15 -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 +95 -0
- package/src/types/property_options.ts +169 -0
- package/src/types/slots.tsx +309 -0
- package/src/types/translations.ts +1026 -0
- package/src/types/user_management_delegate.ts +23 -0
|
@@ -0,0 +1,226 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Admin-panel view models for a collection.
|
|
3
|
+
*
|
|
4
|
+
* These twelve types came out of `collections.ts`, where they sat interleaved
|
|
5
|
+
* with the collection shape itself. None of them describes data: they are the
|
|
6
|
+
* table's controllers, the selection state, the kanban layout, the shape of a
|
|
7
|
+
* toolbar action's props. Every one names `React` or `RebaseContext`, and none is
|
|
8
|
+
* imported by a single backend package — checked across `server`,
|
|
9
|
+
* `server-postgres`, `server-mongo`, `client`, `common`, `utils`, `cli` and
|
|
10
|
+
* `codegen`.
|
|
11
|
+
*
|
|
12
|
+
* That is what made them safe to lift: they were never part of the BaaS surface,
|
|
13
|
+
* only stored next to it.
|
|
14
|
+
*/
|
|
15
|
+
import React from "react";
|
|
16
|
+
import type { Entity, EntityStatus, FilterValues, User } from "@rebasepro/types";
|
|
17
|
+
import type { RebaseContext } from "./rebase_context";
|
|
18
|
+
import type { AdminCollection } from "@rebasepro/admin-types";
|
|
19
|
+
/**
|
|
20
|
+
* Configuration for Kanban board view mode.
|
|
21
|
+
* @group Collections
|
|
22
|
+
*/
|
|
23
|
+
export interface KanbanConfig<M extends Record<string, unknown> = Record<string, unknown>> {
|
|
24
|
+
/**
|
|
25
|
+
* Property key to use for Kanban board columns.
|
|
26
|
+
* Must reference a string property with `enum` values defined.
|
|
27
|
+
* Entities will be grouped into columns based on this property's value.
|
|
28
|
+
* The column order is determined by the order of `enum` values in the property.
|
|
29
|
+
*/
|
|
30
|
+
columnProperty: Extract<keyof M, string> | (string & {});
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* View mode for displaying a collection.
|
|
34
|
+
* - "list": Simple, clean list view — the classic CMS default
|
|
35
|
+
* - "table": Table with inline editing
|
|
36
|
+
* - "cards": Grid of visual cards with thumbnails
|
|
37
|
+
* - "kanban": Board view grouped by a property
|
|
38
|
+
* @group Collections
|
|
39
|
+
*/
|
|
40
|
+
export type ViewMode = "list" | "table" | "cards" | "kanban";
|
|
41
|
+
/**
|
|
42
|
+
* Parameter passed to the `Actions` prop in the collection configuration.
|
|
43
|
+
* The component will receive this prop when it is rendered in the collection
|
|
44
|
+
* toolbar.
|
|
45
|
+
*
|
|
46
|
+
* @group Models
|
|
47
|
+
*/
|
|
48
|
+
export interface CollectionActionsProps<M extends Record<string, unknown> = Record<string, unknown>, USER extends User = User, EC extends AdminCollection<M> = AdminCollection<M>> {
|
|
49
|
+
/**
|
|
50
|
+
* Full collection path of this entity. This is the full path, like
|
|
51
|
+
* `users/1234/addresses`
|
|
52
|
+
*/
|
|
53
|
+
path: string;
|
|
54
|
+
/**
|
|
55
|
+
* Path of the last collection, like `addresses`
|
|
56
|
+
*/
|
|
57
|
+
relativePath: string;
|
|
58
|
+
/**
|
|
59
|
+
* Array of the parent path segments like `['users']`
|
|
60
|
+
*/
|
|
61
|
+
parentCollectionSlugs: string[];
|
|
62
|
+
parentEntityIds: string[];
|
|
63
|
+
/**
|
|
64
|
+
* The collection configuration
|
|
65
|
+
*/
|
|
66
|
+
collection: EC;
|
|
67
|
+
/**
|
|
68
|
+
* Use this controller to get the selected entities and to update the
|
|
69
|
+
* selected entities state.
|
|
70
|
+
*/
|
|
71
|
+
selectionController: SelectionController<M>;
|
|
72
|
+
/**
|
|
73
|
+
* Use this controller to get the table controller and to update the
|
|
74
|
+
* table controller state.
|
|
75
|
+
*/
|
|
76
|
+
tableController: EntityTableController<M>;
|
|
77
|
+
/**
|
|
78
|
+
* Context of the app status
|
|
79
|
+
*/
|
|
80
|
+
context: RebaseContext<USER>;
|
|
81
|
+
/**
|
|
82
|
+
* Count of the entities in this collection.
|
|
83
|
+
* undefined means the count is still loading.
|
|
84
|
+
*/
|
|
85
|
+
collectionEntitiesCount?: number;
|
|
86
|
+
/**
|
|
87
|
+
* Programmatically open the new-document form for this collection,
|
|
88
|
+
* optionally pre-populating it with initial field values.
|
|
89
|
+
* The form opens in the same mode configured for the collection
|
|
90
|
+
* (side panel, full screen, or split).
|
|
91
|
+
*
|
|
92
|
+
* This is the primary hook for workflows that need to create a document
|
|
93
|
+
* from external data — e.g. fetching content from a URL, importing from
|
|
94
|
+
* a third-party API, or duplicating from another system.
|
|
95
|
+
*
|
|
96
|
+
* @example
|
|
97
|
+
* // Inside a custom CollectionAction component:
|
|
98
|
+
* openNewDocument({ title: "Fetched title", body: "..." });
|
|
99
|
+
*/
|
|
100
|
+
openNewDocument: (defaultValues?: Record<string, unknown>) => void;
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Use this controller to retrieve the selected entities or modify them in
|
|
104
|
+
* an {@link AdminCollection}
|
|
105
|
+
* @group Models
|
|
106
|
+
*/
|
|
107
|
+
export interface SelectionController<M extends Record<string, unknown> = Record<string, unknown>> {
|
|
108
|
+
selectedEntities: Entity<M>[];
|
|
109
|
+
setSelectedEntities(entities: Entity<M>[]): void;
|
|
110
|
+
setSelectedEntities(action: (prev: Entity<M>[]) => Entity<M>[]): void;
|
|
111
|
+
isEntitySelected(entity: Entity<M>): boolean;
|
|
112
|
+
toggleEntitySelection(entity: Entity<M>, newSelectedState?: boolean): void;
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Used to indicate valid filter combinations (e.g. created in Firestore)
|
|
116
|
+
* If the user selects a specific filter/sort combination, the CMS checks if it's
|
|
117
|
+
* valid, otherwise it reverts to the simpler valid case
|
|
118
|
+
* @group Models
|
|
119
|
+
*/
|
|
120
|
+
export type FilterCombination<Key extends string> = Partial<Record<Key, "asc" | "desc">>;
|
|
121
|
+
/**
|
|
122
|
+
* Sizes in which a collection can be rendered
|
|
123
|
+
* @group Models
|
|
124
|
+
*/
|
|
125
|
+
export type CollectionSize = "xs" | "s" | "m" | "l" | "xl";
|
|
126
|
+
export type AdditionalFieldDelegateProps<M extends Record<string, unknown> = Record<string, unknown>, USER extends User = User> = {
|
|
127
|
+
entity: Entity<M>;
|
|
128
|
+
context: RebaseContext<USER>;
|
|
129
|
+
};
|
|
130
|
+
/**
|
|
131
|
+
* Use this interface for adding additional fields to entity collection views and forms.
|
|
132
|
+
* @group Models
|
|
133
|
+
*/
|
|
134
|
+
export interface AdditionalFieldDelegate<M extends Record<string, unknown> = Record<string, unknown>, USER extends User = User> {
|
|
135
|
+
/**
|
|
136
|
+
* ID of this column. You can use this id in the `properties` field of the
|
|
137
|
+
* collection in any order you want
|
|
138
|
+
*/
|
|
139
|
+
key: string;
|
|
140
|
+
/**
|
|
141
|
+
* Header of this column
|
|
142
|
+
*/
|
|
143
|
+
name: string;
|
|
144
|
+
/**
|
|
145
|
+
* Width of the generated column in pixels
|
|
146
|
+
*/
|
|
147
|
+
width?: number;
|
|
148
|
+
/**
|
|
149
|
+
* Builder for the custom field
|
|
150
|
+
*/
|
|
151
|
+
Builder?(props: {
|
|
152
|
+
entity: Entity<M>;
|
|
153
|
+
context: RebaseContext<USER>;
|
|
154
|
+
}): React.ReactNode;
|
|
155
|
+
/**
|
|
156
|
+
* If this column needs to update dynamically based on other properties,
|
|
157
|
+
* you can define an array of keys as strings with the
|
|
158
|
+
* `dependencies` prop.
|
|
159
|
+
* e.g. ["name", "surname"]
|
|
160
|
+
* This is a performance optimization, if you don't define dependencies
|
|
161
|
+
* it will be updated in every render.
|
|
162
|
+
*/
|
|
163
|
+
dependencies?: NoInfer<Extract<keyof M, string>> | NoInfer<Extract<keyof M, string>>[] | (string & {}) | (string & {})[];
|
|
164
|
+
/**
|
|
165
|
+
* Use this prop to define the value of the column as a string or number.
|
|
166
|
+
* This is the value that will be used for exporting the collection.
|
|
167
|
+
* If `Builder` is defined, this prop will be ignored in the collection
|
|
168
|
+
* view.
|
|
169
|
+
* @param entity
|
|
170
|
+
*/
|
|
171
|
+
value?(props: {
|
|
172
|
+
entity: Entity<M>;
|
|
173
|
+
context: RebaseContext;
|
|
174
|
+
}): string | number | Promise<string | number> | undefined;
|
|
175
|
+
}
|
|
176
|
+
/**
|
|
177
|
+
* Used in the {@link AdminCollection#defaultSelectedView} to define the default
|
|
178
|
+
* @group Models
|
|
179
|
+
*/
|
|
180
|
+
export type DefaultSelectedViewBuilder = (params: DefaultSelectedViewParams) => string | undefined;
|
|
181
|
+
/**
|
|
182
|
+
* Used in the {@link AdminCollection#defaultSelectedView} to define the default
|
|
183
|
+
* @group Models
|
|
184
|
+
*/
|
|
185
|
+
export type DefaultSelectedViewParams = {
|
|
186
|
+
status?: EntityStatus;
|
|
187
|
+
entityId?: string | number;
|
|
188
|
+
};
|
|
189
|
+
/**
|
|
190
|
+
* You can use this controller to control the table view of a collection.
|
|
191
|
+
*/
|
|
192
|
+
export type EntityTableController<M extends Record<string, unknown> = Record<string, unknown>> = {
|
|
193
|
+
data: Entity<M>[];
|
|
194
|
+
dataLoading: boolean;
|
|
195
|
+
noMoreToLoad: boolean;
|
|
196
|
+
dataLoadingError?: Error;
|
|
197
|
+
filterValues?: FilterValues<Extract<keyof M, string> | (string & {})>;
|
|
198
|
+
setFilterValues?: (filterValues: FilterValues<Extract<keyof M, string> | (string & {})>) => void;
|
|
199
|
+
sortBy?: [Extract<keyof M, string> | (string & {}), "asc" | "desc"];
|
|
200
|
+
setSortBy?: (sortBy?: [Extract<keyof M, string> | (string & {}), "asc" | "desc"]) => void;
|
|
201
|
+
searchString?: string;
|
|
202
|
+
setSearchString?: (searchString?: string) => void;
|
|
203
|
+
clearFilter?: () => void;
|
|
204
|
+
itemCount?: number;
|
|
205
|
+
setItemCount?: (itemCount: number) => void;
|
|
206
|
+
initialScroll?: number;
|
|
207
|
+
onScroll?: (props: {
|
|
208
|
+
scrollDirection: "forward" | "backward";
|
|
209
|
+
scrollOffset: number;
|
|
210
|
+
scrollUpdateWasRequested: boolean;
|
|
211
|
+
}) => void;
|
|
212
|
+
paginationEnabled?: boolean;
|
|
213
|
+
pageSize?: number;
|
|
214
|
+
checkFilterCombination?: (filterValues: FilterValues<string>, sortBy?: [string, "asc" | "desc"]) => boolean;
|
|
215
|
+
popupCell?: SelectedCellProps<M>;
|
|
216
|
+
setPopupCell?: (popupCell?: SelectedCellProps<M>) => void;
|
|
217
|
+
onAddColumn?: (column: string) => void;
|
|
218
|
+
};
|
|
219
|
+
export type SelectedCellProps<M extends Record<string, unknown> = Record<string, unknown>> = {
|
|
220
|
+
propertyKey: Extract<keyof M, string> | (string & {});
|
|
221
|
+
cellRect: DOMRect;
|
|
222
|
+
width: number;
|
|
223
|
+
height: number;
|
|
224
|
+
entityPath: string;
|
|
225
|
+
entityId: string | number;
|
|
226
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export type AnalyticsController = {
|
|
2
|
+
/**
|
|
3
|
+
* Callback used to get analytics events from the CMS
|
|
4
|
+
*/
|
|
5
|
+
onAnalyticsEvent?: (event: AnalyticsEvent, data?: object) => void;
|
|
6
|
+
};
|
|
7
|
+
export type AnalyticsEvent = "entity_click" | "entity_click_from_reference" | "reference_selection_clear" | "reference_selection_toggle" | "reference_selected_single" | "reference_selection_new_entity" | "edit_entity_clicked" | "entity_edited" | "new_entity_click" | "new_entity_saved" | "copy_entity_click" | "entity_copied" | "single_delete_dialog_open" | "multiple_delete_dialog_open" | "single_entity_deleted" | "multiple_entities_deleted" | "drawer_navigate_to_home" | "drawer_navigate_to_collection" | "drawer_navigate_to_view" | "home_navigate_to_collection" | "home_favorite_navigate_to_collection" | "home_navigate_to_view" | "home_navigate_to_admin_view" | "home_favorite_navigate_to_view" | "home_move_card" | "home_move_group" | "home_drop_new_group" | "collection_inline_editing" | "view_mode_changed" | "kanban_card_moved" | "kanban_column_reorder" | "kanban_property_changed" | "kanban_new_entity_in_column" | "kanban_backfill_order" | "card_view_entity_click" | "unmapped_event";
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import type { User } from "@rebasepro/types";
|
|
2
|
+
/**
|
|
3
|
+
* Capabilities advertised by an auth provider.
|
|
4
|
+
* UI components use this to show/hide features dynamically
|
|
5
|
+
* (e.g. password reset, registration, session management).
|
|
6
|
+
* @group Hooks and utilities
|
|
7
|
+
*/
|
|
8
|
+
export interface AuthCapabilities {
|
|
9
|
+
emailPasswordLogin?: boolean;
|
|
10
|
+
googleLogin?: boolean;
|
|
11
|
+
registration?: boolean;
|
|
12
|
+
/** Self-service password reset (emailing a reset link) is available. */
|
|
13
|
+
passwordReset?: boolean;
|
|
14
|
+
/**
|
|
15
|
+
* An admin can reset another user's password. Gates the "Reset Password"
|
|
16
|
+
* entity action in the admin UI. See `AuthAdapterCapabilities`.
|
|
17
|
+
*/
|
|
18
|
+
adminPasswordReset?: boolean;
|
|
19
|
+
sessionManagement?: boolean;
|
|
20
|
+
profileUpdate?: boolean;
|
|
21
|
+
emailVerification?: boolean;
|
|
22
|
+
/** List of enabled OAuth provider IDs (e.g. ["google", "github", "discord"]) */
|
|
23
|
+
enabledProviders?: string[];
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Controller for retrieving the logged user or performing auth related operations.
|
|
27
|
+
* Note that if you are implementing your AuthController, you probably will want
|
|
28
|
+
* to do it as the result of a hook.
|
|
29
|
+
* @group Hooks and utilities
|
|
30
|
+
*/
|
|
31
|
+
export type AuthController<USER extends User = User, ExtraData = unknown> = {
|
|
32
|
+
/**
|
|
33
|
+
* The user currently logged in
|
|
34
|
+
* The values can be: the user object, null if they skipped login
|
|
35
|
+
*/
|
|
36
|
+
user: USER | null;
|
|
37
|
+
/**
|
|
38
|
+
* Initial loading flag. It is used not to display the login screen
|
|
39
|
+
* when the app first loads, and it has not been checked whether the user
|
|
40
|
+
* is logged in or not.
|
|
41
|
+
*/
|
|
42
|
+
initialLoading?: boolean;
|
|
43
|
+
/**
|
|
44
|
+
* Loading flag. It is used to display a loading screen when the user is
|
|
45
|
+
* logging in or out.
|
|
46
|
+
*/
|
|
47
|
+
authLoading: boolean;
|
|
48
|
+
/**
|
|
49
|
+
* Sign out
|
|
50
|
+
*/
|
|
51
|
+
signOut: () => Promise<void>;
|
|
52
|
+
/**
|
|
53
|
+
* Error initializing the authentication
|
|
54
|
+
*/
|
|
55
|
+
authError?: unknown;
|
|
56
|
+
/**
|
|
57
|
+
* Error dispatched by the auth provider
|
|
58
|
+
*/
|
|
59
|
+
authProviderError?: unknown;
|
|
60
|
+
/**
|
|
61
|
+
* You can use this method to retrieve the auth token for the current user.
|
|
62
|
+
*/
|
|
63
|
+
getAuthToken: () => Promise<string>;
|
|
64
|
+
/**
|
|
65
|
+
* Has the user skipped the login process
|
|
66
|
+
*/
|
|
67
|
+
loginSkipped: boolean;
|
|
68
|
+
extra: ExtraData;
|
|
69
|
+
setExtra: (extra: ExtraData) => void;
|
|
70
|
+
setUser?(user: USER | null): void;
|
|
71
|
+
setUserRoles?(roles: string[]): void;
|
|
72
|
+
/**
|
|
73
|
+
* Capabilities advertised by the auth provider.
|
|
74
|
+
* UI components use this to feature-detect what the backend supports.
|
|
75
|
+
*/
|
|
76
|
+
capabilities?: AuthCapabilities;
|
|
77
|
+
};
|
|
78
|
+
/**
|
|
79
|
+
* Extended auth controller with common optional auth methods.
|
|
80
|
+
* Backend implementations (Rebase backend, Firebase, etc.)
|
|
81
|
+
* extend this with their own backend-specific extras.
|
|
82
|
+
* @group Hooks and utilities
|
|
83
|
+
*/
|
|
84
|
+
export interface AuthControllerExtended<USER extends User = User, ExtraData = unknown> extends AuthController<USER, ExtraData> {
|
|
85
|
+
/** Login with email and password */
|
|
86
|
+
emailPasswordLogin?(email: string, password: string): Promise<void>;
|
|
87
|
+
/** Login with Google — accepts an ID token, access token, or authorization code payload */
|
|
88
|
+
googleLogin?: (payload: {
|
|
89
|
+
idToken: string;
|
|
90
|
+
} | {
|
|
91
|
+
accessToken: string;
|
|
92
|
+
} | {
|
|
93
|
+
code: string;
|
|
94
|
+
redirectUri: string;
|
|
95
|
+
}) => Promise<void>;
|
|
96
|
+
/** Generic OAuth login — works with any provider. Posts payload to /auth/{providerId}. */
|
|
97
|
+
oauthLogin?: (providerId: string, payload: Record<string, unknown>) => Promise<void>;
|
|
98
|
+
/** Register a new user */
|
|
99
|
+
register?(email: string, password: string, displayName?: string): Promise<void>;
|
|
100
|
+
/** Skip login (for anonymous access if enabled) */
|
|
101
|
+
skipLogin?(): void;
|
|
102
|
+
/** Request password reset email */
|
|
103
|
+
forgotPassword?(email: string): Promise<void>;
|
|
104
|
+
/** Reset password using a token */
|
|
105
|
+
resetPassword?(token: string, password: string): Promise<void>;
|
|
106
|
+
/** Change password for the authenticated user */
|
|
107
|
+
changePassword?(oldPassword: string, newPassword: string): Promise<void>;
|
|
108
|
+
/** Update user profile */
|
|
109
|
+
updateProfile?(displayName?: string, photoURL?: string): Promise<USER>;
|
|
110
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import type { EntityLinkBuilder } from "../types/entity_link_builder";
|
|
2
|
+
import type { Locale } from "../types/locales";
|
|
3
|
+
import type { EntityAction } from "../types/entity_actions";
|
|
4
|
+
import type { EntityCustomView } from "../types/entity_views";
|
|
5
|
+
import type { RebasePlugin } from "../types/plugins";
|
|
6
|
+
import type { PropertyConfig } from "../types/property_config";
|
|
7
|
+
import type { SlotContribution } from "../types/slots";
|
|
8
|
+
import type { ComponentOverrideMap } from "../types/component_overrides";
|
|
9
|
+
export type CustomizationController = {
|
|
10
|
+
/**
|
|
11
|
+
* Builder for generating utility links for entities
|
|
12
|
+
*/
|
|
13
|
+
entityLinkBuilder?: EntityLinkBuilder;
|
|
14
|
+
/**
|
|
15
|
+
* Use plugins to modify the behaviour of the CMS.
|
|
16
|
+
*/
|
|
17
|
+
plugins?: RebasePlugin[];
|
|
18
|
+
/**
|
|
19
|
+
* Pre-merged slots from plugins + direct slot contributions.
|
|
20
|
+
*/
|
|
21
|
+
resolvedSlots: SlotContribution[];
|
|
22
|
+
/**
|
|
23
|
+
* List of additional custom views for entities.
|
|
24
|
+
* You can use the key to reference the custom view in
|
|
25
|
+
* the `entityViews` prop of a collection.
|
|
26
|
+
*
|
|
27
|
+
* You can also define a entity view from the UI.
|
|
28
|
+
*/
|
|
29
|
+
entityViews?: EntityCustomView[];
|
|
30
|
+
/**
|
|
31
|
+
* List of actions that can be performed on entities.
|
|
32
|
+
* These actions are displayed in the entity view and in the collection view.
|
|
33
|
+
* You can later reuse these actions in the `entityActions` prop of a collection,
|
|
34
|
+
* by specifying the `key` of the action.
|
|
35
|
+
*/
|
|
36
|
+
entityActions?: EntityAction[];
|
|
37
|
+
/**
|
|
38
|
+
* Format of the dates in the CMS.
|
|
39
|
+
* Defaults to 'MMMM dd, yyyy, HH:mm:ss'
|
|
40
|
+
*/
|
|
41
|
+
dateTimeFormat?: string;
|
|
42
|
+
/**
|
|
43
|
+
* Locale of the CMS, currently only affecting dates
|
|
44
|
+
*/
|
|
45
|
+
locale?: Locale;
|
|
46
|
+
/**
|
|
47
|
+
* Record of custom form fields to be used in the CMS.
|
|
48
|
+
* You can use the key to reference the custom field in
|
|
49
|
+
* the `propertyConfig` prop of a property in a collection.
|
|
50
|
+
*/
|
|
51
|
+
propertyConfigs: Record<string, PropertyConfig>;
|
|
52
|
+
/**
|
|
53
|
+
* Global component overrides. Keys are component names from
|
|
54
|
+
* {@link OverridableComponentName}. Values replace the default
|
|
55
|
+
* implementation everywhere in the app.
|
|
56
|
+
*
|
|
57
|
+
* Collection-scoped overrides (set on individual collections)
|
|
58
|
+
* take precedence over global overrides.
|
|
59
|
+
*/
|
|
60
|
+
components?: ComponentOverrideMap;
|
|
61
|
+
};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
/**
|
|
3
|
+
* Controller to open the side dialog
|
|
4
|
+
* @group Hooks and utilities
|
|
5
|
+
*/
|
|
6
|
+
export interface DialogsController {
|
|
7
|
+
/**
|
|
8
|
+
* Close the last dialog
|
|
9
|
+
*/
|
|
10
|
+
close: () => void;
|
|
11
|
+
/**
|
|
12
|
+
* Open a dialog
|
|
13
|
+
* @param props
|
|
14
|
+
*/
|
|
15
|
+
open: <T extends object = object>(props: DialogControllerEntryProps<T>) => {
|
|
16
|
+
closeDialog: () => void;
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Props used to open a side dialog
|
|
21
|
+
* @group Hooks and utilities
|
|
22
|
+
*/
|
|
23
|
+
export interface DialogControllerEntryProps<T extends object = object> {
|
|
24
|
+
key: string;
|
|
25
|
+
/**
|
|
26
|
+
* The component type that will be rendered
|
|
27
|
+
*/
|
|
28
|
+
Component: React.ComponentType<{
|
|
29
|
+
open: boolean;
|
|
30
|
+
closeDialog: () => void;
|
|
31
|
+
} & T>;
|
|
32
|
+
/**
|
|
33
|
+
* Props to pass to the dialog component
|
|
34
|
+
*/
|
|
35
|
+
props?: T;
|
|
36
|
+
}
|
|
@@ -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,20 @@
|
|
|
1
|
+
import type { AdminCollection } from "@rebasepro/admin-types";
|
|
2
|
+
/**
|
|
3
|
+
* @group Models
|
|
4
|
+
*/
|
|
5
|
+
export type PartialCollectionConfig<M extends Record<string, unknown> = Record<string, unknown>> = Partial<AdminCollection<M>>;
|
|
6
|
+
/**
|
|
7
|
+
* This interface is in charge of defining the controller that persists
|
|
8
|
+
* modifications to a collection or collection, and retrieves them back from
|
|
9
|
+
* a data source, such as local storage or Firestore.
|
|
10
|
+
*/
|
|
11
|
+
export interface UserConfigurationPersistence {
|
|
12
|
+
onCollectionModified: <M extends Record<string, unknown> = Record<string, unknown>>(path: string, partialCollection: PartialCollectionConfig<M>) => void;
|
|
13
|
+
getCollectionConfig: <M extends Record<string, unknown> = Record<string, unknown>>(path: string) => PartialCollectionConfig<M>;
|
|
14
|
+
recentlyVisitedPaths: string[];
|
|
15
|
+
setRecentlyVisitedPaths: (paths: string[]) => void;
|
|
16
|
+
favouritePaths: string[];
|
|
17
|
+
setFavouritePaths: (paths: string[]) => void;
|
|
18
|
+
collapsedGroups: string[];
|
|
19
|
+
setCollapsedGroups: (paths: string[]) => void;
|
|
20
|
+
}
|