Skip to content

Commit 6732407

Browse files
committed
Tweak api so it can be called multiple times
to update the space item's properties.
1 parent 8633ba0 commit 6732407

File tree

2 files changed

+25
-15
lines changed

2 files changed

+25
-15
lines changed

packages/element-web-module-api/element-web-module-api.api.md

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -153,8 +153,7 @@ export interface DirectoryCustomisations {
153153

154154
// @alpha
155155
export interface ExtrasApi {
156-
// (undocumented)
157-
addSpacePanelItem(renderer: SpacePanelItemRenderFunction): void;
156+
setSpacePanelItem(spaceKey: string, props: SpacePanelItemProps): void;
158157
}
159158

160159
// @public
@@ -328,10 +327,21 @@ export interface RoomViewProps {
328327
// @alpha @deprecated (undocumented)
329328
export type RuntimeModuleConstructor = new (api: ModuleApi) => RuntimeModule;
330329

331-
// Warning: (ae-forgotten-export) The symbol "SpacePanelItemProps" needs to be exported by the entry point index.d.ts
332-
//
333330
// @alpha
334-
export type SpacePanelItemRenderFunction = (props: SpacePanelItemProps) => JSX.Element;
331+
export interface SpacePanelItemProps {
332+
// (undocumented)
333+
className?: string;
334+
// (undocumented)
335+
contextMenuTooltip?: string;
336+
// (undocumented)
337+
icon?: JSX.Element;
338+
// (undocumented)
339+
label: string;
340+
// (undocumented)
341+
onSelected?(): void;
342+
// (undocumented)
343+
style?: React.CSSProperties;
344+
}
335345

336346
// @public
337347
export type Translations = Record<string, {

packages/element-web-module-api/src/api/extras.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,30 +8,30 @@ Please see LICENSE files in the repository root for full details.
88
import { JSX } from "react";
99

1010
/**
11-
* Any kind of event that can trigger a button
12-
* @alpha
13-
*/
14-
export type ButtonEvent = React.MouseEvent<Element> | React.KeyboardEvent<Element> | React.FormEvent<Element>;
15-
16-
/**
17-
* The type of the function used to render a space panel item.
11+
* Properties of an item added to the Space panel
1812
* @alpha
1913
*/
2014
export interface SpacePanelItemProps {
21-
spaceKey?: string;
2215
className?: string;
2316
icon?: JSX.Element;
2417
label: string;
2518
contextMenuTooltip?: string;
2619
style?: React.CSSProperties;
2720
//notificationState?: NotificationState;
28-
onClick?(ev?: ButtonEvent): void;
21+
onSelected?(): void;
2922
}
3023

3124
/**
3225
* API for inserting extra UI into Element Web.
3326
* @alpha Subject to change.
3427
*/
3528
export interface ExtrasApi {
36-
addSpacePanelItem(props: SpacePanelItemProps): void;
29+
/**
30+
* Inserts an item into the space panel as if it were a space button, below
31+
* buttons for other spaces.
32+
* If called again with the same spaceKey, will update the existing item.
33+
* @param spaceKey - A key to identify this space-like item.
34+
* @param props - Properties of the item to add.
35+
*/
36+
setSpacePanelItem(spaceKey: string, props: SpacePanelItemProps): void;
3737
}

0 commit comments

Comments
 (0)