@iobroker/adapter-react-v5 5.0.4 → 5.0.6

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.
Files changed (55) hide show
  1. package/Components/ColorPicker.d.ts +0 -1
  2. package/Components/ColorPicker.js +1 -1
  3. package/Components/ComplexCron.js +20 -28
  4. package/Components/CopyToClipboard.js +0 -4
  5. package/Components/CustomModal.js +1 -5
  6. package/Components/FileBrowser.js +13 -18
  7. package/Components/FileViewer.js +4 -11
  8. package/Components/Icon.d.ts +2 -2
  9. package/Components/Icon.js +2 -2
  10. package/Components/IconSelector.js +2 -10
  11. package/Components/Image.js +3 -1
  12. package/Components/Loader.d.ts +2 -2
  13. package/Components/Loader.js +1 -1
  14. package/Components/Loaders/PT.d.ts +1 -1
  15. package/Components/Loaders/PT.js +1 -1
  16. package/Components/Loaders/Vendor.d.ts +1 -1
  17. package/Components/Loaders/Vendor.js +2 -2
  18. package/Components/Logo.js +1 -1
  19. package/Components/MDUtils.js +2 -0
  20. package/Components/ObjectBrowser.d.ts +526 -2
  21. package/Components/ObjectBrowser.js +100 -84
  22. package/Components/SaveCloseButtons.js +9 -18
  23. package/Components/Schedule.js +2 -2
  24. package/Components/SimpleCron/cron2text.js +5 -3
  25. package/Components/SimpleCron/cronText.js +1 -1
  26. package/Components/SimpleCron/index.js +29 -35
  27. package/Components/TableResize.d.ts +1 -1
  28. package/Components/TableResize.js +1 -1
  29. package/Components/TextWithIcon.js +1 -1
  30. package/Components/TreeTable.js +5 -4
  31. package/Components/Utils.d.ts +58 -60
  32. package/Components/Utils.js +239 -197
  33. package/Dialogs/ComplexCron.js +2 -10
  34. package/Dialogs/Confirm.d.ts +1 -1
  35. package/Dialogs/Confirm.js +2 -4
  36. package/Dialogs/Cron.js +1 -3
  37. package/Dialogs/Error.d.ts +1 -11
  38. package/Dialogs/Error.js +1 -7
  39. package/Dialogs/Message.d.ts +1 -12
  40. package/Dialogs/Message.js +1 -8
  41. package/Dialogs/SelectFile.js +1 -5
  42. package/Dialogs/SelectID.d.ts +1 -1
  43. package/Dialogs/SelectID.js +13 -7
  44. package/Dialogs/SimpleCron.js +1 -3
  45. package/Dialogs/TextInput.js +1 -5
  46. package/GenericApp.d.ts +2 -3
  47. package/GenericApp.js +11 -9
  48. package/LegacyConnection.d.ts +11 -12
  49. package/LegacyConnection.js +350 -222
  50. package/README.md +25 -0
  51. package/craco-module-federation.js +2 -2
  52. package/i18n.d.ts +1 -1
  53. package/i18n.js +6 -8
  54. package/package.json +7 -7
  55. package/types.d.ts +27 -27
@@ -312,7 +312,7 @@ class TreeTable extends react_1.Component {
312
312
  }
313
313
  renderSelectIdDialog() {
314
314
  if (this.state.showSelectId && this.props.socket) {
315
- return react_1.default.createElement(SelectID_1.default, { key: "tableSelect", imagePrefix: "../..", dialogName: this.props.adapterName, themeType: this.props.themeType, socket: this.props.socket, selected: this.state.selectIdValue, onClose: () => this.setState({ showSelectId: false }), onOk: (selected /* , name*/) => {
315
+ return react_1.default.createElement(SelectID_1.default, { key: "tableSelect", imagePrefix: "../..", dialogName: this.props.adapterName, themeType: this.props.themeType, socket: this.props.socket, selected: this.state.selectIdValue, onClose: () => this.setState({ showSelectId: false }), onOk: (selected /* , name */) => {
316
316
  this.setState({ showSelectId: false, selectIdValue: null });
317
317
  this.selectCallback && this.selectCallback(selected);
318
318
  this.selectCallback = null;
@@ -329,7 +329,7 @@ class TreeTable extends react_1.Component {
329
329
  }, size: "large" },
330
330
  react_1.default.createElement(icons_material_1.ViewHeadline, null)));
331
331
  }
332
- renderCellNonEdit(item, col) {
332
+ static renderCellNonEdit(item, col) {
333
333
  let val = getAttr(item, col.field, col.lookup);
334
334
  if (Array.isArray(val)) {
335
335
  val = val[0];
@@ -343,7 +343,7 @@ class TreeTable extends react_1.Component {
343
343
  if (this.state.editMode === i && col.editable !== 'never' && col.editable !== false) {
344
344
  return react_1.default.createElement(material_1.TableCell, { key: col.field, className: Utils_1.default.clsx(this.props.classes.cell, level && this.props.classes.cellSecondary), style: col.cellStyle, component: "th" }, this.renderCellEdit(item, col));
345
345
  }
346
- return react_1.default.createElement(material_1.TableCell, { key: col.field, className: Utils_1.default.clsx(this.props.classes.cell, level && this.props.classes.cellSecondary), style: col.cellStyle, component: "th" }, this.renderCellNonEdit(item, col));
346
+ return react_1.default.createElement(material_1.TableCell, { key: col.field, className: Utils_1.default.clsx(this.props.classes.cell, level && this.props.classes.cellSecondary), style: col.cellStyle, component: "th" }, TreeTable.renderCellNonEdit(item, col));
347
347
  }
348
348
  renderCellWithSubField(item, col) {
349
349
  const main = getAttr(item, col.field, col.lookup);
@@ -447,7 +447,7 @@ class TreeTable extends react_1.Component {
447
447
  react_1.default.createElement(material_1.TableCell, { component: "th", className: Utils_1.default.clsx(this.props.classes.cell, this.props.classes.cellHeader, this.props.classes.cellButton) }) : null));
448
448
  }
449
449
  render() {
450
- const col = this.props.columns.find(col => col.field === this.state.orderBy);
450
+ const col = this.props.columns.find(_col => _col.field === this.state.orderBy);
451
451
  if (col) {
452
452
  const lookup = col.lookup;
453
453
  const table = stableSort(this.props.data, getComparator(this.state.order, this.state.orderBy, lookup));
@@ -465,6 +465,7 @@ class TreeTable extends react_1.Component {
465
465
  this.renderSelectIdDialog(),
466
466
  this.renderSelectColorDialog());
467
467
  }
468
+ return null;
468
469
  }
469
470
  }
470
471
  /*
@@ -3,13 +3,9 @@
3
3
  *
4
4
  * MIT License
5
5
  *
6
- **/
6
+ * */
7
7
  import React from 'react';
8
8
  import { ThemeName, ThemeType } from '../types';
9
- interface GetObjectNameOptions {
10
- name?: ioBroker.StringOrTranslated;
11
- language?: ioBroker.Languages;
12
- }
13
9
  type SmartName = null | false | string | ({
14
10
  [lang in ioBroker.Languages]?: string;
15
11
  } & {
@@ -18,11 +14,9 @@ type SmartName = null | false | string | ({
18
14
  /** Which value to set when the ON command is issued */
19
15
  byON?: string | null;
20
16
  });
21
- declare namespace clsx {
22
- type ClassValue = ClassArray | ClassDictionary | string | number | null | boolean | undefined;
23
- type ClassDictionary = Record<string, any>;
24
- type ClassArray = ClassValue[];
25
- }
17
+ type ClassDictionary = Record<string, any>;
18
+ type ClassValue = ClassArray | ClassDictionary | string | number | null | boolean | undefined;
19
+ type ClassArray = ClassValue[];
26
20
  declare class Utils {
27
21
  static namespace: string;
28
22
  static INSTANCES: string;
@@ -31,37 +25,43 @@ declare class Utils {
31
25
  /**
32
26
  * Capitalize words.
33
27
  */
34
- static CapitalWords(name: string): string;
28
+ static CapitalWords(name: string | null | undefined): string;
35
29
  static formatSeconds(seconds: number): string;
36
30
  /**
37
31
  * Get the name of the object by id from the name or description.
38
- * @param objects
39
- * @param id
40
- * @param settings
41
- * @param options
42
- * @param isDesc Set to true to get the description.
43
32
  */
44
- static getObjectName(objects: Record<string, ioBroker.Object>, id: string, settings?: GetObjectNameOptions | ioBroker.Languages | null, options?: GetObjectNameOptions, isDesc?: boolean): string;
33
+ static getObjectName(objects: Record<string, ioBroker.Object>, id: string, settings?: {
34
+ name: ioBroker.StringOrTranslated;
35
+ } | ioBroker.Languages | null, options?: {
36
+ language?: ioBroker.Languages;
37
+ },
38
+ /** Set to true to get the description. */
39
+ isDesc?: boolean): string;
45
40
  /**
46
41
  * Get the name of the object from the name or description.
47
- * @param obj
48
- * @param settings or language
49
- * @param options
50
- * @param isDesc Set to true to get the description.
51
- * @param noTrim Allow to use spaces in name (by edit)
52
42
  */
53
- static getObjectNameFromObj(obj: ioBroker.Object, settings?: GetObjectNameOptions | ioBroker.Languages | null, options?: GetObjectNameOptions, isDesc?: boolean, noTrim?: boolean): string;
43
+ static getObjectNameFromObj(obj: ioBroker.PartialObject,
44
+ /** settings or language */
45
+ settings: {
46
+ name: ioBroker.StringOrTranslated;
47
+ } | ioBroker.Languages | null, options?: {
48
+ language?: ioBroker.Languages;
49
+ },
50
+ /** Set to true to get the description. */
51
+ isDesc?: boolean,
52
+ /** Allow using spaces in name (by edit) */
53
+ noTrim?: boolean): string;
54
54
  /**
55
55
  * Extracts from the object material settings, depends on username
56
56
  */
57
57
  static getSettingsOrder(obj: ioBroker.StateObject | ioBroker.StateCommon, forEnumId: string, options: {
58
- user: string;
58
+ user?: string;
59
59
  }): string | null;
60
60
  /**
61
61
  Used in material
62
62
  */
63
63
  static getSettingsCustomURLs(obj: ioBroker.StateObject | ioBroker.StateCommon, forEnumId: string, options: {
64
- user: string;
64
+ user?: string;
65
65
  }): string | null;
66
66
  /**
67
67
  * Reorder the array items in list between source and dest.
@@ -81,7 +81,7 @@ declare class Utils {
81
81
  /**
82
82
  Sets smartName settings for the given object.
83
83
  */
84
- static setSettings(obj: ioBroker.StateObject, settings: any, options: {
84
+ static setSettings(obj: Partial<ioBroker.Object>, settings: Record<string, any>, options: {
85
85
  user?: string;
86
86
  language?: ioBroker.Languages;
87
87
  }): boolean;
@@ -98,9 +98,9 @@ declare class Utils {
98
98
  */
99
99
  static getObjectIcon(id: string | ioBroker.PartialObject, obj?: ioBroker.PartialObject): string | null;
100
100
  /**
101
- * Splits CamelCase into words.
101
+ * Converts word1_word2 to word1Word2.
102
102
  */
103
- static splitCamelCase(text: string | undefined): string;
103
+ static splitCamelCase(text: string | null | undefined): string;
104
104
  /**
105
105
  * Check if the given color is bright.
106
106
  * https://stackoverflow.com/questions/35969656/how-can-i-generate-the-opposite-color-according-to-current-color
@@ -112,9 +112,10 @@ declare class Utils {
112
112
  static getTimeString(seconds: string | number): string;
113
113
  /**
114
114
  * Gets the wind direction with the given angle (degrees).
115
- * @param angle in degrees.
116
115
  */
117
- static getWindDirection(angle: number): string;
116
+ static getWindDirection(
117
+ /** angle in degrees from 0° to 360° */
118
+ angle: number): string;
118
119
  /**
119
120
  * Pad the given number with a zero if it's not two digits long.
120
121
  */
@@ -138,7 +139,7 @@ declare class Utils {
138
139
  /**
139
140
  * Get the smart name from a state.
140
141
  */
141
- static getSmartNameFromObj(obj: ioBroker.StateObject, instanceId: string, noCommon?: boolean): SmartName | undefined;
142
+ static getSmartNameFromObj(obj: ioBroker.StateObject | ioBroker.StateCommon, instanceId: string, noCommon?: boolean): SmartName | undefined;
142
143
  /**
143
144
  * Enable smart name for a state.
144
145
  */
@@ -148,7 +149,7 @@ declare class Utils {
148
149
  */
149
150
  static removeSmartName(obj: ioBroker.StateObject, instanceId: string, noCommon?: boolean): void;
150
151
  /**
151
- * Update the smartname of a state.
152
+ * Update the smart name of a state.
152
153
  */
153
154
  static updateSmartName(obj: ioBroker.StateObject, newSmartName: ioBroker.StringOrTranslated, byON: string | null, smartType: string | null, instanceId: string, noCommon?: boolean): void;
154
155
  /**
@@ -168,17 +169,19 @@ declare class Utils {
168
169
  /**
169
170
  * Format number of bytes as a string with B, KB, MB or GB.
170
171
  * The base for all calculations is 1024.
171
- * @param bytes The number of bytes.
172
172
  * @returns The formatted string (e.g. '723.5 KB')
173
173
  */
174
- static formatBytes(bytes: number): string;
174
+ static formatBytes(
175
+ /** The number of bytes. */
176
+ bytes: number): string;
175
177
  /**
176
178
  * Invert the given color according to a theme type to get the inverted text color for background
177
- * @param color Color in the format '#rrggbb' or '#rgb' (or without a hash)
178
- * @param themeType theme type
179
- * @param invert dark theme has light color in control or light theme has light color in control
180
179
  */
181
- static getInvertedColor(color: string, themeType?: ThemeType, invert?: boolean): string | undefined;
180
+ static getInvertedColor(
181
+ /** Color in the format '#rrggbb' or '#rgb' (or without a hash) */
182
+ color: string, themeType: ThemeType,
183
+ /** dark theme has light color in control, or light theme has light color in control */
184
+ invert?: boolean): string | undefined;
182
185
  /**
183
186
  * Invert the given color
184
187
  * @param hex Color in the format '#rrggbb' or '#rgb' (or without hash)
@@ -208,12 +211,12 @@ declare class Utils {
208
211
  /**
209
212
  * @private
210
213
  */
211
- static _toVal(mix: clsx.ClassValue): string;
214
+ static _toVal(mix: ClassValue): string;
212
215
  /**
213
216
  * Convert any object to a string with its values.
214
217
  * @returns {string}
215
218
  */
216
- static clsx(...inputs: clsx.ClassValue[]): string;
219
+ static clsx(...inputs: ClassValue[]): string;
217
220
  /**
218
221
  * Get the current theme name (either from local storage or the browser settings).
219
222
  */
@@ -230,7 +233,7 @@ declare class Utils {
230
233
  * Toggle the theme name between 'dark' and 'colored'.
231
234
  * @returns the new theme name.
232
235
  */
233
- static toggleTheme(themeName: ThemeName | null): ThemeName;
236
+ static toggleTheme(themeName?: ThemeName | null): ThemeName;
234
237
  /**
235
238
  * Get the list of themes
236
239
  * @returns list of possible themes
@@ -239,7 +242,7 @@ declare class Utils {
239
242
  /**
240
243
  * Parse a query string into its parts.
241
244
  */
242
- static parseQuery(query: string): Record<string, string | boolean | number>;
245
+ static parseQuery(query: string): Record<string, string | number | boolean>;
243
246
  /**
244
247
  * Returns parent ID.
245
248
  * @returns parent ID or null if no parent
@@ -256,12 +259,11 @@ declare class Utils {
256
259
  };
257
260
  static MDremoveDocsify(text: string): string;
258
261
  /**
259
- * Generate the json file on the file for download.
260
- * @param fileName file name
261
- * @param json file data
262
- * @returns {object} json structure (not stringified)
262
+ * Generate the file for download from JSON object.
263
263
  */
264
- static generateFile(fileName: string, json: string): void;
264
+ static generateFile(fileName: string,
265
+ /** json file data */
266
+ json: Record<string, any>): void;
265
267
  /**
266
268
  * Convert quality code into text
267
269
  * @returns lines that decode quality
@@ -270,7 +272,7 @@ declare class Utils {
270
272
  /**
271
273
  * Deep copy object
272
274
  */
273
- static clone(object: any): any;
275
+ static clone(object: Record<string, any>): Record<string, any>;
274
276
  /**
275
277
  * Get states of object
276
278
  * @returns states as an object in form {"value1": "label1", "value2": "label2"} or null
@@ -284,27 +286,23 @@ declare class Utils {
284
286
  static getSvg(url: string): Promise<string>;
285
287
  /**
286
288
  * Detect file extension by its content
287
- * @param {string} base64 Base64 encoded binary file
288
- * @returns {string} Detected extension, like 'jpg'
289
+ * @returns Detected extension, like 'jpg'
289
290
  */
290
- static detectMimeType(base64: string): string | null;
291
+ static detectMimeType(
292
+ /** Base64 encoded binary file */
293
+ base64: string): string | null;
291
294
  /**
292
295
  * Check if configured repository is the stable repository
293
- *
294
- * @param activeRepo current configured repository or multi repository
295
296
  */
296
- static isStableRepository(activeRepo: string | string[]): boolean;
297
+ static isStableRepository(
298
+ /** current configured repository or multi repository */
299
+ activeRepo: string | string[]): boolean;
297
300
  /**
298
301
  * Check if a given string is an integer
299
- *
300
- * @param str string to check
301
302
  */
302
- static isStringInteger(str: string): boolean;
303
+ static isStringInteger(str: string | number): boolean;
303
304
  /**
304
305
  * Check if the date is valid
305
- *
306
- * @param {Date} date
307
- * @return {boolean}
308
306
  */
309
307
  static isValidDate(date: any): boolean;
310
308
  }