@iobroker/adapter-react-v5 5.0.7 → 6.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (54) hide show
  1. package/Components/404.d.ts +2 -5
  2. package/Components/404.js +10 -10
  3. package/Components/ColorPicker.d.ts +41 -4
  4. package/Components/ColorPicker.js +35 -32
  5. package/Components/ComplexCron.d.ts +35 -4
  6. package/Components/ComplexCron.js +14 -15
  7. package/Components/CustomModal.d.ts +2 -3
  8. package/Components/CustomModal.js +15 -16
  9. package/Components/FileBrowser.d.ts +116 -4
  10. package/Components/FileBrowser.js +160 -164
  11. package/Components/FileViewer.js +10 -8
  12. package/Components/Icon.d.ts +1 -0
  13. package/Components/Icon.js +11 -4
  14. package/Components/IconPicker.d.ts +5 -1
  15. package/Components/IconPicker.js +47 -49
  16. package/Components/ObjectBrowser.d.ts +12 -15
  17. package/Components/ObjectBrowser.js +362 -326
  18. package/Components/SaveCloseButtons.d.ts +6 -3
  19. package/Components/SaveCloseButtons.js +4 -5
  20. package/Components/Schedule.d.ts +60 -3
  21. package/Components/Schedule.js +112 -117
  22. package/Components/SelectWithIcon.d.ts +17 -4
  23. package/Components/SelectWithIcon.js +11 -7
  24. package/Components/SimpleCron/index.d.ts +19 -3
  25. package/Components/SimpleCron/index.js +8 -9
  26. package/Components/TabContainer.d.ts +3 -4
  27. package/Components/TabContainer.js +3 -7
  28. package/Components/TabContent.d.ts +2 -3
  29. package/Components/TabContent.js +2 -4
  30. package/Components/TableResize.d.ts +26 -3
  31. package/Components/TableResize.js +1 -39
  32. package/Components/TextWithIcon.d.ts +4 -4
  33. package/Components/TextWithIcon.js +6 -7
  34. package/Components/TreeTable.d.ts +40 -5
  35. package/Components/TreeTable.js +39 -37
  36. package/Components/UploadImage.d.ts +13 -4
  37. package/Components/UploadImage.js +11 -13
  38. package/Components/Utils.d.ts +2 -1
  39. package/Components/Utils.js +31 -0
  40. package/Dialogs/ComplexCron.d.ts +11 -3
  41. package/Dialogs/ComplexCron.js +2 -3
  42. package/Dialogs/Confirm.d.ts +20 -7
  43. package/Dialogs/Confirm.js +4 -15
  44. package/Dialogs/Cron.d.ts +12 -3
  45. package/Dialogs/Cron.js +3 -11
  46. package/Dialogs/SelectFile.d.ts +12 -3
  47. package/Dialogs/SelectFile.js +8 -9
  48. package/Dialogs/SelectID.d.ts +1 -1
  49. package/Dialogs/SelectID.js +1 -1
  50. package/Dialogs/SimpleCron.d.ts +10 -3
  51. package/Dialogs/SimpleCron.js +2 -10
  52. package/README.md +74 -1
  53. package/modulefederation.admin.config.js +2 -0
  54. package/package.json +6 -7
@@ -30,7 +30,6 @@ exports.EXTENSIONS = void 0;
30
30
  // File viewer in adapter-react does not support write
31
31
  // import { Buffer } from 'buffer';
32
32
  const react_1 = __importStar(require("react"));
33
- const styles_1 = require("@mui/styles");
34
33
  const material_1 = require("@mui/material");
35
34
  // Icons
36
35
  const fa_1 = require("react-icons/fa");
@@ -218,12 +217,12 @@ class FileViewer extends react_1.Component {
218
217
  getContent() {
219
218
  if (this.state.ext && exports.EXTENSIONS.images.includes(this.state.ext)) {
220
219
  if (this.state.imgError) {
221
- return react_1.default.createElement(IconNoIcon_1.default, { className: Utils_1.default.clsx(this.props.classes.img, this.props.getClassBackgroundImage()) });
220
+ return react_1.default.createElement(IconNoIcon_1.default, { style: Object.assign(Object.assign({}, styles.img), this.props.getStyleBackgroundImage()) });
222
221
  }
223
222
  return react_1.default.createElement(Icon_1.default, { onError: e => {
224
223
  e.target.onerror = null;
225
224
  this.setState({ imgError: true });
226
- }, className: Utils_1.default.clsx(this.props.classes.img, this.props.getClassBackgroundImage()), src: `${this.props.href}?ts=${this.state.forceUpdate}`, alt: this.props.href });
225
+ }, style: Object.assign(Object.assign({}, styles.img), this.props.getStyleBackgroundImage()), src: `${this.props.href}?ts=${this.state.forceUpdate}`, alt: this.props.href });
227
226
  }
228
227
  if (this.state.code !== null || this.state.text !== null || this.state.editing) {
229
228
  // File viewer in adapter-react does not support write
@@ -233,20 +232,23 @@ class FileViewer extends react_1.Component {
233
232
  // value={this.state.editingValue || this.state.code || this.state.text}
234
233
  // onChange={this.state.editing ? newValue => this.setState({ editingValue: newValue, changed: true }) : undefined}
235
234
  // />;
236
- return react_1.default.createElement(material_1.TextField, { variant: "standard", className: this.props.classes.textarea, multiline: true, value: this.state.editingValue || this.state.code || this.state.text,
235
+ return react_1.default.createElement(material_1.TextField, { variant: "standard", style: styles.textarea, multiline: true, value: this.state.editingValue || this.state.code || this.state.text,
237
236
  // onChange={newValue => this.setState({ editingValue: newValue, changed: true })}
238
237
  InputProps: { readOnly: !this.state.editing } });
239
238
  }
240
239
  return null;
241
240
  }
242
241
  render() {
243
- return react_1.default.createElement(material_1.Dialog, { classes: { scrollPaper: this.props.classes.dialog, paper: this.props.classes.paper }, scroll: "paper", open: !!this.props.href, onClose: () => this.props.onClose(), fullWidth: true, maxWidth: "xl", "aria-labelledby": "ar_dialog_file_view_title" },
244
- react_1.default.createElement("div", { className: this.props.classes.dialogTitle },
242
+ return react_1.default.createElement(material_1.Dialog, { sx: {
243
+ '&.MuiDialog-scrollPaper': styles.dialog,
244
+ '& .MuiDialog-paper': styles.paper,
245
+ }, scroll: "paper", open: !!this.props.href, onClose: () => this.props.onClose(), fullWidth: true, maxWidth: "xl", "aria-labelledby": "ar_dialog_file_view_title" },
246
+ react_1.default.createElement("div", { style: styles.dialogTitle },
245
247
  react_1.default.createElement(material_1.DialogTitle, { id: "ar_dialog_file_view_title" }, `${this.props.t(this.state.editing ? 'Edit' : 'View')}: ${this.props.href}`),
246
248
  this.state.ext && exports.EXTENSIONS.images.includes(this.state.ext) && react_1.default.createElement("div", null,
247
249
  react_1.default.createElement(material_1.IconButton, { size: "large", color: "inherit", onClick: this.props.setStateBackgroundImage },
248
250
  react_1.default.createElement(icons_material_1.Brightness6, null)))),
249
- react_1.default.createElement(material_1.DialogContent, { className: this.props.classes.content }, this.getContent()),
251
+ react_1.default.createElement(material_1.DialogContent, { style: styles.content }, this.getContent()),
250
252
  react_1.default.createElement(material_1.DialogActions, null,
251
253
  this.state.copyPossible ?
252
254
  react_1.default.createElement(material_1.Button, { color: "grey", onClick: e => {
@@ -259,4 +261,4 @@ class FileViewer extends react_1.Component {
259
261
  react_1.default.createElement(material_1.Button, { variant: "contained", onClick: () => this.props.onClose(), color: "primary", startIcon: react_1.default.createElement(icons_material_1.Close, null) }, this.props.t('Close'))));
260
262
  }
261
263
  }
262
- exports.default = (0, withWidth_1.default)()((0, styles_1.withStyles)(styles)(FileViewer));
264
+ exports.default = (0, withWidth_1.default)()(FileViewer);
@@ -8,6 +8,7 @@ interface IconProps {
8
8
  className?: string;
9
9
  /** Style for image */
10
10
  style?: React.CSSProperties;
11
+ sx?: Record<string, any>;
11
12
  /** Tooltip */
12
13
  title?: string;
13
14
  /** Styles for utf-8 characters */
@@ -9,6 +9,7 @@ const react_inlinesvg_1 = __importDefault(require("react-inlinesvg"));
9
9
  const icons_material_1 = require("@mui/icons-material");
10
10
  const IconAlias_1 = __importDefault(require("../icons/IconAlias"));
11
11
  const Utils_1 = __importDefault(require("./Utils"));
12
+ const material_1 = require("@mui/material");
12
13
  function getSystemIcon(obj) {
13
14
  let icon;
14
15
  const id = obj === null || obj === void 0 ? void 0 : obj._id;
@@ -104,6 +105,9 @@ function Icon(props) {
104
105
  if (typeof props.src === 'string') {
105
106
  if (props.src.length < 3) {
106
107
  // utf-8 char
108
+ if (props.sx) {
109
+ return react_1.default.createElement(material_1.Box, { component: "span", sx: props.sx, title: props.title || undefined, style: Object.assign({ height: 27, marginTop: -8 }, (props.styleUTF8 || props.style)), className: Utils_1.default.clsx(props.className, 'iconOwn') }, props.src);
110
+ }
107
111
  return react_1.default.createElement("span", { title: props.title || undefined, style: Object.assign({ height: 27, marginTop: -8 }, (props.styleUTF8 || props.style)), className: Utils_1.default.clsx(props.className, 'iconOwn') }, props.src);
108
112
  }
109
113
  if (props.src.startsWith('data:image/svg')) {
@@ -117,10 +121,13 @@ function Icon(props) {
117
121
  else if (!src.startsWith('/')) {
118
122
  src = REMOTE_PREFIX + src;
119
123
  }
120
- return react_1.default.createElement("img", { title: props.title || undefined, style: props.style || {}, className: Utils_1.default.clsx(props.className, 'iconOwn'), src: `https://remote-files.iobroker.in${src}`, alt: props.alt || undefined, ref: props.ref, onError: e => {
121
- // analyse error
122
- props.onError && props.onError(e);
123
- } });
124
+ if (props.sx) {
125
+ return react_1.default.createElement(material_1.Box, { component: "img", sx: props.sx, title: props.title || undefined, style: props.style || {}, className: Utils_1.default.clsx(props.className, 'iconOwn'), src: `https://remote-files.iobroker.in${src}`, alt: props.alt || undefined, ref: props.ref, onError: e => props.onError && props.onError(e) });
126
+ }
127
+ return react_1.default.createElement("img", { title: props.title || undefined, style: props.style || {}, className: Utils_1.default.clsx(props.className, 'iconOwn'), src: `https://remote-files.iobroker.in${src}`, alt: props.alt || undefined, ref: props.ref, onError: e => props.onError && props.onError(e) });
128
+ }
129
+ if (props.sx) {
130
+ return react_1.default.createElement(material_1.Box, { component: "img", sx: props.sx, title: props.title || undefined, style: props.style || {}, className: Utils_1.default.clsx(props.className, 'iconOwn'), src: props.src, alt: props.alt || undefined, ref: props.ref, onError: props.onError });
124
131
  }
125
132
  return react_1.default.createElement("img", { title: props.title || undefined, style: props.style || {}, className: Utils_1.default.clsx(props.className, 'iconOwn'), src: props.src, alt: props.alt || undefined, ref: props.ref, onError: props.onError });
126
133
  }
@@ -1,8 +1,12 @@
1
1
  import React from 'react';
2
2
  interface IconPickerProps {
3
+ previewStyle?: React.CSSProperties;
3
4
  previewClassName?: string;
4
5
  /** Custom icon element. */
5
- icon?: React.ComponentType<any>;
6
+ icon?: React.FC<{
7
+ style?: React.CSSProperties;
8
+ }>;
9
+ customStyles?: Record<string, React.CSSProperties>;
6
10
  customClasses?: Record<string, string>;
7
11
  /** The label. */
8
12
  label?: string;
@@ -28,53 +28,51 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
28
28
  Object.defineProperty(exports, "__esModule", { value: true });
29
29
  const react_1 = __importStar(require("react"));
30
30
  const react_dropzone_1 = require("react-dropzone");
31
- const styles_1 = require("@mui/styles");
32
31
  const material_1 = require("@mui/material");
33
32
  const icons_material_1 = require("@mui/icons-material");
34
33
  const IconSelector_1 = __importDefault(require("./IconSelector"));
35
34
  const Icon_1 = __importDefault(require("./Icon"));
36
35
  const i18n_1 = __importDefault(require("../i18n"));
37
36
  const Utils_1 = __importDefault(require("./Utils"));
37
+ const styles = {
38
+ formContainer: {
39
+ display: 'flex',
40
+ justifyContent: 'left',
41
+ alignItems: 'center',
42
+ },
43
+ formControl: {
44
+ display: 'flex',
45
+ padding: 24,
46
+ flexGrow: 1000,
47
+ },
48
+ divContainer: {
49
+ width: 32 + 24,
50
+ height: 32,
51
+ whiteSpace: 'nowrap',
52
+ lineHeight: '32px',
53
+ marginRight: 8,
54
+ },
55
+ dragField: {
56
+ textAlign: 'center',
57
+ display: 'table',
58
+ minHeight: 90,
59
+ width: 'calc(100% - 60px)',
60
+ border: '2px dashed #777',
61
+ borderRadius: 10,
62
+ padding: 4,
63
+ },
64
+ formIcon: {
65
+ margin: 10,
66
+ opacity: 0.6,
67
+ },
68
+ text: {
69
+ display: 'table-cell',
70
+ verticalAlign: 'middle',
71
+ },
72
+ };
38
73
  const IconPicker = (props) => {
39
- var _a, _b;
74
+ var _a, _b, _c, _d;
40
75
  const IconCustom = props.icon;
41
- const useStyles = (0, styles_1.makeStyles)(() => ({
42
- formContainer: {
43
- display: 'flex',
44
- justifyContent: 'left',
45
- alignItems: 'center',
46
- },
47
- formControl: {
48
- display: 'flex',
49
- padding: 24,
50
- flexGrow: 1000,
51
- },
52
- divContainer: {
53
- width: 32 + 24,
54
- height: 32,
55
- whiteSpace: 'nowrap',
56
- lineHeight: '32px',
57
- marginRight: 8,
58
- },
59
- dragField: {
60
- textAlign: 'center',
61
- display: 'table',
62
- minHeight: 90,
63
- width: 'calc(100% - 60px)',
64
- border: '2px dashed #777',
65
- borderRadius: 10,
66
- padding: 4,
67
- },
68
- formIcon: {
69
- margin: 10,
70
- opacity: 0.6,
71
- },
72
- text: {
73
- display: 'table-cell',
74
- verticalAlign: 'middle',
75
- },
76
- }));
77
- const classes = useStyles();
78
76
  const onDrop = (0, react_1.useCallback)((acceptedFiles) => {
79
77
  const reader = new FileReader();
80
78
  reader.addEventListener('load', () => props.onChange(reader.result), false);
@@ -83,22 +81,22 @@ const IconPicker = (props) => {
83
81
  }
84
82
  }, []); // eslint-disable-line react-hooks/exhaustive-deps
85
83
  const { getRootProps, getInputProps, isDragActive } = (0, react_dropzone_1.useDropzone)({ onDrop });
86
- return react_1.default.createElement("div", { className: classes.formContainer },
87
- IconCustom ? react_1.default.createElement(IconCustom, { className: classes.formIcon }) : null,
88
- react_1.default.createElement(material_1.FormControl, { variant: "standard", className: classes.formControl, style: { padding: 3 } },
89
- react_1.default.createElement(material_1.InputLabel, { shrink: true, classes: { root: (_a = props.customClasses) === null || _a === void 0 ? void 0 : _a.label } }, props.label),
90
- react_1.default.createElement("div", { className: classes.formContainer },
84
+ return react_1.default.createElement("div", { style: styles.formContainer },
85
+ IconCustom ? react_1.default.createElement(IconCustom, { style: styles.formIcon }) : null,
86
+ react_1.default.createElement(material_1.FormControl, { variant: "standard", style: Object.assign(Object.assign({}, styles.formControl), { padding: 3 }) },
87
+ react_1.default.createElement(material_1.InputLabel, { shrink: true, sx: ((_a = props.customStyles) === null || _a === void 0 ? void 0 : _a.label) ? { '&.MuiInputLabel-root': props.customStyles.label } : undefined, classes: { root: (_b = props.customClasses) === null || _b === void 0 ? void 0 : _b.label } }, props.label),
88
+ react_1.default.createElement("div", { style: styles.formContainer },
91
89
  props.value ?
92
- react_1.default.createElement("div", { className: classes.divContainer },
93
- react_1.default.createElement(Icon_1.default, { className: Utils_1.default.clsx(props.previewClassName, (_b = props.customClasses) === null || _b === void 0 ? void 0 : _b.icon), src: props.value }),
90
+ react_1.default.createElement("div", { style: styles.divContainer },
91
+ react_1.default.createElement(Icon_1.default, { style: Object.assign(Object.assign({}, props.previewStyle), (((_c = props.customStyles) === null || _c === void 0 ? void 0 : _c.icon) || undefined)), src: props.value, className: Utils_1.default.clsx(props.previewClassName, (_d = props.customClasses) === null || _d === void 0 ? void 0 : _d.icon) }),
94
92
  !props.disabled && react_1.default.createElement(material_1.IconButton, { style: { verticalAlign: 'top' }, title: i18n_1.default.t('ra_Clear icon'), size: "small", onClick: () => props.onChange('') },
95
93
  react_1.default.createElement(icons_material_1.Clear, null)))
96
94
  :
97
95
  (!props.disabled && react_1.default.createElement(IconSelector_1.default, { icons: props.icons, onlyRooms: props.onlyRooms, onlyDevices: props.onlyDevices, onSelect: (base64) => props.onChange(base64), t: i18n_1.default.t, lang: i18n_1.default.getLanguage() })),
98
- !props.disabled && react_1.default.createElement("div", Object.assign({}, getRootProps(), { className: classes.dragField, style: isDragActive ? { backgroundColor: 'rgba(0, 255, 0, 0.1)' } : { cursor: 'pointer' } }),
96
+ !props.disabled && react_1.default.createElement("div", Object.assign({}, getRootProps(), { style: Object.assign({}, styles.dragField, isDragActive ? { backgroundColor: 'rgba(0, 255, 0, 0.1)' } : { cursor: 'pointer' }) }),
99
97
  react_1.default.createElement("input", Object.assign({}, getInputProps())),
100
98
  isDragActive ?
101
- react_1.default.createElement("span", { className: classes.text }, i18n_1.default.t('ra_Drop the files here...')) :
102
- react_1.default.createElement("span", { className: classes.text }, i18n_1.default.t('ra_Drag \'n\' drop some files here, or click to select files'))))));
99
+ react_1.default.createElement("span", { style: styles.text }, i18n_1.default.t('ra_Drop the files here...')) :
100
+ react_1.default.createElement("span", { style: styles.text }, i18n_1.default.t('ra_Drag \'n\' drop some files here, or click to select files'))))));
103
101
  };
104
102
  exports.default = IconPicker;
@@ -8,11 +8,6 @@ import React, { Component } from 'react';
8
8
  import type Router from './Router';
9
9
  import type { ThemeType, ThemeName, IobTheme, Translate } from '../types';
10
10
  import Connection from '../Connection';
11
- declare module '@mui/material/Button' {
12
- interface ButtonPropsColorOverrides {
13
- grey: true;
14
- }
15
- }
16
11
  declare global {
17
12
  interface Window {
18
13
  sparkline: {
@@ -20,6 +15,11 @@ declare global {
20
15
  };
21
16
  }
22
17
  }
18
+ declare module '@mui/material/Button' {
19
+ interface ButtonPropsColorOverrides {
20
+ grey: true;
21
+ }
22
+ }
23
23
  type ObjectEventType = 'new' | 'changed' | 'deleted';
24
24
  interface ObjectEvent {
25
25
  id: string;
@@ -119,7 +119,6 @@ interface AdapterColumn {
119
119
  align?: 'center' | 'left' | 'right';
120
120
  }
121
121
  interface ObjectBrowserEditRoleProps {
122
- classes: Record<string, string>;
123
122
  roles: string[];
124
123
  id: string;
125
124
  socket: Connection;
@@ -134,7 +133,8 @@ interface ObjectViewFileDialogProps {
134
133
  }
135
134
  interface DragWrapperProps {
136
135
  item: TreeItem;
137
- className: string;
136
+ className?: string;
137
+ style?: React.CSSProperties;
138
138
  children: React.JSX.Element | null;
139
139
  }
140
140
  interface ObjectCustomDialogProps {
@@ -151,13 +151,10 @@ interface ObjectCustomDialogProps {
151
151
  onClose: () => void;
152
152
  reportChangedIds: (ids: string[]) => void;
153
153
  isFloatComma: boolean;
154
- classes: Record<string, string>;
155
154
  allVisibleObjects: boolean;
156
155
  systemConfig: ioBroker.SystemConfigObject;
157
156
  }
158
157
  interface ObjectBrowserValueProps {
159
- /** Css classes */
160
- classes: Record<string, string>;
161
158
  /** State type */
162
159
  type: 'states' | 'string' | 'number' | 'boolean' | 'json';
163
160
  /** State role */
@@ -185,7 +182,6 @@ interface ObjectBrowserValueProps {
185
182
  lang: ioBroker.Languages;
186
183
  }
187
184
  interface ObjectBrowserEditObjectProps {
188
- classes: Record<string, string>;
189
185
  socket: Connection;
190
186
  obj: ioBroker.AnyObject;
191
187
  roleArray: string[];
@@ -211,7 +207,6 @@ interface ObjectAliasEditorProps {
211
207
  interface ObjectBrowserProps {
212
208
  /** where to store settings in localStorage */
213
209
  dialogName?: string;
214
- classes: Record<string, string>;
215
210
  defaultFilters?: ObjectBrowserFilter;
216
211
  selected?: string | string[];
217
212
  onSelect?: (selected: string | string[], name: string, isDouble?: boolean) => void;
@@ -373,6 +368,7 @@ export declare class ObjectBrowserClass extends Component<ObjectBrowserProps, Ob
373
368
  private readonly possibleCols;
374
369
  private readonly imagePrefix;
375
370
  private adapterColumns;
371
+ private styleTheme;
376
372
  private edit;
377
373
  private readonly levelPadding;
378
374
  private customWidth;
@@ -396,6 +392,7 @@ export declare class ObjectBrowserClass extends Component<ObjectBrowserProps, Ob
396
392
  private changedIds;
397
393
  private contextMenu;
398
394
  private recordStates;
395
+ private styles;
399
396
  private customColumnDialog;
400
397
  constructor(props: ObjectBrowserProps);
401
398
  loadAllObjects(update?: boolean): Promise<void>;
@@ -518,7 +515,7 @@ export declare class ObjectBrowserClass extends Component<ObjectBrowserProps, Ob
518
515
  private toggleExpanded;
519
516
  private onCopy;
520
517
  renderTooltipAccessControl: (acl: ioBroker.StateACL) => null | React.JSX.Element;
521
- renderColumnButtons(id: string, item: TreeItem, classes: Record<string, string>): React.JSX.Element | React.JSX.Element[];
518
+ renderColumnButtons(id: string, item: TreeItem): React.JSX.Element | React.JSX.Element[];
522
519
  private readHistory;
523
520
  private getTooltipInfo;
524
521
  private renderColumnValue;
@@ -537,13 +534,13 @@ export declare class ObjectBrowserClass extends Component<ObjectBrowserProps, Ob
537
534
  /**
538
535
  * Renders a leaf.
539
536
  */
540
- renderLeaf(item: TreeItem, isExpanded: boolean | undefined, classes: Record<string, string>, counter: {
537
+ renderLeaf(item: TreeItem, isExpanded: boolean | undefined, counter: {
541
538
  count: number;
542
539
  }): React.JSX.Element;
543
540
  /**
544
541
  * Renders an item.
545
542
  */
546
- renderItem(root: TreeItem, isExpanded: boolean | undefined, classes: Record<string, string>, counter?: {
543
+ renderItem(root: TreeItem, isExpanded: boolean | undefined, counter?: {
547
544
  count: number;
548
545
  }): React.JSX.Element[];
549
546
  private calculateColumnsVisibility;