@nextcloud/vue
Version:
Nextcloud vue components
84 lines (83 loc) • 2.82 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;
isResizable: 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 (all optional)
* @param props.hasInteractiveView - Whether the widget exposes an interactive view (default: true)
* @param props.fullWidth - Whether the widget renders at full container width (default: false)
* @param props.isResizable - Whether the user can drag-resize the widget height (default: false)
*/
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;
/**
* Check if the widget is resizable.
*
* @param id - Id of the widget
*/
export declare function isResizable(id: string): boolean;
export {};