@iobroker/adapter-react-v5
Version:
React components to develop ioBroker interfaces with react.
171 lines (170 loc) • 7.25 kB
TypeScript
import React, { Component, type JSX } from 'react';
import type { ThemeType } from '../types';
import type { FormatValueOptions, InputSelectItem, TreeItem, ObjectBrowserCustomFilter, TreeInfo, GetValueStyleOptions, AdapterColumn, ObjectBrowserFilter, TreeItemData } from './objectBrowser.types';
export declare const ICON_SIZE = 24;
export declare const ROW_HEIGHT = 32;
export declare const COLOR_NAME_USERDATA: (themeType: ThemeType) => string;
export declare const COLOR_NAME_ALIAS: (themeType: ThemeType) => string;
export declare const COLOR_NAME_JAVASCRIPT: (themeType: ThemeType) => string;
export declare const COLOR_NAME_SYSTEM: (themeType: ThemeType) => string;
export declare const COLOR_NAME_SYSTEM_ADAPTER: (themeType: ThemeType) => string;
export declare const styles: Record<string, any>;
export declare function ButtonIcon(props?: {
style?: React.CSSProperties;
}): JSX.Element;
/** Converts ioB pattern into regex */
export declare function pattern2RegEx(pattern: string): string;
/**
* Function that walks through all keys of an object or array and applies a function to each key.
*/
export declare function walkThroughArray(object: any[], iteratee: (result: any[], value: any, key: number) => void): any[];
/**
* Function that walks through all keys of an object or array and applies a function to each key.
*/
export declare function walkThroughObject(object: Record<string, any>, iteratee: (result: Record<string, any>, value: any, key: string) => void): Record<string, any>;
/**
* Function to reduce an object primarily by a given list of keys
*/
export declare function filterObject(
/** The objects which should be filtered */
obj: Record<string, any> | any[],
/** The keys which should be excluded */
filterKeys: string[],
/** Whether translations should be reduced to only the english value */
excludeTranslations?: boolean): Record<string, any> | any[];
export declare function filterRoles(roleArray: {
role: string;
type: ioBroker.CommonType;
}[], type: ioBroker.CommonType, defaultRoles?: {
role: string;
type: ioBroker.CommonType;
}[]): string[];
/**
* Function to generate a json-file for an object and trigger download it
*/
export declare function generateFile(
/** The desired filename */
fileName: string,
/** The objects which should be downloaded */
obj: Record<string, ioBroker.Object>,
/** Options to filter/reduce the output */
options: {
/** Whether the output should be beautified */
beautify?: boolean;
/** Whether "system.repositories" should be excluded */
excludeSystemRepositories?: boolean;
/** Whether translations should be reduced to only the english value */
excludeTranslations?: boolean;
}): void;
interface CustomFilterSelectProps {
name: 'room' | 'func' | 'type' | 'role' | 'custom';
texts: Record<string, string>;
initialValue: string[] | undefined;
onChange: (name: 'room' | 'func' | 'type' | 'role' | 'custom', value: string[] | undefined) => void;
values: (string | InputSelectItem)[];
}
interface CustomFilterSelectState {
value: string[];
}
export declare class CustomFilterSelect extends Component<CustomFilterSelectProps, CustomFilterSelectState> {
private readonly hasIcons;
private timer;
constructor(props: CustomFilterSelectProps);
componentWillUnmount(): void;
render(): React.JSX.Element;
}
interface CustomFilterInputProps {
name: 'name' | 'id';
texts: Record<string, string>;
initialValue: string | undefined;
onChange: (name: 'name' | 'id', value: string | undefined) => void;
t: (text: string) => string;
styles?: React.CSSProperties;
}
interface CustomFilterInputState {
value: string;
}
export declare class CustomFilterInput extends Component<CustomFilterInputProps, CustomFilterInputState> {
private timer;
constructor(props: CustomFilterInputProps);
componentWillUnmount(): void;
render(): React.JSX.Element;
}
export declare function binarySearch(list: string[], find: string, _start?: number, _end?: number): boolean;
export declare function getName(name: ioBroker.StringOrTranslated, lang: ioBroker.Languages): string;
export declare function getSelectIdIconFromObjects(objects: Record<string, ioBroker.Object>, id: string, lang: ioBroker.Languages, imagePrefix?: string): string | JSX.Element | null;
export declare function applyFilter(item: TreeItem, filters: ObjectBrowserFilter, lang: ioBroker.Languages, objects: Record<string, ioBroker.Object>, context?: {
id?: string;
idRx?: RegExp;
name?: string;
nameRx?: RegExp;
type?: string[];
custom?: string[];
role?: string[];
room?: string[];
func?: string[];
}, counter?: {
count: number;
}, customFilter?: ObjectBrowserCustomFilter, selectedTypes?: string[], _depth?: number): boolean;
export declare function getVisibleItems(item: TreeItem, type: ioBroker.ObjectType, objects: Record<string, ioBroker.Object>, _result?: string[]): string[];
export declare function getObjectTooltip(data: TreeItemData, lang: ioBroker.Languages): string | null;
export declare function getIdFieldTooltip(data: TreeItemData, lang: ioBroker.Languages): JSX.Element;
export declare function buildTree(objects: Record<string, ioBroker.Object>, options: {
imagePrefix?: string;
root?: string;
lang: ioBroker.Languages;
themeType: ThemeType;
}): {
root: TreeItem;
info: TreeInfo;
};
export declare function findNode(root: TreeItem, id: string, _parts?: string[], _path?: string, _level?: number): TreeItem | null;
export declare function findRoomsForObject(info: TreeInfo, id: string, lang: ioBroker.Languages, rooms?: string[]): {
rooms: string[];
per: boolean;
};
export declare function findEnumsForObjectAsIds(info: TreeInfo, id: string, enumName: 'roomEnums' | 'funcEnums', funcs?: string[]): string[];
export declare function findFunctionsForObject(info: TreeInfo, id: string, lang: ioBroker.Languages, funcs?: string[]): {
funcs: string[];
pef: boolean;
};
/**
* Format a state value for visualization
*/
export declare function formatValue(options: FormatValueOptions): {
valText: {
/** value as string */
v: string;
/** value unit */
u?: string;
/** value isn't replaced by `common.states` */
s?: string;
/** Text for copy to clipboard */
c?: string;
};
valFull: {
/** label */
t: string;
/** value */
v: string;
/** no break */
nbr?: boolean;
}[] | undefined;
fileViewer: 'image' | 'text' | 'json' | 'html' | 'pdf' | 'audio' | 'video' | undefined;
};
/**
* Get CSS style for given state value
*/
export declare function getValueStyle(options: GetValueStyleOptions): {
color: string;
};
export declare function prepareSparkData(values: ioBroker.GetHistoryResult, from: number): number[];
export declare function getCustomValue(obj: ioBroker.Object, it: AdapterColumn): string | number | boolean | null;
export declare function setCustomValue(obj: ioBroker.Object, it: AdapterColumn, value: string | number | boolean): boolean;
/**
* Check if it is a non-expert id
*
* @param id id to test
*/
export declare function isNonExpertId(id: string): boolean;
export {};