@iobroker/adapter-react-v5 3.1.24 → 3.1.27

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 (132) hide show
  1. package/Components/404.d.ts +3 -0
  2. package/Components/ColorPicker.d.ts +138 -0
  3. package/Components/ComplexCron.d.ts +8 -0
  4. package/Components/CustomModal.d.ts +3 -0
  5. package/Components/FileBrowser.d.ts +125 -0
  6. package/Components/FileViewer.d.ts +80 -0
  7. package/Components/FileViewer.js +10 -9
  8. package/Components/FileViewer.js.map +1 -1
  9. package/Components/Icon.d.ts +21 -0
  10. package/Components/IconPicker.d.ts +64 -0
  11. package/Components/IconSelector.d.ts +25 -0
  12. package/Components/Image.d.ts +64 -0
  13. package/Components/JsonConfigComponent/ChipInput.d.ts +13 -0
  14. package/Components/JsonConfigComponent/ConfigAlive.d.ts +10 -0
  15. package/Components/JsonConfigComponent/ConfigAutocomplete.d.ts +14 -0
  16. package/Components/JsonConfigComponent/ConfigAutocompleteSendTo.d.ts +14 -0
  17. package/Components/JsonConfigComponent/ConfigCRON.d.ts +15 -0
  18. package/Components/JsonConfigComponent/ConfigCertificateSelect.d.ts +14 -0
  19. package/Components/JsonConfigComponent/ConfigCheckbox.d.ts +14 -0
  20. package/Components/JsonConfigComponent/ConfigChip.d.ts +14 -0
  21. package/Components/JsonConfigComponent/ConfigColor.d.ts +14 -0
  22. package/Components/JsonConfigComponent/ConfigCoordinates.d.ts +14 -0
  23. package/Components/JsonConfigComponent/ConfigCustom.d.ts +26 -0
  24. package/Components/JsonConfigComponent/ConfigDatePicker.d.ts +14 -0
  25. package/Components/JsonConfigComponent/ConfigFile.d.ts +15 -0
  26. package/Components/JsonConfigComponent/ConfigFileSelector.d.ts +3 -0
  27. package/Components/JsonConfigComponent/ConfigFunc.d.ts +14 -0
  28. package/Components/JsonConfigComponent/ConfigGeneric.d.ts +71 -0
  29. package/Components/JsonConfigComponent/ConfigIP.d.ts +14 -0
  30. package/Components/JsonConfigComponent/ConfigImageUpload.d.ts +14 -0
  31. package/Components/JsonConfigComponent/ConfigInstanceSelect.d.ts +14 -0
  32. package/Components/JsonConfigComponent/ConfigJsonEditor.d.ts +14 -0
  33. package/Components/JsonConfigComponent/ConfigLanguage.d.ts +14 -0
  34. package/Components/JsonConfigComponent/ConfigNumber.d.ts +3 -0
  35. package/Components/JsonConfigComponent/ConfigObjectId.d.ts +17 -0
  36. package/Components/JsonConfigComponent/ConfigPanel.d.ts +3 -0
  37. package/Components/JsonConfigComponent/ConfigPassword.d.ts +14 -0
  38. package/Components/JsonConfigComponent/ConfigPattern.d.ts +14 -0
  39. package/Components/JsonConfigComponent/ConfigRoom.d.ts +14 -0
  40. package/Components/JsonConfigComponent/ConfigSelect.d.ts +14 -0
  41. package/Components/JsonConfigComponent/ConfigSelectSendTo.d.ts +17 -0
  42. package/Components/JsonConfigComponent/ConfigSendto.d.ts +18 -0
  43. package/Components/JsonConfigComponent/ConfigSendto.js +171 -9
  44. package/Components/JsonConfigComponent/ConfigSendto.js.map +1 -1
  45. package/Components/JsonConfigComponent/ConfigSetState.d.ts +18 -0
  46. package/Components/JsonConfigComponent/ConfigSlider.d.ts +14 -0
  47. package/Components/JsonConfigComponent/ConfigStaticDivider.d.ts +14 -0
  48. package/Components/JsonConfigComponent/ConfigStaticHeader.d.ts +14 -0
  49. package/Components/JsonConfigComponent/ConfigStaticImage.d.ts +14 -0
  50. package/Components/JsonConfigComponent/ConfigStaticText.d.ts +14 -0
  51. package/Components/JsonConfigComponent/ConfigTable.d.ts +3 -0
  52. package/Components/JsonConfigComponent/ConfigTabs.d.ts +33 -0
  53. package/Components/JsonConfigComponent/ConfigText.d.ts +14 -0
  54. package/Components/JsonConfigComponent/ConfigTextSendTo.d.ts +10 -0
  55. package/Components/JsonConfigComponent/ConfigTimePicker.d.ts +14 -0
  56. package/Components/JsonConfigComponent/ConfigTopic.d.ts +17 -0
  57. package/Components/JsonConfigComponent/ConfigUser.d.ts +14 -0
  58. package/Components/JsonConfigComponent/index.d.ts +27 -0
  59. package/Components/JsonConfigComponent/index.js +21 -17
  60. package/Components/JsonConfigComponent/index.js.map +1 -1
  61. package/Components/Loader.d.ts +37 -0
  62. package/Components/Loaders/PT.d.ts +41 -0
  63. package/Components/Loaders/Vendor.d.ts +41 -0
  64. package/Components/Logo.d.ts +59 -0
  65. package/Components/MDUtils.d.ts +12 -0
  66. package/Components/ObjectBrowser.d.ts +632 -0
  67. package/Components/Router.d.ts +35 -0
  68. package/Components/SaveCloseButtons.d.ts +64 -0
  69. package/Components/Schedule.d.ts +7 -0
  70. package/Components/SelectWithIcon.d.ts +21 -0
  71. package/Components/SimpleCron/cron2text.d.ts +8 -0
  72. package/Components/SimpleCron/cronText.d.ts +2 -0
  73. package/Components/SimpleCron/index.d.ts +8 -0
  74. package/Components/SimpleCron/jquery.cron.locale.d.ts +2 -0
  75. package/Components/TabContainer.d.ts +42 -0
  76. package/Components/TabContent.d.ts +32 -0
  77. package/Components/TabHeader.d.ts +13 -0
  78. package/Components/TableResize.d.ts +14 -0
  79. package/Components/TextWithIcon.d.ts +3 -0
  80. package/Components/ToggleThemeMenu.d.ts +8 -0
  81. package/Components/TreeTable.d.ts +3 -0
  82. package/Components/UploadImage.d.ts +2 -0
  83. package/Components/Utils.d.ts +334 -0
  84. package/Components/copy-to-clipboard.d.ts +2 -0
  85. package/Components/withWidth.d.ts +2 -0
  86. package/Connection.d.ts +761 -0
  87. package/Connection.js +9 -1
  88. package/Connection.js.map +1 -1
  89. package/Dialogs/ComplexCron.d.ts +15 -0
  90. package/Dialogs/Confirm.d.ts +48 -0
  91. package/Dialogs/Cron.d.ts +15 -0
  92. package/Dialogs/Error.d.ts +49 -0
  93. package/Dialogs/FileSelect.d.ts +148 -0
  94. package/Dialogs/Message.d.ts +39 -0
  95. package/Dialogs/SelectID.d.ts +161 -0
  96. package/Dialogs/SimpleCron.d.ts +14 -0
  97. package/Dialogs/TextInput.d.ts +87 -0
  98. package/GenericApp.d.ts +213 -0
  99. package/Prompt.d.ts +5 -0
  100. package/README.md +7 -0
  101. package/Theme.d.ts +7 -0
  102. package/assets/devices/parseNames.d.ts +1 -0
  103. package/assets/rooms/parseNames.d.ts +1 -0
  104. package/i18n/de.json +4 -1
  105. package/i18n/en.json +4 -1
  106. package/i18n/es.json +4 -1
  107. package/i18n/fr.json +4 -1
  108. package/i18n/it.json +4 -1
  109. package/i18n/nl.json +4 -1
  110. package/i18n/pl.json +4 -1
  111. package/i18n/pt.json +4 -1
  112. package/i18n/ru.json +4 -1
  113. package/i18n/zh-cn.json +4 -1
  114. package/i18n.d.ts +92 -0
  115. package/icons/IconAdapter.d.ts +11 -0
  116. package/icons/IconAlias.d.ts +11 -0
  117. package/icons/IconChannel.d.ts +11 -0
  118. package/icons/IconClearFilter.d.ts +11 -0
  119. package/icons/IconClosed.d.ts +11 -0
  120. package/icons/IconCopy.d.ts +38 -0
  121. package/icons/IconDevice.d.ts +11 -0
  122. package/icons/IconDocument.d.ts +11 -0
  123. package/icons/IconDocumentReadOnly.d.ts +11 -0
  124. package/icons/IconExpert.d.ts +38 -0
  125. package/icons/IconFx.d.ts +11 -0
  126. package/icons/IconInstance.d.ts +11 -0
  127. package/icons/IconLogout.d.ts +38 -0
  128. package/icons/IconNoIcon.d.ts +38 -0
  129. package/icons/IconOpen.d.ts +11 -0
  130. package/icons/IconState.d.ts +11 -0
  131. package/index.d.ts +113 -0
  132. package/package.json +8 -8
@@ -0,0 +1,3 @@
1
+ declare const _default: React.JSXElementConstructor<any>;
2
+ export default _default;
3
+ import React from "react";
@@ -0,0 +1,138 @@
1
+ export default _export;
2
+ export type Rgb = {
3
+ /**
4
+ * The red component of the color (0-255).
5
+ */
6
+ r: number;
7
+ /**
8
+ * The green component of the color (0-255).
9
+ */
10
+ g: number;
11
+ /**
12
+ * The blue component of the color (0-255).
13
+ */
14
+ b: number;
15
+ /**
16
+ * The alpha component of the color (0-255).
17
+ */
18
+ a: number;
19
+ };
20
+ /**
21
+ * Definition of a color.
22
+ */
23
+ export type Color = string | Rgb | {
24
+ rgb: Rgb;
25
+ };
26
+ export type ColorPickerProps = {
27
+ /**
28
+ * Set to true to disable the color picker.
29
+ */
30
+ disabled?: boolean;
31
+ /**
32
+ * The currently selected color.
33
+ */
34
+ value?: Color;
35
+ /**
36
+ * The color change callback.
37
+ */
38
+ onChange?: (rgba: string) => void;
39
+ /**
40
+ * The name.
41
+ */
42
+ name?: string;
43
+ /**
44
+ * Additional styling for this component.
45
+ */
46
+ style?: React.CSSProperties;
47
+ /**
48
+ * The CSS class name.
49
+ */
50
+ className?: string;
51
+ /**
52
+ * Open the color picker above the field?
53
+ */
54
+ openAbove?: boolean;
55
+ };
56
+ /** @type {typeof ColorPicker} */
57
+ declare const _export: typeof ColorPicker;
58
+ /**
59
+ * @typedef {object} Rgb
60
+ * @property {number} r The red component of the color (0-255).
61
+ * @property {number} g The green component of the color (0-255).
62
+ * @property {number} b The blue component of the color (0-255).
63
+ * @property {number} a The alpha component of the color (0-255).
64
+ *
65
+ * @typedef {string | Rgb | { rgb: Rgb }} Color Definition of a color.
66
+ *
67
+ * @typedef {object} ColorPickerProps
68
+ * @property {boolean} [disabled] Set to true to disable the color picker.
69
+ * @property {Color} [value] The currently selected color.
70
+ * @property {(rgba: string) => void} [onChange] The color change callback.
71
+ * @property {string} [name] The name.
72
+ * @property {React.CSSProperties} [style] Additional styling for this component.
73
+ * @property {string} [className] The CSS class name.
74
+ * @property {boolean} [openAbove] Open the color picker above the field?
75
+ *
76
+ * @extends {React.Component<ColorPickerProps>}
77
+ */
78
+ declare class ColorPicker extends React.Component<ColorPickerProps, any, any> {
79
+ /**
80
+ * Get the state derived from the given properties and state.
81
+ * @param {{ color: Color; }} props
82
+ * @param {{ color: Color; }} state
83
+ */
84
+ static getDerivedStateFromProps(props: {
85
+ color: Color;
86
+ }, state: {
87
+ color: Color;
88
+ }): {
89
+ color: any;
90
+ };
91
+ /**
92
+ * Convert the given color to hex ('#rrggbb') or rgba ('rgba(r,g,b,a)') format.
93
+ * @param {Color} [color]
94
+ * @param {boolean} [isHex] The returning string should be in hex format
95
+ * @returns {string} the hex or rgba representation of the given color.
96
+ */
97
+ static getColor(color?: Color, isHex?: boolean): string;
98
+ /**
99
+ * Convert rgb() or rgba() format to hex format #rrggbb.
100
+ * @param {string} rgb
101
+ * @returns {string}
102
+ */
103
+ static rgb2hex(rgb: string): string;
104
+ /**
105
+ * @param {Readonly<ColorPickerProps>} props
106
+ */
107
+ constructor(props: Readonly<ColorPickerProps>);
108
+ state: {
109
+ displayColorPicker: boolean;
110
+ color: any;
111
+ };
112
+ /**
113
+ * @private
114
+ */
115
+ private handleClick;
116
+ /**
117
+ * @private
118
+ */
119
+ private handleClose;
120
+ /**
121
+ * @private
122
+ */
123
+ private handleChange;
124
+ render(): JSX.Element;
125
+ }
126
+ declare namespace ColorPicker {
127
+ namespace propTypes {
128
+ const disabled: PropTypes.Requireable<boolean>;
129
+ const value: PropTypes.Requireable<string>;
130
+ const onChange: PropTypes.Validator<(...args: any[]) => any>;
131
+ const name: PropTypes.Requireable<string>;
132
+ const style: PropTypes.Requireable<object>;
133
+ const className: PropTypes.Requireable<string>;
134
+ const openAbove: PropTypes.Requireable<boolean>;
135
+ }
136
+ }
137
+ import React from "react";
138
+ import PropTypes from "prop-types";
@@ -0,0 +1,8 @@
1
+ declare const _default: React.JSXElementConstructor<Omit<PropTypes.InferProps<{
2
+ cronExpression: PropTypes.Requireable<string>;
3
+ onChange: PropTypes.Validator<(...args: any[]) => any>;
4
+ language: PropTypes.Requireable<string>;
5
+ }>, "classes"> & import("@mui/styles/withStyles").StyledComponentProps<"slider" | "appBar" | "mainDiv" | "periodSelect" | "tabContent" | "numberButton" | "numberButtonBreak"> & object>;
6
+ export default _default;
7
+ import PropTypes from "prop-types";
8
+ import React from "react";
@@ -0,0 +1,3 @@
1
+ declare const _default: React.JSXElementConstructor<any>;
2
+ export default _default;
3
+ import React from "react";
@@ -0,0 +1,125 @@
1
+ export default _export;
2
+ /** @type {typeof FileBrowser} */
3
+ declare const _export: typeof FileBrowser;
4
+ /**
5
+ * @extends {React.Component<import('./types').FileBrowserProps>}
6
+ */
7
+ declare class FileBrowser extends React.Component<import("./types").FileBrowserProps, any, any> {
8
+ static getDerivedStateFromProps(props: any, state: any): {
9
+ expertMode: any;
10
+ loadAllFolders: boolean;
11
+ };
12
+ static getEditFile(ext: any): boolean;
13
+ /**
14
+ * @param {Readonly<import("./types").FileBrowserProps>} props
15
+ */
16
+ constructor(props: Readonly<import("./types").FileBrowserProps>);
17
+ limitToObjectID: any;
18
+ limitToPath: any;
19
+ state: {
20
+ viewType: any;
21
+ folders: {};
22
+ filterEmpty: boolean;
23
+ expanded: any;
24
+ currentDir: string;
25
+ expertMode: boolean;
26
+ addFolder: boolean;
27
+ uploadFile: boolean;
28
+ deleteItem: string;
29
+ marked: any[];
30
+ viewer: string;
31
+ formatEditFile: string;
32
+ path: any;
33
+ selected: any;
34
+ errorText: string;
35
+ modalEditOfAccess: boolean;
36
+ backgroundImage: any;
37
+ queueLength: number;
38
+ loadAllFolders: boolean;
39
+ allFoldersLoaded: boolean;
40
+ fileErrors: any[];
41
+ };
42
+ imagePrefix: string;
43
+ levelPadding: any;
44
+ mounted: boolean;
45
+ suppressDeleteConfirm: number;
46
+ browseList: any[];
47
+ browseListRunning: boolean;
48
+ initialReadFinished: boolean;
49
+ supportSubscribes: any;
50
+ _tempTimeout: {};
51
+ loadFolders(): any;
52
+ scrollToSelected(): void;
53
+ componentDidMount(): Promise<void>;
54
+ componentWillUnmount(): void;
55
+ browseFolders(foldersList: any, _newFolders: any, _resolve: any): any;
56
+ readDirSerial(adapter: any, relPath: any): Promise<any>;
57
+ processBrowseList(level: any): void;
58
+ browseFolder(folderId: any, _newFolders: any, _checkEmpty: any, force: any): any;
59
+ toggleFolder(item: any, e: any): any;
60
+ onFileChange: (id: any, fileName: any, size: any) => void;
61
+ changeFolder(e: any, folder: any): any;
62
+ lastSelect: number;
63
+ select(id: any, e: any, cb: any): void;
64
+ renderFolder(item: any, expanded: any): JSX.Element;
65
+ renderBackFolder(): JSX.Element;
66
+ formatSize(size: any): JSX.Element;
67
+ formatAcl(acl: any): JSX.Element;
68
+ getFileIcon(ext: any): JSX.Element;
69
+ setStateBackgroundImage: () => void;
70
+ getClassBackgroundImage: () => any;
71
+ renderFile(item: any): JSX.Element;
72
+ renderItems(folderId: any): any;
73
+ renderToolbar(): JSX.Element;
74
+ findItem(id: any, folders: any): any;
75
+ renderInputDialog(): void | JSX.Element;
76
+ componentDidUpdate(): void;
77
+ setOpacityTimer: any;
78
+ uploadFile(fileName: any, data: any): Promise<void>;
79
+ findFirstFolder(id: any): any;
80
+ renderUpload(): JSX.Element[];
81
+ deleteRecursive(id: any): Promise<void>;
82
+ deleteItem(deleteItem: any): void;
83
+ renderDeleteDialog(): false | JSX.Element;
84
+ renderViewDialog(): JSX.Element;
85
+ renderError(): JSX.Element;
86
+ updateItemsAcl(info: any): void;
87
+ changeToPath(): void;
88
+ renderBreadcrumb(): any;
89
+ renderPath(): JSX.Element;
90
+ render(): JSX.Element;
91
+ foldersLoading: boolean;
92
+ }
93
+ declare namespace FileBrowser {
94
+ namespace defaultProps {
95
+ function modalEditOfAccessControl(): void;
96
+ }
97
+ namespace propTypes {
98
+ export const style: PropTypes.Requireable<object>;
99
+ export const className: PropTypes.Requireable<string>;
100
+ export const t: PropTypes.Validator<(...args: any[]) => any>;
101
+ export const lang: PropTypes.Validator<string>;
102
+ export const socket: PropTypes.Validator<object>;
103
+ export const ready: PropTypes.Requireable<boolean>;
104
+ export const expertMode: PropTypes.Requireable<boolean>;
105
+ export const showToolbar: PropTypes.Requireable<boolean>;
106
+ export const allowUpload: PropTypes.Requireable<boolean>;
107
+ export const allowDownload: PropTypes.Requireable<boolean>;
108
+ export const allowCreateFolder: PropTypes.Requireable<boolean>;
109
+ export const allowDelete: PropTypes.Requireable<boolean>;
110
+ export const allowView: PropTypes.Requireable<boolean>;
111
+ export const imagePrefix: PropTypes.Requireable<string>;
112
+ export const showExpertButton: PropTypes.Requireable<boolean>;
113
+ export const viewType: PropTypes.Requireable<string>;
114
+ export const showViewTypeButton: PropTypes.Requireable<boolean>;
115
+ export const selected: PropTypes.Requireable<string>;
116
+ export const tileView: PropTypes.Requireable<boolean>;
117
+ export const filterFiles: PropTypes.Requireable<any[]>;
118
+ export const filterByType: PropTypes.Requireable<string>;
119
+ export const onSelect: PropTypes.Requireable<(...args: any[]) => any>;
120
+ const modalEditOfAccessControl_1: PropTypes.Requireable<(...args: any[]) => any>;
121
+ export { modalEditOfAccessControl_1 as modalEditOfAccessControl };
122
+ }
123
+ }
124
+ import React from "react";
125
+ import PropTypes from "prop-types";
@@ -0,0 +1,80 @@
1
+ export namespace EXTENSIONS {
2
+ const images: string[];
3
+ const code: string[];
4
+ const txt: string[];
5
+ const audio: string[];
6
+ const video: string[];
7
+ }
8
+ export default _export;
9
+ export type FileViewerProps = {
10
+ /**
11
+ * Translation function
12
+ */
13
+ t: import('../types').Translator;
14
+ /**
15
+ * The selected language.
16
+ */
17
+ lang?: ioBroker.Languages;
18
+ /**
19
+ * Is expert mode enabled? (default: false)
20
+ */
21
+ expertMode?: boolean;
22
+ /**
23
+ * Callback when the viewer is closed.
24
+ */
25
+ onClose: () => void;
26
+ /**
27
+ * The URL to the file to be displayed.
28
+ */
29
+ href: string;
30
+ };
31
+ /** @type {typeof FileViewer} */
32
+ declare const _export: typeof FileViewer;
33
+ /**
34
+ * @typedef {object} FileViewerProps
35
+ * @property {import('../types').Translator} t Translation function
36
+ * @property {ioBroker.Languages} [lang] The selected language.
37
+ * @property {boolean} [expertMode] Is expert mode enabled? (default: false)
38
+ * @property {() => void} onClose Callback when the viewer is closed.
39
+ * @property {string} href The URL to the file to be displayed.
40
+ *
41
+ * @extends {React.Component<FileViewerProps>}
42
+ */
43
+ declare class FileViewer extends React.Component<FileViewerProps, any, any> {
44
+ static getEditFile(ext: any): "html" | "json" | "json5" | "javascript";
45
+ /**
46
+ * @param {Readonly<FileViewerProps>} props
47
+ */
48
+ constructor(props: Readonly<FileViewerProps>);
49
+ state: {
50
+ text: any;
51
+ code: any;
52
+ ext: string;
53
+ editing: boolean;
54
+ editingValue: any;
55
+ copyPossible: boolean;
56
+ forceUpdate: number;
57
+ changed: boolean;
58
+ imgError: boolean;
59
+ };
60
+ readFile(): void;
61
+ componentDidMount(): void;
62
+ componentWillUnmount(): void;
63
+ onFileChanged: (id: any, fileName: any, size: any) => void;
64
+ timeout: any;
65
+ writeFile64: () => void;
66
+ getContent(): JSX.Element;
67
+ render(): JSX.Element;
68
+ }
69
+ declare namespace FileViewer {
70
+ namespace propTypes {
71
+ const t: PropTypes.Requireable<(...args: any[]) => any>;
72
+ const lang: PropTypes.Requireable<string>;
73
+ const expertMode: PropTypes.Requireable<boolean>;
74
+ const onClose: PropTypes.Requireable<(...args: any[]) => any>;
75
+ const href: PropTypes.Validator<string>;
76
+ const supportSubscribes: PropTypes.Requireable<boolean>;
77
+ }
78
+ }
79
+ import React from "react";
80
+ import PropTypes from "prop-types";
@@ -29,8 +29,6 @@ var _styles = require("@mui/styles");
29
29
 
30
30
  var _propTypes = _interopRequireDefault(require("prop-types"));
31
31
 
32
- var _buffer = require("buffer");
33
-
34
32
  var _TextField = _interopRequireDefault(require("@mui/material/TextField"));
35
33
 
36
34
  var _Button = _interopRequireDefault(require("@mui/material/Button"));
@@ -163,13 +161,13 @@ var FileViewer = /*#__PURE__*/function (_Component) {
163
161
  var data = _this.state.editingValue;
164
162
  parts.splice(0, 2);
165
163
  var adapter = parts[0];
166
- var name = parts.splice(1).join('/');
164
+ var name = parts.splice(1).join('/'); // File viewer in adapter-react does not support write
167
165
 
168
- _this.props.socket.writeFile64(adapter, name, _buffer.Buffer.from(data).toString('base64')).then(function (_) {
169
- return _this.props.onClose();
170
- })["catch"](function (e) {
171
- return window.alert('Cannot write file: ' + e);
172
- });
166
+ /*
167
+ this.props.socket.writeFile64(adapter, name, Buffer.from(data).toString('base64'))
168
+ .then(_ => this.props.onClose())
169
+ .catch(e => window.alert('Cannot write file: ' + e));
170
+ */
173
171
  });
174
172
 
175
173
  var ext = _Utils["default"].getFileExtension(_this.props.href);
@@ -178,7 +176,10 @@ var FileViewer = /*#__PURE__*/function (_Component) {
178
176
  text: null,
179
177
  code: null,
180
178
  ext: ext,
181
- editing: !!_this.props.formatEditFile || false,
179
+ // File viewer in adapter-react does not support write
180
+ editing:
181
+ /* !!this.props.formatEditFile || */
182
+ false,
182
183
  editingValue: null,
183
184
  copyPossible: EXTENSIONS.code.includes(ext) || EXTENSIONS.txt.includes(ext),
184
185
  forceUpdate: Date.now(),
@@ -1 +1 @@
1
- {"version":3,"file":"FileViewer.js","names":["styles","theme","dialog","height","paper","content","textAlign","textarea","width","img","objectFit","dialogTitle","justifyContent","display","EXTENSIONS","images","code","txt","audio","video","bufferToBase64","buffer","binary","bytes","Uint8Array","len","byteLength","i","String","fromCharCode","window","btoa","FileViewer","props","id","fileName","size","state","changed","timeout","clearTimeout","setTimeout","alert","text","readFile","setState","forceUpdate","Date","now","parts","href","split","data","editingValue","splice","adapter","name","join","socket","writeFile64","Buffer","from","toString","then","_","onClose","e","ext","Utils","getFileExtension","editing","formatEditFile","copyPossible","includes","imgError","file","undefined","newState","type","detectMimeType","supportSubscribes","subscribeFiles","onFileChanged","clsx","classes","getClassBackgroundImage","target","onerror","newValue","readOnly","scrollPaper","t","setStateBackgroundImage","getContent","copyToClipboard","Component","propTypes","PropTypes","func","lang","string","expertMode","bool","isRequired","_export","withWidth","withStyles"],"sources":["FileViewer.js"],"sourcesContent":["import React, { Component } from 'react';\nimport { withStyles } from '@mui/styles';\nimport PropTypes from 'prop-types';\n\nimport { Buffer } from 'buffer';\n\nimport TextField from '@mui/material/TextField';\nimport Button from '@mui/material/Button';\nimport Dialog from '@mui/material/Dialog';\nimport DialogActions from '@mui/material/DialogActions';\nimport DialogContent from '@mui/material/DialogContent';\nimport DialogTitle from '@mui/material/DialogTitle';\nimport { IconButton } from '@mui/material';\n\nimport IconNoIcon from '../icons/IconNoIcon';\nimport withWidth from './withWidth';\nimport Utils from './Utils';\n\n// Icons\nimport { FaCopy as CopyIcon } from 'react-icons/fa';\nimport Brightness5Icon from '@mui/icons-material/Brightness6';\nimport CloseIcon from '@mui/icons-material/Close';\nimport SaveIcon from '@mui/icons-material/Save';\n\nconst styles = theme => ({\n dialog: {\n height: '100%',\n },\n paper: {\n height: 'calc(100% - 64px)',\n },\n content: {\n textAlign: 'center',\n },\n textarea: {\n width: '100%',\n height: '100%',\n },\n img: {\n width: 'auto',\n height: 'calc(100% - 5px)',\n objectFit: 'contain',\n },\n dialogTitle: {\n justifyContent: 'space-between',\n display: 'flex'\n }\n});\n\nexport const EXTENSIONS = {\n images: ['png', 'jpg', 'svg', 'jpeg', 'bmp'],\n code: ['js', 'json', 'json5', 'md'],\n txt: ['log', 'txt', 'html', 'css', 'xml'],\n audio: ['mp3', 'wav', 'ogg', 'acc'],\n video: ['mp4', 'mov', 'avi'],\n};\n\nfunction bufferToBase64(buffer) {\n let binary = '';\n let bytes = new Uint8Array(buffer);\n let len = bytes.byteLength;\n for (let i = 0; i < len && i < 50; i++) {\n binary += String.fromCharCode(bytes[i]);\n }\n return window.btoa(binary);\n}\n\n/**\n * @typedef {object} FileViewerProps\n * @property {import('../types').Translator} t Translation function\n * @property {ioBroker.Languages} [lang] The selected language.\n * @property {boolean} [expertMode] Is expert mode enabled? (default: false)\n * @property {() => void} onClose Callback when the viewer is closed.\n * @property {string} href The URL to the file to be displayed.\n *\n * @extends {React.Component<FileViewerProps>}\n */\nclass FileViewer extends Component {\n /**\n * @param {Readonly<FileViewerProps>} props\n */\n constructor(props) {\n super(props);\n const ext = Utils.getFileExtension(this.props.href);\n\n this.state = {\n text: null,\n code: null,\n ext,\n editing: !!this.props.formatEditFile || false,\n editingValue: null,\n copyPossible: EXTENSIONS.code.includes(ext) || EXTENSIONS.txt.includes(ext),\n forceUpdate: Date.now(),\n changed: false,\n imgError: false,\n };\n }\n\n readFile() {\n if (this.props.href) {\n const parts = this.props.href.split('/');\n parts.splice(0, 2);\n const adapter = parts[0];\n const name = parts.splice(1).join('/');\n\n this.props.socket.readFile(adapter, name)\n .then(data => {\n if (data.file !== undefined) {\n data = data.file;\n }\n\n const newState = {copyPossible: this.state.copyPossible};\n // try to detect valid extension\n if (data.type === 'Buffer') {\n const ext = Utils.detectMimeType(bufferToBase64(data.data));\n if (ext) {\n newState.ext = ext;\n newState.copyPossible = EXTENSIONS.code.includes(ext) || EXTENSIONS.txt.includes(ext);\n }\n }\n\n if (newState.copyPossible) {\n if (EXTENSIONS.txt.includes(this.state.ext)) {\n newState.text = data;\n newState.editingValue = data;\n } else if (EXTENSIONS.code.includes(this.state.ext)) {\n newState.code = data;\n newState.editingValue = data;\n }\n }\n\n this.setState(newState);\n })\n .catch(e => window.alert('Cannot read file: ' + e));\n }\n }\n\n componentDidMount() {\n this.readFile();\n\n const parts = this.props.href.split('/');\n parts.splice(0, 2);\n const adapter = parts[0];\n const name = parts.splice(1).join('/');\n\n this.props.supportSubscribes && this.props.socket.subscribeFiles(adapter, name, this.onFileChanged);\n }\n\n componentWillUnmount() {\n this.timeout && clearTimeout(this.timeout);\n const parts = this.props.href.split('/');\n parts.splice(0, 2);\n const adapter = parts[0];\n const name = parts.splice(1).join('/');\n this.props.supportSubscribes && this.props.socket.subscribeFiles(adapter, name, this.onFileChanged);\n }\n\n onFileChanged = (id, fileName, size) => {\n if (!this.state.changed) {\n this.timeout && clearTimeout(this.timeout);\n this.timeout = setTimeout(() => {\n this.timeout = null;\n if (size === null) {\n window.alert('Show file was deleted!');\n } else if (this.state.text !== null || this.state.code !== null) {\n this.readFile();\n } else {\n this.setState({ forceUpdate: Date.now() });\n }\n }, 300);\n }\n };\n\n writeFile64 = () => {\n const parts = this.props.href.split('/');\n const data = this.state.editingValue;\n parts.splice(0, 2);\n const adapter = parts[0];\n const name = parts.splice(1).join('/');\n this.props.socket.writeFile64(adapter, name, Buffer.from(data).toString('base64'))\n .then(_ => this.props.onClose())\n .catch(e => window.alert('Cannot write file: ' + e));\n }\n\n static getEditFile(ext) {\n switch (ext) {\n case 'json':\n return 'json';\n case 'json5':\n return 'json5';\n case 'js':\n return 'javascript';\n case 'html':\n return 'html';\n case 'txt':\n return 'html';\n default:\n return 'json';\n }\n }\n\n getContent() {\n if (EXTENSIONS.images.includes(this.state.ext)) {\n if (this.state.imgError) {\n return <IconNoIcon className={Utils.clsx(this.props.classes.img, this.props.getClassBackgroundImage())} />;\n } else {\n return <img\n onError={e => {\n e.target.onerror = null;\n this.setState({ imgError: true });\n }}\n className={Utils.clsx(this.props.classes.img, this.props.getClassBackgroundImage())}\n src={this.props.href + '?ts=' + this.state.forceUpdate}\n alt={this.props.href}\n />;\n }\n } else if (this.state.code !== null || this.state.text !== null || this.state.editing) {\n return <TextField\n variant=\"standard\"\n className={ this.props.classes.textarea }\n multiline\n value={ this.state.editingValue || this.state.code || this.state.text }\n onChange={newValue => this.setState({ editingValue: newValue, changed: true })}\n InputProps={{ readOnly: !this.state.editing }}\n />;\n }\n }\n\n render() {\n return <Dialog\n classes={{ scrollPaper: this.props.classes.dialog, paper: this.props.classes.paper }}\n scroll=\"paper\"\n open={!!this.props.href}\n onClose={() => this.props.onClose()}\n fullWidth={true}\n maxWidth=\"xl\"\n aria-labelledby=\"form-dialog-title\"\n >\n <div className={this.props.classes.dialogTitle}>\n <DialogTitle id=\"form-dialog-title\">{this.props.t(this.state.editing ? 'Edit' : 'View') + ': ' + this.props.href}</DialogTitle>\n {EXTENSIONS.images.includes(this.state.ext) && <div>\n <IconButton size=\"large\"\n color={'inherit'}\n onClick={this.props.setStateBackgroundImage}\n >\n <Brightness5Icon />\n </IconButton>\n </div>\n }\n </div>\n <DialogContent className={this.props.classes.content}>\n {this.getContent()}\n </DialogContent>\n <DialogActions>\n {this.state.copyPossible ?\n <Button\n color=\"grey\"\n onClick={e => Utils.copyToClipboard(this.state.text || this.state.code, e)}\n startIcon={<CopyIcon />}\n >\n {this.props.t('Copy content')}\n </Button> : null}\n {this.state.editing ?\n <Button\n color=\"grey\"\n disabled={this.state.editingValue === this.state.code || this.state.editingValue === this.state.text}\n variant=\"contained\"\n onClick={this.writeFile64}\n startIcon={<SaveIcon />}\n >\n {this.props.t('Save')}\n </Button> : null}\n <Button\n variant=\"contained\"\n onClick={() => this.props.onClose()}\n color=\"primary\"\n startIcon={<CloseIcon />}\n >\n {this.props.t('Close')}\n </Button>\n </DialogActions>\n </Dialog>;\n }\n}\n\nFileViewer.propTypes = {\n t: PropTypes.func,\n lang: PropTypes.string,\n expertMode: PropTypes.bool,\n onClose: PropTypes.func,\n href: PropTypes.string.isRequired,\n supportSubscribes: PropTypes.bool,\n};\n\n/** @type {typeof FileViewer} */\nconst _export = withWidth()(withStyles(styles)(FileViewer));\nexport default _export;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AAEA;;AAEA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAEA;;AACA;;AACA;;AAGA;;AACA;;AACA;;AACA;;;;;;;;;;AAEA,IAAMA,MAAM,GAAG,SAATA,MAAS,CAAAC,KAAK;EAAA,OAAK;IACrBC,MAAM,EAAE;MACJC,MAAM,EAAE;IADJ,CADa;IAIrBC,KAAK,EAAE;MACHD,MAAM,EAAE;IADL,CAJc;IAOrBE,OAAO,EAAE;MACLC,SAAS,EAAE;IADN,CAPY;IAUrBC,QAAQ,EAAE;MACNC,KAAK,EAAE,MADD;MAENL,MAAM,EAAE;IAFF,CAVW;IAcrBM,GAAG,EAAE;MACDD,KAAK,EAAE,MADN;MAEDL,MAAM,EAAE,kBAFP;MAGDO,SAAS,EAAE;IAHV,CAdgB;IAmBrBC,WAAW,EAAE;MACTC,cAAc,EAAE,eADP;MAETC,OAAO,EAAE;IAFA;EAnBQ,CAAL;AAAA,CAApB;;AAyBO,IAAMC,UAAU,GAAG;EACtBC,MAAM,EAAE,CAAC,KAAD,EAAQ,KAAR,EAAe,KAAf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FpG;QAGI,OAAO,EAAC,WAHZ;QAII,OAAO,EAAE,KAAKgB,WAJlB;QAKI,SAAS,eAAE,gCAAC,gBAAD;MALf,GAOK,KAAK1B,KAAL,CAAW0D,CAAX,CAAa,MAAb,CAPL,CADH,GASe,IAlBpB,eAmBI,gCAAC,kBAAD;QACI,OAAO,EAAC,WADZ;QAEI,OAAO,EAAE;UAAA,OAAM,MAAI,CAAC1D,KAAL,CAAWgC,OAAX,EAAN;QAAA,CAFb;QAGI,KAAK,EAAC,SAHV;QAII,SAAS,eAAE,gCAAC,iBAAD;MAJf,GAMK,KAAKhC,KAAL,CAAW0D,CAAX,CAAa,OAAb,CANL,CAnBJ,CAxBG,CAAP;IAqDH;;;WAlGD,qBAAmBxB,GAAnB,EAAwB;MACpB,QAAQA,GAAR;QACI,KAAK,MAAL;UACI,OAAO,MAAP;;QACJ,KAAK,OAAL;UACI,OAAO,OAAP;;QACJ,KAAK,IAAL;UACI,OAAO,YAAP;;QACJ,KAAK,MAAL;UACI,OAAO,MAAP;;QACJ,KAAK,KAAL;UACI,OAAO,MAAP;;QACJ;UACI,OAAO,MAAP;MAZR;IAcH;;;EA1HoB4B,gB;;AAgNzB/D,UAAU,CAACgE,SAAX,GAAuB;EACnBL,CAAC,EAAEM,qBAAA,CAAUC,IADM;EAEnBC,IAAI,EAAEF,qBAAA,CAAUG,MAFG;EAGnBC,UAAU,EAAEJ,qBAAA,CAAUK,IAHH;EAInBrC,OAAO,EAAEgC,qBAAA,CAAUC,IAJA;EAKnBhD,IAAI,EAAE+C,qBAAA,CAAUG,MAAV,CAAiBG,UALJ;EAMnBvB,iBAAiB,EAAEiB,qBAAA,CAAUK;AANV,CAAvB;AASA;;AACA,IAAME,OAAO,GAAG,IAAAC,qBAAA,IAAY,IAAAC,kBAAA,EAAW1G,MAAX,EAAmBgC,UAAnB,CAAZ,CAAhB;;eACewE,O"}
1
+ {"version":3,"file":"FileViewer.js","names":["styles","theme","dialog","height","paper","content","textAlign","textarea","width","img","objectFit","dialogTitle","justifyContent","display","EXTENSIONS","images","code","txt","audio","video","bufferToBase64","buffer","binary","bytes","Uint8Array","len","byteLength","i","String","fromCharCode","window","btoa","FileViewer","props","id","fileName","size","state","changed","timeout","clearTimeout","setTimeout","alert","text","readFile","setState","forceUpdate","Date","now","parts","href","split","data","editingValue","splice","adapter","name","join","ext","Utils","getFileExtension","editing","copyPossible","includes","imgError","socket","then","file","undefined","newState","type","detectMimeType","e","supportSubscribes","subscribeFiles","onFileChanged","clsx","classes","getClassBackgroundImage","target","onerror","newValue","readOnly","scrollPaper","onClose","t","setStateBackgroundImage","getContent","copyToClipboard","writeFile64","Component","propTypes","PropTypes","func","lang","string","expertMode","bool","isRequired","_export","withWidth","withStyles"],"sources":["FileViewer.js"],"sourcesContent":["import React, { Component } from 'react';\nimport { withStyles } from '@mui/styles';\nimport PropTypes from 'prop-types';\n\n// File viewer in adapter-react does not support write\n// import { Buffer } from 'buffer';\n\nimport TextField from '@mui/material/TextField';\nimport Button from '@mui/material/Button';\nimport Dialog from '@mui/material/Dialog';\nimport DialogActions from '@mui/material/DialogActions';\nimport DialogContent from '@mui/material/DialogContent';\nimport DialogTitle from '@mui/material/DialogTitle';\nimport { IconButton } from '@mui/material';\n\nimport IconNoIcon from '../icons/IconNoIcon';\nimport withWidth from './withWidth';\nimport Utils from './Utils';\n\n// Icons\nimport { FaCopy as CopyIcon } from 'react-icons/fa';\nimport Brightness5Icon from '@mui/icons-material/Brightness6';\nimport CloseIcon from '@mui/icons-material/Close';\nimport SaveIcon from '@mui/icons-material/Save';\n\nconst styles = theme => ({\n dialog: {\n height: '100%',\n },\n paper: {\n height: 'calc(100% - 64px)',\n },\n content: {\n textAlign: 'center',\n },\n textarea: {\n width: '100%',\n height: '100%',\n },\n img: {\n width: 'auto',\n height: 'calc(100% - 5px)',\n objectFit: 'contain',\n },\n dialogTitle: {\n justifyContent: 'space-between',\n display: 'flex'\n }\n});\n\nexport const EXTENSIONS = {\n images: ['png', 'jpg', 'svg', 'jpeg', 'bmp'],\n code: ['js', 'json', 'json5', 'md'],\n txt: ['log', 'txt', 'html', 'css', 'xml'],\n audio: ['mp3', 'wav', 'ogg', 'acc'],\n video: ['mp4', 'mov', 'avi'],\n};\n\nfunction bufferToBase64(buffer) {\n let binary = '';\n let bytes = new Uint8Array(buffer);\n let len = bytes.byteLength;\n for (let i = 0; i < len && i < 50; i++) {\n binary += String.fromCharCode(bytes[i]);\n }\n return window.btoa(binary);\n}\n\n/**\n * @typedef {object} FileViewerProps\n * @property {import('../types').Translator} t Translation function\n * @property {ioBroker.Languages} [lang] The selected language.\n * @property {boolean} [expertMode] Is expert mode enabled? (default: false)\n * @property {() => void} onClose Callback when the viewer is closed.\n * @property {string} href The URL to the file to be displayed.\n *\n * @extends {React.Component<FileViewerProps>}\n */\nclass FileViewer extends Component {\n /**\n * @param {Readonly<FileViewerProps>} props\n */\n constructor(props) {\n super(props);\n const ext = Utils.getFileExtension(this.props.href);\n\n this.state = {\n text: null,\n code: null,\n ext,\n // File viewer in adapter-react does not support write\n editing: /* !!this.props.formatEditFile || */ false,\n editingValue: null,\n copyPossible: EXTENSIONS.code.includes(ext) || EXTENSIONS.txt.includes(ext),\n forceUpdate: Date.now(),\n changed: false,\n imgError: false,\n };\n }\n\n readFile() {\n if (this.props.href) {\n const parts = this.props.href.split('/');\n parts.splice(0, 2);\n const adapter = parts[0];\n const name = parts.splice(1).join('/');\n\n this.props.socket.readFile(adapter, name)\n .then(data => {\n if (data.file !== undefined) {\n data = data.file;\n }\n\n const newState = {copyPossible: this.state.copyPossible};\n // try to detect valid extension\n if (data.type === 'Buffer') {\n const ext = Utils.detectMimeType(bufferToBase64(data.data));\n if (ext) {\n newState.ext = ext;\n newState.copyPossible = EXTENSIONS.code.includes(ext) || EXTENSIONS.txt.includes(ext);\n }\n }\n\n if (newState.copyPossible) {\n if (EXTENSIONS.txt.includes(this.state.ext)) {\n newState.text = data;\n newState.editingValue = data;\n } else if (EXTENSIONS.code.includes(this.state.ext)) {\n newState.code = data;\n newState.editingValue = data;\n }\n }\n\n this.setState(newState);\n })\n .catch(e => window.alert('Cannot read file: ' + e));\n }\n }\n\n componentDidMount() {\n this.readFile();\n\n const parts = this.props.href.split('/');\n parts.splice(0, 2);\n const adapter = parts[0];\n const name = parts.splice(1).join('/');\n\n this.props.supportSubscribes && this.props.socket.subscribeFiles(adapter, name, this.onFileChanged);\n }\n\n componentWillUnmount() {\n this.timeout && clearTimeout(this.timeout);\n const parts = this.props.href.split('/');\n parts.splice(0, 2);\n const adapter = parts[0];\n const name = parts.splice(1).join('/');\n this.props.supportSubscribes && this.props.socket.subscribeFiles(adapter, name, this.onFileChanged);\n }\n\n onFileChanged = (id, fileName, size) => {\n if (!this.state.changed) {\n this.timeout && clearTimeout(this.timeout);\n this.timeout = setTimeout(() => {\n this.timeout = null;\n if (size === null) {\n window.alert('Show file was deleted!');\n } else if (this.state.text !== null || this.state.code !== null) {\n this.readFile();\n } else {\n this.setState({ forceUpdate: Date.now() });\n }\n }, 300);\n }\n };\n\n writeFile64 = () => {\n const parts = this.props.href.split('/');\n const data = this.state.editingValue;\n parts.splice(0, 2);\n const adapter = parts[0];\n const name = parts.splice(1).join('/');\n // File viewer in adapter-react does not support write\n /*\n this.props.socket.writeFile64(adapter, name, Buffer.from(data).toString('base64'))\n .then(_ => this.props.onClose())\n .catch(e => window.alert('Cannot write file: ' + e));\n */\n }\n\n static getEditFile(ext) {\n switch (ext) {\n case 'json':\n return 'json';\n case 'json5':\n return 'json5';\n case 'js':\n return 'javascript';\n case 'html':\n return 'html';\n case 'txt':\n return 'html';\n default:\n return 'json';\n }\n }\n\n getContent() {\n if (EXTENSIONS.images.includes(this.state.ext)) {\n if (this.state.imgError) {\n return <IconNoIcon className={Utils.clsx(this.props.classes.img, this.props.getClassBackgroundImage())} />;\n } else {\n return <img\n onError={e => {\n e.target.onerror = null;\n this.setState({ imgError: true });\n }}\n className={Utils.clsx(this.props.classes.img, this.props.getClassBackgroundImage())}\n src={this.props.href + '?ts=' + this.state.forceUpdate}\n alt={this.props.href}\n />;\n }\n } else if (this.state.code !== null || this.state.text !== null || this.state.editing) {\n return <TextField\n variant=\"standard\"\n className={ this.props.classes.textarea }\n multiline\n value={ this.state.editingValue || this.state.code || this.state.text }\n onChange={newValue => this.setState({ editingValue: newValue, changed: true })}\n InputProps={{ readOnly: !this.state.editing }}\n />;\n }\n }\n\n render() {\n return <Dialog\n classes={{ scrollPaper: this.props.classes.dialog, paper: this.props.classes.paper }}\n scroll=\"paper\"\n open={!!this.props.href}\n onClose={() => this.props.onClose()}\n fullWidth={true}\n maxWidth=\"xl\"\n aria-labelledby=\"form-dialog-title\"\n >\n <div className={this.props.classes.dialogTitle}>\n <DialogTitle id=\"form-dialog-title\">{this.props.t(this.state.editing ? 'Edit' : 'View') + ': ' + this.props.href}</DialogTitle>\n {EXTENSIONS.images.includes(this.state.ext) && <div>\n <IconButton size=\"large\"\n color={'inherit'}\n onClick={this.props.setStateBackgroundImage}\n >\n <Brightness5Icon />\n </IconButton>\n </div>\n }\n </div>\n <DialogContent className={this.props.classes.content}>\n {this.getContent()}\n </DialogContent>\n <DialogActions>\n {this.state.copyPossible ?\n <Button\n color=\"grey\"\n onClick={e => Utils.copyToClipboard(this.state.text || this.state.code, e)}\n startIcon={<CopyIcon />}\n >\n {this.props.t('Copy content')}\n </Button> : null}\n {this.state.editing ?\n <Button\n color=\"grey\"\n disabled={this.state.editingValue === this.state.code || this.state.editingValue === this.state.text}\n variant=\"contained\"\n onClick={this.writeFile64}\n startIcon={<SaveIcon />}\n >\n {this.props.t('Save')}\n </Button> : null}\n <Button\n variant=\"contained\"\n onClick={() => this.props.onClose()}\n color=\"primary\"\n startIcon={<CloseIcon />}\n >\n {this.props.t('Close')}\n </Button>\n </DialogActions>\n </Dialog>;\n }\n}\n\nFileViewer.propTypes = {\n t: PropTypes.func,\n lang: PropTypes.string,\n expertMode: PropTypes.bool,\n onClose: PropTypes.func,\n href: PropTypes.string.isRequired,\n supportSubscribes: PropTypes.bool,\n};\n\n/** @type {typeof FileViewer} */\nconst _export = withWidth()(withStyles(styles)(FileViewer));\nexport default _export;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AAKA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAEA;;AACA;;AACA;;AAGA;;AACA;;AACA;;AACA;;;;;;;;;;AAEA,IAAMA,MAAM,GAAG,SAATA,MAAS,CAAAC,KAAK;EAAA,OAAK;IACrBC,MAAM,EAAE;MACJC,MAAM,EAAE;IADJ,CADa;IAIrBC,KAAK,EAAE;MACHD,MAAM,EAAE;IADL,CAJc;IAOrBE,OAAO,EAAE;MACLC,SAAS,EAAE;IADN,CAPY;IAUrBC,QAAQ,EAAE;MACNC,KAAK,EAAE,MADD;MAENL,MAAM,EAAE;IAFF,CAVW;IAcrBM,GAAG,EAAE;MACDD,KAAK,EAAE,MADN;MAEDL,MAAM,EAAE,kBAFP;MAGDO,SAAS,EAAE;IAHV,CAdgB;IAmBrBC,WAAW,EAAE;MACTC,cAAc,EAAE,eADP;MAETC,OAAO,EAAE;IAFA;EAnBQ,CAAL;AAAA,CAApB;;AAyBO,IAAMC,UAAU,GAAG;EACtBC,MAAM,EAAE,CAAC,KAAD,EAAQ,KAAR,EAAe,KAAf,EAAsB,MAAtB,EAA8B,KAA9B,CADc;EAEtBC,IAAI,EAAI,CAAC,IAAD,EAAO,MAAP,EAAe,OAAf,EAAwB,IAAxB,CAFc;EAGtBC,GAAG,EAAK,CAAC,KAAD,EAAQ,KAAR,EAAe,MAAf,EAAuB,KAAvB,EAA8B,KAA9B,CAHc;EAItBC,KAAK,EAAG,CAAC,KAAD,EAAQ,KAAR,EAAe,KAAf,EAAsB,KAAtB,CAJc;EAKtBC,KAAK,EAAG,CAAC,KAAD,EAAQ,KAAR,EAAe,KAAf;AALc,CAAnB;;;AAQP,SAASC,cAAT,CAAwBC,MAAxB,EAAgC;EAC5B,IAAIC,MAAM,GAAG,EA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;EACnBN,CAAC,EAAEO,qBAAA,CAAUC,IADM;EAEnBC,IAAI,EAAEF,qBAAA,CAAUG,MAFG;EAGnBC,UAAU,EAAEJ,qBAAA,CAAUK,IAHH;EAInBb,OAAO,EAAEQ,qBAAA,CAAUC,IAJA;EAKnB3C,IAAI,EAAE0C,qBAAA,CAAUG,MAAV,CAAiBG,UALJ;EAMnBzB,iBAAiB,EAAEmB,qBAAA,CAAUK;AANV,CAAvB;AASA;;AACA,IAAME,OAAO,GAAG,IAAAC,qBAAA,IAAY,IAAAC,kBAAA,EAAWrG,MAAX,EAAmBgC,UAAnB,CAAZ,CAAhB;;eACemE,O"}
@@ -0,0 +1,21 @@
1
+ export function getSystemIcon(obj: any): JSX.Element;
2
+ export function getSelectIdIcon(obj: any, imagePrefix: any): string;
3
+ export default Icon;
4
+ declare class Icon extends React.Component<any, any, any> {
5
+ constructor(props: any);
6
+ constructor(props: any, context: any);
7
+ render(): any;
8
+ }
9
+ declare namespace Icon {
10
+ namespace propTypes {
11
+ const color: PropTypes.Requireable<string>;
12
+ const title: PropTypes.Requireable<string>;
13
+ const src: PropTypes.Validator<string | object>;
14
+ const className: PropTypes.Requireable<string>;
15
+ const imagePrefix: PropTypes.Requireable<string>;
16
+ const style: PropTypes.Requireable<object>;
17
+ const styleUTF8: PropTypes.Requireable<object>;
18
+ }
19
+ }
20
+ import React from "react";
21
+ import PropTypes from "prop-types";
@@ -0,0 +1,64 @@
1
+ export default IconPicker;
2
+ export type IconPickerProps = {
3
+ /**
4
+ * The value.
5
+ */
6
+ value?: string;
7
+ /**
8
+ * The label.
9
+ */
10
+ label?: string;
11
+ /**
12
+ * Set to true to disable the icon picker.
13
+ */
14
+ disabled?: boolean;
15
+ /**
16
+ * The icon change callback.
17
+ */
18
+ onChange: (icon: string) => void;
19
+ /**
20
+ * The socket connection.
21
+ */
22
+ socket: import('../Connection').default;
23
+ /**
24
+ * The image prefix (default: './files/')
25
+ */
26
+ imagePrefix?: string;
27
+ /**
28
+ * Additional styling for this component.
29
+ */
30
+ style?: React.CSSProperties;
31
+ /**
32
+ * The CSS class name.
33
+ */
34
+ className?: string;
35
+ };
36
+ /**
37
+ * @typedef {object} IconPickerProps
38
+ * @property {string} [value] The value.
39
+ * @property {string} [label] The label.
40
+ * @property {boolean} [disabled] Set to true to disable the icon picker.
41
+ * @property {(icon: string) => void} onChange The icon change callback.
42
+ * @property {import('../Connection').default} socket The socket connection.
43
+ * @property {string} [imagePrefix] The image prefix (default: './files/')
44
+ * @property {React.CSSProperties} [style] Additional styling for this component.
45
+ * @property {string} [className] The CSS class name.
46
+ *
47
+ * @extends {React.Component<IconPickerProps>}
48
+ */
49
+ declare function IconPicker(props: any): JSX.Element;
50
+ declare namespace IconPicker {
51
+ namespace propTypes {
52
+ const previewClassName: PropTypes.Requireable<string>;
53
+ const icon: PropTypes.Requireable<object>;
54
+ const customClasses: PropTypes.Requireable<object>;
55
+ const label: PropTypes.Requireable<string>;
56
+ const value: PropTypes.Requireable<any>;
57
+ const disabled: PropTypes.Requireable<boolean>;
58
+ const onChange: PropTypes.Validator<(...args: any[]) => any>;
59
+ const icons: PropTypes.Requireable<any[]>;
60
+ const onlyRooms: PropTypes.Requireable<boolean>;
61
+ const onlyDevices: PropTypes.Requireable<boolean>;
62
+ }
63
+ }
64
+ import PropTypes from "prop-types";
@@ -0,0 +1,25 @@
1
+ export default IconSelector;
2
+ declare class IconSelector extends React.Component<any, any, any> {
3
+ constructor(props: any);
4
+ state: {
5
+ opened: boolean;
6
+ names: any[];
7
+ filter: string;
8
+ icons: any;
9
+ };
10
+ loadAllIcons(): void;
11
+ render(): JSX.Element;
12
+ }
13
+ declare namespace IconSelector {
14
+ namespace propTypes {
15
+ const icons: PropTypes.Requireable<any[]>;
16
+ const onlyRooms: PropTypes.Requireable<boolean>;
17
+ const onlyDevices: PropTypes.Requireable<boolean>;
18
+ const onSelect: PropTypes.Requireable<(...args: any[]) => any>;
19
+ const onChange: PropTypes.Requireable<(...args: any[]) => any>;
20
+ const t: PropTypes.Validator<(...args: any[]) => any>;
21
+ const lang: PropTypes.Validator<string>;
22
+ }
23
+ }
24
+ import React from "react";
25
+ import PropTypes from "prop-types";