@iobroker/json-config 6.17.6 → 6.17.13

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 (173) hide show
  1. package/LICENSE +21 -21
  2. package/build/JsonConfig.d.ts +1 -1
  3. package/build/JsonConfig.js +18 -19
  4. package/build/JsonConfig.js.map +1 -1
  5. package/build/JsonConfigComponent/ChipInput.d.ts +89 -11
  6. package/build/JsonConfigComponent/ChipInput.js +48 -137
  7. package/build/JsonConfigComponent/ChipInput.js.map +1 -1
  8. package/build/JsonConfigComponent/ConfigAccordion.d.ts +7 -14
  9. package/build/JsonConfigComponent/ConfigAccordion.js +10 -21
  10. package/build/JsonConfigComponent/ConfigAccordion.js.map +1 -1
  11. package/build/JsonConfigComponent/ConfigAlive.d.ts +5 -1
  12. package/build/JsonConfigComponent/ConfigAlive.js +0 -1
  13. package/build/JsonConfigComponent/ConfigAlive.js.map +1 -1
  14. package/build/JsonConfigComponent/ConfigAutocomplete.d.ts +5 -29
  15. package/build/JsonConfigComponent/ConfigAutocomplete.js +7 -5
  16. package/build/JsonConfigComponent/ConfigAutocomplete.js.map +1 -1
  17. package/build/JsonConfigComponent/ConfigAutocompleteSendTo.d.ts +5 -14
  18. package/build/JsonConfigComponent/ConfigAutocompleteSendTo.js +3 -3
  19. package/build/JsonConfigComponent/ConfigAutocompleteSendTo.js.map +1 -1
  20. package/build/JsonConfigComponent/ConfigCRON.d.ts +1 -1
  21. package/build/JsonConfigComponent/ConfigCertCollection.d.ts +7 -13
  22. package/build/JsonConfigComponent/ConfigCertCollection.js +8 -18
  23. package/build/JsonConfigComponent/ConfigCertCollection.js.map +1 -1
  24. package/build/JsonConfigComponent/ConfigCertificateSelect.d.ts +7 -13
  25. package/build/JsonConfigComponent/ConfigCertificateSelect.js +5 -18
  26. package/build/JsonConfigComponent/ConfigCertificateSelect.js.map +1 -1
  27. package/build/JsonConfigComponent/ConfigCertificates.d.ts +7 -13
  28. package/build/JsonConfigComponent/ConfigCertificates.js +7 -18
  29. package/build/JsonConfigComponent/ConfigCertificates.js.map +1 -1
  30. package/build/JsonConfigComponent/ConfigCheckbox.d.ts +3 -11
  31. package/build/JsonConfigComponent/ConfigCheckbox.js +2 -2
  32. package/build/JsonConfigComponent/ConfigCheckbox.js.map +1 -1
  33. package/build/JsonConfigComponent/ConfigChip.d.ts +1 -1
  34. package/build/JsonConfigComponent/ConfigColor.d.ts +13 -20
  35. package/build/JsonConfigComponent/ConfigColor.js +9 -23
  36. package/build/JsonConfigComponent/ConfigColor.js.map +1 -1
  37. package/build/JsonConfigComponent/ConfigCoordinates.d.ts +8 -13
  38. package/build/JsonConfigComponent/ConfigCoordinates.js +29 -39
  39. package/build/JsonConfigComponent/ConfigCoordinates.js.map +1 -1
  40. package/build/JsonConfigComponent/ConfigCustom.d.ts +4 -50
  41. package/build/JsonConfigComponent/ConfigCustom.js +0 -1
  42. package/build/JsonConfigComponent/ConfigCustom.js.map +1 -1
  43. package/build/JsonConfigComponent/ConfigDatePicker.d.ts +8 -3
  44. package/build/JsonConfigComponent/ConfigDatePicker.js +21 -13
  45. package/build/JsonConfigComponent/ConfigDatePicker.js.map +1 -1
  46. package/build/JsonConfigComponent/ConfigDeviceManager.d.ts +5 -1
  47. package/build/JsonConfigComponent/ConfigDeviceManager.js +1 -1
  48. package/build/JsonConfigComponent/ConfigDeviceManager.js.map +1 -1
  49. package/build/JsonConfigComponent/ConfigFile.d.ts +1 -1
  50. package/build/JsonConfigComponent/ConfigFunc.d.ts +1 -1
  51. package/build/JsonConfigComponent/ConfigGeneric.d.ts +46 -32
  52. package/build/JsonConfigComponent/ConfigGeneric.js +23 -12
  53. package/build/JsonConfigComponent/ConfigGeneric.js.map +1 -1
  54. package/build/JsonConfigComponent/ConfigIP.d.ts +1 -1
  55. package/build/JsonConfigComponent/ConfigImageSendTo.d.ts +1 -1
  56. package/build/JsonConfigComponent/ConfigInstanceSelect.d.ts +1 -1
  57. package/build/JsonConfigComponent/ConfigInterface.d.ts +1 -1
  58. package/build/JsonConfigComponent/ConfigJsonEditor.d.ts +1 -1
  59. package/build/JsonConfigComponent/ConfigLanguage.d.ts +3 -2
  60. package/build/JsonConfigComponent/ConfigLanguage.js +2 -2
  61. package/build/JsonConfigComponent/ConfigLanguage.js.map +1 -1
  62. package/build/JsonConfigComponent/ConfigNumber.d.ts +3 -13
  63. package/build/JsonConfigComponent/ConfigNumber.js +2 -2
  64. package/build/JsonConfigComponent/ConfigNumber.js.map +1 -1
  65. package/build/JsonConfigComponent/ConfigObjectId.d.ts +1 -1
  66. package/build/JsonConfigComponent/ConfigPanel.d.ts +7 -2
  67. package/build/JsonConfigComponent/ConfigPanel.js +5 -40
  68. package/build/JsonConfigComponent/ConfigPanel.js.map +1 -1
  69. package/build/JsonConfigComponent/ConfigPassword.d.ts +1 -1
  70. package/build/JsonConfigComponent/ConfigPort.d.ts +6 -1
  71. package/build/JsonConfigComponent/ConfigPort.js +2 -3
  72. package/build/JsonConfigComponent/ConfigPort.js.map +1 -1
  73. package/build/JsonConfigComponent/ConfigRoom.d.ts +1 -1
  74. package/build/JsonConfigComponent/ConfigSelect.d.ts +1 -1
  75. package/build/JsonConfigComponent/ConfigSelectSendTo.d.ts +7 -16
  76. package/build/JsonConfigComponent/ConfigSelectSendTo.js +15 -61
  77. package/build/JsonConfigComponent/ConfigSelectSendTo.js.map +1 -1
  78. package/build/JsonConfigComponent/ConfigSendto.d.ts +3 -20
  79. package/build/JsonConfigComponent/ConfigSendto.js +8 -8
  80. package/build/JsonConfigComponent/ConfigSendto.js.map +1 -1
  81. package/build/JsonConfigComponent/ConfigSetState.d.ts +1 -1
  82. package/build/JsonConfigComponent/ConfigSlider.d.ts +1 -1
  83. package/build/JsonConfigComponent/ConfigStaticDivider.d.ts +1 -1
  84. package/build/JsonConfigComponent/ConfigStaticHeader.d.ts +1 -1
  85. package/build/JsonConfigComponent/ConfigStaticImage.d.ts +1 -1
  86. package/build/JsonConfigComponent/ConfigStaticText.d.ts +1 -1
  87. package/build/JsonConfigComponent/ConfigTable.d.ts +4 -25
  88. package/build/JsonConfigComponent/ConfigTable.js +5 -4
  89. package/build/JsonConfigComponent/ConfigTable.js.map +1 -1
  90. package/build/JsonConfigComponent/ConfigTabs.d.ts +8 -33
  91. package/build/JsonConfigComponent/ConfigTabs.js +10 -43
  92. package/build/JsonConfigComponent/ConfigTabs.js.map +1 -1
  93. package/build/JsonConfigComponent/ConfigText.d.ts +7 -13
  94. package/build/JsonConfigComponent/ConfigText.js +13 -18
  95. package/build/JsonConfigComponent/ConfigText.js.map +1 -1
  96. package/build/JsonConfigComponent/ConfigTextSendTo.d.ts +7 -9
  97. package/build/JsonConfigComponent/ConfigTextSendTo.js +11 -21
  98. package/build/JsonConfigComponent/ConfigTextSendTo.js.map +1 -1
  99. package/build/JsonConfigComponent/ConfigTimePicker.d.ts +9 -3
  100. package/build/JsonConfigComponent/ConfigTimePicker.js +28 -18
  101. package/build/JsonConfigComponent/ConfigTimePicker.js.map +1 -1
  102. package/build/JsonConfigComponent/ConfigTopic.d.ts +1 -1
  103. package/build/JsonConfigComponent/ConfigUUID.d.ts +12 -13
  104. package/build/JsonConfigComponent/ConfigUUID.js +1 -6
  105. package/build/JsonConfigComponent/ConfigUUID.js.map +1 -1
  106. package/build/JsonConfigComponent/ConfigUser.d.ts +1 -1
  107. package/build/JsonConfigComponent/index.d.ts +66 -25
  108. package/build/JsonConfigComponent/index.js +48 -61
  109. package/build/JsonConfigComponent/index.js.map +1 -1
  110. package/build/index.d.ts +2 -2
  111. package/build/index.js +2 -2
  112. package/build/index.js.map +1 -1
  113. package/package.json +27 -26
  114. package/src/JsonConfig.tsx +710 -0
  115. package/src/JsonConfigComponent/ChipInput.tsx +752 -0
  116. package/src/JsonConfigComponent/ConfigAccordion.tsx +278 -0
  117. package/src/JsonConfigComponent/ConfigAlive.tsx +74 -0
  118. package/src/JsonConfigComponent/ConfigAutocomplete.tsx +108 -0
  119. package/src/JsonConfigComponent/ConfigAutocompleteSendTo.tsx +183 -0
  120. package/src/JsonConfigComponent/ConfigCRON.jsx +101 -0
  121. package/src/JsonConfigComponent/ConfigCertCollection.tsx +102 -0
  122. package/src/JsonConfigComponent/ConfigCertificateSelect.tsx +92 -0
  123. package/src/JsonConfigComponent/ConfigCertificates.tsx +202 -0
  124. package/src/JsonConfigComponent/ConfigCheckLicense.jsx +662 -0
  125. package/src/JsonConfigComponent/ConfigCheckbox.tsx +67 -0
  126. package/src/JsonConfigComponent/ConfigChip.jsx +81 -0
  127. package/src/JsonConfigComponent/ConfigColor.tsx +86 -0
  128. package/src/JsonConfigComponent/ConfigCoordinates.tsx +234 -0
  129. package/src/JsonConfigComponent/ConfigCustom.tsx +246 -0
  130. package/src/JsonConfigComponent/ConfigDatePicker.tsx +48 -0
  131. package/src/JsonConfigComponent/ConfigDeviceManager.tsx +33 -0
  132. package/src/JsonConfigComponent/ConfigFile.jsx +181 -0
  133. package/src/JsonConfigComponent/ConfigFileSelector.jsx +520 -0
  134. package/src/JsonConfigComponent/ConfigFunc.jsx +90 -0
  135. package/src/JsonConfigComponent/ConfigGeneric.tsx +1027 -0
  136. package/src/JsonConfigComponent/ConfigIP.jsx +96 -0
  137. package/src/JsonConfigComponent/ConfigImageSendTo.jsx +79 -0
  138. package/src/JsonConfigComponent/ConfigImageUpload.jsx +114 -0
  139. package/src/JsonConfigComponent/ConfigInstanceSelect.jsx +172 -0
  140. package/src/JsonConfigComponent/ConfigInterface.jsx +112 -0
  141. package/src/JsonConfigComponent/ConfigJsonEditor.jsx +103 -0
  142. package/src/JsonConfigComponent/ConfigLanguage.tsx +153 -0
  143. package/src/JsonConfigComponent/ConfigLicense.jsx +148 -0
  144. package/src/JsonConfigComponent/ConfigNumber.tsx +207 -0
  145. package/src/JsonConfigComponent/ConfigObjectId.jsx +113 -0
  146. package/src/JsonConfigComponent/ConfigPanel.tsx +360 -0
  147. package/src/JsonConfigComponent/ConfigPassword.jsx +160 -0
  148. package/src/JsonConfigComponent/ConfigPattern.jsx +50 -0
  149. package/src/JsonConfigComponent/ConfigPort.tsx +232 -0
  150. package/src/JsonConfigComponent/ConfigRoom.jsx +90 -0
  151. package/src/JsonConfigComponent/ConfigSelect.jsx +124 -0
  152. package/src/JsonConfigComponent/ConfigSelectSendTo.tsx +251 -0
  153. package/src/JsonConfigComponent/ConfigSendto.tsx +340 -0
  154. package/src/JsonConfigComponent/ConfigSetState.jsx +116 -0
  155. package/src/JsonConfigComponent/ConfigSlider.jsx +97 -0
  156. package/src/JsonConfigComponent/ConfigStaticDivider.jsx +51 -0
  157. package/src/JsonConfigComponent/ConfigStaticHeader.jsx +63 -0
  158. package/src/JsonConfigComponent/ConfigStaticImage.jsx +48 -0
  159. package/src/JsonConfigComponent/ConfigStaticText.jsx +72 -0
  160. package/src/JsonConfigComponent/ConfigTable.tsx +1040 -0
  161. package/src/JsonConfigComponent/ConfigTabs.tsx +150 -0
  162. package/src/JsonConfigComponent/ConfigText.tsx +188 -0
  163. package/src/JsonConfigComponent/ConfigTextSendTo.tsx +102 -0
  164. package/src/JsonConfigComponent/ConfigTimePicker.tsx +63 -0
  165. package/src/JsonConfigComponent/ConfigTopic.jsx +78 -0
  166. package/src/JsonConfigComponent/ConfigUUID.tsx +55 -0
  167. package/src/JsonConfigComponent/ConfigUser.jsx +104 -0
  168. package/src/JsonConfigComponent/index.tsx +435 -0
  169. package/src/JsonConfigComponent/wrapper/Components/CustomModal.jsx +145 -0
  170. package/src/JsonConfigComponent/wrapper/Components/Editor.jsx +65 -0
  171. package/src/Utils.jsx +1683 -0
  172. package/src/index.tsx +14 -0
  173. package/src/types.d.ts +372 -0
@@ -0,0 +1,150 @@
1
+ import React from 'react';
2
+ import { withStyles } from '@mui/styles';
3
+
4
+ import { Tabs, Tab } from '@mui/material';
5
+
6
+ import type { ConfigItemTabs } from '#JC/types';
7
+ import ConfigGeneric, { type ConfigGenericProps, type ConfigGenericState } from './ConfigGeneric';
8
+ import ConfigPanel from './ConfigPanel';
9
+ import {bool} from "prop-types";
10
+
11
+ const styles: Record<string, any> = {
12
+ tabs: {
13
+ height: '100%',
14
+ width: '100%',
15
+ },
16
+ panel: {
17
+ height: 'calc(100% - 48px)',
18
+ width: '100%',
19
+ display: 'block',
20
+ },
21
+ };
22
+
23
+ interface ConfigTabsProps extends ConfigGenericProps {
24
+ schema: ConfigItemTabs;
25
+ dialogName?: string;
26
+ }
27
+
28
+ interface ConfigTabsState extends ConfigGenericState {
29
+ tab?: string;
30
+ }
31
+
32
+ class ConfigTabs extends ConfigGeneric<ConfigTabsProps, ConfigTabsState> {
33
+ constructor(props: ConfigTabsProps) {
34
+ super(props);
35
+
36
+ let tab = ((window as any)._localStorage as Storage || window.localStorage).getItem(`${this.props.dialogName || 'App'}.${this.props.adapterName}`) || Object.keys(this.props.schema.items)[0];
37
+ if (!Object.keys(this.props.schema.items).includes(tab)) {
38
+ tab = Object.keys(this.props.schema.items)[0];
39
+ }
40
+ Object.assign(this.state, { tab });
41
+ }
42
+
43
+ render() {
44
+ const items = this.props.schema.items;
45
+
46
+ return <div className={this.props.classes.tabs}>
47
+ <Tabs
48
+ variant="scrollable"
49
+ scrollButtons="auto"
50
+ style={this.props.schema.tabsStyle}
51
+ value={this.state.tab}
52
+ onChange={(e, tab) => {
53
+ ((window as any)._localStorage as Storage || window.localStorage).setItem(`${this.props.dialogName || 'App'}.${this.props.adapterName}`, tab);
54
+ this.setState({ tab });
55
+ }}
56
+ >
57
+ {Object.keys(items).map(name => {
58
+ let disabled: boolean;
59
+ if (this.props.custom) {
60
+ const hidden = this.executeCustom(
61
+ items[name].hidden,
62
+ this.props.data,
63
+ this.props.customObj,
64
+ this.props.instanceObj,
65
+ this.props.index,
66
+ this.props.globalData,
67
+ );
68
+ if (hidden) {
69
+ return null;
70
+ }
71
+ disabled = this.executeCustom(
72
+ items[name].disabled,
73
+ this.props.data,
74
+ this.props.customObj,
75
+ this.props.instanceObj,
76
+ this.props.index,
77
+ this.props.globalData,
78
+ ) as boolean;
79
+ } else {
80
+ const hidden: boolean = this.execute(
81
+ items[name].hidden,
82
+ false,
83
+ this.props.data,
84
+ this.props.index,
85
+ this.props.globalData,
86
+ ) as boolean;
87
+ if (hidden) {
88
+ return null;
89
+ }
90
+ disabled = this.execute(
91
+ items[name].disabled,
92
+ false,
93
+ this.props.data,
94
+ this.props.index,
95
+ this.props.globalData,
96
+ ) as boolean;
97
+ }
98
+ return <Tab
99
+ wrapped
100
+ disabled={disabled}
101
+ key={name}
102
+ value={name}
103
+ iconPosition={this.props.schema.iconPosition || 'start'}
104
+ icon={this.getIcon(items[name].icon)}
105
+ label={this.getText(items[name].label)}
106
+ />;
107
+ })}
108
+ </Tabs>
109
+ <ConfigPanel
110
+ isParentTab
111
+ changed={this.props.changed}
112
+ key={this.state.tab}
113
+ index={1001}
114
+ arrayIndex={this.props.arrayIndex}
115
+ globalData={this.props.globalData}
116
+ onCommandRunning={this.props.onCommandRunning}
117
+ commandRunning={this.props.commandRunning}
118
+ className={this.props.classes.panel}
119
+ socket={this.props.socket}
120
+ adapterName={this.props.adapterName}
121
+ instance={this.props.instance}
122
+ common={this.props.common}
123
+ customs={this.props.customs}
124
+ alive={this.props.alive}
125
+ themeType={this.props.themeType}
126
+ themeName={this.props.themeName}
127
+ data={this.props.data}
128
+ originalData={this.props.originalData}
129
+ systemConfig={this.props.systemConfig}
130
+ onError={this.props.onError}
131
+ onChange={this.props.onChange}
132
+ multiEdit={this.props.multiEdit}
133
+ dateFormat={this.props.dateFormat}
134
+ isFloatComma={this.props.isFloatComma}
135
+ // disabled={disabled}
136
+ imagePrefix={this.props.imagePrefix}
137
+ changeLanguage={this.props.changeLanguage}
138
+ forceUpdate={this.props.forceUpdate}
139
+ registerOnForceUpdate={this.props.registerOnForceUpdate}
140
+ customObj={this.props.customObj}
141
+ instanceObj={this.props.instanceObj}
142
+ custom={this.props.custom}
143
+ schema={items[this.state.tab]}
144
+ table={this.props.table}
145
+ />
146
+ </div>;
147
+ }
148
+ }
149
+
150
+ export default withStyles(styles)(ConfigTabs);
@@ -0,0 +1,188 @@
1
+ import React from 'react';
2
+ import { withStyles } from '@mui/styles';
3
+
4
+ import {
5
+ Autocomplete,
6
+ TextField,
7
+ TextareaAutosize, InputAdornment, IconButton,
8
+ } from '@mui/material';
9
+
10
+ import {
11
+ Close as CloseIcon,
12
+ } from '@mui/icons-material';
13
+
14
+ import { I18n } from '@iobroker/adapter-react-v5';
15
+
16
+ import type { ConfigItemText } from '#JC/types';
17
+ import ConfigGeneric, { type ConfigGenericProps, type ConfigGenericState } from './ConfigGeneric';
18
+
19
+ const styles: Record<string, any> = {
20
+ indeterminate: {
21
+ opacity: 0.5,
22
+ },
23
+ label: {
24
+ width: '100%',
25
+ fontSize: 16,
26
+ },
27
+ helper: {
28
+ width: '100%',
29
+ fontSize: 12,
30
+ },
31
+ error: {
32
+ width: '100%',
33
+ fontSize: 12,
34
+ color: '#FF0000',
35
+ },
36
+ };
37
+
38
+ interface ConfigTextProps extends ConfigGenericProps {
39
+ schema: ConfigItemText;
40
+ }
41
+
42
+ interface ConfigTextState extends ConfigGenericState {
43
+ oldValue?: string;
44
+ }
45
+
46
+ class ConfigText extends ConfigGeneric<ConfigTextProps, ConfigTextState> {
47
+ private updateTimeout: ReturnType<typeof setTimeout> | null = null;
48
+
49
+ componentDidMount() {
50
+ super.componentDidMount();
51
+ let value = ConfigGeneric.getValue(this.props.data, this.props.attr);
52
+
53
+ if (Array.isArray(value) && this.props.multiEdit) {
54
+ value = ConfigGeneric.DIFFERENT_VALUE;
55
+ this.setState({ value, oldValue: value });
56
+ return;
57
+ }
58
+
59
+ this.setState({ value, oldValue: value });
60
+ }
61
+
62
+ static getDerivedStateFromProps(props: ConfigTextProps, state: ConfigTextState) {
63
+ if (props.multiEdit && state.value === ConfigGeneric.DIFFERENT_VALUE) {
64
+ return ConfigGeneric.DIFFERENT_VALUE;
65
+ }
66
+
67
+ let value = ConfigGeneric.getValue(props.data, props.attr);
68
+
69
+ if (value !== null && value !== undefined) {
70
+ value = value.toString();
71
+ }
72
+
73
+ if (value === null || value === undefined || (value !== state.value && value !== state.oldValue)) {
74
+ return { value };
75
+ }
76
+ return null;
77
+ }
78
+
79
+ renderItem(error?: boolean, disabled?: boolean) {
80
+ const isIndeterminate = Array.isArray(this.state.value) || this.state.value === ConfigGeneric.DIFFERENT_VALUE;
81
+
82
+ if (this.state.oldValue !== null && this.state.oldValue !== undefined) {
83
+ this.updateTimeout && clearTimeout(this.updateTimeout);
84
+ this.updateTimeout = setTimeout(() => {
85
+ this.updateTimeout = null;
86
+ this.setState({ oldValue: null });
87
+ }, 30);
88
+ } else if (this.updateTimeout) {
89
+ clearTimeout(this.updateTimeout);
90
+ this.updateTimeout = null;
91
+ }
92
+
93
+ if (isIndeterminate) {
94
+ const autoCompleteOptions = ConfigGeneric.getValue(this.props.data, this.props.attr);
95
+ const arr = [...autoCompleteOptions].map(item => ({ label: item.toString(), value: item }));
96
+ arr.unshift({ label: I18n.t(ConfigGeneric.DIFFERENT_LABEL), value: ConfigGeneric.DIFFERENT_VALUE });
97
+
98
+ return <Autocomplete
99
+ className={this.props.classes.indeterminate}
100
+ fullWidth
101
+ value={arr[0]}
102
+ // getOptionSelected={(option, value) => option.label === value.label}
103
+ onChange={(_, value) => {
104
+ const val = value ? value.value : '';
105
+ this.onChange(this.props.attr, val, () => {
106
+ this.setState({ value: val, oldValue: val });
107
+ });
108
+ }}
109
+ options={arr}
110
+ getOptionLabel={option => option.label}
111
+ renderInput={params => <TextField
112
+ variant="standard"
113
+ {...params}
114
+ error={!!error}
115
+ placeholder={this.getText(this.props.schema.placeholder)}
116
+ inputProps={{
117
+ ...params.inputProps,
118
+ maxLength: this.props.schema.maxLength || this.props.schema.max || undefined,
119
+ readOnly: this.props.schema.readOnly || false,
120
+ }}
121
+ label={this.getText(this.props.schema.label)}
122
+ helperText={this.renderHelp(this.props.schema.help, this.props.schema.helpLink, this.props.schema.noTranslation)}
123
+ disabled={!!disabled}
124
+ />}
125
+ />;
126
+ }
127
+ if (this.props.schema.minRows > 1) {
128
+ const helper = this.renderHelp(this.props.schema.help, this.props.schema.helpLink, this.props.schema.noTranslation);
129
+ return <div style={{ width: '100%' }}>
130
+ {this.props.schema.label ? <div className={this.props.classes.label}>{this.getText(this.props.schema.label)}</div> : null}
131
+ <TextareaAutosize
132
+ // variant="standard"
133
+ style={{
134
+ width: '100%',
135
+ resize: 'vertical',
136
+ backgroundColor: this.props.themeType === 'dark' ? '#363636' : '#cccccc',
137
+ color: this.props.themeType === 'dark' ? '#fff' : '#111',
138
+ }}
139
+ minRows={this.props.schema.minRows}
140
+ maxRows={this.props.schema.maxRows}
141
+ value={this.state.value === null || this.state.value === undefined ? '' : this.state.value}
142
+ disabled={!!disabled}
143
+ readOnly={this.props.schema.readOnly || false}
144
+ onChange={e => {
145
+ const value = e.target.value;
146
+ this.setState({ value, oldValue: this.state.value }, () =>
147
+ this.onChange(this.props.attr, value || ''));
148
+ }}
149
+ placeholder={this.getText(this.props.schema.placeholder)}
150
+ />
151
+ {helper || error ? <div className={error ? this.props.classes.error : this.props.classes.helper}>{error || helper}</div> : null}
152
+ </div>;
153
+ }
154
+ return <TextField
155
+ variant="standard"
156
+ fullWidth
157
+ value={this.state.value === null || this.state.value === undefined ? '' : this.state.value}
158
+ error={!!error}
159
+ disabled={!!disabled}
160
+ inputProps={{
161
+ maxLength: this.props.schema.maxLength || this.props.schema.max || undefined,
162
+ readOnly: this.props.schema.readOnly || false,
163
+ }}
164
+ // eslint-disable-next-line react/jsx-no-duplicate-props
165
+ InputProps={{
166
+ endAdornment: this.state.value && !this.props.schema.noClearButton ? <InputAdornment position="end">
167
+ <IconButton
168
+ size="small"
169
+ onClick={() => this.setState({ value: '', oldValue: this.state.value }, () =>
170
+ this.onChange(this.props.attr, ''))}
171
+ >
172
+ <CloseIcon />
173
+ </IconButton>
174
+ </InputAdornment> : null,
175
+ }}
176
+ onChange={e => {
177
+ const value = e.target.value;
178
+ this.setState({ value, oldValue: this.state.value }, () =>
179
+ this.onChange(this.props.attr, value));
180
+ }}
181
+ placeholder={this.getText(this.props.schema.placeholder)}
182
+ label={this.getText(this.props.schema.label)}
183
+ helperText={this.renderHelp(this.props.schema.help, this.props.schema.helpLink, this.props.schema.noTranslation)}
184
+ />;
185
+ }
186
+ }
187
+
188
+ export default withStyles(styles)(ConfigText);
@@ -0,0 +1,102 @@
1
+ import React from 'react';
2
+ import { withStyles } from '@mui/styles';
3
+
4
+ import {
5
+ TextField,
6
+ IconButton,
7
+ } from '@mui/material';
8
+
9
+ import { IconCopy, Utils } from '@iobroker/adapter-react-v5';
10
+
11
+ import type { ConfigItemSendTo } from '#JC/types';
12
+ import ConfigGeneric, {type ConfigGenericProps, type ConfigGenericState} from './ConfigGeneric';
13
+
14
+ const styles: Record<string, any> = {
15
+ fullWidth: {
16
+ width: '100%',
17
+ },
18
+ };
19
+
20
+ interface ConfigTextSendToProps extends ConfigGenericProps {
21
+ schema: ConfigItemSendTo;
22
+ }
23
+
24
+ interface ConfigTextSendToState extends ConfigGenericState {
25
+ text?: string;
26
+ context?: string;
27
+ }
28
+
29
+ class ConfigTextSendTo extends ConfigGeneric<ConfigTextSendToProps, ConfigTextSendToState> {
30
+ componentDidMount() {
31
+ super.componentDidMount();
32
+
33
+ this.askInstance();
34
+ }
35
+
36
+ askInstance() {
37
+ if (this.props.alive) {
38
+ let data: Record<string, any> | undefined = this.props.schema.data;
39
+ if (data === undefined && this.props.schema.jsonData) {
40
+ const dataStr: string = this.getPattern(this.props.schema.jsonData);
41
+ try {
42
+ data = JSON.parse(dataStr);
43
+ } catch (e) {
44
+ console.error(`Cannot parse json data: ${dataStr}`);
45
+ }
46
+ }
47
+
48
+ if (data === undefined) {
49
+ data = null;
50
+ }
51
+
52
+ this.props.socket.sendTo(`${this.props.adapterName}.${this.props.instance}`, this.props.schema.command || 'send', data)
53
+ .then(text => this.setState({ text: text || '', context: this.getContext() }));
54
+ }
55
+ }
56
+
57
+ getContext() {
58
+ const context: Record<string, any> = {};
59
+ if (Array.isArray(this.props.schema.alsoDependsOn)) {
60
+ this.props.schema.alsoDependsOn.forEach(attr =>
61
+ context[attr] = ConfigGeneric.getValue(this.props.data, attr));
62
+ }
63
+ return JSON.stringify(context);
64
+ }
65
+
66
+ renderItem(/* error, disabled, defaultValue */) {
67
+ if (this.state.text === undefined) {
68
+ return null;
69
+ }
70
+
71
+ if (this.props.alive) {
72
+ const context = this.getContext();
73
+ if (context !== this.state.context) {
74
+ setTimeout(() => this.askInstance(), 300);
75
+ }
76
+ }
77
+
78
+ if (this.props.schema.container === 'text') {
79
+ return <TextField
80
+ variant="standard"
81
+ fullWidth
82
+ InputProps={{
83
+ endAdornment: this.props.schema.copyToClipboard ? <IconButton
84
+ size="small"
85
+ onClick={() => {
86
+ Utils.copyToClipboard(this.state.text);
87
+ window.alert('Copied');
88
+ }}
89
+ >
90
+ <IconCopy />
91
+ </IconButton> : undefined,
92
+ }}
93
+ value={this.state.text}
94
+ label={this.getText(this.props.schema.label)}
95
+ helperText={this.renderHelp(this.props.schema.help, this.props.schema.helpLink, this.props.schema.noTranslation)}
96
+ />;
97
+ }
98
+ return <div className={this.props.classes.fullWidth}>{this.state.text}</div>;
99
+ }
100
+ }
101
+
102
+ export default withStyles(styles)(ConfigTextSendTo);
@@ -0,0 +1,63 @@
1
+ import React from 'react';
2
+
3
+ import { TimePicker } from '@mui/x-date-pickers';
4
+
5
+ import type { ConfigItemTimePicker } from '#JC/types';
6
+ import ConfigGeneric, { type ConfigGenericProps } from './ConfigGeneric';
7
+
8
+ interface ConfigTimePickerProps extends ConfigGenericProps {
9
+ schema: ConfigItemTimePicker;
10
+ dialogName?: string;
11
+ }
12
+
13
+ export default class ConfigTimePicker extends ConfigGeneric<ConfigTimePickerProps> {
14
+ componentDidMount() {
15
+ super.componentDidMount();
16
+ const value = ConfigGeneric.getValue(this.props.data, this.props.attr);
17
+ this.setState({ value });
18
+ }
19
+
20
+ renderItem(_error: unknown, disabled: boolean) {
21
+ // the format could be 'HH:mm:ss' or 'HH:mm'
22
+ const shortFormat = this.props.schema.returnFormat !== 'HH:mm:ss';
23
+
24
+ const value: never = new Date(Date.parse(`Thu, 01 Jan 1970 ${this.state.value || '00:00:00'}`)) as never;
25
+
26
+ return <TimePicker
27
+ sx={theme => ({
28
+ width: '100%',
29
+ borderBottom: `1px solid ${theme.palette.text.primary}`,
30
+ '& fieldset': {
31
+ display: 'none',
32
+ },
33
+ '& input': {
34
+ padding: `${theme.spacing(1.5)} 0 4px 0`,
35
+ },
36
+ '& .MuiInputAdornment-root': {
37
+ marginLeft: 0,
38
+ marginTop: 1, // it is already in spaces
39
+ },
40
+ '& label': {
41
+ transform: 'translate(0px, -9px) scale(0.75)',
42
+ },
43
+ })}
44
+ ampm={this.props.systemConfig.dateFormat.includes('/')}
45
+ timeSteps={this.props.schema.timeSteps || this.props.schema.timesteps || { hours: 1, minutes: 5, seconds: 5 }}
46
+ format={this.props.schema.format || 'HH:mm:ss'}
47
+ disabled={!!disabled}
48
+ value={value}
49
+ onChange={(newValue: Date) => {
50
+ let strValue = newValue.toTimeString();
51
+ strValue = (newValue as any) instanceof Date ? (newValue as Date).toTimeString().split(' ')[0] : newValue.toTimeString();
52
+ if (shortFormat) {
53
+ strValue = strValue.split(':').slice(0, 2).join(':');
54
+ }
55
+
56
+ this.setState({ value: strValue }, () =>
57
+ this.onChange(this.props.attr, this.state.value));
58
+ }}
59
+ views={this.props.schema.views || ['hours', 'minutes', 'seconds']}
60
+ label={this.getText(this.props.schema.label)}
61
+ />;
62
+ }
63
+ }
@@ -0,0 +1,78 @@
1
+ import React from 'react';
2
+ import PropTypes from 'prop-types';
3
+ import { withStyles } from '@mui/styles';
4
+
5
+ import { TextField } from '@mui/material';
6
+
7
+ import ConfigGeneric from './ConfigGeneric';
8
+
9
+ const styles = () => ({
10
+ fullWidth: {
11
+ width: '100%',
12
+ },
13
+ icon: {
14
+ width: 16,
15
+ height: 16,
16
+ marginRight: 8,
17
+ },
18
+ });
19
+
20
+ function convertID2Topic(id, prefix, namespace) {
21
+ let topic;
22
+ if (namespace && id.substring(0, namespace.length) === namespace) {
23
+ topic = id.substring(namespace.length + 1);
24
+ } else {
25
+ topic = id;
26
+ }
27
+ topic = topic.replace(/\./g, '/').replace(/_/g, ' ');
28
+ return topic;
29
+ }
30
+
31
+ class ConfigTopic extends ConfigGeneric {
32
+ componentDidMount() {
33
+ super.componentDidMount();
34
+ const value = ConfigGeneric.getValue(this.props.data, this.props.attr);
35
+ if (!value && this.props.customObj && this.props.customObj._id) {
36
+ const topic = convertID2Topic(this.props.customObj._id, null, `${this.props.adapterName}.${this.props.instance}`);
37
+ this.setState({ value: topic });
38
+ } else {
39
+ this.setState({ value: value || '' });
40
+ }
41
+ }
42
+
43
+ renderItem(error, disabled /* , defaultValue */) {
44
+ return <TextField
45
+ variant="standard"
46
+ fullWidth
47
+ inputProps={{ maxLength: this.props.schema.maxLength || this.props.schema.max || undefined }}
48
+ value={this.state.value}
49
+ error={!!error}
50
+ disabled={disabled}
51
+ placeholder={this.getText(this.props.schema.placeholder)}
52
+ label={this.getText(this.props.schema.label)}
53
+ helperText={this.renderHelp(this.props.schema.help, this.props.schema.helpLink, this.props.schema.noTranslation)}
54
+ onChange={e => {
55
+ const value = e.target.value;
56
+ this.setState({ value }, () =>
57
+ this.onChange(this.props.attr, value));
58
+ }}
59
+ />;
60
+ }
61
+ }
62
+
63
+ ConfigTopic.propTypes = {
64
+ socket: PropTypes.object.isRequired,
65
+ themeType: PropTypes.string,
66
+ themeName: PropTypes.string,
67
+ style: PropTypes.object,
68
+ className: PropTypes.string,
69
+ data: PropTypes.object.isRequired,
70
+ schema: PropTypes.object,
71
+ onError: PropTypes.func,
72
+ onChange: PropTypes.func,
73
+ adapterName: PropTypes.string,
74
+ instance: PropTypes.number,
75
+ customObj: PropTypes.object,
76
+ };
77
+
78
+ export default withStyles(styles)(ConfigTopic);
@@ -0,0 +1,55 @@
1
+ import React from 'react';
2
+
3
+ import {
4
+ TextField,
5
+ IconButton,
6
+ } from '@mui/material';
7
+
8
+ import { ContentCopy as IconCopy } from '@mui/icons-material';
9
+
10
+ import { Utils, I18n } from '@iobroker/adapter-react-v5';
11
+
12
+ import type { ConfigItemUUID } from '#JC/types';
13
+ import ConfigGeneric, {type ConfigGenericProps, type ConfigGenericState} from './ConfigGeneric';
14
+
15
+ interface ConfigUUIDProps extends ConfigGenericProps {
16
+ schema: ConfigItemUUID;
17
+ }
18
+
19
+ interface ConfigUUIDState extends ConfigGenericState {
20
+ uuid?: string;
21
+ }
22
+
23
+ class ConfigUUID extends ConfigGeneric<ConfigUUIDProps, ConfigUUIDState> {
24
+ async componentDidMount() {
25
+ super.componentDidMount();
26
+
27
+ const uuidObj = await this.props.socket.getObject('system.meta.uuid');
28
+ this.setState({ uuid: uuidObj?.native?.uuid || 'unknown' });
29
+ }
30
+
31
+ renderItem(error: unknown, disabled: boolean) {
32
+ return <TextField
33
+ variant="standard"
34
+ fullWidth
35
+ error={!!error}
36
+ disabled={!!disabled}
37
+ inputProps={{ readOnly: true }}
38
+ // eslint-disable-next-line react/jsx-no-duplicate-props
39
+ InputProps={{
40
+ endAdornment: <IconButton onClick={() => {
41
+ Utils.copyToClipboard(this.state.uuid);
42
+ window.alert(I18n.t('ra_Copied %s', this.state.uuid));
43
+ }}
44
+ >
45
+ <IconCopy />
46
+ </IconButton>,
47
+ }}
48
+ value={this.state.uuid || ''}
49
+ label={this.getText(this.props.schema.label) || I18n.t('ra_Serial number (UUID)')}
50
+ helperText={this.renderHelp(this.props.schema.help, this.props.schema.helpLink, this.props.schema.noTranslation)}
51
+ />;
52
+ }
53
+ }
54
+
55
+ export default ConfigUUID;