@iobroker/adapter-react-v5 2.1.7 → 2.1.11
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.
- package/Components/404.js +17 -25
- package/Components/404.js.map +1 -1
- package/Components/ColorPicker.js +25 -35
- package/Components/ColorPicker.js.map +1 -1
- package/Components/ComplexCron.js +29 -37
- package/Components/ComplexCron.js.map +1 -1
- package/Components/FileBrowser.js +281 -276
- package/Components/FileBrowser.js.map +1 -1
- package/Components/FileViewer.js +230 -96
- package/Components/FileViewer.js.map +1 -1
- package/Components/Icon.js +15 -25
- package/Components/Icon.js.map +1 -1
- package/Components/IconPicker.js +6 -6
- package/Components/IconPicker.js.map +1 -1
- package/Components/IconSelector.js +25 -31
- package/Components/IconSelector.js.map +1 -1
- package/Components/Image.js +15 -25
- package/Components/Image.js.map +1 -1
- package/Components/Loader.js +14 -24
- package/Components/Loader.js.map +1 -1
- package/Components/Loaders/PT.js +13 -23
- package/Components/Loaders/PT.js.map +1 -1
- package/Components/Loaders/Vendor.js +14 -24
- package/Components/Loaders/Vendor.js.map +1 -1
- package/Components/Logo.js +15 -25
- package/Components/Logo.js.map +1 -1
- package/Components/MDUtils.js +14 -11
- package/Components/MDUtils.js.map +1 -1
- package/Components/ObjectBrowser.js +127 -210
- package/Components/ObjectBrowser.js.map +1 -1
- package/Components/Router.js +13 -21
- package/Components/Router.js.map +1 -1
- package/Components/SaveCloseButtons.js +15 -25
- package/Components/SaveCloseButtons.js.map +1 -1
- package/Components/Schedule.js +23 -37
- package/Components/Schedule.js.map +1 -1
- package/Components/SelectWithIcon.js +17 -25
- package/Components/SelectWithIcon.js.map +1 -1
- package/Components/SimpleCron/cronText.js +2 -2
- package/Components/SimpleCron/cronText.js.map +1 -1
- package/Components/SimpleCron/index.js +24 -34
- package/Components/SimpleCron/index.js.map +1 -1
- package/Components/TabContainer.js +18 -28
- package/Components/TabContainer.js.map +1 -1
- package/Components/TabContent.js +17 -27
- package/Components/TabContent.js.map +1 -1
- package/Components/TabHeader.js +13 -23
- package/Components/TabHeader.js.map +1 -1
- package/Components/TextWithIcon.js +5 -5
- package/Components/TextWithIcon.js.map +1 -1
- package/Components/ToggleThemeMenu.js +2 -2
- package/Components/ToggleThemeMenu.js.map +1 -1
- package/Components/TreeTable.js +21 -42
- package/Components/TreeTable.js.map +1 -1
- package/Components/Utils.js +56 -42
- package/Components/Utils.js.map +1 -1
- package/Components/withWidth.js +42 -0
- package/Components/withWidth.js.map +1 -0
- package/Connection.js +15 -22
- package/Connection.js.map +1 -1
- package/Dialogs/ComplexCron.js +15 -25
- package/Dialogs/ComplexCron.js.map +1 -1
- package/Dialogs/Confirm.js +15 -25
- package/Dialogs/Confirm.js.map +1 -1
- package/Dialogs/Cron.js +19 -27
- package/Dialogs/Cron.js.map +1 -1
- package/Dialogs/Error.js +15 -25
- package/Dialogs/Error.js.map +1 -1
- package/Dialogs/Message.js +15 -25
- package/Dialogs/Message.js.map +1 -1
- package/Dialogs/SelectID.js +19 -27
- package/Dialogs/SelectID.js.map +1 -1
- package/Dialogs/SimpleCron.js +15 -25
- package/Dialogs/SimpleCron.js.map +1 -1
- package/Dialogs/TextInput.js +18 -28
- package/Dialogs/TextInput.js.map +1 -1
- package/GenericApp.js +37 -49
- package/GenericApp.js.map +1 -1
- package/README.md +12 -1
- package/Theme.js +2 -2
- package/Theme.js.map +1 -1
- package/i18n.js +10 -14
- package/i18n.js.map +1 -1
- package/icons/IconAdapter.js +2 -2
- package/icons/IconAdapter.js.map +1 -1
- package/icons/IconAlias.js +2 -2
- package/icons/IconAlias.js.map +1 -1
- package/icons/IconChannel.js +2 -2
- package/icons/IconChannel.js.map +1 -1
- package/icons/IconClearFilter.js +2 -2
- package/icons/IconClearFilter.js.map +1 -1
- package/icons/IconClosed.js +2 -2
- package/icons/IconClosed.js.map +1 -1
- package/icons/IconCopy.js +2 -2
- package/icons/IconCopy.js.map +1 -1
- package/icons/IconDevice.js +2 -2
- package/icons/IconDevice.js.map +1 -1
- package/icons/IconDocument.js +2 -2
- package/icons/IconDocument.js.map +1 -1
- package/icons/IconExpert.js +2 -2
- package/icons/IconExpert.js.map +1 -1
- package/icons/IconFx.js +2 -2
- package/icons/IconFx.js.map +1 -1
- package/icons/IconInstance.js +2 -2
- package/icons/IconInstance.js.map +1 -1
- package/icons/IconLogout.js +2 -2
- package/icons/IconLogout.js.map +1 -1
- package/icons/IconOpen.js +2 -2
- package/icons/IconOpen.js.map +1 -1
- package/icons/IconState.js +6 -6
- package/icons/IconState.js.map +1 -1
- package/package.json +10 -10
package/Components/FileViewer.js
CHANGED
|
@@ -1,18 +1,38 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
var _typeof = require("@babel/runtime/helpers/typeof");
|
|
4
6
|
|
|
5
7
|
Object.defineProperty(exports, "__esModule", {
|
|
6
8
|
value: true
|
|
7
9
|
});
|
|
8
10
|
exports["default"] = exports.EXTENSIONS = void 0;
|
|
9
11
|
|
|
10
|
-
var
|
|
12
|
+
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
13
|
+
|
|
14
|
+
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
15
|
+
|
|
16
|
+
var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
|
|
17
|
+
|
|
18
|
+
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
|
|
19
|
+
|
|
20
|
+
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
|
|
11
21
|
|
|
12
|
-
var
|
|
22
|
+
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
|
|
23
|
+
|
|
24
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
25
|
+
|
|
26
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
27
|
+
|
|
28
|
+
var _styles = require("@mui/styles");
|
|
29
|
+
|
|
30
|
+
var _withWidth = _interopRequireDefault(require("./withWidth"));
|
|
13
31
|
|
|
14
32
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
15
33
|
|
|
34
|
+
var _TextField = _interopRequireDefault(require("@mui/material/TextField"));
|
|
35
|
+
|
|
16
36
|
var _Button = _interopRequireDefault(require("@mui/material/Button"));
|
|
17
37
|
|
|
18
38
|
var _Dialog = _interopRequireDefault(require("@mui/material/Dialog"));
|
|
@@ -23,7 +43,7 @@ var _DialogContent = _interopRequireDefault(require("@mui/material/DialogContent
|
|
|
23
43
|
|
|
24
44
|
var _DialogTitle = _interopRequireDefault(require("@mui/material/DialogTitle"));
|
|
25
45
|
|
|
26
|
-
var
|
|
46
|
+
var _material = require("@mui/material");
|
|
27
47
|
|
|
28
48
|
var _no_icon = _interopRequireDefault(require("../assets/no_icon.svg"));
|
|
29
49
|
|
|
@@ -31,49 +51,27 @@ var _Utils = _interopRequireDefault(require("./Utils"));
|
|
|
31
51
|
|
|
32
52
|
var _fa = require("react-icons/fa");
|
|
33
53
|
|
|
34
|
-
var
|
|
35
|
-
|
|
36
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
37
|
-
|
|
38
|
-
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
54
|
+
var _Brightness = _interopRequireDefault(require("@mui/icons-material/Brightness6"));
|
|
39
55
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
43
|
-
|
|
44
|
-
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
|
56
|
+
var _Close = _interopRequireDefault(require("@mui/icons-material/Close"));
|
|
45
57
|
|
|
46
|
-
|
|
58
|
+
var _Save = _interopRequireDefault(require("@mui/icons-material/Save"));
|
|
47
59
|
|
|
48
|
-
function
|
|
60
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
49
61
|
|
|
50
|
-
function
|
|
62
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
51
63
|
|
|
52
|
-
function
|
|
64
|
+
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2["default"])(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2["default"])(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2["default"])(this, result); }; }
|
|
53
65
|
|
|
54
66
|
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
55
67
|
|
|
56
|
-
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
57
|
-
|
|
58
|
-
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
59
|
-
|
|
60
|
-
// FIXME checkout https://mui.com/components/use-media-query/#migrating-from-withwidth
|
|
61
|
-
var withWidth = function withWidth() {
|
|
62
|
-
return function (WrappedComponent) {
|
|
63
|
-
return function (props) {
|
|
64
|
-
return /*#__PURE__*/_react["default"].createElement(WrappedComponent, _extends({}, props, {
|
|
65
|
-
width: "xs"
|
|
66
|
-
}));
|
|
67
|
-
};
|
|
68
|
-
};
|
|
69
|
-
};
|
|
70
|
-
|
|
71
68
|
var styles = function styles(theme) {
|
|
72
69
|
return {
|
|
73
70
|
dialog: {
|
|
74
|
-
height: '100%'
|
|
75
|
-
|
|
76
|
-
|
|
71
|
+
height: '100%'
|
|
72
|
+
},
|
|
73
|
+
paper: {
|
|
74
|
+
height: 'calc(100% - 64px)'
|
|
77
75
|
},
|
|
78
76
|
content: {
|
|
79
77
|
textAlign: 'center'
|
|
@@ -86,15 +84,32 @@ var styles = function styles(theme) {
|
|
|
86
84
|
width: 'auto',
|
|
87
85
|
height: 'calc(100% - 5px)',
|
|
88
86
|
objectFit: 'contain'
|
|
87
|
+
},
|
|
88
|
+
dialogTitle: {
|
|
89
|
+
justifyContent: 'space-between',
|
|
90
|
+
display: 'flex'
|
|
89
91
|
}
|
|
90
92
|
};
|
|
91
93
|
};
|
|
92
94
|
|
|
93
95
|
var EXTENSIONS = {
|
|
94
|
-
images: ['png', 'jpg', 'svg', 'jpeg', '
|
|
95
|
-
code: ['js', 'json'],
|
|
96
|
+
images: ['png', 'jpg', 'svg', 'jpeg', 'bmp'],
|
|
97
|
+
code: ['js', 'json', 'md'],
|
|
96
98
|
txt: ['log', 'txt', 'html', 'css', 'xml']
|
|
97
99
|
};
|
|
100
|
+
exports.EXTENSIONS = EXTENSIONS;
|
|
101
|
+
|
|
102
|
+
function bufferToBase64(buffer) {
|
|
103
|
+
var binary = '';
|
|
104
|
+
var bytes = new Uint8Array(buffer);
|
|
105
|
+
var len = bytes.byteLength;
|
|
106
|
+
|
|
107
|
+
for (var i = 0; i < len && i < 50; i++) {
|
|
108
|
+
binary += String.fromCharCode(bytes[i]);
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
return window.btoa(binary);
|
|
112
|
+
}
|
|
98
113
|
/**
|
|
99
114
|
* @typedef {object} FileViewerProps
|
|
100
115
|
* @property {string} [key] The key to identify this component.
|
|
@@ -107,10 +122,9 @@ var EXTENSIONS = {
|
|
|
107
122
|
* @extends {React.Component<FileViewerProps>}
|
|
108
123
|
*/
|
|
109
124
|
|
|
110
|
-
exports.EXTENSIONS = EXTENSIONS;
|
|
111
125
|
|
|
112
|
-
var FileViewer = /*#__PURE__*/function (
|
|
113
|
-
|
|
126
|
+
var FileViewer = /*#__PURE__*/function (_Component) {
|
|
127
|
+
(0, _inherits2["default"])(FileViewer, _Component);
|
|
114
128
|
|
|
115
129
|
var _super = _createSuper(FileViewer);
|
|
116
130
|
|
|
@@ -120,66 +134,169 @@ var FileViewer = /*#__PURE__*/function (_React$Component) {
|
|
|
120
134
|
function FileViewer(props) {
|
|
121
135
|
var _this;
|
|
122
136
|
|
|
123
|
-
|
|
124
|
-
|
|
137
|
+
(0, _classCallCheck2["default"])(this, FileViewer);
|
|
125
138
|
_this = _super.call(this, props);
|
|
126
|
-
|
|
139
|
+
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "onFileChanged", function (id, fileName, size) {
|
|
140
|
+
if (!_this.state.changed) {
|
|
141
|
+
_this.timeout && clearTimeout(_this.timeout);
|
|
142
|
+
_this.timeout = setTimeout(function () {
|
|
143
|
+
_this.timeout = null;
|
|
144
|
+
|
|
145
|
+
if (size === null) {
|
|
146
|
+
window.alert('Show file was deleted!');
|
|
147
|
+
} else if (_this.state.text !== null || _this.state.code !== null) {
|
|
148
|
+
_this.readFile();
|
|
149
|
+
} else {
|
|
150
|
+
_this.setState({
|
|
151
|
+
forceUpdate: Date.now()
|
|
152
|
+
});
|
|
153
|
+
}
|
|
154
|
+
}, 300);
|
|
155
|
+
}
|
|
156
|
+
});
|
|
157
|
+
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "writeFile64", function () {
|
|
158
|
+
var parts = _this.props.href.split('/');
|
|
159
|
+
|
|
160
|
+
var data = _this.state.editingValue;
|
|
161
|
+
parts.splice(0, 2);
|
|
162
|
+
var adapter = parts[0];
|
|
163
|
+
var name = parts.splice(1).join('/');
|
|
164
|
+
|
|
165
|
+
_this.props.socket.writeFile64(adapter, name, Buffer.from(data).toString('base64')).then(function (_) {
|
|
166
|
+
return _this.props.onClose();
|
|
167
|
+
})["catch"](function (e) {
|
|
168
|
+
return window.alert('Cannot write file: ' + e);
|
|
169
|
+
});
|
|
170
|
+
});
|
|
171
|
+
|
|
172
|
+
var ext = _Utils["default"].getFileExtension(_this.props.href);
|
|
173
|
+
|
|
127
174
|
_this.state = {
|
|
128
175
|
text: null,
|
|
129
176
|
code: null,
|
|
130
|
-
|
|
177
|
+
ext: ext,
|
|
178
|
+
editing: !!_this.props.formatEditFile || false,
|
|
179
|
+
editingValue: null,
|
|
180
|
+
copyPossible: EXTENSIONS.code.includes(ext) || EXTENSIONS.txt.includes(ext),
|
|
181
|
+
forceUpdate: Date.now(),
|
|
182
|
+
changed: false
|
|
131
183
|
};
|
|
184
|
+
return _this;
|
|
185
|
+
}
|
|
132
186
|
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
187
|
+
(0, _createClass2["default"])(FileViewer, [{
|
|
188
|
+
key: "readFile",
|
|
189
|
+
value: function readFile() {
|
|
190
|
+
var _this2 = this;
|
|
191
|
+
|
|
192
|
+
if (this.props.href) {
|
|
193
|
+
var parts = this.props.href.split('/');
|
|
194
|
+
parts.splice(0, 2);
|
|
195
|
+
var adapter = parts[0];
|
|
196
|
+
var name = parts.splice(1).join('/');
|
|
197
|
+
this.props.socket.readFile(adapter, name).then(function (data) {
|
|
198
|
+
if (data.file !== undefined) {
|
|
199
|
+
data = data.file;
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
var newState = {
|
|
203
|
+
copyPossible: _this2.state.copyPossible
|
|
204
|
+
}; // try to detect valid extension
|
|
205
|
+
|
|
206
|
+
if (data.type === 'Buffer') {
|
|
207
|
+
var ext = AdminUtils.detectMimeType(bufferToBase64(data.data));
|
|
208
|
+
|
|
209
|
+
if (ext) {
|
|
210
|
+
newState.ext = ext;
|
|
211
|
+
newState.copyPossible = EXTENSIONS.code.includes(ext) || EXTENSIONS.txt.includes(ext);
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
if (newState.copyPossible) {
|
|
216
|
+
if (EXTENSIONS.txt.includes(_this2.state.ext)) {
|
|
217
|
+
newState.text = data;
|
|
218
|
+
newState.editingValue = data;
|
|
219
|
+
} else if (EXTENSIONS.code.includes(_this2.state.ext)) {
|
|
220
|
+
newState.code = data;
|
|
221
|
+
newState.editingValue = data;
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
_this2.setState(newState);
|
|
226
|
+
})["catch"](function (e) {
|
|
227
|
+
return window.alert('Cannot read file: ' + e);
|
|
228
|
+
});
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
}, {
|
|
232
|
+
key: "componentDidMount",
|
|
233
|
+
value: function componentDidMount() {
|
|
234
|
+
this.readFile();
|
|
235
|
+
var parts = this.props.href.split('/');
|
|
236
|
+
parts.splice(0, 2);
|
|
237
|
+
var adapter = parts[0];
|
|
238
|
+
var name = parts.splice(1).join('/');
|
|
239
|
+
this.props.supportSubscribes && this.props.socket.subscribeFiles(adapter, name, this.onFileChanged);
|
|
240
|
+
}
|
|
241
|
+
}, {
|
|
242
|
+
key: "componentWillUnmount",
|
|
243
|
+
value: function componentWillUnmount() {
|
|
244
|
+
this.timeout && clearTimeout(this.timeout);
|
|
245
|
+
var parts = this.props.href.split('/');
|
|
246
|
+
parts.splice(0, 2);
|
|
247
|
+
var adapter = parts[0];
|
|
248
|
+
var name = parts.splice(1).join('/');
|
|
249
|
+
this.props.supportSubscribes && this.props.socket.subscribeFiles(adapter, name, this.onFileChanged);
|
|
147
250
|
}
|
|
251
|
+
}, {
|
|
252
|
+
key: "getEditFile",
|
|
253
|
+
value: function getEditFile(ext) {
|
|
254
|
+
switch (ext) {
|
|
255
|
+
case 'json':
|
|
256
|
+
return 'json';
|
|
148
257
|
|
|
149
|
-
|
|
150
|
-
|
|
258
|
+
case 'js':
|
|
259
|
+
return 'javascript';
|
|
260
|
+
|
|
261
|
+
case 'html':
|
|
262
|
+
return 'html';
|
|
263
|
+
|
|
264
|
+
case 'txt':
|
|
265
|
+
return 'html';
|
|
151
266
|
|
|
152
|
-
|
|
267
|
+
default:
|
|
268
|
+
return 'json';
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
}, {
|
|
153
272
|
key: "getContent",
|
|
154
273
|
value: function getContent() {
|
|
155
|
-
|
|
274
|
+
var _this3 = this;
|
|
275
|
+
|
|
276
|
+
if (EXTENSIONS.images.includes(this.state.ext)) {
|
|
156
277
|
return /*#__PURE__*/_react["default"].createElement("img", {
|
|
157
278
|
onError: function onError(e) {
|
|
158
279
|
e.target.onerror = null;
|
|
159
280
|
e.target.src = _no_icon["default"];
|
|
160
281
|
},
|
|
161
|
-
className: this.props.classes.img,
|
|
162
|
-
src: this.props.href,
|
|
282
|
+
className: _Utils["default"].clsx(this.props.classes.img, this.props.getClassBackgroundImage()),
|
|
283
|
+
src: this.props.href + '?ts=' + this.state.forceUpdate,
|
|
163
284
|
alt: this.props.href
|
|
164
285
|
});
|
|
165
|
-
} else if (this.state.code !== null) {
|
|
166
|
-
return /*#__PURE__*/_react["default"].createElement(_TextField["default"], {
|
|
167
|
-
variant: "standard",
|
|
168
|
-
className: this.props.classes.textarea,
|
|
169
|
-
multiline: true,
|
|
170
|
-
value: this.state.code,
|
|
171
|
-
InputProps: {
|
|
172
|
-
readOnly: true
|
|
173
|
-
}
|
|
174
|
-
});
|
|
175
|
-
} else if (this.state.text !== null) {
|
|
286
|
+
} else if (this.state.code !== null || this.state.text !== null || this.state.editing) {
|
|
176
287
|
return /*#__PURE__*/_react["default"].createElement(_TextField["default"], {
|
|
177
288
|
variant: "standard",
|
|
178
289
|
className: this.props.classes.textarea,
|
|
179
|
-
value: this.state.code,
|
|
180
290
|
multiline: true,
|
|
291
|
+
value: this.state.editingValue || this.state.code || this.state.text,
|
|
292
|
+
onChange: function onChange(newValue) {
|
|
293
|
+
return _this3.setState({
|
|
294
|
+
editingValue: newValue,
|
|
295
|
+
changed: true
|
|
296
|
+
});
|
|
297
|
+
},
|
|
181
298
|
InputProps: {
|
|
182
|
-
readOnly:
|
|
299
|
+
readOnly: !this.state.editing
|
|
183
300
|
}
|
|
184
301
|
});
|
|
185
302
|
}
|
|
@@ -187,50 +304,67 @@ var FileViewer = /*#__PURE__*/function (_React$Component) {
|
|
|
187
304
|
}, {
|
|
188
305
|
key: "render",
|
|
189
306
|
value: function render() {
|
|
190
|
-
var
|
|
307
|
+
var _this4 = this;
|
|
191
308
|
|
|
192
309
|
return /*#__PURE__*/_react["default"].createElement(_Dialog["default"], {
|
|
193
|
-
|
|
310
|
+
classes: {
|
|
311
|
+
scrollPaper: this.props.classes.dialog,
|
|
312
|
+
paper: this.props.classes.paper
|
|
313
|
+
},
|
|
314
|
+
scroll: "paper",
|
|
194
315
|
open: !!this.props.href,
|
|
195
316
|
onClose: function onClose() {
|
|
196
|
-
return
|
|
317
|
+
return _this4.props.onClose();
|
|
197
318
|
},
|
|
198
319
|
fullWidth: true,
|
|
199
|
-
|
|
320
|
+
maxWidth: "xl",
|
|
200
321
|
"aria-labelledby": "form-dialog-title"
|
|
322
|
+
}, /*#__PURE__*/_react["default"].createElement("div", {
|
|
323
|
+
className: this.props.classes.dialogTitle
|
|
201
324
|
}, /*#__PURE__*/_react["default"].createElement(_DialogTitle["default"], {
|
|
202
325
|
id: "form-dialog-title"
|
|
203
|
-
}, this.props.t('
|
|
326
|
+
}, this.props.t(this.state.editing ? 'Edit' : 'View') + ': ' + this.props.href), EXTENSIONS.images.includes(this.state.ext) && /*#__PURE__*/_react["default"].createElement("div", null, /*#__PURE__*/_react["default"].createElement(_material.IconButton, {
|
|
327
|
+
size: "large",
|
|
328
|
+
color: 'inherit',
|
|
329
|
+
onClick: this.props.setStateBackgroundImage
|
|
330
|
+
}, /*#__PURE__*/_react["default"].createElement(_Brightness["default"], null)))), /*#__PURE__*/_react["default"].createElement(_DialogContent["default"], {
|
|
204
331
|
className: this.props.classes.content
|
|
205
332
|
}, this.getContent()), /*#__PURE__*/_react["default"].createElement(_DialogActions["default"], null, this.state.copyPossible ? /*#__PURE__*/_react["default"].createElement(_Button["default"], {
|
|
206
333
|
color: "grey",
|
|
207
334
|
onClick: function onClick(e) {
|
|
208
|
-
return _Utils["default"].copyToClipboard(
|
|
209
|
-
}
|
|
210
|
-
|
|
335
|
+
return _Utils["default"].copyToClipboard(_this4.state.text || _this4.state.code, e);
|
|
336
|
+
},
|
|
337
|
+
startIcon: /*#__PURE__*/_react["default"].createElement(_fa.FaCopy, null)
|
|
338
|
+
}, this.props.t('Copy content')) : null, this.state.editing ? /*#__PURE__*/_react["default"].createElement(_Button["default"], {
|
|
339
|
+
color: "grey",
|
|
340
|
+
disabled: this.state.editingValue === this.state.code || this.state.editingValue === this.state.text,
|
|
341
|
+
variant: "contained",
|
|
342
|
+
onClick: this.writeFile64,
|
|
343
|
+
startIcon: /*#__PURE__*/_react["default"].createElement(_Save["default"], null)
|
|
344
|
+
}, this.props.t('Save')) : null, /*#__PURE__*/_react["default"].createElement(_Button["default"], {
|
|
345
|
+
variant: "contained",
|
|
211
346
|
onClick: function onClick() {
|
|
212
|
-
return
|
|
347
|
+
return _this4.props.onClose();
|
|
213
348
|
},
|
|
214
|
-
color: "primary"
|
|
215
|
-
|
|
349
|
+
color: "primary",
|
|
350
|
+
startIcon: /*#__PURE__*/_react["default"].createElement(_Close["default"], null)
|
|
351
|
+
}, this.props.t('Close'))));
|
|
216
352
|
}
|
|
217
|
-
}], [{
|
|
218
|
-
key: "getDerivedStateFromProps",
|
|
219
|
-
value: function getDerivedStateFromProps() {}
|
|
220
353
|
}]);
|
|
221
|
-
|
|
222
354
|
return FileViewer;
|
|
223
|
-
}(_react
|
|
355
|
+
}(_react.Component);
|
|
224
356
|
|
|
225
357
|
FileViewer.propTypes = {
|
|
226
358
|
t: _propTypes["default"].func,
|
|
359
|
+
lang: _propTypes["default"].string,
|
|
360
|
+
expertMode: _propTypes["default"].bool,
|
|
227
361
|
onClose: _propTypes["default"].func,
|
|
228
362
|
href: _propTypes["default"].string.isRequired,
|
|
229
|
-
|
|
363
|
+
supportSubscribes: _propTypes["default"].bool
|
|
230
364
|
};
|
|
231
365
|
/** @type {typeof FileViewer} */
|
|
232
366
|
|
|
233
|
-
var _export =
|
|
367
|
+
var _export = (0, _withWidth["default"])()((0, _styles.withStyles)(styles)(FileViewer));
|
|
234
368
|
|
|
235
369
|
var _default = _export;
|
|
236
370
|
exports["default"] = _default;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FileViewer.js","names":["withWidth","WrappedComponent","props","styles","theme","dialog","height","maxHeight","maxWidth","content","textAlign","textarea","width","img","objectFit","EXTENSIONS","images","code","txt","FileViewer","ext","Utils","getFileExtension","href","state","text","copyPossible","includes","fetch","then","response","data","setState","e","target","onerror","src","NoImage","classes","readOnly","onClose","fullScreen","undefined","t","getContent","copyToClipboard","React","Component","propTypes","PropTypes","func","string","isRequired","bool","_export"],"sources":["FileViewer.js"],"sourcesContent":["import React from 'react';\nimport withStyles from '@mui/styles/withStyles';\nimport PropTypes from 'prop-types';\n\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 TextField from '@mui/material/TextField';\n\nimport NoImage from '../assets/no_icon.svg';\nimport Utils from './Utils';\n\n// Icons\nimport {FaCopy as CopyIcon} from 'react-icons/fa';\nimport CloseIcon from '@mui/icons-material/Close';\n\n// FIXME checkout https://mui.com/components/use-media-query/#migrating-from-withwidth\nconst withWidth = () => WrappedComponent => props => <WrappedComponent {...props} width=\"xs\" />;\n\nconst styles = theme => ({\n dialog: {\n height: '100%',\n maxHeight: '100%',\n maxWidth: '100%',\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});\n\nexport const EXTENSIONS = {\n images: ['png', 'jpg', 'svg', 'jpeg', 'jpg'],\n code: ['js', 'json'],\n txt: ['log', 'txt', 'html', 'css', 'xml'],\n};\n\n/**\n * @typedef {object} FileViewerProps\n * @property {string} [key] The key to identify this component.\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 React.Component {\n /**\n * @param {Readonly<FileViewerProps>} props\n */\n constructor(props) {\n super(props);\n\n this.ext = Utils.getFileExtension(this.props.href);\n\n this.state = {\n text: null,\n code: null,\n copyPossible: EXTENSIONS.code.includes(this.ext) || EXTENSIONS.txt.includes(this.ext),\n };\n\n if (this.state.copyPossible) {\n fetch(this.props.href)\n .then(response => response.text())\n .then(data => {\n if (EXTENSIONS.txt.includes(this.ext)) {\n this.setState({ text: data });\n } else if (EXTENSIONS.code.includes(this.ext)) {\n this.setState({ code: data });\n }\n });\n }\n }\n\n static getDerivedStateFromProps() {\n\n }\n\n getContent() {\n if (EXTENSIONS.images.includes(this.ext)) {\n return <img\n onError={ e => {\n e.target.onerror = null;\n e.target.src = NoImage;\n }}\n className={ this.props.classes.img }\n src={ this.props.href }\n alt={ this.props.href }\n />;\n } else if (this.state.code !== null) {\n return <TextField\n variant=\"standard\"\n className={ this.props.classes.textarea }\n multiline\n value={ this.state.code }\n InputProps={{\n readOnly: true,\n }}\n />;\n } else if (this.state.text !== null) {\n return <TextField\n variant=\"standard\"\n className={ this.props.classes.textarea }\n value={ this.state.code }\n multiline\n InputProps={{\n readOnly: true,\n }}\n />;\n }\n }\n\n render() {\n return <Dialog\n className={ this.props.classes.dialog }\n open={ !!this.props.href }\n onClose={ () => this.props.onClose() }\n fullWidth\n fullScreen={this.props.fullScreen !== undefined ? this.props.fullScreen : true}\n aria-labelledby=\"form-dialog-title\"\n >\n <DialogTitle id=\"form-dialog-title\">{ this.props.t('ra_View: %s', this.props.href) }</DialogTitle>\n <DialogContent className={ this.props.classes.content }>\n { this.getContent() }\n </DialogContent>\n <DialogActions>\n { this.state.copyPossible ? <Button color=\"grey\" onClick={e => Utils.copyToClipboard(this.state.text || this.state.code, e) } >\n <CopyIcon />\n { this.props.t('ra_Copy content') }\n </Button> : null }\n\n <Button onClick={() => this.props.onClose()} color=\"primary\">\n <CloseIcon />\n { this.props.t('ra_Close') }\n </Button>\n </DialogActions>\n </Dialog>;\n }\n}\n\nFileViewer.propTypes = {\n t: PropTypes.func,\n\n onClose: PropTypes.func,\n href: PropTypes.string.isRequired,\n fullScreen: PropTypes.bool,\n};\n\n/** @type {typeof FileViewer} */\nconst _export = withWidth()(withStyles(styles)(FileViewer));\nexport default _export;\n"],"mappings":";;;;;;;;;AAAA;;AACA;;AACA;;AAEA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAEA;;AACA;;AAGA;;AACA;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA;AACA,IAAMA,SAAS,GAAG,SAAZA,SAAY;EAAA,OAAM,UAAAC,gBAAgB;IAAA,OAAI,UAAAC,KAAK;MAAA,oBAAI,gCAAC,gBAAD,eAAsBA,KAAtB;QAA6B,KAAK,EAAC;MAAnC,GAAJ;IAAA,CAAT;EAAA,CAAtB;AAAA,CAAlB;;AAEA,IAAMC,MAAM,GAAG,SAATA,MAAS,CAAAC,KAAK;EAAA,OAAK;IACrBC,MAAM,EAAE;MACJC,MAAM,EAAE,MADJ;MAEJC,SAAS,EAAE,MAFP;MAGJC,QAAQ,EAAE;IAHN,CADa;IAMrBC,OAAO,EAAE;MACLC,SAAS,EAAE;IADN,CANY;IASrBC,QAAQ,EAAE;MACNC,KAAK,EAAE,MADD;MAENN,MAAM,EAAE;IAFF,CATW;IAarBO,GAAG,EAAE;MACDD,KAAK,EAAE,MADN;MAEDN,MAAM,EAAE,kBAFP;MAGDQ,SAAS,EAAE;IAHV;EAbgB,CAAL;AAAA,CAApB;;AAoBO,IAAMC,UAAU,GAAG;EACtBC,MAAM,EAAE,CAAC,KAAD,EAAQ,KAAR,EAAe,KAAf,EAAsB,MAAtB,EAA8B,KAA9B,CADc;EAEtBC,IAAI,EAAI,CAAC,IAAD,EAAO,MAAP,CAFc;EAGtBC,GAAG,EAAK,CAAC,KAAD,EAAQ,KAAR,EAAe,MAAf,EAAuB,KAAvB,EA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ACemC,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","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","file","undefined","newState","type","AdminUtils","detectMimeType","supportSubscribes","subscribeFiles","onFileChanged","target","onerror","src","NoImage","clsx","classes","getClassBackgroundImage","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 withWidth from './withWidth';\nimport PropTypes from 'prop-types';\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 NoImage from '../assets/no_icon.svg';\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', 'md'],\n txt: ['log', 'txt', 'html', 'css', 'xml'],\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 {string} [key] The key to identify this component.\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 };\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 = AdminUtils.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 getEditFile(ext) {\n switch (ext) {\n case 'json':\n return 'json';\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 return <img\n onError={e => {\n e.target.onerror = null;\n e.target.src = NoImage;\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 } 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;;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B;AASA;;AACA,IAAME,OAAO,GAAG,IAAAC,qBAAA,IAAY,IAAAC,kBAAA,EAAW1G,MAAX,EAAmB8B,UAAnB,CAAZ,CAAhB;;eACe0E,O"}
|
package/Components/Icon.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
4
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", {
|
|
6
6
|
value: true
|
|
@@ -9,6 +9,16 @@ exports["default"] = void 0;
|
|
|
9
9
|
exports.getSelectIdIcon = getSelectIdIcon;
|
|
10
10
|
exports.getSystemIcon = getSystemIcon;
|
|
11
11
|
|
|
12
|
+
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
13
|
+
|
|
14
|
+
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
15
|
+
|
|
16
|
+
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
|
|
17
|
+
|
|
18
|
+
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
|
|
19
|
+
|
|
20
|
+
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
|
|
21
|
+
|
|
12
22
|
var _react = _interopRequireDefault(require("react"));
|
|
13
23
|
|
|
14
24
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
@@ -35,28 +45,10 @@ var _IconAlias = _interopRequireDefault(require("../icons/IconAlias"));
|
|
|
35
45
|
|
|
36
46
|
var _Utils = _interopRequireDefault(require("./Utils"));
|
|
37
47
|
|
|
38
|
-
function
|
|
39
|
-
|
|
40
|
-
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
41
|
-
|
|
42
|
-
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
|
|
43
|
-
|
|
44
|
-
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
45
|
-
|
|
46
|
-
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
|
47
|
-
|
|
48
|
-
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
49
|
-
|
|
50
|
-
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
51
|
-
|
|
52
|
-
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
|
|
53
|
-
|
|
54
|
-
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
48
|
+
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2["default"])(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2["default"])(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2["default"])(this, result); }; }
|
|
55
49
|
|
|
56
50
|
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
57
51
|
|
|
58
|
-
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
59
|
-
|
|
60
52
|
function getSystemIcon(obj) {
|
|
61
53
|
var icon;
|
|
62
54
|
var id = obj === null || obj === void 0 ? void 0 : obj._id;
|
|
@@ -162,17 +154,16 @@ function getSelectIdIcon(obj, imagePrefix) {
|
|
|
162
154
|
}
|
|
163
155
|
|
|
164
156
|
var Icon = /*#__PURE__*/function (_React$Component) {
|
|
165
|
-
|
|
157
|
+
(0, _inherits2["default"])(Icon, _React$Component);
|
|
166
158
|
|
|
167
159
|
var _super = _createSuper(Icon);
|
|
168
160
|
|
|
169
161
|
function Icon() {
|
|
170
|
-
|
|
171
|
-
|
|
162
|
+
(0, _classCallCheck2["default"])(this, Icon);
|
|
172
163
|
return _super.apply(this, arguments);
|
|
173
164
|
}
|
|
174
165
|
|
|
175
|
-
|
|
166
|
+
(0, _createClass2["default"])(Icon, [{
|
|
176
167
|
key: "render",
|
|
177
168
|
value: function render() {
|
|
178
169
|
if (this.props.src) {
|
|
@@ -216,7 +207,6 @@ var Icon = /*#__PURE__*/function (_React$Component) {
|
|
|
216
207
|
}
|
|
217
208
|
}
|
|
218
209
|
}]);
|
|
219
|
-
|
|
220
210
|
return Icon;
|
|
221
211
|
}(_react["default"].Component);
|
|
222
212
|
|