Skip to content

Commit 8c0fd75

Browse files
committed
feat(SidebarTab): allow to postpone component definition
Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
1 parent ff2cffd commit 8c0fd75

1 file changed

Lines changed: 14 additions & 1 deletion

File tree

lib/sidebar/SidebarTab.ts

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ export interface ISidebarContext {
3232
* @see https://developer.mozilla.org/en-US/docs/Web/API/Web_components
3333
* @see https://vuejs.org/guide/extras/web-components#building-custom-elements-with-vue
3434
*/
35-
export interface SidebarComponent extends HTMLElement, ISidebarContext {
35+
export interface SidebarTabComponent extends ISidebarContext {
3636
/**
3737
* This method is called by the files app if the sidebar tab state changes.
3838
*
@@ -41,6 +41,11 @@ export interface SidebarComponent extends HTMLElement, ISidebarContext {
4141
setActive(active: boolean): Promise<void>
4242
}
4343

44+
/**
45+
* The instance type of a sidebar tab web component.
46+
*/
47+
export type SidebarTabComponentInstance = SidebarTabComponent & HTMLElement
48+
4449
/**
4550
* Implementation of a custom sidebar tab within the files app.
4651
*/
@@ -82,6 +87,14 @@ export interface ISidebarTab {
8287
* @param context - The current context of the files app
8388
*/
8489
enabled: (context: ISidebarContext) => boolean
90+
91+
/**
92+
* Called when the sidebar tab is registered in the sidebar.
93+
* This can be used to call the `CustomElementRegistry.define()` method to register the web component.
94+
*
95+
* The sidebar itself will anyways wait for the component to be defined in the registry (`customElements.whenDefined()`).
96+
*/
97+
register?: () => Promise<void>
8598
}
8699

87100
/**

0 commit comments

Comments
 (0)