@rebasepro/types 0.1.0 → 0.2.1
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 +1 -1
- package/README.md +178 -110
- package/dist/controllers/auth.d.ts +9 -8
- package/dist/controllers/client.d.ts +3 -0
- package/dist/index.es.js.map +1 -1
- package/dist/index.umd.js.map +1 -1
- package/dist/types/auth_adapter.d.ts +356 -0
- package/dist/types/collections.d.ts +67 -2
- package/dist/types/database_adapter.d.ts +94 -0
- package/dist/types/entity_actions.d.ts +7 -1
- package/dist/types/entity_callbacks.d.ts +1 -1
- package/dist/types/entity_views.d.ts +36 -1
- package/dist/types/index.d.ts +2 -0
- package/dist/types/plugins.d.ts +1 -1
- package/dist/types/properties.d.ts +24 -5
- package/dist/types/property_config.d.ts +6 -2
- package/dist/types/relations.d.ts +1 -1
- package/dist/types/translations.d.ts +8 -0
- package/dist/users/user.d.ts +5 -0
- package/package.json +13 -10
- package/src/controllers/analytics_controller.d.ts +7 -0
- package/src/controllers/auth.d.ts +125 -0
- package/src/controllers/auth.tsx +2 -5
- package/src/controllers/client.d.ts +183 -0
- package/src/controllers/client.ts +3 -2
- package/src/controllers/collection_registry.d.ts +46 -0
- package/src/controllers/customization_controller.d.ts +60 -0
- package/src/controllers/data.d.ts +168 -0
- package/src/controllers/data_driver.d.ts +195 -0
- package/src/controllers/database_admin.d.ts +11 -0
- package/src/controllers/dialogs_controller.d.ts +36 -0
- package/src/controllers/effective_role.d.ts +4 -0
- package/src/controllers/email.d.ts +34 -0
- package/src/controllers/index.d.ts +18 -0
- package/src/controllers/local_config_persistence.d.ts +20 -0
- package/src/controllers/navigation.d.ts +225 -0
- package/src/controllers/registry.d.ts +62 -0
- package/src/controllers/side_dialogs_controller.d.ts +67 -0
- package/src/controllers/side_entity_controller.d.ts +97 -0
- package/src/controllers/snackbar.d.ts +24 -0
- package/src/controllers/storage.d.ts +171 -0
- package/src/index.d.ts +4 -0
- package/src/rebase_context.d.ts +122 -0
- package/src/types/auth_adapter.d.ts +354 -0
- package/src/types/auth_adapter.ts +410 -0
- package/src/types/backend.d.ts +536 -0
- package/src/types/backend_hooks.d.ts +187 -0
- package/src/types/builders.d.ts +15 -0
- package/src/types/chips.d.ts +5 -0
- package/src/types/collections.d.ts +920 -0
- package/src/types/collections.ts +77 -2
- package/src/types/component_ref.d.ts +47 -0
- package/src/types/cron.d.ts +102 -0
- package/src/types/data_source.d.ts +64 -0
- package/src/types/database_adapter.d.ts +90 -0
- package/src/types/database_adapter.ts +120 -0
- package/src/types/entities.d.ts +145 -0
- package/src/types/entity_actions.d.ts +98 -0
- package/src/types/entity_actions.tsx +8 -1
- package/src/types/entity_callbacks.d.ts +173 -0
- package/src/types/entity_callbacks.ts +1 -1
- package/src/types/entity_link_builder.d.ts +7 -0
- package/src/types/entity_overrides.d.ts +10 -0
- package/src/types/entity_views.d.ts +60 -0
- package/src/types/entity_views.tsx +39 -1
- package/src/types/export_import.d.ts +21 -0
- package/src/types/formex.d.ts +40 -0
- package/src/types/index.d.ts +28 -0
- package/src/types/index.ts +2 -0
- package/src/types/locales.d.ts +4 -0
- package/src/types/modify_collections.d.ts +5 -0
- package/src/types/plugins.d.ts +282 -0
- package/src/types/plugins.tsx +1 -1
- package/src/types/properties.d.ts +1160 -0
- package/src/types/properties.ts +34 -4
- package/src/types/property_config.d.ts +70 -0
- package/src/types/property_config.tsx +6 -3
- package/src/types/relations.d.ts +336 -0
- package/src/types/relations.ts +1 -1
- package/src/types/slots.d.ts +262 -0
- package/src/types/translations.d.ts +882 -0
- package/src/types/translations.ts +11 -0
- package/src/types/user_management_delegate.d.ts +121 -0
- package/src/types/websockets.d.ts +78 -0
- package/src/users/index.d.ts +2 -0
- package/src/users/roles.d.ts +22 -0
- package/src/users/user.d.ts +46 -0
- package/src/users/user.ts +6 -0
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import type { Entity } from "./entities";
|
|
3
|
+
import type { EntityCollection, SelectionController } from "./collections";
|
|
4
|
+
import type { FormContext } from "./entity_views";
|
|
5
|
+
import type { User } from "../users";
|
|
6
|
+
import type { RebaseContext } from "../rebase_context";
|
|
7
|
+
import type { SideEntityController } from "../controllers/side_entity_controller";
|
|
8
|
+
/**
|
|
9
|
+
* An entity action is a custom action that can be performed on an entity.
|
|
10
|
+
* They are displayed in the entity view and in the collection view.
|
|
11
|
+
*/
|
|
12
|
+
export interface EntityAction<M extends Record<string, unknown> = Record<string, unknown>, USER extends User = User> {
|
|
13
|
+
/**
|
|
14
|
+
* Title of the action
|
|
15
|
+
*/
|
|
16
|
+
name: string;
|
|
17
|
+
/**
|
|
18
|
+
* Key of the action. You only need to provide this if you want to
|
|
19
|
+
* override the default actions, or if you are not passing the action
|
|
20
|
+
* directly to the `entityActions` prop of a collection.
|
|
21
|
+
* You can define your actions at the app level, in which case you
|
|
22
|
+
* must provide a key.
|
|
23
|
+
* The default actions are:
|
|
24
|
+
* - edit
|
|
25
|
+
* - delete
|
|
26
|
+
* - copy
|
|
27
|
+
*/
|
|
28
|
+
key?: string;
|
|
29
|
+
/**
|
|
30
|
+
* Icon of the action
|
|
31
|
+
*/
|
|
32
|
+
icon?: React.ReactElement;
|
|
33
|
+
/**
|
|
34
|
+
* Callback when the action is clicked
|
|
35
|
+
* @param props
|
|
36
|
+
*/
|
|
37
|
+
onClick(props: EntityActionClickProps<M, USER>): Promise<void> | void;
|
|
38
|
+
/**
|
|
39
|
+
* Optional callback in case you want to disable the action
|
|
40
|
+
* @param props
|
|
41
|
+
*/
|
|
42
|
+
isEnabled?(props: EntityActionClickProps<M, USER>): boolean;
|
|
43
|
+
/**
|
|
44
|
+
* Show this action collapsed in the menu of the collection view.
|
|
45
|
+
* Defaults to true
|
|
46
|
+
* If false, the action will be shown in the menu
|
|
47
|
+
*/
|
|
48
|
+
collapsed?: boolean;
|
|
49
|
+
/**
|
|
50
|
+
* Show this action in the form, defaults to true
|
|
51
|
+
*/
|
|
52
|
+
includeInForm?: boolean;
|
|
53
|
+
}
|
|
54
|
+
export type EntityActionClickProps<M extends Record<string, unknown>, USER extends User = User> = {
|
|
55
|
+
entity?: Entity<M>;
|
|
56
|
+
context: RebaseContext<USER>;
|
|
57
|
+
path?: string;
|
|
58
|
+
collection?: EntityCollection<M>;
|
|
59
|
+
/**
|
|
60
|
+
* Optional form context, present if the action is being called from a form.
|
|
61
|
+
* This allows you to access the form state and methods, including modifying the form values.
|
|
62
|
+
*/
|
|
63
|
+
formContext?: FormContext;
|
|
64
|
+
/**
|
|
65
|
+
* Present if this actions is being called from a side dialog only
|
|
66
|
+
*/
|
|
67
|
+
sideEntityController?: SideEntityController;
|
|
68
|
+
/**
|
|
69
|
+
* Is the action being called from the collection view or from the entity form view?
|
|
70
|
+
*/
|
|
71
|
+
view: "collection" | "form";
|
|
72
|
+
/**
|
|
73
|
+
* If the action is rendered in the form, is it open in a side panel or full screen?
|
|
74
|
+
*/
|
|
75
|
+
openEntityMode: "side_panel" | "full_screen" | "split";
|
|
76
|
+
/**
|
|
77
|
+
* Optional selection controller, present if the action is being called from a collection view
|
|
78
|
+
*/
|
|
79
|
+
selectionController?: SelectionController;
|
|
80
|
+
/**
|
|
81
|
+
* Optional highlight function to highlight the entity in the collection view
|
|
82
|
+
* @param entity
|
|
83
|
+
*/
|
|
84
|
+
highlightEntity?: (entity: Entity<Record<string, unknown>>) => void;
|
|
85
|
+
/**
|
|
86
|
+
* Optional unhighlight function to remove the highlight from the entity in the collection view
|
|
87
|
+
* @param entity
|
|
88
|
+
*/
|
|
89
|
+
unhighlightEntity?: (entity: Entity<Record<string, unknown>>) => void;
|
|
90
|
+
/**
|
|
91
|
+
* Optional function to navigate back (e.g. when deleting an entity or navigating from a form)
|
|
92
|
+
*/
|
|
93
|
+
navigateBack?: () => void;
|
|
94
|
+
/**
|
|
95
|
+
* Callback to be called when the collection changes, e.g. after an entity is deleted or created.
|
|
96
|
+
*/
|
|
97
|
+
onCollectionChange?: () => void;
|
|
98
|
+
};
|
|
@@ -46,6 +46,13 @@ export interface EntityAction<M extends Record<string, unknown> = Record<string,
|
|
|
46
46
|
*/
|
|
47
47
|
isEnabled?(props: EntityActionClickProps<M, USER>): boolean;
|
|
48
48
|
|
|
49
|
+
/**
|
|
50
|
+
* When true, this action is rendered inline on each row in the list view.
|
|
51
|
+
* By default, entity actions only appear in the table view and entity form.
|
|
52
|
+
* Use this for actions that should be easily accessible regardless of view mode.
|
|
53
|
+
*/
|
|
54
|
+
showActionsInListView?: boolean;
|
|
55
|
+
|
|
49
56
|
/**
|
|
50
57
|
* Show this action collapsed in the menu of the collection view.
|
|
51
58
|
* Defaults to true
|
|
@@ -86,7 +93,7 @@ export type EntityActionClickProps<M extends Record<string, unknown>, USER exten
|
|
|
86
93
|
/**
|
|
87
94
|
* If the action is rendered in the form, is it open in a side panel or full screen?
|
|
88
95
|
*/
|
|
89
|
-
openEntityMode: "side_panel" | "full_screen" | "split";
|
|
96
|
+
openEntityMode: "side_panel" | "full_screen" | "split" | "dialog";
|
|
90
97
|
|
|
91
98
|
/**
|
|
92
99
|
* Optional selection controller, present if the action is being called from a collection view
|
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
import type { EntityCollection } from "./collections";
|
|
2
|
+
import type { Entity, EntityStatus, EntityValues } from "./entities";
|
|
3
|
+
import type { User } from "../users";
|
|
4
|
+
import type { RebaseCallContext } from "../rebase_context";
|
|
5
|
+
/**
|
|
6
|
+
* This interface defines all the callbacks that can be used when an entity
|
|
7
|
+
* is being created, updated or deleted.
|
|
8
|
+
* Useful for adding your own logic or blocking the execution of the operation.
|
|
9
|
+
* @group Models
|
|
10
|
+
*/
|
|
11
|
+
export type EntityCallbacks<M extends Record<string, unknown> = Record<string, unknown>, USER extends User = User> = {
|
|
12
|
+
/**
|
|
13
|
+
* Callback used after fetching data
|
|
14
|
+
* @param props
|
|
15
|
+
*/
|
|
16
|
+
afterRead?(props: EntityAfterReadProps<M, USER>): Promise<Entity<M>> | Entity<M>;
|
|
17
|
+
/**
|
|
18
|
+
* Callback used before saving, you need to return the values that will get
|
|
19
|
+
* saved. If you throw an error in this method the process stops, and an
|
|
20
|
+
* error snackbar gets displayed.
|
|
21
|
+
* This runs after schema validation.
|
|
22
|
+
* @param props
|
|
23
|
+
*/
|
|
24
|
+
beforeSave?(props: EntityBeforeSaveProps<M, USER>): Promise<Partial<EntityValues<M>>> | Partial<EntityValues<M>>;
|
|
25
|
+
/**
|
|
26
|
+
* Callback used when save is successful
|
|
27
|
+
* @param props
|
|
28
|
+
*/
|
|
29
|
+
afterSave?(props: EntityAfterSaveProps<M, USER>): Promise<void> | void;
|
|
30
|
+
/**
|
|
31
|
+
* Callback used when saving fails
|
|
32
|
+
* @param props
|
|
33
|
+
*/
|
|
34
|
+
afterSaveError?(props: EntityAfterSaveErrorProps<M, USER>): Promise<void> | void;
|
|
35
|
+
/**
|
|
36
|
+
* Callback used before the entity is deleted.
|
|
37
|
+
* If you throw an error in this method the process stops, and an
|
|
38
|
+
* error snackbar gets displayed.
|
|
39
|
+
*
|
|
40
|
+
* @param props
|
|
41
|
+
*/
|
|
42
|
+
beforeDelete?(props: EntityBeforeDeleteProps<M, USER>): Promise<boolean | void> | boolean | void;
|
|
43
|
+
/**
|
|
44
|
+
* Callback used after the entity is deleted.
|
|
45
|
+
*
|
|
46
|
+
* @param props
|
|
47
|
+
*/
|
|
48
|
+
afterDelete?(props: EntityAfterDeleteProps<M, USER>): void;
|
|
49
|
+
};
|
|
50
|
+
/**
|
|
51
|
+
* Parameters passed to hooks when an entity is fetched
|
|
52
|
+
* @group Models
|
|
53
|
+
*/
|
|
54
|
+
export interface EntityAfterReadProps<M extends Record<string, unknown> = Record<string, unknown>, USER extends User = User> {
|
|
55
|
+
/**
|
|
56
|
+
* Collection of the entity
|
|
57
|
+
*/
|
|
58
|
+
collection: EntityCollection<M>;
|
|
59
|
+
/**
|
|
60
|
+
* Full path of the CMS where this collection is being fetched.
|
|
61
|
+
* Might contain unresolved aliases.
|
|
62
|
+
*/
|
|
63
|
+
path: string;
|
|
64
|
+
/**
|
|
65
|
+
* Fetched entity
|
|
66
|
+
*/
|
|
67
|
+
entity: Entity<M>;
|
|
68
|
+
/**
|
|
69
|
+
* Context of the app status
|
|
70
|
+
*/
|
|
71
|
+
context: RebaseCallContext<USER>;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Parameters passed to hooks before an entity is saved
|
|
75
|
+
* @group Models
|
|
76
|
+
*/
|
|
77
|
+
export type EntityBeforeSaveProps<M extends Record<string, unknown> = Record<string, unknown>, USER extends User = User> = Omit<EntityAfterSaveProps<M, USER>, "entityId"> & {
|
|
78
|
+
entityId?: string | number;
|
|
79
|
+
};
|
|
80
|
+
/**
|
|
81
|
+
* Parameters passed to hooks before an entity is saved
|
|
82
|
+
* @group Models
|
|
83
|
+
*/
|
|
84
|
+
export type EntityAfterSaveErrorProps<M extends Record<string, unknown> = Record<string, unknown>, USER extends User = User> = Omit<EntityAfterSaveProps<M, USER>, "entityId"> & {
|
|
85
|
+
entityId?: string | number;
|
|
86
|
+
};
|
|
87
|
+
/**
|
|
88
|
+
* Parameters passed to hooks when an entity is saved
|
|
89
|
+
* @group Models
|
|
90
|
+
*/
|
|
91
|
+
export interface EntityAfterSaveProps<M extends Record<string, unknown> = Record<string, unknown>, USER extends User = User> {
|
|
92
|
+
/**
|
|
93
|
+
* Resolved collection of the entity
|
|
94
|
+
*/
|
|
95
|
+
collection: EntityCollection<M>;
|
|
96
|
+
/**
|
|
97
|
+
* Full path of the CMS where this entity is being saved.
|
|
98
|
+
* Might contain unresolved aliases.
|
|
99
|
+
*/
|
|
100
|
+
path: string;
|
|
101
|
+
/**
|
|
102
|
+
* ID of the entity
|
|
103
|
+
*/
|
|
104
|
+
entityId: string | number;
|
|
105
|
+
/**
|
|
106
|
+
* Values being saved
|
|
107
|
+
*/
|
|
108
|
+
values: Partial<EntityValues<M>>;
|
|
109
|
+
/**
|
|
110
|
+
* Previous values
|
|
111
|
+
*/
|
|
112
|
+
previousValues?: Partial<EntityValues<M>>;
|
|
113
|
+
/**
|
|
114
|
+
* New or existing entity
|
|
115
|
+
*/
|
|
116
|
+
status: EntityStatus;
|
|
117
|
+
/**
|
|
118
|
+
* Context of the app status
|
|
119
|
+
*/
|
|
120
|
+
context: RebaseCallContext<USER>;
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* Parameters passed to hooks when an entity is deleted
|
|
124
|
+
* @group Models
|
|
125
|
+
*/
|
|
126
|
+
export interface EntityBeforeDeleteProps<M extends Record<string, unknown> = Record<string, unknown>, USER extends User = User> {
|
|
127
|
+
/**
|
|
128
|
+
* collection of the entity being deleted
|
|
129
|
+
*/
|
|
130
|
+
collection: EntityCollection<M>;
|
|
131
|
+
/**
|
|
132
|
+
* Path of the parent collection
|
|
133
|
+
*/
|
|
134
|
+
path: string;
|
|
135
|
+
/**
|
|
136
|
+
* Deleted entity id
|
|
137
|
+
*/
|
|
138
|
+
entityId: string | number;
|
|
139
|
+
/**
|
|
140
|
+
* Deleted entity
|
|
141
|
+
*/
|
|
142
|
+
entity: Entity<M>;
|
|
143
|
+
/**
|
|
144
|
+
* Context of the app status
|
|
145
|
+
*/
|
|
146
|
+
context: RebaseCallContext<USER>;
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
149
|
+
* Parameters passed to hooks after an entity is deleted
|
|
150
|
+
* @group Models
|
|
151
|
+
*/
|
|
152
|
+
export interface EntityAfterDeleteProps<M extends Record<string, unknown> = Record<string, unknown>, USER extends User = User> {
|
|
153
|
+
/**
|
|
154
|
+
* collection of the entity being deleted
|
|
155
|
+
*/
|
|
156
|
+
collection: EntityCollection<M>;
|
|
157
|
+
/**
|
|
158
|
+
* Path of the parent collection
|
|
159
|
+
*/
|
|
160
|
+
path: string;
|
|
161
|
+
/**
|
|
162
|
+
* Deleted entity id
|
|
163
|
+
*/
|
|
164
|
+
entityId: string | number;
|
|
165
|
+
/**
|
|
166
|
+
* Deleted entity
|
|
167
|
+
*/
|
|
168
|
+
entity: Entity<M>;
|
|
169
|
+
/**
|
|
170
|
+
* Context of the app status
|
|
171
|
+
*/
|
|
172
|
+
context: RebaseCallContext<USER>;
|
|
173
|
+
}
|
|
@@ -50,7 +50,7 @@ export type EntityCallbacks<M extends Record<string, unknown> = Record<string, u
|
|
|
50
50
|
*
|
|
51
51
|
* @param props
|
|
52
52
|
*/
|
|
53
|
-
beforeDelete?(props: EntityBeforeDeleteProps<M, USER>): void;
|
|
53
|
+
beforeDelete?(props: EntityBeforeDeleteProps<M, USER>): Promise<boolean | void> | boolean | void;
|
|
54
54
|
|
|
55
55
|
/**
|
|
56
56
|
* Callback used after the entity is deleted.
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { DataDriver } from "../controllers/data_driver";
|
|
2
|
+
import type { StorageSource } from "../controllers/storage";
|
|
3
|
+
export type EntityOverrides = {
|
|
4
|
+
/**
|
|
5
|
+
* Internal driver override for this collection.
|
|
6
|
+
* Used by the CMS engine to route data operations.
|
|
7
|
+
*/
|
|
8
|
+
driver?: DataDriver;
|
|
9
|
+
storageSource?: StorageSource;
|
|
10
|
+
};
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import type { Entity, EntityValues } from "./entities";
|
|
3
|
+
import type { EntityCollection } from "./collections";
|
|
4
|
+
import type { FormexController } from "./formex";
|
|
5
|
+
import type { ComponentRef } from "./component_ref";
|
|
6
|
+
/**
|
|
7
|
+
* Context passed to custom fields and entity views.
|
|
8
|
+
* @group Form custom fields
|
|
9
|
+
*/
|
|
10
|
+
export interface FormContext<M extends Record<string, unknown> = Record<string, unknown>> {
|
|
11
|
+
/**
|
|
12
|
+
* Current values of the entity
|
|
13
|
+
*/
|
|
14
|
+
values: M;
|
|
15
|
+
/**
|
|
16
|
+
* Update the value of a field
|
|
17
|
+
*/
|
|
18
|
+
setFieldValue: (key: string, value: unknown, shouldValidate?: boolean) => void;
|
|
19
|
+
/**
|
|
20
|
+
* Save the entity.
|
|
21
|
+
*/
|
|
22
|
+
save: (values: M) => void;
|
|
23
|
+
/**
|
|
24
|
+
* Collection of the entity being modified
|
|
25
|
+
*/
|
|
26
|
+
collection?: EntityCollection<M>;
|
|
27
|
+
/**
|
|
28
|
+
* Entity id, it can be undefined if it's a new entity
|
|
29
|
+
*/
|
|
30
|
+
entityId?: string | number;
|
|
31
|
+
/**
|
|
32
|
+
* Path this entity is located at
|
|
33
|
+
*/
|
|
34
|
+
path?: string;
|
|
35
|
+
status: "new" | "existing" | "copy";
|
|
36
|
+
entity?: Entity<M>;
|
|
37
|
+
savingError?: Error;
|
|
38
|
+
openEntityMode: "side_panel" | "full_screen" | "split";
|
|
39
|
+
/**
|
|
40
|
+
* The underlying formex controller that powers the form.
|
|
41
|
+
*/
|
|
42
|
+
formex: FormexController<M>;
|
|
43
|
+
disabled: boolean;
|
|
44
|
+
}
|
|
45
|
+
export type EntityCustomView<M extends Record<string, unknown> = Record<string, unknown>> = {
|
|
46
|
+
key: string;
|
|
47
|
+
name: string;
|
|
48
|
+
tabComponent?: React.ReactNode;
|
|
49
|
+
includeActions?: boolean | "bottom";
|
|
50
|
+
Builder?: ComponentRef<EntityCustomViewParams<M>>;
|
|
51
|
+
position?: "start" | "end";
|
|
52
|
+
};
|
|
53
|
+
export interface EntityCustomViewParams<M extends Record<string, unknown> = Record<string, unknown>> {
|
|
54
|
+
collection: EntityCollection<M>;
|
|
55
|
+
entity?: Entity<M>;
|
|
56
|
+
modifiedValues?: EntityValues<M>;
|
|
57
|
+
formContext: FormContext<M>;
|
|
58
|
+
parentCollectionSlugs?: string[];
|
|
59
|
+
parentEntityIds?: string[];
|
|
60
|
+
}
|
|
@@ -46,7 +46,7 @@ export interface FormContext<M extends Record<string, unknown> = Record<string,
|
|
|
46
46
|
|
|
47
47
|
savingError?: Error;
|
|
48
48
|
|
|
49
|
-
openEntityMode: "side_panel" | "full_screen" | "split";
|
|
49
|
+
openEntityMode: "side_panel" | "full_screen" | "split" | "dialog";
|
|
50
50
|
|
|
51
51
|
/**
|
|
52
52
|
* The underlying formex controller that powers the form.
|
|
@@ -54,6 +54,12 @@ export interface FormContext<M extends Record<string, unknown> = Record<string,
|
|
|
54
54
|
formex: FormexController<M>;
|
|
55
55
|
|
|
56
56
|
disabled: boolean;
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Whether the form context is in read-only detail view mode.
|
|
60
|
+
* Custom entity views can use this to adjust their rendering.
|
|
61
|
+
*/
|
|
62
|
+
readOnly?: boolean;
|
|
57
63
|
}
|
|
58
64
|
|
|
59
65
|
|
|
@@ -74,3 +80,35 @@ export interface EntityCustomViewParams<M extends Record<string, unknown> = Reco
|
|
|
74
80
|
parentCollectionSlugs?: string[];
|
|
75
81
|
parentEntityIds?: string[];
|
|
76
82
|
}
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* Configuration for customizing the read-only detail view of an entity.
|
|
86
|
+
* Only used when `defaultEntityAction` is set to `"view"` on the collection.
|
|
87
|
+
* @group Models
|
|
88
|
+
*/
|
|
89
|
+
export type EntityDetailViewConfig<M extends Record<string, unknown> = Record<string, unknown>> = {
|
|
90
|
+
/**
|
|
91
|
+
* Custom component rendered above the property display in the detail view.
|
|
92
|
+
*/
|
|
93
|
+
Header?: ComponentRef<EntityDetailViewParams<M>>;
|
|
94
|
+
/**
|
|
95
|
+
* Custom component rendered below the property display in the detail view.
|
|
96
|
+
*/
|
|
97
|
+
Footer?: ComponentRef<EntityDetailViewParams<M>>;
|
|
98
|
+
/**
|
|
99
|
+
* Completely replace the default detail view with a custom component.
|
|
100
|
+
* When set, Header and Footer are ignored.
|
|
101
|
+
*/
|
|
102
|
+
Builder?: ComponentRef<EntityDetailViewParams<M>>;
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* Props passed to detail view customization components (Header, Footer, Builder).
|
|
107
|
+
* @group Models
|
|
108
|
+
*/
|
|
109
|
+
export interface EntityDetailViewParams<M extends Record<string, unknown> = Record<string, unknown>> {
|
|
110
|
+
collection: EntityCollection<M>;
|
|
111
|
+
entity: Entity<M>;
|
|
112
|
+
path: string;
|
|
113
|
+
onEditClick: () => void;
|
|
114
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { Entity } from "./entities";
|
|
2
|
+
import type { User } from "../users";
|
|
3
|
+
import type { RebaseContext } from "../rebase_context";
|
|
4
|
+
/**
|
|
5
|
+
* You can use this configuration to add additional fields to the data
|
|
6
|
+
* exports
|
|
7
|
+
* @group Models
|
|
8
|
+
*/
|
|
9
|
+
export interface ExportConfig<USER extends User = User> {
|
|
10
|
+
additionalFields: ExportMappingFunction<USER>[];
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* @group Models
|
|
14
|
+
*/
|
|
15
|
+
export interface ExportMappingFunction<USER extends User = User> {
|
|
16
|
+
key: string;
|
|
17
|
+
builder: ({ entity, context }: {
|
|
18
|
+
entity: Entity<any>;
|
|
19
|
+
context: RebaseContext<USER>;
|
|
20
|
+
}) => Promise<string> | string;
|
|
21
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import React, { FormEvent } from "react";
|
|
2
|
+
export type FormexController<T = any> = {
|
|
3
|
+
values: T;
|
|
4
|
+
initialValues: T;
|
|
5
|
+
setValues: (values: T) => void;
|
|
6
|
+
setFieldValue: (key: string, value: unknown, shouldValidate?: boolean) => void;
|
|
7
|
+
touched: Record<string, boolean>;
|
|
8
|
+
setFieldTouched: (key: string, touched: boolean, shouldValidate?: boolean) => void;
|
|
9
|
+
setTouched: (touched: Record<string, boolean>) => void;
|
|
10
|
+
dirty: boolean;
|
|
11
|
+
setDirty: (dirty: boolean) => void;
|
|
12
|
+
setSubmitCount: (submitCount: number) => void;
|
|
13
|
+
errors: Record<string, string>;
|
|
14
|
+
setFieldError: (key: string, error?: string) => void;
|
|
15
|
+
handleChange: (event: React.SyntheticEvent) => void;
|
|
16
|
+
handleBlur: (event: React.FocusEvent) => void;
|
|
17
|
+
handleSubmit: (event?: FormEvent<HTMLFormElement>) => void;
|
|
18
|
+
validate: () => void;
|
|
19
|
+
resetForm: (props?: FormexResetProps<T>) => void;
|
|
20
|
+
submitCount: number;
|
|
21
|
+
isSubmitting: boolean;
|
|
22
|
+
setSubmitting: (isSubmitting: boolean) => void;
|
|
23
|
+
isValidating: boolean;
|
|
24
|
+
/**
|
|
25
|
+
* The version of the form. This is incremented every time the form is reset
|
|
26
|
+
* or the form is submitted.
|
|
27
|
+
*/
|
|
28
|
+
version: number;
|
|
29
|
+
debugId?: string;
|
|
30
|
+
undo: () => void;
|
|
31
|
+
redo: () => void;
|
|
32
|
+
canUndo: boolean;
|
|
33
|
+
canRedo: boolean;
|
|
34
|
+
};
|
|
35
|
+
export type FormexResetProps<T = any> = {
|
|
36
|
+
values?: T;
|
|
37
|
+
submitCount?: number;
|
|
38
|
+
errors?: Record<string, string>;
|
|
39
|
+
touched?: Record<string, boolean>;
|
|
40
|
+
};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
export * from "./entities";
|
|
2
|
+
export * from "./chips";
|
|
3
|
+
export * from "./properties";
|
|
4
|
+
export * from "./collections";
|
|
5
|
+
export * from "./relations";
|
|
6
|
+
export * from "./locales";
|
|
7
|
+
export * from "./entity_link_builder";
|
|
8
|
+
export * from "./user_management_delegate";
|
|
9
|
+
export * from "./entity_callbacks";
|
|
10
|
+
export * from "./entity_overrides";
|
|
11
|
+
export * from "./export_import";
|
|
12
|
+
export * from "./modify_collections";
|
|
13
|
+
export * from "./formex";
|
|
14
|
+
export * from "./websockets";
|
|
15
|
+
export * from "./backend";
|
|
16
|
+
export * from "./translations";
|
|
17
|
+
export * from "./plugins";
|
|
18
|
+
export * from "./builders";
|
|
19
|
+
export * from "./slots";
|
|
20
|
+
export * from "./entity_actions";
|
|
21
|
+
export * from "./property_config";
|
|
22
|
+
export * from "./entity_views";
|
|
23
|
+
export * from "./data_source";
|
|
24
|
+
export * from "./cron";
|
|
25
|
+
export * from "./backend_hooks";
|
|
26
|
+
export * from "./component_ref";
|
|
27
|
+
export * from "./auth_adapter";
|
|
28
|
+
export * from "./database_adapter";
|
package/src/types/index.ts
CHANGED
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @group Models
|
|
3
|
+
*/
|
|
4
|
+
export type Locale = "af" | "ar" | "arDZ" | "arMA" | "arSA" | "az" | "be" | "bg" | "bn" | "ca" | "cs" | "cy" | "da" | "de" | "el" | "enAU" | "enCA" | "enGB" | "enIN" | "enNZ" | "enUS" | "eo" | "es" | "et" | "eu" | "faIR" | "fi" | "fil" | "fr" | "frCA" | "frCH" | "gd" | "gl" | "gu" | "he" | "hi" | "hr" | "hu" | "hy" | "id" | "is" | "it" | "ja" | "ka" | "kk" | "kn" | "ko" | "lb" | "lt" | "lv" | "mk" | "ms" | "mt" | "nb" | "nl" | "nlBE" | "nn" | "pl" | "pt" | "ptBR" | "ro" | "ru" | "sk" | "sl" | "sr" | "srLatn" | "sv" | "ta" | "te" | "th" | "tr" | "ug" | "uk" | "uz" | "vi" | "zhCN" | "zhTW";
|