@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,67 +0,0 @@
1
- import React from 'react';
2
- import { withStyles } from '@mui/styles';
3
-
4
- import {
5
- FormControlLabel,
6
- Checkbox,
7
- FormHelperText,
8
- FormControl,
9
- } from '@mui/material';
10
-
11
- import { type AdminConnection, I18n } from '@iobroker/adapter-react-v5';
12
- import type { ThemeName, ThemeType } from '@iobroker/adapter-react-v5/types';
13
-
14
- import ConfigGeneric, { type ConfigGenericProps, type ConfigGenericState } from './ConfigGeneric';
15
- import type {ConfigItemCheckbox} from "#JC/types";
16
-
17
- const styles: Record<string, any> = {
18
- error: {
19
- color: 'red',
20
- },
21
- };
22
-
23
- interface ConfigCheckboxProps extends ConfigGenericProps {
24
- schema: ConfigItemCheckbox;
25
- }
26
-
27
- class ConfigCheckbox extends ConfigGeneric<ConfigCheckboxProps, ConfigGenericState> {
28
- renderItem(error: unknown, disabled: boolean): React.JSX.Element {
29
- const value = ConfigGeneric.getValue(this.props.data, this.props.attr);
30
- const isIndeterminate = Array.isArray(value);
31
-
32
- return <FormControl className={this.props.classes.fullWidth} variant="standard">
33
- <FormControlLabel
34
- onClick={e => {
35
- e.preventDefault();
36
- e.stopPropagation();
37
-
38
- if (!disabled) {
39
- this.onChange(this.props.attr, !value);
40
- }
41
- }}
42
- control={<Checkbox
43
- indeterminate={isIndeterminate}
44
- checked={!!value}
45
- onChange={e => {
46
- if (isIndeterminate) {
47
- this.onChange(this.props.attr, true);
48
- } else {
49
- this.onChange(this.props.attr, e.target.checked);
50
- }
51
- }}
52
- disabled={disabled}
53
- />}
54
- label={this.getText(this.props.schema.label)}
55
- />
56
- <FormHelperText className={this.props.classes.error}>
57
- {
58
- error ? (this.props.schema.validatorErrorText ? I18n.t(this.props.schema.validatorErrorText) : I18n.t('ra_Error')) :
59
- null
60
- }
61
- </FormHelperText>
62
- {this.props.schema.help ? <FormHelperText>{this.renderHelp(this.props.schema.help, this.props.schema.helpLink, this.props.schema.noTranslation)}</FormHelperText> : null}
63
- </FormControl>;
64
- }
65
- }
66
-
67
- export default withStyles(styles)(ConfigCheckbox);
@@ -1,81 +0,0 @@
1
- import React from 'react';
2
- import PropTypes from 'prop-types';
3
- import { withStyles } from '@mui/styles';
4
-
5
- import {
6
- FormHelperText,
7
- FormControl,
8
- } from '@mui/material';
9
-
10
- import ConfigGeneric from './ConfigGeneric';
11
- import ChipInput from './ChipInput';
12
-
13
- const styles = () => ({
14
- fullWidth: {
15
- width: '100%',
16
- },
17
- });
18
-
19
- class ConfigLanguage extends ConfigGeneric {
20
- componentDidMount() {
21
- super.componentDidMount();
22
- const { data, attr } = this.props;
23
- const value = ConfigGeneric.getValue(data, attr);
24
- if (this.props.schema.delimiter && typeof value === 'string') {
25
- const parts = value.split(this.props.schema.delimiter).map(a => a.trim()).filter(a => a);
26
- this.setState({ value: parts });
27
- } else {
28
- this.setState({ value: value || [] });
29
- }
30
- }
31
-
32
- renderItem(error, disabled /* , defaultValue */) {
33
- const { attr, schema } = this.props;
34
- const { value } = this.state;
35
- return <FormControl className={this.props.classes.fullWidth} variant="standard">
36
- <ChipInput
37
- value={value}
38
- disabled={!!disabled}
39
- label={this.getText(schema.label)}
40
- error={!!error}
41
- onAdd={chip => {
42
- const newValue = JSON.parse(JSON.stringify(value));
43
- newValue.push(chip);
44
- this.setState({ value: newValue, prevValue: '' }, () => {
45
- if (this.props.schema.delimiter) {
46
- this.onChange(attr, newValue.join(`${this.props.schema.delimiter} `));
47
- } else {
48
- this.onChange(attr, newValue);
49
- }
50
- });
51
- }}
52
- onDelete={(chip, index) => {
53
- const newValue = JSON.parse(JSON.stringify(value));
54
- newValue.splice(index, 1);
55
- this.setState({ value: newValue, prevValue: '' }, () => {
56
- if (this.props.schema.delimiter) {
57
- this.onChange(attr, newValue.join(`${this.props.schema.delimiter} `));
58
- } else {
59
- this.onChange(attr, newValue);
60
- }
61
- });
62
- }}
63
- />
64
- {this.props.schema.help ? <FormHelperText>{this.renderHelp(this.props.schema.help, this.props.schema.helpLink, this.props.schema.noTranslation)}</FormHelperText> : null}
65
- </FormControl>;
66
- }
67
- }
68
-
69
- ConfigLanguage.propTypes = {
70
- socket: PropTypes.object.isRequired,
71
- themeType: PropTypes.string,
72
- themeName: PropTypes.string,
73
- style: PropTypes.object,
74
- className: PropTypes.string,
75
- data: PropTypes.object.isRequired,
76
- schema: PropTypes.object,
77
- onError: PropTypes.func,
78
- onChange: PropTypes.func,
79
- };
80
-
81
- export default withStyles(styles)(ConfigLanguage);
@@ -1,86 +0,0 @@
1
- import React from 'react';
2
- import { ChromePicker, type ColorResult, type RGBColor } from 'react-color';
3
-
4
- import {
5
- IconButton,
6
- TextField,
7
- Dialog,
8
- } from '@mui/material';
9
-
10
- import { Close as ClearIcon } from '@mui/icons-material';
11
-
12
- import { Utils } from '@iobroker/adapter-react-v5';
13
-
14
- import type { ConfigItemText } from '#JC/types';
15
- import ConfigGeneric, { type ConfigGenericProps, type ConfigGenericState } from './ConfigGeneric';
16
-
17
- interface ConfigColorProps extends ConfigGenericProps {
18
- schema: ConfigItemText;
19
- }
20
-
21
- interface ConfigColorState extends ConfigGenericState {
22
- showColorDialog?: boolean;
23
- colorDialogValue?: string;
24
- }
25
-
26
- class ConfigColor extends ConfigGeneric<ConfigColorProps, ConfigColorState> {
27
- renderColorDialog() {
28
- return !!this.state.showColorDialog && <Dialog
29
- onClose={() => this.setState({ showColorDialog: false })}
30
- open={this.state.showColorDialog}
31
- >
32
- <ChromePicker
33
- color={this.state.colorDialogValue}
34
- onChange={(color: ColorResult) =>
35
- this.setState({ colorDialogValue: color.hex }, () =>
36
- this.onChange(this.props.attr, this.state.colorDialogValue))}
37
- />
38
- </Dialog>;
39
- }
40
-
41
- renderItem(_error: unknown, disabled: boolean /* , defaultValue */) {
42
- const value = ConfigGeneric.getValue(this.props.data, this.props.attr);
43
- let textColor = Utils.isUseBright(value, null);
44
- if (textColor === null) {
45
- textColor = undefined;
46
- }
47
- return <>
48
- {this.renderColorDialog()}
49
- <TextField
50
- variant="standard"
51
- disabled={!!disabled}
52
- style={{ minWidth: 100, width: 'calc(100% - 8px)' }}
53
- label={this.getText(this.props.schema.label)}
54
- value={value || ''}
55
- onClick={() => !this.props.schema.readOnly && this.setState({ showColorDialog: true, colorDialogValue: value || '' })}
56
- onChange={e => {
57
- const color = e.target.value;
58
- this.onChange(this.props.attr, color);
59
- }}
60
- inputProps={{
61
- style: {
62
- // paddingLeft: noPadding ? 0 : 8,
63
- backgroundColor: value,
64
- color: textColor ? '#FFF' : '#000',
65
- },
66
- readOnly: this.props.schema.readOnly || false,
67
- }}
68
- // eslint-disable-next-line react/jsx-no-duplicate-props
69
- InputProps={{
70
- endAdornment: value && !this.props.schema.noClearButton ? <IconButton
71
- size="small"
72
- onClick={e => {
73
- e.stopPropagation();
74
- this.onChange(this.props.attr, '');
75
- }}
76
- >
77
- <ClearIcon />
78
- </IconButton> : undefined,
79
- }}
80
- InputLabelProps={{ shrink: true }}
81
- />
82
- </>;
83
- }
84
- }
85
-
86
- export default ConfigColor;
@@ -1,234 +0,0 @@
1
- import React from 'react';
2
- import { withStyles } from '@mui/styles';
3
-
4
- import {
5
- TextField,
6
- Fab,
7
- FormControlLabel,
8
- Checkbox,
9
- } from '@mui/material';
10
-
11
- import {
12
- GpsFixed as IconGpsFixed,
13
- LocationOn as IconLocationOn,
14
- } from '@mui/icons-material';
15
-
16
- import { I18n } from '@iobroker/adapter-react-v5';
17
-
18
- import ConfigGeneric, { type ConfigGenericProps, type ConfigGenericState } from './ConfigGeneric';
19
- import type { ConfigItemCoordinates } from '#JC/types';
20
-
21
- const styles: Record<string, any> = {
22
- width: {
23
- width: 'calc(100% - 85px)',
24
- },
25
- width50: {
26
- width: 120,
27
- marginRight: 5,
28
- },
29
- };
30
-
31
- interface ConfigCoordinatesProps extends ConfigGenericProps {
32
- classes: Record<string, string>;
33
- schema: ConfigItemCoordinates;
34
- }
35
-
36
- interface ConfigCoordinatesState extends ConfigGenericState {
37
- useSystem?: boolean;
38
- longitude?: string | number;
39
- latitude?: string | number;
40
- }
41
-
42
- class ConfigCoordinates extends ConfigGeneric<ConfigCoordinatesProps, ConfigCoordinatesState> {
43
- componentDidMount() {
44
- super.componentDidMount();
45
-
46
- const value = ConfigGeneric.getValue(this.props.data, this.props.attr);
47
- this.setState({ value });
48
-
49
- const newState: Partial<ConfigCoordinatesState> = {};
50
- if (this.props.schema.useSystemName) {
51
- newState.useSystem = !!ConfigGeneric.getValue(this.props.data, this.props.schema.useSystemName);
52
- }
53
- if (this.props.schema.longitudeName && this.props.schema.latitudeName) {
54
- newState.longitude = ConfigGeneric.getValue(this.props.data, this.props.schema.longitudeName);
55
- newState.latitude = ConfigGeneric.getValue(this.props.data, this.props.schema.latitudeName);
56
- if (!newState.longitude && !newState.latitude && this.props.schema.autoInit) {
57
- setTimeout(() => this.getCoordinates(), 300);
58
- }
59
- } else {
60
- const value_ = ConfigGeneric.getValue(this.props.data, this.props.attr);
61
- if (!value_ && this.props.schema.autoInit) {
62
- setTimeout(() => this.getCoordinates(), 300);
63
- }
64
- }
65
- Object.keys(newState).length && setTimeout(() => this.setState(newState as ConfigCoordinatesState), 50);
66
- }
67
-
68
- async getSystemCoordinates() {
69
- const obj = await this.props.socket.getCompactSystemConfig();
70
- if (obj?.common && (obj.common.longitude || obj.common.latitude)) {
71
- window.alert(I18n.t('ra_Used system settings'));
72
- if (this.props.schema.longitudeName && this.props.schema.latitudeName) {
73
- this.setState(
74
- {
75
- longitude: obj.common.longitude,
76
- latitude: obj.common.latitude,
77
- },
78
- async () => {
79
- await this.onChange(this.props.schema.longitudeName, (obj.common.longitude || '').trim());
80
- await this.onChange(this.props.schema.latitudeName, (obj.common.latitude || '').trim());
81
- },
82
- );
83
- } else {
84
- const value = obj.common.latitude + (this.props.schema.divider || ',') + obj.common.longitude;
85
- this.setState(
86
- {
87
- value,
88
- },
89
- () => {
90
- this.onChange(this.props.attr, value);
91
- },
92
- );
93
- }
94
- } else {
95
- window.alert(
96
- I18n.t(
97
- 'ra_Cannot determine position: System settings are empty and GPS detection is disabled in browser',
98
- ),
99
- );
100
- }
101
- }
102
-
103
- getCoordinates() {
104
- if (navigator.geolocation) {
105
- navigator.geolocation.getCurrentPosition(
106
- position => {
107
- if (position?.coords) {
108
- if (this.props.schema.longitudeName && this.props.schema.latitudeName) {
109
- this.setState(
110
- {
111
- longitude: position.coords.longitude,
112
- latitude: position.coords.latitude,
113
- },
114
- async () => {
115
- await this.onChange(
116
- this.props.schema.longitudeName,
117
- position.coords.longitude || '',
118
- );
119
- await this.onChange(this.props.schema.latitudeName, position.coords.latitude || '');
120
- },
121
- );
122
- } else {
123
- const value =
124
- position.coords.latitude +
125
- (this.props.schema.divider || ',') +
126
- position.coords.longitude;
127
- this.setState({ value }, () => {
128
- this.onChange(this.props.attr, value);
129
- });
130
- }
131
- } else {
132
- this.getSystemCoordinates();
133
- }
134
- },
135
- error => {
136
- console.error(`Cannot determine coordinates from browser: ${error}`);
137
- this.getSystemCoordinates();
138
- },
139
- );
140
- } else {
141
- this.getSystemCoordinates();
142
- }
143
- }
144
-
145
- renderItem(error: string, disabled: boolean /* , defaultValue */) {
146
- return <>
147
- {this.props.schema.useSystemName ? <FormControlLabel
148
- control={
149
- <Checkbox
150
- checked={!!this.state.useSystem}
151
- onChange={e => {
152
- const useSystem = e.target.checked;
153
- if (useSystem) {
154
- this.getSystemCoordinates();
155
- }
156
- this.setState({ useSystem }, () =>
157
- this.onChange(this.props.schema.useSystemName, useSystem));
158
- }}
159
- />
160
- }
161
- label={I18n.t('ra_Use system settings for position')}
162
- /> : null}
163
- {this.props.schema.longitudeName && this.props.schema.latitudeName ?
164
- <TextField
165
- variant="standard"
166
- className={this.props.classes.width50}
167
- value={this.state.longitude ?? ''}
168
- error={!!error}
169
- disabled={this.state.useSystem || !!disabled}
170
- onChange={e => {
171
- const longitude = e.target.value;
172
- this.setState({ longitude }, () => {
173
- this.onChange(this.props.schema.longitudeName, (longitude || '').trim());
174
- });
175
- }}
176
- label={I18n.t('ra_Longitude')}
177
- /> : null}
178
- {this.props.schema.longitudeName && this.props.schema.latitudeName ?
179
- <TextField
180
- variant="standard"
181
- className={this.props.classes.width50}
182
- value={this.state.latitude ?? ''}
183
- error={!!error}
184
- disabled={this.state.useSystem || !!disabled}
185
- onChange={e => {
186
- const latitude = e.target.value;
187
- this.setState({ latitude }, () =>
188
- this.onChange(this.props.schema.latitudeName, (latitude || '').trim()));
189
- }}
190
- label={I18n.t('ra_Latitude')}
191
- /> : null}
192
- {!this.props.schema.longitudeName || !this.props.schema.latitudeName ?
193
- <TextField
194
- variant="standard"
195
- className={this.props.classes.width}
196
- value={this.state.value === null || this.state.value === undefined ? '' : this.state.value}
197
- error={!!error}
198
- disabled={!!disabled}
199
- inputProps={{
200
- maxLength: this.props.schema.maxLength || this.props.schema.max || undefined,
201
- readOnly: this.state.useSystem,
202
- }}
203
- onChange={e => {
204
- const value = e.target.value;
205
- this.setState({ value }, () => this.onChange(this.props.attr, (value || '').trim()));
206
- }}
207
- placeholder={this.getText(this.props.schema.placeholder)}
208
- label={this.getText(this.props.schema.label)}
209
- helperText={this.renderHelp(
210
- this.props.schema.help,
211
- this.props.schema.helpLink,
212
- this.props.schema.noTranslation,
213
- )}
214
- /> : null}
215
- {!this.state.useSystem ? <Fab
216
- size="small"
217
- onClick={() => this.getCoordinates()}
218
- title={I18n.t('ra_Take browser position')}
219
- style={{ marginRight: 4 }}
220
- >
221
- <IconLocationOn />
222
- </Fab> : null}
223
- {!this.state.useSystem ? <Fab
224
- size="small"
225
- onClick={() => this.getSystemCoordinates()}
226
- title={I18n.t('ra_Take position from system settings')}
227
- >
228
- <IconGpsFixed />
229
- </Fab> : null}
230
- </>;
231
- }
232
- }
233
-
234
- export default withStyles(styles)(ConfigCoordinates);