@iobroker/adapter-react-v5 4.6.12 → 4.7.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 (36) hide show
  1. package/Components/FileViewer.js +1 -1
  2. package/Components/FileViewer.js.map +1 -1
  3. package/Components/JsonConfigComponent/ConfigColor.d.ts +2 -1
  4. package/Components/JsonConfigComponent/ConfigFile.js +1 -1
  5. package/Components/JsonConfigComponent/ConfigFile.js.map +1 -1
  6. package/Components/JsonConfigComponent/ConfigFileSelector.js +4 -4
  7. package/Components/JsonConfigComponent/ConfigFileSelector.js.map +1 -1
  8. package/Components/JsonConfigComponent/ConfigGeneric.d.ts +68 -67
  9. package/Components/JsonConfigComponent/ConfigGeneric.js +600 -665
  10. package/Components/JsonConfigComponent/ConfigInterface.d.ts +14 -0
  11. package/Components/JsonConfigComponent/ConfigInterface.js +146 -0
  12. package/Components/JsonConfigComponent/ConfigInterface.js.map +1 -0
  13. package/Components/JsonConfigComponent/ConfigJsonEditor.d.ts +0 -1
  14. package/Components/JsonConfigComponent/ConfigJsonEditor.js +6 -11
  15. package/Components/JsonConfigComponent/ConfigJsonEditor.js.map +1 -1
  16. package/Components/JsonConfigComponent/ConfigLicense.d.ts +2 -1
  17. package/Components/JsonConfigComponent/ConfigNumber.d.ts +16 -2
  18. package/Components/JsonConfigComponent/ConfigNumber.js +105 -201
  19. package/Components/JsonConfigComponent/ConfigPattern.d.ts +2 -1
  20. package/Components/JsonConfigComponent/ConfigPort.d.ts +1 -1
  21. package/Components/JsonConfigComponent/ConfigPort.js +159 -210
  22. package/Components/JsonConfigComponent/ConfigUUID.d.ts +2 -1
  23. package/Components/JsonConfigComponent/wrapper/AdminConnection.d.ts +2 -0
  24. package/Components/JsonConfigComponent/wrapper/AdminConnection.js +7 -0
  25. package/Components/MDUtils.js +3 -3
  26. package/Components/MDUtils.js.map +1 -1
  27. package/Components/SimpleCron/cron2text.js +31 -36
  28. package/Components/SimpleCron/cron2text.js.map +1 -1
  29. package/Components/SimpleCron/index.js +10 -10
  30. package/Components/SimpleCron/index.js.map +1 -1
  31. package/LegacyConnection.js.map +1 -1
  32. package/README.md +1 -1
  33. package/package.json +1 -1
  34. package/Components/JsonConfigComponent/ConfigGeneric.js.map +0 -1
  35. package/Components/JsonConfigComponent/ConfigNumber.js.map +0 -1
  36. package/Components/JsonConfigComponent/ConfigPort.js.map +0 -1
@@ -1,213 +1,117 @@
1
1
  "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
- Object.defineProperty(exports, "__esModule", {
5
- value: true
6
- });
7
- exports["default"] = void 0;
8
- var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
9
- var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
10
- var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
11
- var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
12
- var _get2 = _interopRequireDefault(require("@babel/runtime/helpers/get"));
13
- var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
14
- var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
15
- var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
16
- var _react = _interopRequireDefault(require("react"));
17
- var _propTypes = _interopRequireDefault(require("prop-types"));
18
- var _styles = require("@mui/styles");
19
- var _material = require("@mui/material");
20
- var _i18n = _interopRequireDefault(require("./wrapper/i18n"));
21
- var _ConfigGeneric2 = _interopRequireDefault(require("./ConfigGeneric"));
22
- function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2["default"])(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2["default"])(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2["default"])(this, result); }; }
23
- function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
24
- var styles = function styles() {
25
- return {
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const react_1 = __importDefault(require("react"));
7
+ const styles_1 = require("@mui/styles");
8
+ const material_1 = require("@mui/material");
9
+ const i18n_1 = __importDefault(require("./wrapper/i18n"));
10
+ const ConfigGeneric_1 = __importDefault(require("./ConfigGeneric"));
11
+ const styles = () => ({
26
12
  indeterminate: {
27
- opacity: 0.5
13
+ opacity: 0.5,
28
14
  },
29
15
  control: {
30
- flexDirection: 'row',
31
- width: '100%'
32
- }
33
- };
34
- };
35
- var ConfigNumber = /*#__PURE__*/function (_ConfigGeneric) {
36
- (0, _inherits2["default"])(ConfigNumber, _ConfigGeneric);
37
- var _super = _createSuper(ConfigNumber);
38
- function ConfigNumber() {
39
- (0, _classCallCheck2["default"])(this, ConfigNumber);
40
- return _super.apply(this, arguments);
41
- }
42
- (0, _createClass2["default"])(ConfigNumber, [{
43
- key: "componentDidMount",
44
- value: function componentDidMount() {
45
- (0, _get2["default"])((0, _getPrototypeOf2["default"])(ConfigNumber.prototype), "componentDidMount", this).call(this);
46
- var _value = _ConfigGeneric2["default"].getValue(this.props.data, this.props.attr);
47
- if (_value === null || _value === undefined) {
48
- _value = '';
49
- }
50
- this.setState({
51
- _value: _value.toString(),
52
- oldValue: _value.toString()
53
- });
54
- // this.props.registerOnForceUpdate(this.props.attr, this.onUpdate);
55
- }
56
- }, {
57
- key: "checkValue",
58
- value: function checkValue(value) {
59
- if (value === null || value === undefined) {
60
- return null;
61
- }
62
- value = value.toString().trim();
63
- var f = value === '' ? 0 : parseFloat(value);
64
- if (value !== '' && Number.isNaN(f)) {
65
- return 'ra_Not a number';
66
- }
67
-
68
- // eslint-disable-next-line no-restricted-properties
69
- if (value !== '' && window.isFinite(value)) {
70
- if (this.props.schema.min !== undefined && f < this.props.schema.min) {
71
- return 'ra_Too small';
16
+ flexDirection: 'row',
17
+ width: '100%',
18
+ },
19
+ });
20
+ class ConfigNumber extends ConfigGeneric_1.default {
21
+ componentDidMount() {
22
+ super.componentDidMount();
23
+ let _value = ConfigGeneric_1.default.getValue(this.props.data, this.props.attr);
24
+ if (_value === null || _value === undefined) {
25
+ _value = '';
72
26
  }
73
- if (this.props.schema.max !== undefined && f > this.props.schema.max) {
74
- return 'ra_Too big';
27
+ this.setState({ _value: _value.toString(), oldValue: _value.toString() });
28
+ // this.props.registerOnForceUpdate(this.props.attr, this.onUpdate);
29
+ }
30
+ static getDerivedStateFromProps(props, state) {
31
+ if ((props.schema.min !== undefined && props.schema.min < 0) ||
32
+ (props.schema.max !== undefined && props.schema.max < 0)) {
33
+ return null;
75
34
  }
76
- if (value === '' || value === '-' || Number.isNaN(f)) {
77
- return 'ra_Not a number';
35
+ const _value = ConfigGeneric_1.default.getValue(props.data, props.attr);
36
+ if (_value === null ||
37
+ _value === undefined ||
38
+ state.oldValue === null ||
39
+ state.oldValue === undefined ||
40
+ (_value.toString() !== parseFloat(state._value).toString() &&
41
+ _value.toString() !== state.oldValue.toString())) {
42
+ return { _value };
78
43
  }
79
44
  return null;
80
- }
81
- return 'ra_Not a number';
82
45
  }
83
- }, {
84
- key: "renderItem",
85
- value: function renderItem(error, disabled /* , defaultValue */) {
86
- var _this = this;
87
- var isIndeterminate = Array.isArray(this.state.value) || this.state.value === _ConfigGeneric2["default"].DIFFERENT_VALUE;
88
- if (this.state.oldValue !== null && this.state.oldValue !== undefined) {
89
- this.updateTimeout && clearTimeout(this.updateTimeout);
90
- this.updateTimeout = setTimeout(function () {
91
- _this.updateTimeout = null;
92
- _this.setState({
93
- oldValue: null
94
- });
95
- }, 30);
96
- } else if (this.updateTimeout) {
97
- clearTimeout(this.updateTimeout);
98
- this.updateTimeout = null;
99
- }
100
- if (isIndeterminate) {
101
- var arr = (0, _toConsumableArray2["default"])(this.state.value).map(function (item) {
102
- return {
103
- label: item.toString(),
104
- value: item
105
- };
106
- });
107
- arr.unshift({
108
- label: _i18n["default"].t(_ConfigGeneric2["default"].DIFFERENT_LABEL),
109
- value: _ConfigGeneric2["default"].DIFFERENT_VALUE
110
- });
111
- return /*#__PURE__*/_react["default"].createElement(_material.Autocomplete, {
112
- className: this.props.classes.indeterminate,
113
- fullWidth: true,
114
- value: arr[0],
115
- getOptionSelected: function getOptionSelected(option, value) {
116
- return option.label === value.label;
117
- },
118
- onChange: function onChange(_, value) {
119
- return _this.onChange(_this.props.attr, value.value);
120
- },
121
- options: arr,
122
- getOptionLabel: function getOptionLabel(option) {
123
- return option.label;
124
- },
125
- renderInput: function renderInput(params) {
126
- return /*#__PURE__*/_react["default"].createElement(_material.TextField, (0, _extends2["default"])({
127
- variant: "standard"
128
- }, params, {
129
- inputProps: {
130
- readOnly: _this.props.schema.readOnly || false
131
- },
132
- error: !!error,
133
- placeholder: _this.getText(_this.props.schema.placeholder),
134
- label: _this.getText(_this.props.schema.label),
135
- helperText: _this.renderHelp(_this.props.schema.help, _this.props.schema.helpLink, _this.props.schema.noTranslation),
136
- disabled: !!disabled
137
- }));
138
- }
139
- });
140
- }
141
- if (!error && this.state._value !== null && this.state._value !== undefined && this.state._value) {
142
- error = this.checkValue(this.state._value);
143
- if (error) {
144
- error = _i18n["default"].t(error);
46
+ checkValue(value) {
47
+ if (value === null || value === undefined) {
48
+ return null;
145
49
  }
146
- }
147
- return /*#__PURE__*/_react["default"].createElement(_material.FormControl, {
148
- variant: "standard",
149
- className: this.props.classes.control
150
- }, /*#__PURE__*/_react["default"].createElement(_material.TextField, {
151
- variant: "standard",
152
- type: "number",
153
- fullWidth: true,
154
- inputProps: {
155
- min: this.props.schema.min,
156
- max: this.props.schema.max,
157
- step: this.props.schema.step,
158
- readOnly: this.props.schema.readOnly || false
159
- },
160
- value: this.state._value === null || this.state._value === undefined ? '' : this.state._value,
161
- error: !!error,
162
- disabled: !!disabled,
163
- onChange: function onChange(e) {
164
- var _value = e.target.value; // value is always a string and it is valid formatted
165
- var _error = _this.checkValue(_value);
166
- if (_error) {
167
- _this.onError(_this.props.attr, _i18n["default"].t(_error));
168
- } else {
169
- _this.onError(_this.props.attr); // clear error
170
- }
171
-
172
- _this.setState({
173
- _value: _value,
174
- oldValue: _this.state._value
175
- }, function () {
176
- return _this.onChange(_this.props.attr, _value);
177
- });
178
- },
179
- placeholder: this.getText(this.props.schema.placeholder),
180
- label: this.getText(this.props.schema.label),
181
- helperText: error && typeof error === 'string' ? error : this.renderHelp(this.props.schema.help, this.props.schema.helpLink, this.props.schema.noTranslation)
182
- }));
50
+ value = value.toString().trim();
51
+ const f = value === '' ? 0 : parseFloat(value);
52
+ if (value !== '' && Number.isNaN(f)) {
53
+ return 'ra_Not a number';
54
+ }
55
+ // eslint-disable-next-line no-restricted-properties
56
+ if (value !== '' && window.isFinite(f)) {
57
+ if (this.props.schema.min !== undefined && f < this.props.schema.min) {
58
+ return 'ra_Too small';
59
+ }
60
+ if (this.props.schema.max !== undefined && f > this.props.schema.max) {
61
+ return 'ra_Too big';
62
+ }
63
+ if (value === '' || value === '-' || Number.isNaN(f)) {
64
+ return 'ra_Not a number';
65
+ }
66
+ return null;
67
+ }
68
+ return 'ra_Not a number';
183
69
  }
184
- }], [{
185
- key: "getDerivedStateFromProps",
186
- value: function getDerivedStateFromProps(props, state) {
187
- if (props.schema.min !== undefined && props.schema.min < 0 || props.schema.max !== undefined && props.schema.max < 0) {
188
- return null;
189
- }
190
- var _value = _ConfigGeneric2["default"].getValue(props.data, props.attr);
191
- if (_value === null || _value === undefined || state.oldValue === null || state.oldValue === undefined || _value.toString() !== parseFloat(state._value).toString() && _value.toString() !== state.oldValue.toString()) {
192
- return {
193
- _value: _value
194
- };
195
- }
196
- return null;
70
+ renderItem(error, disabled) {
71
+ const isIndeterminate = Array.isArray(this.state.value) || this.state.value === ConfigGeneric_1.default.DIFFERENT_VALUE;
72
+ if (this.state.oldValue !== null && this.state.oldValue !== undefined) {
73
+ this.updateTimeout && clearTimeout(this.updateTimeout);
74
+ this.updateTimeout = setTimeout(() => {
75
+ this.updateTimeout = undefined;
76
+ this.setState({ oldValue: null });
77
+ }, 30);
78
+ }
79
+ else if (this.updateTimeout) {
80
+ clearTimeout(this.updateTimeout);
81
+ this.updateTimeout = undefined;
82
+ }
83
+ if (isIndeterminate) {
84
+ const arr = [...this.state.value].map(item => ({ label: item.toString(), value: item }));
85
+ arr.unshift({ label: i18n_1.default.t(ConfigGeneric_1.default.DIFFERENT_LABEL), value: ConfigGeneric_1.default.DIFFERENT_VALUE });
86
+ return react_1.default.createElement(material_1.Autocomplete, { className: this.props.classes.indeterminate, fullWidth: true, value: arr[0],
87
+ // @ts-expect-error needs investigation if this really has no effect
88
+ getOptionSelected: (option, value) => option.label === value.label, onChange: (_, value) => this.onChange(this.props.attr, value === null || value === void 0 ? void 0 : value.value), options: arr, getOptionLabel: option => option.label, renderInput: params => (react_1.default.createElement(material_1.TextField, Object.assign({ variant: "standard" }, params, { inputProps: { readOnly: this.props.schema.readOnly || false }, error: !!error, placeholder: this.getText(this.props.schema.placeholder), label: this.getText(this.props.schema.label), helperText: this.renderHelp(this.props.schema.help, this.props.schema.helpLink, this.props.schema.noTranslation), disabled: !!disabled }))) });
89
+ }
90
+ if (!error && this.state._value !== null && this.state._value !== undefined && this.state._value) {
91
+ error = this.checkValue(this.state._value);
92
+ if (error) {
93
+ error = i18n_1.default.t(error);
94
+ }
95
+ }
96
+ return react_1.default.createElement(material_1.FormControl, { variant: "standard", className: this.props.classes.control },
97
+ react_1.default.createElement(material_1.TextField, { variant: "standard", type: "number", fullWidth: true, inputProps: {
98
+ min: this.props.schema.min,
99
+ max: this.props.schema.max,
100
+ step: this.props.schema.step,
101
+ readOnly: this.props.schema.readOnly || false,
102
+ }, value: this.state._value === null || this.state._value === undefined ? '' : this.state._value, error: !!error, disabled: !!disabled, onChange: e => {
103
+ const _value = e.target.value; // value is always a string and it is validly formatted
104
+ const _error = this.checkValue(_value);
105
+ if (_error) {
106
+ this.onError(this.props.attr, i18n_1.default.t(_error));
107
+ }
108
+ else {
109
+ this.onError(this.props.attr); // clear error
110
+ }
111
+ this.setState({ _value, oldValue: this.state._value }, () => this.onChange(this.props.attr, parseFloat(_value)));
112
+ }, placeholder: this.getText(this.props.schema.placeholder), label: this.getText(this.props.schema.label), helperText: error && typeof error === 'string'
113
+ ? error
114
+ : this.renderHelp(this.props.schema.help, this.props.schema.helpLink, this.props.schema.noTranslation) }));
197
115
  }
198
- }]);
199
- return ConfigNumber;
200
- }(_ConfigGeneric2["default"]);
201
- ConfigNumber.propTypes = {
202
- socket: _propTypes["default"].object.isRequired,
203
- themeType: _propTypes["default"].string,
204
- themeName: _propTypes["default"].string,
205
- style: _propTypes["default"].object,
206
- className: _propTypes["default"].string,
207
- data: _propTypes["default"].object.isRequired,
208
- schema: _propTypes["default"].object,
209
- onError: _propTypes["default"].func,
210
- onChange: _propTypes["default"].func
211
- };
212
- var _default = exports["default"] = (0, _styles.withStyles)(styles)(ConfigNumber);
213
- //# sourceMappingURL=ConfigNumber.js.map
116
+ }
117
+ exports.default = (0, styles_1.withStyles)(styles)(ConfigNumber);
@@ -1,5 +1,6 @@
1
1
  export default ConfigPattern;
2
- declare class ConfigPattern extends ConfigGeneric {
2
+ declare class ConfigPattern extends ConfigGeneric<any, any> {
3
+ constructor(props: any);
3
4
  renderItem(error: any, disabled: any): React.JSX.Element;
4
5
  }
5
6
  declare namespace ConfigPattern {
@@ -1,3 +1,3 @@
1
+ import React from 'react';
1
2
  declare const _default: React.JSXElementConstructor<any>;
2
3
  export default _default;
3
- import React from 'react';