@rebasepro/types 0.10.0 → 0.10.1-canary.0a881d4
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/dist/call_context.d.ts +51 -0
- package/dist/controllers/auth_state.d.ts +23 -0
- package/dist/controllers/client.d.ts +3 -1
- package/dist/controllers/collection_registry.d.ts +5 -1
- package/dist/controllers/data_driver.d.ts +31 -2
- package/dist/controllers/index.d.ts +1 -10
- package/dist/index.d.ts +1 -1
- package/dist/index.es.js +374 -1
- package/dist/index.es.js.map +1 -1
- package/dist/types/admin_block.d.ts +34 -0
- package/dist/types/backend.d.ts +30 -1
- package/dist/types/channel_bus.d.ts +192 -0
- package/dist/types/collection_contract.d.ts +43 -0
- package/dist/types/collections.d.ts +17 -789
- package/dist/types/component_ref.d.ts +39 -6
- package/dist/types/entity_callbacks.d.ts +1 -1
- package/dist/types/index.d.ts +7 -15
- package/dist/types/project_manifest.d.ts +336 -0
- package/dist/types/properties.d.ts +12 -157
- package/dist/types/schema_version.d.ts +18 -0
- package/dist/types/security_rules.d.ts +320 -0
- package/dist/types/storage_authorize.d.ts +74 -0
- package/package.json +3 -6
- package/src/call_context.ts +56 -0
- package/src/controllers/auth_state.ts +24 -0
- package/src/controllers/client.ts +3 -2
- package/src/controllers/collection_registry.ts +5 -1
- package/src/controllers/data_driver.ts +58 -2
- package/src/controllers/index.ts +1 -10
- package/src/index.ts +1 -1
- package/src/types/admin_block.ts +75 -0
- package/src/types/backend.ts +33 -1
- package/src/types/channel_bus.ts +202 -0
- package/src/types/collection_contract.ts +278 -0
- package/src/types/collections.ts +25 -848
- package/src/types/component_ref.ts +40 -6
- package/src/types/entity_callbacks.ts +1 -1
- package/src/types/index.ts +7 -15
- package/src/types/policy.ts +25 -11
- package/src/types/project_manifest.ts +362 -0
- package/src/types/properties.ts +11 -169
- package/src/types/schema_version.ts +112 -0
- package/src/types/security_rules.ts +344 -0
- package/src/types/storage_authorize.ts +77 -0
- package/dist/controllers/analytics_controller.d.ts +0 -7
- package/dist/controllers/auth.d.ts +0 -110
- package/dist/controllers/customization_controller.d.ts +0 -61
- package/dist/controllers/dialogs_controller.d.ts +0 -36
- package/dist/controllers/local_config_persistence.d.ts +0 -20
- package/dist/controllers/navigation.d.ts +0 -225
- package/dist/controllers/registry.d.ts +0 -80
- package/dist/controllers/side_dialogs_controller.d.ts +0 -67
- package/dist/controllers/side_panel_controller.d.ts +0 -97
- package/dist/controllers/snackbar.d.ts +0 -24
- package/dist/rebase_context.d.ts +0 -110
- package/dist/types/breadcrumbs.d.ts +0 -26
- package/dist/types/builders.d.ts +0 -15
- package/dist/types/component_overrides.d.ts +0 -196
- package/dist/types/entity_actions.d.ts +0 -104
- package/dist/types/entity_link_builder.d.ts +0 -7
- package/dist/types/entity_views.d.ts +0 -95
- package/dist/types/export_import.d.ts +0 -21
- package/dist/types/formex.d.ts +0 -40
- package/dist/types/locales.d.ts +0 -4
- package/dist/types/modify_collections.d.ts +0 -5
- package/dist/types/plugins.d.ts +0 -277
- package/dist/types/property_config.d.ts +0 -74
- package/dist/types/slots.d.ts +0 -262
- package/dist/types/translations.d.ts +0 -915
- package/dist/types/user_management_delegate.d.ts +0 -22
- package/src/controllers/analytics_controller.tsx +0 -57
- package/src/controllers/auth.tsx +0 -121
- package/src/controllers/customization_controller.tsx +0 -72
- package/src/controllers/dialogs_controller.tsx +0 -37
- package/src/controllers/local_config_persistence.tsx +0 -22
- package/src/controllers/navigation.ts +0 -267
- package/src/controllers/registry.ts +0 -95
- package/src/controllers/side_dialogs_controller.tsx +0 -82
- package/src/controllers/side_panel_controller.tsx +0 -112
- package/src/controllers/snackbar.ts +0 -29
- package/src/rebase_context.tsx +0 -130
- package/src/types/breadcrumbs.ts +0 -27
- package/src/types/builders.ts +0 -17
- package/src/types/component_overrides.ts +0 -244
- package/src/types/entity_actions.tsx +0 -125
- package/src/types/entity_link_builder.ts +0 -8
- package/src/types/entity_views.tsx +0 -114
- package/src/types/export_import.ts +0 -26
- package/src/types/formex.ts +0 -45
- package/src/types/locales.ts +0 -81
- package/src/types/modify_collections.tsx +0 -6
- package/src/types/plugins.tsx +0 -346
- package/src/types/property_config.tsx +0 -95
- package/src/types/slots.tsx +0 -307
- package/src/types/translations.ts +0 -1026
- package/src/types/user_management_delegate.ts +0 -23
|
@@ -1,82 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1,112 +0,0 @@
|
|
|
1
|
-
import type { Entity } from "../types/entities";
|
|
2
|
-
import type { CollectionConfig } from "../types/collections";
|
|
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?: CollectionConfig<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
|
-
}
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
/**
|
|
3
|
-
* Possible snackbar types
|
|
4
|
-
* @group Hooks and utilities
|
|
5
|
-
*/
|
|
6
|
-
export type SnackbarMessageType = "success" | "info" | "warning" | "error";
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* Controller to display snackbars
|
|
10
|
-
* @group Hooks and utilities
|
|
11
|
-
*/
|
|
12
|
-
export interface SnackbarController {
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* Close the currently open snackbar
|
|
16
|
-
*/
|
|
17
|
-
close: () => void;
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* Display a new snackbar. You need to specify the type and message.
|
|
21
|
-
* You can optionally specify a title
|
|
22
|
-
*/
|
|
23
|
-
open: (props: {
|
|
24
|
-
type: SnackbarMessageType;
|
|
25
|
-
message: React.ReactNode;
|
|
26
|
-
autoHideDuration?: number;
|
|
27
|
-
}) => void;
|
|
28
|
-
|
|
29
|
-
}
|
package/src/rebase_context.tsx
DELETED
|
@@ -1,130 +0,0 @@
|
|
|
1
|
-
import type { AnalyticsController } from "./controllers/analytics_controller";
|
|
2
|
-
import type { AuthController } from "./controllers/auth";
|
|
3
|
-
import type { StorageSource } from "./controllers/storage";
|
|
4
|
-
import type { UserConfigurationPersistence } from "./controllers/local_config_persistence";
|
|
5
|
-
import type { DatabaseAdmin } from "./types/backend";
|
|
6
|
-
import type { RebaseClient } from "./controllers/client";
|
|
7
|
-
|
|
8
|
-
import type { RebaseSdkData } from "./controllers/data";
|
|
9
|
-
import type { User } from "./users";
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* Context that is provided to entity callbacks (hooks).
|
|
14
|
-
* It contains only the dependencies that are available in both the frontend and the backend.
|
|
15
|
-
* @group Hooks and utilities
|
|
16
|
-
*/
|
|
17
|
-
export type RebaseCallContext<USER extends User = User> = {
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* The Rebase client instance.
|
|
21
|
-
* Available in all entity callbacks (beforeSave, afterSave, afterRead,
|
|
22
|
-
* beforeDelete, afterDelete) and in CollectionActionsProps via context.
|
|
23
|
-
* Use it to call backend functions, access data, storage, etc.
|
|
24
|
-
*
|
|
25
|
-
* @example
|
|
26
|
-
* // In a beforeSave callback:
|
|
27
|
-
* const result = await context.client.functions.invoke('my-function', { ... });
|
|
28
|
-
*
|
|
29
|
-
* @example
|
|
30
|
-
* // In a CollectionAction component:
|
|
31
|
-
* const { client } = props.context;
|
|
32
|
-
* const result = await client.functions.invoke('extract-job', { url });
|
|
33
|
-
*/
|
|
34
|
-
client: RebaseClient;
|
|
35
|
-
|
|
36
|
-
/**
|
|
37
|
-
* Unified data access — `context.data.products.create(...)`.
|
|
38
|
-
* Access any collection as a dynamic property.
|
|
39
|
-
*
|
|
40
|
-
* Returns flat rows (`{ id, ...columns }`), identical to the frontend SDK
|
|
41
|
-
* client — so `context.data` in a backend callback and `client.data` in the
|
|
42
|
-
* frontend behave the same way (`row.title`, never `row.values.title`).
|
|
43
|
-
*/
|
|
44
|
-
data: RebaseSdkData;
|
|
45
|
-
|
|
46
|
-
/**
|
|
47
|
-
* Used storage implementation
|
|
48
|
-
*/
|
|
49
|
-
storageSource: StorageSource;
|
|
50
|
-
|
|
51
|
-
/**
|
|
52
|
-
* Set by the backend when callbacks are executed on the server.
|
|
53
|
-
*/
|
|
54
|
-
user?: USER;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
/**
|
|
58
|
-
* Context that includes the internal controllers and contexts used by the app.
|
|
59
|
-
* Some controllers and context included in this context can be accessed
|
|
60
|
-
* directly from their respective hooks.
|
|
61
|
-
* @group Hooks and utilities
|
|
62
|
-
* @see useRebaseContext
|
|
63
|
-
*/
|
|
64
|
-
export type RebaseContext<USER extends User = User, AuthControllerType extends AuthController<USER> = AuthController<USER>> = RebaseCallContext<USER> & {
|
|
65
|
-
|
|
66
|
-
authController: AuthControllerType;
|
|
67
|
-
|
|
68
|
-
/**
|
|
69
|
-
* Controller mapping strings to collections
|
|
70
|
-
*/
|
|
71
|
-
collectionRegistryController?: import("./controllers/collection_registry").CollectionRegistryController;
|
|
72
|
-
|
|
73
|
-
/**
|
|
74
|
-
* Controller for navigation state
|
|
75
|
-
*/
|
|
76
|
-
navigationStateController?: import("./controllers/navigation").NavigationStateController;
|
|
77
|
-
|
|
78
|
-
/**
|
|
79
|
-
* Controller for side dialogs (side sheets)
|
|
80
|
-
*/
|
|
81
|
-
sideDialogsController?: import("./controllers/side_dialogs_controller").SideDialogsController;
|
|
82
|
-
|
|
83
|
-
/**
|
|
84
|
-
* Controller to open the side panel displaying entity forms
|
|
85
|
-
*/
|
|
86
|
-
sidePanelController?: import("./controllers/side_panel_controller").SidePanelController;
|
|
87
|
-
|
|
88
|
-
/**
|
|
89
|
-
* Controller resolving URLs in the CMS
|
|
90
|
-
*/
|
|
91
|
-
urlController?: import("./controllers/navigation").UrlController;
|
|
92
|
-
|
|
93
|
-
/**
|
|
94
|
-
* Controller to handle simple confirmation and alert dialogs
|
|
95
|
-
*/
|
|
96
|
-
dialogsController?: import("./controllers/dialogs_controller").DialogsController;
|
|
97
|
-
|
|
98
|
-
/**
|
|
99
|
-
* Controller for CMS customization
|
|
100
|
-
*/
|
|
101
|
-
customizationController?: import("./controllers/customization_controller").CustomizationController;
|
|
102
|
-
|
|
103
|
-
/**
|
|
104
|
-
* Controller for effective role
|
|
105
|
-
*/
|
|
106
|
-
effectiveRoleController?: { effectiveRole: string | null, setEffectiveRole: (role: string | null) => void };
|
|
107
|
-
|
|
108
|
-
/**
|
|
109
|
-
* Use this controller to access data stored in the browser for the user
|
|
110
|
-
*/
|
|
111
|
-
userConfigPersistence?: UserConfigurationPersistence;
|
|
112
|
-
|
|
113
|
-
/**
|
|
114
|
-
* Callback to send analytics events
|
|
115
|
-
*/
|
|
116
|
-
analyticsController?: AnalyticsController;
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
/**
|
|
120
|
-
* Administrative database operations (SQL, schema discovery).
|
|
121
|
-
* Only available in developer/admin contexts.
|
|
122
|
-
*/
|
|
123
|
-
databaseAdmin?: DatabaseAdmin;
|
|
124
|
-
|
|
125
|
-
/**
|
|
126
|
-
* Controller for snackbars
|
|
127
|
-
*/
|
|
128
|
-
snackbarController?: import("./controllers/snackbar").SnackbarController;
|
|
129
|
-
|
|
130
|
-
};
|
package/src/types/breadcrumbs.ts
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
export interface BreadcrumbEntry {
|
|
2
|
-
title: string;
|
|
3
|
-
url: string;
|
|
4
|
-
/**
|
|
5
|
-
* Optional entity count for collection breadcrumbs.
|
|
6
|
-
* - undefined: not applicable (e.g., entity breadcrumb, custom view)
|
|
7
|
-
* - null: loading
|
|
8
|
-
* - number: loaded count
|
|
9
|
-
*/
|
|
10
|
-
count?: number | null;
|
|
11
|
-
/**
|
|
12
|
-
* Unique identifier for this breadcrumb (e.g., collection path).
|
|
13
|
-
* Used to update count without replacing entire breadcrumb array.
|
|
14
|
-
*/
|
|
15
|
-
id?: string;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
export interface BreadcrumbsController {
|
|
19
|
-
breadcrumbs: BreadcrumbEntry[];
|
|
20
|
-
set: (props: {
|
|
21
|
-
breadcrumbs: BreadcrumbEntry[];
|
|
22
|
-
}) => void;
|
|
23
|
-
/**
|
|
24
|
-
* Update the count for a specific breadcrumb by ID.
|
|
25
|
-
*/
|
|
26
|
-
updateCount: (id: string, count: number | null | undefined) => void;
|
|
27
|
-
}
|
package/src/types/builders.ts
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import type { AuthController } from "../controllers/auth";
|
|
2
|
-
import type { RebaseData } from "../controllers/data";
|
|
3
|
-
import type { User } from "../users";
|
|
4
|
-
import type { CollectionConfig } from "./collections";
|
|
5
|
-
import type { AppView } from "../controllers/navigation";
|
|
6
|
-
|
|
7
|
-
export type CollectionConfigsBuilder<EC extends CollectionConfig = CollectionConfig> = (params: {
|
|
8
|
-
user: User | null,
|
|
9
|
-
authController: AuthController,
|
|
10
|
-
data: RebaseData
|
|
11
|
-
}) => EC[] | Promise<EC[]>;
|
|
12
|
-
|
|
13
|
-
export type AppViewsBuilder = (params: {
|
|
14
|
-
user: User | null,
|
|
15
|
-
authController: AuthController,
|
|
16
|
-
data: RebaseData
|
|
17
|
-
}) => AppView[] | Promise<AppView[]>;
|
|
@@ -1,244 +0,0 @@
|
|
|
1
|
-
import type React from "react";
|
|
2
|
-
import type { Property } from "./properties";
|
|
3
|
-
import type { WhereFilterOp } from "./filter-operators";
|
|
4
|
-
|
|
5
|
-
// ── Scoped component name unions ──────────────────────────────────────
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* Components that can only be overridden at the **app level** via the
|
|
9
|
-
* `components` prop on `<Rebase>`.
|
|
10
|
-
*
|
|
11
|
-
* These are shell-level / global components that exist outside of any
|
|
12
|
-
* specific collection context.
|
|
13
|
-
*
|
|
14
|
-
* @group Component Overrides
|
|
15
|
-
*/
|
|
16
|
-
export type AppComponentName =
|
|
17
|
-
// ── Shell / Layout ──
|
|
18
|
-
| "Shell.AppBar"
|
|
19
|
-
| "Shell.Drawer"
|
|
20
|
-
| "Shell.DrawerNavigationItem"
|
|
21
|
-
| "Shell.DrawerNavigationGroup"
|
|
22
|
-
|
|
23
|
-
// ── Home Page ──
|
|
24
|
-
| "HomePage"
|
|
25
|
-
| "HomePage.CollectionCard"
|
|
26
|
-
|
|
27
|
-
// ── Auth ──
|
|
28
|
-
| "Auth.LoginView";
|
|
29
|
-
|
|
30
|
-
/**
|
|
31
|
-
* Components that can be overridden at the **collection level**
|
|
32
|
-
* (on an individual collection definition) or at the **app level**
|
|
33
|
-
* (as a default for all collections).
|
|
34
|
-
*
|
|
35
|
-
* When set at the app level, these act as defaults. When set on a
|
|
36
|
-
* specific collection, they override the app-level default for that
|
|
37
|
-
* collection only.
|
|
38
|
-
*
|
|
39
|
-
* @group Component Overrides
|
|
40
|
-
*/
|
|
41
|
-
export type CollectionComponentName =
|
|
42
|
-
// ── Collection View ──
|
|
43
|
-
| "Collection.View"
|
|
44
|
-
| "Collection.Table"
|
|
45
|
-
| "Collection.Card"
|
|
46
|
-
| "Collection.EmptyState"
|
|
47
|
-
| "Collection.Actions"
|
|
48
|
-
| "Collection.FilterField"
|
|
49
|
-
|
|
50
|
-
// ── Entity / Form ──
|
|
51
|
-
| "Entity.Form"
|
|
52
|
-
| "EditView.FormActions"
|
|
53
|
-
| "DetailView"
|
|
54
|
-
| "Entity.SidePanel"
|
|
55
|
-
| "EntityPreview"
|
|
56
|
-
| "Entity.MissingReference";
|
|
57
|
-
|
|
58
|
-
/**
|
|
59
|
-
* All overridable component names across all scopes.
|
|
60
|
-
* @group Component Overrides
|
|
61
|
-
*/
|
|
62
|
-
export type OverridableComponentName = AppComponentName | CollectionComponentName;
|
|
63
|
-
|
|
64
|
-
/**
|
|
65
|
-
* Props received by a filter field component — whether it is a built-in
|
|
66
|
-
* per-type field, a property-level replacement (`property.ui.Filter`), or a
|
|
67
|
-
* `"Collection.FilterField"` override.
|
|
68
|
-
*
|
|
69
|
-
* The `operators` list is **already resolved**: it is the intersection of the
|
|
70
|
-
* engine's {@link DataSourceCapabilities.filterOperators}, the property-type
|
|
71
|
-
* defaults, and any `property.ui.filterOperators` narrowing. A custom field
|
|
72
|
-
* should only offer operators from this list — anything else may throw at
|
|
73
|
-
* query time on engines that cannot execute it.
|
|
74
|
-
*
|
|
75
|
-
* @example
|
|
76
|
-
* ```tsx
|
|
77
|
-
* function MyStatusFilter({ value, setValue, operators }: FilterFieldBindingProps) {
|
|
78
|
-
* return (
|
|
79
|
-
* <select
|
|
80
|
-
* value={value?.[1] as string ?? ""}
|
|
81
|
-
* onChange={e => setValue(e.target.value ? ["==", e.target.value] : undefined)}>
|
|
82
|
-
* <option value="">Any</option>
|
|
83
|
-
* <option value="active">Active</option>
|
|
84
|
-
* <option value="archived">Archived</option>
|
|
85
|
-
* </select>
|
|
86
|
-
* );
|
|
87
|
-
* }
|
|
88
|
-
* ```
|
|
89
|
-
*
|
|
90
|
-
* @group Component Overrides
|
|
91
|
-
*/
|
|
92
|
-
export interface FilterFieldBindingProps {
|
|
93
|
-
/** Key of the property being filtered (the column id). */
|
|
94
|
-
propertyKey: string;
|
|
95
|
-
|
|
96
|
-
/**
|
|
97
|
-
* The resolved property. For array properties this is the **item**
|
|
98
|
-
* property (`property.of`), with `isArray` set to true.
|
|
99
|
-
*/
|
|
100
|
-
property: Property;
|
|
101
|
-
|
|
102
|
-
/** True when the underlying property is an array of `property`. */
|
|
103
|
-
isArray: boolean;
|
|
104
|
-
|
|
105
|
-
/**
|
|
106
|
-
* Operators this field may offer, already narrowed by engine
|
|
107
|
-
* capabilities, property-type defaults, and `property.ui.filterOperators`.
|
|
108
|
-
*/
|
|
109
|
-
operators: readonly WhereFilterOp[];
|
|
110
|
-
|
|
111
|
-
/** Current filter condition for this property, if any. */
|
|
112
|
-
value?: [WhereFilterOp, unknown];
|
|
113
|
-
|
|
114
|
-
/** Set (or clear, with `undefined`) the filter condition. */
|
|
115
|
-
setValue: (value?: [WhereFilterOp, unknown]) => void;
|
|
116
|
-
|
|
117
|
-
/** Display title for the field (usually the property name). */
|
|
118
|
-
title?: string;
|
|
119
|
-
|
|
120
|
-
/**
|
|
121
|
-
* Coordination flags used by fields that open their own dialogs
|
|
122
|
-
* (e.g. the reference picker hides the parent filters dialog).
|
|
123
|
-
*/
|
|
124
|
-
hidden?: boolean;
|
|
125
|
-
setHidden?: (hidden: boolean) => void;
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
// ── Override entry ────────────────────────────────────────────────────
|
|
129
|
-
|
|
130
|
-
/**
|
|
131
|
-
* A single component override entry.
|
|
132
|
-
*
|
|
133
|
-
* - **Eject mode** (default): Your component fully replaces the built-in one.
|
|
134
|
-
* It receives the same props as the original.
|
|
135
|
-
*
|
|
136
|
-
* - **Wrap mode** (`wrap: true`): Your component wraps the original. The
|
|
137
|
-
* built-in component is passed as `OriginalComponent` in props, so you can
|
|
138
|
-
* render it inside your custom layout/logic.
|
|
139
|
-
*
|
|
140
|
-
* @example
|
|
141
|
-
* ```tsx
|
|
142
|
-
* // Eject — full replacement
|
|
143
|
-
* { Component: MyCustomAppBar }
|
|
144
|
-
*
|
|
145
|
-
* // Wrap — augment the original
|
|
146
|
-
* {
|
|
147
|
-
* Component: ({ OriginalComponent, ...props }) => (
|
|
148
|
-
* <div>
|
|
149
|
-
* <MyBanner />
|
|
150
|
-
* <OriginalComponent {...props} />
|
|
151
|
-
* </div>
|
|
152
|
-
* ),
|
|
153
|
-
* wrap: true
|
|
154
|
-
* }
|
|
155
|
-
* ```
|
|
156
|
-
*
|
|
157
|
-
* @group Component Overrides
|
|
158
|
-
*/
|
|
159
|
-
export interface ComponentOverride<P = Record<string, unknown>> {
|
|
160
|
-
/**
|
|
161
|
-
* The replacement component. Receives the same props as the built-in
|
|
162
|
-
* component it replaces.
|
|
163
|
-
*
|
|
164
|
-
* When `wrap` is true, an additional `OriginalComponent` prop is injected
|
|
165
|
-
* containing the default component, allowing you to render it within
|
|
166
|
-
* your custom wrapper.
|
|
167
|
-
*/
|
|
168
|
-
Component: React.ComponentType<P>;
|
|
169
|
-
|
|
170
|
-
/**
|
|
171
|
-
* When true, the original default component is injected as the
|
|
172
|
-
* `OriginalComponent` prop into your Component, enabling the
|
|
173
|
-
* wrapping pattern (similar to Docusaurus's `--wrap` swizzle mode).
|
|
174
|
-
*
|
|
175
|
-
* When false or omitted, your component fully replaces the default
|
|
176
|
-
* (similar to Docusaurus's `--eject` swizzle mode).
|
|
177
|
-
*
|
|
178
|
-
* @default false
|
|
179
|
-
*/
|
|
180
|
-
wrap?: boolean;
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
// ── Override maps by scope ────────────────────────────────────────────
|
|
184
|
-
|
|
185
|
-
/**
|
|
186
|
-
* Collection-scoped overrides. Only collection-level components
|
|
187
|
-
* can be overridden here.
|
|
188
|
-
*
|
|
189
|
-
* Set on a collection's `components` field to customize
|
|
190
|
-
* components for that specific collection.
|
|
191
|
-
*
|
|
192
|
-
* @example
|
|
193
|
-
* ```tsx
|
|
194
|
-
* const productsCollection = {
|
|
195
|
-
* name: "Products",
|
|
196
|
-
* slug: "products",
|
|
197
|
-
* components: {
|
|
198
|
-
* "Entity.Form": { Component: ProductForm },
|
|
199
|
-
* "Collection.EmptyState": { Component: ProductsEmptyState },
|
|
200
|
-
* "Collection.Card": { Component: ProductCard },
|
|
201
|
-
* }
|
|
202
|
-
* };
|
|
203
|
-
* ```
|
|
204
|
-
*
|
|
205
|
-
* @group Component Overrides
|
|
206
|
-
*/
|
|
207
|
-
export type CollectionComponentOverrideMap = {
|
|
208
|
-
[K in CollectionComponentName]?: ComponentOverride;
|
|
209
|
-
};
|
|
210
|
-
|
|
211
|
-
/**
|
|
212
|
-
* App-level overrides. Includes both app-only components (Shell, HomePage, Auth)
|
|
213
|
-
* and collection-level components (as defaults for all collections).
|
|
214
|
-
*
|
|
215
|
-
* Pass this to the `components` prop on `<Rebase>`.
|
|
216
|
-
*
|
|
217
|
-
* Collection-level components set here act as **defaults** — they apply to all
|
|
218
|
-
* collections unless a specific collection overrides them in its own
|
|
219
|
-
* `components`.
|
|
220
|
-
*
|
|
221
|
-
* @example
|
|
222
|
-
* ```tsx
|
|
223
|
-
* <Rebase
|
|
224
|
-
* client={client}
|
|
225
|
-
* components={{
|
|
226
|
-
* // App-level: only available here
|
|
227
|
-
* "Shell.AppBar": { Component: MyAppBar },
|
|
228
|
-
* "HomePage": { Component: MyDashboard },
|
|
229
|
-
*
|
|
230
|
-
* // Collection defaults: apply to ALL collections
|
|
231
|
-
* "EditView.FormActions": {
|
|
232
|
-
* Component: MyFormActions,
|
|
233
|
-
* wrap: true
|
|
234
|
-
* },
|
|
235
|
-
* "Collection.EmptyState": { Component: MyEmptyState },
|
|
236
|
-
* }}
|
|
237
|
-
* />
|
|
238
|
-
* ```
|
|
239
|
-
*
|
|
240
|
-
* @group Component Overrides
|
|
241
|
-
*/
|
|
242
|
-
export type ComponentOverrideMap = {
|
|
243
|
-
[K in OverridableComponentName]?: ComponentOverride;
|
|
244
|
-
};
|