@iobroker/adapter-react-v5
Version:
React components to develop ioBroker interfaces with react.
272 lines (271 loc) • 8.55 kB
TypeScript
/**
* Copyright 2020-2025, Denis Haev <dogafox@gmail.com>
*
* MIT License
*
*/
import React, { Component, type JSX } from 'react';
import { getSelectIdIconFromObjects } from './objectBrowserUtils';
import type { ObjectBrowserProps, AdapterColumn, ObjectBrowserFilter, ObjectBrowserState, TreeItem, CustomAdminColumnStored, ObjectEvent } from './objectBrowser.types';
export { getSelectIdIconFromObjects, type ObjectBrowserFilter };
declare global {
interface Window {
sparkline: {
sparkline: (el: HTMLDivElement, data: number[]) => JSX.Element;
};
}
}
declare module '@mui/material/Button' {
interface ButtonPropsColorOverrides {
grey: true;
}
}
export declare const ITEM_IMAGES: Record<string, JSX.Element>;
export declare class ObjectBrowserClass extends Component<ObjectBrowserProps, ObjectBrowserState> {
private info;
private localStorage;
private readonly tableRef;
private pausedSubscribes;
private selectFirst;
private root;
private readonly states;
private subscribes;
private unsubscribeTimer;
private statesUpdateTimer;
private objectsUpdateTimer;
private readonly visibleCols;
private readonly texts;
private readonly possibleCols;
private readonly imagePrefix;
private adapterColumns;
private styleTheme;
private edit;
private readonly levelPadding;
private customWidth;
private resizeTimeout;
private resizerNextName;
private resizerActiveName;
private resizerCurrentWidths;
private resizeLeft;
private resizerOldWidth;
private resizerMin;
private resizerNextMin;
private resizerOldWidthNext;
private resizerPosition;
private resizerActiveDiv;
private resizerNextDiv;
private storedWidths;
private systemConfig;
objects: Record<string, ioBroker.Object>;
private defaultHistory;
private ctrlPressed;
private columnsVisibility;
private changedIds;
private contextMenu;
private recordStates;
private styles;
private expertMode;
private customColumnDialog;
constructor(props: ObjectBrowserProps);
loadAllObjects(update?: boolean): Promise<void>;
private expandAllSelected;
/**
* @param isDouble is double click
*/
private onAfterSelect;
private static getDerivedStateFromProps;
/**
* Called when component is mounted.
*/
componentDidMount(): Promise<void>;
onKeyPress: (event: KeyboardEvent) => void;
/**
* Called when component is unmounted.
*/
componentWillUnmount(): void;
/**
* Show the deletion dialog for a given object
*/
showDeleteDialog(options: {
id: string;
obj: ioBroker.Object;
item: TreeItem;
}): void;
/**
* Context menu handler.
*/
onContextMenu: (e: MouseEvent) => void;
/**
* Called when component is mounted.
*/
refreshComponent(): void;
/**
* Renders the error dialog.
*/
renderErrorDialog(): JSX.Element | null;
/**
* Show the error dialog.
*/
showError(error: any): void;
/**
* Called when an item is selected/deselected.
*/
onSelect(toggleItem: string, isDouble?: boolean, cb?: () => void): void;
private _renderDefinedList;
/**
* Renders the columns' selector.
*/
renderColumnsSelectorDialog(): JSX.Element | null;
private getAdditionalColumns;
private checkUnsubscribes;
/**
* Find an item.
*/
findItem(id: string, _parts?: string[], _root?: TreeItem | null, _partyId?: string): TreeItem | null;
/**
* Called when a state changes.
*/
onStateChange: (id: string, state?: ioBroker.State | null) => void;
private parseObjectForAdmins;
onObjectChangeFromWorker: (events: ObjectEvent[]) => void;
onObjectChange: (id: string, obj?: ioBroker.Object | null) => void;
afterObjectUpdated(): void;
updateAliases(aliasId: string): void;
/**
* Processes a single element in regard to certain filters, columns for admin and updates object dict
*
* @param id The id of the object
* @param obj The object itself
* @returns Returns an object containing the new state (if any) and whether the object was filtered.
*/
processOnObjectChangeElement(id: string, obj?: ioBroker.Object | null): {
filtered: boolean;
newInnerState: null | {
columnsForAdmin: Record<string, CustomAdminColumnStored[]> | null;
};
};
private subscribe;
private unsubscribe;
private pauseSubscribe;
clearFilter(): void;
isFilterEmpty(): boolean;
private getFilterInput;
private getFilterSelect;
private getFilterSelectRole;
private getFilterSelectRoom;
private getFilterSelectFunction;
private getFilterSelectType;
private getFilterSelectCustoms;
private onExpandAll;
private onCollapseAll;
private expandDepth;
private static collapseDepth;
private onExpandVisible;
private onStatesViewVisible;
private onCollapseVisible;
private getEnumsForId;
private _createAllEnums;
private loadObjects;
_getSelectedIdsForExport(): string[];
/**
* Exports the selected objects based on the given options and triggers file generation
*/
private _exportObjects;
renderExportDialog(): JSX.Element | null;
renderRenameDialog(): JSX.Element | null;
private parseJsonFile;
private handleJsonUpload;
toolTipObjectCreating: () => JSX.Element[] | string;
onOpenFile(): void;
renderInputJsonDialog(): JSX.Element | null;
/**
* Renders the toolbar.
*/
getToolbar(): JSX.Element;
private toggleExpanded;
private onCopy;
renderTooltipAccessControl: (acl: ioBroker.StateACL) => null | JSX.Element;
renderColumnButtons(id: string, item: TreeItem): (JSX.Element | null)[] | JSX.Element | null;
private readHistory;
private getTooltipInfo;
/**
* This function renders the value in different forms in the table
*
* @param id state ID
* @param item Item
* @param narrowStyleWithDetails if use mobile view
*/
private renderColumnValue;
private _syncEnum;
private syncEnum;
private renderEnumDialog;
private renderEditRoleDialog;
private onColumnsEditCustomDialogClose;
private renderColumnsEditCustomDialog;
/**
* Renders a custom value.
*/
renderCustomValue(obj: ioBroker.Object, it: AdapterColumn, item: TreeItem): JSX.Element | null;
renderAliasLink(id: string, index?: number, customStyle?: Record<string, any>): JSX.Element | null;
/**
* Renders a leaf.
*/
renderLeaf(item: TreeItem, isExpanded: boolean | undefined, counter: {
count: number;
}): {
row: JSX.Element;
details: JSX.Element | null;
};
/**
* Renders an item.
*/
renderItem(root: TreeItem, isExpanded: boolean | undefined, counter?: {
count: number;
}): JSX.Element[];
private calculateColumnsVisibility;
resizerMouseMove: (e: MouseEvent) => void;
resizerMouseUp: () => void;
resizerMouseDown: (e: React.MouseEvent<HTMLDivElement>) => void;
/**
* Handle keyboard events for navigation
*/
navigateKeyPress(event: React.KeyboardEvent): void;
/**
* Find the id from the root
*
* @param root The current root
* @param id The object id to find
*/
private static getItemFromRoot;
resizerReset: () => void;
/**
* Render the right handle for resizing
*/
renderHandleRight(): JSX.Element;
private renderHeader;
private renderToast;
/**
* Called when component is updated.
*/
componentDidUpdate(): void;
scrollToItem(id: string): void;
private renderCustomDialog;
private onUpdate;
private renderEditObjectDialog;
private renderViewObjectFileDialog;
private renderAliasEditorDialog;
showAddDataPointDialog(id: string, initialType: ioBroker.ObjectType, initialStateType?: ioBroker.CommonType): void;
/** Renders the aliases list for one state (if more than 2) */
private renderAliasMenu;
/**
* Renders the right mouse button context menu
*/
private renderContextMenu;
private renderEditValueDialog;
doFilter(doNotStore?: boolean): void;
/**
* The rendering method of this component.
*/
render(): JSX.Element;
}
export declare const ObjectBrowser: (props: Record<string, any>) => JSX.Element;