@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.
- package/LICENSE +21 -0
- package/README.md +174 -0
- package/dist/components/EntityFormActionsProps.d.ts +17 -0
- package/dist/components/EntityFormProps.d.ts +46 -0
- package/dist/components/PropertyPreviewProps.d.ts +50 -0
- package/dist/components/formex.d.ts +40 -0
- package/dist/components/index.d.ts +3 -0
- package/dist/controllers/analytics_controller.d.ts +7 -0
- package/dist/controllers/auth.d.ts +73 -0
- package/dist/controllers/customization_controller.d.ts +50 -0
- package/dist/controllers/datasource.d.ts +179 -0
- package/dist/controllers/dialogs_controller.d.ts +36 -0
- package/dist/controllers/index.d.ts +11 -0
- package/dist/controllers/local_config_persistence.d.ts +20 -0
- package/dist/controllers/navigation.d.ts +262 -0
- package/dist/controllers/side_dialogs_controller.d.ts +67 -0
- package/dist/controllers/side_entity_controller.d.ts +90 -0
- package/dist/controllers/snackbar.d.ts +24 -0
- package/dist/controllers/storage.d.ts +173 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.es.js +113 -0
- package/dist/index.es.js.map +1 -0
- package/dist/index.umd.js +117 -0
- package/dist/index.umd.js.map +1 -0
- package/dist/rebase_context.d.ts +91 -0
- package/dist/types/backend.d.ts +254 -0
- package/dist/types/chips.d.ts +5 -0
- package/dist/types/collections.d.ts +887 -0
- package/dist/types/entities.d.ts +140 -0
- package/dist/types/entity_actions.d.ts +98 -0
- package/dist/types/entity_callbacks.d.ts +173 -0
- package/dist/types/entity_link_builder.d.ts +7 -0
- package/dist/types/entity_overrides.d.ts +5 -0
- package/dist/types/export_import.d.ts +21 -0
- package/dist/types/fields.d.ts +221 -0
- package/dist/types/index.d.ts +19 -0
- package/dist/types/locales.d.ts +4 -0
- package/dist/types/modify_collections.d.ts +5 -0
- package/dist/types/plugins.d.ts +276 -0
- package/dist/types/properties.d.ts +1103 -0
- package/dist/types/property_config.d.ts +68 -0
- package/dist/types/rebase.d.ts +180 -0
- package/dist/types/relations.d.ts +336 -0
- package/dist/types/user_management_delegate.d.ts +78 -0
- package/dist/types/websockets.d.ts +33 -0
- package/dist/users/index.d.ts +2 -0
- package/dist/users/roles.d.ts +22 -0
- package/dist/users/user.d.ts +42 -0
- package/package.json +137 -0
- package/src/components/EntityFormActionsProps.tsx +18 -0
- package/src/components/EntityFormProps.tsx +52 -0
- package/src/components/PropertyPreviewProps.tsx +61 -0
- package/src/components/formex.tsx +46 -0
- package/src/components/index.ts +3 -0
- package/src/controllers/analytics_controller.tsx +57 -0
- package/src/controllers/auth.tsx +94 -0
- package/src/controllers/customization_controller.tsx +61 -0
- package/src/controllers/datasource.ts +218 -0
- package/src/controllers/dialogs_controller.tsx +37 -0
- package/src/controllers/index.ts +11 -0
- package/src/controllers/local_config_persistence.tsx +22 -0
- package/src/controllers/navigation.ts +317 -0
- package/src/controllers/side_dialogs_controller.tsx +82 -0
- package/src/controllers/side_entity_controller.tsx +104 -0
- package/src/controllers/snackbar.ts +29 -0
- package/src/controllers/storage.ts +196 -0
- package/src/index.ts +5 -0
- package/src/rebase_context.tsx +122 -0
- package/src/types/backend.ts +385 -0
- package/src/types/chips.ts +46 -0
- package/src/types/collections.ts +1013 -0
- package/src/types/entities.ts +207 -0
- package/src/types/entity_actions.tsx +118 -0
- package/src/types/entity_callbacks.ts +217 -0
- package/src/types/entity_link_builder.ts +8 -0
- package/src/types/entity_overrides.tsx +6 -0
- package/src/types/export_import.ts +26 -0
- package/src/types/fields.tsx +298 -0
- package/src/types/index.ts +20 -0
- package/src/types/locales.ts +81 -0
- package/src/types/modify_collections.tsx +6 -0
- package/src/types/plugins.tsx +328 -0
- package/src/types/properties.ts +1270 -0
- package/src/types/property_config.tsx +93 -0
- package/src/types/rebase.tsx +211 -0
- package/src/types/relations.ts +351 -0
- package/src/types/user_management_delegate.ts +98 -0
- package/src/types/websockets.ts +37 -0
- package/src/users/index.ts +2 -0
- package/src/users/roles.ts +33 -0
- package/src/users/user.ts +46 -0
|
@@ -0,0 +1,276 @@
|
|
|
1
|
+
import React, { PropsWithChildren } from "react";
|
|
2
|
+
import { CollectionActionsProps, EntityCollection, EntityTableController } from "./collections";
|
|
3
|
+
import { FieldProps, FormContext } from "./fields";
|
|
4
|
+
import { Property } from "./properties";
|
|
5
|
+
import { EntityStatus } from "./entities";
|
|
6
|
+
import { RebaseContext } from "../rebase_context";
|
|
7
|
+
import { NavigationGroupMapping, CMSView } from "../controllers";
|
|
8
|
+
import { User } from "../users";
|
|
9
|
+
import { UserManagementDelegate } from "./user_management_delegate";
|
|
10
|
+
/**
|
|
11
|
+
* Interface used to define plugins for Rebase.
|
|
12
|
+
* NOTE: This is a work in progress and the API is not stable yet.
|
|
13
|
+
* @group Core
|
|
14
|
+
*/
|
|
15
|
+
export type RebasePlugin<PROPS = any, FORM_PROPS = any, EC extends EntityCollection = EntityCollection, COL_ACTIONS_PROPS = any, COL_ACTIONS_START__PROPS = any> = {
|
|
16
|
+
/**
|
|
17
|
+
* Key of the plugin. This is used to identify the plugin in the CMS.
|
|
18
|
+
*/
|
|
19
|
+
key: string;
|
|
20
|
+
/**
|
|
21
|
+
* If this flag is set to true, no content will be shown in the CMS
|
|
22
|
+
* until the plugin is fully loaded.
|
|
23
|
+
*/
|
|
24
|
+
loading?: boolean;
|
|
25
|
+
/**
|
|
26
|
+
* You can use this prop to add higher order components to the CMS.
|
|
27
|
+
* The components will be added to the root of the CMS, so any component
|
|
28
|
+
* rendered underneath by this plugin will have access to the context
|
|
29
|
+
* provided by this HOC.
|
|
30
|
+
* Anyhow, this is rendered below the {@link RebaseContext} provider, so
|
|
31
|
+
* you can use the hooks provided by the CMS.
|
|
32
|
+
* @param props
|
|
33
|
+
*/
|
|
34
|
+
provider?: {
|
|
35
|
+
Component: React.ComponentType<PropsWithChildren<PROPS & {
|
|
36
|
+
context: RebaseContext;
|
|
37
|
+
}>>;
|
|
38
|
+
props?: PROPS;
|
|
39
|
+
};
|
|
40
|
+
userManagement?: UserManagementDelegate;
|
|
41
|
+
/**
|
|
42
|
+
* Views to be automatically added to the navigation.
|
|
43
|
+
* These views will be merged with the views provided to useBuildNavigationController.
|
|
44
|
+
*/
|
|
45
|
+
views?: CMSView[];
|
|
46
|
+
homePage?: {
|
|
47
|
+
/**
|
|
48
|
+
* Additional actions to be rendered in the home page, close to the search bar.
|
|
49
|
+
*/
|
|
50
|
+
additionalActions?: React.ReactNode;
|
|
51
|
+
/**
|
|
52
|
+
* Additional children to be rendered in the beginning of the home page.
|
|
53
|
+
*/
|
|
54
|
+
additionalChildrenStart?: React.ReactNode;
|
|
55
|
+
/**
|
|
56
|
+
* Additional children to be rendered at the end of the home page.
|
|
57
|
+
*/
|
|
58
|
+
additionalChildrenEnd?: React.ReactNode;
|
|
59
|
+
/**
|
|
60
|
+
* Use this component to add custom actions to the navigation card
|
|
61
|
+
* in the home page.
|
|
62
|
+
*/
|
|
63
|
+
CollectionActions?: React.ComponentType<PluginHomePageActionsProps>;
|
|
64
|
+
/**
|
|
65
|
+
* Additional props passed to `CollectionActions`
|
|
66
|
+
*/
|
|
67
|
+
extraProps?: Record<string, unknown>;
|
|
68
|
+
/**
|
|
69
|
+
* Add additional cards to each collection group in the home page.
|
|
70
|
+
*/
|
|
71
|
+
AdditionalCards?: React.ComponentType<PluginHomePageAdditionalCardsProps> | React.ComponentType<PluginHomePageAdditionalCardsProps>[];
|
|
72
|
+
/**
|
|
73
|
+
* Include a section in the home page with a custom component and title.
|
|
74
|
+
* @param props
|
|
75
|
+
*/
|
|
76
|
+
includeSection?: (props: PluginGenericProps) => {
|
|
77
|
+
title: string;
|
|
78
|
+
children: React.ReactNode;
|
|
79
|
+
};
|
|
80
|
+
/**
|
|
81
|
+
* Allow reordering with drag and drop of the collections in the home page.
|
|
82
|
+
*/
|
|
83
|
+
allowDragAndDrop?: boolean;
|
|
84
|
+
navigationEntries?: NavigationGroupMapping[];
|
|
85
|
+
/**
|
|
86
|
+
* This method will be called when the entries are updated in the home page.
|
|
87
|
+
* group => navigationEntriesOrder (path)
|
|
88
|
+
* @param entries
|
|
89
|
+
*/
|
|
90
|
+
onNavigationEntriesUpdate?: (entries: NavigationGroupMapping[]) => void;
|
|
91
|
+
};
|
|
92
|
+
collectionView?: {
|
|
93
|
+
/**
|
|
94
|
+
* Custom component to render when a collection loading error occurs.
|
|
95
|
+
* If provided, this replaces the default error view in all collection view modes
|
|
96
|
+
* (table, card, kanban).
|
|
97
|
+
* Return `null` from the component to fall back to the default error view.
|
|
98
|
+
*/
|
|
99
|
+
CollectionError?: React.ComponentType<{
|
|
100
|
+
path: string;
|
|
101
|
+
collection: EC;
|
|
102
|
+
parentCollectionIds?: string[];
|
|
103
|
+
error: Error;
|
|
104
|
+
}>;
|
|
105
|
+
/**
|
|
106
|
+
* Use this component to add custom actions to the entity collections
|
|
107
|
+
* toolbar.
|
|
108
|
+
*/
|
|
109
|
+
CollectionActions?: React.ComponentType<CollectionActionsProps<Record<string, unknown>, User, EC> & COL_ACTIONS_PROPS> | React.ComponentType<CollectionActionsProps<Record<string, unknown>, User, EC> & COL_ACTIONS_PROPS>[];
|
|
110
|
+
collectionActionsProps?: COL_ACTIONS_PROPS;
|
|
111
|
+
CollectionActionsStart?: React.ComponentType<CollectionActionsProps<Record<string, unknown>, User, EC> & COL_ACTIONS_START__PROPS> | React.ComponentType<CollectionActionsProps<Record<string, unknown>, User, EC> & COL_ACTIONS_START__PROPS>[];
|
|
112
|
+
collectionActionsStartProps?: COL_ACTIONS_START__PROPS;
|
|
113
|
+
blockSearch?: (props: {
|
|
114
|
+
context: RebaseContext;
|
|
115
|
+
path: string;
|
|
116
|
+
collection: EC;
|
|
117
|
+
parentCollectionIds?: string[];
|
|
118
|
+
}) => boolean;
|
|
119
|
+
showTextSearchBar?: (props: {
|
|
120
|
+
context: RebaseContext;
|
|
121
|
+
path: string;
|
|
122
|
+
collection: EC;
|
|
123
|
+
parentCollectionIds?: string[];
|
|
124
|
+
}) => boolean;
|
|
125
|
+
onTextSearchClick?: (props: {
|
|
126
|
+
context: RebaseContext;
|
|
127
|
+
path: string;
|
|
128
|
+
collection: EC;
|
|
129
|
+
parentCollectionIds?: string[];
|
|
130
|
+
}) => Promise<boolean>;
|
|
131
|
+
/**
|
|
132
|
+
* Use this method to inject widgets to the entity collections header
|
|
133
|
+
* @param props
|
|
134
|
+
*/
|
|
135
|
+
HeaderAction?: React.ComponentType<{
|
|
136
|
+
property: Property;
|
|
137
|
+
propertyKey: string;
|
|
138
|
+
path: string;
|
|
139
|
+
parentCollectionIds: string[];
|
|
140
|
+
onHover: boolean;
|
|
141
|
+
collection: EC;
|
|
142
|
+
tableController: EntityTableController;
|
|
143
|
+
}>;
|
|
144
|
+
/**
|
|
145
|
+
* If you add this callback to your plugin, an add button will be added to the collection table.
|
|
146
|
+
* TODO: Only the first plugin that defines this callback will be used, at the moment.
|
|
147
|
+
*/
|
|
148
|
+
AddColumnComponent?: React.ComponentType<{
|
|
149
|
+
path: string;
|
|
150
|
+
parentCollectionIds: string[];
|
|
151
|
+
collection: EC;
|
|
152
|
+
tableController: EntityTableController;
|
|
153
|
+
}>;
|
|
154
|
+
/**
|
|
155
|
+
* Callback called when columns are reordered via drag and drop.
|
|
156
|
+
* Used by plugins to persist the new column order.
|
|
157
|
+
*/
|
|
158
|
+
onColumnsReorder?: (props: {
|
|
159
|
+
fullPath: string;
|
|
160
|
+
parentCollectionIds: string[];
|
|
161
|
+
collection: EC;
|
|
162
|
+
newPropertiesOrder: string[];
|
|
163
|
+
}) => void;
|
|
164
|
+
/**
|
|
165
|
+
* Callback called when Kanban board columns are reordered via drag and drop.
|
|
166
|
+
* Used by plugins to persist the new Kanban column order.
|
|
167
|
+
*/
|
|
168
|
+
onKanbanColumnsReorder?: (props: {
|
|
169
|
+
fullPath: string;
|
|
170
|
+
parentCollectionIds: string[];
|
|
171
|
+
collection: EC;
|
|
172
|
+
kanbanColumnProperty: string;
|
|
173
|
+
newColumnsOrder: string[];
|
|
174
|
+
}) => void;
|
|
175
|
+
/**
|
|
176
|
+
* Component to render when Kanban view is missing configuration.
|
|
177
|
+
* Used to provide a CTA to open the collection editor to configure Kanban.
|
|
178
|
+
*/
|
|
179
|
+
KanbanSetupComponent?: React.ComponentType<{
|
|
180
|
+
collection: EC;
|
|
181
|
+
fullPath: string;
|
|
182
|
+
parentCollectionIds: string[];
|
|
183
|
+
}>;
|
|
184
|
+
/**
|
|
185
|
+
* Component to render an "Add Column" button at the end of the Kanban board.
|
|
186
|
+
* Used to allow adding new enum values to the column property.
|
|
187
|
+
*/
|
|
188
|
+
AddKanbanColumnComponent?: React.ComponentType<{
|
|
189
|
+
collection: EC;
|
|
190
|
+
fullPath: string;
|
|
191
|
+
parentCollectionIds: string[];
|
|
192
|
+
columnProperty: string;
|
|
193
|
+
}>;
|
|
194
|
+
};
|
|
195
|
+
form?: {
|
|
196
|
+
provider?: {
|
|
197
|
+
Component: React.ComponentType<PropsWithChildren<FORM_PROPS & PluginFormActionProps<User, EC>>>;
|
|
198
|
+
props?: FORM_PROPS;
|
|
199
|
+
};
|
|
200
|
+
/**
|
|
201
|
+
* Add custom actions to the default ones ("Save", "Discard"...)
|
|
202
|
+
*/
|
|
203
|
+
Actions?: React.ComponentType<PluginFormActionProps<User, EC>>;
|
|
204
|
+
/**
|
|
205
|
+
* Add custom actions to the top of the form
|
|
206
|
+
*/
|
|
207
|
+
ActionsTop?: React.ComponentType<PluginFormActionProps<User, EC>>;
|
|
208
|
+
/**
|
|
209
|
+
* Add custom content above the entity title in the form view
|
|
210
|
+
*/
|
|
211
|
+
BeforeTitle?: React.ComponentType<PluginFormActionProps<User, EC>>;
|
|
212
|
+
fieldBuilder?: <T>(props: PluginFieldBuilderParams<Record<string, unknown>, EC>) => React.ComponentType<FieldProps<any>> | null;
|
|
213
|
+
fieldBuilderEnabled?: <T>(props: PluginFieldBuilderParams) => boolean;
|
|
214
|
+
};
|
|
215
|
+
collection?: {
|
|
216
|
+
/**
|
|
217
|
+
* Use this method to modify a single collection before it is rendered.
|
|
218
|
+
* @param collection
|
|
219
|
+
*/
|
|
220
|
+
modifyCollection?: (collection: EntityCollection) => EntityCollection;
|
|
221
|
+
/**
|
|
222
|
+
* Use this method to modify, add or remove collections.
|
|
223
|
+
* @param collections
|
|
224
|
+
*/
|
|
225
|
+
injectCollections?: (collections: EntityCollection[]) => EntityCollection[];
|
|
226
|
+
};
|
|
227
|
+
};
|
|
228
|
+
/**
|
|
229
|
+
* Props passed to the {@link RebasePlugin.homePage.CollectionActions} method.
|
|
230
|
+
* You can use it to add custom actions to the navigation card of each collection.
|
|
231
|
+
*
|
|
232
|
+
* @group Models
|
|
233
|
+
*/
|
|
234
|
+
export interface PluginHomePageActionsProps<EP extends object = object, M extends Record<string, any> = any, USER extends User = User, EC extends EntityCollection<M> = EntityCollection<M>> {
|
|
235
|
+
/**
|
|
236
|
+
* Collection path of this entity. This is the full path, like
|
|
237
|
+
* `users/1234/addresses`
|
|
238
|
+
*/
|
|
239
|
+
slug: string;
|
|
240
|
+
/**
|
|
241
|
+
* The collection configuration
|
|
242
|
+
*/
|
|
243
|
+
collection: EC;
|
|
244
|
+
/**
|
|
245
|
+
* Context of the app status
|
|
246
|
+
*/
|
|
247
|
+
context: RebaseContext<USER>;
|
|
248
|
+
extraProps?: EP;
|
|
249
|
+
}
|
|
250
|
+
export interface PluginFormActionProps<USER extends User = User, EC extends EntityCollection = EntityCollection> {
|
|
251
|
+
entityId?: string | number;
|
|
252
|
+
path: string;
|
|
253
|
+
parentCollectionIds: string[];
|
|
254
|
+
status: EntityStatus;
|
|
255
|
+
collection: EC;
|
|
256
|
+
disabled: boolean;
|
|
257
|
+
formContext?: FormContext;
|
|
258
|
+
context: RebaseContext<USER>;
|
|
259
|
+
openEntityMode: "side_panel" | "full_screen";
|
|
260
|
+
}
|
|
261
|
+
export type PluginFieldBuilderParams<M extends Record<string, any> = any, EC extends EntityCollection<M> = EntityCollection<M>> = {
|
|
262
|
+
fieldConfigId: string;
|
|
263
|
+
propertyKey: string;
|
|
264
|
+
property: Property;
|
|
265
|
+
Field: React.ComponentType<FieldProps<Property, unknown, M>>;
|
|
266
|
+
plugin: RebasePlugin;
|
|
267
|
+
path?: string;
|
|
268
|
+
collection?: EC;
|
|
269
|
+
};
|
|
270
|
+
export interface PluginGenericProps<USER extends User = User> {
|
|
271
|
+
context: RebaseContext<USER>;
|
|
272
|
+
}
|
|
273
|
+
export interface PluginHomePageAdditionalCardsProps<USER extends User = User> {
|
|
274
|
+
group?: string;
|
|
275
|
+
context: RebaseContext<USER>;
|
|
276
|
+
}
|