@nextcloud/vue
Version:
Nextcloud vue components
74 lines (73 loc) • 2.35 kB
TypeScript
/**
* SPDX-FileCopyrightText: 2023 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
/** Reference interface (copied from OpenAPI core) */
export interface ReferenceWidgetObject {
richObjectType: string;
richObject: {
[key: string]: Record<string, unknown> | null;
};
openGraphObject: {
id: string;
name: string;
description: string | null;
thumb: string | null;
link: string;
};
accessible: boolean;
}
export interface ReferenceWidgetRenderProperties extends ReferenceWidgetObject {
interactive: boolean;
}
type ReferenceWidgetRenderCallback = (el: HTMLElement, properties: ReferenceWidgetRenderProperties) => void;
type ReferenceWidgetDestroyCallback = (el: HTMLElement) => void;
export interface ReferenceWidgetProps {
id: string;
hasInteractiveView: boolean;
fullWidth: boolean;
callback: ReferenceWidgetRenderCallback;
onDestroy: ReferenceWidgetDestroyCallback;
}
/**
* Register a new reference widget
*
* @param id - Id tof the widget
* @param callback - Render callback
* @param onDestroy - Cleanup callback
* @param props - Widget props
*/
export declare function registerWidget(id: string, callback: ReferenceWidgetRenderCallback, onDestroy?: ReferenceWidgetDestroyCallback, props?: Partial<ReferenceWidgetProps>): void;
/**
* Render a reference widget to a given HTML element.
*
* @param el - The element to render widget to
* @param options - render options
*/
export declare function renderWidget(el: HTMLElement, options: ReferenceWidgetRenderProperties): void;
/**
* Call the cleanup callback of the reference widget for given object type.
*
* @param richObjectType - The object type
* @param el - The element
*/
export declare function destroyWidget(richObjectType: string, el: HTMLElement): void;
/**
* Check if a widget with the give id is registered.
*
* @param id - Id of the widget
*/
export declare function isWidgetRegistered(id: string): boolean;
/**
* Check if the given widget has an interactive view.
*
* @param id - Id of the widget
*/
export declare function hasInteractiveView(id: string): boolean;
/**
* Check if the widget supports full width.
*
* @param id - Id of the widget
*/
export declare function hasFullWidth(id: string): boolean;
export {};