@rebasepro/types 0.0.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.
Files changed (91) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +174 -0
  3. package/dist/components/EntityFormActionsProps.d.ts +17 -0
  4. package/dist/components/EntityFormProps.d.ts +46 -0
  5. package/dist/components/PropertyPreviewProps.d.ts +50 -0
  6. package/dist/components/formex.d.ts +40 -0
  7. package/dist/components/index.d.ts +3 -0
  8. package/dist/controllers/analytics_controller.d.ts +7 -0
  9. package/dist/controllers/auth.d.ts +73 -0
  10. package/dist/controllers/customization_controller.d.ts +50 -0
  11. package/dist/controllers/datasource.d.ts +179 -0
  12. package/dist/controllers/dialogs_controller.d.ts +36 -0
  13. package/dist/controllers/index.d.ts +11 -0
  14. package/dist/controllers/local_config_persistence.d.ts +20 -0
  15. package/dist/controllers/navigation.d.ts +262 -0
  16. package/dist/controllers/side_dialogs_controller.d.ts +67 -0
  17. package/dist/controllers/side_entity_controller.d.ts +90 -0
  18. package/dist/controllers/snackbar.d.ts +24 -0
  19. package/dist/controllers/storage.d.ts +173 -0
  20. package/dist/index.d.ts +5 -0
  21. package/dist/index.es.js +113 -0
  22. package/dist/index.es.js.map +1 -0
  23. package/dist/index.umd.js +117 -0
  24. package/dist/index.umd.js.map +1 -0
  25. package/dist/rebase_context.d.ts +91 -0
  26. package/dist/types/backend.d.ts +254 -0
  27. package/dist/types/chips.d.ts +5 -0
  28. package/dist/types/collections.d.ts +887 -0
  29. package/dist/types/entities.d.ts +140 -0
  30. package/dist/types/entity_actions.d.ts +98 -0
  31. package/dist/types/entity_callbacks.d.ts +173 -0
  32. package/dist/types/entity_link_builder.d.ts +7 -0
  33. package/dist/types/entity_overrides.d.ts +5 -0
  34. package/dist/types/export_import.d.ts +21 -0
  35. package/dist/types/fields.d.ts +221 -0
  36. package/dist/types/index.d.ts +19 -0
  37. package/dist/types/locales.d.ts +4 -0
  38. package/dist/types/modify_collections.d.ts +5 -0
  39. package/dist/types/plugins.d.ts +276 -0
  40. package/dist/types/properties.d.ts +1103 -0
  41. package/dist/types/property_config.d.ts +68 -0
  42. package/dist/types/rebase.d.ts +180 -0
  43. package/dist/types/relations.d.ts +336 -0
  44. package/dist/types/user_management_delegate.d.ts +78 -0
  45. package/dist/types/websockets.d.ts +33 -0
  46. package/dist/users/index.d.ts +2 -0
  47. package/dist/users/roles.d.ts +22 -0
  48. package/dist/users/user.d.ts +42 -0
  49. package/package.json +137 -0
  50. package/src/components/EntityFormActionsProps.tsx +18 -0
  51. package/src/components/EntityFormProps.tsx +52 -0
  52. package/src/components/PropertyPreviewProps.tsx +61 -0
  53. package/src/components/formex.tsx +46 -0
  54. package/src/components/index.ts +3 -0
  55. package/src/controllers/analytics_controller.tsx +57 -0
  56. package/src/controllers/auth.tsx +94 -0
  57. package/src/controllers/customization_controller.tsx +61 -0
  58. package/src/controllers/datasource.ts +218 -0
  59. package/src/controllers/dialogs_controller.tsx +37 -0
  60. package/src/controllers/index.ts +11 -0
  61. package/src/controllers/local_config_persistence.tsx +22 -0
  62. package/src/controllers/navigation.ts +317 -0
  63. package/src/controllers/side_dialogs_controller.tsx +82 -0
  64. package/src/controllers/side_entity_controller.tsx +104 -0
  65. package/src/controllers/snackbar.ts +29 -0
  66. package/src/controllers/storage.ts +196 -0
  67. package/src/index.ts +5 -0
  68. package/src/rebase_context.tsx +122 -0
  69. package/src/types/backend.ts +385 -0
  70. package/src/types/chips.ts +46 -0
  71. package/src/types/collections.ts +1013 -0
  72. package/src/types/entities.ts +207 -0
  73. package/src/types/entity_actions.tsx +118 -0
  74. package/src/types/entity_callbacks.ts +217 -0
  75. package/src/types/entity_link_builder.ts +8 -0
  76. package/src/types/entity_overrides.tsx +6 -0
  77. package/src/types/export_import.ts +26 -0
  78. package/src/types/fields.tsx +298 -0
  79. package/src/types/index.ts +20 -0
  80. package/src/types/locales.ts +81 -0
  81. package/src/types/modify_collections.tsx +6 -0
  82. package/src/types/plugins.tsx +328 -0
  83. package/src/types/properties.ts +1270 -0
  84. package/src/types/property_config.tsx +93 -0
  85. package/src/types/rebase.tsx +211 -0
  86. package/src/types/relations.ts +351 -0
  87. package/src/types/user_management_delegate.ts +98 -0
  88. package/src/types/websockets.ts +37 -0
  89. package/src/users/index.ts +2 -0
  90. package/src/users/roles.ts +33 -0
  91. package/src/users/user.ts +46 -0
@@ -0,0 +1,218 @@
1
+ import { CollectionRegistryController } from "./navigation";
2
+ import { Entity, EntityCollection, EntityStatus, EntityValues, FilterValues, TableColumnInfo } from "../types";
3
+ import { RebaseContext } from "../rebase_context";
4
+
5
+ /**
6
+ * @group Datasource
7
+ */
8
+ export interface FetchEntityProps<M extends Record<string, any> = any> {
9
+ path: string;
10
+ entityId: string | number;
11
+ databaseId?: string;
12
+ collection?: EntityCollection<M, any>
13
+ }
14
+
15
+ /**
16
+ * @group Datasource
17
+ */
18
+ export type ListenEntityProps<M extends Record<string, any> = any> =
19
+ FetchEntityProps<M>
20
+ & {
21
+ onUpdate: (entity: Entity<M> | null) => void,
22
+ onError?: (error: Error) => void,
23
+ }
24
+
25
+ /**
26
+ * @group Datasource
27
+ */
28
+ export interface FetchCollectionProps<M extends Record<string, any> = any> {
29
+ path: string;
30
+ collection?: EntityCollection<M>;
31
+ filter?: FilterValues<Extract<keyof M, string>>,
32
+ limit?: number;
33
+ startAfter?: unknown;
34
+ orderBy?: string;
35
+ searchString?: string;
36
+ order?: "desc" | "asc";
37
+ }
38
+
39
+ /**
40
+ * @group Datasource
41
+ */
42
+ export type ListenCollectionProps<M extends Record<string, any> = any> =
43
+ FetchCollectionProps<M> &
44
+ {
45
+ onUpdate: (entities: Entity<M>[]) => void;
46
+ onError?: (error: Error) => void;
47
+ };
48
+
49
+ /**
50
+ * @group Datasource
51
+ */
52
+ export interface SaveEntityProps<M extends Record<string, any> = any> {
53
+ path: string;
54
+ values: Partial<EntityValues<M>>;
55
+ entityId?: string | number; // can be empty for new entities
56
+ previousValues?: Partial<EntityValues<M>>;
57
+ collection?: EntityCollection<M>;
58
+ status: EntityStatus;
59
+ }
60
+
61
+ /**
62
+ * @group Datasource
63
+ */
64
+ export interface DeleteEntityProps<M extends Record<string, any> = any> {
65
+ entity: Entity<M>;
66
+ collection?: EntityCollection<M>;
67
+ }
68
+
69
+ export type FilterCombinationValidProps = {
70
+ path: string;
71
+ databaseId?: string;
72
+ collection: EntityCollection<any>;
73
+ filterValues: FilterValues<any>;
74
+ sortBy?: [string, "asc" | "desc"];
75
+ };
76
+
77
+ /**
78
+ * Component in charge of communicating with the data source.
79
+ * @group Datasource
80
+ */
81
+ export interface DataSource {
82
+
83
+ /**
84
+ * Key that identifies this data source
85
+ */
86
+ key?: string;
87
+
88
+ /**
89
+ * If the data source has been initialised
90
+ */
91
+ initialised?: boolean;
92
+
93
+ /**
94
+ * Fetch data from a collection
95
+ * @param props
96
+ * @return Promise of entities
97
+ * @see useCollectionFetch if you need this functionality implemented as a hook
98
+ */
99
+ fetchCollection<M extends Record<string, any> = any>(props: FetchCollectionProps<M>): Promise<Entity<M>[]>;
100
+
101
+ /**
102
+ * Listen to a collection in a given path. If you don't implement this method
103
+ * `fetchCollection` will be used instead, with no real time updates.
104
+ * @param props
105
+ * @return Function to cancel subscription
106
+ * @see useCollectionFetch if you need this functionality implemented as a hook
107
+ */
108
+ listenCollection?<M extends Record<string, any> = any>(props: ListenCollectionProps<M>): () => void;
109
+
110
+ /**
111
+ * Retrieve an entity given a path and a collection
112
+ * @param props
113
+ */
114
+ fetchEntity<M extends Record<string, any> = any>(props: FetchEntityProps<M>): Promise<Entity<M> | undefined>;
115
+
116
+ /**
117
+ * Get realtime updates on one entity.
118
+ * @param props
119
+ * @return Function to cancel subscription
120
+ */
121
+ listenEntity?<M extends Record<string, any> = any>(props: ListenEntityProps<M>): () => void;
122
+
123
+ /**
124
+ * Save entity to the specified path
125
+ * @param props
126
+ */
127
+ saveEntity<M extends Record<string, any> = any>(props: SaveEntityProps<M>): Promise<Entity<M>>;
128
+
129
+ /**
130
+ * Delete an entity
131
+ * @param props
132
+ * @return was the whole deletion flow successful
133
+ */
134
+ deleteEntity<M extends Record<string, any> = any>(props: DeleteEntityProps<M>): Promise<void>;
135
+
136
+ /**
137
+ * Check if the given property is unique in the given collection
138
+ * @param path Collection path
139
+ * @param name of the property
140
+ * @param value
141
+ * @param entityId
142
+ * @param collection
143
+ * @return `true` if there are no other fields besides the given entity
144
+ */
145
+ checkUniqueField(
146
+ path: string,
147
+ name: string,
148
+ value: unknown,
149
+ entityId?: string | number,
150
+ collection?: EntityCollection
151
+ ): Promise<boolean>;
152
+
153
+ /**
154
+ * Count the number of entities in a collection
155
+ */
156
+ countEntities?<M extends Record<string, any> = any>(props: FetchCollectionProps<M>): Promise<number>;
157
+
158
+ /**
159
+ * Check if the given filter combination is valid
160
+ * @param props
161
+ */
162
+ isFilterCombinationValid?(props: Omit<FilterCombinationValidProps, "collection"> & {
163
+ databaseId?: string
164
+ }): boolean;
165
+
166
+ /**
167
+ * Get the object to generate the current time in the datasource
168
+ */
169
+ currentTime?: () => unknown;
170
+
171
+ delegateToCMSModel?: (data: unknown) => unknown;
172
+
173
+ cmsToDelegateModel?: (data: unknown) => unknown;
174
+
175
+ initTextSearch?: (props: {
176
+ context: RebaseContext,
177
+ path: string,
178
+ databaseId?: string,
179
+ collection: EntityCollection,
180
+ parentCollectionIds?: string[]
181
+ }) => Promise<boolean>;
182
+
183
+ /**
184
+ * Execute raw SQL (if supported by the datasource)
185
+ */
186
+ executeSql?(sql: string, options?: { database?: string, role?: string }): Promise<Record<string, unknown>[]>;
187
+
188
+ /**
189
+ * Fetch the available databases (if supported by the datasource)
190
+ */
191
+ fetchAvailableDatabases?(): Promise<string[]>;
192
+
193
+ /**
194
+ * Fetch the available roles (if supported by the datasource)
195
+ */
196
+ fetchAvailableRoles?(): Promise<string[]>;
197
+
198
+ /**
199
+ * Fetch the current database name (if supported by the datasource)
200
+ */
201
+ fetchCurrentDatabase?(): Promise<string | undefined>;
202
+
203
+ /**
204
+ * Fetch database tables not yet mapped to a collection (if supported)
205
+ */
206
+ fetchUnmappedTables?(mappedPaths?: string[]): Promise<string[]>;
207
+
208
+ /**
209
+ * Fetch column metadata for a given table (if supported)
210
+ */
211
+ fetchTableColumns?(tableName: string): Promise<TableColumnInfo[]>;
212
+
213
+ /**
214
+ * Flag to indicate if the datasource delegate has requested the initialization of the text search index
215
+ */
216
+ needsInitTextSearch?: boolean;
217
+
218
+ }
@@ -0,0 +1,37 @@
1
+ import React from "react";
2
+
3
+ /**
4
+ * Controller to open the side dialog
5
+ * @group Hooks and utilities
6
+ */
7
+ export interface DialogsController {
8
+
9
+ /**
10
+ * Close the last dialog
11
+ */
12
+ close: () => void;
13
+
14
+ /**
15
+ * Open a dialog
16
+ * @param props
17
+ */
18
+ open: <T extends object = object>(props: DialogControllerEntryProps<T>) => { closeDialog: () => void };
19
+ }
20
+
21
+ /**
22
+ * Props used to open a side dialog
23
+ * @group Hooks and utilities
24
+ */
25
+ export interface DialogControllerEntryProps<T extends object = object> {
26
+
27
+ key: string;
28
+ /**
29
+ * The component type that will be rendered
30
+ */
31
+ Component: React.ComponentType<{ open: boolean, closeDialog: () => void } & T>;
32
+ /**
33
+ * Props to pass to the dialog component
34
+ */
35
+ props?: T;
36
+
37
+ }
@@ -0,0 +1,11 @@
1
+ export * from "./analytics_controller";
2
+ export * from "./auth";
3
+ export * from "./customization_controller";
4
+ export * from "./datasource";
5
+ export * from "./dialogs_controller";
6
+ export * from "./local_config_persistence";
7
+ export * from "./navigation";
8
+ export * from "./side_dialogs_controller";
9
+ export * from "./side_entity_controller";
10
+ export * from "./snackbar";
11
+ export * from "./storage";
@@ -0,0 +1,22 @@
1
+ import { EntityCollection } from "../types";
2
+
3
+ /**
4
+ * @group Models
5
+ */
6
+ export type PartialEntityCollection<M extends Record<string, any> = any> = Partial<EntityCollection<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, any> = any>(path: string, partialCollection: PartialEntityCollection<M>) => void;
15
+ getCollectionConfig: <M extends Record<string, any> = any>(path: string) => PartialEntityCollection<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,317 @@
1
+ import React from "react";
2
+ import { EntityCollection, EntityReference, RebasePlugin } from "../types";
3
+
4
+ /**
5
+ * Controller that handles URL path building and resolution.
6
+ * @group Models
7
+ */
8
+ export type CMSUrlController = {
9
+ /**
10
+ * Default path under the navigation routes of the CMS will be created.
11
+ * Defaults to '/'. You may want to change this `basepath` to 'admin' for example.
12
+ */
13
+ basePath: string;
14
+
15
+ /**
16
+ * Default path under the collection routes of the CMS will be created.
17
+ * It defaults to '/c'
18
+ */
19
+ baseCollectionPath: string;
20
+
21
+ /**
22
+ * Convert a URL path to a collection or entity path
23
+ * `/c/products` => `products`
24
+ * `/my_cms/c/products/B34SAP8Z` => `products/B34SAP8Z`
25
+ * `/my_cms/my_view` => `my_view`
26
+ * @param cmsPath
27
+ */
28
+ urlPathToDataPath: (cmsPath: string) => string;
29
+
30
+ /**
31
+ * Base url path for the home screen
32
+ */
33
+ homeUrl: string;
34
+
35
+ /**
36
+ * Check if a url path belongs to a collection
37
+ * @param path
38
+ */
39
+ isUrlCollectionPath: (urlPath: string) => boolean;
40
+
41
+ /**
42
+ * Build a URL collection path from a data path
43
+ * `products` => `/c/products`
44
+ * `products/B34SAP8Z` => `/c/products/B34SAP8Z`
45
+ * @param path
46
+ */
47
+ buildUrlCollectionPath: (path: string) => string;
48
+
49
+ /**
50
+ * Build a URL path for the CMS (e.g. for custom views)
51
+ * @param path
52
+ */
53
+ buildCMSUrlPath: (path: string) => string;
54
+
55
+ /**
56
+ * Turn a path with collection ids into a resolved path.
57
+ * The ids (typically used in urls) will be replaced with relative paths (typically used in database paths)
58
+ * @param path
59
+ */
60
+ resolveDatabasePathsFrom: (path: string) => string;
61
+
62
+ /**
63
+ * A function to navigate to a specified route or URL.
64
+ *
65
+ * @param {string} to - The target route or URL to navigate to.
66
+ * @param {NavigateOptions} [options] - Optional configuration settings for navigation, such as replace behavior or state data.
67
+ */
68
+ navigate: (to: string, options?: NavigateOptions) => void;
69
+ };
70
+
71
+ /**
72
+ * Controller that manages the state of the navigation menu,
73
+ * including resolved views and top-level grouping.
74
+ * @group Models
75
+ */
76
+ export type NavigationStateController = {
77
+ /**
78
+ * Custom additional views created by the developer, added to the main
79
+ * navigation
80
+ */
81
+ views?: CMSView[];
82
+
83
+ /**
84
+ * Custom additional views created by the developer, added to the admin
85
+ * navigation
86
+ */
87
+ adminViews?: CMSView[];
88
+
89
+ /**
90
+ * Configuration for the views that should be displayed at the top
91
+ * level of the navigation (e.g. in the home page or the navigation
92
+ * drawer)
93
+ */
94
+ topLevelNavigation?: NavigationResult;
95
+
96
+ /**
97
+ * Is the navigation loading (the configuration persistence has not
98
+ * loaded yet, or a specified navigation builder has not completed)
99
+ */
100
+ loading: boolean;
101
+
102
+ /**
103
+ * Was there an error while loading the navigation data
104
+ */
105
+ navigationLoadingError?: unknown;
106
+
107
+ /**
108
+ * Call this method to recalculate the navigation
109
+ */
110
+ refreshNavigation: () => void;
111
+
112
+ /**
113
+ * Plugin system allowing to extend the CMS functionality.
114
+ */
115
+ plugins?: RebasePlugin<any, any, any>[];
116
+ };
117
+
118
+ /**
119
+ * Controller that provides access to the registered entity collections.
120
+ * @group Models
121
+ */
122
+ export type CollectionRegistryController<EC extends EntityCollection = EntityCollection<any>> = {
123
+
124
+ /**
125
+ * List of the mapped collections in the CMS.
126
+ * Each entry relates to a collection in the root database.
127
+ * Each of the navigation entries in this field
128
+ * generates an entry in the main menu.
129
+ */
130
+ collections?: EntityCollection[];
131
+
132
+ /**
133
+ * Is the registry ready to be used
134
+ */
135
+ initialised: boolean;
136
+
137
+ /**
138
+ * Get the collection configuration for a given path.
139
+ * The collection is resolved from the given path or alias.
140
+ */
141
+ getCollection: (slugOrPath: string, includeUserOverride?: boolean) => EC | undefined;
142
+
143
+ /**
144
+ * Get the raw, un-normalized collection configuration.
145
+ * This bypasses the `CollectionRegistry` normalization (such as injecting `relation` instances).
146
+ * This is strictly for the Visual Editor to manipulate AST code without persisting runtime state.
147
+ */
148
+ getRawCollection: (slugOrPath: string) => EC | undefined;
149
+
150
+
151
+
152
+ /**
153
+ * Retrieve all the related parent references for a given path
154
+ * @param path
155
+ */
156
+ getParentReferencesFromPath: (path: string) => EntityReference[];
157
+
158
+ /**
159
+ * Retrieve all the related parent collection ids for a given path
160
+ * @param path
161
+ */
162
+ getParentCollectionIds: (path: string) => string[];
163
+
164
+ /**
165
+ * Resolve paths from a list of ids
166
+ * @param ids
167
+ */
168
+ convertIdsToPaths: (ids: string[]) => string[];
169
+
170
+ };
171
+
172
+ /**
173
+ * Legacy monolithic controller that includes the resolved navigation and utility methods and attributes.
174
+ * It is a combination of CMSUrlController, NavigationStateController, and CollectionRegistryController.
175
+ * @group Models
176
+ * @deprecated Use the specific controllers instead.
177
+ */
178
+ export type NavigationController<EC extends EntityCollection = EntityCollection<any>> =
179
+ CMSUrlController &
180
+ NavigationStateController &
181
+ CollectionRegistryController<EC>;
182
+
183
+ export interface NavigateOptions {
184
+ replace?: boolean;
185
+ state?: unknown;
186
+ preventScrollReset?: boolean;
187
+ relative?: "route" | "path";
188
+ flushSync?: boolean;
189
+ viewTransition?: boolean;
190
+ }
191
+
192
+ // currently not used, in favor of a single blocker in `RebaseRoute`
193
+ export type NavigationBlocker = {
194
+ updateBlockListener: (path: string, block: boolean, basePath?: string) => () => void;
195
+ isBlocked: (path: string) => boolean;
196
+ proceed?: () => void;
197
+ reset?: () => void;
198
+ };
199
+
200
+ /**
201
+ * Custom additional views created by the developer, added to the main
202
+ * navigation.
203
+ * @group Models
204
+ */
205
+ export interface CMSView {
206
+
207
+ /**
208
+ * CMS Path you can reach this view from.
209
+ */
210
+ slug: string;
211
+
212
+ /**
213
+ * Name of this view
214
+ */
215
+ name: string;
216
+
217
+ /**
218
+ * Optional description of this view. You can use Markdown
219
+ */
220
+ description?: string;
221
+
222
+ /**
223
+ * Icon key to use in this view.
224
+ * You can use any of the icons in the Material specs:
225
+ * https://fonts.google.com/icons
226
+ * e.g. 'account_tree' or 'person'
227
+ * Find all the icons in https://rebase.pro/docs/icons
228
+ */
229
+ icon?: string | React.ReactNode;
230
+
231
+ /**
232
+ * Should this view be hidden from the main navigation panel.
233
+ * It will still be accessible if you reach the specified path
234
+ */
235
+ hideFromNavigation?: boolean;
236
+
237
+ /**
238
+ * Component to be rendered. This can be any React component, and can use
239
+ * any of the provided hooks
240
+ */
241
+ view: React.ReactNode;
242
+
243
+ /**
244
+ * Optional field used to group top level navigation entries under a
245
+ * navigation view.
246
+ * This prop is ignored for admin views.
247
+ */
248
+ group?: string;
249
+
250
+ /**
251
+ * If true, a wildcard route (slug/*) is automatically registered
252
+ * alongside the base route, enabling nested navigation within this view.
253
+ */
254
+ nestedRoutes?: boolean;
255
+
256
+ }
257
+
258
+ /**
259
+ * A composable section that can be rendered on the home page.
260
+ * Use this to add custom content alongside the auto-generated
261
+ * navigation groups.
262
+ * @group Models
263
+ */
264
+ export interface HomePageSection {
265
+ /**
266
+ * Unique key for this section.
267
+ */
268
+ key: string;
269
+
270
+ /**
271
+ * Title displayed as the section header.
272
+ */
273
+ title: string;
274
+
275
+ /**
276
+ * Arbitrary React content rendered inside the section.
277
+ */
278
+ children: React.ReactNode;
279
+ }
280
+
281
+ /**
282
+ * Used to group navigation entries in the main navigation.
283
+ */
284
+ export interface NavigationGroupMapping {
285
+ /**
286
+ * Name of the group, used to display the group header in the UI
287
+ */
288
+ name: string;
289
+ /**
290
+ * List of collection ids or view paths that belong to this group.
291
+ */
292
+ entries: string[];
293
+ }
294
+
295
+ export interface NavigationEntry {
296
+ id: string;
297
+ url: string;
298
+ name: string;
299
+ slug: string;
300
+ type: "collection" | "view" | "admin";
301
+ collection?: EntityCollection;
302
+ view?: CMSView;
303
+ description?: string;
304
+ group: string;
305
+ }
306
+
307
+ export type NavigationResult = {
308
+
309
+ allowDragAndDrop: boolean;
310
+
311
+ navigationEntries: NavigationEntry[],
312
+
313
+ groups: string[],
314
+
315
+ onNavigationEntriesUpdate: (entries: NavigationGroupMapping[]) => void;
316
+ };
317
+
@@ -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
+ }