@iobroker/adapter-react-v5 7.0.2 → 7.1.0

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 (307) hide show
  1. package/Components/404.d.ts +3 -2
  2. package/Components/404.js +3 -2
  3. package/Components/ColorPicker.d.ts +22 -8
  4. package/Components/ColorPicker.js +34 -17
  5. package/Components/ComplexCron.js +24 -24
  6. package/Components/CopyToClipboard.d.ts +10 -1
  7. package/Components/CopyToClipboard.js +17 -8
  8. package/Components/CustomModal.d.ts +1 -1
  9. package/Components/CustomModal.js +8 -8
  10. package/Components/FileBrowser.d.ts +11 -11
  11. package/Components/FileBrowser.js +135 -152
  12. package/Components/FileViewer.js +34 -23
  13. package/Components/Icon.d.ts +16 -2
  14. package/Components/Icon.js +19 -8
  15. package/Components/IconPicker.js +10 -14
  16. package/Components/IconSelector.d.ts +1 -1
  17. package/Components/IconSelector.js +64 -74
  18. package/Components/Image.d.ts +8 -4
  19. package/Components/Image.js +13 -32
  20. package/Components/Loader.d.ts +2 -2
  21. package/Components/Loader.js +21 -18
  22. package/Components/Loaders/MV.d.ts +6 -1
  23. package/Components/Loaders/MV.js +23 -7
  24. package/Components/Loaders/PT.d.ts +7 -2
  25. package/Components/Loaders/PT.js +20 -7
  26. package/Components/Loaders/Vendor.d.ts +2 -2
  27. package/Components/Loaders/Vendor.js +15 -7
  28. package/Components/Logo.js +16 -18
  29. package/Components/MDUtils.d.ts +1 -1
  30. package/Components/MDUtils.js +8 -4
  31. package/Components/ObjectBrowser.d.ts +40 -39
  32. package/Components/ObjectBrowser.js +550 -435
  33. package/Components/Router.d.ts +1 -3
  34. package/Components/Router.js +3 -1
  35. package/Components/SaveCloseButtons.d.ts +3 -3
  36. package/Components/SaveCloseButtons.js +3 -3
  37. package/Components/Schedule.d.ts +15 -15
  38. package/Components/Schedule.js +177 -154
  39. package/Components/SelectWithIcon.d.ts +2 -2
  40. package/Components/SelectWithIcon.js +45 -34
  41. package/Components/SimpleCron/index.js +83 -43
  42. package/Components/TabContainer.js +2 -2
  43. package/Components/TabContent.js +1 -1
  44. package/Components/TabHeader.js +1 -1
  45. package/Components/TableResize.d.ts +2 -2
  46. package/Components/TableResize.js +5 -5
  47. package/Components/TextWithIcon.d.ts +1 -1
  48. package/Components/TextWithIcon.js +10 -8
  49. package/Components/ToggleThemeMenu.d.ts +2 -2
  50. package/Components/ToggleThemeMenu.js +3 -3
  51. package/Components/TreeTable.d.ts +18 -18
  52. package/Components/TreeTable.js +76 -72
  53. package/Components/UploadImage.d.ts +2 -2
  54. package/Components/UploadImage.js +25 -21
  55. package/Components/Utils.d.ts +42 -22
  56. package/Components/Utils.js +66 -65
  57. package/Components/withWidth.d.ts +2 -2
  58. package/Components/withWidth.js +10 -6
  59. package/Dialogs/ComplexCron.d.ts +2 -2
  60. package/Dialogs/ComplexCron.js +3 -3
  61. package/Dialogs/Confirm.d.ts +4 -4
  62. package/Dialogs/Confirm.js +18 -8
  63. package/Dialogs/Cron.d.ts +3 -3
  64. package/Dialogs/Cron.js +21 -17
  65. package/Dialogs/Error.d.ts +3 -3
  66. package/Dialogs/Error.js +6 -4
  67. package/Dialogs/Message.d.ts +3 -3
  68. package/Dialogs/Message.js +6 -4
  69. package/Dialogs/SelectFile.d.ts +4 -4
  70. package/Dialogs/SelectFile.js +6 -4
  71. package/Dialogs/SelectID.d.ts +12 -10
  72. package/Dialogs/SelectID.js +12 -8
  73. package/Dialogs/SimpleCron.d.ts +2 -2
  74. package/Dialogs/SimpleCron.js +2 -2
  75. package/Dialogs/TextInput.d.ts +2 -2
  76. package/Dialogs/TextInput.js +3 -3
  77. package/GenericApp.d.ts +19 -13
  78. package/GenericApp.js +128 -85
  79. package/LegacyConnection.d.ts +240 -248
  80. package/LegacyConnection.js +500 -525
  81. package/README.md +1234 -1170
  82. package/Theme.d.ts +1 -1
  83. package/Theme.js +9 -12
  84. package/assets/devices.json +1 -0
  85. package/assets/rooms.json +1 -0
  86. package/craco-module-federation.js +3 -12
  87. package/i18n/de.json +434 -434
  88. package/i18n/en.json +434 -434
  89. package/i18n/es.json +434 -434
  90. package/i18n/fr.json +434 -434
  91. package/i18n/it.json +434 -434
  92. package/i18n/nl.json +434 -434
  93. package/i18n/pl.json +434 -434
  94. package/i18n/pt.json +434 -434
  95. package/i18n/ru.json +434 -434
  96. package/i18n/uk.json +434 -434
  97. package/i18n/zh-cn.json +434 -434
  98. package/i18n.d.ts +26 -19
  99. package/i18n.js +28 -22
  100. package/icons/IconAdapter.js +2 -2
  101. package/icons/IconAlias.js +2 -2
  102. package/icons/IconChannel.js +2 -2
  103. package/icons/IconClearFilter.js +2 -2
  104. package/icons/IconClosed.js +2 -2
  105. package/icons/IconCopy.js +2 -2
  106. package/icons/IconDevice.js +2 -2
  107. package/icons/IconDocument.js +2 -2
  108. package/icons/IconDocumentReadOnly.js +2 -2
  109. package/icons/IconExpert.js +2 -2
  110. package/icons/IconFx.js +2 -2
  111. package/icons/IconInstance.js +2 -2
  112. package/icons/IconLogout.js +2 -2
  113. package/icons/IconNoIcon.js +2 -2
  114. package/icons/IconOpen.d.ts +2 -2
  115. package/icons/IconOpen.js +2 -2
  116. package/icons/IconProps.d.ts +4 -3
  117. package/icons/IconState.d.ts +2 -2
  118. package/icons/IconState.js +2 -2
  119. package/index.css +3 -2
  120. package/package.json +1 -1
  121. package/src/Components/404.tsx +32 -31
  122. package/src/Components/ColorPicker.tsx +142 -114
  123. package/src/Components/ComplexCron.tsx +174 -137
  124. package/src/Components/CopyToClipboard.tsx +22 -9
  125. package/src/Components/CustomModal.tsx +76 -69
  126. package/src/Components/FileBrowser.tsx +959 -852
  127. package/src/Components/FileViewer.tsx +146 -127
  128. package/src/Components/Icon.tsx +80 -52
  129. package/src/Components/IconPicker.tsx +83 -67
  130. package/src/Components/IconSelector.tsx +159 -141
  131. package/src/Components/Image.tsx +43 -26
  132. package/src/Components/Loader.tsx +56 -32
  133. package/src/Components/Logo.tsx +62 -52
  134. package/src/Components/MDUtils.tsx +10 -6
  135. package/src/Components/ObjectBrowser.tsx +3198 -2478
  136. package/src/Components/Router.tsx +11 -11
  137. package/src/Components/SaveCloseButtons.tsx +43 -39
  138. package/src/Components/Schedule.tsx +1091 -853
  139. package/src/Components/SelectWithIcon.tsx +135 -93
  140. package/src/Components/TabContainer.tsx +21 -19
  141. package/src/Components/TabContent.tsx +13 -12
  142. package/src/Components/TabHeader.tsx +10 -9
  143. package/src/Components/TableResize.tsx +52 -37
  144. package/src/Components/TextWithIcon.tsx +30 -19
  145. package/src/Components/ToggleThemeMenu.tsx +31 -13
  146. package/src/Components/TreeTable.tsx +468 -385
  147. package/src/Components/UploadImage.tsx +153 -121
  148. package/src/Components/Utils.tsx +135 -127
  149. package/src/Components/loader.css +40 -31
  150. package/src/Components/withWidth.tsx +23 -12
  151. package/src/Connection.tsx +1 -3
  152. package/src/Dialogs/ComplexCron.tsx +55 -61
  153. package/src/Dialogs/Confirm.tsx +88 -65
  154. package/src/Dialogs/Cron.tsx +122 -112
  155. package/src/Dialogs/Error.tsx +37 -42
  156. package/src/Dialogs/Message.tsx +39 -37
  157. package/src/Dialogs/SelectFile.tsx +95 -85
  158. package/src/Dialogs/SelectID.tsx +141 -129
  159. package/src/Dialogs/SimpleCron.tsx +44 -44
  160. package/src/Dialogs/TextInput.tsx +60 -68
  161. package/src/GenericApp.tsx +342 -242
  162. package/src/LegacyConnection.tsx +972 -842
  163. package/src/Prompt.tsx +3 -1
  164. package/src/Theme.tsx +19 -26
  165. package/src/icons/IconAdapter.tsx +16 -14
  166. package/src/icons/IconAlias.tsx +16 -14
  167. package/src/icons/IconChannel.tsx +55 -16
  168. package/src/icons/IconClearFilter.tsx +17 -15
  169. package/src/icons/IconClosed.tsx +16 -11
  170. package/src/icons/IconCopy.tsx +16 -11
  171. package/src/icons/IconDevice.tsx +121 -22
  172. package/src/icons/IconDocument.tsx +16 -11
  173. package/src/icons/IconDocumentReadOnly.tsx +21 -12
  174. package/src/icons/IconExpert.tsx +20 -12
  175. package/src/icons/IconFx.tsx +16 -14
  176. package/src/icons/IconInstance.tsx +16 -14
  177. package/src/icons/IconLogout.tsx +20 -18
  178. package/src/icons/IconNoIcon.tsx +16 -14
  179. package/src/icons/IconOpen.tsx +17 -12
  180. package/src/icons/IconProps.tsx +4 -3
  181. package/src/icons/IconState.tsx +34 -13
  182. package/src/index.css +3 -2
  183. package/tasks.js +91 -0
  184. package/types.d.ts +141 -0
  185. package/Components/Loaders/PT.css +0 -109
  186. package/Components/Loaders/Vendor.css +0 -13
  187. package/Components/loader.css +0 -222
  188. package/Components/types.d.ts +0 -82
  189. package/assets/devices/Alarm Systems.svg +0 -19
  190. package/assets/devices/Amplifier.svg +0 -22
  191. package/assets/devices/Awnings.svg +0 -5
  192. package/assets/devices/Battery Status.svg +0 -5
  193. package/assets/devices/Ceiling Spotlights.svg +0 -16
  194. package/assets/devices/Chandelier.svg +0 -7
  195. package/assets/devices/Climate.svg +0 -12
  196. package/assets/devices/Coffee Makers.svg +0 -6
  197. package/assets/devices/Cold Water.svg +0 -31
  198. package/assets/devices/Computer.svg +0 -21
  199. package/assets/devices/Consumption.svg +0 -8
  200. package/assets/devices/Curtains.svg +0 -43
  201. package/assets/devices/Dishwashers.svg +0 -12
  202. package/assets/devices/Doors.svg +0 -6
  203. package/assets/devices/Doorstep.svg +0 -35
  204. package/assets/devices/Dryer.svg +0 -14
  205. package/assets/devices/Fan.svg +0 -20
  206. package/assets/devices/Floor Lamps.svg +0 -5
  207. package/assets/devices/Garage Doors.svg +0 -9
  208. package/assets/devices/Gates.svg +0 -32
  209. package/assets/devices/Hairdryer.svg +0 -23
  210. package/assets/devices/Handle.svg +0 -6
  211. package/assets/devices/Hanging Lamps.svg +0 -9
  212. package/assets/devices/Heater.svg +0 -44
  213. package/assets/devices/Hoods.svg +0 -12
  214. package/assets/devices/Hot Water.svg +0 -10
  215. package/assets/devices/Humidity.svg +0 -41
  216. package/assets/devices/Iron.svg +0 -5
  217. package/assets/devices/Irrigation.svg +0 -23
  218. package/assets/devices/Led Strip.svg +0 -31
  219. package/assets/devices/Light.svg +0 -30
  220. package/assets/devices/Lightings.svg +0 -46
  221. package/assets/devices/Lock.svg +0 -19
  222. package/assets/devices/Louvre.svg +0 -7
  223. package/assets/devices/Mowing Machine.svg +0 -9
  224. package/assets/devices/Music.svg +0 -13
  225. package/assets/devices/Outdoor Blinds.svg +0 -7
  226. package/assets/devices/People.svg +0 -19
  227. package/assets/devices/Pool.svg +0 -8
  228. package/assets/devices/Power Consumption.svg +0 -13
  229. package/assets/devices/Printer.svg +0 -10
  230. package/assets/devices/Pump.svg +0 -10
  231. package/assets/devices/Receiver.svg +0 -19
  232. package/assets/devices/Sconces.svg +0 -10
  233. package/assets/devices/Security.svg +0 -34
  234. package/assets/devices/Shading.svg +0 -5
  235. package/assets/devices/Shutters.svg +0 -11
  236. package/assets/devices/SmokeDetector.svg +0 -13
  237. package/assets/devices/Sockets.svg +0 -13
  238. package/assets/devices/Speaker.svg +0 -35
  239. package/assets/devices/Stove.svg +0 -12
  240. package/assets/devices/Table Lamps.svg +0 -12
  241. package/assets/devices/Temperature Sensors.svg +0 -28
  242. package/assets/devices/Tv.svg +0 -8
  243. package/assets/devices/Vacuum Cleaner.svg +0 -16
  244. package/assets/devices/Ventilation.svg +0 -12
  245. package/assets/devices/Washing Machines.svg +0 -16
  246. package/assets/devices/Water Consumption.svg +0 -6
  247. package/assets/devices/Water Heater.svg +0 -8
  248. package/assets/devices/Water.svg +0 -40
  249. package/assets/devices/Weather.svg +0 -28
  250. package/assets/devices/Window.svg +0 -8
  251. package/assets/rooms/Anteroom.svg +0 -53
  252. package/assets/rooms/Attic.svg +0 -21
  253. package/assets/rooms/Balcony.svg +0 -13
  254. package/assets/rooms/Barn.svg +0 -6
  255. package/assets/rooms/Basement.svg +0 -5
  256. package/assets/rooms/Bathroom.svg +0 -38
  257. package/assets/rooms/Bedroom.svg +0 -5
  258. package/assets/rooms/Boiler Room.svg +0 -13
  259. package/assets/rooms/Carport.svg +0 -17
  260. package/assets/rooms/Cellar.svg +0 -89
  261. package/assets/rooms/Chamber.svg +0 -9
  262. package/assets/rooms/Corridor.svg +0 -53
  263. package/assets/rooms/Dining Area.svg +0 -37
  264. package/assets/rooms/Dining Room.svg +0 -37
  265. package/assets/rooms/Dining.svg +0 -37
  266. package/assets/rooms/Dressing Room.svg +0 -5
  267. package/assets/rooms/Driveway.svg +0 -15
  268. package/assets/rooms/Entrance.svg +0 -44
  269. package/assets/rooms/Equipment Room.svg +0 -15
  270. package/assets/rooms/Front Yard.svg +0 -64
  271. package/assets/rooms/Gallery.svg +0 -14
  272. package/assets/rooms/Garage.svg +0 -20
  273. package/assets/rooms/Garden.svg +0 -13
  274. package/assets/rooms/Ground Floor.svg +0 -95
  275. package/assets/rooms/Guest Bathroom.svg +0 -33
  276. package/assets/rooms/Guest Room.svg +0 -5
  277. package/assets/rooms/Gym.svg +0 -5
  278. package/assets/rooms/Hall.svg +0 -19
  279. package/assets/rooms/Home Theater.svg +0 -8
  280. package/assets/rooms/Kitchen.svg +0 -18
  281. package/assets/rooms/Laundry Room.svg +0 -12
  282. package/assets/rooms/Living Area.svg +0 -11
  283. package/assets/rooms/Living Room.svg +0 -10
  284. package/assets/rooms/Locker Room.svg +0 -17
  285. package/assets/rooms/Nursery.svg +0 -5
  286. package/assets/rooms/Office.svg +0 -8
  287. package/assets/rooms/Outdoors.svg +0 -7
  288. package/assets/rooms/Playroom.svg +0 -6
  289. package/assets/rooms/Pool.svg +0 -8
  290. package/assets/rooms/Rear Wall.svg +0 -30
  291. package/assets/rooms/Second Floor.svg +0 -95
  292. package/assets/rooms/Shed.svg +0 -16
  293. package/assets/rooms/Sleeping Area.svg +0 -22
  294. package/assets/rooms/Stairway.svg +0 -5
  295. package/assets/rooms/Stairwell.svg +0 -15
  296. package/assets/rooms/Storeroom.svg +0 -5
  297. package/assets/rooms/Summer House.svg +0 -27
  298. package/assets/rooms/Swimming Pool.svg +0 -21
  299. package/assets/rooms/Terrace.svg +0 -7
  300. package/assets/rooms/Toilet.svg +0 -10
  301. package/assets/rooms/Upstairs.svg +0 -6
  302. package/assets/rooms/Wardrobe.svg +0 -60
  303. package/assets/rooms/Washroom.svg +0 -20
  304. package/assets/rooms/Wc.svg +0 -10
  305. package/assets/rooms/Windscreen.svg +0 -60
  306. package/assets/rooms/Workshop.svg +0 -23
  307. package/assets/rooms/Workspace.svg +0 -8
@@ -3,15 +3,15 @@
3
3
  *
4
4
  * MIT License
5
5
  *
6
- * */
6
+ */
7
7
  import React from 'react';
8
8
  import copy from './CopyToClipboard';
9
9
  import I18n from '../i18n';
10
- import { IobTheme, ThemeName, ThemeType } from '../types';
10
+ import type { IobTheme, ThemeName, ThemeType } from '../types';
11
11
 
12
- const NAMESPACE = 'material';
13
- const days = ['Su', 'Mo', 'Tu', 'We', 'Th', 'Fr', 'Sa'];
14
- const months = ['Jan', 'Feb', 'Mar', 'Apr', 'Mai', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
12
+ const NAMESPACE = 'material';
13
+ const days = ['Su', 'Mo', 'Tu', 'We', 'Th', 'Fr', 'Sa'];
14
+ const months = ['Jan', 'Feb', 'Mar', 'Apr', 'Mai', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
15
15
  const QUALITY_BITS: Record<ioBroker.STATE_QUALITY[keyof ioBroker.STATE_QUALITY], string> = {
16
16
  0x00: '0x00 - good',
17
17
 
@@ -45,18 +45,18 @@ const SIGNATURES: Record<string, string> = {
45
45
  AAABAA: 'ico', // 00 00 01 00 according to https://en.wikipedia.org/wiki/List_of_file_signatures
46
46
  };
47
47
 
48
- type SmartName = null
48
+ type SmartName =
49
+ | null
49
50
  | false
50
51
  | string
51
52
  | ({ [lang in ioBroker.Languages]?: string } & {
52
- /** Which kind of device it is */
53
- smartType?: string | null;
54
- /** Which value to set when the ON command is issued */
55
- byON?: string | null;
56
- });
53
+ /** Which kind of device it is */
54
+ smartType?: string | null;
55
+ /** Which value to set when the ON command is issued */
56
+ byON?: string | null;
57
+ });
57
58
 
58
59
  type ClassDictionary = Record<string, any>;
59
- // eslint-disable-next-line no-use-before-define
60
60
  type ClassValue = ClassArray | ClassDictionary | string | number | null | boolean | undefined;
61
61
  type ClassArray = ClassValue[];
62
62
 
@@ -138,14 +138,14 @@ class Utils {
138
138
  if (typeof textObj === 'object') {
139
139
  text = (options.language && textObj[options.language]) || textObj.en;
140
140
  } else {
141
- text = textObj as string;
141
+ text = textObj;
142
142
  }
143
143
  } else if (isDesc && item?.common?.desc) {
144
144
  const textObj = item.common.desc;
145
145
  if (typeof textObj === 'object') {
146
146
  text = (options.language && textObj[options.language]) || textObj.en || textObj.de || textObj.ru || '';
147
147
  } else {
148
- text = textObj as string;
148
+ text = textObj;
149
149
  }
150
150
  text = (text || '').toString().replace(/[_.]/g, ' ');
151
151
 
@@ -299,11 +299,7 @@ class Utils {
299
299
  /**
300
300
  * Reorder the array items in list between source and dest.
301
301
  */
302
- static reorder(
303
- list: Iterable<any> | ArrayLike<any>,
304
- source: number,
305
- dest: number,
306
- ): Iterable<any> | ArrayLike<any> {
302
+ static reorder(list: Iterable<any> | ArrayLike<any>, source: number, dest: number): Iterable<any> | ArrayLike<any> {
307
303
  const result = Array.from(list);
308
304
  const [removed] = result.splice(source, 1);
309
305
  result.splice(dest, 0, removed);
@@ -324,7 +320,13 @@ class Utils {
324
320
  language?: ioBroker.Languages;
325
321
  },
326
322
  defaultEnabling?: boolean,
327
- ) {
323
+ ): {
324
+ name: string;
325
+ enabled?: boolean;
326
+ useCustom?: boolean;
327
+ icon?: string;
328
+ color?: string;
329
+ } {
328
330
  let settings;
329
331
  const id = (obj as ioBroker.StateObject)?._id || options?.id;
330
332
  let common: ioBroker.StateCommon | undefined;
@@ -442,10 +444,22 @@ class Utils {
442
444
  return <span style={style || {}}>{settings.icon}</span>;
443
445
  }
444
446
  if (settings.icon.startsWith('data:image')) {
445
- return <img alt={settings.name} src={settings.icon} style={style || {}} />;
447
+ return (
448
+ <img
449
+ alt={settings.name}
450
+ src={settings.icon}
451
+ style={style || {}}
452
+ />
453
+ );
446
454
  }
447
455
  // maybe later some changes for a second type
448
- return <img alt={settings.name} src={(settings.prefix || '') + settings.icon} style={style} />;
456
+ return (
457
+ <img
458
+ alt={settings.name}
459
+ src={(settings.prefix || '') + settings.icon}
460
+ style={style}
461
+ />
462
+ );
449
463
  }
450
464
  return null;
451
465
  }
@@ -456,7 +470,7 @@ class Utils {
456
470
  static getObjectIcon(id: string | ioBroker.PartialObject, obj?: ioBroker.PartialObject): string | null {
457
471
  // If id is Object
458
472
  if (typeof id === 'object') {
459
- obj = id as ioBroker.PartialObject;
473
+ obj = id;
460
474
  id = obj?._id as string;
461
475
  }
462
476
 
@@ -581,7 +595,9 @@ class Utils {
581
595
  return '--:--';
582
596
  }
583
597
  const hours = Math.floor(seconds / 3600);
584
- const minutes = Math.floor((seconds % 3600) / 60).toString().padStart(2, '0');
598
+ const minutes = Math.floor((seconds % 3600) / 60)
599
+ .toString()
600
+ .padStart(2, '0');
585
601
  const secs = (seconds % 60).toString().padStart(2, '0');
586
602
  if (hours) {
587
603
  return `${hours}:${minutes}:${secs}`;
@@ -756,16 +772,18 @@ class Utils {
756
772
  const rel = m[0].match(/rel="([^"]+)"/) || m[0].match(/rel='([^']+)'/);
757
773
  const title = m[0].match(/>([^<]*)</);
758
774
 
759
- // eslint-disable-next-line
760
- result.push(<a
761
- key={`a${key++}`}
762
- href={href ? href[1] : ''}
763
- target={target ? target[1] : '_blank'}
764
- rel={rel ? rel[1] : ''}
765
- style={{ color: 'inherit' }}
766
- >
767
- {title ? title[1] : ''}
768
- </a>);
775
+ result.push(
776
+ // eslint-disable-next-line react/jsx-no-target-blank
777
+ <a
778
+ key={`a${key++}`}
779
+ href={href ? href[1] : ''}
780
+ target={target ? target[1] : '_blank'}
781
+ rel={rel ? rel[1] : 'noreferrer'}
782
+ style={{ color: 'inherit' }}
783
+ >
784
+ {title ? title[1] : ''}
785
+ </a>,
786
+ );
769
787
  }
770
788
 
771
789
  m = text ? text.match(/<a [^<]+<\/a>|<br\/?>|<b>[^<]+<\/b>|<i>[^<]+<\/i>/) : null;
@@ -803,16 +821,18 @@ class Utils {
803
821
  return (states as ioBroker.StateCommon).smartName;
804
822
  }
805
823
  const obj = states as ioBroker.StateObject;
806
- return obj?.common?.custom && obj.common.custom[instanceId] ?
807
- obj.common.custom[instanceId].smartName : undefined;
824
+ return obj?.common?.custom && obj.common.custom[instanceId]
825
+ ? obj.common.custom[instanceId].smartName
826
+ : undefined;
808
827
  }
809
828
  if (!noCommon) {
810
829
  return (states as Record<string, ioBroker.StateObject>)[id].common.smartName;
811
830
  }
812
831
  const obj = (states as Record<string, ioBroker.StateObject>)[id];
813
832
 
814
- return obj?.common?.custom && obj.common.custom[instanceId] ?
815
- obj.common.custom[instanceId].smartName || null : null;
833
+ return obj?.common?.custom && obj.common.custom[instanceId]
834
+ ? obj.common.custom[instanceId].smartName || null
835
+ : null;
816
836
  }
817
837
 
818
838
  /**
@@ -837,7 +857,9 @@ class Utils {
837
857
  return (obj as ioBroker.StateCommon).smartName;
838
858
  }
839
859
 
840
- const custom: Record<string, string> | undefined | null = (obj as ioBroker.StateObject)?.common?.custom?.[instanceId];
860
+ const custom: Record<string, string> | undefined | null = (obj as ioBroker.StateObject)?.common?.custom?.[
861
+ instanceId
862
+ ];
841
863
 
842
864
  return custom ? custom.smartName : undefined;
843
865
  }
@@ -845,11 +867,7 @@ class Utils {
845
867
  /**
846
868
  * Enable smart name for a state.
847
869
  */
848
- static enableSmartName(
849
- obj: ioBroker.StateObject,
850
- instanceId: string,
851
- noCommon?: boolean,
852
- ): void {
870
+ static enableSmartName(obj: ioBroker.StateObject, instanceId: string, noCommon?: boolean): void {
853
871
  if (noCommon) {
854
872
  obj.common.custom = obj.common.custom || {};
855
873
  obj.common.custom[instanceId] = obj.common.custom[instanceId] || {};
@@ -862,11 +880,7 @@ class Utils {
862
880
  /**
863
881
  * Completely remove smart name from a state.
864
882
  */
865
- static removeSmartName(
866
- obj: ioBroker.StateObject,
867
- instanceId: string,
868
- noCommon?: boolean,
869
- ) {
883
+ static removeSmartName(obj: ioBroker.StateObject, instanceId: string, noCommon?: boolean): void {
870
884
  if (noCommon) {
871
885
  if (obj.common && obj.common.custom && obj.common.custom[instanceId]) {
872
886
  obj.common.custom[instanceId] = null;
@@ -886,7 +900,7 @@ class Utils {
886
900
  smartType: string | null,
887
901
  instanceId: string,
888
902
  noCommon?: boolean,
889
- ) {
903
+ ): void {
890
904
  const language = I18n.getLanguage();
891
905
 
892
906
  // convert the old format
@@ -903,8 +917,8 @@ class Utils {
903
917
 
904
918
  if (_smartName && typeof _smartName !== 'object') {
905
919
  _smartName = {
906
- en: _smartName as string,
907
- [language]: _smartName as string,
920
+ en: _smartName,
921
+ [language]: _smartName,
908
922
  };
909
923
  }
910
924
  obj.common.smartName = _smartName;
@@ -993,7 +1007,9 @@ class Utils {
993
1007
  }
994
1008
  // @ts-expect-error fixed in js-controller
995
1009
  } else if (obj.common.smartName && (obj.common.smartName as SmartName).byON !== undefined) {
996
- const _smartName: { [lang in ioBroker.Languages]?: string } = obj.common.smartName as { [lang in ioBroker.Languages]?: string };
1010
+ const _smartName: { [lang in ioBroker.Languages]?: string } = obj.common.smartName as {
1011
+ [lang in ioBroker.Languages]?: string;
1012
+ };
997
1013
  delete _smartName.en;
998
1014
  delete _smartName.de;
999
1015
  delete _smartName.ru;
@@ -1016,11 +1032,7 @@ class Utils {
1016
1032
  /**
1017
1033
  * Disable the smart name of a state.
1018
1034
  */
1019
- static disableSmartName(
1020
- obj: ioBroker.StateObject,
1021
- instanceId: string,
1022
- noCommon?: boolean,
1023
- ): void {
1035
+ static disableSmartName(obj: ioBroker.StateObject, instanceId: string, noCommon?: boolean): void {
1024
1036
  if (noCommon) {
1025
1037
  obj.common.custom = obj.common.custom || {};
1026
1038
  obj.common.custom[instanceId] = obj.common.custom[instanceId] || {};
@@ -1033,10 +1045,7 @@ class Utils {
1033
1045
  /**
1034
1046
  * Copy text to the clipboard.
1035
1047
  */
1036
- static copyToClipboard(
1037
- text: string,
1038
- e?: Event,
1039
- ): boolean {
1048
+ static copyToClipboard(text: string, e?: Event): boolean {
1040
1049
  if (e) {
1041
1050
  e.stopPropagation();
1042
1051
  e.preventDefault();
@@ -1046,6 +1055,7 @@ class Utils {
1046
1055
 
1047
1056
  /**
1048
1057
  * Gets the extension of a file name.
1058
+ *
1049
1059
  * @param fileName the file name.
1050
1060
  * @returns The extension in lower case.
1051
1061
  */
@@ -1060,12 +1070,11 @@ class Utils {
1060
1070
  /**
1061
1071
  * Format number of bytes as a string with B, KB, MB or GB.
1062
1072
  * The base for all calculations is 1024.
1073
+ *
1074
+ * @param bytes The number of bytes.
1063
1075
  * @returns The formatted string (e.g. '723.5 KB')
1064
1076
  */
1065
- static formatBytes(
1066
- /** The number of bytes. */
1067
- bytes: number,
1068
- ): string {
1077
+ static formatBytes(bytes: number): string {
1069
1078
  if (Math.abs(bytes) < 1024) {
1070
1079
  return `${bytes} B`;
1071
1080
  }
@@ -1084,14 +1093,12 @@ class Utils {
1084
1093
 
1085
1094
  /**
1086
1095
  * Invert the given color according to a theme type to get the inverted text color for background
1096
+ *
1097
+ * @param color Color in the format '#rrggbb' or '#rgb' (or without a hash)
1098
+ * @param themeType 'light' or 'dark'
1099
+ * @param invert If true, the dark theme has a light color in the control, or the dark theme has a light color in the control
1087
1100
  */
1088
- static getInvertedColor(
1089
- /** Color in the format '#rrggbb' or '#rgb' (or without a hash) */
1090
- color: string,
1091
- themeType: ThemeType,
1092
- /** dark theme has light color in control, or light theme has light color in control */
1093
- invert?: boolean,
1094
- ): string | undefined {
1101
+ static getInvertedColor(color: string, themeType: ThemeType, invert?: boolean): string | undefined {
1095
1102
  if (!color) {
1096
1103
  return undefined;
1097
1104
  }
@@ -1109,7 +1116,8 @@ class Utils {
1109
1116
  // Big thanks to: https://stackoverflow.com/questions/35969656/how-can-i-generate-the-opposite-color-according-to-current-color
1110
1117
  /**
1111
1118
  * Invert the given color
1112
- * @param hex Color in the format '#rrggbb' or '#rgb' (or without hash)
1119
+ *
1120
+ * @param hex Color in the format '#rrggbb' or '#rgb' (or without a hash)
1113
1121
  * @param bw Set to black or white.
1114
1122
  */
1115
1123
  static invertColor(hex: string, bw?: boolean): string {
@@ -1153,9 +1161,7 @@ class Utils {
1153
1161
 
1154
1162
  if (bw) {
1155
1163
  // http://stackoverflow.com/a/3943023/112731
1156
- return r * 0.299 + g * 0.587 + b * 0.114 > 186
1157
- ? `#000000${alfa || ''}`
1158
- : `#FFFFFF${alfa || ''}`;
1164
+ return r * 0.299 + g * 0.587 + b * 0.114 > 186 ? `#000000${alfa || ''}` : `#FFFFFF${alfa || ''}`;
1159
1165
  }
1160
1166
  // invert color components
1161
1167
  const rs = (255 - r).toString(16);
@@ -1167,6 +1173,7 @@ class Utils {
1167
1173
 
1168
1174
  /**
1169
1175
  * Convert RGB to array [r, g, b]
1176
+ *
1170
1177
  * @param hex Color in the format '#rrggbb' or '#rgb' (or without hash) or rgb(r,g,b) or rgba(r,g,b,a)
1171
1178
  * @returns Array with 3 elements [r, g, b]
1172
1179
  */
@@ -1202,18 +1209,15 @@ class Utils {
1202
1209
  return false;
1203
1210
  }
1204
1211
 
1205
- return [
1206
- parseInt(hex.slice(0, 2), 16),
1207
- parseInt(hex.slice(2, 4), 16),
1208
- parseInt(hex.slice(4, 6), 16),
1209
- ];
1212
+ return [parseInt(hex.slice(0, 2), 16), parseInt(hex.slice(2, 4), 16), parseInt(hex.slice(4, 6), 16)];
1210
1213
  }
1211
1214
 
1212
1215
  // Big thanks to: https://github.com/antimatter15/rgb-lab
1213
1216
  /**
1214
1217
  * Convert RGB to LAB
1215
- * @param {Array<number>} rgb color in format [r,g,b]
1216
- * @returns {Array<number>} lab color in format [l,a,b]
1218
+ *
1219
+ * @param rgb color in format [r,g,b]
1220
+ * @returns lab color in format [l,a,b]
1217
1221
  */
1218
1222
  static rgb2lab(rgb: [number, number, number]): [number, number, number] {
1219
1223
  let r = rgb[0] / 255;
@@ -1237,7 +1241,8 @@ class Utils {
1237
1241
 
1238
1242
  /**
1239
1243
  * Calculate the distance between two colors in LAB color space in the range 0-100^2
1240
- * If distance is less than 1000, the colors are similar
1244
+ * If the distance is less than 1000, the colors are similar
1245
+ *
1241
1246
  * @param color1 Color in the format '#rrggbb' or '#rgb' (or without hash) or rgb(r,g,b) or rgba(r,g,b,a)
1242
1247
  * @param color2 Color in the format '#rrggbb' or '#rgb' (or without hash) or rgb(r,g,b) or rgba(r,g,b,a)
1243
1248
  * @returns distance in the range 0-100^2
@@ -1271,10 +1276,7 @@ class Utils {
1271
1276
  // https://github.com/lukeed/clsx/blob/master/src/index.js
1272
1277
  // License
1273
1278
  // MIT © Luke Edwards
1274
- /**
1275
- * @private
1276
- */
1277
- static _toVal(mix: ClassValue): string {
1279
+ private static _toVal(mix: ClassValue): string {
1278
1280
  let y;
1279
1281
  let str = '';
1280
1282
 
@@ -1309,7 +1311,6 @@ class Utils {
1309
1311
  // MIT © Luke Edwards
1310
1312
  /**
1311
1313
  * Convert any object to a string with its values.
1312
- * @returns {string}
1313
1314
  */
1314
1315
  static clsx(...inputs: ClassValue[]): string {
1315
1316
  let i = 0;
@@ -1317,7 +1318,6 @@ class Utils {
1317
1318
  let x;
1318
1319
  let str = '';
1319
1320
  while (i < inputs.length) {
1320
- // eslint-disable-next-line prefer-rest-params
1321
1321
  tmp = inputs[i++];
1322
1322
  if (tmp) {
1323
1323
  x = Utils._toVal(tmp);
@@ -1334,7 +1334,11 @@ class Utils {
1334
1334
  * Get the current theme name (either from local storage or the browser settings).
1335
1335
  */
1336
1336
  static getThemeName(themeName?: ThemeName | null): ThemeName {
1337
- if ((window as any).vendorPrefix && (window as any).vendorPrefix !== '@@vendorPrefix@@' && (window as any).vendorPrefix !== 'MV') {
1337
+ if (
1338
+ (window as any).vendorPrefix &&
1339
+ (window as any).vendorPrefix !== '@@vendorPrefix@@' &&
1340
+ (window as any).vendorPrefix !== 'MV'
1341
+ ) {
1338
1342
  return (window as any).vendorPrefix;
1339
1343
  }
1340
1344
 
@@ -1374,13 +1378,19 @@ class Utils {
1374
1378
 
1375
1379
  /**
1376
1380
  * Toggle the theme name between 'dark' and 'colored'.
1381
+ *
1377
1382
  * @returns the new theme name.
1378
1383
  */
1379
1384
  static toggleTheme(themeName?: ThemeName | null): ThemeName {
1380
- if ((window as any).vendorPrefix && (window as any).vendorPrefix !== '@@vendorPrefix@@' && (window as any).vendorPrefix !== 'MV') {
1385
+ if (
1386
+ (window as any).vendorPrefix &&
1387
+ (window as any).vendorPrefix !== '@@vendorPrefix@@' &&
1388
+ (window as any).vendorPrefix !== 'MV'
1389
+ ) {
1381
1390
  return (window as any).vendorPrefix as ThemeName;
1382
1391
  }
1383
- themeName = themeName || ((window as any)._localStorage || window.localStorage).getItem('App.themeName') || 'light';
1392
+ themeName =
1393
+ themeName || ((window as any)._localStorage || window.localStorage).getItem('App.themeName') || 'light';
1384
1394
 
1385
1395
  // dark => blue => colored => light => dark
1386
1396
  const themes = Utils.getThemeNames();
@@ -1398,14 +1408,19 @@ class Utils {
1398
1408
 
1399
1409
  /**
1400
1410
  * Get the list of themes
1411
+ *
1401
1412
  * @returns list of possible themes
1402
1413
  */
1403
1414
  static getThemeNames(): ThemeName[] {
1404
- if ((window as any).vendorPrefix && (window as any).vendorPrefix !== '@@vendorPrefix@@' && (window as any).vendorPrefix !== 'MV') {
1415
+ if (
1416
+ (window as any).vendorPrefix &&
1417
+ (window as any).vendorPrefix !== '@@vendorPrefix@@' &&
1418
+ (window as any).vendorPrefix !== 'MV'
1419
+ ) {
1405
1420
  return [(window as any).vendorPrefix as ThemeName];
1406
1421
  }
1407
1422
 
1408
- return ['light', 'dark', 'blue', 'colored'];
1423
+ return ['light', 'dark'];
1409
1424
  }
1410
1425
 
1411
1426
  /**
@@ -1443,6 +1458,7 @@ class Utils {
1443
1458
 
1444
1459
  /**
1445
1460
  * Returns parent ID.
1461
+ *
1446
1462
  * @returns parent ID or null if no parent
1447
1463
  */
1448
1464
  static getParentId(id: string): string | null {
@@ -1478,9 +1494,9 @@ class Utils {
1478
1494
  return text;
1479
1495
  }
1480
1496
 
1481
- /*
1482
- Format seconds to string like 'h:mm:ss' or 'd.hh:mm:ss'
1483
- */
1497
+ /**
1498
+ * Format seconds to string like 'h:mm:ss' or 'd.hh:mm:ss'
1499
+ */
1484
1500
  static formatTime(seconds: number): string {
1485
1501
  if (seconds) {
1486
1502
  seconds = Math.round(seconds);
@@ -1513,8 +1529,8 @@ class Utils {
1513
1529
  .toLowerCase();
1514
1530
  }
1515
1531
 
1516
- /*
1517
- Open url link in the new target window
1532
+ /**
1533
+ * Open url link in the new target window
1518
1534
  */
1519
1535
  static openLink(url: string, target?: string): void {
1520
1536
  // replace IPv6 Address with [ipv6]:port
@@ -1615,28 +1631,23 @@ class Utils {
1615
1631
 
1616
1632
  /**
1617
1633
  * Convert quality code into text
1634
+ *
1618
1635
  * @returns lines that decode quality
1619
1636
  */
1620
1637
  static quality2text(quality: ioBroker.STATE_QUALITY[keyof ioBroker.STATE_QUALITY]): string[] {
1621
- // eslint-disable-next-line no-bitwise
1622
- const custom = quality & 0xFFFF0000;
1638
+ const custom = quality & 0xffff0000;
1623
1639
  const text: string = QUALITY_BITS[quality];
1624
1640
  let result;
1625
1641
  if (text) {
1626
1642
  result = [text];
1627
- // eslint-disable-next-line no-bitwise
1628
1643
  } else if (quality & 0x01) {
1629
- // eslint-disable-next-line no-bitwise
1630
- result = [QUALITY_BITS[0x01], `0x${(quality & (0xFFFF & ~1)).toString(16)}`];
1631
- // eslint-disable-next-line no-bitwise
1644
+ result = [QUALITY_BITS[0x01], `0x${(quality & (0xffff & ~1)).toString(16)}`];
1632
1645
  } else if (quality & 0x02) {
1633
- // eslint-disable-next-line no-bitwise
1634
- result = [QUALITY_BITS[0x02], `0x${(quality & (0xFFFF & ~2)).toString(16)}`];
1646
+ result = [QUALITY_BITS[0x02], `0x${(quality & (0xffff & ~2)).toString(16)}`];
1635
1647
  } else {
1636
1648
  result = [`0x${quality.toString(16)}`];
1637
1649
  }
1638
1650
  if (custom) {
1639
- // eslint-disable-next-line no-bitwise
1640
1651
  result.push(`0x${(custom >> 16).toString(16).toUpperCase()}`);
1641
1652
  }
1642
1653
  return result;
@@ -1651,6 +1662,7 @@ class Utils {
1651
1662
 
1652
1663
  /**
1653
1664
  * Get states of object
1665
+ *
1654
1666
  * @returns states as an object in form {"value1": "label1", "value2": "label2"} or null
1655
1667
  */
1656
1668
  static getStates(obj: ioBroker.StateObject | null | undefined): Record<string, string> | null {
@@ -1660,7 +1672,7 @@ class Utils {
1660
1672
  if (typeof states === 'string' && states[0] === '{') {
1661
1673
  try {
1662
1674
  result = JSON.parse(states) as Record<string, string>;
1663
- } catch (ex) {
1675
+ } catch {
1664
1676
  console.error(`Cannot parse states: ${states}`);
1665
1677
  result = null;
1666
1678
  }
@@ -1683,7 +1695,7 @@ class Utils {
1683
1695
  result.true = states[1];
1684
1696
  }
1685
1697
  } else if (typeof states === 'object') {
1686
- result = states as Record<string, string>;
1698
+ result = states;
1687
1699
  }
1688
1700
  }
1689
1701
 
@@ -1692,6 +1704,7 @@ class Utils {
1692
1704
 
1693
1705
  /**
1694
1706
  * Get svg file as text
1707
+ *
1695
1708
  * @param url URL of SVG file
1696
1709
  * @returns Promise with "data:image..."
1697
1710
  */
@@ -1700,7 +1713,6 @@ class Utils {
1700
1713
  const blob = await response.blob();
1701
1714
  return new Promise(resolve => {
1702
1715
  const reader = new FileReader();
1703
- // eslint-disable-next-line func-names
1704
1716
  reader.onload = function () {
1705
1717
  resolve(this.result?.toString() || '');
1706
1718
  };
@@ -1709,8 +1721,9 @@ class Utils {
1709
1721
  }
1710
1722
 
1711
1723
  /**
1712
- * Detect file extension by its content
1713
- * @returns Detected extension, like 'jpg'
1724
+ * Detect a file extension by its content
1725
+ *
1726
+ * @returns The detected extension, like 'jpg'
1714
1727
  */
1715
1728
  static detectMimeType(
1716
1729
  /** Base64 encoded binary file */
@@ -1727,16 +1740,10 @@ class Utils {
1727
1740
  /** current configured repository or multi repository */
1728
1741
  activeRepo: string | string[],
1729
1742
  ): boolean {
1730
- return !!((
1731
- typeof activeRepo === 'string' &&
1732
- activeRepo.toLowerCase().startsWith('stable')
1733
- )
1734
- ||
1735
- (
1736
- activeRepo &&
1737
- typeof activeRepo !== 'string' &&
1738
- activeRepo.find(r => r.toLowerCase().startsWith('stable'))
1739
- ));
1743
+ return !!(
1744
+ (typeof activeRepo === 'string' && activeRepo.toLowerCase().startsWith('stable')) ||
1745
+ (activeRepo && typeof activeRepo !== 'string' && activeRepo.find(r => r.toLowerCase().startsWith('stable')))
1746
+ );
1740
1747
  }
1741
1748
 
1742
1749
  /**
@@ -1753,7 +1760,6 @@ class Utils {
1753
1760
  * Check if the date is valid
1754
1761
  */
1755
1762
  static isValidDate(date: any): boolean {
1756
- // eslint-disable-next-line no-restricted-globals
1757
1763
  return date instanceof Date && !isNaN(date as any as number);
1758
1764
  }
1759
1765
 
@@ -1769,7 +1775,9 @@ class Utils {
1769
1775
  } else if (args[a] && typeof args[a] === 'object') {
1770
1776
  Object.keys(args[a] as Record<string, any>).forEach((attr: string) => {
1771
1777
  if (typeof (args[a] as Record<string, any>)[attr] === 'function') {
1772
- result[attr] = ((args[a] as Record<string, any>)[attr] as (_theme: IobTheme) => Record<string, any>)(theme);
1778
+ result[attr] = (
1779
+ (args[a] as Record<string, any>)[attr] as (_theme: IobTheme) => Record<string, any>
1780
+ )(theme);
1773
1781
  } else if (typeof (args[a] as Record<string, any>)[attr] === 'object') {
1774
1782
  const obj = (args[a] as Record<string, any>)[attr];
1775
1783
  result[attr] = {};