@iobroker/adapter-react-v5 5.0.3 → 5.0.5

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 (54) 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 +4 -1
  51. package/i18n.d.ts +1 -1
  52. package/i18n.js +6 -8
  53. package/package.json +2 -2
  54. package/types.d.ts +27 -27
@@ -32,7 +32,6 @@ interface ColorPickerProps {
32
32
  /** The CSS class name. */
33
33
  className?: string;
34
34
  /** Open the color picker above the field? */
35
- openAbove?: boolean;
36
35
  customPalette?: string[];
37
36
  noInputField?: boolean;
38
37
  barWidth?: number;
@@ -219,7 +219,7 @@ class ColorPicker extends react_1.Component {
219
219
  picker: {
220
220
  backgroundColor: '#112233',
221
221
  },
222
- }
222
+ },
223
223
  } }),
224
224
  color && this.props.noInputField ? react_1.default.createElement(material_1.IconButton, { className: this.props.classes.closeButton, onClick: () => this.handleChange('') },
225
225
  react_1.default.createElement(icons_material_1.Delete, null)) : null,
@@ -89,7 +89,7 @@ const MONTHS = [
89
89
  ];
90
90
  // 5-7,9-11 => [5,6,7,9,10,11]
91
91
  function convertMinusIntoArray(value, max) {
92
- let result = [];
92
+ const result = [];
93
93
  if (value === '*') {
94
94
  if (max === 24 || max === 60 || max === 7) {
95
95
  for (let i = 0; i < max; i++) {
@@ -236,12 +236,6 @@ class ComplexCron extends react_1.Component {
236
236
  this.setState({ cron }, () => this.props.onChange && this.props.onChange(this.state.cron));
237
237
  }
238
238
  }
239
- onChange(cron) {
240
- if (cron !== this.state.cron) {
241
- this.setState({ cron });
242
- this.props.onChange && this.props.onChange(cron);
243
- }
244
- }
245
239
  onToggle(i, type, max) {
246
240
  if (i === true) {
247
241
  this.setCronAttr(type, '*');
@@ -300,7 +294,7 @@ class ComplexCron extends react_1.Component {
300
294
  ];
301
295
  }
302
296
  getPeriodsTab(type, max) {
303
- let value = this.state[type];
297
+ const value = this.state[type];
304
298
  let every = value === '*';
305
299
  let everyN = value === undefined || value === null ? false : value.toString().includes('/');
306
300
  let select;
@@ -341,7 +335,7 @@ class ComplexCron extends react_1.Component {
341
335
  react_1.default.createElement(material_1.MenuItem, { key: "everyN", value: "everyN" }, i18n_1.default.t(`sc_everyN_${type}`)),
342
336
  react_1.default.createElement(material_1.MenuItem, { key: "specific", value: "specific" }, i18n_1.default.t(`sc_specific_${type}`))),
343
337
  everyN && false && react_1.default.createElement("span", null, value),
344
- everyN && react_1.default.createElement(material_1.TextField, { variant: "standard", key: "interval", label: i18n_1.default.t(`sc_${type}`), value: valueNumber, inputProps: { min: 1, max: max }, onChange: e => {
338
+ everyN && react_1.default.createElement(material_1.TextField, { variant: "standard", key: "interval", label: i18n_1.default.t(`sc_${type}`), value: valueNumber, inputProps: { min: 1, max }, onChange: e => {
345
339
  // @ts-expect-error is allowed
346
340
  this.setState({ [type]: `*/${e.target.value}` }, () => this.recalcCron());
347
341
  }, InputLabelProps: { shrink: true }, type: "number", margin: "normal" }),
@@ -377,25 +371,23 @@ class ComplexCron extends react_1.Component {
377
371
  this.setState({ modes }, () => this.recalcCron());
378
372
  }
379
373
  }
380
- else {
381
- if (attr === 'seconds') {
382
- this.setState({ seconds: value }, () => this.recalcCron());
383
- }
384
- else if (attr === 'minutes') {
385
- this.setState({ minutes: value }, () => this.recalcCron());
386
- }
387
- else if (attr === 'hours') {
388
- this.setState({ hours: value }, () => this.recalcCron());
389
- }
390
- else if (attr === 'dates') {
391
- this.setState({ dates: value }, () => this.recalcCron());
392
- }
393
- else if (attr === 'months') {
394
- this.setState({ months: value }, () => this.recalcCron());
395
- }
396
- else if (attr === 'dow') {
397
- this.setState({ dow: value }, () => this.recalcCron());
398
- }
374
+ else if (attr === 'seconds') {
375
+ this.setState({ seconds: value }, () => this.recalcCron());
376
+ }
377
+ else if (attr === 'minutes') {
378
+ this.setState({ minutes: value }, () => this.recalcCron());
379
+ }
380
+ else if (attr === 'hours') {
381
+ this.setState({ hours: value }, () => this.recalcCron());
382
+ }
383
+ else if (attr === 'dates') {
384
+ this.setState({ dates: value }, () => this.recalcCron());
385
+ }
386
+ else if (attr === 'months') {
387
+ this.setState({ months: value }, () => this.recalcCron());
388
+ }
389
+ else if (attr === 'dow') {
390
+ this.setState({ dow: value }, () => this.recalcCron());
399
391
  }
400
392
  }
401
393
  render() {
@@ -89,11 +89,8 @@ function copy(text, options) {
89
89
  // used to preserve spaces and line breaks
90
90
  mark.style.whiteSpace = 'pre';
91
91
  // do not inherit user-select (it may be `none`)
92
- // @ts-ignore
93
92
  mark.style.webkitUserSelect = 'text';
94
- // @ts-ignore
95
93
  mark.style.MozUserSelect = 'text';
96
- // @ts-ignore
97
94
  mark.style.msUserSelect = 'text';
98
95
  mark.style.userSelect = 'text';
99
96
  mark.addEventListener('copy', e => {
@@ -105,7 +102,6 @@ function copy(text, options) {
105
102
  debug && console.warn('unable to use e.clipboardData');
106
103
  debug && console.warn('trying IE specific stuff');
107
104
  (_a = window.clipboardData) === null || _a === void 0 ? void 0 : _a.clearData();
108
- // @ts-ignore
109
105
  const _format = clipboardToIE11Formatting[options.format] || clipboardToIE11Formatting.default;
110
106
  (_b = window.clipboardData) === null || _b === void 0 ? void 0 : _b.setData(_format, text);
111
107
  }
@@ -84,10 +84,6 @@ const CustomModal = (props) => {
84
84
  help ? react_1.default.createElement("div", null, help) : null),
85
85
  react_1.default.createElement(material_1.DialogActions, null,
86
86
  applyButton !== false && react_1.default.createElement(material_1.Button, { startIcon: react_1.default.createElement(icons_material_1.Check, null), disabled: progress || (applyDisabled && defaultValue === value), onClick: () => onApply(textInput ? value : ''), variant: "contained", color: "primary" }, i18n_1.default.t(titleButtonApply || 'ra_Ok')),
87
- react_1.default.createElement(material_1.Button
88
- // @ts-expect-error grey is valid color
89
- , {
90
- // @ts-expect-error grey is valid color
91
- color: "grey", onClick: onClose, disabled: progress, variant: "contained", startIcon: react_1.default.createElement(icons_material_1.Close, null) }, i18n_1.default.t(titleButtonClose || 'ra_Cancel'))));
87
+ react_1.default.createElement(material_1.Button, { color: "grey", onClick: onClose, disabled: progress, variant: "contained", startIcon: react_1.default.createElement(icons_material_1.Close, null) }, i18n_1.default.t(titleButtonClose || 'ra_Cancel'))));
92
88
  };
93
89
  exports.default = (0, styles_1.withStyles)(styles)(CustomModal);
@@ -1112,16 +1112,17 @@ class FileBrowser extends react_1.Component {
1112
1112
  this.props.allowDelete &&
1113
1113
  item.id !== 'vis.0/' &&
1114
1114
  item.id !== 'vis-2.0/' &&
1115
- item.id !== USER_DATA ? react_1.default.createElement(material_1.IconButton, { "aria-label": "delete", onClick: e => {
1116
- e.stopPropagation();
1117
- if (this.suppressDeleteConfirm > Date.now()) {
1118
- this.deleteItem(item.id);
1119
- }
1120
- else {
1121
- this.setState({ deleteItem: item.id });
1122
- }
1123
- }, className: this.props.classes[`itemDeleteButton${this.state.viewType}`], size: "large" },
1124
- react_1.default.createElement(icons_material_1.Delete, { fontSize: "small" }))
1115
+ item.id !== USER_DATA ?
1116
+ react_1.default.createElement(material_1.IconButton, { "aria-label": "delete", onClick: e => {
1117
+ e.stopPropagation();
1118
+ if (this.suppressDeleteConfirm > Date.now()) {
1119
+ this.deleteItem(item.id);
1120
+ }
1121
+ else {
1122
+ this.setState({ deleteItem: item.id });
1123
+ }
1124
+ }, className: this.props.classes[`itemDeleteButton${this.state.viewType}`], size: "large" },
1125
+ react_1.default.createElement(icons_material_1.Delete, { fontSize: "small" }))
1125
1126
  :
1126
1127
  (this.state.viewType === TABLE && this.props.allowDelete ?
1127
1128
  react_1.default.createElement("div", { className: this.props.classes[`itemDeleteButton${this.state.viewType}`] }) : null));
@@ -1514,18 +1515,12 @@ class FileBrowser extends react_1.Component {
1514
1515
  react_1.default.createElement(material_1.DialogContent, null,
1515
1516
  react_1.default.createElement(material_1.DialogContentText, null, this.props.t('ra_Are you sure?'))),
1516
1517
  react_1.default.createElement(material_1.DialogActions, null,
1517
- react_1.default.createElement(material_1.Button
1518
- // @ts-expect-error grey is valid color
1519
- , {
1520
- // @ts-expect-error grey is valid color
1521
- color: "grey", variant: "contained", onClick: () => {
1518
+ react_1.default.createElement(material_1.Button, { color: "grey", variant: "contained", onClick: () => {
1522
1519
  this.suppressDeleteConfirm = Date.now() + 60000 * 5;
1523
1520
  this.deleteItem('');
1524
1521
  } }, this.props.t('ra_Delete (no confirm for 5 mins)')),
1525
1522
  react_1.default.createElement(material_1.Button, { variant: "contained", onClick: () => this.deleteItem(''), color: "primary", autoFocus: true }, this.props.t('ra_Delete')),
1526
- react_1.default.createElement(material_1.Button, { variant: "contained", onClick: () => this.setState({ deleteItem: '' }),
1527
- // @ts-expect-error grey is valid color
1528
- color: "grey" }, this.props.t('ra_Cancel'))));
1523
+ react_1.default.createElement(material_1.Button, { variant: "contained", onClick: () => this.setState({ deleteItem: '' }), color: "grey" }, this.props.t('ra_Cancel'))));
1529
1524
  }
1530
1525
  return false;
1531
1526
  }
@@ -105,6 +105,7 @@ class FileViewer extends react_1.Component {
105
105
  }, 300);
106
106
  }
107
107
  };
108
+ // eslint-disable-next-line class-methods-use-this
108
109
  this.writeFile64 = () => {
109
110
  /*
110
111
  // File viewer in adapter-react does not support write
@@ -232,7 +233,7 @@ class FileViewer extends react_1.Component {
232
233
  // value={this.state.editingValue || this.state.code || this.state.text}
233
234
  // onChange={this.state.editing ? newValue => this.setState({ editingValue: newValue, changed: true }) : undefined}
234
235
  // />;
235
- return react_1.default.createElement(material_1.TextField, { variant: "standard", className: this.props.classes.textarea, multiline: true, inputProps: { readOnly: !this.state.editing }, value: this.state.editingValue || this.state.code || this.state.text,
236
+ return react_1.default.createElement(material_1.TextField, { variant: "standard", className: this.props.classes.textarea, multiline: true, value: this.state.editingValue || this.state.code || this.state.text,
236
237
  // onChange={newValue => this.setState({ editingValue: newValue, changed: true })}
237
238
  InputProps: { readOnly: !this.state.editing } });
238
239
  }
@@ -248,21 +249,13 @@ class FileViewer extends react_1.Component {
248
249
  react_1.default.createElement(material_1.DialogContent, { className: this.props.classes.content }, this.getContent()),
249
250
  react_1.default.createElement(material_1.DialogActions, null,
250
251
  this.state.copyPossible ?
251
- react_1.default.createElement(material_1.Button
252
- // @ts-expect-error grey is valid color
253
- , {
254
- // @ts-expect-error grey is valid color
255
- color: "grey", onClick: e => {
252
+ react_1.default.createElement(material_1.Button, { color: "grey", onClick: e => {
256
253
  e.stopPropagation();
257
254
  e.preventDefault();
258
255
  Utils_1.default.copyToClipboard(this.state.text || this.state.code || '');
259
256
  }, startIcon: react_1.default.createElement(fa_1.FaCopy, null) }, this.props.t('Copy content')) : null,
260
257
  this.state.editing ?
261
- react_1.default.createElement(material_1.Button
262
- // @ts-expect-error grey is valid color
263
- , {
264
- // @ts-expect-error grey is valid color
265
- color: "grey", disabled: this.state.editingValue === this.state.code || this.state.editingValue === this.state.text, variant: "contained", onClick: this.writeFile64, startIcon: react_1.default.createElement(icons_material_1.Save, null) }, this.props.t('Save')) : null,
258
+ react_1.default.createElement(material_1.Button, { color: "grey", disabled: this.state.editingValue === this.state.code || this.state.editingValue === this.state.text, variant: "contained", onClick: this.writeFile64, startIcon: react_1.default.createElement(icons_material_1.Save, null) }, this.props.t('Save')) : null,
266
259
  react_1.default.createElement(material_1.Button, { variant: "contained", onClick: () => this.props.onClose(), color: "primary", startIcon: react_1.default.createElement(icons_material_1.Close, null) }, this.props.t('Close'))));
267
260
  }
268
261
  }
@@ -17,5 +17,5 @@ interface IconProps {
17
17
  /** Alternative text for image */
18
18
  alt?: string;
19
19
  }
20
- declare const Icon: (props: IconProps) => React.JSX.Element;
21
- export default Icon;
20
+ export default function Icon(props: IconProps): React.JSX.Element;
21
+ export {};
@@ -98,7 +98,7 @@ function getSelectIdIcon(obj, imagePrefix) {
98
98
  exports.getSelectIdIcon = getSelectIdIcon;
99
99
  const REMOTE_SERVER = window.location.hostname.includes('iobroker.in');
100
100
  const REMOTE_PREFIX = window.location.pathname.substring(0, window.location.pathname.lastIndexOf('/') + 1);
101
- const Icon = (props) => {
101
+ function Icon(props) {
102
102
  var _a, _b, _c;
103
103
  if (props.src) {
104
104
  if (typeof props.src === 'string') {
@@ -127,5 +127,5 @@ const Icon = (props) => {
127
127
  return props.src;
128
128
  }
129
129
  return null;
130
- };
130
+ }
131
131
  exports.default = Icon;
@@ -2091,11 +2091,7 @@ class IconSelector extends react_1.Component {
2091
2091
  return react_1.default.createElement(material_1.CircularProgress, null);
2092
2092
  }
2093
2093
  return react_1.default.createElement(react_1.default.Fragment, null,
2094
- react_1.default.createElement(material_1.Button
2095
- // @ts-expect-error grey is valid color
2096
- , {
2097
- // @ts-expect-error grey is valid color
2098
- color: "grey", variant: "outlined", title: this.props.t('ra_Select predefined icon'), onClick: () => this.setState({ opened: true }, () => this.loadAllIcons()), style: { minWidth: 40, marginRight: 8 } }, "..."),
2094
+ react_1.default.createElement(material_1.Button, { color: "grey", variant: "outlined", title: this.props.t('ra_Select predefined icon'), onClick: () => this.setState({ opened: true }, () => this.loadAllIcons()), style: { minWidth: 40, marginRight: 8 } }, "..."),
2099
2095
  this.state.opened ? react_1.default.createElement(material_1.Dialog, { onClose: () => this.setState({ opened: false }), open: !0 },
2100
2096
  react_1.default.createElement(material_1.DialogTitle, null,
2101
2097
  this.props.t('ra_Select predefined icon'),
@@ -2122,11 +2118,7 @@ class IconSelector extends react_1.Component {
2122
2118
  return null;
2123
2119
  }))),
2124
2120
  react_1.default.createElement(material_1.DialogActions, null,
2125
- react_1.default.createElement(material_1.Button
2126
- // @ts-expect-error grey is valid color
2127
- , {
2128
- // @ts-expect-error grey is valid color
2129
- color: "grey", variant: "contained", onClick: () => this.setState({ opened: false }), startIcon: react_1.default.createElement(icons_material_1.Close, null) }, this.props.t('ra_Close')))) : null);
2121
+ react_1.default.createElement(material_1.Button, { color: "grey", variant: "contained", onClick: () => this.setState({ opened: false }), startIcon: react_1.default.createElement(icons_material_1.Close, null) }, this.props.t('ra_Close')))) : null);
2130
2122
  }
2131
2123
  }
2132
2124
  exports.default = IconSelector;
@@ -108,7 +108,9 @@ class Image extends react_1.Component {
108
108
  const inner = svg.innerHTML;
109
109
  const svgProps = serializeAttrs(svg.attributes);
110
110
  svg.remove();
111
- return react_1.default.createElement("svg", Object.assign({ className: this.props.className, style: this.state.color ? { color: this.state.color } : {} }, svgProps, { dangerouslySetInnerHTML: { __html: inner } }));
111
+ return react_1.default.createElement("svg", Object.assign({ className: this.props.className, style: this.state.color ? { color: this.state.color } : {} }, svgProps, {
112
+ // eslint-disable-next-line react/no-danger
113
+ dangerouslySetInnerHTML: { __html: inner } }));
112
114
  }
113
115
  catch (e) {
114
116
  // ignore
@@ -3,7 +3,7 @@
3
3
  *
4
4
  * MIT License
5
5
  *
6
- **/
6
+ * */
7
7
  import React from 'react';
8
8
  import { ThemeName, ThemeType } from '../types';
9
9
  declare global {
@@ -18,7 +18,7 @@ interface LoaderProps {
18
18
  size?: number;
19
19
  /** The chosen theme type. */
20
20
  themeType?: ThemeType;
21
- /** Theme name*/
21
+ /** Theme name */
22
22
  themeName?: ThemeName;
23
23
  /** @deprecated Theme name. use themeName instead */
24
24
  theme?: ThemeName;
@@ -28,7 +28,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
28
28
  *
29
29
  * MIT License
30
30
  *
31
- **/
31
+ * */
32
32
  const react_1 = __importStar(require("react"));
33
33
  const loaderStyles = `
34
34
  /**
@@ -3,7 +3,7 @@
3
3
  *
4
4
  * MIT License
5
5
  *
6
- **/
6
+ * */
7
7
  import React from 'react';
8
8
  import { ThemeType, ThemeName } from '../../types';
9
9
  interface LoaderPTProps {
@@ -28,7 +28,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
28
28
  *
29
29
  * MIT License
30
30
  *
31
- **/
31
+ * */
32
32
  const react_1 = __importStar(require("react"));
33
33
  // import './PT.css'
34
34
  const ptStyles = `
@@ -3,7 +3,7 @@
3
3
  *
4
4
  * MIT License
5
5
  *
6
- **/
6
+ * */
7
7
  import React from 'react';
8
8
  import { ThemeType, ThemeName } from '../../types';
9
9
  interface LoaderVendorProps {
@@ -28,7 +28,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
28
28
  *
29
29
  * MIT License
30
30
  *
31
- **/
31
+ * */
32
32
  const react_1 = __importStar(require("react"));
33
33
  const material_1 = require("@mui/material");
34
34
  // import './Vendor.css'
@@ -63,7 +63,7 @@ function LoaderVendor(props) {
63
63
  backgroundSize: 'cover',
64
64
  } },
65
65
  react_1.default.createElement("div", { style: { flexGrow: 1 } }),
66
- react_1.default.createElement(material_1.CircularProgress, { color: "secondary", size: 200, thickness: 5 }),
66
+ react_1.default.createElement(material_1.CircularProgress, { color: "secondary", size: props.size || 200, thickness: 5 }),
67
67
  react_1.default.createElement("div", { style: { flexGrow: 1 } }));
68
68
  }
69
69
  exports.default = LoaderVendor;
@@ -17,7 +17,7 @@ class Logo extends react_1.default.Component {
17
17
  if (!files || !files.length) {
18
18
  return;
19
19
  }
20
- let f = files[0];
20
+ const f = files[0];
21
21
  if (f) {
22
22
  const r = new window.FileReader();
23
23
  r.onload = () => {
@@ -13,6 +13,8 @@ class MDUtils {
13
13
  return text.replace(/[^a-zA-Zа-яА-Я0-9]/g, '').trim().replace(/\s/g, '').toLowerCase();
14
14
  }
15
15
  static openLink(url, target) {
16
+ // replace IPv6 Address with [ipv6]:port
17
+ url = url.replace(/\/\/([0-9a-f]*:[0-9a-f]*:[0-9a-f]*:[0-9a-f]*:[0-9a-f]*:[0-9a-f]*)(:\d+)?\//i, '//[$1]$2/');
16
18
  if (target === 'this') {
17
19
  window.location.href = url;
18
20
  }