@iobroker/json-config 6.17.12 → 6.17.14

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 (61) hide show
  1. package/package.json +27 -27
  2. package/src/JsonConfig.tsx +0 -710
  3. package/src/JsonConfigComponent/ChipInput.tsx +0 -752
  4. package/src/JsonConfigComponent/ConfigAccordion.tsx +0 -278
  5. package/src/JsonConfigComponent/ConfigAlive.tsx +0 -74
  6. package/src/JsonConfigComponent/ConfigAutocomplete.tsx +0 -108
  7. package/src/JsonConfigComponent/ConfigAutocompleteSendTo.tsx +0 -183
  8. package/src/JsonConfigComponent/ConfigCRON.jsx +0 -101
  9. package/src/JsonConfigComponent/ConfigCertCollection.tsx +0 -102
  10. package/src/JsonConfigComponent/ConfigCertificateSelect.tsx +0 -92
  11. package/src/JsonConfigComponent/ConfigCertificates.tsx +0 -202
  12. package/src/JsonConfigComponent/ConfigCheckLicense.jsx +0 -662
  13. package/src/JsonConfigComponent/ConfigCheckbox.tsx +0 -67
  14. package/src/JsonConfigComponent/ConfigChip.jsx +0 -81
  15. package/src/JsonConfigComponent/ConfigColor.tsx +0 -86
  16. package/src/JsonConfigComponent/ConfigCoordinates.tsx +0 -234
  17. package/src/JsonConfigComponent/ConfigCustom.tsx +0 -246
  18. package/src/JsonConfigComponent/ConfigDatePicker.tsx +0 -48
  19. package/src/JsonConfigComponent/ConfigDeviceManager.tsx +0 -33
  20. package/src/JsonConfigComponent/ConfigFile.jsx +0 -181
  21. package/src/JsonConfigComponent/ConfigFileSelector.jsx +0 -520
  22. package/src/JsonConfigComponent/ConfigFunc.jsx +0 -90
  23. package/src/JsonConfigComponent/ConfigGeneric.tsx +0 -1027
  24. package/src/JsonConfigComponent/ConfigIP.jsx +0 -96
  25. package/src/JsonConfigComponent/ConfigImageSendTo.jsx +0 -79
  26. package/src/JsonConfigComponent/ConfigImageUpload.jsx +0 -114
  27. package/src/JsonConfigComponent/ConfigInstanceSelect.jsx +0 -172
  28. package/src/JsonConfigComponent/ConfigInterface.jsx +0 -112
  29. package/src/JsonConfigComponent/ConfigJsonEditor.jsx +0 -103
  30. package/src/JsonConfigComponent/ConfigLanguage.tsx +0 -153
  31. package/src/JsonConfigComponent/ConfigLicense.jsx +0 -148
  32. package/src/JsonConfigComponent/ConfigNumber.tsx +0 -207
  33. package/src/JsonConfigComponent/ConfigObjectId.jsx +0 -113
  34. package/src/JsonConfigComponent/ConfigPanel.tsx +0 -360
  35. package/src/JsonConfigComponent/ConfigPassword.jsx +0 -160
  36. package/src/JsonConfigComponent/ConfigPattern.jsx +0 -50
  37. package/src/JsonConfigComponent/ConfigPort.tsx +0 -232
  38. package/src/JsonConfigComponent/ConfigRoom.jsx +0 -90
  39. package/src/JsonConfigComponent/ConfigSelect.jsx +0 -124
  40. package/src/JsonConfigComponent/ConfigSelectSendTo.tsx +0 -251
  41. package/src/JsonConfigComponent/ConfigSendto.tsx +0 -340
  42. package/src/JsonConfigComponent/ConfigSetState.jsx +0 -116
  43. package/src/JsonConfigComponent/ConfigSlider.jsx +0 -97
  44. package/src/JsonConfigComponent/ConfigStaticDivider.jsx +0 -51
  45. package/src/JsonConfigComponent/ConfigStaticHeader.jsx +0 -63
  46. package/src/JsonConfigComponent/ConfigStaticImage.jsx +0 -48
  47. package/src/JsonConfigComponent/ConfigStaticText.jsx +0 -72
  48. package/src/JsonConfigComponent/ConfigTable.tsx +0 -1040
  49. package/src/JsonConfigComponent/ConfigTabs.tsx +0 -150
  50. package/src/JsonConfigComponent/ConfigText.tsx +0 -188
  51. package/src/JsonConfigComponent/ConfigTextSendTo.tsx +0 -102
  52. package/src/JsonConfigComponent/ConfigTimePicker.tsx +0 -63
  53. package/src/JsonConfigComponent/ConfigTopic.jsx +0 -78
  54. package/src/JsonConfigComponent/ConfigUUID.tsx +0 -55
  55. package/src/JsonConfigComponent/ConfigUser.jsx +0 -104
  56. package/src/JsonConfigComponent/index.tsx +0 -435
  57. package/src/JsonConfigComponent/wrapper/Components/CustomModal.jsx +0 -145
  58. package/src/JsonConfigComponent/wrapper/Components/Editor.jsx +0 -65
  59. package/src/Utils.jsx +0 -1683
  60. package/src/index.tsx +0 -14
  61. package/src/types.d.ts +0 -372
@@ -1,340 +0,0 @@
1
- import React from 'react';
2
- import { withStyles } from '@mui/styles';
3
-
4
- import { Button, CircularProgress } from '@mui/material';
5
-
6
- import {
7
- Warning as IconWarning,
8
- Error as IconError,
9
- Info as IconInfo,
10
- } from '@mui/icons-material';
11
-
12
- import {
13
- Confirm as DialogConfirm, Error as DialogError, Message as DialogMessage, I18n,
14
- } from '@iobroker/adapter-react-v5';
15
-
16
- import type { ConfigItemSendTo } from '#JC/types';
17
- import ConfigGeneric, { type ConfigGenericProps, type ConfigGenericState } from './ConfigGeneric';
18
-
19
- const styles: Record<string, any> = {
20
- fullWidth: {
21
- width: '100%',
22
- },
23
- icon: {
24
- width: 24,
25
- height: 24,
26
- marginRight: 4,
27
- },
28
- };
29
-
30
- function ip2int(ip: string) {
31
- // eslint-disable-next-line no-bitwise
32
- return ip.split('.').reduce((ipInt, octet) => (ipInt << 8) + parseInt(octet, 10), 0) >>> 0;
33
- }
34
-
35
- // copied from iobroker.admin/src-rx/src/Utils.js
36
- function findNetworkAddressOfHost(obj: Record<string, any>, localIp: string) {
37
- const networkInterfaces = obj?.native?.hardware?.networkInterfaces;
38
- if (!networkInterfaces) {
39
- return null;
40
- }
41
-
42
- let hostIp: string | undefined;
43
-
44
- // check ipv4 addresses
45
- Object.keys(networkInterfaces).forEach(inter =>
46
- networkInterfaces[inter].forEach((ip: Record<string, any>) => {
47
- if (ip.internal) {
48
- return;
49
- }
50
- if (localIp.includes(':') && ip.family !== 'IPv6') {
51
- return;
52
- }
53
- if (localIp.includes('.') && !localIp.match(/[^.\d]/) && ip.family !== 'IPv4') {
54
- return;
55
- }
56
- // if ip4 and not docker or wsl
57
- if (ip.family === 'IPv4' && !ip.address.startsWith('172') && (localIp === '127.0.0.0' || localIp === 'localhost' || localIp.match(/[^.\d]/))) { // if DNS name
58
- hostIp = ip.address;
59
- } else if (!hostIp) {
60
- if (ip.family === 'IPv4' && localIp.includes('.') &&
61
- // eslint-disable-next-line no-bitwise
62
- (ip2int(localIp) & ip2int(ip.netmask)) === (ip2int(ip.address) & ip2int(ip.netmask))) {
63
- hostIp = ip.address;
64
- } else {
65
- hostIp = ip.address;
66
- }
67
- }
68
- }));
69
-
70
- // check ipv6 addresses
71
- if (!hostIp) {
72
- Object.keys(networkInterfaces).forEach(inter =>
73
- networkInterfaces[inter].forEach((ip: Record<string, any>) => {
74
- if (ip.internal) {
75
- return;
76
- } if (localIp.includes(':') && ip.family !== 'IPv6') {
77
- return;
78
- } if (localIp.includes('.') && !localIp.match(/[^.\d]/) && ip.family !== 'IPv4') {
79
- return;
80
- }
81
- if (ip.family === 'IPv6' && (localIp === '127.0.0.0' || localIp === 'localhost' || localIp.match(/[^.\d]/))) { // if DNS name
82
- hostIp = ip.address;
83
- } else if (!hostIp) {
84
- if (ip.family === 'IPv4' && localIp.includes('.') &&
85
- // eslint-disable-next-line no-bitwise
86
- (ip2int(localIp) & ip2int(ip.netmask)) === (ip2int(ip.address) & ip2int(ip.netmask))) {
87
- hostIp = ip.address;
88
- } else {
89
- hostIp = ip.address;
90
- }
91
- }
92
- }));
93
- }
94
-
95
- if (!hostIp) {
96
- Object.keys(networkInterfaces).forEach(inter => {
97
- networkInterfaces[inter].forEach((ip: Record<string, any>) => {
98
- if (ip.internal) {
99
- return;
100
- } if (localIp.includes(':') && ip.family !== 'IPv6') {
101
- return;
102
- } if (localIp.includes('.') && !localIp.match(/[^.\d]/) && ip.family !== 'IPv4') {
103
- return;
104
- }
105
- if (localIp === '127.0.0.0' || localIp === 'localhost' || localIp.match(/[^.\d]/)) { // if DNS name
106
- hostIp = ip.address;
107
- } else {
108
- hostIp = ip.address;
109
- }
110
- });
111
- });
112
- }
113
-
114
- if (!hostIp) {
115
- Object.keys(networkInterfaces).forEach(inter => {
116
- networkInterfaces[inter].forEach((ip: Record<string, any>) => {
117
- if (ip.internal) {
118
- return;
119
- }
120
- hostIp = ip.address;
121
- });
122
- });
123
- }
124
-
125
- return hostIp;
126
- }
127
-
128
- interface ConfigSendToProps extends ConfigGenericProps {
129
- schema: ConfigItemSendTo;
130
- }
131
-
132
- interface ConfigSendToState extends ConfigGenericState {
133
- _error: string;
134
- _message: string;
135
- hostname: string;
136
- running?: boolean;
137
- }
138
-
139
- class ConfigSendto extends ConfigGeneric<ConfigSendToProps, ConfigSendToState> {
140
- async componentDidMount() {
141
- super.componentDidMount();
142
-
143
- let hostname = window.location.hostname;
144
- if (this.props.schema.openUrl) {
145
- // read admin host
146
- const adminInstance = await this.props.socket.getCurrentInstance();
147
- const instanceObj = await this.props.socket.getObject(`system.adapter.${adminInstance}` as ioBroker.ObjectIDs.Instance);
148
-
149
- if (instanceObj) {
150
- const hostObj = await this.props.socket.getObject(`system.host.${instanceObj?.common?.host}`);
151
- if (hostObj) {
152
- const ip = findNetworkAddressOfHost(hostObj, window.location.hostname);
153
- if (ip) {
154
- hostname = `${ip}:${window.location.port}`;
155
- } else {
156
- console.warn(`Cannot find suitable IP in host ${instanceObj.common.host} for ${instanceObj._id}`);
157
- return;
158
- }
159
- }
160
- }
161
- }
162
-
163
- await new Promise<void>(resolve => { this.setState({ _error: '', _message: '', hostname }, resolve); });
164
-
165
- if (this.props.schema.onLoaded) {
166
- this._onClick();
167
- }
168
- }
169
-
170
- renderErrorDialog() {
171
- if (this.state._error) {
172
- return <DialogError text={this.state._error} onClose={() => this.setState({ _error: '' })} />;
173
- }
174
- return null;
175
- }
176
-
177
- renderMessageDialog() {
178
- if (this.state._message) {
179
- return <DialogMessage text={this.state._message} onClose={() => this.setState({ _message: '' })} />;
180
- }
181
- return null;
182
- }
183
-
184
- _onClick() {
185
- this.props.onCommandRunning(true);
186
- this.setState({ running: true });
187
-
188
- const _origin = `${window.location.protocol}//${window.location.host}${window.location.pathname.replace(/\/index\.html$/, '')}`;
189
- const _originIp = `${window.location.protocol}//${this.state.hostname.split(':').length > 3 ? `[${this.state.hostname}]` : this.state.hostname}${window.location.pathname.replace(/\/index\.html$/, '')}`;
190
-
191
- let data: Record<string, any> = this.props.schema.data;
192
- if (data === undefined && this.props.schema.jsonData) {
193
- const dataStr = this.getPattern(this.props.schema.jsonData, {
194
- _origin,
195
- _originIp,
196
- ...this.props.data,
197
- });
198
-
199
- try {
200
- data = JSON.parse(dataStr);
201
- } catch (e) {
202
- console.error(`Cannot parse json data: ${dataStr}`);
203
- }
204
- }
205
- if (data === undefined) {
206
- data = null;
207
- }
208
- if (this.props.schema.openUrl && !data) {
209
- data = {
210
- _origin,
211
- _originIp,
212
- };
213
- }
214
- let timeout: ReturnType<typeof setTimeout> | undefined;
215
- if (this.props.schema.timeout) {
216
- timeout = setTimeout(() => {
217
- this.props.onCommandRunning(false);
218
- this.setState({ _error: I18n.t('ra_Request timed out'), running: false });
219
- }, parseInt(this.props.schema.timeout as any as string, 10) || 10000);
220
- }
221
-
222
- this.props.socket.sendTo(
223
- `${this.props.adapterName}.${this.props.instance}`,
224
- this.props.schema.command || 'send',
225
- data,
226
- )
227
- .then(async (response: Record<string, any>) => {
228
- if (timeout) {
229
- clearTimeout(timeout);
230
- timeout = undefined;
231
- }
232
- if (response?.error) {
233
- if (this.props.schema.error && this.props.schema.error[response.error]) {
234
- let error = this.getText(this.props.schema.error[response.error]);
235
- if (response.args) {
236
- response.args.forEach((arg: string) => error = error.replace('%s', arg));
237
- }
238
- this.setState({ _error: error });
239
- } else {
240
- this.setState({ _error: response.error ? I18n.t(response.error) : I18n.t('ra_Error') });
241
- }
242
- } else {
243
- if (response?.reloadBrowser && this.props.schema.reloadBrowser) {
244
- window.location.reload();
245
- } else if (response?.openUrl && this.props.schema.openUrl) {
246
- window.open(response.openUrl, response.window || this.props.schema.window || '_blank');
247
- } else if (response?.result && this.props.schema.result && this.props.schema.result[response.result]) {
248
- let text = this.getText(this.props.schema.result[response.result]);
249
- if (response.args) {
250
- response.args.forEach((arg: string) => text = text.replace('%s', arg));
251
- }
252
- window.alert(text);
253
- }
254
-
255
- if (response?.native && this.props.schema.useNative) {
256
- for (const [attr, val] of Object.entries(response.native)) {
257
- await this.onChangeAsync(attr, val);
258
- }
259
-
260
- setTimeout(() => this.props.forceUpdate(Object.keys(response.native), this.props.data), 300);
261
- } else if (response?.result) {
262
- window.alert(typeof response.result === 'object' ? JSON.stringify(response.result) : response.result);
263
- } else {
264
- window.alert(I18n.t('ra_Ok'));
265
- }
266
-
267
- if (response?.saveConfig) {
268
- this.props.onChange(null, null, null, true);
269
- }
270
- }
271
- })
272
- .catch((e: any) => {
273
- if (this.props.schema.error && this.props.schema.error[e.toString()]) {
274
- this.setState({ _error: this.getText(this.props.schema.error[e.toString()]) });
275
- } else {
276
- this.setState({ _error: I18n.t(e.toString()) || I18n.t('ra_Error') });
277
- }
278
- })
279
- .then(() => {
280
- this.props.onCommandRunning(false);
281
- this.setState({ running: false });
282
- });
283
- }
284
-
285
- renderConfirmDialog() {
286
- if (!this.state.confirmDialog) {
287
- return null;
288
- }
289
- const confirm = this.state.confirmData || this.props.schema.confirm;
290
- let icon = null;
291
- if (confirm.type === 'warning') {
292
- icon = <IconWarning />;
293
- } else if (confirm.type === 'error') {
294
- icon = <IconError />;
295
- } else if (confirm.type === 'info') {
296
- icon = <IconInfo />;
297
- }
298
-
299
- return <DialogConfirm
300
- title={this.getText(confirm.title) || I18n.t('ra_Please confirm')}
301
- text={this.getText(confirm.text)}
302
- ok={this.getText(confirm.ok) || I18n.t('ra_Ok')}
303
- cancel={this.getText(confirm.cancel) || I18n.t('ra_Cancel')}
304
- icon={icon || undefined}
305
- onClose={isOk =>
306
- this.setState({ confirmDialog: false }, () =>
307
- isOk && this._onClick())}
308
- />;
309
- }
310
-
311
- renderItem(error: Error | undefined, disabled: boolean) {
312
- const icon = this.getIcon();
313
-
314
- return <div className={this.props.classes.fullWidth}>
315
- <Button
316
- variant={this.props.schema.variant || undefined}
317
- // @ts-expect-error grey is valid color
318
- color={this.props.schema.color || 'grey'}
319
- className={this.props.classes.fullWidth}
320
- disabled={disabled || !this.props.alive}
321
- startIcon={icon}
322
- title={this.props.alive ? this.getText(this.props.schema.title) || '' : I18n.t('ra_Instance is not alive')}
323
- onClick={() => {
324
- if (this.props.schema.confirm) {
325
- this.setState({ confirmDialog: true });
326
- } else {
327
- this._onClick();
328
- }
329
- }}
330
- >
331
- {this.props.schema.showProcess && this.state.running ? <CircularProgress size={20} style={{ marginRight: 8 }} /> : null}
332
- {this.getText(this.props.schema.label, this.props.schema.noTranslation)}
333
- </Button>
334
- {this.renderErrorDialog()}
335
- {this.renderMessageDialog()}
336
- </div>;
337
- }
338
- }
339
-
340
- export default withStyles(styles)(ConfigSendto);
@@ -1,116 +0,0 @@
1
- import React from 'react';
2
- import PropTypes from 'prop-types';
3
- import { withStyles } from '@mui/styles';
4
-
5
- import { Button } from '@mui/material';
6
-
7
- import {
8
- Warning as IconWarning,
9
- Error as IconError,
10
- Info as IconInfo,
11
- } from '@mui/icons-material';
12
-
13
- import { Confirm as ConfirmDialog, Icon, I18n } from '@iobroker/adapter-react-v5';
14
- import ConfigGeneric from './ConfigGeneric';
15
-
16
- const styles = () => ({
17
- fullWidth: {
18
- width: '100%',
19
- },
20
- icon: {
21
- width: 24,
22
- height: 24,
23
- marginRight: 4,
24
- },
25
- });
26
-
27
- class ConfigSetState extends ConfigGeneric {
28
- async _onClick() {
29
- let val = this.props.schema.val;
30
- if (typeof val === 'string' && val.includes('${')) {
31
- val = this.getPattern(val);
32
- const obj = await this.props.socket.getObject(this.props.schema.id);
33
- if (obj?.common?.type === 'number') {
34
- val = parseFloat(val);
35
- } else if (obj?.common?.type === 'boolean') {
36
- val = val === 'true' || val === true || val === '1' || val === 1;
37
- }
38
- }
39
-
40
- const id = (this.props.schema.id || '').replace(/%INSTANCE%/g, this.props.instance);
41
-
42
- try {
43
- await this.props.socket.setState(id, { val, ack: !!this.props.schema.ack });
44
- this.props.schema.okText && window.alert(this.getText(this.props.schema.okText));
45
- } catch (e) {
46
- if (this.props.schema.error && this.props.schema.error[e.toString()]) {
47
- window.alert(this.getText(this.props.schema.error[e.toString()]));
48
- } else {
49
- window.alert(I18n.t(e.toString()) || I18n.t('ra_Error'));
50
- }
51
- }
52
- }
53
-
54
- renderConfirmDialog() {
55
- if (!this.state.confirmDialog) {
56
- return null;
57
- }
58
- const confirm = this.state.confirmData || this.props.schema.confirm;
59
- let icon = null;
60
- if (confirm.type === 'warning') {
61
- icon = <IconWarning />;
62
- } else if (confirm.type === 'error') {
63
- icon = <IconError />;
64
- } else if (confirm.type === 'info') {
65
- icon = <IconInfo />;
66
- }
67
-
68
- return <ConfirmDialog
69
- title={this.getText(confirm.title) || I18n.t('ra_Please confirm')}
70
- text={this.getText(confirm.text)}
71
- ok={this.getText(confirm.ok) || I18n.t('ra_Ok')}
72
- cancel={this.getText(confirm.cancel) || I18n.t('ra_Cancel')}
73
- icon={icon}
74
- onClose={isOk =>
75
- this.setState({ confirmDialog: false }, () =>
76
- isOk && this._onClick())}
77
- />;
78
- }
79
-
80
- renderItem(error, disabled /* , defaultValue */) {
81
- return <Button
82
- variant={this.props.schema.variant || undefined}
83
- color={this.props.schema.color || 'grey'}
84
- className={this.props.classes.fullWidth}
85
- disabled={disabled}
86
- onClick={async () => {
87
- if (this.props.schema.confirm) {
88
- this.setState({ confirmDialog: true });
89
- } else {
90
- await this._onClick();
91
- }
92
- }}
93
- >
94
- {this.props.schema.icon ? <Icon src={this.props.schema.icon} className={this.props.classes.icon} /> : null}
95
- {this.getText(this.props.schema.label, this.props.schema.noTranslation)}
96
- </Button>;
97
- }
98
- }
99
-
100
- ConfigSetState.propTypes = {
101
- socket: PropTypes.object.isRequired,
102
- themeType: PropTypes.string,
103
- themeName: PropTypes.string,
104
- style: PropTypes.object,
105
- className: PropTypes.string,
106
- data: PropTypes.object.isRequired,
107
- schema: PropTypes.object,
108
- onError: PropTypes.func,
109
- onChange: PropTypes.func,
110
- adapterName: PropTypes.string,
111
- instance: PropTypes.number,
112
- commandRunning: PropTypes.bool,
113
- onCommandRunning: PropTypes.func,
114
- };
115
-
116
- export default withStyles(styles)(ConfigSetState);
@@ -1,97 +0,0 @@
1
- import React from 'react';
2
- import PropTypes from 'prop-types';
3
- import { withStyles } from '@mui/styles';
4
-
5
- import { Box, Typography, Slider } from '@mui/material';
6
-
7
- import ConfigGeneric from './ConfigGeneric';
8
-
9
- const styles = () => ({
10
- fullWidth: {
11
- width: '100%',
12
- },
13
- slider: {
14
- marginLeft: 10,
15
- marginRight: 10,
16
- width: 'calc(100% - 20px)',
17
- },
18
- });
19
-
20
- class ConfigSlider extends ConfigGeneric {
21
- componentDidMount() {
22
- super.componentDidMount();
23
- const _value = ConfigGeneric.getValue(this.props.data, this.props.attr);
24
- this.setState({ _value });
25
- }
26
-
27
- static getDerivedStateFromProps(props, state) {
28
- if (
29
- (props.schema.min !== undefined && props.schema.min < 0) ||
30
- (props.schema.max !== undefined && props.schema.max < 0)
31
- ) {
32
- return null;
33
- }
34
- const _value = ConfigGeneric.getValue(props.data, props.attr);
35
- if (_value === null || _value === undefined || _value.toString() !== parseFloat(state._value).toString()) {
36
- return { _value };
37
- }
38
-
39
- return null;
40
- }
41
-
42
- renderItem(error, disabled /* , defaultValue */) {
43
- const min = this.props.schema.min || 0;
44
- const max = this.props.schema.max || 100;
45
- const unit = this.props.schema.unit || '';
46
-
47
- const marks = [
48
- { value: min, label: min + unit },
49
- { value: max, label: max + unit },
50
- ];
51
-
52
- return (
53
- <Box className={this.props.classes.fullWidth}>
54
- {this.props.schema.label ? (
55
- <Typography gutterBottom>{this.getText(this.props.schema.label)}</Typography>
56
- ) : null}
57
- <Slider
58
- className={this.props.classes.slider}
59
- value={this.state._value}
60
- getAriaValueText={value => value + unit}
61
- step={this.props.schema.step || (max - min) / 100}
62
- valueLabelDisplay="auto"
63
- marks={marks}
64
- min={min}
65
- max={max}
66
- disabled={!!disabled}
67
- error={error || ''}
68
- onChange={e => {
69
- const _value = e.target.value;
70
- this.setState({ _value }, () => this.onChange(this.props.attr, _value));
71
- }}
72
- />
73
- {this.props.schema.help ? <Typography>
74
- {this.renderHelp(
75
- this.props.schema.help,
76
- this.props.schema.helpLink,
77
- this.props.schema.noTranslation,
78
- )}
79
- </Typography> : null}
80
- </Box>
81
- );
82
- }
83
- }
84
-
85
- ConfigSlider.propTypes = {
86
- socket: PropTypes.object.isRequired,
87
- themeType: PropTypes.string,
88
- themeName: PropTypes.string,
89
- style: PropTypes.object,
90
- className: PropTypes.string,
91
- data: PropTypes.object.isRequired,
92
- schema: PropTypes.object,
93
- onError: PropTypes.func,
94
- onChange: PropTypes.func,
95
- };
96
-
97
- export default withStyles(styles)(ConfigSlider);
@@ -1,51 +0,0 @@
1
- import React from 'react';
2
- import PropTypes from 'prop-types';
3
- import { withStyles } from '@mui/styles';
4
-
5
- import { Utils } from '@iobroker/adapter-react-v5';
6
-
7
- import ConfigGeneric from './ConfigGeneric';
8
-
9
- const styles = theme => ({
10
- fullWidth: {
11
- width: '100%',
12
- backgroundColor: theme.palette.mode === 'dark' ? '#FFF' : '#000',
13
- borderStyle: 'hidden',
14
- },
15
- primary: {
16
- backgroundColor: theme.palette.primary.main,
17
- },
18
- secondary: {
19
- backgroundColor: theme.palette.secondary.main,
20
- },
21
- });
22
-
23
- class ConfigStaticDivider extends ConfigGeneric {
24
- renderItem() {
25
- return <hr
26
- className={Utils.clsx(
27
- this.props.classes.fullWidth,
28
- this.props.schema.color === 'primary' && this.props.classes.primary,
29
- this.props.schema.color === 'secondary' && this.props.classes.secondary,
30
- )}
31
- style={{
32
- height: this.props.schema.color ? this.props.schema.height || 2 : this.props.schema.height || 1,
33
- backgroundColor: this.props.schema.color !== 'primary' && this.props.schema.color !== 'secondary' && this.props.schema.color ? this.props.schema.color : undefined,
34
- }}
35
- />;
36
- }
37
- }
38
-
39
- ConfigStaticDivider.propTypes = {
40
- socket: PropTypes.object.isRequired,
41
- themeType: PropTypes.string,
42
- themeName: PropTypes.string,
43
- style: PropTypes.object,
44
- className: PropTypes.string,
45
- data: PropTypes.object.isRequired,
46
- schema: PropTypes.object,
47
- onError: PropTypes.func,
48
- onChange: PropTypes.func,
49
- };
50
-
51
- export default withStyles(styles)(ConfigStaticDivider);
@@ -1,63 +0,0 @@
1
- import React from 'react';
2
- import PropTypes from 'prop-types';
3
- import { withStyles } from '@mui/styles';
4
-
5
- import ConfigGeneric from './ConfigGeneric';
6
-
7
- const styles = theme => ({
8
- header: {
9
- width: '100%',
10
- background: theme.palette.primary.main,
11
- color: theme.palette.primary.contrastText,
12
- padding: '4px !important',
13
- borderRadius: 3,
14
- marginBlockEnd: 0,
15
- marginBlockStart: 0,
16
- },
17
- });
18
-
19
- class ConfigStaticHeader extends ConfigGeneric {
20
- renderItem() {
21
- switch ((this.props.schema.size || 5).toString()) {
22
- case '1':
23
- return <h1 className={this.props.classes.header}>
24
- {this.getText(this.props.schema.text, this.props.schema.noTranslation)}
25
- </h1>;
26
-
27
- case '2':
28
- return <h2 className={this.props.classes.header}>
29
- {this.getText(this.props.schema.text, this.props.schema.noTranslation)}
30
- </h2>;
31
-
32
- case '3':
33
- return <h3 className={this.props.classes.header}>
34
- {this.getText(this.props.schema.text, this.props.schema.noTranslation)}
35
- </h3>;
36
-
37
- case '4':
38
- return <h4 className={this.props.classes.header}>
39
- {this.getText(this.props.schema.text, this.props.schema.noTranslation)}
40
- </h4>;
41
-
42
- case '5':
43
- default:
44
- return <h5 className={this.props.classes.header}>
45
- {this.getText(this.props.schema.text, this.props.schema.noTranslation)}
46
- </h5>;
47
- }
48
- }
49
- }
50
-
51
- ConfigStaticHeader.propTypes = {
52
- socket: PropTypes.object.isRequired,
53
- themeType: PropTypes.string,
54
- themeName: PropTypes.string,
55
- style: PropTypes.object,
56
- className: PropTypes.string,
57
- data: PropTypes.object.isRequired,
58
- schema: PropTypes.object,
59
- onError: PropTypes.func,
60
- onChange: PropTypes.func,
61
- };
62
-
63
- export default withStyles(styles)(ConfigStaticHeader);