@rebasepro/admin-types 0.10.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.
Files changed (72) hide show
  1. package/LICENSE +21 -0
  2. package/dist/admin_collection.d.ts +464 -0
  3. package/dist/augment.d.ts +66 -0
  4. package/dist/collections.d.ts +226 -0
  5. package/dist/controllers/analytics_controller.d.ts +7 -0
  6. package/dist/controllers/auth.d.ts +110 -0
  7. package/dist/controllers/customization_controller.d.ts +61 -0
  8. package/dist/controllers/dialogs_controller.d.ts +36 -0
  9. package/dist/controllers/index.d.ts +10 -0
  10. package/dist/controllers/local_config_persistence.d.ts +20 -0
  11. package/dist/controllers/navigation.d.ts +225 -0
  12. package/dist/controllers/registry.d.ts +80 -0
  13. package/dist/controllers/side_dialogs_controller.d.ts +67 -0
  14. package/dist/controllers/side_panel_controller.d.ts +97 -0
  15. package/dist/controllers/snackbar.d.ts +24 -0
  16. package/dist/index.d.ts +18 -0
  17. package/dist/index.es.js +92 -0
  18. package/dist/index.es.js.map +1 -0
  19. package/dist/react_component_ref.d.ts +43 -0
  20. package/dist/rebase_context.d.ts +68 -0
  21. package/dist/types/breadcrumbs.d.ts +26 -0
  22. package/dist/types/builders.d.ts +15 -0
  23. package/dist/types/component_overrides.d.ts +196 -0
  24. package/dist/types/entity_actions.d.ts +105 -0
  25. package/dist/types/entity_link_builder.d.ts +7 -0
  26. package/dist/types/entity_views.d.ts +95 -0
  27. package/dist/types/export_import.d.ts +21 -0
  28. package/dist/types/formex.d.ts +40 -0
  29. package/dist/types/index.d.ts +15 -0
  30. package/dist/types/locales.d.ts +4 -0
  31. package/dist/types/modify_collections.d.ts +5 -0
  32. package/dist/types/plugins.d.ts +277 -0
  33. package/dist/types/property_config.d.ts +74 -0
  34. package/dist/types/property_options.d.ts +154 -0
  35. package/dist/types/slots.d.ts +263 -0
  36. package/dist/types/translations.d.ts +915 -0
  37. package/dist/types/user_management_delegate.d.ts +22 -0
  38. package/package.json +103 -0
  39. package/src/admin_collection.ts +582 -0
  40. package/src/augment.ts +60 -0
  41. package/src/collections.ts +256 -0
  42. package/src/controllers/analytics_controller.tsx +57 -0
  43. package/src/controllers/auth.ts +121 -0
  44. package/src/controllers/customization_controller.tsx +72 -0
  45. package/src/controllers/dialogs_controller.tsx +37 -0
  46. package/src/controllers/index.ts +10 -0
  47. package/src/controllers/local_config_persistence.tsx +22 -0
  48. package/src/controllers/navigation.ts +264 -0
  49. package/src/controllers/registry.ts +96 -0
  50. package/src/controllers/side_dialogs_controller.tsx +82 -0
  51. package/src/controllers/side_panel_controller.tsx +112 -0
  52. package/src/controllers/snackbar.ts +29 -0
  53. package/src/index.ts +20 -0
  54. package/src/react_component_ref.ts +52 -0
  55. package/src/rebase_context.ts +81 -0
  56. package/src/types/breadcrumbs.ts +27 -0
  57. package/src/types/builders.ts +18 -0
  58. package/src/types/component_overrides.ts +244 -0
  59. package/src/types/entity_actions.tsx +127 -0
  60. package/src/types/entity_link_builder.ts +8 -0
  61. package/src/types/entity_views.tsx +114 -0
  62. package/src/types/export_import.ts +26 -0
  63. package/src/types/formex.ts +45 -0
  64. package/src/types/index.ts +15 -0
  65. package/src/types/locales.ts +81 -0
  66. package/src/types/modify_collections.tsx +6 -0
  67. package/src/types/plugins.tsx +346 -0
  68. package/src/types/property_config.tsx +95 -0
  69. package/src/types/property_options.ts +169 -0
  70. package/src/types/slots.tsx +309 -0
  71. package/src/types/translations.ts +1026 -0
  72. package/src/types/user_management_delegate.ts +23 -0
@@ -0,0 +1,43 @@
1
+ import type React from "react";
2
+ import type { ComponentLike, ComponentRef, LazyComponentRef } from "@rebasepro/types";
3
+ /**
4
+ * `ComponentRef`, narrowed to real React types.
5
+ *
6
+ * Core's {@link ComponentRef} describes a component structurally
7
+ * ({@link ComponentLike}) so that `properties.ts` — and therefore the whole
8
+ * property model the backend reads — can live without React. The trade is that
9
+ * the return type is `unknown`, so a function returning something React cannot
10
+ * render type-checks there.
11
+ *
12
+ * Use this type wherever React genuinely exists: authoring a collection's admin
13
+ * options, and inside the admin packages. Assignments flow into core unchanged,
14
+ * because every member of this union is a member of that one.
15
+ */
16
+ export type ReactComponentRef<P = any> = string | LazyComponentRef<P> | (() => Promise<{
17
+ default: React.ComponentType<P>;
18
+ }>) | React.ComponentType<P>;
19
+ /**
20
+ * The `ComponentLike` contract, as a signature the compiler has to keep true.
21
+ *
22
+ * The split rests on one claim: **every form a React component takes is
23
+ * assignable to `ComponentLike`** — function components, class components,
24
+ * `memo`, `forwardRef`. If that stopped holding, core's `ComponentRef` would
25
+ * quietly begin rejecting real components, and the failure would surface far away
26
+ * in whichever collection file happened to use the broken form.
27
+ *
28
+ * So the claim is not left to a test that someone has to run. This function's
29
+ * parameter and return types state it, and `pnpm typecheck` enforces it on every
30
+ * commit. It is also useful on its own: an explicit widening at the point where
31
+ * an authored component enters a collection config.
32
+ *
33
+ * @example
34
+ * import { MyField } from "./MyField";
35
+ * admin: { Field: asComponentRef(MyField) }
36
+ */
37
+ export declare function asComponentRef<P>(component: React.ComponentType<P>): ComponentRef<P>;
38
+ /**
39
+ * The same contract in the other direction: a `ComponentLike` is only renderable
40
+ * once narrowed, and this is the single sanctioned place that narrowing is
41
+ * spelled out. `resolveComponentRef` in `@rebasepro/app` does the runtime half.
42
+ */
43
+ export declare function asReactComponent<P>(component: ComponentLike<P>): React.ComponentType<P>;
@@ -0,0 +1,68 @@
1
+ import type { AnalyticsController } from "./controllers/analytics_controller";
2
+ import type { AuthController } from "./controllers/auth";
3
+ import type { UserConfigurationPersistence } from "./controllers/local_config_persistence";
4
+ import type { DatabaseAdmin } from "@rebasepro/types";
5
+ import type { RebaseCallContext } from "@rebasepro/types";
6
+ import type { User } from "@rebasepro/types";
7
+ /**
8
+ * Context that includes the internal controllers and contexts used by the app.
9
+ * Some controllers and context included in this context can be accessed
10
+ * directly from their respective hooks.
11
+ * @group Hooks and utilities
12
+ * @see useRebaseContext
13
+ */
14
+ export type RebaseContext<USER extends User = User, AuthControllerType extends AuthController<USER> = AuthController<USER>> = RebaseCallContext<USER> & {
15
+ authController: AuthControllerType;
16
+ /**
17
+ * Controller mapping strings to collections
18
+ */
19
+ collectionRegistryController?: import("@rebasepro/types").CollectionRegistryController;
20
+ /**
21
+ * Controller for navigation state
22
+ */
23
+ navigationStateController?: import("./controllers/navigation").NavigationStateController;
24
+ /**
25
+ * Controller for side dialogs (side sheets)
26
+ */
27
+ sideDialogsController?: import("./controllers/side_dialogs_controller").SideDialogsController;
28
+ /**
29
+ * Controller to open the side panel displaying entity forms
30
+ */
31
+ sidePanelController?: import("./controllers/side_panel_controller").SidePanelController;
32
+ /**
33
+ * Controller resolving URLs in the CMS
34
+ */
35
+ urlController?: import("./controllers/navigation").UrlController;
36
+ /**
37
+ * Controller to handle simple confirmation and alert dialogs
38
+ */
39
+ dialogsController?: import("./controllers/dialogs_controller").DialogsController;
40
+ /**
41
+ * Controller for CMS customization
42
+ */
43
+ customizationController?: import("./controllers/customization_controller").CustomizationController;
44
+ /**
45
+ * Controller for effective role
46
+ */
47
+ effectiveRoleController?: {
48
+ effectiveRole: string | null;
49
+ setEffectiveRole: (role: string | null) => void;
50
+ };
51
+ /**
52
+ * Use this controller to access data stored in the browser for the user
53
+ */
54
+ userConfigPersistence?: UserConfigurationPersistence;
55
+ /**
56
+ * Callback to send analytics events
57
+ */
58
+ analyticsController?: AnalyticsController;
59
+ /**
60
+ * Administrative database operations (SQL, schema discovery).
61
+ * Only available in developer/admin contexts.
62
+ */
63
+ databaseAdmin?: DatabaseAdmin;
64
+ /**
65
+ * Controller for snackbars
66
+ */
67
+ snackbarController?: import("./controllers/snackbar").SnackbarController;
68
+ };
@@ -0,0 +1,26 @@
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
+ export interface BreadcrumbsController {
18
+ breadcrumbs: BreadcrumbEntry[];
19
+ set: (props: {
20
+ breadcrumbs: BreadcrumbEntry[];
21
+ }) => void;
22
+ /**
23
+ * Update the count for a specific breadcrumb by ID.
24
+ */
25
+ updateCount: (id: string, count: number | null | undefined) => void;
26
+ }
@@ -0,0 +1,15 @@
1
+ import type { AuthController } from "../controllers/auth";
2
+ import type { RebaseData } from "@rebasepro/types";
3
+ import type { User } from "@rebasepro/types";
4
+ import type { AppView } from "../controllers/navigation";
5
+ import type { AdminCollection } from "@rebasepro/admin-types";
6
+ export type CollectionConfigsBuilder<EC extends AdminCollection = AdminCollection> = (params: {
7
+ user: User | null;
8
+ authController: AuthController;
9
+ data: RebaseData;
10
+ }) => EC[] | Promise<EC[]>;
11
+ export type AppViewsBuilder = (params: {
12
+ user: User | null;
13
+ authController: AuthController;
14
+ data: RebaseData;
15
+ }) => AppView[] | Promise<AppView[]>;
@@ -0,0 +1,196 @@
1
+ import type React from "react";
2
+ import type { Property } from "@rebasepro/types";
3
+ import type { WhereFilterOp } from "@rebasepro/types";
4
+ /**
5
+ * Components that can only be overridden at the **app level** via the
6
+ * `components` prop on `<Rebase>`.
7
+ *
8
+ * These are shell-level / global components that exist outside of any
9
+ * specific collection context.
10
+ *
11
+ * @group Component Overrides
12
+ */
13
+ export type AppComponentName = "Shell.AppBar" | "Shell.Drawer" | "Shell.DrawerNavigationItem" | "Shell.DrawerNavigationGroup" | "HomePage" | "HomePage.CollectionCard" | "Auth.LoginView";
14
+ /**
15
+ * Components that can be overridden at the **collection level**
16
+ * (on an individual collection definition) or at the **app level**
17
+ * (as a default for all collections).
18
+ *
19
+ * When set at the app level, these act as defaults. When set on a
20
+ * specific collection, they override the app-level default for that
21
+ * collection only.
22
+ *
23
+ * @group Component Overrides
24
+ */
25
+ export type CollectionComponentName = "Collection.View" | "Collection.Table" | "Collection.Card" | "Collection.EmptyState" | "Collection.Actions" | "Collection.FilterField" | "Entity.Form" | "EditView.FormActions" | "DetailView" | "Entity.SidePanel" | "EntityPreview" | "Entity.MissingReference";
26
+ /**
27
+ * All overridable component names across all scopes.
28
+ * @group Component Overrides
29
+ */
30
+ export type OverridableComponentName = AppComponentName | CollectionComponentName;
31
+ /**
32
+ * Props received by a filter field component — whether it is a built-in
33
+ * per-type field, a property-level replacement (`property.ui.Filter`), or a
34
+ * `"Collection.FilterField"` override.
35
+ *
36
+ * The `operators` list is **already resolved**: it is the intersection of the
37
+ * engine's {@link DataSourceCapabilities.filterOperators}, the property-type
38
+ * defaults, and any `property.ui.filterOperators` narrowing. A custom field
39
+ * should only offer operators from this list — anything else may throw at
40
+ * query time on engines that cannot execute it.
41
+ *
42
+ * @example
43
+ * ```tsx
44
+ * function MyStatusFilter({ value, setValue, operators }: FilterFieldBindingProps) {
45
+ * return (
46
+ * <select
47
+ * value={value?.[1] as string ?? ""}
48
+ * onChange={e => setValue(e.target.value ? ["==", e.target.value] : undefined)}>
49
+ * <option value="">Any</option>
50
+ * <option value="active">Active</option>
51
+ * <option value="archived">Archived</option>
52
+ * </select>
53
+ * );
54
+ * }
55
+ * ```
56
+ *
57
+ * @group Component Overrides
58
+ */
59
+ export interface FilterFieldBindingProps {
60
+ /** Key of the property being filtered (the column id). */
61
+ propertyKey: string;
62
+ /**
63
+ * The resolved property. For array properties this is the **item**
64
+ * property (`property.of`), with `isArray` set to true.
65
+ */
66
+ property: Property;
67
+ /** True when the underlying property is an array of `property`. */
68
+ isArray: boolean;
69
+ /**
70
+ * Operators this field may offer, already narrowed by engine
71
+ * capabilities, property-type defaults, and `property.ui.filterOperators`.
72
+ */
73
+ operators: readonly WhereFilterOp[];
74
+ /** Current filter condition for this property, if any. */
75
+ value?: [WhereFilterOp, unknown];
76
+ /** Set (or clear, with `undefined`) the filter condition. */
77
+ setValue: (value?: [WhereFilterOp, unknown]) => void;
78
+ /** Display title for the field (usually the property name). */
79
+ title?: string;
80
+ /**
81
+ * Coordination flags used by fields that open their own dialogs
82
+ * (e.g. the reference picker hides the parent filters dialog).
83
+ */
84
+ hidden?: boolean;
85
+ setHidden?: (hidden: boolean) => void;
86
+ }
87
+ /**
88
+ * A single component override entry.
89
+ *
90
+ * - **Eject mode** (default): Your component fully replaces the built-in one.
91
+ * It receives the same props as the original.
92
+ *
93
+ * - **Wrap mode** (`wrap: true`): Your component wraps the original. The
94
+ * built-in component is passed as `OriginalComponent` in props, so you can
95
+ * render it inside your custom layout/logic.
96
+ *
97
+ * @example
98
+ * ```tsx
99
+ * // Eject — full replacement
100
+ * { Component: MyCustomAppBar }
101
+ *
102
+ * // Wrap — augment the original
103
+ * {
104
+ * Component: ({ OriginalComponent, ...props }) => (
105
+ * <div>
106
+ * <MyBanner />
107
+ * <OriginalComponent {...props} />
108
+ * </div>
109
+ * ),
110
+ * wrap: true
111
+ * }
112
+ * ```
113
+ *
114
+ * @group Component Overrides
115
+ */
116
+ export interface ComponentOverride<P = Record<string, unknown>> {
117
+ /**
118
+ * The replacement component. Receives the same props as the built-in
119
+ * component it replaces.
120
+ *
121
+ * When `wrap` is true, an additional `OriginalComponent` prop is injected
122
+ * containing the default component, allowing you to render it within
123
+ * your custom wrapper.
124
+ */
125
+ Component: React.ComponentType<P>;
126
+ /**
127
+ * When true, the original default component is injected as the
128
+ * `OriginalComponent` prop into your Component, enabling the
129
+ * wrapping pattern (similar to Docusaurus's `--wrap` swizzle mode).
130
+ *
131
+ * When false or omitted, your component fully replaces the default
132
+ * (similar to Docusaurus's `--eject` swizzle mode).
133
+ *
134
+ * @default false
135
+ */
136
+ wrap?: boolean;
137
+ }
138
+ /**
139
+ * Collection-scoped overrides. Only collection-level components
140
+ * can be overridden here.
141
+ *
142
+ * Set on a collection's `components` field to customize
143
+ * components for that specific collection.
144
+ *
145
+ * @example
146
+ * ```tsx
147
+ * const productsCollection = {
148
+ * name: "Products",
149
+ * slug: "products",
150
+ * components: {
151
+ * "Entity.Form": { Component: ProductForm },
152
+ * "Collection.EmptyState": { Component: ProductsEmptyState },
153
+ * "Collection.Card": { Component: ProductCard },
154
+ * }
155
+ * };
156
+ * ```
157
+ *
158
+ * @group Component Overrides
159
+ */
160
+ export type CollectionComponentOverrideMap = {
161
+ [K in CollectionComponentName]?: ComponentOverride;
162
+ };
163
+ /**
164
+ * App-level overrides. Includes both app-only components (Shell, HomePage, Auth)
165
+ * and collection-level components (as defaults for all collections).
166
+ *
167
+ * Pass this to the `components` prop on `<Rebase>`.
168
+ *
169
+ * Collection-level components set here act as **defaults** — they apply to all
170
+ * collections unless a specific collection overrides them in its own
171
+ * `components`.
172
+ *
173
+ * @example
174
+ * ```tsx
175
+ * <Rebase
176
+ * client={client}
177
+ * components={{
178
+ * // App-level: only available here
179
+ * "Shell.AppBar": { Component: MyAppBar },
180
+ * "HomePage": { Component: MyDashboard },
181
+ *
182
+ * // Collection defaults: apply to ALL collections
183
+ * "EditView.FormActions": {
184
+ * Component: MyFormActions,
185
+ * wrap: true
186
+ * },
187
+ * "Collection.EmptyState": { Component: MyEmptyState },
188
+ * }}
189
+ * />
190
+ * ```
191
+ *
192
+ * @group Component Overrides
193
+ */
194
+ export type ComponentOverrideMap = {
195
+ [K in OverridableComponentName]?: ComponentOverride;
196
+ };
@@ -0,0 +1,105 @@
1
+ import React from "react";
2
+ import type { Entity } from "@rebasepro/types";
3
+ import type { SelectionController } from "../collections";
4
+ import type { FormContext } from "./entity_views";
5
+ import type { User } from "@rebasepro/types";
6
+ import type { RebaseContext } from "../rebase_context";
7
+ import type { SidePanelController } from "../controllers/side_panel_controller";
8
+ import type { AdminCollection } from "@rebasepro/admin-types";
9
+ /**
10
+ * A entity action is a custom action that can be performed on a entity.
11
+ * They are displayed in the entity view and in the collection view.
12
+ */
13
+ export interface EntityAction<M extends Record<string, unknown> = Record<string, unknown>, USER extends User = User> {
14
+ /**
15
+ * Title of the action
16
+ */
17
+ name: string;
18
+ /**
19
+ * Key of the action. You only need to provide this if you want to
20
+ * override the default actions, or if you are not passing the action
21
+ * directly to the `entityActions` prop of a collection.
22
+ * You can define your actions at the app level, in which case you
23
+ * must provide a key.
24
+ * The default actions are:
25
+ * - edit
26
+ * - delete
27
+ * - copy
28
+ */
29
+ key?: string;
30
+ /**
31
+ * Icon of the action
32
+ */
33
+ icon?: React.ReactElement;
34
+ /**
35
+ * Callback when the action is clicked
36
+ * @param props
37
+ */
38
+ onClick(props: EntityActionClickProps<M, USER>): Promise<void> | void;
39
+ /**
40
+ * Optional callback in case you want to disable the action
41
+ * @param props
42
+ */
43
+ isEnabled?(props: EntityActionClickProps<M, USER>): boolean;
44
+ /**
45
+ * When true, this action is rendered inline on each row in the list view.
46
+ * By default, entity actions only appear in the table view and entity form.
47
+ * Use this for actions that should be easily accessible regardless of view mode.
48
+ */
49
+ showActionsInListView?: boolean;
50
+ /**
51
+ * Show this action collapsed in the menu of the collection view.
52
+ * Defaults to true
53
+ * If false, the action will be shown in the menu
54
+ */
55
+ collapsed?: boolean;
56
+ /**
57
+ * Show this action in the form, defaults to true
58
+ */
59
+ includeInForm?: boolean;
60
+ }
61
+ export type EntityActionClickProps<M extends Record<string, unknown>, USER extends User = User> = {
62
+ entity?: Entity<M>;
63
+ context?: RebaseContext<USER>;
64
+ path?: string;
65
+ collection?: AdminCollection<M>;
66
+ /**
67
+ * Optional form context, present if the action is being called from a form.
68
+ * This allows you to access the form state and methods, including modifying the form values.
69
+ */
70
+ formContext?: FormContext;
71
+ /**
72
+ * Present if this actions is being called from a side dialog only
73
+ */
74
+ sidePanelController?: SidePanelController;
75
+ /**
76
+ * Is the action being called from the collection view or from the entity form view?
77
+ */
78
+ view: "collection" | "form";
79
+ /**
80
+ * If the action is rendered in the form, is it open in a side panel or full screen?
81
+ */
82
+ openEntityMode?: "side_panel" | "full_screen" | "split" | "dialog";
83
+ /**
84
+ * Optional selection controller, present if the action is being called from a collection view
85
+ */
86
+ selectionController?: SelectionController;
87
+ /**
88
+ * Optional highlight function to highlight the entity in the collection view
89
+ * @param entity
90
+ */
91
+ highlightEntity?: (entity: Entity<Record<string, unknown>>) => void;
92
+ /**
93
+ * Optional unhighlight function to remove the highlight from the entity in the collection view
94
+ * @param entity
95
+ */
96
+ unhighlightEntity?: (entity: Entity<Record<string, unknown>>) => void;
97
+ /**
98
+ * Optional function to navigate back (e.g. when deleting a entity or navigating from a form)
99
+ */
100
+ navigateBack?: () => void;
101
+ /**
102
+ * Callback to be called when the collection changes, e.g. after a entity is deleted or created.
103
+ */
104
+ onCollectionChange?: () => void;
105
+ };
@@ -0,0 +1,7 @@
1
+ import { Entity } from "@rebasepro/types";
2
+ /**
3
+ * @group Models
4
+ */
5
+ export type EntityLinkBuilder<M extends Record<string, unknown> = Record<string, unknown>> = ({ entity }: {
6
+ entity: Entity<M>;
7
+ }) => string;
@@ -0,0 +1,95 @@
1
+ import React from "react";
2
+ import type { Entity, EntityValues } from "@rebasepro/types";
3
+ import type { FormexController } from "./formex";
4
+ import type { ComponentRef } from "@rebasepro/types";
5
+ import type { AdminCollection } from "@rebasepro/admin-types";
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
+ * Quietly persist the entity to the database without any UI feedback
21
+ * (no validation, no snackbar, no form reset).
22
+ * Use this for programmatic/background saves from custom views.
23
+ */
24
+ save: (values: M) => void;
25
+ /**
26
+ * Submit the form — validates, saves, resets the form, and shows
27
+ * a success snackbar. This is what the Save button calls.
28
+ * Use this from custom views when you want the full "user saved" experience.
29
+ */
30
+ submit: () => void;
31
+ /**
32
+ * Collection of the entity being modified
33
+ */
34
+ collection?: AdminCollection<M>;
35
+ /**
36
+ * Entity id, it can be undefined if it's a new entity
37
+ */
38
+ entityId?: string | number;
39
+ /**
40
+ * Path this entity is located at
41
+ */
42
+ path?: string;
43
+ status: "new" | "existing" | "copy";
44
+ entity?: Entity<M>;
45
+ savingError?: Error;
46
+ openEntityMode?: "side_panel" | "full_screen" | "split" | "dialog";
47
+ /**
48
+ * The underlying formex controller that powers the form.
49
+ */
50
+ formex: FormexController<M>;
51
+ disabled: boolean;
52
+ /**
53
+ * Whether the form context is in read-only detail view mode.
54
+ * Custom entity views can use this to adjust their rendering.
55
+ */
56
+ readOnly?: boolean;
57
+ }
58
+ export type EntityCustomView<M extends Record<string, unknown> = Record<string, unknown>> = {
59
+ key: string;
60
+ name: string;
61
+ icon?: string | React.ReactNode;
62
+ tabComponent?: React.ReactNode;
63
+ includeActions?: boolean | "bottom";
64
+ Builder?: ComponentRef<EntityCustomViewParams<M>>;
65
+ position?: "start" | "end";
66
+ };
67
+ /**
68
+ * Configuration to replace the default entity form with a custom component.
69
+ * The Builder receives the same props as entity view tabs (entity, formContext, etc.)
70
+ * and has full control over the UI.
71
+ *
72
+ * The form tab still appears in the tab bar but renders your Builder
73
+ * instead of the auto-generated field form.
74
+ *
75
+ * @group Models
76
+ */
77
+ export type FormViewConfig<M extends Record<string, unknown> = Record<string, unknown>> = {
78
+ /**
79
+ * Custom component that replaces the default form.
80
+ */
81
+ Builder: ComponentRef<EntityCustomViewParams<M>>;
82
+ /**
83
+ * If true, the save/delete action bar is rendered alongside the custom view.
84
+ * Defaults to true.
85
+ */
86
+ includeActions?: boolean;
87
+ };
88
+ export interface EntityCustomViewParams<M extends Record<string, unknown> = Record<string, unknown>> {
89
+ collection: AdminCollection<M>;
90
+ entity?: Entity<M>;
91
+ modifiedValues?: EntityValues<M>;
92
+ formContext: FormContext<M>;
93
+ parentCollectionSlugs?: string[];
94
+ parentEntityIds?: string[];
95
+ }
@@ -0,0 +1,21 @@
1
+ import type { Entity } from "@rebasepro/types";
2
+ import type { User } from "@rebasepro/types";
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;
19
+ context: RebaseContext<USER>;
20
+ }) => Promise<string> | string;
21
+ }
@@ -0,0 +1,40 @@
1
+ import React, { FormEvent } from "react";
2
+ export type FormexController<T = unknown> = {
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 = unknown> = {
36
+ values?: T;
37
+ submitCount?: number;
38
+ errors?: Record<string, string>;
39
+ touched?: Record<string, boolean>;
40
+ };
@@ -0,0 +1,15 @@
1
+ export * from "./breadcrumbs";
2
+ export * from "./builders";
3
+ export * from "./component_overrides";
4
+ export * from "./entity_actions";
5
+ export * from "./entity_link_builder";
6
+ export * from "./entity_views";
7
+ export * from "./export_import";
8
+ export * from "./formex";
9
+ export * from "./locales";
10
+ export * from "./modify_collections";
11
+ export * from "./plugins";
12
+ export * from "./property_config";
13
+ export * from "./slots";
14
+ export * from "./translations";
15
+ export * from "./user_management_delegate";
@@ -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";
@@ -0,0 +1,5 @@
1
+ import type { AdminCollection } from "@rebasepro/admin-types";
2
+ export type ModifyCollectionProps = {
3
+ collection: AdminCollection;
4
+ parentPaths: string[];
5
+ };