@iobroker/adapter-react-v5 8.0.7 → 8.0.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -691,6 +691,10 @@ You can find the migration instructions:
691
691
  -->
692
692
 
693
693
  ## Changelog
694
+ ### 8.0.8 (2025-11-02)
695
+ - (@GermanBluefox) Added possibility to import objects from text
696
+ - (@GermanBluefox) Object browser was split into a few files
697
+
694
698
  ### 8.0.7 (2025-10-28)
695
699
 
696
700
  - (@GermanBluefox) Added `updateSmartNameEx` function to Utils
@@ -5,9 +5,9 @@
5
5
  *
6
6
  */
7
7
  import React, { Component, type JSX } from 'react';
8
- import type { ThemeType, ThemeName, IobTheme, Translate } from '../types';
9
- import type { Router } from './Router';
10
- import { Connection } from '../Connection';
8
+ import { getSelectIdIconFromObjects } from './objectBrowserUtils';
9
+ import type { ObjectBrowserProps, AdapterColumn, ObjectBrowserFilter, ObjectBrowserState, TreeItem, CustomAdminColumnStored, ObjectEvent } from './objectBrowser.types';
10
+ export { getSelectIdIconFromObjects, type ObjectBrowserFilter };
11
11
  declare global {
12
12
  interface Window {
13
13
  sparkline: {
@@ -20,391 +20,7 @@ declare module '@mui/material/Button' {
20
20
  grey: true;
21
21
  }
22
22
  }
23
- type ObjectEventType = 'new' | 'changed' | 'deleted';
24
- interface ObjectEvent {
25
- id: string;
26
- obj?: ioBroker.Object;
27
- type: ObjectEventType;
28
- oldObj?: ioBroker.Object;
29
- }
30
- interface ObjectsWorker {
31
- getObjects(update?: boolean): Promise<void | Record<string, ioBroker.Object>>;
32
- registerHandler(cb: (events: ObjectEvent[]) => void): void;
33
- unregisterHandler(cb: (events: ObjectEvent[]) => void, doNotUnsubscribe?: boolean): void;
34
- }
35
- interface CustomAdminColumnStored {
36
- path: string;
37
- name: string;
38
- objTypes?: ioBroker.ObjectType[];
39
- width?: number;
40
- edit?: boolean;
41
- type?: ioBroker.CommonType;
42
- }
43
- export interface TreeItemData {
44
- id: string;
45
- name: string;
46
- obj?: ioBroker.Object;
47
- /** Object ID in lower case for filtering */
48
- fID?: string;
49
- /** translated common.name in lower case for filtering */
50
- fName?: string;
51
- /** Link to parent item */
52
- parent?: TreeItem;
53
- level?: number;
54
- icon?: string | JSX.Element | null;
55
- /** If the item existing object or generated folder */
56
- generated?: boolean;
57
- title?: string;
58
- /** if the item has "write" button (value=true, ack=false) */
59
- button?: boolean;
60
- /** If the item has read and write and is boolean */
61
- switch?: boolean;
62
- /** If the item is url linke */
63
- url?: boolean;
64
- /** if the item has custom settings in `common.custom` */
65
- hasCustoms?: boolean;
66
- /** If this item is visible */
67
- visible?: boolean;
68
- /** Is any of the children visible (not only directly children) */
69
- hasVisibleChildren?: boolean;
70
- /** Is any of the parents visible (not only directly parent) */
71
- hasVisibleParent?: boolean;
72
- /** Combination of `visible || hasVisibleChildren` */
73
- sumVisibility?: boolean;
74
- /** translated names of enumerations (functions) where this object is the member (or the parent), divided by comma */
75
- funcs?: string;
76
- /** is if the enums are from parent */
77
- pef?: boolean;
78
- /** translated names of enumerations (rooms) where this object is the member (or the parent), divided by comma */
79
- rooms?: string;
80
- /** is if the enums are from parent */
81
- per?: boolean;
82
- lang?: ioBroker.Languages;
83
- state?: {
84
- valTextRx?: JSX.Element[] | null;
85
- style?: React.CSSProperties;
86
- };
87
- aclTooltip?: null | JSX.Element;
88
- }
89
- export interface ObjectBrowserCustomFilter {
90
- type?: ioBroker.ObjectType | ioBroker.ObjectType[];
91
- common?: {
92
- type?: ioBroker.CommonType | ioBroker.CommonType[];
93
- role?: string | string[];
94
- custom?: '_' | '_dataSources' | true | string | string[];
95
- };
96
- }
97
- export interface TreeItem {
98
- id?: string;
99
- data: TreeItemData;
100
- children?: TreeItem[];
101
- }
102
- /** Converts ioB pattern into regex */
103
- export declare function pattern2RegEx(pattern: string): string;
104
- export declare function filterRoles(roleArray: {
105
- role: string;
106
- type: ioBroker.CommonType;
107
- }[], type: ioBroker.CommonType, defaultRoles?: {
108
- role: string;
109
- type: ioBroker.CommonType;
110
- }[]): string[];
111
- export declare function getSelectIdIconFromObjects(objects: Record<string, ioBroker.Object>, id: string, lang: ioBroker.Languages, imagePrefix?: string): string | JSX.Element | null;
112
23
  export declare const ITEM_IMAGES: Record<string, JSX.Element>;
113
- export interface ObjectBrowserFilter {
114
- id?: string;
115
- name?: string;
116
- room?: string[];
117
- func?: string[];
118
- role?: string[];
119
- type?: string[];
120
- custom?: string[];
121
- expertMode?: boolean;
122
- }
123
- interface AdapterColumn {
124
- adapter: string;
125
- id: string;
126
- name: string;
127
- path: string[];
128
- pathText: string;
129
- edit?: boolean;
130
- type?: 'boolean' | 'string' | 'number';
131
- objTypes?: ioBroker.ObjectType[];
132
- align?: 'center' | 'left' | 'right';
133
- }
134
- interface ObjectBrowserEditRoleProps {
135
- roleArray: {
136
- role: string;
137
- type: ioBroker.CommonType;
138
- }[];
139
- id: string;
140
- socket: Connection;
141
- onClose: (obj?: ioBroker.Object | null) => void;
142
- t: Translate;
143
- commonType: ioBroker.CommonType;
144
- }
145
- interface ObjectViewFileDialogProps {
146
- t: Translate;
147
- socket: Connection;
148
- obj: ioBroker.AnyObject;
149
- onClose: () => void;
150
- }
151
- interface DragWrapperProps {
152
- item: TreeItem;
153
- className?: string;
154
- style?: React.CSSProperties;
155
- children: JSX.Element | null;
156
- }
157
- interface ObjectCustomDialogProps {
158
- allVisibleObjects: boolean;
159
- customsInstances: string[];
160
- expertMode?: boolean;
161
- isFloatComma: boolean;
162
- lang: ioBroker.Languages;
163
- objectIDs: string[];
164
- objects: Record<string, ioBroker.Object>;
165
- onClose: () => void;
166
- reportChangedIds: (ids: string[]) => void;
167
- socket: Connection;
168
- systemConfig: ioBroker.SystemConfigObject;
169
- t: Translate;
170
- theme: IobTheme;
171
- themeName: ThemeName;
172
- themeType: ThemeType;
173
- }
174
- interface ObjectMoveRenameDialogProps {
175
- childrenIds: string[];
176
- expertMode: boolean;
177
- id: string;
178
- objectType: ioBroker.ObjectType | undefined;
179
- onClose: () => void;
180
- socket: Connection;
181
- t: Translate;
182
- theme: IobTheme;
183
- }
184
- interface ObjectBrowserValueProps {
185
- /** State type */
186
- type: 'states' | 'string' | 'number' | 'boolean' | 'json';
187
- /** State role */
188
- role: string;
189
- /** common.states */
190
- states: Record<string, string> | null;
191
- /** The state value */
192
- value: string | number | boolean | null;
193
- /** If expert mode is enabled */
194
- expertMode: boolean;
195
- onClose: (newValue?: {
196
- val: ioBroker.StateValue;
197
- ack: boolean;
198
- q: ioBroker.STATE_QUALITY[keyof ioBroker.STATE_QUALITY];
199
- expire: number | undefined;
200
- }) => void;
201
- /** Configured theme */
202
- themeType: ThemeType;
203
- theme: IobTheme;
204
- socket: Connection;
205
- defaultHistory: string;
206
- dateFormat: string;
207
- object: ioBroker.StateObject;
208
- isFloatComma: boolean;
209
- t: Translate;
210
- lang: ioBroker.Languages;
211
- width?: 'xs' | 'sm' | 'md' | 'lg' | 'xl';
212
- }
213
- interface ObjectBrowserEditObjectProps {
214
- socket: Connection;
215
- obj: ioBroker.AnyObject;
216
- roleArray: {
217
- role: string;
218
- type: ioBroker.CommonType;
219
- }[];
220
- expertMode: boolean;
221
- themeType: ThemeType;
222
- theme: IobTheme;
223
- aliasTab: boolean;
224
- onClose: (obj?: ioBroker.AnyObject) => void;
225
- dialogName?: string;
226
- objects: Record<string, ioBroker.AnyObject>;
227
- dateFormat: string;
228
- isFloatComma: boolean;
229
- onNewObject: (obj: ioBroker.AnyObject) => void;
230
- t: Translate;
231
- width?: 'xs' | 'sm' | 'md' | 'lg' | 'xl';
232
- }
233
- export interface ObjectAliasEditorProps {
234
- t: Translate;
235
- roleArray: {
236
- role: string;
237
- type: ioBroker.CommonType;
238
- }[];
239
- socket: Connection;
240
- objects: Record<string, ioBroker.AnyObject>;
241
- onRedirect: (id: string, delay?: number) => void;
242
- obj: ioBroker.AnyObject;
243
- onClose: () => void;
244
- }
245
- export type ObjectBrowserColumn = 'name' | 'type' | 'role' | 'room' | 'func' | 'val' | 'buttons';
246
- type ObjectBrowserPossibleColumns = 'name' | 'type' | 'role' | 'room' | 'func' | 'val' | 'buttons' | 'changedFrom' | 'qualityCode' | 'timestamp' | 'lastChange' | 'id';
247
- export interface ObjectBrowserProps {
248
- /** where to store settings in localStorage */
249
- dialogName?: string;
250
- defaultFilters?: ObjectBrowserFilter;
251
- selected?: string | string[];
252
- onSelect?: (selected: string | string[], name: string | null, isDouble?: boolean) => void;
253
- onFilterChanged?: (newFilter: ObjectBrowserFilter) => void;
254
- socket: Connection;
255
- showExpertButton?: boolean;
256
- expertMode?: boolean;
257
- imagePrefix?: string;
258
- themeName: ThemeName;
259
- themeType: ThemeType;
260
- /** will be filled by withWidth */
261
- width?: 'xs' | 'sm' | 'md' | 'lg' | 'xl';
262
- theme: IobTheme;
263
- t: Translate;
264
- lang: ioBroker.Languages;
265
- multiSelect?: boolean;
266
- notEditable?: boolean;
267
- foldersFirst?: boolean;
268
- disableColumnSelector?: boolean;
269
- isFloatComma?: boolean;
270
- dateFormat?: string;
271
- levelPadding?: number;
272
- /** Allow selection of non-objects (virtual branches) */
273
- allowNonObjects?: boolean;
274
- /** Called when all objects are loaded */
275
- onAllLoaded?: () => void;
276
- objectCustomDialog?: React.FC<ObjectCustomDialogProps>;
277
- objectMoveRenameDialog?: React.FC<ObjectMoveRenameDialogProps>;
278
- objectAddBoolean?: boolean;
279
- objectEditBoolean?: boolean;
280
- objectStatesView?: boolean;
281
- objectImportExport?: boolean;
282
- objectEditOfAccessControl?: boolean;
283
- /** modal add object */
284
- modalNewObject?: (oBrowser: ObjectBrowserClass) => JSX.Element;
285
- /** modal Edit Of Access Control */
286
- modalEditOfAccessControl: (oBrowser: ObjectBrowserClass, data: TreeItemData) => JSX.Element;
287
- onObjectDelete?: (id: string, hasChildren: boolean, objectExists: boolean, childrenCount: number) => void;
288
- /**
289
- * Optional filter
290
- * `{common: {custom: true}}` - show only objects with some custom settings
291
- * `{common: {custom: 'sql.0'}}` - show only objects with sql.0 custom settings (only of the specific instance)
292
- * `{common: {custom: '_dataSources'}}` - show only objects of adapters `influxdb' or 'sql' or 'history'
293
- * `{common: {custom: 'adapterName.'}}` - show only objects of custom settings of specific adapter (all instances)
294
- * `{type: 'channel'}` - show only channels
295
- * `{type: ['channel', 'device']}` - show only channels and devices
296
- * `{common: {type: 'number'}` - show only states of type 'number
297
- * `{common: {type: ['number', 'string']}` - show only states of type 'number and string
298
- * `{common: {role: ['switch']}` - show only states with roles starting from switch
299
- * `{common: {role: ['switch', 'button']}` - show only states with roles starting from `switch` and `button`
300
- */
301
- customFilter: ObjectBrowserCustomFilter;
302
- objectBrowserValue?: React.FC<ObjectBrowserValueProps>;
303
- objectBrowserEditObject?: React.FC<ObjectBrowserEditObjectProps>;
304
- /** on edit alias */
305
- objectBrowserAliasEditor?: React.FC<ObjectAliasEditorProps>;
306
- /** on Edit role */
307
- objectBrowserEditRole?: React.FC<ObjectBrowserEditRoleProps>;
308
- /** on view file state */
309
- objectBrowserViewFile?: React.FC<ObjectViewFileDialogProps>;
310
- router?: typeof Router;
311
- types?: ioBroker.ObjectType[];
312
- /** Possible columns: ['name', 'type', 'role', 'room', 'func', 'val', 'buttons'] */
313
- columns?: ObjectBrowserColumn[];
314
- /** Shows only elements of this root */
315
- root?: string;
316
- /** cache of objects */
317
- objectsWorker?: ObjectsWorker;
318
- /**
319
- * function to filter out all unnecessary objects. It cannot be used together with "types"
320
- * Example for function: `obj => obj.common?.type === 'boolean'` to show only boolean states
321
- */
322
- filterFunc?: (obj: ioBroker.Object) => boolean;
323
- /** Used for enums dragging */
324
- DragWrapper?: React.FC<DragWrapperProps>;
325
- /** let DragWrapper know about objects to get the icons */
326
- setObjectsReference?: (objects: Record<string, ioBroker.Object>) => void;
327
- dragEnabled?: boolean;
328
- }
329
- interface ObjectBrowserState {
330
- loaded: boolean;
331
- foldersFirst: boolean;
332
- selected: string[];
333
- focused: string;
334
- selectedNonObject: string;
335
- filter: ObjectBrowserFilter;
336
- filterKey: number;
337
- depth: number;
338
- expandAllVisible: boolean;
339
- expanded: string[];
340
- toast: string;
341
- scrollBarWidth: number;
342
- customDialog: null | string[];
343
- customDialogAll?: boolean;
344
- editObjectDialog: string;
345
- editObjectAlias: boolean;
346
- viewFileDialog: string;
347
- showAliasEditor: string;
348
- enumDialog: null | {
349
- item: TreeItem;
350
- type: 'room' | 'func';
351
- enumsOriginal: string;
352
- };
353
- enumDialogEnums?: null | string[];
354
- roleDialog: null | string;
355
- statesView: boolean;
356
- /** ['name', 'type', 'role', 'room', 'func', 'val', 'buttons'] */
357
- columns: ObjectBrowserPossibleColumns[] | null;
358
- columnsForAdmin: Record<string, CustomAdminColumnStored[]> | null;
359
- columnsSelectorShow: boolean;
360
- columnsAuto: boolean;
361
- columnsWidths: Record<string, number>;
362
- columnsDialogTransparent: number;
363
- columnsEditCustomDialog: null | {
364
- obj: ioBroker.Object;
365
- item: TreeItem;
366
- it: AdapterColumn;
367
- };
368
- customColumnDialogValueChanged: boolean;
369
- showExportDialog: false | number;
370
- showAllExportOptions: boolean;
371
- linesEnabled: boolean;
372
- showDescription: boolean;
373
- showContextMenu: {
374
- item: TreeItem;
375
- position: {
376
- left: number;
377
- top: number;
378
- };
379
- subItem?: string;
380
- subAnchor?: HTMLLIElement;
381
- } | null;
382
- noStatesByExportImport: boolean;
383
- beautifyJsonExport: boolean;
384
- excludeSystemRepositoriesFromExport: boolean;
385
- excludeTranslations: boolean;
386
- updating?: boolean;
387
- modalNewObj?: null | {
388
- id: string;
389
- initialType?: ioBroker.ObjectType;
390
- initialStateType?: ioBroker.CommonType;
391
- };
392
- error?: any;
393
- modalEditOfAccess?: boolean;
394
- modalEditOfAccessObjData?: TreeItemData;
395
- updateOpened?: boolean;
396
- tooltipInfo: null | {
397
- el: JSX.Element[];
398
- id: string;
399
- };
400
- /** Show the menu with aliases for state */
401
- aliasMenu: string;
402
- /** Show rename dialog */
403
- showRenameDialog: {
404
- id: string;
405
- childrenIds: string[];
406
- } | null;
407
- }
408
24
  export declare class ObjectBrowserClass extends Component<ObjectBrowserProps, ObjectBrowserState> {
409
25
  private info;
410
26
  private localStorage;
@@ -442,7 +58,7 @@ export declare class ObjectBrowserClass extends Component<ObjectBrowserProps, Ob
442
58
  private systemConfig;
443
59
  objects: Record<string, ioBroker.Object>;
444
60
  private defaultHistory;
445
- private cltrPressed;
61
+ private ctrlPressed;
446
62
  private columnsVisibility;
447
63
  private changedIds;
448
64
  private contextMenu;
@@ -450,16 +66,8 @@ export declare class ObjectBrowserClass extends Component<ObjectBrowserProps, Ob
450
66
  private styles;
451
67
  private expertMode;
452
68
  private customColumnDialog;
453
- /** Namespaces which are allowed to be edited by non-expert users */
454
- static NON_EXPERT_NAMESPACES: string[];
455
69
  constructor(props: ObjectBrowserProps);
456
70
  loadAllObjects(update?: boolean): Promise<void>;
457
- /**
458
- * Check if it is a non-expert id
459
- */
460
- static isNonExpertId(
461
- /** id to test */
462
- id: string): boolean;
463
71
  private expandAllSelected;
464
72
  /**
465
73
  * @param isDouble is double click
@@ -565,8 +173,11 @@ export declare class ObjectBrowserClass extends Component<ObjectBrowserProps, Ob
565
173
  private _exportObjects;
566
174
  renderExportDialog(): JSX.Element | null;
567
175
  renderRenameDialog(): JSX.Element | null;
176
+ private parseJsonFile;
568
177
  private handleJsonUpload;
569
178
  toolTipObjectCreating: () => JSX.Element[] | string;
179
+ onOpenFile(): void;
180
+ renderInputJsonDialog(): JSX.Element | null;
570
181
  /**
571
182
  * Renders the toolbar.
572
183
  */
@@ -591,8 +202,6 @@ export declare class ObjectBrowserClass extends Component<ObjectBrowserProps, Ob
591
202
  private renderEditRoleDialog;
592
203
  private onColumnsEditCustomDialogClose;
593
204
  private renderColumnsEditCustomDialog;
594
- private static getCustomValue;
595
- private static setCustomValue;
596
205
  /**
597
206
  * Renders a custom value.
598
207
  */
@@ -660,4 +269,3 @@ export declare class ObjectBrowserClass extends Component<ObjectBrowserProps, Ob
660
269
  render(): JSX.Element;
661
270
  }
662
271
  export declare const ObjectBrowser: (props: Record<string, any>) => JSX.Element;
663
- export {};