@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,298 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export * from "./entities";
|
|
2
|
+
export * from "./chips";
|
|
3
|
+
export * from "./entity_actions";
|
|
4
|
+
export * from "./properties";
|
|
5
|
+
export * from "./collections";
|
|
6
|
+
export * from "./relations";
|
|
7
|
+
|
|
8
|
+
export * from "./locales";
|
|
9
|
+
export * from "./fields";
|
|
10
|
+
export * from "./property_config";
|
|
11
|
+
export * from "./entity_link_builder";
|
|
12
|
+
export * from "./user_management_delegate";
|
|
13
|
+
export * from "./entity_callbacks";
|
|
14
|
+
export * from "./entity_overrides";
|
|
15
|
+
export * from "./plugins";
|
|
16
|
+
export * from "./rebase";
|
|
17
|
+
export * from "./export_import";
|
|
18
|
+
export * from "./modify_collections";
|
|
19
|
+
export * from "./websockets";
|
|
20
|
+
export * from "./backend";
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @group Models
|
|
3
|
+
*/
|
|
4
|
+
export type Locale =
|
|
5
|
+
"af" |
|
|
6
|
+
"ar" |
|
|
7
|
+
"arDZ" |
|
|
8
|
+
"arMA" |
|
|
9
|
+
"arSA" |
|
|
10
|
+
"az" |
|
|
11
|
+
"be" |
|
|
12
|
+
"bg" |
|
|
13
|
+
"bn" |
|
|
14
|
+
"ca" |
|
|
15
|
+
"cs" |
|
|
16
|
+
"cy" |
|
|
17
|
+
"da" |
|
|
18
|
+
"de" |
|
|
19
|
+
"el" |
|
|
20
|
+
"enAU" |
|
|
21
|
+
"enCA" |
|
|
22
|
+
"enGB" |
|
|
23
|
+
"enIN" |
|
|
24
|
+
"enNZ" |
|
|
25
|
+
"enUS" |
|
|
26
|
+
"eo" |
|
|
27
|
+
"es" |
|
|
28
|
+
"et" |
|
|
29
|
+
"eu" |
|
|
30
|
+
"faIR" |
|
|
31
|
+
"fi" |
|
|
32
|
+
"fil" |
|
|
33
|
+
"fr" |
|
|
34
|
+
"frCA" |
|
|
35
|
+
"frCH" |
|
|
36
|
+
"gd" |
|
|
37
|
+
"gl" |
|
|
38
|
+
"gu" |
|
|
39
|
+
"he" |
|
|
40
|
+
"hi" |
|
|
41
|
+
"hr" |
|
|
42
|
+
"hu" |
|
|
43
|
+
"hy" |
|
|
44
|
+
"id" |
|
|
45
|
+
"is" |
|
|
46
|
+
"it" |
|
|
47
|
+
"ja" |
|
|
48
|
+
"ka" |
|
|
49
|
+
"kk" |
|
|
50
|
+
"kn" |
|
|
51
|
+
"ko" |
|
|
52
|
+
"lb" |
|
|
53
|
+
"lt" |
|
|
54
|
+
"lv" |
|
|
55
|
+
"mk" |
|
|
56
|
+
"ms" |
|
|
57
|
+
"mt" |
|
|
58
|
+
"nb" |
|
|
59
|
+
"nl" |
|
|
60
|
+
"nlBE" |
|
|
61
|
+
"nn" |
|
|
62
|
+
"pl" |
|
|
63
|
+
"pt" |
|
|
64
|
+
"ptBR" |
|
|
65
|
+
"ro" |
|
|
66
|
+
"ru" |
|
|
67
|
+
"sk" |
|
|
68
|
+
"sl" |
|
|
69
|
+
"sr" |
|
|
70
|
+
"srLatn" |
|
|
71
|
+
"sv" |
|
|
72
|
+
"ta" |
|
|
73
|
+
"te" |
|
|
74
|
+
"th" |
|
|
75
|
+
"tr" |
|
|
76
|
+
"ug" |
|
|
77
|
+
"uk" |
|
|
78
|
+
"uz" |
|
|
79
|
+
"vi" |
|
|
80
|
+
"zhCN" |
|
|
81
|
+
"zhTW";
|