Add API to replace Login component renderer

This commit is contained in:
Michael Telatynski
2026-03-02 16:54:23 +00:00
parent 7206db8243
commit ccf3fcf4af
2 changed files with 107 additions and 2 deletions
@@ -7,6 +7,7 @@
import { ComponentType } from 'react';
import { JSX } from 'react';
import { ModuleApi } from '@matrix-org/react-sdk-module-api';
import { ReactNode } from 'react';
import { Root } from 'react-dom/client';
import { RuntimeModule } from '@matrix-org/react-sdk-module-api';
@@ -109,10 +110,29 @@ export interface ConfigApi {
// @alpha
export interface CustomComponentsApi {
registerLoginComponent(renderer: CustomLoginRenderFunction): void;
registerMessageRenderer(eventTypeOrFilter: string | ((mxEvent: MatrixEvent) => boolean), renderer: CustomMessageRenderFunction, hints?: CustomMessageRenderHints): void;
registerRoomPreviewBar(renderer: CustomRoomPreviewBarRenderFunction): void;
}
// @alpha
export type CustomLoginComponentProps = {
serverConfig: CustomLoginComponentPropsServerConfig;
fragmentAfterLogin?: string;
children?: ReactNode;
onLoggedIn(data: AccountAuthInfo): void;
onServerConfigChange(config: CustomLoginComponentPropsServerConfig): void;
};
// @alpha
export interface CustomLoginComponentPropsServerConfig {
hsName: string;
hsUrl: string;
}
// @alpha
export type CustomLoginRenderFunction = ExtendablePropsRenderFunction<CustomLoginComponentProps>;
// @alpha
export type CustomMessageComponentProps = {
mxEvent: MatrixEvent;
@@ -171,6 +191,11 @@ export interface DirectoryCustomisations {
requireCanonicalAliasAccessToPublish?(): boolean;
}
// @alpha
export type ExtendablePropsRenderFunction<BaseProps> = <P extends BaseProps>(
props: P,
originalComponent: (props: P) => JSX.Element) => JSX.Element;
// @alpha
export interface ExtrasApi {
getVisibleRoomBySpaceKey(spaceKey: string, cb: () => string[]): void;
@@ -476,4 +501,3 @@ export interface WidgetVariablesCustomisations {
// (No @packageDocumentation comment for this package)
```