@rebasepro/admin 0.6.1 → 0.7.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/dist/{CollectionEditorDialog-HNXGxXdO.js → CollectionEditorDialog-iGgS4rLX.js} +233 -152
- package/dist/CollectionEditorDialog-iGgS4rLX.js.map +1 -0
- package/dist/{PropertyEditView-C2wp8kQ9.js → PropertyEditView-C9yhLyja.js} +129 -15
- package/dist/PropertyEditView-C9yhLyja.js.map +1 -0
- package/dist/{CollectionsStudioView-B1mN33GB.js → RouterCollectionsStudioView-Dqx27GD8.js} +61 -39
- package/dist/RouterCollectionsStudioView-Dqx27GD8.js.map +1 -0
- package/dist/collection_editor/extensibility_types.d.ts +135 -0
- package/dist/collection_editor/index.d.ts +6 -0
- package/dist/collection_editor/serializable_types.d.ts +374 -0
- package/dist/collection_editor/serializable_utils.d.ts +50 -0
- package/dist/collection_editor/ui/collection_editor/CollectionEditorDialog.d.ts +2 -1
- package/dist/collection_editor/ui/collection_editor/CollectionPropertiesEditorForm.d.ts +12 -1
- package/dist/collection_editor/ui/collection_editor/CollectionStudioView.d.ts +13 -1
- package/dist/collection_editor/ui/collection_editor/CollectionsStudioView.d.ts +24 -2
- package/dist/collection_editor/ui/collection_editor/DisplaySettingsForm.d.ts +2 -1
- package/dist/collection_editor/ui/collection_editor/GeneralSettingsForm.d.ts +4 -1
- package/dist/collection_editor/ui/collection_editor/PropertyEditView.d.ts +12 -1
- package/dist/collection_editor/ui/collection_editor/RouterCollectionStudioView.d.ts +15 -0
- package/dist/collection_editor/ui/collection_editor/RouterCollectionsStudioView.d.ts +14 -0
- package/dist/collection_editor/useJsonCollectionsConfigController.d.ts +37 -0
- package/dist/collection_editor/useSafeSnackbarController.d.ts +2 -0
- package/dist/collection_editor_ui.d.ts +4 -0
- package/dist/collection_editor_ui.js +33 -4
- package/dist/collection_editor_ui.js.map +1 -0
- package/dist/components/EntityCollectionView/EntityBoardCard.d.ts +3 -3
- package/dist/components/EntityCollectionView/hooks/useKanbanDragAndDrop.d.ts +3 -3
- package/dist/components/EntityEditView.d.ts +3 -2
- package/dist/components/RebaseCMS.d.ts +1 -1
- package/dist/form/EntityForm.d.ts +10 -9
- package/dist/form/EntityFormBinding.d.ts +27 -0
- package/dist/form/form_utils.d.ts +8 -0
- package/dist/form/index.d.ts +5 -1
- package/dist/{history-BO6VT85a.js → history-ChHgyyvM.js} +2 -2
- package/dist/{history-BO6VT85a.js.map → history-ChHgyyvM.js.map} +1 -1
- package/dist/hooks/navigation/contexts/CollectionRegistryContext.d.ts +1 -1
- package/dist/hooks/navigation/useAsyncResolver.d.ts +26 -0
- package/dist/hooks/navigation/useBuildCollectionRegistryController.d.ts +2 -0
- package/dist/hooks/navigation/useTopLevelNavigation.d.ts +1 -1
- package/dist/hooks/navigation/utils.d.ts +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.js +2 -2
- package/dist/routes/CustomViewRoute.d.ts +2 -1
- package/dist/{src-BYniefVu.js → src-DOX2nOyh.js} +1586 -1283
- package/dist/src-DOX2nOyh.js.map +1 -0
- package/dist/types/components/EntityFormActionsProps.d.ts +1 -1
- package/dist/types/components/EntityFormProps.d.ts +59 -0
- package/dist/types/fields.d.ts +6 -1
- package/dist/util/dataControllerAdapter.d.ts +30 -0
- package/dist/util/navigation_utils.d.ts +1 -1
- package/dist/util/propertyConfigMapper.d.ts +17 -0
- package/package.json +18 -18
- package/src/collection_editor/extensibility_types.ts +168 -0
- package/src/collection_editor/index.ts +46 -0
- package/src/collection_editor/serializable_types.ts +487 -0
- package/src/collection_editor/serializable_utils.ts +588 -0
- package/src/collection_editor/ui/collection_editor/AICollectionGeneratorPopover.tsx +4 -4
- package/src/collection_editor/ui/collection_editor/CollectionEditorDialog.tsx +134 -70
- package/src/collection_editor/ui/collection_editor/CollectionPropertiesEditorForm.tsx +95 -78
- package/src/collection_editor/ui/collection_editor/CollectionStudioView.tsx +23 -20
- package/src/collection_editor/ui/collection_editor/CollectionsStudioView.tsx +79 -27
- package/src/collection_editor/ui/collection_editor/DisplaySettingsForm.tsx +9 -7
- package/src/collection_editor/ui/collection_editor/GeneralSettingsForm.tsx +22 -5
- package/src/collection_editor/ui/collection_editor/GetCodeDialog.tsx +3 -3
- package/src/collection_editor/ui/collection_editor/PropertyEditView.tsx +155 -10
- package/src/collection_editor/ui/collection_editor/PropertyFieldPreview.tsx +6 -6
- package/src/collection_editor/ui/collection_editor/PropertyTree.tsx +1 -0
- package/src/collection_editor/ui/collection_editor/RouterCollectionStudioView.tsx +44 -0
- package/src/collection_editor/ui/collection_editor/RouterCollectionsStudioView.tsx +41 -0
- package/src/collection_editor/ui/collection_editor/properties/EnumPropertyField.tsx +4 -3
- package/src/collection_editor/useJsonCollectionsConfigController.tsx +286 -0
- package/src/collection_editor/useSafeSnackbarController.ts +9 -0
- package/src/collection_editor_ui.ts +6 -0
- package/src/components/DefaultDrawer.tsx +13 -3
- package/src/components/DrawerNavigationGroup.tsx +2 -2
- package/src/components/EntityCollectionView/EntityBoardCard.tsx +6 -6
- package/src/components/EntityCollectionView/EntityCollectionBoardView.tsx +12 -11
- package/src/components/EntityCollectionView/EntityCollectionCardView.tsx +40 -190
- package/src/components/EntityCollectionView/EntityCollectionListView.tsx +54 -183
- package/src/components/EntityCollectionView/hooks/useKanbanDragAndDrop.ts +6 -6
- package/src/components/EntityEditView.tsx +5 -4
- package/src/components/EntityEditViewFormActions.tsx +32 -26
- package/src/components/HomePage/ContentHomePage.tsx +13 -4
- package/src/components/RebaseCMS.tsx +3 -2
- package/src/components/RebaseNavigation.tsx +71 -7
- package/src/components/SelectableTable/SelectableTable.tsx +2 -2
- package/src/components/SideDialogs.tsx +0 -7
- package/src/components/common/default_entity_actions.tsx +9 -9
- package/src/contexts/BreacrumbsContext.tsx +15 -6
- package/src/editor/selectors/ai-selector.tsx +0 -1
- package/src/form/EntityForm.tsx +191 -428
- package/src/form/EntityFormActions.tsx +33 -47
- package/src/form/EntityFormBinding.tsx +323 -0
- package/src/form/components/FormLayout.tsx +1 -1
- package/src/form/field_bindings/ReadOnlyFieldBinding.tsx +7 -2
- package/src/form/form_utils.ts +163 -0
- package/src/form/index.tsx +14 -5
- package/src/hooks/navigation/contexts/CollectionRegistryContext.tsx +2 -2
- package/src/hooks/navigation/contexts/NavigationStateContext.tsx +2 -2
- package/src/hooks/navigation/contexts/UrlContext.tsx +1 -2
- package/src/hooks/navigation/useAsyncResolver.ts +100 -0
- package/src/hooks/navigation/useBuildCollectionRegistryController.tsx +15 -8
- package/src/hooks/navigation/useBuildNavigationStateController.tsx +12 -8
- package/src/hooks/navigation/useNavigationResolution.ts +33 -0
- package/src/hooks/navigation/useResolvedCollections.ts +29 -71
- package/src/hooks/navigation/useResolvedViews.tsx +40 -70
- package/src/hooks/navigation/useTopLevelNavigation.ts +20 -16
- package/src/hooks/navigation/utils.ts +7 -4
- package/src/index.ts +5 -0
- package/src/routes/CustomViewRoute.tsx +14 -6
- package/src/types/components/EntityFormActionsProps.tsx +1 -1
- package/src/types/components/EntityFormProps.tsx +68 -0
- package/src/types/fields.tsx +7 -1
- package/src/util/dataControllerAdapter.ts +93 -0
- package/src/util/navigation_utils.ts +1 -1
- package/src/util/propertyConfigMapper.ts +134 -0
- package/LICENSE +0 -21
- package/dist/CollectionEditorDialog-HNXGxXdO.js.map +0 -1
- package/dist/CollectionsStudioView-B1mN33GB.js.map +0 -1
- package/dist/PropertyEditView-C2wp8kQ9.js.map +0 -1
- package/dist/components/EntityCollectionView/Board.d.ts +0 -3
- package/dist/components/EntityCollectionView/BoardColumn.d.ts +0 -42
- package/dist/components/EntityCollectionView/BoardColumnTitle.d.ts +0 -9
- package/dist/components/EntityCollectionView/BoardSortableList.d.ts +0 -14
- package/dist/components/EntityCollectionView/board_types.d.ts +0 -105
- package/dist/hooks/navigation/useNavigationRegistry.d.ts +0 -12
- package/dist/hooks/navigation/useNavigationURLs.d.ts +0 -11
- package/dist/src-BYniefVu.js.map +0 -1
- package/src/components/EntityCollectionView/Board.tsx +0 -475
- package/src/components/EntityCollectionView/BoardColumn.tsx +0 -165
- package/src/components/EntityCollectionView/BoardColumnTitle.tsx +0 -46
- package/src/components/EntityCollectionView/BoardSortableList.tsx +0 -177
- package/src/components/EntityCollectionView/board_types.ts +0 -113
- package/src/hooks/navigation/useNavigationRegistry.ts +0 -164
- package/src/hooks/navigation/useNavigationURLs.ts +0 -56
|
@@ -12,7 +12,7 @@ export interface EntityFormActionsProps {
|
|
|
12
12
|
disabled: boolean;
|
|
13
13
|
status: "new" | "existing" | "copy";
|
|
14
14
|
pluginActions: React.ReactNode[];
|
|
15
|
-
openEntityMode
|
|
15
|
+
openEntityMode?: "side_panel" | "full_screen" | "split" | "dialog";
|
|
16
16
|
showDefaultActions?: boolean;
|
|
17
17
|
navigateBack: () => void;
|
|
18
18
|
formContext: FormContext;
|
|
@@ -3,6 +3,11 @@ import { EntityCollection, EntityCustomViewParams } from "@rebasepro/types";
|
|
|
3
3
|
import { FormContext } from "../fields";
|
|
4
4
|
import { FormexController } from "./formex";
|
|
5
5
|
import { EntityFormActionsProps } from "./EntityFormActionsProps";
|
|
6
|
+
/**
|
|
7
|
+
* Props for the headless EntityForm component.
|
|
8
|
+
* This form can be used without CMS context — all backend concerns
|
|
9
|
+
* (save, caching, analytics, plugin slots) are provided via callbacks.
|
|
10
|
+
*/
|
|
6
11
|
export type EntityFormProps<M extends Record<string, unknown>> = {
|
|
7
12
|
path: string;
|
|
8
13
|
fullIdPath?: string;
|
|
@@ -38,6 +43,60 @@ export type EntityFormProps<M extends Record<string, unknown>> = {
|
|
|
38
43
|
navigateBack?: () => void;
|
|
39
44
|
Builder?: React.ComponentType<EntityCustomViewParams<M>>;
|
|
40
45
|
children?: React.ReactNode;
|
|
46
|
+
/**
|
|
47
|
+
* Called on form submit with the values to save.
|
|
48
|
+
* The EntityFormBinding wrapper provides this automatically.
|
|
49
|
+
* When using EntityForm standalone, provide your own save logic.
|
|
50
|
+
*/
|
|
51
|
+
onSubmit?: (values: M, formex: FormexController<M>) => Promise<Entity<M> | void> | void;
|
|
52
|
+
/**
|
|
53
|
+
* Called when form values change (deferred).
|
|
54
|
+
* The EntityFormBinding wrapper uses this for entity caching.
|
|
55
|
+
*/
|
|
56
|
+
onValuesChangeDeferred?: (values: M, controller: FormexController<M>) => void;
|
|
57
|
+
/**
|
|
58
|
+
* Called when the form is reset.
|
|
59
|
+
*/
|
|
60
|
+
onReset?: () => void;
|
|
61
|
+
/**
|
|
62
|
+
* Validate that a field value is unique.
|
|
63
|
+
* The EntityFormBinding wrapper provides this via the data layer.
|
|
64
|
+
*/
|
|
65
|
+
uniqueFieldValidator?: (params: {
|
|
66
|
+
name: string;
|
|
67
|
+
value: unknown;
|
|
68
|
+
}) => Promise<boolean>;
|
|
69
|
+
/** Content rendered before the form fields */
|
|
70
|
+
beforeFields?: React.ReactNode;
|
|
71
|
+
/** Content rendered after the form fields */
|
|
72
|
+
afterFields?: React.ReactNode;
|
|
73
|
+
/** Plugin-provided action elements */
|
|
74
|
+
pluginActions?: React.ReactNode[];
|
|
75
|
+
/**
|
|
76
|
+
* Initial values for the form, after applying local changes.
|
|
77
|
+
* If not provided, computed from entity + collection defaults.
|
|
78
|
+
*/
|
|
79
|
+
computedInitialValues?: Partial<M>;
|
|
80
|
+
/**
|
|
81
|
+
* Whether there are unsaved local changes in the cache.
|
|
82
|
+
*/
|
|
83
|
+
hasLocalChanges?: boolean;
|
|
84
|
+
/**
|
|
85
|
+
* The local changes data for the manual-apply menu.
|
|
86
|
+
*/
|
|
87
|
+
localChangesData?: Partial<M>;
|
|
88
|
+
/**
|
|
89
|
+
* Whether manual-apply local changes mode is enabled.
|
|
90
|
+
*/
|
|
91
|
+
manualApplyLocalChanges?: boolean;
|
|
92
|
+
/**
|
|
93
|
+
* Cache key for the local changes menu.
|
|
94
|
+
*/
|
|
95
|
+
localChangesCacheKey?: string;
|
|
96
|
+
/**
|
|
97
|
+
* Callback when local changes are cleared.
|
|
98
|
+
*/
|
|
99
|
+
onClearLocalChanges?: () => void;
|
|
41
100
|
};
|
|
42
101
|
export type OnUpdateParams = {
|
|
43
102
|
entity: Entity<Record<string, unknown>>;
|
package/dist/types/fields.d.ts
CHANGED
|
@@ -149,7 +149,7 @@ export interface FormContext<M extends Record<string, unknown> = Record<string,
|
|
|
149
149
|
status: "new" | "existing" | "copy";
|
|
150
150
|
entity?: Entity<M>;
|
|
151
151
|
savingError?: Error;
|
|
152
|
-
openEntityMode
|
|
152
|
+
openEntityMode?: "side_panel" | "full_screen" | "split" | "dialog";
|
|
153
153
|
/**
|
|
154
154
|
* This is the underlying formex controller that powers the form.
|
|
155
155
|
* If you are in a red only mode, the formex controller is there, but you can't
|
|
@@ -157,6 +157,11 @@ export interface FormContext<M extends Record<string, unknown> = Record<string,
|
|
|
157
157
|
*/
|
|
158
158
|
formex: FormexController<M>;
|
|
159
159
|
disabled: boolean;
|
|
160
|
+
/**
|
|
161
|
+
* Whether the form context is in read-only detail view mode.
|
|
162
|
+
* Custom entity views can use this to adjust their rendering.
|
|
163
|
+
*/
|
|
164
|
+
readOnly?: boolean;
|
|
160
165
|
}
|
|
161
166
|
/**
|
|
162
167
|
* In case you need to render a field bound to a Property inside your
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Adapts an `EntityTableController<M>` (from @rebasepro/types) to a
|
|
3
|
+
* `CollectionDataController<T>` (from @rebasepro/ui), bridging the
|
|
4
|
+
* entity-aware data layer to the headless collection view.
|
|
5
|
+
*/
|
|
6
|
+
import type { EntityTableController } from "@rebasepro/types";
|
|
7
|
+
import type { CollectionDataController } from "@rebasepro/ui";
|
|
8
|
+
/**
|
|
9
|
+
* React hook that adapts an EntityTableController to a CollectionDataController.
|
|
10
|
+
*
|
|
11
|
+
* Usage:
|
|
12
|
+
* ```tsx
|
|
13
|
+
* const tableController = useDataTableController({ path, collection });
|
|
14
|
+
* const dataController = useCollectionDataController(tableController);
|
|
15
|
+
*
|
|
16
|
+
* <CollectionView dataController={dataController} ... />
|
|
17
|
+
* ```
|
|
18
|
+
*/
|
|
19
|
+
export declare function useCollectionDataController<M extends Record<string, unknown>>(tableController: EntityTableController<M>): CollectionDataController<M & {
|
|
20
|
+
id: string | number;
|
|
21
|
+
path: string;
|
|
22
|
+
}>;
|
|
23
|
+
/**
|
|
24
|
+
* Non-hook version for cases where you already have the data
|
|
25
|
+
* and just need to build a static controller.
|
|
26
|
+
*/
|
|
27
|
+
export declare function createStaticDataController<T extends Record<string, unknown>>(data: T[], options?: {
|
|
28
|
+
loading?: boolean;
|
|
29
|
+
error?: Error;
|
|
30
|
+
}): CollectionDataController<T>;
|
|
@@ -5,7 +5,7 @@ export { removeInitialAndTrailingSlashes, removeInitialSlash, removeTrailingSlas
|
|
|
5
5
|
* This is an admin-specific UI concern and lives here (not in common).
|
|
6
6
|
*/
|
|
7
7
|
export declare function navigateToEntity({ openEntityMode, collection, entityId, copy, path, selectedTab, defaultValues, sideEntityController, onClose, navigation, replace }: {
|
|
8
|
-
openEntityMode
|
|
8
|
+
openEntityMode?: "side_panel" | "full_screen" | "split" | "dialog";
|
|
9
9
|
collection?: EntityCollection;
|
|
10
10
|
entityId?: string | number;
|
|
11
11
|
selectedTab?: string;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Maps a Rebase `Property` (from @rebasepro/types) to a `CollectionPropertyConfig`
|
|
3
|
+
* (from @rebasepro/ui), stripping all entity-specific fields and keeping only
|
|
4
|
+
* the UI-relevant subset.
|
|
5
|
+
*
|
|
6
|
+
* This is the bridge between the entity-aware and headless layers.
|
|
7
|
+
*/
|
|
8
|
+
import type { Property, Properties } from "@rebasepro/types";
|
|
9
|
+
import type { CollectionPropertyConfig } from "@rebasepro/ui";
|
|
10
|
+
/**
|
|
11
|
+
* Convert a single Property to a CollectionPropertyConfig.
|
|
12
|
+
*/
|
|
13
|
+
export declare function mapPropertyToConfig(property: Property): CollectionPropertyConfig;
|
|
14
|
+
/**
|
|
15
|
+
* Convert a Properties record to a CollectionPropertyConfig record.
|
|
16
|
+
*/
|
|
17
|
+
export declare function mapPropertiesToConfigs(properties: Properties): Record<string, CollectionPropertyConfig>;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rebasepro/admin",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.7.0",
|
|
5
5
|
"description": "Rebase CMS — content management views, forms, and routing",
|
|
6
6
|
"funding": {
|
|
7
7
|
"url": "https://github.com/sponsors/rebaseco"
|
|
@@ -31,6 +31,14 @@
|
|
|
31
31
|
"headless cms",
|
|
32
32
|
"content manager"
|
|
33
33
|
],
|
|
34
|
+
"scripts": {
|
|
35
|
+
"watch": "vite build --watch",
|
|
36
|
+
"build": "vite build && tsc --emitDeclarationOnly -p tsconfig.prod.json",
|
|
37
|
+
"test:lint": "eslint \"src/**\" --quiet",
|
|
38
|
+
"test": "jest --passWithNoTests",
|
|
39
|
+
"clean": "rm -rf dist && find ./src -name '*.js' -type f | xargs rm -f",
|
|
40
|
+
"generateIcons": "ts-node --esm src/icons/generateIcons.ts"
|
|
41
|
+
},
|
|
34
42
|
"exports": {
|
|
35
43
|
".": {
|
|
36
44
|
"types": "./dist/index.d.ts",
|
|
@@ -55,6 +63,13 @@
|
|
|
55
63
|
"@dnd-kit/sortable": "^10.0.0",
|
|
56
64
|
"@dnd-kit/utilities": "^3.2.2",
|
|
57
65
|
"@floating-ui/dom": "^1.7.6",
|
|
66
|
+
"@rebasepro/common": "workspace:*",
|
|
67
|
+
"@rebasepro/core": "workspace:*",
|
|
68
|
+
"@rebasepro/formex": "workspace:*",
|
|
69
|
+
"@rebasepro/schema-inference": "workspace:*",
|
|
70
|
+
"@rebasepro/types": "workspace:*",
|
|
71
|
+
"@rebasepro/ui": "workspace:*",
|
|
72
|
+
"@rebasepro/utils": "workspace:*",
|
|
58
73
|
"cmdk": "^1.1.1",
|
|
59
74
|
"date-fns": "^4.4.0",
|
|
60
75
|
"exceljs": "^4.4.0",
|
|
@@ -82,14 +97,7 @@
|
|
|
82
97
|
"prosemirror-view": "^1.41.9",
|
|
83
98
|
"react-dropzone": "^15.0.0",
|
|
84
99
|
"react-use-measure": "^2.1.7",
|
|
85
|
-
"zod": "^4.4.3"
|
|
86
|
-
"@rebasepro/core": "0.6.1",
|
|
87
|
-
"@rebasepro/formex": "0.6.1",
|
|
88
|
-
"@rebasepro/schema-inference": "0.6.1",
|
|
89
|
-
"@rebasepro/common": "0.6.1",
|
|
90
|
-
"@rebasepro/types": "0.6.1",
|
|
91
|
-
"@rebasepro/utils": "0.6.1",
|
|
92
|
-
"@rebasepro/ui": "0.6.1"
|
|
100
|
+
"zod": "^4.4.3"
|
|
93
101
|
},
|
|
94
102
|
"peerDependencies": {
|
|
95
103
|
"react": ">=19.0.0",
|
|
@@ -160,13 +168,5 @@
|
|
|
160
168
|
"^@rebasepro/formex$": "<rootDir>/../formex/src/index.ts",
|
|
161
169
|
"^@rebasepro/utils$": "<rootDir>/../utils/src/index.ts"
|
|
162
170
|
}
|
|
163
|
-
},
|
|
164
|
-
"scripts": {
|
|
165
|
-
"watch": "vite build --watch",
|
|
166
|
-
"build": "vite build && tsc --emitDeclarationOnly -p tsconfig.prod.json",
|
|
167
|
-
"test:lint": "eslint \"src/**\" --quiet",
|
|
168
|
-
"test": "jest --passWithNoTests",
|
|
169
|
-
"clean": "rm -rf dist && find ./src -name '*.js' -type f | xargs rm -f",
|
|
170
|
-
"generateIcons": "ts-node --esm src/icons/generateIcons.ts"
|
|
171
171
|
}
|
|
172
|
-
}
|
|
172
|
+
}
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Extension point types for the collection editor UI.
|
|
3
|
+
*
|
|
4
|
+
* These types define props that let external consumers customize the editor
|
|
5
|
+
* without forking the UI: property type presets, type filtering,
|
|
6
|
+
* custom form field slots, and tab visibility.
|
|
7
|
+
*
|
|
8
|
+
* All extension points are additive and optional — the standard Rebase
|
|
9
|
+
* editor experience is unchanged when these props are not provided.
|
|
10
|
+
*
|
|
11
|
+
* @module
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
import type React from "react";
|
|
15
|
+
import type { SerializableProperty, SerializableCollection } from "./serializable_types";
|
|
16
|
+
|
|
17
|
+
// ═══════════════════════════════════════════════════════════════════════
|
|
18
|
+
// PROPERTY TYPE PRESETS
|
|
19
|
+
// ═══════════════════════════════════════════════════════════════════════
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* The base property data types supported by Rebase.
|
|
23
|
+
* Derived from the `type` discriminant on `SerializableProperty`.
|
|
24
|
+
*/
|
|
25
|
+
export type PropertyType = SerializableProperty["type"];
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* A higher-level "preset" that maps to a base Rebase property type
|
|
29
|
+
* with pre-filled configuration. Presets replace the default type picker
|
|
30
|
+
* in the property form when provided.
|
|
31
|
+
*
|
|
32
|
+
* @example
|
|
33
|
+
* ```typescript
|
|
34
|
+
* const emailPreset: PropertyTypePreset = {
|
|
35
|
+
* id: "email",
|
|
36
|
+
* label: "Email",
|
|
37
|
+
* baseType: "string",
|
|
38
|
+
* icon: "Mail",
|
|
39
|
+
* defaults: { email: true },
|
|
40
|
+
* detect: (p) => p.type === "string" && "email" in p && p.email === true,
|
|
41
|
+
* };
|
|
42
|
+
* ```
|
|
43
|
+
*/
|
|
44
|
+
export interface PropertyTypePreset {
|
|
45
|
+
/** Unique identifier for this preset (e.g. "email", "phone", "currency"). */
|
|
46
|
+
id: string;
|
|
47
|
+
|
|
48
|
+
/** Display label shown in the type picker. */
|
|
49
|
+
label: string;
|
|
50
|
+
|
|
51
|
+
/** The underlying Rebase property type this maps to. */
|
|
52
|
+
baseType: PropertyType;
|
|
53
|
+
|
|
54
|
+
/** Icon to show in the picker (Lucide icon name string or React node). */
|
|
55
|
+
icon?: string | React.ReactNode;
|
|
56
|
+
|
|
57
|
+
/** Default property config applied when this preset is selected. */
|
|
58
|
+
defaults: Partial<SerializableProperty>;
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Optional: detect this preset from an existing property.
|
|
62
|
+
* Used when loading existing schemas to show the correct preset label
|
|
63
|
+
* instead of the raw base type. First match wins.
|
|
64
|
+
* If not provided, falls back to matching by `baseType` alone.
|
|
65
|
+
*/
|
|
66
|
+
detect?: (property: SerializableProperty) => boolean;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
// ═══════════════════════════════════════════════════════════════════════
|
|
70
|
+
// TAB VISIBILITY
|
|
71
|
+
// ═══════════════════════════════════════════════════════════════════════
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* The tabs available in the collection editor.
|
|
75
|
+
*/
|
|
76
|
+
export type CollectionEditorTab = "general" | "display" | "properties" | "rls";
|
|
77
|
+
|
|
78
|
+
// ═══════════════════════════════════════════════════════════════════════
|
|
79
|
+
// CUSTOM FORM FIELD SLOTS
|
|
80
|
+
// ═══════════════════════════════════════════════════════════════════════
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* Parameters passed to the `renderExtraPropertyFields` render prop.
|
|
84
|
+
*/
|
|
85
|
+
export interface ExtraPropertyFieldsParams {
|
|
86
|
+
/** Current metadata values from `property.metadata`. */
|
|
87
|
+
metadata: Record<string, unknown>;
|
|
88
|
+
/** Callback to update a single metadata key. Triggers dirty-state tracking. */
|
|
89
|
+
onMetadataChange: (key: string, value: unknown) => void;
|
|
90
|
+
/** The full current property being edited (serializable form). */
|
|
91
|
+
property: SerializableProperty;
|
|
92
|
+
/** The collection this property belongs to (serializable form). */
|
|
93
|
+
collection: SerializableCollection;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* Parameters passed to the `renderExtraCollectionFields` render prop.
|
|
98
|
+
*/
|
|
99
|
+
export interface ExtraCollectionFieldsParams {
|
|
100
|
+
/** Current metadata values from `collection.metadata`. */
|
|
101
|
+
metadata: Record<string, unknown>;
|
|
102
|
+
/** Callback to update a single metadata key. Triggers dirty-state tracking. */
|
|
103
|
+
onMetadataChange: (key: string, value: unknown) => void;
|
|
104
|
+
/** The full current collection being edited (serializable form). */
|
|
105
|
+
collection: SerializableCollection;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
// ═══════════════════════════════════════════════════════════════════════
|
|
109
|
+
// COMBINED EXTENSION PROPS
|
|
110
|
+
// ═══════════════════════════════════════════════════════════════════════
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* All extension props for the collection editor UI.
|
|
114
|
+
*
|
|
115
|
+
* This interface groups every customization point into a single type
|
|
116
|
+
* that can be intersected with component props interfaces for clean threading.
|
|
117
|
+
*
|
|
118
|
+
* All fields are optional — when not provided, the standard Rebase
|
|
119
|
+
* editor experience is unchanged (backward compatible).
|
|
120
|
+
*/
|
|
121
|
+
export interface CollectionEditorExtensionProps {
|
|
122
|
+
/**
|
|
123
|
+
* Custom property type presets. When provided, these REPLACE the default
|
|
124
|
+
* type picker entirely. To include standard Rebase types alongside custom
|
|
125
|
+
* ones, include them explicitly in the array.
|
|
126
|
+
*
|
|
127
|
+
* When not provided, the standard Rebase widget picker is shown.
|
|
128
|
+
*/
|
|
129
|
+
propertyTypePresets?: PropertyTypePreset[];
|
|
130
|
+
|
|
131
|
+
/**
|
|
132
|
+
* Property types to hide from the type picker.
|
|
133
|
+
* Only applies when `propertyTypePresets` is NOT provided.
|
|
134
|
+
* When `propertyTypePresets` IS provided, this prop is ignored.
|
|
135
|
+
*/
|
|
136
|
+
hiddenPropertyTypes?: PropertyType[];
|
|
137
|
+
|
|
138
|
+
/**
|
|
139
|
+
* Render additional form fields below the standard property configuration.
|
|
140
|
+
* Metadata is stored in `property.metadata`.
|
|
141
|
+
*/
|
|
142
|
+
renderExtraPropertyFields?: (params: ExtraPropertyFieldsParams) => React.ReactNode;
|
|
143
|
+
|
|
144
|
+
/**
|
|
145
|
+
* Render additional form fields in the collection editor's General tab.
|
|
146
|
+
* Metadata is stored in `collection.metadata`.
|
|
147
|
+
*/
|
|
148
|
+
renderExtraCollectionFields?: (params: ExtraCollectionFieldsParams) => React.ReactNode;
|
|
149
|
+
|
|
150
|
+
/**
|
|
151
|
+
* Which tabs to show in the collection editor.
|
|
152
|
+
* Default: all tabs are shown (current behavior).
|
|
153
|
+
*/
|
|
154
|
+
visibleTabs?: CollectionEditorTab[];
|
|
155
|
+
|
|
156
|
+
/**
|
|
157
|
+
* When true, the editor runs in standalone mode — all Rebase-specific
|
|
158
|
+
* context dependencies (snackbar, auth, collection registry, import,
|
|
159
|
+
* navigation state, URL controller) use safe defaults instead of
|
|
160
|
+
* reading from React contexts.
|
|
161
|
+
*
|
|
162
|
+
* Use this when embedding the collection editor outside of the Rebase
|
|
163
|
+
* CMS, where the Rebase context providers are not available.
|
|
164
|
+
*
|
|
165
|
+
* Default: false (standard Rebase mode).
|
|
166
|
+
*/
|
|
167
|
+
standalone?: boolean;
|
|
168
|
+
}
|
|
@@ -17,6 +17,50 @@ export {
|
|
|
17
17
|
export {
|
|
18
18
|
useLocalCollectionsConfigController
|
|
19
19
|
} from "./useLocalCollectionsConfigController";
|
|
20
|
+
export {
|
|
21
|
+
useJsonCollectionsConfigController,
|
|
22
|
+
type UseJsonCollectionsConfigControllerOptions,
|
|
23
|
+
} from "./useJsonCollectionsConfigController";
|
|
24
|
+
|
|
25
|
+
export {
|
|
26
|
+
toSerializableCollection,
|
|
27
|
+
toSerializableProperty,
|
|
28
|
+
toSerializableProperties,
|
|
29
|
+
fromSerializableCollection,
|
|
30
|
+
fromSerializableProperty,
|
|
31
|
+
fromSerializableProperties,
|
|
32
|
+
} from "./serializable_utils";
|
|
33
|
+
|
|
34
|
+
export type {
|
|
35
|
+
SerializableCollection,
|
|
36
|
+
SerializableProperty,
|
|
37
|
+
SerializableProperties,
|
|
38
|
+
SerializableBaseProperty,
|
|
39
|
+
SerializableStringProperty,
|
|
40
|
+
SerializableNumberProperty,
|
|
41
|
+
SerializableBooleanProperty,
|
|
42
|
+
SerializableDateProperty,
|
|
43
|
+
SerializableGeopointProperty,
|
|
44
|
+
SerializableReferenceProperty,
|
|
45
|
+
SerializableRelationProperty,
|
|
46
|
+
SerializableArrayProperty,
|
|
47
|
+
SerializableMapProperty,
|
|
48
|
+
SerializableVectorProperty,
|
|
49
|
+
SerializableBinaryProperty,
|
|
50
|
+
SerializableStorageConfig,
|
|
51
|
+
SerializableStringValidation,
|
|
52
|
+
SerializableDateValidation,
|
|
53
|
+
JsonCollectionStore,
|
|
54
|
+
} from "./serializable_types";
|
|
55
|
+
|
|
56
|
+
export type {
|
|
57
|
+
PropertyTypePreset,
|
|
58
|
+
PropertyType,
|
|
59
|
+
CollectionEditorTab,
|
|
60
|
+
CollectionEditorExtensionProps,
|
|
61
|
+
ExtraPropertyFieldsParams,
|
|
62
|
+
ExtraCollectionFieldsParams,
|
|
63
|
+
} from "./extensibility_types";
|
|
20
64
|
|
|
21
65
|
export {
|
|
22
66
|
validateCollectionJson,
|
|
@@ -58,4 +102,6 @@ export * from "./ui/collection_editor/util";
|
|
|
58
102
|
export type { CollectionEditorDialogProps } from "./ui/collection_editor/CollectionEditorDialog";
|
|
59
103
|
export type { CollectionStudioViewProps } from "./ui/collection_editor/CollectionStudioView";
|
|
60
104
|
export type { CollectionsStudioViewProps } from "./ui/collection_editor/CollectionsStudioView";
|
|
105
|
+
export type { RouterCollectionStudioViewProps } from "./ui/collection_editor/RouterCollectionStudioView";
|
|
106
|
+
export type { RouterCollectionsStudioViewProps } from "./ui/collection_editor/RouterCollectionsStudioView";
|
|
61
107
|
export type { PropertyFormProps, OnPropertyChangedParams } from "./ui/collection_editor/PropertyEditView";
|