@iobroker/adapter-react-v5 6.1.3 → 6.1.5

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 (66) hide show
  1. package/README.md +3 -0
  2. package/craco-module-federation.js +1 -1
  3. package/package.json +1 -1
  4. package/src/AdminConnection.tsx +3 -0
  5. package/src/Components/404.tsx +121 -0
  6. package/src/Components/ColorPicker.tsx +315 -0
  7. package/src/Components/ComplexCron.tsx +507 -0
  8. package/src/Components/CopyToClipboard.tsx +165 -0
  9. package/src/Components/CustomModal.tsx +163 -0
  10. package/src/Components/FileBrowser.tsx +2394 -0
  11. package/src/Components/FileViewer.tsx +384 -0
  12. package/src/Components/Icon.tsx +210 -0
  13. package/src/Components/IconPicker.tsx +149 -0
  14. package/src/Components/IconSelector.tsx +2202 -0
  15. package/src/Components/Image.tsx +176 -0
  16. package/src/Components/Loader.tsx +304 -0
  17. package/src/Components/Logo.tsx +166 -0
  18. package/src/Components/MDUtils.tsx +100 -0
  19. package/src/Components/ObjectBrowser.tsx +7915 -0
  20. package/src/Components/Router.tsx +90 -0
  21. package/src/Components/SaveCloseButtons.tsx +113 -0
  22. package/src/Components/Schedule.tsx +1724 -0
  23. package/src/Components/SelectWithIcon.tsx +197 -0
  24. package/src/Components/TabContainer.tsx +55 -0
  25. package/src/Components/TabContent.tsx +37 -0
  26. package/src/Components/TabHeader.tsx +19 -0
  27. package/src/Components/TableResize.tsx +259 -0
  28. package/src/Components/TextWithIcon.tsx +148 -0
  29. package/src/Components/ToggleThemeMenu.tsx +34 -0
  30. package/src/Components/TreeTable.tsx +919 -0
  31. package/src/Components/UploadImage.tsx +599 -0
  32. package/src/Components/Utils.tsx +1794 -0
  33. package/src/Components/loader.css +222 -0
  34. package/src/Components/withWidth.tsx +21 -0
  35. package/src/Connection.tsx +7 -0
  36. package/src/Dialogs/ComplexCron.tsx +129 -0
  37. package/src/Dialogs/Confirm.tsx +162 -0
  38. package/src/Dialogs/Cron.tsx +182 -0
  39. package/src/Dialogs/Error.tsx +72 -0
  40. package/src/Dialogs/Message.tsx +71 -0
  41. package/src/Dialogs/SelectFile.tsx +270 -0
  42. package/src/Dialogs/SelectID.tsx +298 -0
  43. package/src/Dialogs/SimpleCron.tsx +100 -0
  44. package/src/Dialogs/TextInput.tsx +107 -0
  45. package/src/GenericApp.tsx +976 -0
  46. package/src/LegacyConnection.tsx +3589 -0
  47. package/src/Prompt.tsx +20 -0
  48. package/src/Theme.tsx +479 -0
  49. package/src/icons/IconAdapter.tsx +20 -0
  50. package/src/icons/IconAlias.tsx +20 -0
  51. package/src/icons/IconChannel.tsx +21 -0
  52. package/src/icons/IconClearFilter.tsx +22 -0
  53. package/src/icons/IconClosed.tsx +17 -0
  54. package/src/icons/IconCopy.tsx +16 -0
  55. package/src/icons/IconDevice.tsx +27 -0
  56. package/src/icons/IconDocument.tsx +17 -0
  57. package/src/icons/IconDocumentReadOnly.tsx +18 -0
  58. package/src/icons/IconExpert.tsx +18 -0
  59. package/src/icons/IconFx.tsx +36 -0
  60. package/src/icons/IconInstance.tsx +20 -0
  61. package/src/icons/IconLogout.tsx +30 -0
  62. package/src/icons/IconNoIcon.tsx +19 -0
  63. package/src/icons/IconOpen.tsx +17 -0
  64. package/src/icons/IconProps.tsx +15 -0
  65. package/src/icons/IconState.tsx +17 -0
  66. package/src/index.css +55 -0
@@ -0,0 +1,222 @@
1
+ /**
2
+ * Copyright 2018-2023 Denis Haev (bluefox) <dogafox@gmail.com>
3
+ *
4
+ * MIT License
5
+ *
6
+ **/
7
+
8
+ .logo-background-light, .logo-background-colored {
9
+ background: white;
10
+ }
11
+ .logo-background-dark, .logo-background-blue {
12
+ background: black;
13
+ }
14
+ .logo-div {
15
+ position: absolute;
16
+ top: 50%;
17
+ left: 50%;
18
+ -ms-transform: translateX(-50%) translateY(-50%);
19
+ -webkit-transform: translate(-50%,-50%);
20
+ transform: translate(-50%,-50%);
21
+ overflow: hidden;
22
+ border-radius: 50%;
23
+ z-index: 2;
24
+ }
25
+ .logo-border {
26
+ /*border-color: #164477;*/
27
+ border-top-color: #3399CC;
28
+ border-left-color: #164477;
29
+ border-bottom-color: #164477;
30
+ border-right-color: #164477;
31
+ border-radius: 50%;
32
+ border-style: solid;
33
+ box-sizing: border-box;
34
+ width: 100%;
35
+ height: 100%;
36
+ position: absolute;
37
+ }
38
+ .logo-top {
39
+ position: absolute;
40
+ width: 4.5%;
41
+ height: 16%;
42
+ top: 0;
43
+ z-index: 2;
44
+ }
45
+ .logo-i {
46
+ position: absolute;
47
+ width: 14.5%;
48
+ height: 60%;
49
+ top: 20%;
50
+ left: 42%;
51
+ background: #3399CC;
52
+ }
53
+ .logo-i-top {
54
+ position: absolute;
55
+ width: 14.5%;
56
+ height: 4%;
57
+ left: 42%;
58
+ background: #3399CC;
59
+ border-radius: 100%;
60
+ }
61
+ .logo-back {
62
+ width: 100%;
63
+ height: 100%;
64
+ z-index: 0;
65
+ overflow: hidden;
66
+ }
67
+ @keyframes logo-grow {
68
+ 0% {
69
+ width: 230px;
70
+ height: 230px;
71
+ transform: translate(-50%,-50%) scale(1);
72
+ opacity: 1
73
+ }
74
+ 99% {
75
+ width: 230px;
76
+ height: 230px;
77
+ transform: translate(-50%,-50%) scale(10);
78
+ opacity: 0;
79
+ }
80
+ 100% {
81
+ width: 0;
82
+ height: 0;
83
+ opacity: 0;
84
+ }
85
+ }
86
+ @keyframes logo-spin { 100% { -webkit-transform: rotate(360deg); transform: rotate(360deg); } }
87
+ @keyframes logo-color-inside-light {
88
+ 0% {
89
+ background: #FEFEFE;
90
+ }
91
+ 100% {
92
+ background: #3399CC;
93
+ }
94
+ }
95
+ @keyframes logo-color-inside-dark {
96
+ 0% {
97
+ background: #030303;
98
+ }
99
+ 100% {
100
+ background: #3399CC;
101
+ }
102
+ }
103
+ @keyframes logo-color-inside-colored {
104
+ 0% {
105
+ background: #FEFEFE;
106
+ }
107
+ 100% {
108
+ background: #3399CC;
109
+ }
110
+ }
111
+ @keyframes logo-color-inside-blue {
112
+ 0% {
113
+ background: #030303;
114
+ }
115
+ 100% {
116
+ background: #3399CC;
117
+ }
118
+ }
119
+
120
+ @keyframes logo-color-outside-light {
121
+ 0% {
122
+ border-color: #FEFEFE;
123
+ }
124
+ 100% {
125
+ border-top-color: #3399CC;
126
+ border-left-color: #164477;
127
+ border-bottom-color: #164477;
128
+ border-right-color: #164477;
129
+ }
130
+ }
131
+ @keyframes logo-color-outside-dark {
132
+ 0% {
133
+ border-color: #040404;
134
+ }
135
+ 100% {
136
+ border-top-color: #3399CC;
137
+ border-left-color: #164477;
138
+ border-bottom-color: #164477;
139
+ border-right-color: #164477;
140
+ }
141
+ }
142
+ @keyframes logo-color-outside-colored {
143
+ 0% {
144
+ border-color: #FEFEFE;
145
+ }
146
+ 100% {
147
+ border-top-color: #3399CC;
148
+ border-left-color: #164477;
149
+ border-bottom-color: #164477;
150
+ border-right-color: #164477;
151
+ }
152
+ }
153
+ @keyframes logo-color-outside-blue {
154
+ 0% {
155
+ border-color: #040404;
156
+ }
157
+ 100% {
158
+ border-top-color: #3399CC;
159
+ border-left-color: #164477;
160
+ border-bottom-color: #164477;
161
+ border-right-color: #164477;
162
+ }
163
+ }
164
+
165
+ .logo-animate-wait {
166
+ animation: logo-color-outside 1.5s, logo-spin 1.5s linear infinite;
167
+ }
168
+
169
+ .logo-animate-grow-light {
170
+ background: #DDD;
171
+ }
172
+ .logo-animate-grow-dark {
173
+ background: #1d1d1d;
174
+ }
175
+ .logo-animate-grow-colored {
176
+ background: #DDD;
177
+ }
178
+ .logo-animate-grow-blue {
179
+ background: #1d1d1d;
180
+ }
181
+
182
+ .logo-animate-grow {
183
+ display: inline-block;
184
+ text-align: center;
185
+ z-index: 1;
186
+ top: 50%;
187
+ left: 50%;
188
+ -ms-transform: translateX(-50%) translateY(-50%);
189
+ -webkit-transform: translate(-50%,-50%);
190
+ transform: translate(-50%,-50%);
191
+ width: 245px;
192
+ height: 245px;
193
+ border-radius: 50%;
194
+ position: absolute;
195
+ animation: logo-grow 1s 1 ease forwards;
196
+ }
197
+
198
+ .logo-animate-color-inside-light {
199
+ animation: logo-color-inside-light 2.5s;
200
+ }
201
+ .logo-animate-color-inside-dark {
202
+ animation: logo-color-inside-dark 2.5s;
203
+ }
204
+ .logo-animate-color-inside-colored {
205
+ animation: logo-color-inside-colored 2.5s;
206
+ }
207
+ .logo-animate-color-inside-blue {
208
+ animation: logo-color-inside-blue 2.5s;
209
+ }
210
+
211
+ .logo-animate-color-outside-light {
212
+ animation: logo-color-outside-light 1.5s;
213
+ }
214
+ .logo-animate-color-outside-dark {
215
+ animation: logo-color-outside-dark 1.5s;
216
+ }
217
+ .logo-animate-color-outside-colored {
218
+ animation: logo-color-outside-colored 1.5s;
219
+ }
220
+ .logo-animate-color-outside-blue {
221
+ animation: logo-color-outside-blue 1.5s;
222
+ }
@@ -0,0 +1,21 @@
1
+ import React, { JSXElementConstructor } from 'react';
2
+ import { useTheme } from '@mui/material/styles';
3
+ import { Breakpoint, useMediaQuery } from '@mui/material';
4
+
5
+ function useWidth() {
6
+ const theme = useTheme();
7
+ const keys = [...theme.breakpoints.keys].reverse();
8
+ return keys.reduce((output: Breakpoint | null, key: Breakpoint) => {
9
+ // eslint-disable-next-line react-hooks/rules-of-hooks
10
+ const matches = useMediaQuery(theme.breakpoints.up(key));
11
+ return !output && matches ? key : output;
12
+ }, null) || 'xs';
13
+ }
14
+
15
+ // FIXME checkout https://mui.com/components/use-media-query/#migrating-from-withwidth
16
+ const withWidth = () => (WrappedComponent: JSXElementConstructor<any>) => (props: Record<string, any>) => {
17
+ const width = useWidth();
18
+ return <WrappedComponent {...props} width={width} />;
19
+ };
20
+
21
+ export default withWidth;
@@ -0,0 +1,7 @@
1
+ import {
2
+ Connection, PROGRESS, ERRORS, PERMISSION_ERROR,
3
+ } from '@iobroker/socket-client';
4
+
5
+ export { PROGRESS, ERRORS, PERMISSION_ERROR };
6
+
7
+ export default Connection;
@@ -0,0 +1,129 @@
1
+ import React from 'react';
2
+
3
+ import {
4
+ Button,
5
+ DialogTitle,
6
+ DialogContent,
7
+ DialogActions,
8
+ Dialog,
9
+ } from '@mui/material';
10
+
11
+ import {
12
+ Check as IconOk,
13
+ Cancel as IconCancel,
14
+ Delete as IconClear,
15
+ } from '@mui/icons-material';
16
+
17
+ import ComplexCron from '../Components/ComplexCron';
18
+
19
+ import I18n from '../i18n';
20
+
21
+ // Generate cron expression
22
+ const styles: Record<string, React.CSSProperties> = {
23
+ headerID: {
24
+ fontWeight: 'bold',
25
+ fontStyle: 'italic',
26
+ },
27
+ radio: {
28
+ display: 'inline-block',
29
+ },
30
+ dialogPaper: {
31
+ height: 'calc(100% - 96px)',
32
+ },
33
+ };
34
+
35
+ interface DialogCronProps {
36
+ onClose: () => void;
37
+ onOk: (cron: string | false) => void;
38
+ title?: string;
39
+ cron?: string;
40
+ cancel?: string;
41
+ ok?: string;
42
+ clear?: string;
43
+ clearButton?: boolean;
44
+ }
45
+
46
+ interface DialogCronState {
47
+ cron: string;
48
+ }
49
+
50
+ class DialogComplexCron extends React.Component<DialogCronProps, DialogCronState> {
51
+ constructor(props: DialogCronProps) {
52
+ super(props);
53
+ let cron;
54
+ if (this.props.cron && typeof this.props.cron === 'string' && this.props.cron.replace(/^["']/, '')[0] !== '{') {
55
+ cron = this.props.cron.replace(/['"]/g, '').trim();
56
+ } else {
57
+ cron = this.props.cron || '{}';
58
+ if (typeof cron === 'string') {
59
+ cron = cron.replace(/^["']/, '').replace(/["']\n?$/, '');
60
+ }
61
+ }
62
+
63
+ this.state = {
64
+ cron,
65
+ };
66
+ }
67
+
68
+ handleCancel() {
69
+ this.props.onClose();
70
+ }
71
+
72
+ handleOk() {
73
+ this.props.onOk(this.state.cron);
74
+ this.props.onClose();
75
+ }
76
+
77
+ handleClear() {
78
+ this.props.onOk(false);
79
+ this.props.onClose();
80
+ }
81
+
82
+ render() {
83
+ return <Dialog
84
+ onClose={() => {}}
85
+ maxWidth="md"
86
+ fullWidth
87
+ sx={{ '& .MuiDialog-paper': styles.dialogPaper }}
88
+ open={!0}
89
+ aria-labelledby="cron-dialog-title"
90
+ >
91
+ <DialogTitle id="cron-dialog-title">{this.props.title || I18n.t('ra_Define schedule...')}</DialogTitle>
92
+ <DialogContent style={{ height: '100%', overflow: 'hidden' }}>
93
+ <ComplexCron
94
+ cronExpression={this.state.cron}
95
+ onChange={cron => this.setState({ cron })}
96
+ language={I18n.getLanguage()}
97
+ />
98
+ </DialogContent>
99
+ <DialogActions>
100
+ {!!this.props.clearButton && <Button
101
+ color="grey"
102
+ variant="contained"
103
+ onClick={() => this.handleClear()}
104
+ startIcon={<IconClear />}
105
+ >
106
+ {this.props.clear || I18n.t('ra_Clear')}
107
+ </Button>}
108
+ <Button
109
+ variant="contained"
110
+ onClick={() => this.handleOk()}
111
+ color="primary"
112
+ startIcon={<IconOk />}
113
+ >
114
+ {this.props.ok || I18n.t('ra_Ok')}
115
+ </Button>
116
+ <Button
117
+ color="grey"
118
+ variant="contained"
119
+ onClick={() => this.handleCancel()}
120
+ startIcon={<IconCancel />}
121
+ >
122
+ {this.props.cancel || I18n.t('ra_Cancel')}
123
+ </Button>
124
+ </DialogActions>
125
+ </Dialog>;
126
+ }
127
+ }
128
+
129
+ export default DialogComplexCron;
@@ -0,0 +1,162 @@
1
+ /**
2
+ * Copyright 2019-2023 Denis Haev (bluefox) <dogafox@gmail.com>
3
+ *
4
+ * MIT License
5
+ *
6
+ * */
7
+
8
+ // please do not delete React, as without it other projects could not be compiled: ReferenceError: React is not defined
9
+ import React, { Component } from 'react';
10
+
11
+ import {
12
+ Button,
13
+ Dialog,
14
+ DialogActions,
15
+ DialogContent,
16
+ DialogContentText,
17
+ DialogTitle,
18
+ FormControlLabel,
19
+ Checkbox,
20
+ } from '@mui/material';
21
+
22
+ import {
23
+ Check as IconCheck,
24
+ Close as IconClose,
25
+ } from '@mui/icons-material';
26
+
27
+ import I18n from '../i18n';
28
+
29
+ const styles: Record<string, React.CSSProperties> = {
30
+ suppress: {
31
+ fontSize: 12,
32
+ },
33
+ suppressRoot: {
34
+ // it is sx
35
+ marginTop: '16px',
36
+ },
37
+ };
38
+
39
+ interface DialogConfirmProps {
40
+ /** The dialog title; default: Are you sure? (translated) */
41
+ title?: string;
42
+ /** The dialog text */
43
+ text?: string | React.JSX.Element;
44
+ /** Close handler. */
45
+ onClose?: (ok: boolean) => void;
46
+ /** if the dialog must be fill sized */
47
+ fullWidth?: boolean;
48
+ /** optional icon */
49
+ icon?: React.JSX.Element;
50
+ /** optional ok button text */
51
+ ok?: string;
52
+ /** optional cancel button text */
53
+ cancel?: string;
54
+ /** optional interval in minutes for which the confirmation dialog will be suppressed if activated. */
55
+ suppressQuestionMinutes?: number;
56
+ /** optional text for the suppression checkbox */
57
+ suppressText?: string;
58
+ /** optional name of the dialog. Used only with suppressQuestionMinutes to store the user choice */
59
+ dialogName?: string;
60
+ }
61
+
62
+ interface DialogConfirmState {
63
+ suppress: number | boolean;
64
+ }
65
+
66
+ class DialogConfirm extends Component<DialogConfirmProps, DialogConfirmState> {
67
+ constructor(props: DialogConfirmProps) {
68
+ super(props);
69
+
70
+ if (!this.props.dialogName && this.props.suppressQuestionMinutes) {
71
+ throw new Error('dialogName required if suppressQuestionMinutes used');
72
+ }
73
+ let suppress: number | boolean = false;
74
+
75
+ if (this.props.suppressQuestionMinutes) {
76
+ suppress = parseInt(((window as any)._localStorage || window.localStorage).getItem(this.props.dialogName), 10) || 0;
77
+
78
+ if (!suppress) {
79
+ suppress = false;
80
+ } else if (Date.now() > suppress) {
81
+ ((window as any)._localStorage || window.localStorage).removeItem(this.props.dialogName);
82
+ suppress = false;
83
+ }
84
+ }
85
+
86
+ this.state = {
87
+ suppress,
88
+ };
89
+ }
90
+
91
+ handleOk() {
92
+ if (this.state.suppress) {
93
+ ((window as any)._localStorage || window.localStorage).setItem(this.props.dialogName, Date.now() + (this.props.suppressQuestionMinutes || 2) * 60000);
94
+ }
95
+ this.props.onClose && this.props.onClose(true);
96
+ }
97
+
98
+ handleCancel() {
99
+ this.props.onClose && this.props.onClose(false);
100
+ }
101
+
102
+ render() {
103
+ if (typeof this.state.suppress === 'number') {
104
+ setTimeout(() => this.props.onClose && this.props.onClose(true), 100);
105
+ return null;
106
+ }
107
+
108
+ return <Dialog
109
+ open={!0}
110
+ maxWidth="md"
111
+ fullWidth={this.props.fullWidth !== undefined ? this.props.fullWidth : true}
112
+ onClose={(event, reason) => {
113
+ if (reason !== 'backdropClick' && reason !== 'escapeKeyDown') {
114
+ this.handleCancel();
115
+ }
116
+ }}
117
+ aria-labelledby="ar_confirmation_dialog_title"
118
+ aria-describedby="ar_confirmation_dialog_description"
119
+ >
120
+ <DialogTitle id="ar_confirmation_dialog_title">{this.props.title || I18n.t('ra_Are you sure?')}</DialogTitle>
121
+ <DialogContent>
122
+ <DialogContentText id="ar_confirmation_dialog_description">
123
+ {this.props.icon || null}
124
+ {this.props.text}
125
+ {this.props.suppressQuestionMinutes ? <br /> : null}
126
+ {this.props.suppressQuestionMinutes ? <FormControlLabel
127
+ sx={{ '& .FormControlLabel-label': styles.suppress, '&.FormControlLabel-root': styles.suppressRoot }}
128
+ control={<Checkbox
129
+ id={`ar_dialog_confirm_suppress_${this.props.dialogName || ''}`}
130
+ checked={!!this.state.suppress}
131
+ onChange={() => this.setState({ suppress: !this.state.suppress })}
132
+ />}
133
+ label={this.props.suppressText || I18n.t('ra_Suppress question for next %s minutes', (this.props.suppressQuestionMinutes || 2).toString())}
134
+ /> : null}
135
+ </DialogContentText>
136
+ </DialogContent>
137
+ <DialogActions>
138
+ <Button
139
+ id={`ar_dialog_confirm_ok_${this.props.dialogName || ''}`}
140
+ variant="contained"
141
+ onClick={() => this.handleOk()}
142
+ color="primary"
143
+ autoFocus
144
+ startIcon={<IconCheck />}
145
+ >
146
+ {this.props.ok || I18n.t('ra_Ok')}
147
+ </Button>
148
+ <Button
149
+ id={`ar_dialog_confirm_cancel_${this.props.dialogName || ''}`}
150
+ variant="contained"
151
+ onClick={() => this.handleCancel()}
152
+ color="grey"
153
+ startIcon={<IconClose />}
154
+ >
155
+ {this.props.cancel || I18n.t('ra_Cancel')}
156
+ </Button>
157
+ </DialogActions>
158
+ </Dialog>;
159
+ }
160
+ }
161
+
162
+ export default DialogConfirm;