@rebasepro/core 0.4.0 → 0.6.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 (66) hide show
  1. package/README.md +142 -210
  2. package/dist/components/AIIcon.d.ts +3 -2
  3. package/dist/components/ConfirmationDialog.d.ts +1 -1
  4. package/dist/components/Debug/UIReferenceView.d.ts +13 -1
  5. package/dist/components/Debug/UIStyleGuide.d.ts +2 -1
  6. package/dist/components/ErrorTooltip.d.ts +2 -1
  7. package/dist/components/LanguageToggle.d.ts +2 -1
  8. package/dist/components/LoginView/LoginView.d.ts +2 -2
  9. package/dist/components/NotFoundPage.d.ts +2 -1
  10. package/dist/components/RebaseLogo.d.ts +1 -1
  11. package/dist/components/SchemaDriftBanner.d.ts +27 -0
  12. package/dist/components/UnsavedChangesDialog.d.ts +1 -1
  13. package/dist/components/UserDisplay.d.ts +1 -1
  14. package/dist/components/UserSelectPopover.d.ts +2 -1
  15. package/dist/components/UserSettingsView.d.ts +2 -1
  16. package/dist/components/index.d.ts +1 -1
  17. package/dist/contexts/ComponentOverrideContext.d.ts +42 -0
  18. package/dist/contexts/RebaseClientInstanceContext.d.ts +1 -1
  19. package/dist/contexts/index.d.ts +1 -1
  20. package/dist/core/Rebase.d.ts +2 -1
  21. package/dist/core/RebaseProps.d.ts +23 -22
  22. package/dist/core/RebaseRouter.d.ts +1 -1
  23. package/dist/core/RebaseRoutes.d.ts +1 -1
  24. package/dist/hooks/ApiConfigContext.d.ts +1 -1
  25. package/dist/hooks/index.d.ts +1 -2
  26. package/dist/hooks/useComponentOverride.d.ts +32 -0
  27. package/dist/hooks/useRebaseRegistry.d.ts +1 -1
  28. package/dist/hooks/useStudioBridge.d.ts +4 -16
  29. package/dist/i18n/RebaseI18nProvider.d.ts +2 -2
  30. package/dist/index.es.js +12878 -15004
  31. package/dist/index.es.js.map +1 -1
  32. package/dist/index.umd.js +13192 -15144
  33. package/dist/index.umd.js.map +1 -1
  34. package/dist/util/icons.d.ts +2 -2
  35. package/dist/vitePlugin.js +4 -1
  36. package/package.json +21 -22
  37. package/src/components/ErrorView.tsx +16 -6
  38. package/src/components/LoginView/LoginView.tsx +14 -16
  39. package/src/components/SchemaDriftBanner.tsx +102 -0
  40. package/src/components/common/useDataTableController.tsx +3 -3
  41. package/src/components/index.tsx +1 -1
  42. package/src/contexts/ComponentOverrideContext.tsx +81 -0
  43. package/src/contexts/RebaseClientInstanceContext.tsx +1 -1
  44. package/src/contexts/index.ts +1 -1
  45. package/src/core/Rebase.tsx +16 -18
  46. package/src/core/RebaseProps.tsx +24 -25
  47. package/src/hooks/data/useCollectionFetch.tsx +10 -2
  48. package/src/hooks/data/useRelationSelector.tsx +4 -2
  49. package/src/hooks/index.tsx +1 -3
  50. package/src/hooks/useCollapsedGroups.ts +2 -1
  51. package/src/hooks/useComponentOverride.tsx +59 -0
  52. package/src/hooks/useRebaseContext.tsx +3 -5
  53. package/src/hooks/useResolvedComponent.tsx +1 -1
  54. package/src/hooks/useStudioBridge.tsx +5 -13
  55. package/src/locales/en.ts +3 -0
  56. package/src/util/entity_cache.ts +0 -2
  57. package/src/util/previews.ts +1 -1
  58. package/src/vitePlugin.ts +2 -1
  59. package/dist/components/BootstrapAdminBanner.d.ts +0 -4
  60. package/dist/contexts/InternalUserManagementContext.d.ts +0 -3
  61. package/dist/hooks/data/useUserSelector.d.ts +0 -31
  62. package/dist/hooks/useInternalUserManagementController.d.ts +0 -12
  63. package/src/components/BootstrapAdminBanner.tsx +0 -75
  64. package/src/contexts/InternalUserManagementContext.tsx +0 -4
  65. package/src/hooks/data/useUserSelector.tsx +0 -157
  66. package/src/hooks/useInternalUserManagementController.tsx +0 -17
@@ -1,5 +1,5 @@
1
1
  import React from "react";
2
- import { Locale, User, AuthController, AnalyticsEvent, DataDriver, StorageSource, UserConfigurationPersistence, DatabaseAdmin, RebaseData, RebaseClient, RebaseContext, UserManagementDelegate, EntityLinkBuilder, RebasePlugin, SlotContribution, PropertyConfig, EntityCustomView, EntityAction, RebaseTranslations } from "@rebasepro/types";
2
+ import { Locale, User, AuthController, AnalyticsEvent, DataDriver, StorageSource, UserConfigurationPersistence, DatabaseAdmin, RebaseData, RebaseClient, RebaseContext, EntityLinkBuilder, RebasePlugin, SlotContribution, PropertyConfig, EntityCustomView, EntityAction, RebaseTranslations, ComponentOverrideMap } from "@rebasepro/types";
3
3
  /** DeepPartial helper — allows partial overrides at any nesting level */
4
4
  type DeepPartial<T> = T extends object ? {
5
5
  [K in keyof T]?: DeepPartial<T[K]>;
@@ -92,19 +92,6 @@ export type RebaseProps<USER extends User> = {
92
92
  * The function must return a URL that gets opened when the button is clicked
93
93
  */
94
94
  entityLinkBuilder?: EntityLinkBuilder;
95
- /**
96
- * You can use this props to provide your own user management implementation.
97
- * Note that this will not affect the UI, but it will be used to show user information
98
- * in various places of the CMS, for example, to show who created or modified an entity,
99
- * or to assign ownership of an entity.
100
- *
101
- * You can also use this data to be retrieved in your custom properties,
102
- * for example, to show a list of users in a dropdown.
103
- *
104
- * If you are using the Rebase user management plugin, this
105
- * prop will be implemented automatically.
106
- */
107
- userManagement?: UserManagementDelegate<USER>;
108
95
  /**
109
96
  * Plugins loaded in the CMS
110
97
  */
@@ -125,14 +112,6 @@ export type RebaseProps<USER extends User> = {
125
112
  * Entity Actions
126
113
  */
127
114
  entityActions?: EntityAction[];
128
- components?: {
129
- /**
130
- * Component to render when a reference is missing
131
- */
132
- missingReference?: React.ComponentType<{
133
- path: string;
134
- }>;
135
- };
136
115
  /**
137
116
  * Controller to simulate different roles when dev mode is active.
138
117
  */
@@ -143,5 +122,27 @@ export type RebaseProps<USER extends User> = {
143
122
  translations?: {
144
123
  [locale: string]: DeepPartial<RebaseTranslations>;
145
124
  };
125
+ /**
126
+ * Override built-in UI components with custom implementations.
127
+ *
128
+ * Keys are component names from {@link OverridableComponentName}.
129
+ * Values specify the replacement component and an optional `wrap`
130
+ * flag for the wrapping pattern.
131
+ *
132
+ * @example
133
+ * ```tsx
134
+ * <Rebase
135
+ * client={client}
136
+ * components={{
137
+ * "Shell.AppBar": { Component: MyCustomAppBar },
138
+ * "Entity.FormActions": {
139
+ * Component: MyFormActions,
140
+ * wrap: true
141
+ * }
142
+ * }}
143
+ * >
144
+ * ```
145
+ */
146
+ components?: ComponentOverrideMap;
146
147
  };
147
148
  export {};
@@ -1,4 +1,4 @@
1
1
  export declare function RebaseRouter({ children, basePath }: {
2
2
  children: React.ReactNode;
3
3
  basePath?: string;
4
- }): import("react/jsx-runtime").JSX.Element;
4
+ }): import("react").JSX.Element;
@@ -14,4 +14,4 @@ import React from "react";
14
14
  */
15
15
  export declare function RebaseRoutes({ children }: {
16
16
  children?: React.ReactNode;
17
- }): import("react/jsx-runtime").JSX.Element;
17
+ }): React.JSX.Element;
@@ -21,4 +21,4 @@ export declare function useApiConfig(): ApiConfig | undefined;
21
21
  */
22
22
  export declare function ApiConfigProvider({ apiUrl, getAuthToken, children }: ApiConfig & {
23
23
  children: React.ReactNode;
24
- }): import("react/jsx-runtime").JSX.Element;
24
+ }): React.JSX.Element;
@@ -2,7 +2,6 @@ export * from "./data/useData";
2
2
  export * from "./data/useCollectionFetch";
3
3
  export * from "./data/useEntityFetch";
4
4
  export * from "./data/useRelationSelector";
5
- export * from "./data/useUserSelector";
6
5
  export * from "./data/save";
7
6
  export * from "./data/delete";
8
7
  export * from "./useUnsavedChangesDialog";
@@ -20,7 +19,6 @@ export * from "./useModeController";
20
19
  export * from "./useClipboard";
21
20
  export * from "./useLargeLayout";
22
21
  export * from "./useCollapsedGroups";
23
- export * from "./useInternalUserManagementController";
24
22
  export * from "./useBrowserTitleAndIcon";
25
23
  export * from "./useSlot";
26
24
  export * from "./useCustomizationController";
@@ -35,3 +33,4 @@ export * from "./useRebaseClient";
35
33
  export * from "./useAnalyticsController";
36
34
  export * from "./useUserConfigurationPersistence";
37
35
  export * from "./useResolvedComponent";
36
+ export * from "./useComponentOverride";
@@ -0,0 +1,32 @@
1
+ import React from "react";
2
+ import type { OverridableComponentName } from "@rebasepro/types";
3
+ /**
4
+ * Resolves a potentially overridden component.
5
+ *
6
+ * Resolution order:
7
+ * 1. Collection-scoped override (highest priority)
8
+ * 2. Global override
9
+ * 3. Default component (fallback)
10
+ *
11
+ * Supports two override modes:
12
+ * - **Eject** (default): The override component fully replaces the default.
13
+ * - **Wrap** (`wrap: true`): The override component wraps the default.
14
+ * The default is passed as `OriginalComponent` in props.
15
+ *
16
+ * @param name - The overridable component name (e.g. `"Entity.Form"`)
17
+ * @param DefaultComponent - The built-in default component
18
+ * @returns The resolved component — either the default, a full replacement, or a wrapper
19
+ *
20
+ * @example
21
+ * ```tsx
22
+ * import { useComponentOverride } from "@rebasepro/core";
23
+ *
24
+ * function EntityFormWrapper(props: EntityFormProps) {
25
+ * const ResolvedForm = useComponentOverride("Entity.Form", DefaultEntityForm);
26
+ * return <ResolvedForm {...props} />;
27
+ * }
28
+ * ```
29
+ *
30
+ * @group Hooks
31
+ */
32
+ export declare function useComponentOverride<P>(name: OverridableComponentName, DefaultComponent: React.ComponentType<P>): React.ComponentType<P>;
@@ -19,7 +19,7 @@ interface RegistryDispatch {
19
19
  }
20
20
  export declare function RebaseRegistryProvider({ children }: {
21
21
  children: React.ReactNode;
22
- }): import("react/jsx-runtime").JSX.Element;
22
+ }): React.JSX.Element;
23
23
  /**
24
24
  * Returns the full registry (state + dispatch).
25
25
  * Use this in RebaseShell where you need to read configs.
@@ -1,18 +1,6 @@
1
1
  import React from "react";
2
- import type { CollectionRegistryController, SideEntityController, UrlController, NavigationStateController } from "@rebasepro/types";
3
- export interface BreadcrumbEntry {
4
- title: string;
5
- url: string;
6
- count?: number | null;
7
- id?: string;
8
- }
9
- export interface BreadcrumbsController {
10
- breadcrumbs: BreadcrumbEntry[];
11
- set: (props: {
12
- breadcrumbs: BreadcrumbEntry[];
13
- }) => void;
14
- updateCount: (id: string, count: number | null | undefined) => void;
15
- }
2
+ import type { CollectionRegistryController, SideEntityController, UrlController, NavigationStateController, BreadcrumbEntry, BreadcrumbsController } from "@rebasepro/types";
3
+ export type { BreadcrumbEntry, BreadcrumbsController };
16
4
  /**
17
5
  * StudioBridge provides optional CMS capabilities to Studio components.
18
6
  * When CMS is present, a bridge provider injects real implementations.
@@ -46,7 +34,7 @@ export declare const StudioBridgeContext: React.Context<StudioBridge>;
46
34
  export declare function StudioBridgeProvider({ value, children }: {
47
35
  value: Partial<StudioBridge>;
48
36
  children: React.ReactNode;
49
- }): import("react/jsx-runtime").JSX.Element;
37
+ }): React.JSX.Element;
50
38
  /** Collection registry — returns noop if CMS is not present. */
51
39
  export declare function useStudioCollectionRegistry(): CollectionRegistryController;
52
40
  /** Side entity controller — returns noop if CMS is not present. */
@@ -88,4 +76,4 @@ export declare const StudioBridgeRegistryContext: React.Context<StudioBridgeRegi
88
76
  */
89
77
  export declare function StudioBridgeRegistryProvider({ children }: {
90
78
  children: React.ReactNode;
91
- }): import("react/jsx-runtime").JSX.Element;
79
+ }): React.JSX.Element;
@@ -1,4 +1,4 @@
1
- import { PropsWithChildren } from "react";
1
+ import React, { PropsWithChildren } from "react";
2
2
  import { RebaseTranslations } from "@rebasepro/types";
3
3
  export declare const REBASE_LOCALE_STORAGE_KEY = "rebase_locale";
4
4
  /** DeepPartial helper — allows partial overrides at any nesting level */
@@ -29,5 +29,5 @@ export interface RebaseI18nProviderProps {
29
29
  *
30
30
  * @internal
31
31
  */
32
- export declare function RebaseI18nProvider({ locale, translations, children }: PropsWithChildren<RebaseI18nProviderProps>): import("react/jsx-runtime").JSX.Element | null;
32
+ export declare function RebaseI18nProvider({ locale, translations, children }: PropsWithChildren<RebaseI18nProviderProps>): React.JSX.Element | null;
33
33
  export {};