@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.
- package/Components/FileViewer.js +1 -1
- package/Components/FileViewer.js.map +1 -1
- package/Components/JsonConfigComponent/ConfigColor.d.ts +2 -1
- package/Components/JsonConfigComponent/ConfigFile.js +1 -1
- package/Components/JsonConfigComponent/ConfigFile.js.map +1 -1
- package/Components/JsonConfigComponent/ConfigFileSelector.js +4 -4
- package/Components/JsonConfigComponent/ConfigFileSelector.js.map +1 -1
- package/Components/JsonConfigComponent/ConfigGeneric.d.ts +68 -67
- package/Components/JsonConfigComponent/ConfigGeneric.js +600 -665
- package/Components/JsonConfigComponent/ConfigInterface.d.ts +14 -0
- package/Components/JsonConfigComponent/ConfigInterface.js +146 -0
- package/Components/JsonConfigComponent/ConfigInterface.js.map +1 -0
- package/Components/JsonConfigComponent/ConfigJsonEditor.d.ts +0 -1
- package/Components/JsonConfigComponent/ConfigJsonEditor.js +6 -11
- package/Components/JsonConfigComponent/ConfigJsonEditor.js.map +1 -1
- package/Components/JsonConfigComponent/ConfigLicense.d.ts +2 -1
- package/Components/JsonConfigComponent/ConfigNumber.d.ts +16 -2
- package/Components/JsonConfigComponent/ConfigNumber.js +105 -201
- package/Components/JsonConfigComponent/ConfigPattern.d.ts +2 -1
- package/Components/JsonConfigComponent/ConfigPort.d.ts +1 -1
- package/Components/JsonConfigComponent/ConfigPort.js +159 -210
- package/Components/JsonConfigComponent/ConfigUUID.d.ts +2 -1
- package/Components/JsonConfigComponent/wrapper/AdminConnection.d.ts +2 -0
- package/Components/JsonConfigComponent/wrapper/AdminConnection.js +7 -0
- package/Components/MDUtils.js +3 -3
- package/Components/MDUtils.js.map +1 -1
- package/Components/SimpleCron/cron2text.js +31 -36
- package/Components/SimpleCron/cron2text.js.map +1 -1
- package/Components/SimpleCron/index.js +10 -10
- package/Components/SimpleCron/index.js.map +1 -1
- package/LegacyConnection.js.map +1 -1
- package/README.md +1 -1
- package/package.json +1 -1
- package/Components/JsonConfigComponent/ConfigGeneric.js.map +0 -1
- package/Components/JsonConfigComponent/ConfigNumber.js.map +0 -1
- package/Components/JsonConfigComponent/ConfigPort.js.map +0 -1
|
@@ -1,213 +1,117 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
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
|
-
|
|
13
|
+
opacity: 0.5,
|
|
28
14
|
},
|
|
29
15
|
control: {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
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
|
-
|
|
74
|
-
|
|
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
|
-
|
|
77
|
-
|
|
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
|
-
|
|
85
|
-
|
|
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
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
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
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
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
|
-
|
|
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 {
|