@iobroker/adapter-react-v5 6.1.3 → 6.1.6

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 (74) hide show
  1. package/README.md +6 -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
  67. package/assets/devices/list.json +0 -994
  68. package/assets/devices/names.txt +0 -63
  69. package/assets/devices/parseNames.d.ts +0 -0
  70. package/assets/devices/parseNames.js +0 -34
  71. package/assets/rooms/list.json +0 -946
  72. package/assets/rooms/names.txt +0 -60
  73. package/assets/rooms/parseNames.d.ts +0 -0
  74. package/assets/rooms/parseNames.js +0 -34
@@ -0,0 +1,148 @@
1
+ import React from 'react';
2
+
3
+ import Icon from './Icon';
4
+ import Utils from './Utils';
5
+ import { ThemeType } from '../types';
6
+
7
+ const styles: Record<string, React.CSSProperties> = {
8
+ div: {
9
+ borderRadius: 3,
10
+ padding: '0 3px',
11
+ lineHeight: '20px',
12
+ whiteSpace: 'nowrap',
13
+ overflow: 'hidden',
14
+ display: 'flex',
15
+ alignItems: 'center',
16
+ },
17
+ icon: {
18
+ width: 16,
19
+ height: 16,
20
+ marginRight: 8,
21
+ verticalAlign: 'middle',
22
+ },
23
+ text: {
24
+ display: 'inline-block',
25
+ overflow: 'hidden',
26
+ textOverflow: 'ellipsis',
27
+ },
28
+ };
29
+
30
+ interface TextWithIconProps {
31
+ lang: ioBroker.Languages;
32
+ themeType?: ThemeType;
33
+ value: string | Record<string, any>;
34
+ list?: ioBroker.Object[] | Record<string, ioBroker.Object>;
35
+ options?: Record<string, any>;
36
+ className?: string;
37
+ style?: React.CSSProperties;
38
+ title?: string;
39
+ removePrefix?: string;
40
+ moreClasses?: {
41
+ root?: string;
42
+ icon?: string;
43
+ text?: string;
44
+ };
45
+ icon?: string;
46
+ color?: string;
47
+ }
48
+
49
+ interface TextWithIconItem {
50
+ name: string;
51
+ value: string;
52
+ icon?: string;
53
+ color?: string;
54
+ }
55
+
56
+ const TextWithIcon = (props: TextWithIconProps) => {
57
+ const value = props.value;
58
+ let item: TextWithIconItem;
59
+ const prefix = props.removePrefix || '';
60
+
61
+ if (typeof value === 'string') {
62
+ const list = props.list || props.options;
63
+ if (list) {
64
+ // if a list is array, then it is list of ioBroker.Object
65
+ if (Array.isArray(list)) {
66
+ const _item: ioBroker.Object = list.find((obj: ioBroker.Object) => obj._id === prefix + value);
67
+ if (_item) {
68
+ item = {
69
+ name: Utils.getObjectNameFromObj(_item, props.lang).replace('system.group.', ''),
70
+ value: _item._id,
71
+ icon: props.icon || _item.common?.icon,
72
+ color: props.color || _item.common?.color,
73
+ };
74
+ } else {
75
+ item = {
76
+ name: value,
77
+ value: prefix + value,
78
+ };
79
+ }
80
+ } else if (list[prefix + value]) {
81
+ // List is object with key-value pairs: {'enum.rooms.1': {common: {name: 'Room 1'}}}
82
+ const obj: ioBroker.Object = list[prefix + value];
83
+ item = {
84
+ name: Utils.getObjectNameFromObj(obj, props.lang).replace('system.group.', ''),
85
+ value: obj._id,
86
+ icon: props.icon || obj.common?.icon,
87
+ color: props.color || obj.common?.color,
88
+ };
89
+ } else {
90
+ // value is a string, ignore list
91
+ item = {
92
+ name: value,
93
+ value: prefix + value,
94
+ icon: props.icon,
95
+ color: props.color,
96
+ };
97
+ }
98
+ } else {
99
+ item = {
100
+ name: value,
101
+ value: prefix + value,
102
+ icon: props.icon,
103
+ color: props.color,
104
+ };
105
+ }
106
+ } else if (!value || typeof value !== 'object') {
107
+ item = {
108
+ name: '',
109
+ value: '',
110
+ icon: props.icon,
111
+ color: props.color,
112
+ };
113
+ } else {
114
+ // Item is an ioBroker.Object
115
+ const obj: ioBroker.Object = value as ioBroker.Object;
116
+ item = {
117
+ name: Utils.getObjectNameFromObj(obj, props.lang)
118
+ .replace('system.group.', '')
119
+ .replace('system.user.', '')
120
+ .replace('enum.rooms.', '')
121
+ .replace('enum.functions.', ''),
122
+ value: obj._id,
123
+ icon: props.icon || obj.common?.icon,
124
+ color: props.color || obj.common?.color,
125
+ };
126
+ }
127
+
128
+ const style = item?.color ? {
129
+ border:`1px solid ${Utils.invertColor(item?.color)}`,
130
+ color: Utils.getInvertedColor(item?.color, props.themeType || 'light', true) || undefined,
131
+ backgroundColor: item?.color,
132
+ } : {};
133
+
134
+ return <div
135
+ style={{ ...(props.style || undefined), ...styles.div, ...(style || undefined) }}
136
+ className={Utils.clsx(props.className, props.moreClasses?.root)}
137
+ title={props.title || item.value}
138
+ >
139
+ {item?.icon ? <Icon
140
+ src={item?.icon}
141
+ className={props.moreClasses?.icon}
142
+ style={styles.icon}
143
+ /> : null}
144
+ <div style={styles.text} className={props.moreClasses?.text}>{item?.name}</div>
145
+ </div>;
146
+ };
147
+
148
+ export default TextWithIcon;
@@ -0,0 +1,34 @@
1
+ import React from 'react';
2
+
3
+ import { IconButton, Tooltip } from '@mui/material';
4
+
5
+ import {
6
+ Brightness4 as Brightness4Icon,
7
+ Brightness5 as Brightness5Icon,
8
+ Brightness6 as Brightness6Icon,
9
+ Brightness7 as Brightness7Icon,
10
+ } from '@mui/icons-material';
11
+
12
+ interface ToggleThemeMenuProps {
13
+ themeName: 'dark' | 'blue' | 'colored' | 'light';
14
+ toggleTheme: () => void;
15
+ t: (key: string) => string;
16
+ className?: string;
17
+ style?: React.CSSProperties;
18
+ size?: 'small' | 'medium' | 'large';
19
+ }
20
+
21
+ export default function ToggleThemeMenu({
22
+ themeName, toggleTheme, t, className, style, size,
23
+ }: ToggleThemeMenuProps) {
24
+ return <div className={className || undefined} style={style || undefined}>
25
+ <Tooltip title={t('ra_Change color theme')} componentsProps={{ popper: { sx: { pointerEvents: 'none' } } }}>
26
+ <IconButton onClick={() => toggleTheme()} size={size || 'medium'}>
27
+ {themeName === 'dark' && <Brightness4Icon className={className} />}
28
+ {themeName === 'blue' && <Brightness5Icon className={className} />}
29
+ {themeName === 'colored' && <Brightness6Icon className={className} />}
30
+ {themeName !== 'dark' && themeName !== 'blue' && themeName !== 'colored' && <Brightness7Icon className={className} />}
31
+ </IconButton>
32
+ </Tooltip>
33
+ </div>;
34
+ }