@rebasepro/plugin-insights 0.0.1-canary.09e5ec5
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 +6 -0
- package/dist/common/src/collections/CollectionRegistry.d.ts +56 -0
- package/dist/common/src/collections/index.d.ts +1 -0
- package/dist/common/src/data/buildRebaseData.d.ts +14 -0
- package/dist/common/src/index.d.ts +3 -0
- package/dist/common/src/util/builders.d.ts +57 -0
- package/dist/common/src/util/callbacks.d.ts +6 -0
- package/dist/common/src/util/collections.d.ts +11 -0
- package/dist/common/src/util/common.d.ts +2 -0
- package/dist/common/src/util/conditions.d.ts +26 -0
- package/dist/common/src/util/entities.d.ts +58 -0
- package/dist/common/src/util/enums.d.ts +3 -0
- package/dist/common/src/util/index.d.ts +16 -0
- package/dist/common/src/util/navigation_from_path.d.ts +34 -0
- package/dist/common/src/util/navigation_utils.d.ts +20 -0
- package/dist/common/src/util/parent_references_from_path.d.ts +6 -0
- package/dist/common/src/util/paths.d.ts +14 -0
- package/dist/common/src/util/permissions.d.ts +5 -0
- package/dist/common/src/util/references.d.ts +2 -0
- package/dist/common/src/util/relations.d.ts +22 -0
- package/dist/common/src/util/resolutions.d.ts +72 -0
- package/dist/common/src/util/storage.d.ts +24 -0
- package/dist/core/src/components/AIIcon.d.ts +16 -0
- package/dist/core/src/components/ConfirmationDialog.d.ts +9 -0
- package/dist/core/src/components/Debug/UIReferenceView.d.ts +1 -0
- package/dist/core/src/components/Debug/UIStyleGuide.d.ts +1 -0
- package/dist/core/src/components/ErrorTooltip.d.ts +2 -0
- package/dist/core/src/components/ErrorView.d.ts +21 -0
- package/dist/core/src/components/LanguageToggle.d.ts +1 -0
- package/dist/core/src/components/LoginView/LoginView.d.ts +68 -0
- package/dist/core/src/components/LoginView/index.d.ts +2 -0
- package/dist/core/src/components/NotFoundPage.d.ts +1 -0
- package/dist/core/src/components/RebaseAuth.d.ts +10 -0
- package/dist/core/src/components/RebaseLogo.d.ts +7 -0
- package/dist/core/src/components/UnsavedChangesDialog.d.ts +9 -0
- package/dist/core/src/components/UserDisplay.d.ts +7 -0
- package/dist/core/src/components/UserSelectPopover.d.ts +62 -0
- package/dist/core/src/components/UserSettingsView.d.ts +1 -0
- package/dist/core/src/components/common/index.d.ts +6 -0
- package/dist/core/src/components/common/table_height.d.ts +5 -0
- package/dist/core/src/components/common/types.d.ts +63 -0
- package/dist/core/src/components/common/useColumnsIds.d.ts +9 -0
- package/dist/core/src/components/common/useDataTableController.d.ts +45 -0
- package/dist/core/src/components/common/useDebouncedData.d.ts +9 -0
- package/dist/core/src/components/common/useScrollRestoration.d.ts +14 -0
- package/dist/core/src/components/index.d.ts +16 -0
- package/dist/core/src/contexts/AdminModeController.d.ts +4 -0
- package/dist/core/src/contexts/AnalyticsContext.d.ts +3 -0
- package/dist/core/src/contexts/AuthControllerContext.d.ts +3 -0
- package/dist/core/src/contexts/CustomizationControllerContext.d.ts +3 -0
- package/dist/core/src/contexts/DataDriverContext.d.ts +3 -0
- package/dist/core/src/contexts/DatabaseAdminContext.d.ts +3 -0
- package/dist/core/src/contexts/DialogsProvider.d.ts +4 -0
- package/dist/core/src/contexts/EffectiveRoleController.d.ts +4 -0
- package/dist/core/src/contexts/InternalUserManagementContext.d.ts +3 -0
- package/dist/core/src/contexts/ModeController.d.ts +4 -0
- package/dist/core/src/contexts/RebaseClientInstanceContext.d.ts +6 -0
- package/dist/core/src/contexts/RebaseDataContext.d.ts +3 -0
- package/dist/core/src/contexts/SnackbarProvider.d.ts +2 -0
- package/dist/core/src/contexts/StorageSourceContext.d.ts +3 -0
- package/dist/core/src/contexts/UserConfigurationPersistenceContext.d.ts +3 -0
- package/dist/core/src/contexts/index.d.ts +13 -0
- package/dist/core/src/core/PluginLifecycleManager.d.ts +17 -0
- package/dist/core/src/core/PluginProviderStack.d.ts +21 -0
- package/dist/core/src/core/Rebase.d.ts +14 -0
- package/dist/core/src/core/RebaseProps.d.ts +136 -0
- package/dist/core/src/core/RebaseRouter.d.ts +4 -0
- package/dist/core/src/core/RebaseRoutes.d.ts +17 -0
- package/dist/core/src/core/index.d.ts +4 -0
- package/dist/core/src/hooks/ApiConfigContext.d.ts +24 -0
- package/dist/core/src/hooks/data/delete.d.ts +31 -0
- package/dist/core/src/hooks/data/save.d.ts +34 -0
- package/dist/core/src/hooks/data/useCollectionFetch.d.ts +51 -0
- package/dist/core/src/hooks/data/useData.d.ts +13 -0
- package/dist/core/src/hooks/data/useDataOrder.d.ts +12 -0
- package/dist/core/src/hooks/data/useEntityFetch.d.ts +38 -0
- package/dist/core/src/hooks/data/useRelationSelector.d.ts +52 -0
- package/dist/core/src/hooks/data/useUserSelector.d.ts +31 -0
- package/dist/core/src/hooks/index.d.ts +37 -0
- package/dist/core/src/hooks/useAdminModeController.d.ts +19 -0
- package/dist/core/src/hooks/useAnalyticsController.d.ts +5 -0
- package/dist/core/src/hooks/useAuthController.d.ts +11 -0
- package/dist/core/src/hooks/useAuthSubscription.d.ts +2 -0
- package/dist/core/src/hooks/useBackendStorageSource.d.ts +30 -0
- package/dist/core/src/hooks/useBridgeRegistration.d.ts +18 -0
- package/dist/core/src/hooks/useBrowserTitleAndIcon.d.ts +6 -0
- package/dist/core/src/hooks/useBuildAdminModeController.d.ts +6 -0
- package/dist/core/src/hooks/useBuildEffectiveRoleController.d.ts +8 -0
- package/dist/core/src/hooks/useBuildLocalConfigurationPersistence.d.ts +2 -0
- package/dist/core/src/hooks/useBuildModeController.d.ts +6 -0
- package/dist/core/src/hooks/useClipboard.d.ts +57 -0
- package/dist/core/src/hooks/useCollapsedGroups.d.ts +12 -0
- package/dist/core/src/hooks/useCustomizationController.d.ts +11 -0
- package/dist/core/src/hooks/useDialogsController.d.ts +11 -0
- package/dist/core/src/hooks/useEffectiveRoleController.d.ts +7 -0
- package/dist/core/src/hooks/useInternalUserManagementController.d.ts +12 -0
- package/dist/core/src/hooks/useLargeLayout.d.ts +1 -0
- package/dist/core/src/hooks/useModeController.d.ts +19 -0
- package/dist/core/src/hooks/usePermissions.d.ts +12 -0
- package/dist/core/src/hooks/useRebaseClient.d.ts +5 -0
- package/dist/core/src/hooks/useRebaseContext.d.ts +11 -0
- package/dist/core/src/hooks/useRebaseRegistry.d.ts +34 -0
- package/dist/core/src/hooks/useSlot.d.ts +18 -0
- package/dist/core/src/hooks/useSnackbarController.d.ts +20 -0
- package/dist/core/src/hooks/useStorageSource.d.ts +7 -0
- package/dist/core/src/hooks/useStudioBridge.d.ts +91 -0
- package/dist/core/src/hooks/useTranslation.d.ts +17 -0
- package/dist/core/src/hooks/useUnsavedChangesDialog.d.ts +12 -0
- package/dist/core/src/hooks/useUserConfigurationPersistence.d.ts +8 -0
- package/dist/core/src/hooks/useValidateAuthenticator.d.ts +21 -0
- package/dist/core/src/i18n/RebaseI18nProvider.d.ts +33 -0
- package/dist/core/src/index.d.ts +15 -0
- package/dist/core/src/internal/common.d.ts +3 -0
- package/dist/core/src/internal/useRestoreScroll.d.ts +6 -0
- package/dist/core/src/locales/de.d.ts +2 -0
- package/dist/core/src/locales/en.d.ts +10 -0
- package/dist/core/src/locales/es.d.ts +10 -0
- package/dist/core/src/locales/fr.d.ts +2 -0
- package/dist/core/src/locales/hi.d.ts +2 -0
- package/dist/core/src/locales/it.d.ts +2 -0
- package/dist/core/src/locales/pt.d.ts +7 -0
- package/dist/core/src/util/constants.d.ts +1 -0
- package/dist/core/src/util/createFormexStub.d.ts +2 -0
- package/dist/core/src/util/entity_cache.d.ts +27 -0
- package/dist/core/src/util/enums.d.ts +5 -0
- package/dist/core/src/util/icon_list.d.ts +5 -0
- package/dist/core/src/util/icon_synonyms.d.ts +1 -0
- package/dist/core/src/util/icons.d.ts +20 -0
- package/dist/core/src/util/index.d.ts +10 -0
- package/dist/core/src/util/previews.d.ts +4 -0
- package/dist/core/src/util/useStorageUploadController.d.ts +38 -0
- package/dist/core/src/util/useTraceUpdate.d.ts +2 -0
- package/dist/formex/src/Field.d.ts +52 -0
- package/dist/formex/src/Formex.d.ts +7 -0
- package/dist/formex/src/index.d.ts +5 -0
- package/dist/formex/src/types.d.ts +40 -0
- package/dist/formex/src/useCreateFormex.d.ts +14 -0
- package/dist/formex/src/utils.d.ts +16 -0
- package/dist/index.es.js +945 -0
- package/dist/index.es.js.map +1 -0
- package/dist/index.umd.js +944 -0
- package/dist/index.umd.js.map +1 -0
- package/dist/plugin-insights/src/components/CollectionInsightsInline.d.ts +16 -0
- package/dist/plugin-insights/src/components/HomeCardInsightSlot.d.ts +16 -0
- package/dist/plugin-insights/src/components/HomeInsightsSlot.d.ts +13 -0
- package/dist/plugin-insights/src/components/InsightWidget.d.ts +19 -0
- package/dist/plugin-insights/src/components/InsightWidgetSkeleton.d.ts +20 -0
- package/dist/plugin-insights/src/components/InsightsScorecardView.d.ts +19 -0
- package/dist/plugin-insights/src/engine/InsightsCache.d.ts +18 -0
- package/dist/plugin-insights/src/engine/InsightsProvider.d.ts +22 -0
- package/dist/plugin-insights/src/engine/useInsightsData.d.ts +17 -0
- package/dist/plugin-insights/src/index.d.ts +8 -0
- package/dist/plugin-insights/src/types/engine.d.ts +79 -0
- package/dist/plugin-insights/src/types/index.d.ts +2 -0
- package/dist/plugin-insights/src/types/widgets.d.ts +59 -0
- package/dist/plugin-insights/src/useInsightsPlugin.d.ts +37 -0
- package/dist/types/src/controllers/analytics_controller.d.ts +7 -0
- package/dist/types/src/controllers/auth.d.ts +119 -0
- package/dist/types/src/controllers/client.d.ts +170 -0
- package/dist/types/src/controllers/collection_registry.d.ts +45 -0
- package/dist/types/src/controllers/customization_controller.d.ts +60 -0
- package/dist/types/src/controllers/data.d.ts +168 -0
- package/dist/types/src/controllers/data_driver.d.ts +160 -0
- package/dist/types/src/controllers/database_admin.d.ts +11 -0
- package/dist/types/src/controllers/dialogs_controller.d.ts +36 -0
- package/dist/types/src/controllers/effective_role.d.ts +4 -0
- package/dist/types/src/controllers/email.d.ts +34 -0
- package/dist/types/src/controllers/index.d.ts +18 -0
- package/dist/types/src/controllers/local_config_persistence.d.ts +20 -0
- package/dist/types/src/controllers/navigation.d.ts +213 -0
- package/dist/types/src/controllers/registry.d.ts +54 -0
- package/dist/types/src/controllers/side_dialogs_controller.d.ts +67 -0
- package/dist/types/src/controllers/side_entity_controller.d.ts +90 -0
- package/dist/types/src/controllers/snackbar.d.ts +24 -0
- package/dist/types/src/controllers/storage.d.ts +171 -0
- package/dist/types/src/index.d.ts +4 -0
- package/dist/types/src/rebase_context.d.ts +105 -0
- package/dist/types/src/types/backend.d.ts +536 -0
- package/dist/types/src/types/builders.d.ts +15 -0
- package/dist/types/src/types/chips.d.ts +5 -0
- package/dist/types/src/types/collections.d.ts +856 -0
- package/dist/types/src/types/cron.d.ts +102 -0
- package/dist/types/src/types/data_source.d.ts +64 -0
- package/dist/types/src/types/entities.d.ts +145 -0
- package/dist/types/src/types/entity_actions.d.ts +98 -0
- package/dist/types/src/types/entity_callbacks.d.ts +173 -0
- package/dist/types/src/types/entity_link_builder.d.ts +7 -0
- package/dist/types/src/types/entity_overrides.d.ts +10 -0
- package/dist/types/src/types/entity_views.d.ts +61 -0
- package/dist/types/src/types/export_import.d.ts +21 -0
- package/dist/types/src/types/index.d.ts +23 -0
- package/dist/types/src/types/locales.d.ts +4 -0
- package/dist/types/src/types/modify_collections.d.ts +5 -0
- package/dist/types/src/types/plugins.d.ts +279 -0
- package/dist/types/src/types/properties.d.ts +1176 -0
- package/dist/types/src/types/property_config.d.ts +70 -0
- package/dist/types/src/types/relations.d.ts +336 -0
- package/dist/types/src/types/slots.d.ts +252 -0
- package/dist/types/src/types/translations.d.ts +870 -0
- package/dist/types/src/types/user_management_delegate.d.ts +121 -0
- package/dist/types/src/types/websockets.d.ts +78 -0
- package/dist/types/src/users/index.d.ts +2 -0
- package/dist/types/src/users/roles.d.ts +22 -0
- package/dist/types/src/users/user.d.ts +46 -0
- package/dist/ui/src/components/Alert.d.ts +12 -0
- package/dist/ui/src/components/Autocomplete.d.ts +21 -0
- package/dist/ui/src/components/Avatar.d.ts +11 -0
- package/dist/ui/src/components/Badge.d.ts +8 -0
- package/dist/ui/src/components/BooleanSwitch.d.ts +14 -0
- package/dist/ui/src/components/BooleanSwitchWithLabel.d.ts +17 -0
- package/dist/ui/src/components/Button.d.ts +14 -0
- package/dist/ui/src/components/Card.d.ts +9 -0
- package/dist/ui/src/components/CenteredView.d.ts +9 -0
- package/dist/ui/src/components/Checkbox.d.ts +13 -0
- package/dist/ui/src/components/Chip.d.ts +26 -0
- package/dist/ui/src/components/CircularProgress.d.ts +5 -0
- package/dist/ui/src/components/CircularProgressCenter.d.ts +11 -0
- package/dist/ui/src/components/Collapse.d.ts +9 -0
- package/dist/ui/src/components/ColorPicker.d.ts +30 -0
- package/dist/ui/src/components/Container.d.ts +8 -0
- package/dist/ui/src/components/DateTimeField.d.ts +24 -0
- package/dist/ui/src/components/DebouncedTextField.d.ts +2 -0
- package/dist/ui/src/components/Dialog.d.ts +39 -0
- package/dist/ui/src/components/DialogActions.d.ts +7 -0
- package/dist/ui/src/components/DialogContent.d.ts +7 -0
- package/dist/ui/src/components/DialogTitle.d.ts +10 -0
- package/dist/ui/src/components/ErrorBoundary.d.ts +11 -0
- package/dist/ui/src/components/ExpandablePanel.d.ts +12 -0
- package/dist/ui/src/components/FileUpload.d.ts +23 -0
- package/dist/ui/src/components/IconButton.d.ts +12 -0
- package/dist/ui/src/components/InfoLabel.d.ts +5 -0
- package/dist/ui/src/components/InputLabel.d.ts +11 -0
- package/dist/ui/src/components/Label.d.ts +7 -0
- package/dist/ui/src/components/LoadingButton.d.ts +7 -0
- package/dist/ui/src/components/Markdown.d.ts +10 -0
- package/dist/ui/src/components/Menu.d.ts +23 -0
- package/dist/ui/src/components/Menubar.d.ts +80 -0
- package/dist/ui/src/components/MultiSelect.d.ts +48 -0
- package/dist/ui/src/components/Paper.d.ts +6 -0
- package/dist/ui/src/components/Popover.d.ts +24 -0
- package/dist/ui/src/components/RadioGroup.d.ts +28 -0
- package/dist/ui/src/components/ResizablePanels.d.ts +18 -0
- package/dist/ui/src/components/SearchBar.d.ts +22 -0
- package/dist/ui/src/components/Select.d.ts +43 -0
- package/dist/ui/src/components/Separator.d.ts +5 -0
- package/dist/ui/src/components/Sheet.d.ts +22 -0
- package/dist/ui/src/components/Skeleton.d.ts +6 -0
- package/dist/ui/src/components/Slider.d.ts +21 -0
- package/dist/ui/src/components/Table.d.ts +34 -0
- package/dist/ui/src/components/Tabs.d.ts +19 -0
- package/dist/ui/src/components/TextField.d.ts +58 -0
- package/dist/ui/src/components/TextareaAutosize.d.ts +43 -0
- package/dist/ui/src/components/ToggleButtonGroup.d.ts +30 -0
- package/dist/ui/src/components/Tooltip.d.ts +19 -0
- package/dist/ui/src/components/Typography.d.ts +36 -0
- package/dist/ui/src/components/VirtualTable/VirtualTable.d.ts +11 -0
- package/dist/ui/src/components/VirtualTable/VirtualTableCell.d.ts +21 -0
- package/dist/ui/src/components/VirtualTable/VirtualTableHeader.d.ts +29 -0
- package/dist/ui/src/components/VirtualTable/VirtualTableHeaderRow.d.ts +2 -0
- package/dist/ui/src/components/VirtualTable/VirtualTableProps.d.ts +243 -0
- package/dist/ui/src/components/VirtualTable/VirtualTableRow.d.ts +3 -0
- package/dist/ui/src/components/VirtualTable/index.d.ts +3 -0
- package/dist/ui/src/components/VirtualTable/types.d.ts +38 -0
- package/dist/ui/src/components/common/SelectInputLabel.d.ts +5 -0
- package/dist/ui/src/components/index.d.ts +53 -0
- package/dist/ui/src/hooks/PortalContainerContext.d.ts +31 -0
- package/dist/ui/src/hooks/index.d.ts +6 -0
- package/dist/ui/src/hooks/useDebounceCallback.d.ts +1 -0
- package/dist/ui/src/hooks/useDebounceValue.d.ts +1 -0
- package/dist/ui/src/hooks/useDebouncedCallback.d.ts +1 -0
- package/dist/ui/src/hooks/useInjectStyles.d.ts +7 -0
- package/dist/ui/src/hooks/useOutsideAlerter.d.ts +5 -0
- package/dist/ui/src/icons/GitHubIcon.d.ts +2 -0
- package/dist/ui/src/icons/HandleIcon.d.ts +1 -0
- package/dist/ui/src/icons/Icon.d.ts +20 -0
- package/dist/ui/src/icons/cool_icon_keys.d.ts +1 -0
- package/dist/ui/src/icons/icon_keys.d.ts +1 -0
- package/dist/ui/src/icons/index.d.ts +6 -0
- package/dist/ui/src/index.d.ts +5 -0
- package/dist/ui/src/styles.d.ts +12 -0
- package/dist/ui/src/util/chip_colors.d.ts +4 -0
- package/dist/ui/src/util/cls.d.ts +2 -0
- package/dist/ui/src/util/debounce.d.ts +10 -0
- package/dist/ui/src/util/hash.d.ts +1 -0
- package/dist/ui/src/util/index.d.ts +4 -0
- package/dist/ui/src/util/key_to_icon_component.d.ts +1 -0
- package/package.json +80 -0
- package/src/components/CollectionInsightsInline.tsx +30 -0
- package/src/components/HomeCardInsightSlot.tsx +36 -0
- package/src/components/HomeInsightsSlot.tsx +30 -0
- package/src/components/InsightWidget.tsx +65 -0
- package/src/components/InsightWidgetSkeleton.tsx +122 -0
- package/src/components/InsightsScorecardView.tsx +160 -0
- package/src/engine/InsightsCache.ts +52 -0
- package/src/engine/InsightsProvider.tsx +38 -0
- package/src/engine/useInsightsData.ts +100 -0
- package/src/index.ts +22 -0
- package/src/types/engine.ts +85 -0
- package/src/types/index.ts +5 -0
- package/src/types/widgets.ts +66 -0
- package/src/useInsightsPlugin.tsx +117 -0
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { EntityCollection } from "@rebasepro/types";
|
|
2
|
+
import { Entity, RebaseContext, SaveEntityProps } from "@rebasepro/types";
|
|
3
|
+
import { RebaseData } from "@rebasepro/types";
|
|
4
|
+
/**
|
|
5
|
+
* @group Hooks and utilities
|
|
6
|
+
*/
|
|
7
|
+
export type SaveEntityWithCallbacksProps<M extends Record<string, any>> = SaveEntityProps<M> & {
|
|
8
|
+
afterSave?: (updatedEntity: Entity<M>) => void;
|
|
9
|
+
afterSaveError?: (e: Error) => void;
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* This function is in charge of saving an entity.
|
|
13
|
+
* It will run all the save callbacks specified in the collection.
|
|
14
|
+
* It is also possible to attach callbacks on save success or error, and callback
|
|
15
|
+
* errors.
|
|
16
|
+
*
|
|
17
|
+
* @param collection
|
|
18
|
+
* @param path
|
|
19
|
+
* @param entityId
|
|
20
|
+
* @param callbacks
|
|
21
|
+
* @param values
|
|
22
|
+
* @param previousValues
|
|
23
|
+
* @param status
|
|
24
|
+
* @param data
|
|
25
|
+
* @param context
|
|
26
|
+
* @param afterSave
|
|
27
|
+
* @param afterSaveError
|
|
28
|
+
* @group Hooks and utilities
|
|
29
|
+
*/
|
|
30
|
+
export declare function saveEntityWithCallbacks<M extends Record<string, any>>({ collection, path, entityId, values, previousValues, status, data, context, afterSave, afterSaveError }: SaveEntityWithCallbacksProps<M> & {
|
|
31
|
+
collection: EntityCollection;
|
|
32
|
+
data: RebaseData;
|
|
33
|
+
context: RebaseContext;
|
|
34
|
+
}): Promise<Entity<M>>;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import type { EntityCollection } from "@rebasepro/types";
|
|
2
|
+
import { Entity, FilterValues, User } from "@rebasepro/types";
|
|
3
|
+
/**
|
|
4
|
+
* @group Hooks and utilities
|
|
5
|
+
*/
|
|
6
|
+
export interface CollectionFetchProps<M extends Record<string, any>> {
|
|
7
|
+
/**
|
|
8
|
+
* Absolute collection path
|
|
9
|
+
*/
|
|
10
|
+
path: string;
|
|
11
|
+
/**
|
|
12
|
+
* collection of the entity displayed by this collection
|
|
13
|
+
*/
|
|
14
|
+
collection: EntityCollection<M>;
|
|
15
|
+
/**
|
|
16
|
+
* Number of entities to fetch
|
|
17
|
+
*/
|
|
18
|
+
itemCount?: number;
|
|
19
|
+
/**
|
|
20
|
+
* Filter the fetched data by the property
|
|
21
|
+
*/
|
|
22
|
+
filterValues?: FilterValues<Extract<keyof M, string>>;
|
|
23
|
+
/**
|
|
24
|
+
* Sort the results by
|
|
25
|
+
*/
|
|
26
|
+
sortBy?: [Extract<keyof M, string>, "asc" | "desc"];
|
|
27
|
+
/**
|
|
28
|
+
* Search string
|
|
29
|
+
*/
|
|
30
|
+
searchString?: string;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* @group Hooks and utilities
|
|
34
|
+
*/
|
|
35
|
+
export interface CollectionFetchResult<M extends Record<string, any>> {
|
|
36
|
+
data: Entity<M>[];
|
|
37
|
+
dataLoading: boolean;
|
|
38
|
+
noMoreToLoad: boolean;
|
|
39
|
+
dataLoadingError?: Error;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* This hook is used to fetch collections using a given collection
|
|
43
|
+
* @param path
|
|
44
|
+
* @param collection
|
|
45
|
+
* @param filterValues
|
|
46
|
+
* @param sortBy
|
|
47
|
+
* @param itemCount
|
|
48
|
+
* @param searchString
|
|
49
|
+
* @group Hooks and utilities
|
|
50
|
+
*/
|
|
51
|
+
export declare function useCollectionFetch<M extends Record<string, any>, USER extends User>({ path, collection, filterValues, sortBy, itemCount, searchString }: CollectionFetchProps<M>): CollectionFetchResult<M>;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { RebaseData } from "@rebasepro/types";
|
|
2
|
+
/**
|
|
3
|
+
* Use this hook to access the unified data API.
|
|
4
|
+
*
|
|
5
|
+
* ```ts
|
|
6
|
+
* const data = useData();
|
|
7
|
+
* const { data: products } = await data.products.find({ where: { status: "eq.published" } });
|
|
8
|
+
* await data.products.create({ name: "Camera", price: 299 });
|
|
9
|
+
* ```
|
|
10
|
+
*
|
|
11
|
+
* @group Hooks and utilities
|
|
12
|
+
*/
|
|
13
|
+
export declare const useData: () => RebaseData;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Entity } from "@rebasepro/types";
|
|
2
|
+
export interface DataOrderProps<M extends Record<string, any>> {
|
|
3
|
+
data: Entity<M>[];
|
|
4
|
+
entitiesDisplayedFirst?: Entity<M>[];
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* This hook is used to have some entities at the beginning of data.
|
|
8
|
+
* @param path
|
|
9
|
+
* @param entitiesDisplayedFirst
|
|
10
|
+
* @group Hooks and utilities
|
|
11
|
+
*/
|
|
12
|
+
export declare function useDataOrder<M extends Record<string, any>>({ data, entitiesDisplayedFirst }: DataOrderProps<M>): Entity<M>[];
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import type { EntityCollection } from "@rebasepro/types";
|
|
2
|
+
import { Entity, User } from "@rebasepro/types";
|
|
3
|
+
/**
|
|
4
|
+
* @group Hooks and utilities
|
|
5
|
+
*/
|
|
6
|
+
export interface EntityFetchProps<M extends Record<string, any>, USER extends User = User> {
|
|
7
|
+
path: string;
|
|
8
|
+
entityId?: string | number;
|
|
9
|
+
databaseId?: string;
|
|
10
|
+
collection: EntityCollection<M, USER>;
|
|
11
|
+
useCache?: boolean;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* @group Hooks and utilities
|
|
15
|
+
*/
|
|
16
|
+
export interface EntityFetchResult<M extends Record<string, any>> {
|
|
17
|
+
entity?: Entity<M>;
|
|
18
|
+
dataLoading: boolean;
|
|
19
|
+
dataLoadingError?: Error;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Pre-populate the entity fetch cache with entities loaded from a collection.
|
|
23
|
+
* This allows entity detail views to render instantly using cached data,
|
|
24
|
+
* while the background fetch/listener brings in fresh data.
|
|
25
|
+
* @param path - The collection path (e.g. "products")
|
|
26
|
+
* @param entities - Array of entities to cache
|
|
27
|
+
*/
|
|
28
|
+
export declare function populateEntityFetchCache<M extends Record<string, any>>(path: string, entities: Entity<M>[]): void;
|
|
29
|
+
/**
|
|
30
|
+
* This hook is used to fetch an entity.
|
|
31
|
+
* It gives real time updates if the driver supports it.
|
|
32
|
+
* @param path
|
|
33
|
+
* @param collection
|
|
34
|
+
* @param entityId
|
|
35
|
+
* @param useCache
|
|
36
|
+
* @group Hooks and utilities
|
|
37
|
+
*/
|
|
38
|
+
export declare function useEntityFetch<M extends Record<string, any>, USER extends User = User>({ path, entityId, collection, databaseId, useCache }: EntityFetchProps<M, USER>): EntityFetchResult<M>;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import type { EntityCollection } from "@rebasepro/types";
|
|
2
|
+
import { Entity, EntityRelation, FilterValues } from "@rebasepro/types";
|
|
3
|
+
export interface RelationItem {
|
|
4
|
+
id: string | number;
|
|
5
|
+
label: string;
|
|
6
|
+
description?: string;
|
|
7
|
+
data: Entity<any>;
|
|
8
|
+
relation: EntityRelation;
|
|
9
|
+
}
|
|
10
|
+
export interface UseRelationSelectorProps<M extends Record<string, any> = any> {
|
|
11
|
+
/**
|
|
12
|
+
* Full path where the relation data is located
|
|
13
|
+
*/
|
|
14
|
+
path: string;
|
|
15
|
+
/**
|
|
16
|
+
* The collection that represents the relation entities
|
|
17
|
+
*/
|
|
18
|
+
collection: EntityCollection<M>;
|
|
19
|
+
/**
|
|
20
|
+
* Force filter to be applied to the relation search
|
|
21
|
+
*/
|
|
22
|
+
forceFilter?: FilterValues<string>;
|
|
23
|
+
/**
|
|
24
|
+
* Page size for pagination
|
|
25
|
+
*/
|
|
26
|
+
pageSize?: number;
|
|
27
|
+
/**
|
|
28
|
+
* Function to extract the label from an entity
|
|
29
|
+
*/
|
|
30
|
+
getLabelFromEntity?: (entity: Entity<M>) => string;
|
|
31
|
+
/**
|
|
32
|
+
* Function to extract the description from an entity
|
|
33
|
+
*/
|
|
34
|
+
getDescriptionFromEntity?: (entity: Entity<M>) => string | undefined;
|
|
35
|
+
/**
|
|
36
|
+
* Property name to use as the secondary display field
|
|
37
|
+
*/
|
|
38
|
+
descriptionProperty?: keyof M;
|
|
39
|
+
}
|
|
40
|
+
export interface RelationSelectorController {
|
|
41
|
+
items: RelationItem[];
|
|
42
|
+
isLoading: boolean;
|
|
43
|
+
error: Error | undefined;
|
|
44
|
+
search: (searchString: string) => void;
|
|
45
|
+
loadMore: () => void;
|
|
46
|
+
hasMore: boolean;
|
|
47
|
+
entityToRelationItem: (entity: Entity<any>, relation: EntityRelation) => RelationItem;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Hook to manage relation selection with data fetching from Rebase data source
|
|
51
|
+
*/
|
|
52
|
+
export declare function useRelationSelector<M extends Record<string, any> = any>({ path, collection, forceFilter, pageSize, getLabelFromEntity, getDescriptionFromEntity, descriptionProperty }: UseRelationSelectorProps<M>): RelationSelectorController;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { User } from "@rebasepro/types";
|
|
2
|
+
export interface UserSelectorItem {
|
|
3
|
+
uid: string;
|
|
4
|
+
label: string;
|
|
5
|
+
description?: string;
|
|
6
|
+
user: User;
|
|
7
|
+
}
|
|
8
|
+
export interface UseUserSelectorProps {
|
|
9
|
+
/**
|
|
10
|
+
* Page size for pagination. Defaults to 10.
|
|
11
|
+
*/
|
|
12
|
+
pageSize?: number;
|
|
13
|
+
}
|
|
14
|
+
export interface UserSelectorController {
|
|
15
|
+
items: UserSelectorItem[];
|
|
16
|
+
isLoading: boolean;
|
|
17
|
+
error: Error | undefined;
|
|
18
|
+
search: (searchString: string) => void;
|
|
19
|
+
loadMore: () => void;
|
|
20
|
+
hasMore: boolean;
|
|
21
|
+
getUser: (uid: string) => User | null;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Hook to manage user selection with server-side search and pagination.
|
|
25
|
+
* Similar to useRelationSelector but for the UserManagementDelegate.
|
|
26
|
+
*
|
|
27
|
+
* If the delegate provides `searchUsers`, this hook uses server-side
|
|
28
|
+
* search/pagination. Otherwise it falls back to client-side filtering
|
|
29
|
+
* over the in-memory `users` array.
|
|
30
|
+
*/
|
|
31
|
+
export declare function useUserSelector({ pageSize }?: UseUserSelectorProps): UserSelectorController;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
export * from "./data/useData";
|
|
2
|
+
export * from "./data/useCollectionFetch";
|
|
3
|
+
export * from "./data/useEntityFetch";
|
|
4
|
+
export * from "./data/useRelationSelector";
|
|
5
|
+
export * from "./data/useUserSelector";
|
|
6
|
+
export * from "./data/save";
|
|
7
|
+
export * from "./data/delete";
|
|
8
|
+
export * from "./useUnsavedChangesDialog";
|
|
9
|
+
export * from "./useStorageSource";
|
|
10
|
+
export * from "./useAuthController";
|
|
11
|
+
export * from "./useAuthSubscription";
|
|
12
|
+
export * from "./useDialogsController";
|
|
13
|
+
export * from "./useAdminModeController";
|
|
14
|
+
export * from "./useBuildAdminModeController";
|
|
15
|
+
export * from "./useEffectiveRoleController";
|
|
16
|
+
export * from "./useBuildEffectiveRoleController";
|
|
17
|
+
export * from "./useRebaseContext";
|
|
18
|
+
export * from "./useSnackbarController";
|
|
19
|
+
export * from "./useModeController";
|
|
20
|
+
export * from "./useClipboard";
|
|
21
|
+
export * from "./useLargeLayout";
|
|
22
|
+
export * from "./useCollapsedGroups";
|
|
23
|
+
export * from "./useInternalUserManagementController";
|
|
24
|
+
export * from "./useBrowserTitleAndIcon";
|
|
25
|
+
export * from "./useSlot";
|
|
26
|
+
export * from "./useCustomizationController";
|
|
27
|
+
export * from "./useBuildLocalConfigurationPersistence";
|
|
28
|
+
export * from "./useBuildModeController";
|
|
29
|
+
export * from "./useValidateAuthenticator";
|
|
30
|
+
export * from "./useRebaseRegistry";
|
|
31
|
+
export * from "./useBackendStorageSource";
|
|
32
|
+
export * from "./usePermissions";
|
|
33
|
+
export * from "./ApiConfigContext";
|
|
34
|
+
export * from "./useTranslation";
|
|
35
|
+
export * from "./useRebaseClient";
|
|
36
|
+
export * from "./useAnalyticsController";
|
|
37
|
+
export * from "./useUserConfigurationPersistence";
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Use this controller to change the admin mode (developer vs editor)
|
|
3
|
+
* @group Hooks and utilities
|
|
4
|
+
*/
|
|
5
|
+
export interface AdminModeController {
|
|
6
|
+
mode: "content" | "studio" | "settings";
|
|
7
|
+
setMode: (mode: "content" | "studio" | "settings") => void;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Hook to retrieve the current admin mode ("developer" | "editor"), and `setMode`
|
|
11
|
+
* to change it.
|
|
12
|
+
*
|
|
13
|
+
* Consider that in order to use this hook you need to have a parent
|
|
14
|
+
* `Rebase`
|
|
15
|
+
*
|
|
16
|
+
* @see AdminModeController
|
|
17
|
+
* @group Hooks and utilities
|
|
18
|
+
*/
|
|
19
|
+
export declare const useAdminModeController: () => AdminModeController;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { AuthController, User } from "@rebasepro/types";
|
|
2
|
+
/**
|
|
3
|
+
* Hook to retrieve the AuthContext.
|
|
4
|
+
*
|
|
5
|
+
* Consider that in order to use this hook you need to have a parent
|
|
6
|
+
* `Rebase`
|
|
7
|
+
*
|
|
8
|
+
* @see AuthController
|
|
9
|
+
* @group Hooks and utilities
|
|
10
|
+
*/
|
|
11
|
+
export declare const useAuthController: <USER extends User = User, AuthControllerType extends AuthController<USER> = AuthController<USER>>() => AuthControllerType;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* React hook for using backend storage API as a StorageSource
|
|
3
|
+
*/
|
|
4
|
+
import { StorageSource } from "@rebasepro/types";
|
|
5
|
+
export interface BackendStorageSourceProps {
|
|
6
|
+
/**
|
|
7
|
+
* Backend API URL (e.g., 'http://localhost:3001')
|
|
8
|
+
*/
|
|
9
|
+
apiUrl: string;
|
|
10
|
+
/**
|
|
11
|
+
* Function to get the current auth token
|
|
12
|
+
*/
|
|
13
|
+
getAuthToken: () => Promise<string>;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Hook to create a StorageSource that uses the backend storage REST API.
|
|
17
|
+
* Use this for self-hosted Rebase with local or S3 storage.
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* ```tsx
|
|
21
|
+
* const storageSource = useBackendStorageSource({
|
|
22
|
+
* apiUrl: 'http://localhost:3001',
|
|
23
|
+
* getAuthToken: authController.getAuthToken
|
|
24
|
+
* });
|
|
25
|
+
*
|
|
26
|
+
* // Then pass to Rebase:
|
|
27
|
+
* <Rebase storageSource={storageSource} ... />
|
|
28
|
+
* ```
|
|
29
|
+
*/
|
|
30
|
+
export declare function useBackendStorageSource({ apiUrl, getAuthToken }: BackendStorageSourceProps): StorageSource;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { StudioBridge } from "./useStudioBridge";
|
|
2
|
+
/**
|
|
3
|
+
* Registers a value into the self-assembling Studio bridge.
|
|
4
|
+
*
|
|
5
|
+
* Each controller (collectionRegistry, sideEntity, url, navigation, breadcrumbs)
|
|
6
|
+
* calls this hook on mount to inject its real implementation into the bridge.
|
|
7
|
+
* On unmount the slice is automatically removed, reverting to the noop default.
|
|
8
|
+
*
|
|
9
|
+
* Usage:
|
|
10
|
+
* ```tsx
|
|
11
|
+
* function SomeProvider({ children }) {
|
|
12
|
+
* const controller = useBuildSomeController();
|
|
13
|
+
* useBridgeRegistration("sideEntityController", controller);
|
|
14
|
+
* return <SomeContext.Provider value={controller}>{children}</SomeContext.Provider>;
|
|
15
|
+
* }
|
|
16
|
+
* ```
|
|
17
|
+
*/
|
|
18
|
+
export declare function useBridgeRegistration<K extends keyof StudioBridge>(key: K, value: StudioBridge[K]): void;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { EffectiveRoleController } from "@rebasepro/types";
|
|
2
|
+
/**
|
|
3
|
+
* Use this hook to build an effective role controller that determines
|
|
4
|
+
* what role is simulated in Editor mode when Dev mode is active.
|
|
5
|
+
*
|
|
6
|
+
* It uses localStorage to persist the simulated role across reloads.
|
|
7
|
+
*/
|
|
8
|
+
export declare function useBuildEffectiveRoleController(): EffectiveRoleController;
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { MutableRefObject } from "react";
|
|
2
|
+
export interface UseClipboardProps {
|
|
3
|
+
/**
|
|
4
|
+
* It's callback function that is called after the `copy` command
|
|
5
|
+
* is executed.
|
|
6
|
+
*
|
|
7
|
+
* @param text: The selected clipboard text.
|
|
8
|
+
*/
|
|
9
|
+
onSuccess?: (text: string) => void;
|
|
10
|
+
/**
|
|
11
|
+
* Triggers when the hook encounters an error.
|
|
12
|
+
* If passed hook won't throw an error.
|
|
13
|
+
*
|
|
14
|
+
* @param error: cause of the error
|
|
15
|
+
*/
|
|
16
|
+
onError?: (error: string) => void;
|
|
17
|
+
/**
|
|
18
|
+
* Disables the new clipboard API `navigator.clipboard` even if
|
|
19
|
+
* it is supported.
|
|
20
|
+
*/
|
|
21
|
+
disableClipboardAPI?: boolean;
|
|
22
|
+
/**
|
|
23
|
+
* revert back the isCopied flag to false again if a value is set.
|
|
24
|
+
*/
|
|
25
|
+
copiedDuration?: number;
|
|
26
|
+
}
|
|
27
|
+
export interface useClipboardReturnType {
|
|
28
|
+
/**
|
|
29
|
+
* Use ref to pull the text content from.
|
|
30
|
+
*/
|
|
31
|
+
ref: MutableRefObject<any>;
|
|
32
|
+
/**
|
|
33
|
+
* Use it to perform the copy operation
|
|
34
|
+
*/
|
|
35
|
+
copy: (text?: string) => void;
|
|
36
|
+
/**
|
|
37
|
+
* Use it to perform the cut operation
|
|
38
|
+
*/
|
|
39
|
+
cut: () => void;
|
|
40
|
+
/**
|
|
41
|
+
* Indicates wheater the content was successfully copied or not.
|
|
42
|
+
*/
|
|
43
|
+
isCoppied: boolean;
|
|
44
|
+
/**
|
|
45
|
+
* Current selected clipboard content.
|
|
46
|
+
*/
|
|
47
|
+
clipboard: string;
|
|
48
|
+
/**
|
|
49
|
+
* Clears the user clipboard.
|
|
50
|
+
*/
|
|
51
|
+
clearClipboard: () => void;
|
|
52
|
+
/**
|
|
53
|
+
* Check to see if the browser supports the new `navigator.clipboard` API.
|
|
54
|
+
*/
|
|
55
|
+
isSupported: () => boolean;
|
|
56
|
+
}
|
|
57
|
+
export declare const useClipboard: (options?: UseClipboardProps) => useClipboardReturnType;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Custom hook for managing collapsed/expanded state of navigation groups
|
|
3
|
+
* with localStorage persistence. Automatically cleans up stale group entries
|
|
4
|
+
* when groups are removed from the navigation.
|
|
5
|
+
*
|
|
6
|
+
* @param groupNames - Array of group names to track
|
|
7
|
+
* @param namespace - Namespace for localStorage key (e.g., "home", "drawer") to allow independent state
|
|
8
|
+
*/
|
|
9
|
+
export declare function useCollapsedGroups(groupNames: string[], namespace?: string): {
|
|
10
|
+
isGroupCollapsed: (name: string) => boolean;
|
|
11
|
+
toggleGroupCollapsed: (name: string) => void;
|
|
12
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { CustomizationController } from "@rebasepro/types";
|
|
2
|
+
/**
|
|
3
|
+
* Use this hook to retrieve the customization controller.
|
|
4
|
+
* This hook includes all the customization options that can be used
|
|
5
|
+
* to customize the CMS.
|
|
6
|
+
*
|
|
7
|
+
* You will likely not need to use this hook directly.
|
|
8
|
+
*
|
|
9
|
+
* @group Hooks and utilities
|
|
10
|
+
*/
|
|
11
|
+
export declare const useCustomizationController: () => CustomizationController;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { DialogsController } from "@rebasepro/types";
|
|
2
|
+
/**
|
|
3
|
+
* Use this hook to open a dialog imperatively.
|
|
4
|
+
* Alternatively, you can use dialogs declaratively using the `Dialog` component.
|
|
5
|
+
*
|
|
6
|
+
* Consider that in order to use this hook you need to have a parent
|
|
7
|
+
* `Rebase`
|
|
8
|
+
*
|
|
9
|
+
* @group Hooks and utilities
|
|
10
|
+
*/
|
|
11
|
+
export declare const useDialogsController: () => DialogsController;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { User, UserManagementDelegate } from "@rebasepro/types";
|
|
2
|
+
/**
|
|
3
|
+
* Use this hook to get the internal user management of the app.
|
|
4
|
+
* Note that this is different from the user management plugin controller.
|
|
5
|
+
* This controller will be eventually replaced by the one provided
|
|
6
|
+
* by the user management plugin.
|
|
7
|
+
*
|
|
8
|
+
* Use at your own risk!
|
|
9
|
+
*
|
|
10
|
+
* @group Hooks and utilities
|
|
11
|
+
*/
|
|
12
|
+
export declare function useInternalUserManagementController<USER extends User>(): UserManagementDelegate<USER> | undefined;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const useLargeLayout: () => boolean;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Use this controller to change color mode
|
|
3
|
+
* @group Hooks and utilities
|
|
4
|
+
*/
|
|
5
|
+
export interface ModeController {
|
|
6
|
+
mode: "light" | "dark";
|
|
7
|
+
setMode: (mode: "light" | "dark" | "system") => void;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Hook to retrieve the current mode ("light" | "dark"), and `setMode`
|
|
11
|
+
* or `toggle` functions to change it.
|
|
12
|
+
*
|
|
13
|
+
* Consider that in order to use this hook you need to have a parent
|
|
14
|
+
* `Rebase`
|
|
15
|
+
*
|
|
16
|
+
* @see ModeController
|
|
17
|
+
* @group Hooks and utilities
|
|
18
|
+
*/
|
|
19
|
+
export declare const useModeController: () => ModeController;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { EntityCollection } from "@rebasepro/types";
|
|
2
|
+
import { Entity } from "@rebasepro/types";
|
|
3
|
+
/**
|
|
4
|
+
* Hook to evaluate roles and permissions for the current user.
|
|
5
|
+
* It abstracts away the need to pass `authController` to permission evaluation functions.
|
|
6
|
+
*/
|
|
7
|
+
export declare function usePermissions(): {
|
|
8
|
+
canCreate: (collection: EntityCollection<any>, path: string) => boolean;
|
|
9
|
+
canEdit: (collection: EntityCollection<any>, path: string, entity: Entity<any> | null) => boolean;
|
|
10
|
+
canDelete: (collection: EntityCollection<any>, path: string, entity: Entity<any> | null) => boolean;
|
|
11
|
+
canRead: (collection: EntityCollection<any>) => boolean;
|
|
12
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { AuthController, RebaseContext, User } from "@rebasepro/types";
|
|
2
|
+
/**
|
|
3
|
+
* Hook to retrieve the {@link RebaseContext}.
|
|
4
|
+
*
|
|
5
|
+
* Consider that in order to use this hook you need to have a parent
|
|
6
|
+
* `Rebase` component.
|
|
7
|
+
*
|
|
8
|
+
* @see RebaseContext
|
|
9
|
+
* @group Hooks and utilities
|
|
10
|
+
*/
|
|
11
|
+
export declare const useRebaseContext: <USER extends User = User, AuthControllerType extends AuthController<USER> = AuthController<USER>>() => RebaseContext<USER, AuthControllerType>;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import type { RebaseRegistryController, RebaseCMSConfig, RebaseStudioConfig, RebaseAuthConfig } from "@rebasepro/types";
|
|
3
|
+
/**
|
|
4
|
+
* Split into two contexts to prevent infinite re-render loops:
|
|
5
|
+
* - DispatchContext: stable register/unregister functions (never changes identity)
|
|
6
|
+
* - StateContext: the current config values (changes when modules register)
|
|
7
|
+
*
|
|
8
|
+
* Feature components (RebaseAuth, RebaseCMS, RebaseStudio) only consume
|
|
9
|
+
* the dispatch context, so registering does NOT cause them to re-render.
|
|
10
|
+
* RebaseShell consumes state context to read the collected configs.
|
|
11
|
+
*/
|
|
12
|
+
interface RegistryDispatch {
|
|
13
|
+
registerCMS: (config: RebaseCMSConfig) => void;
|
|
14
|
+
unregisterCMS: () => void;
|
|
15
|
+
registerStudio: (config: RebaseStudioConfig) => void;
|
|
16
|
+
unregisterStudio: () => void;
|
|
17
|
+
registerAuth: (config: RebaseAuthConfig) => void;
|
|
18
|
+
unregisterAuth: () => void;
|
|
19
|
+
}
|
|
20
|
+
export declare function RebaseRegistryProvider({ children }: {
|
|
21
|
+
children: React.ReactNode;
|
|
22
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
23
|
+
/**
|
|
24
|
+
* Returns the full registry (state + dispatch).
|
|
25
|
+
* Use this in RebaseShell where you need to read configs.
|
|
26
|
+
*/
|
|
27
|
+
export declare function useRebaseRegistry(): RebaseRegistryController;
|
|
28
|
+
/**
|
|
29
|
+
* Returns only the stable dispatch functions.
|
|
30
|
+
* Use this in feature components (RebaseAuth, RebaseCMS, RebaseStudio)
|
|
31
|
+
* to avoid re-render loops.
|
|
32
|
+
*/
|
|
33
|
+
export declare function useRebaseRegistryDispatch(): RegistryDispatch;
|
|
34
|
+
export {};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { SlotName, SlotRegistry } from "@rebasepro/types";
|
|
2
|
+
import React from "react";
|
|
3
|
+
/**
|
|
4
|
+
* Hook that retrieves and renders all slot contributions for a given slot name.
|
|
5
|
+
*
|
|
6
|
+
* @param slot - The slot name to render contributions for.
|
|
7
|
+
* @param props - Props passed to each slot component.
|
|
8
|
+
* @returns An array of rendered React nodes, each wrapped in an ErrorBoundary.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```tsx
|
|
12
|
+
* const actions = useSlot("home.actions", { context });
|
|
13
|
+
* return <div>{actions}</div>;
|
|
14
|
+
* ```
|
|
15
|
+
*
|
|
16
|
+
* @group Hooks
|
|
17
|
+
*/
|
|
18
|
+
export declare function useSlot<K extends SlotName>(slot: K, props: SlotRegistry[K]): React.ReactNode[];
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { SnackbarMessageType } from "@rebasepro/types";
|
|
2
|
+
import React from "react";
|
|
3
|
+
/**
|
|
4
|
+
* Hook to retrieve the SnackbarContext.
|
|
5
|
+
*
|
|
6
|
+
* Consider that in order to use this hook you need to have a parent
|
|
7
|
+
* `Rebase`
|
|
8
|
+
*
|
|
9
|
+
* @see SnackbarController
|
|
10
|
+
* @group Hooks and utilities
|
|
11
|
+
*/
|
|
12
|
+
export declare const useSnackbarController: () => {
|
|
13
|
+
open: (props: {
|
|
14
|
+
type: SnackbarMessageType;
|
|
15
|
+
title?: string;
|
|
16
|
+
message: React.ReactNode;
|
|
17
|
+
autoHideDuration?: number;
|
|
18
|
+
}) => void;
|
|
19
|
+
close: () => void;
|
|
20
|
+
};
|