@rebasepro/types 0.0.1-canary.2 → 0.0.1-canary.4829d6e
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 +93 -174
- package/dist/controllers/analytics_controller.d.ts +2 -2
- package/dist/controllers/auth.d.ts +62 -25
- package/dist/controllers/client.d.ts +481 -0
- package/dist/controllers/collection_registry.d.ts +46 -0
- package/dist/controllers/customization_controller.d.ts +22 -11
- package/dist/controllers/data.d.ts +411 -0
- package/dist/controllers/data_driver.d.ts +231 -0
- package/dist/controllers/database_admin.d.ts +11 -0
- package/dist/controllers/effective_role.d.ts +4 -0
- package/dist/controllers/email.d.ts +36 -0
- package/dist/controllers/index.d.ts +12 -5
- package/dist/controllers/local_config_persistence.d.ts +4 -4
- package/dist/controllers/navigation.d.ts +42 -79
- package/dist/controllers/registry.d.ts +80 -0
- package/dist/controllers/{side_entity_controller.d.ts → side_panel_controller.d.ts} +17 -10
- package/dist/controllers/storage.d.ts +63 -26
- package/dist/errors.d.ts +64 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.es.js +550 -108
- package/dist/index.es.js.map +1 -1
- package/dist/index.umd.js +589 -115
- package/dist/index.umd.js.map +1 -1
- package/dist/rebase_context.d.ts +58 -39
- package/dist/types/api_keys.d.ts +57 -0
- package/dist/types/auth_adapter.d.ts +443 -0
- package/dist/types/backend.d.ts +361 -32
- package/dist/types/backup.d.ts +20 -0
- package/dist/types/breadcrumbs.d.ts +26 -0
- package/dist/types/builders.d.ts +15 -0
- package/dist/types/chips.d.ts +1 -1
- package/dist/types/collections.d.ts +735 -412
- package/dist/types/component_overrides.d.ts +196 -0
- package/dist/types/component_ref.d.ts +47 -0
- package/dist/types/cron.d.ts +111 -0
- package/dist/types/data_source.d.ts +153 -0
- package/dist/types/database_adapter.d.ts +111 -0
- package/dist/types/entities.d.ts +33 -28
- package/dist/types/entity_actions.d.ts +24 -18
- package/dist/types/entity_callbacks.d.ts +57 -45
- package/dist/types/entity_link_builder.d.ts +1 -1
- package/dist/types/entity_views.d.ts +95 -0
- package/dist/types/export_import.d.ts +4 -4
- package/dist/types/filter-operators.d.ts +153 -0
- package/dist/{components → types}/formex.d.ts +2 -2
- package/dist/types/index.d.ts +20 -6
- package/dist/types/modify_collections.d.ts +2 -2
- package/dist/types/plugins.d.ts +228 -227
- package/dist/types/policy.d.ts +191 -0
- package/dist/types/properties.d.ts +377 -190
- package/dist/types/property_config.d.ts +18 -12
- package/dist/types/relations.d.ts +3 -3
- package/dist/types/slots.d.ts +262 -0
- package/dist/types/storage_source.d.ts +83 -0
- package/dist/types/translations.d.ts +915 -0
- package/dist/types/user_management_delegate.d.ts +15 -71
- package/dist/types/websockets.d.ts +51 -7
- package/dist/users/index.d.ts +0 -1
- package/dist/users/user.d.ts +30 -10
- package/package.json +94 -131
- package/src/controllers/analytics_controller.tsx +2 -2
- package/src/controllers/auth.tsx +57 -30
- package/src/controllers/client.ts +497 -0
- package/src/controllers/collection_registry.ts +58 -0
- package/src/controllers/customization_controller.tsx +24 -13
- package/src/controllers/data.ts +451 -0
- package/src/controllers/data_driver.ts +290 -0
- package/src/controllers/database_admin.ts +22 -0
- package/src/controllers/effective_role.ts +4 -0
- package/src/controllers/email.ts +38 -0
- package/src/controllers/index.ts +15 -5
- package/src/controllers/local_config_persistence.tsx +4 -4
- package/src/controllers/navigation.ts +46 -96
- package/src/controllers/registry.ts +95 -0
- package/src/controllers/{side_entity_controller.tsx → side_panel_controller.tsx} +18 -10
- package/src/controllers/storage.ts +85 -29
- package/src/errors.ts +80 -0
- package/src/index.ts +1 -1
- package/src/rebase_context.tsx +60 -52
- package/src/types/api_keys.ts +52 -0
- package/src/types/auth_adapter.ts +517 -0
- package/src/types/backend.ts +437 -51
- package/src/types/backup.ts +26 -0
- package/src/types/breadcrumbs.ts +27 -0
- package/src/types/builders.ts +17 -0
- package/src/types/chips.ts +15 -40
- package/src/types/collections.ts +826 -448
- package/src/types/component_overrides.ts +244 -0
- package/src/types/component_ref.ts +57 -0
- package/src/types/cron.ts +159 -0
- package/src/types/data_source.ts +251 -0
- package/src/types/database_adapter.ts +135 -0
- package/src/types/entities.ts +44 -37
- package/src/types/entity_actions.tsx +24 -17
- package/src/types/entity_callbacks.ts +60 -49
- package/src/types/entity_link_builder.ts +1 -1
- package/src/types/entity_views.tsx +114 -0
- package/src/types/export_import.ts +4 -4
- package/src/types/filter-operators.ts +240 -0
- package/src/{components/formex.tsx → types/formex.ts} +2 -3
- package/src/types/index.ts +22 -6
- package/src/types/modify_collections.tsx +2 -2
- package/src/types/plugins.tsx +281 -263
- package/src/types/policy.ts +229 -0
- package/src/types/properties.ts +446 -205
- package/src/types/property_config.tsx +15 -13
- package/src/types/relations.ts +3 -3
- package/src/types/slots.tsx +307 -0
- package/src/types/storage_source.ts +90 -0
- package/src/types/translations.ts +1026 -0
- package/src/types/user_management_delegate.ts +15 -90
- package/src/types/websockets.ts +53 -7
- package/src/users/index.ts +1 -1
- package/src/users/user.ts +33 -10
- package/dist/components/EntityFormActionsProps.d.ts +0 -17
- package/dist/components/EntityFormProps.d.ts +0 -46
- package/dist/components/PropertyPreviewProps.d.ts +0 -50
- package/dist/components/index.d.ts +0 -3
- package/dist/controllers/datasource.d.ts +0 -179
- package/dist/types/entity_overrides.d.ts +0 -5
- package/dist/types/fields.d.ts +0 -221
- package/dist/types/rebase.d.ts +0 -180
- package/dist/users/roles.d.ts +0 -22
- package/src/components/EntityFormActionsProps.tsx +0 -18
- package/src/components/EntityFormProps.tsx +0 -52
- package/src/components/PropertyPreviewProps.tsx +0 -61
- package/src/components/index.ts +0 -3
- package/src/controllers/datasource.ts +0 -218
- package/src/types/entity_overrides.tsx +0 -6
- package/src/types/fields.tsx +0 -298
- package/src/types/rebase.tsx +0 -211
- package/src/users/roles.ts +0 -33
|
@@ -1,218 +0,0 @@
|
|
|
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
|
-
}
|
package/src/types/fields.tsx
DELETED
|
@@ -1,298 +0,0 @@
|
|
|
1
|
-
import { InferPropertyType, Property } from "./properties";
|
|
2
|
-
import { Entity } from "./entities";
|
|
3
|
-
import { FormexController } from "../components/formex";
|
|
4
|
-
import { EntityCollection } from "./collections";
|
|
5
|
-
|
|
6
|
-
export type DefaultFieldConfig =
|
|
7
|
-
| "text_field"
|
|
8
|
-
| "multiline"
|
|
9
|
-
| "markdown"
|
|
10
|
-
| "url"
|
|
11
|
-
| "email"
|
|
12
|
-
| "switch"
|
|
13
|
-
| "select"
|
|
14
|
-
| "multi_select"
|
|
15
|
-
| "user_select"
|
|
16
|
-
| "number_input"
|
|
17
|
-
| "number_select"
|
|
18
|
-
| "multi_number_select"
|
|
19
|
-
| "file_upload"
|
|
20
|
-
| "multi_file_upload"
|
|
21
|
-
| "reference_as_string"
|
|
22
|
-
| "reference"
|
|
23
|
-
| "multi_references"
|
|
24
|
-
| "relation"
|
|
25
|
-
| "date_time"
|
|
26
|
-
| "group"
|
|
27
|
-
| "key_value"
|
|
28
|
-
| "repeat"
|
|
29
|
-
| "custom_array"
|
|
30
|
-
| "block";
|
|
31
|
-
|
|
32
|
-
/**
|
|
33
|
-
* When building a custom field you need to create a React component that takes
|
|
34
|
-
* this interface as props.
|
|
35
|
-
*
|
|
36
|
-
* @group Form custom fields
|
|
37
|
-
*/
|
|
38
|
-
export interface FieldProps<
|
|
39
|
-
P extends Property = Property,
|
|
40
|
-
CustomProps = any,
|
|
41
|
-
M extends Record<string, any> = any> {
|
|
42
|
-
|
|
43
|
-
/**
|
|
44
|
-
* Key of the property
|
|
45
|
-
* E.g. "user.name" for a property with path "user.name"
|
|
46
|
-
*/
|
|
47
|
-
propertyKey: string;
|
|
48
|
-
|
|
49
|
-
/**
|
|
50
|
-
* Current value of this field, inferred from the property type P
|
|
51
|
-
*/
|
|
52
|
-
value: InferPropertyType<P>;
|
|
53
|
-
|
|
54
|
-
/**
|
|
55
|
-
* Set value of field directly
|
|
56
|
-
*/
|
|
57
|
-
setValue: (value: InferPropertyType<P> | null, shouldValidate?: boolean) => void;
|
|
58
|
-
|
|
59
|
-
/**
|
|
60
|
-
* Set value of a different field directly
|
|
61
|
-
* @param propertyKey
|
|
62
|
-
* @param value
|
|
63
|
-
* @param shouldValidate
|
|
64
|
-
*/
|
|
65
|
-
setFieldValue: (propertyKey: string, value: unknown, shouldValidate?: boolean) => void;
|
|
66
|
-
|
|
67
|
-
/**
|
|
68
|
-
* Is the form currently submitting
|
|
69
|
-
*/
|
|
70
|
-
isSubmitting?: boolean;
|
|
71
|
-
|
|
72
|
-
/**
|
|
73
|
-
* Should this field show the error indicator.
|
|
74
|
-
* Note that there might be an error (like an empty field that should be
|
|
75
|
-
* filled) but we don't want to show the error until the user has tried
|
|
76
|
-
* saving.
|
|
77
|
-
*/
|
|
78
|
-
showError?: boolean;
|
|
79
|
-
|
|
80
|
-
/**
|
|
81
|
-
* Is there an error in this field. The error field has the same shape as
|
|
82
|
-
* the field, replacing values with a string containing the error.
|
|
83
|
-
* It takes the value `null` if there is no error
|
|
84
|
-
*/
|
|
85
|
-
error?: string;
|
|
86
|
-
|
|
87
|
-
/**
|
|
88
|
-
* Has this field been touched
|
|
89
|
-
*/
|
|
90
|
-
touched?: boolean;
|
|
91
|
-
|
|
92
|
-
/**
|
|
93
|
-
* Property related to this field, now strongly typed to P
|
|
94
|
-
*/
|
|
95
|
-
property: P;
|
|
96
|
-
|
|
97
|
-
/**
|
|
98
|
-
* Should this field include a description
|
|
99
|
-
*/
|
|
100
|
-
includeDescription?: boolean;
|
|
101
|
-
|
|
102
|
-
/**
|
|
103
|
-
* Flag to indicate that the underlying value has been updated in the
|
|
104
|
-
* datasource
|
|
105
|
-
*/
|
|
106
|
-
underlyingValueHasChanged?: boolean;
|
|
107
|
-
|
|
108
|
-
/**
|
|
109
|
-
* Is this field part of an array
|
|
110
|
-
*/
|
|
111
|
-
partOfArray?: boolean;
|
|
112
|
-
|
|
113
|
-
/**
|
|
114
|
-
* Is this field part of a block
|
|
115
|
-
*/
|
|
116
|
-
partOfBlock?: boolean;
|
|
117
|
-
|
|
118
|
-
/**
|
|
119
|
-
* Display the child properties directly, without being wrapped in an
|
|
120
|
-
* extendable panel. Note that this will also hide the title of this property.
|
|
121
|
-
*/
|
|
122
|
-
minimalistView?: boolean;
|
|
123
|
-
|
|
124
|
-
/**
|
|
125
|
-
* Should this field autofocus on mount
|
|
126
|
-
*/
|
|
127
|
-
autoFocus?: boolean;
|
|
128
|
-
|
|
129
|
-
/**
|
|
130
|
-
* Additional properties set by the developer
|
|
131
|
-
*/
|
|
132
|
-
customProps: CustomProps
|
|
133
|
-
|
|
134
|
-
/**
|
|
135
|
-
* Additional values related to the state of the form or the entity
|
|
136
|
-
*/
|
|
137
|
-
context: FormContext<M>;
|
|
138
|
-
|
|
139
|
-
/**
|
|
140
|
-
* Flag to indicate if this field should be disabled
|
|
141
|
-
*/
|
|
142
|
-
disabled?: boolean;
|
|
143
|
-
|
|
144
|
-
/**
|
|
145
|
-
* Size of the field
|
|
146
|
-
*/
|
|
147
|
-
size?: "small" | "medium" | "large";
|
|
148
|
-
|
|
149
|
-
/**
|
|
150
|
-
* Some properties might change internal state (like expanding a panel).
|
|
151
|
-
* This function should be called when the internal state changes.
|
|
152
|
-
* This is used to preserve state in array containers.
|
|
153
|
-
*
|
|
154
|
-
* @param property
|
|
155
|
-
*/
|
|
156
|
-
onPropertyChange?: (property: Partial<Property>) => void;
|
|
157
|
-
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
/**
|
|
161
|
-
* Context passed to custom fields
|
|
162
|
-
* @group Form custom fields
|
|
163
|
-
*/
|
|
164
|
-
export interface FormContext<M extends Record<string, any> = any> {
|
|
165
|
-
|
|
166
|
-
/**
|
|
167
|
-
* Current values of the entity
|
|
168
|
-
*/
|
|
169
|
-
values: M;
|
|
170
|
-
|
|
171
|
-
/**
|
|
172
|
-
* Update the value of a field
|
|
173
|
-
* @param key
|
|
174
|
-
* @param value
|
|
175
|
-
* @param shouldValidate
|
|
176
|
-
*/
|
|
177
|
-
setFieldValue: (key: string, value: unknown, shouldValidate?: boolean) => void;
|
|
178
|
-
|
|
179
|
-
/**
|
|
180
|
-
* Save the entity.
|
|
181
|
-
*/
|
|
182
|
-
save: (values: M) => void;
|
|
183
|
-
|
|
184
|
-
/**
|
|
185
|
-
* Collection of the entity being modified
|
|
186
|
-
*/
|
|
187
|
-
collection?: EntityCollection<M>;
|
|
188
|
-
|
|
189
|
-
/**
|
|
190
|
-
* Entity id, it can be undefined if it's a new entity
|
|
191
|
-
*/
|
|
192
|
-
entityId?: string | number;
|
|
193
|
-
|
|
194
|
-
/**
|
|
195
|
-
* Path this entity is located at
|
|
196
|
-
*/
|
|
197
|
-
path?: string;
|
|
198
|
-
|
|
199
|
-
status: "new" | "existing" | "copy";
|
|
200
|
-
|
|
201
|
-
entity?: Entity<M>;
|
|
202
|
-
|
|
203
|
-
savingError?: Error;
|
|
204
|
-
|
|
205
|
-
openEntityMode: "side_panel" | "full_screen";
|
|
206
|
-
|
|
207
|
-
/**
|
|
208
|
-
* This is the underlying formex controller that powers the form.
|
|
209
|
-
* If you are in a red only mode, the formex controller is there, but you can't
|
|
210
|
-
* operate with it
|
|
211
|
-
*/
|
|
212
|
-
formex: FormexController<M>;
|
|
213
|
-
|
|
214
|
-
disabled: boolean;
|
|
215
|
-
}
|
|
216
|
-
|
|
217
|
-
/**
|
|
218
|
-
* In case you need to render a field bound to a Property inside your
|
|
219
|
-
* custom field you can use {@link PropertyFieldBinding} with these props.
|
|
220
|
-
* @group Form custom fields
|
|
221
|
-
*/
|
|
222
|
-
export interface PropertyFieldBindingProps<M extends Record<string, any> = any> {
|
|
223
|
-
|
|
224
|
-
/**
|
|
225
|
-
* The key/path of the property, such as `age`. You can use nested and array
|
|
226
|
-
* indexed such as `address.street` or `people[3]`
|
|
227
|
-
*/
|
|
228
|
-
propertyKey: string;
|
|
229
|
-
|
|
230
|
-
/**
|
|
231
|
-
* The CMS property you are binding this field to
|
|
232
|
-
*/
|
|
233
|
-
property: Property;
|
|
234
|
-
|
|
235
|
-
/**
|
|
236
|
-
* The context where this field is being rendered. You get a context as a
|
|
237
|
-
* prop when creating a custom field.
|
|
238
|
-
*/
|
|
239
|
-
context: FormContext<M>;
|
|
240
|
-
|
|
241
|
-
/**
|
|
242
|
-
* Should the description be included in this field
|
|
243
|
-
*/
|
|
244
|
-
includeDescription?: boolean;
|
|
245
|
-
|
|
246
|
-
/**
|
|
247
|
-
* Has the value of this property been updated in the database while this
|
|
248
|
-
* field is being edited
|
|
249
|
-
*/
|
|
250
|
-
underlyingValueHasChanged?: boolean;
|
|
251
|
-
|
|
252
|
-
/**
|
|
253
|
-
* Is this field part of an array
|
|
254
|
-
*/
|
|
255
|
-
partOfArray?: boolean;
|
|
256
|
-
|
|
257
|
-
/**
|
|
258
|
-
* Is this field part of a block
|
|
259
|
-
*/
|
|
260
|
-
partOfBlock?: boolean;
|
|
261
|
-
|
|
262
|
-
/**
|
|
263
|
-
* Display the child properties directly, without being wrapped in an
|
|
264
|
-
* extendable panel. Note that this will also hide the title of this property.
|
|
265
|
-
*/
|
|
266
|
-
minimalistView?: boolean;
|
|
267
|
-
|
|
268
|
-
/**
|
|
269
|
-
* Should the field take focus when rendered. When opening the popup view
|
|
270
|
-
* in table mode, it makes sense to put the focus on the only field rendered.
|
|
271
|
-
*/
|
|
272
|
-
autoFocus?: boolean;
|
|
273
|
-
|
|
274
|
-
/**
|
|
275
|
-
* Should this field be disabled
|
|
276
|
-
*/
|
|
277
|
-
disabled?: boolean;
|
|
278
|
-
|
|
279
|
-
/**
|
|
280
|
-
* Index of the field in the array.
|
|
281
|
-
* Only used when the field is part of an array.
|
|
282
|
-
*/
|
|
283
|
-
index?: number;
|
|
284
|
-
|
|
285
|
-
/**
|
|
286
|
-
* The size of the field
|
|
287
|
-
*/
|
|
288
|
-
size?: "small" | "medium" | "large",
|
|
289
|
-
|
|
290
|
-
/**
|
|
291
|
-
* Some properties might change internal state (like expanding a panel).
|
|
292
|
-
* This function should be called when the internal state changes.
|
|
293
|
-
* This is used to preserve state in array containers.
|
|
294
|
-
*
|
|
295
|
-
* @param property
|
|
296
|
-
*/
|
|
297
|
-
onPropertyChange?: (property: Partial<Property>) => void;
|
|
298
|
-
}
|