@iobroker/adapter-react-v5 7.0.2 → 7.1.1

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 +1264 -1171
  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 +4 -4
  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 +22 -20
  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
@@ -1,16 +1,6 @@
1
1
  import React, { Component } from 'react';
2
2
 
3
- import {
4
- Checkbox,
5
- Button,
6
- MenuItem,
7
- Select,
8
- FormControlLabel,
9
- AppBar,
10
- Tabs,
11
- Tab,
12
- TextField, Box,
13
- } from '@mui/material';
3
+ import { Checkbox, Button, MenuItem, Select, FormControlLabel, AppBar, Tabs, Tab, TextField } from '@mui/material';
14
4
 
15
5
  import I18n from '../i18n';
16
6
  import convertCronToText from './SimpleCron/cronText';
@@ -48,16 +38,7 @@ const styles: Record<string, React.CSSProperties> = {
48
38
  },
49
39
  };
50
40
 
51
- const WEEKDAYS = [
52
- 'Sunday',
53
- 'Monday',
54
- 'Tuesday',
55
- 'Wednesday',
56
- 'Thursday',
57
- 'Friday',
58
- 'Saturday',
59
- 'Sunday',
60
- ];
41
+ const WEEKDAYS = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday'];
61
42
  const MONTHS = [
62
43
  'January',
63
44
  'February',
@@ -120,7 +101,7 @@ function convertMinusIntoArray(value: string | false | undefined, max: number):
120
101
  }
121
102
 
122
103
  // [5,6,7,9,10,11] => 5-7,9-11
123
- function convertArrayIntoMinus(value: number | number [], max: number): string {
104
+ function convertArrayIntoMinus(value: number | number[], max: number): string {
124
105
  if (typeof value !== 'object') {
125
106
  value = [value];
126
107
  }
@@ -197,8 +178,10 @@ interface ComplexCronState {
197
178
  class ComplexCron extends Component<ComplexCronProps, ComplexCronState> {
198
179
  constructor(props: ComplexCronProps) {
199
180
  super(props);
200
- let cron = typeof this.props.cronExpression === 'string' ?
201
- this.props.cronExpression.replace(/^["']/, '').replace(/["']\n?$/, '') : '';
181
+ let cron =
182
+ typeof this.props.cronExpression === 'string'
183
+ ? this.props.cronExpression.replace(/^["']/, '').replace(/["']\n?$/, '')
184
+ : '';
202
185
  if (cron[0] === '{') {
203
186
  cron = '';
204
187
  }
@@ -258,15 +241,14 @@ class ComplexCron extends Component<ComplexCronProps, ComplexCronState> {
258
241
  return text;
259
242
  }
260
243
 
261
- recalcCron() {
244
+ recalcCron(): void {
262
245
  const cron = ComplexCron.state2cron(this.state);
263
246
  if (cron !== this.state.cron) {
264
- this.setState({ cron }, () =>
265
- this.props.onChange && this.props.onChange(this.state.cron));
247
+ this.setState({ cron }, () => this.props.onChange && this.props.onChange(this.state.cron));
266
248
  }
267
249
  }
268
250
 
269
- onToggle(i: boolean | number, type: CronNames, max: number) {
251
+ onToggle(i: boolean | number, type: CronNames, max: number): void {
270
252
  if (i === true) {
271
253
  this.setCronAttr(type, '*');
272
254
  } else if (i === false) {
@@ -288,7 +270,7 @@ class ComplexCron extends Component<ComplexCronProps, ComplexCronState> {
288
270
  }
289
271
  }
290
272
 
291
- getDigitsSelector(type: CronNames, max: number) {
273
+ getDigitsSelector(type: CronNames, max: number): React.JSX.Element[] {
292
274
  let values = [];
293
275
  if (max === 7) {
294
276
  values = [1, 2, 3, 4, 5, 6, 0];
@@ -326,13 +308,17 @@ class ComplexCron extends Component<ComplexCronProps, ComplexCronState> {
326
308
  {I18n.t('ra_Select all')}
327
309
  </Button>,
328
310
  <div key="all">
329
- {values.map(i =>
330
- [((max === 7 && i === 4) ||
311
+ {values.map(i => [
312
+ (max === 7 && i === 4) ||
331
313
  (max === 12 && i === 7) ||
332
314
  (max === 31 && !((i - 1) % 10)) ||
333
315
  (max === 60 && i && !(i % 10)) ||
334
- (max === 24 && i && !(i % 6))) ?
335
- <div key={`allInner${i}`} style={{ width: '100%' }} /> : null,
316
+ (max === 24 && i && !(i % 6)) ? (
317
+ <div
318
+ key={`allInner${i}`}
319
+ style={{ width: '100%' }}
320
+ />
321
+ ) : null,
336
322
  <Button
337
323
  key={`_${i}`}
338
324
  variant={parts.indexOf(i) !== -1 ? 'contained' : 'outlined'}
@@ -340,9 +326,9 @@ class ComplexCron extends Component<ComplexCronProps, ComplexCronState> {
340
326
  color={parts.indexOf(i) !== -1 ? 'secondary' : 'primary'}
341
327
  onClick={() => this.onToggle(i, type, max)}
342
328
  >
343
- {max === 7 ? I18n.t(WEEKDAYS[i]) : (max === 12 ? MONTHS[i - 1] : i)}
329
+ {max === 7 ? I18n.t(WEEKDAYS[i]) : max === 12 ? MONTHS[i - 1] : i}
344
330
  </Button>,
345
- ])}
331
+ ])}
346
332
  </div>,
347
333
  ];
348
334
  }
@@ -353,7 +339,7 @@ class ComplexCron extends Component<ComplexCronProps, ComplexCronState> {
353
339
  let everyN = value === undefined || value === null ? false : value.toString().includes('/');
354
340
  let select;
355
341
  if (this.state.modes[type] === null) {
356
- select = every ? 'every' : (everyN ? 'everyN' : 'specific');
342
+ select = every ? 'every' : everyN ? 'everyN' : 'specific';
357
343
  const modes = JSON.parse(JSON.stringify(this.state.modes));
358
344
  modes[type] = select;
359
345
  setTimeout(() => this.setState({ modes }, () => this.recalcCron()), 100);
@@ -369,49 +355,75 @@ class ComplexCron extends Component<ComplexCronProps, ComplexCronState> {
369
355
  valueNumber = parseInt(value.replace('*/', ''), 10) || 1;
370
356
  }
371
357
 
372
- return <div>
373
- <Select
374
- variant="standard"
375
- style={{ ...styles.periodSelect, verticalAlign: 'bottom' }}
376
- value={select}
377
- onChange={e => {
378
- const modes = JSON.parse(JSON.stringify(this.state.modes));
379
- modes[type] = e.target.value;
380
- if (e.target.value === 'every') {
381
- this.setCronAttr(type, '*', modes);
382
- } else if (e.target.value === 'everyN') {
383
- const num = parseInt((this.state[type] || '').toString().replace('*/', ''), 10) || 1;
384
- this.setCronAttr(type, `*/${num}`, modes);
385
- } else if (e.target.value === 'specific') {
386
- let num = parseInt((this.state[type] || '').toString().split(',')[0], 10) || 0;
387
- if (!num && (type === 'months' || type === 'dates')) {
388
- num = 1;
358
+ return (
359
+ <div>
360
+ <Select
361
+ variant="standard"
362
+ style={{ ...styles.periodSelect, verticalAlign: 'bottom' }}
363
+ value={select}
364
+ onChange={e => {
365
+ const modes = JSON.parse(JSON.stringify(this.state.modes));
366
+ modes[type] = e.target.value;
367
+ if (e.target.value === 'every') {
368
+ this.setCronAttr(type, '*', modes);
369
+ } else if (e.target.value === 'everyN') {
370
+ const num = parseInt((this.state[type] || '').toString().replace('*/', ''), 10) || 1;
371
+ this.setCronAttr(type, `*/${num}`, modes);
372
+ } else if (e.target.value === 'specific') {
373
+ let num = parseInt((this.state[type] || '').toString().split(',')[0], 10) || 0;
374
+ if (!num && (type === 'months' || type === 'dates')) {
375
+ num = 1;
376
+ }
377
+ this.setCronAttr(type, convertArrayIntoMinus(num, max), modes);
389
378
  }
390
- this.setCronAttr(type, convertArrayIntoMinus(num, max), modes);
391
- }
392
- }}
393
- >
394
- <MenuItem key="every" value="every">{I18n.t(`sc_every_${type}`)}</MenuItem>
395
- <MenuItem key="everyN" value="everyN">{I18n.t(`sc_everyN_${type}`)}</MenuItem>
396
- <MenuItem key="specific" value="specific">{I18n.t(`sc_specific_${type}`)}</MenuItem>
397
- </Select>
398
- {everyN && false && <span>{value}</span>}
399
- {everyN && <TextField
400
- variant="standard"
401
- key="interval"
402
- label={I18n.t(`sc_${type}`)}
403
- value={valueNumber}
404
- inputProps={{ min: 1, max }}
405
- onChange={e => {
406
- // @ts-expect-error is allowed
407
- this.setState({ [type]: `*/${e.target.value}` }, () => this.recalcCron());
408
- }}
409
- InputLabelProps={{ shrink: true }}
410
- type="number"
411
- margin="normal"
412
- />}
413
- {!every && !everyN && this.getDigitsSelector(type, max)}
414
- </div>;
379
+ }}
380
+ >
381
+ <MenuItem
382
+ key="every"
383
+ value="every"
384
+ >
385
+ {I18n.t(`sc_every_${type}`)}
386
+ </MenuItem>
387
+ <MenuItem
388
+ key="everyN"
389
+ value="everyN"
390
+ >
391
+ {I18n.t(`sc_everyN_${type}`)}
392
+ </MenuItem>
393
+ <MenuItem
394
+ key="specific"
395
+ value="specific"
396
+ >
397
+ {I18n.t(`sc_specific_${type}`)}
398
+ </MenuItem>
399
+ </Select>
400
+ {/* everyN && false && <span>{value}</span> */}
401
+ {everyN && (
402
+ <TextField
403
+ variant="standard"
404
+ key="interval"
405
+ label={I18n.t(`sc_${type}`)}
406
+ value={valueNumber}
407
+ slotProps={{
408
+ htmlInput: {
409
+ min: 1,
410
+ max,
411
+ },
412
+ inputLabel: {
413
+ shrink: true,
414
+ },
415
+ }}
416
+ onChange={e => {
417
+ // @ts-expect-error is allowed
418
+ this.setState({ [type]: `*/${e.target.value}` }, () => this.recalcCron());
419
+ }}
420
+ type="number"
421
+ margin="normal"
422
+ />
423
+ )}
424
+ {!every && !everyN && this.getDigitsSelector(type, max)}
425
+ </div>
426
+ );
415
427
  }
416
428
 
417
429
  static convertCronToText(cron: string, lang: ioBroker.Languages): string {
@@ -421,86 +433,111 @@ class ComplexCron extends Component<ComplexCronProps, ComplexCronState> {
421
433
  return convertCronToText(cron, lang);
422
434
  }
423
435
 
424
- setCronAttr(attr: CronNames, value: string, modes?: CronProps) {
436
+ setCronAttr(attr: CronNames, value: string, modes?: CronProps): void {
425
437
  if (modes) {
426
438
  if (attr === 'seconds') {
427
- this.setState({ seconds: value, modes }, () =>
428
- this.recalcCron());
439
+ this.setState({ seconds: value, modes }, () => this.recalcCron());
429
440
  } else if (attr === 'minutes') {
430
- this.setState({ minutes: value, modes }, () =>
431
- this.recalcCron());
441
+ this.setState({ minutes: value, modes }, () => this.recalcCron());
432
442
  } else if (attr === 'hours') {
433
- this.setState({ hours: value, modes }, () =>
434
- this.recalcCron());
443
+ this.setState({ hours: value, modes }, () => this.recalcCron());
435
444
  } else if (attr === 'dates') {
436
- this.setState({ dates: value, modes }, () =>
437
- this.recalcCron());
445
+ this.setState({ dates: value, modes }, () => this.recalcCron());
438
446
  } else if (attr === 'months') {
439
- this.setState({ months: value, modes }, () =>
440
- this.recalcCron());
447
+ this.setState({ months: value, modes }, () => this.recalcCron());
441
448
  } else if (attr === 'dow') {
442
- this.setState({ dow: value, modes }, () =>
443
- this.recalcCron());
449
+ this.setState({ dow: value, modes }, () => this.recalcCron());
444
450
  } else {
445
- this.setState({ modes }, () =>
446
- this.recalcCron());
451
+ this.setState({ modes }, () => this.recalcCron());
447
452
  }
448
453
  } else if (attr === 'seconds') {
449
- this.setState({ seconds: value }, () =>
450
- this.recalcCron());
454
+ this.setState({ seconds: value }, () => this.recalcCron());
451
455
  } else if (attr === 'minutes') {
452
- this.setState({ minutes: value }, () =>
453
- this.recalcCron());
456
+ this.setState({ minutes: value }, () => this.recalcCron());
454
457
  } else if (attr === 'hours') {
455
- this.setState({ hours: value }, () =>
456
- this.recalcCron());
458
+ this.setState({ hours: value }, () => this.recalcCron());
457
459
  } else if (attr === 'dates') {
458
- this.setState({ dates: value }, () =>
459
- this.recalcCron());
460
+ this.setState({ dates: value }, () => this.recalcCron());
460
461
  } else if (attr === 'months') {
461
- this.setState({ months: value }, () =>
462
- this.recalcCron());
462
+ this.setState({ months: value }, () => this.recalcCron());
463
463
  } else if (attr === 'dow') {
464
- this.setState({ dow: value }, () =>
465
- this.recalcCron());
464
+ this.setState({ dow: value }, () => this.recalcCron());
466
465
  }
467
466
  }
468
467
 
469
- render() {
468
+ render(): React.JSX.Element {
470
469
  const tab = this.state.seconds !== false ? this.state.tab : this.state.tab + 1;
471
- return <div style={styles.mainDiv}>
472
- <div style={{ paddingLeft: 8, width: '100%' }}><TextField variant="standard" style={{ width: '100%' }} value={this.state.cron} disabled /></div>
473
- <div style={{ paddingLeft: 8, width: '100%', height: 60 }}>{ComplexCron.convertCronToText(this.state.cron, this.props.language || 'en')}</div>
474
- <FormControlLabel
475
- control={<Checkbox
476
- checked={!!this.state.seconds}
477
- onChange={e => this.setState({ seconds: e.target.checked ? '*' : false }, () => this.recalcCron())}
478
- />}
479
- label={I18n.t('ra_use seconds')}
480
- />
481
- <AppBar position="static" sx={{ '&.MuiAppBar-root': styles.appBar }} color="secondary">
482
- <Tabs
483
- value={this.state.tab}
484
- style={styles.appBar}
470
+ return (
471
+ <div style={styles.mainDiv}>
472
+ <div style={{ paddingLeft: 8, width: '100%' }}>
473
+ <TextField
474
+ variant="standard"
475
+ style={{ width: '100%' }}
476
+ value={this.state.cron}
477
+ disabled
478
+ />
479
+ </div>
480
+ <div style={{ paddingLeft: 8, width: '100%', height: 60 }}>
481
+ {ComplexCron.convertCronToText(this.state.cron, this.props.language || 'en')}
482
+ </div>
483
+ <FormControlLabel
484
+ control={
485
+ <Checkbox
486
+ checked={!!this.state.seconds}
487
+ onChange={e =>
488
+ this.setState({ seconds: e.target.checked ? '*' : false }, () => this.recalcCron())
489
+ }
490
+ />
491
+ }
492
+ label={I18n.t('ra_use seconds')}
493
+ />
494
+ <AppBar
495
+ position="static"
496
+ sx={{ '&.MuiAppBar-root': styles.appBar }}
485
497
  color="secondary"
486
- onChange={(active, _tab) =>
487
- this.setState({ tab: _tab })}
488
498
  >
489
- {this.state.seconds !== false && <Tab id="sc_seconds" label={I18n.t('sc_seconds')} />}
490
- <Tab id="minutes" label={I18n.t('sc_minutes')} />
491
- <Tab id="hours" label={I18n.t('sc_hours')} />
492
- <Tab id="dates" label={I18n.t('sc_dates')} />
493
- <Tab id="months" label={I18n.t('sc_months')} />
494
- <Tab id="dow" label={I18n.t('sc_dows')} />
495
- </Tabs>
496
- </AppBar>
497
- {tab === 0 && <div style={styles.tabContent}>{this.getPeriodsTab('seconds', 60)}</div>}
498
- {tab === 1 && <div style={styles.tabContent}>{this.getPeriodsTab('minutes', 60)}</div>}
499
- {tab === 2 && <div style={styles.tabContent}>{this.getPeriodsTab('hours', 24)}</div>}
500
- {tab === 3 && <div style={styles.tabContent}>{this.getPeriodsTab('dates', 31)}</div>}
501
- {tab === 4 && <div style={styles.tabContent}>{this.getPeriodsTab('months', 12)}</div>}
502
- {tab === 5 && <div style={styles.tabContent}>{this.getPeriodsTab('dow', 7)}</div>}
503
- </div>;
499
+ <Tabs
500
+ value={this.state.tab}
501
+ style={styles.appBar}
502
+ color="secondary"
503
+ onChange={(active, _tab) => this.setState({ tab: _tab })}
504
+ >
505
+ {this.state.seconds !== false && (
506
+ <Tab
507
+ id="sc_seconds"
508
+ label={I18n.t('sc_seconds')}
509
+ />
510
+ )}
511
+ <Tab
512
+ id="minutes"
513
+ label={I18n.t('sc_minutes')}
514
+ />
515
+ <Tab
516
+ id="hours"
517
+ label={I18n.t('sc_hours')}
518
+ />
519
+ <Tab
520
+ id="dates"
521
+ label={I18n.t('sc_dates')}
522
+ />
523
+ <Tab
524
+ id="months"
525
+ label={I18n.t('sc_months')}
526
+ />
527
+ <Tab
528
+ id="dow"
529
+ label={I18n.t('sc_dows')}
530
+ />
531
+ </Tabs>
532
+ </AppBar>
533
+ {tab === 0 && <div style={styles.tabContent}>{this.getPeriodsTab('seconds', 60)}</div>}
534
+ {tab === 1 && <div style={styles.tabContent}>{this.getPeriodsTab('minutes', 60)}</div>}
535
+ {tab === 2 && <div style={styles.tabContent}>{this.getPeriodsTab('hours', 24)}</div>}
536
+ {tab === 3 && <div style={styles.tabContent}>{this.getPeriodsTab('dates', 31)}</div>}
537
+ {tab === 4 && <div style={styles.tabContent}>{this.getPeriodsTab('months', 12)}</div>}
538
+ {tab === 5 && <div style={styles.tabContent}>{this.getPeriodsTab('dow', 7)}</div>}
539
+ </div>
540
+ );
504
541
  }
505
542
  }
506
543
 
@@ -34,7 +34,9 @@ function deselectCurrent() {
34
34
  ranges.push(selection.getRangeAt(i));
35
35
  }
36
36
 
37
- switch (active?.tagName.toUpperCase()) { // .toUpperCase handles XHTML
37
+ switch (
38
+ active?.tagName.toUpperCase() // .toUpperCase handles XHTML
39
+ ) {
38
40
  case 'INPUT':
39
41
  case 'TEXTAREA':
40
42
  active.blur();
@@ -47,8 +49,7 @@ function deselectCurrent() {
47
49
 
48
50
  selection.removeAllRanges();
49
51
  return () => {
50
- selection.type === 'Caret' &&
51
- selection.removeAllRanges();
52
+ selection.type === 'Caret' && selection.removeAllRanges();
52
53
 
53
54
  if (!selection.rangeCount) {
54
55
  ranges.forEach(range => selection.addRange(range));
@@ -73,7 +74,19 @@ function format(message: string): string {
73
74
  return message.replace(/#{\s*key\s*}/g, copyKey);
74
75
  }
75
76
 
76
- function copy(text: string, options?: { debug?: boolean; format?: string; message?: string }) {
77
+ /**
78
+ * Copy text to clipboard
79
+ *
80
+ * @param text Text to copy
81
+ * @param options Options
82
+ * @param options.debug Debug mode
83
+ * @param options.format Format of the data
84
+ * @param options.message Message to show in prompt
85
+ */
86
+ function copy(
87
+ text: string,
88
+ options?: { debug?: boolean; format?: 'text/plain' | 'text/html'; message?: string },
89
+ ): boolean {
77
90
  let reselectPrevious;
78
91
  let range;
79
92
  let selection;
@@ -100,21 +113,20 @@ function copy(text: string, options?: { debug?: boolean; format?: string; messag
100
113
  // used to preserve spaces and line breaks
101
114
  mark.style.whiteSpace = 'pre';
102
115
  // do not inherit user-select (it may be `none`)
103
- mark.style.webkitUserSelect = 'text';
104
- mark.style.MozUserSelect = 'text';
105
- mark.style.msUserSelect = 'text';
106
116
  mark.style.userSelect = 'text';
107
117
  mark.addEventListener('copy', e => {
108
118
  e.stopPropagation();
109
119
  if (options?.format) {
110
120
  e.preventDefault();
111
- if (typeof e.clipboardData === 'undefined') { // IE 11
121
+ if (typeof e.clipboardData === 'undefined') {
122
+ // IE 11
112
123
  debug && console.warn('unable to use e.clipboardData');
113
124
  debug && console.warn('trying IE specific stuff');
114
125
  (window as any).clipboardData?.clearData();
115
126
  const _format = clipboardToIE11Formatting[options.format] || clipboardToIE11Formatting.default;
116
127
  (window as any).clipboardData?.setData(_format, text);
117
- } else { // all other browsers
128
+ } else {
129
+ // all other browsers
118
130
  e.clipboardData?.clearData();
119
131
  e.clipboardData?.setData(options.format, text);
120
132
  }
@@ -126,6 +138,7 @@ function copy(text: string, options?: { debug?: boolean; format?: string; messag
126
138
  range.selectNodeContents(mark);
127
139
  selection?.addRange(range);
128
140
 
141
+ // there is no alternative for execCommand
129
142
  const successful = document.execCommand('copy');
130
143
  if (!successful) {
131
144
  throw new Error('copy command was unsuccessful');