@iobroker/adapter-react-v5 3.4.3 → 3.4.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Components/Utils.d.ts +0 -32
- package/Components/Utils.js +2 -123
- package/Components/Utils.js.map +1 -1
- package/Components/copy-to-clipboard.js +36 -35
- package/Components/copy-to-clipboard.js.map +1 -1
- package/Dialogs/SelectFile.d.ts +75 -21
- package/Dialogs/SelectFile.js +51 -35
- package/Dialogs/SelectFile.js.map +1 -1
- package/README.md +2 -2
- package/package.json +1 -1
- package/Dialogs/FileSelect.d.ts +0 -148
- package/Dialogs/FileSelect.js +0 -226
- package/Dialogs/FileSelect.js.map +0 -1
package/Dialogs/FileSelect.d.ts
DELETED
|
@@ -1,148 +0,0 @@
|
|
|
1
|
-
export default _export;
|
|
2
|
-
export type FileSelectDialogProps = {
|
|
3
|
-
/**
|
|
4
|
-
* The internal name of the dialog; default: "default"
|
|
5
|
-
*/
|
|
6
|
-
dialogName?: string;
|
|
7
|
-
/**
|
|
8
|
-
* The dialog title; default: Please select object ID... (translated)
|
|
9
|
-
*/
|
|
10
|
-
title?: string;
|
|
11
|
-
/**
|
|
12
|
-
* Prefix (default: '.')
|
|
13
|
-
*/
|
|
14
|
-
imagePrefix?: string;
|
|
15
|
-
/**
|
|
16
|
-
* Pre-selected file
|
|
17
|
-
*/
|
|
18
|
-
selected?: boolean;
|
|
19
|
-
/**
|
|
20
|
-
* Close handler that is always called when the dialog is closed.
|
|
21
|
-
*/
|
|
22
|
-
onClose: () => void;
|
|
23
|
-
/**
|
|
24
|
-
* Handler that is called when the user presses OK.
|
|
25
|
-
*/
|
|
26
|
-
onOk: (selected: string | undefined) => void;
|
|
27
|
-
/**
|
|
28
|
-
* The ok button text; default: OK (translated)
|
|
29
|
-
*/
|
|
30
|
-
ok?: string;
|
|
31
|
-
/**
|
|
32
|
-
* The cancel button text; default: Cancel (translated)
|
|
33
|
-
*/
|
|
34
|
-
cancel?: string;
|
|
35
|
-
/**
|
|
36
|
-
* Socket class (required)
|
|
37
|
-
*/
|
|
38
|
-
socket?: boolean;
|
|
39
|
-
/**
|
|
40
|
-
* If download of files enabled
|
|
41
|
-
*/
|
|
42
|
-
allowUpload?: boolean;
|
|
43
|
-
/**
|
|
44
|
-
* If download of files enabled
|
|
45
|
-
*/
|
|
46
|
-
allowDownload?: boolean;
|
|
47
|
-
/**
|
|
48
|
-
* If creation of folders enabled
|
|
49
|
-
*/
|
|
50
|
-
allowCreateFolder?: boolean;
|
|
51
|
-
/**
|
|
52
|
-
* If creation of folders enabled
|
|
53
|
-
*/
|
|
54
|
-
allowDelete?: boolean;
|
|
55
|
-
/**
|
|
56
|
-
* if tile view enabled (default true)
|
|
57
|
-
*/
|
|
58
|
-
allowView?: boolean;
|
|
59
|
-
/**
|
|
60
|
-
* Show toolbar (default true)
|
|
61
|
-
*/
|
|
62
|
-
showToolbar?: boolean;
|
|
63
|
-
/**
|
|
64
|
-
* Limit file browser to one specific objectID of type meta and following path (like vis.0/main)
|
|
65
|
-
*/
|
|
66
|
-
limitPath?: any[];
|
|
67
|
-
/**
|
|
68
|
-
* like `['png', 'svg', 'bmp', 'jpg', 'jpeg']`
|
|
69
|
-
*/
|
|
70
|
-
filterFiles?: any[];
|
|
71
|
-
/**
|
|
72
|
-
* images, code, txt, audio, video
|
|
73
|
-
*/
|
|
74
|
-
filterByType?: string;
|
|
75
|
-
/**
|
|
76
|
-
* allow only folders selection
|
|
77
|
-
*/
|
|
78
|
-
selectOnlyFolders?: bool;
|
|
79
|
-
};
|
|
80
|
-
/** @type {typeof DialogFileSelect} */
|
|
81
|
-
declare const _export: typeof DialogFileSelect;
|
|
82
|
-
/**
|
|
83
|
-
* @typedef {object} FileSelectDialogProps
|
|
84
|
-
* @property {string} [dialogName] The internal name of the dialog; default: "default"
|
|
85
|
-
* @property {string} [title] The dialog title; default: Please select object ID... (translated)
|
|
86
|
-
* @property {string} [imagePrefix] Prefix (default: '.')
|
|
87
|
-
* @property {boolean} [dialogName] PropTypes.string, // where to store settings in localStorage
|
|
88
|
-
* @property {boolean} [selected] Pre-selected file
|
|
89
|
-
* @property {() => void} onClose Close handler that is always called when the dialog is closed.
|
|
90
|
-
* @property {(selected: string | undefined) => void} onOk Handler that is called when the user presses OK.
|
|
91
|
-
* @property {string} [ok] The ok button text; default: OK (translated)
|
|
92
|
-
* @property {string} [cancel] The cancel button text; default: Cancel (translated)
|
|
93
|
-
* @property {boolean} [socket] Socket class (required)
|
|
94
|
-
* @property {boolean} [allowUpload] If download of files enabled
|
|
95
|
-
* @property {boolean} [allowDownload] If download of files enabled
|
|
96
|
-
* @property {boolean} [allowCreateFolder] If creation of folders enabled
|
|
97
|
-
* @property {boolean} [allowDelete] If creation of folders enabled
|
|
98
|
-
* @property {boolean} [allowView] if tile view enabled (default true)
|
|
99
|
-
* @property {boolean} [showToolbar] Show toolbar (default true)
|
|
100
|
-
* @property {array} [limitPath] Limit file browser to one specific objectID of type meta and following path (like vis.0/main)
|
|
101
|
-
* @property {array} [filterFiles] like `['png', 'svg', 'bmp', 'jpg', 'jpeg']`
|
|
102
|
-
* @property {string} [filterByType] images, code, txt, audio, video
|
|
103
|
-
* @property {bool} [selectOnlyFolders] allow only folders selection
|
|
104
|
-
*
|
|
105
|
-
* @extends {React.Component<FileSelectDialogProps>}
|
|
106
|
-
*/
|
|
107
|
-
declare class DialogFileSelect extends React.Component<FileSelectDialogProps, any, any> {
|
|
108
|
-
/**
|
|
109
|
-
* @param {FileSelectDialogProps} props
|
|
110
|
-
*/
|
|
111
|
-
constructor(props: FileSelectDialogProps);
|
|
112
|
-
dialogName: string;
|
|
113
|
-
filters: any;
|
|
114
|
-
state: {
|
|
115
|
-
selected: string | true;
|
|
116
|
-
isFolder: boolean;
|
|
117
|
-
name: string;
|
|
118
|
-
isMobile: boolean;
|
|
119
|
-
};
|
|
120
|
-
handleCancel(): void;
|
|
121
|
-
handleOk(): void;
|
|
122
|
-
render(): JSX.Element;
|
|
123
|
-
}
|
|
124
|
-
declare namespace DialogFileSelect {
|
|
125
|
-
namespace propTypes {
|
|
126
|
-
const imagePrefix: PropTypes.Requireable<string>;
|
|
127
|
-
const dialogName: PropTypes.Requireable<string>;
|
|
128
|
-
const selected: PropTypes.Requireable<string>;
|
|
129
|
-
const onClose: PropTypes.Validator<(...args: any[]) => any>;
|
|
130
|
-
const onOk: PropTypes.Validator<(...args: any[]) => any>;
|
|
131
|
-
const ok: PropTypes.Requireable<string>;
|
|
132
|
-
const cancel: PropTypes.Requireable<string>;
|
|
133
|
-
const socket: PropTypes.Validator<object>;
|
|
134
|
-
const allowUpload: PropTypes.Requireable<boolean>;
|
|
135
|
-
const allowDownload: PropTypes.Requireable<boolean>;
|
|
136
|
-
const allowCreateFolder: PropTypes.Requireable<boolean>;
|
|
137
|
-
const allowDelete: PropTypes.Requireable<boolean>;
|
|
138
|
-
const allowView: PropTypes.Requireable<boolean>;
|
|
139
|
-
const showToolbar: PropTypes.Requireable<boolean>;
|
|
140
|
-
const objectID: PropTypes.Requireable<string>;
|
|
141
|
-
const filterFiles: PropTypes.Requireable<string[]>;
|
|
142
|
-
const filterByType: PropTypes.Requireable<string>;
|
|
143
|
-
const limitPath: PropTypes.Requireable<string>;
|
|
144
|
-
const selectOnlyFolders: PropTypes.Requireable<boolean>;
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
import React from "react";
|
|
148
|
-
import PropTypes from "prop-types";
|
package/Dialogs/FileSelect.js
DELETED
|
@@ -1,226 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
Object.defineProperty(exports, "__esModule", {
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
exports["default"] = void 0;
|
|
8
|
-
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
9
|
-
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
10
|
-
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
|
|
11
|
-
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
|
|
12
|
-
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
|
|
13
|
-
var _react = _interopRequireDefault(require("react"));
|
|
14
|
-
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
15
|
-
var _withStyles = _interopRequireDefault(require("@mui/styles/withStyles"));
|
|
16
|
-
var _Button = _interopRequireDefault(require("@mui/material/Button"));
|
|
17
|
-
var _DialogTitle = _interopRequireDefault(require("@mui/material/DialogTitle"));
|
|
18
|
-
var _DialogContent = _interopRequireDefault(require("@mui/material/DialogContent"));
|
|
19
|
-
var _DialogActions = _interopRequireDefault(require("@mui/material/DialogActions"));
|
|
20
|
-
var _Dialog = _interopRequireDefault(require("@mui/material/Dialog"));
|
|
21
|
-
var _Cancel = _interopRequireDefault(require("@mui/icons-material/Cancel"));
|
|
22
|
-
var _Check = _interopRequireDefault(require("@mui/icons-material/Check"));
|
|
23
|
-
var _i18n = _interopRequireDefault(require("../i18n"));
|
|
24
|
-
var _Utils = _interopRequireDefault(require("../Components/Utils"));
|
|
25
|
-
var _FileBrowser = _interopRequireDefault(require("../Components/FileBrowser"));
|
|
26
|
-
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); }; }
|
|
27
|
-
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; } }
|
|
28
|
-
var styles = function styles(theme) {
|
|
29
|
-
return {
|
|
30
|
-
headerID: {
|
|
31
|
-
fontWeight: 'bold',
|
|
32
|
-
fontStyle: 'italic'
|
|
33
|
-
},
|
|
34
|
-
dialog: {
|
|
35
|
-
height: '95%',
|
|
36
|
-
backgroundColor: theme.palette.mode === 'dark' ? '#303030' : '#fafafa'
|
|
37
|
-
},
|
|
38
|
-
dialogMobile: {
|
|
39
|
-
padding: 4,
|
|
40
|
-
width: '100%',
|
|
41
|
-
maxWidth: '100%',
|
|
42
|
-
maxHeight: 'calc(100% - 16px)',
|
|
43
|
-
height: '100%'
|
|
44
|
-
},
|
|
45
|
-
content: {
|
|
46
|
-
height: '100%',
|
|
47
|
-
overflow: 'hidden'
|
|
48
|
-
},
|
|
49
|
-
contentMobile: {
|
|
50
|
-
padding: '8px 4px'
|
|
51
|
-
},
|
|
52
|
-
titleRoot: {
|
|
53
|
-
whiteSpace: 'nowrap',
|
|
54
|
-
width: 'calc(100% - 72px)',
|
|
55
|
-
overflow: 'hidden',
|
|
56
|
-
display: 'inline-block',
|
|
57
|
-
textOverflow: 'ellipsis'
|
|
58
|
-
}
|
|
59
|
-
};
|
|
60
|
-
};
|
|
61
|
-
|
|
62
|
-
/**
|
|
63
|
-
* @typedef {object} FileSelectDialogProps
|
|
64
|
-
* @property {string} [dialogName] The internal name of the dialog; default: "default"
|
|
65
|
-
* @property {string} [title] The dialog title; default: Please select object ID... (translated)
|
|
66
|
-
* @property {string} [imagePrefix] Prefix (default: '.')
|
|
67
|
-
* @property {boolean} [dialogName] PropTypes.string, // where to store settings in localStorage
|
|
68
|
-
* @property {boolean} [selected] Pre-selected file
|
|
69
|
-
* @property {() => void} onClose Close handler that is always called when the dialog is closed.
|
|
70
|
-
* @property {(selected: string | undefined) => void} onOk Handler that is called when the user presses OK.
|
|
71
|
-
* @property {string} [ok] The ok button text; default: OK (translated)
|
|
72
|
-
* @property {string} [cancel] The cancel button text; default: Cancel (translated)
|
|
73
|
-
* @property {boolean} [socket] Socket class (required)
|
|
74
|
-
* @property {boolean} [allowUpload] If download of files enabled
|
|
75
|
-
* @property {boolean} [allowDownload] If download of files enabled
|
|
76
|
-
* @property {boolean} [allowCreateFolder] If creation of folders enabled
|
|
77
|
-
* @property {boolean} [allowDelete] If creation of folders enabled
|
|
78
|
-
* @property {boolean} [allowView] if tile view enabled (default true)
|
|
79
|
-
* @property {boolean} [showToolbar] Show toolbar (default true)
|
|
80
|
-
* @property {array} [limitPath] Limit file browser to one specific objectID of type meta and following path (like vis.0/main)
|
|
81
|
-
* @property {array} [filterFiles] like `['png', 'svg', 'bmp', 'jpg', 'jpeg']`
|
|
82
|
-
* @property {string} [filterByType] images, code, txt, audio, video
|
|
83
|
-
* @property {bool} [selectOnlyFolders] allow only folders selection
|
|
84
|
-
*
|
|
85
|
-
* @extends {React.Component<FileSelectDialogProps>}
|
|
86
|
-
*/
|
|
87
|
-
var DialogFileSelect = /*#__PURE__*/function (_React$Component) {
|
|
88
|
-
(0, _inherits2["default"])(DialogFileSelect, _React$Component);
|
|
89
|
-
var _super = _createSuper(DialogFileSelect);
|
|
90
|
-
/**
|
|
91
|
-
* @param {FileSelectDialogProps} props
|
|
92
|
-
*/
|
|
93
|
-
function DialogFileSelect(props) {
|
|
94
|
-
var _this;
|
|
95
|
-
(0, _classCallCheck2["default"])(this, DialogFileSelect);
|
|
96
|
-
_this = _super.call(this, props);
|
|
97
|
-
_this.dialogName = _this.props.dialogName || 'default';
|
|
98
|
-
_this.dialogName = 'FileSelect.' + _this.dialogName;
|
|
99
|
-
_this.filters = (window._localStorage || window.localStorage).getItem(_this.dialogName) || '{}';
|
|
100
|
-
try {
|
|
101
|
-
_this.filters = JSON.parse(_this.filters);
|
|
102
|
-
} catch (e) {
|
|
103
|
-
_this.filters = {};
|
|
104
|
-
}
|
|
105
|
-
_this.state = {
|
|
106
|
-
selected: _this.props.selected || '',
|
|
107
|
-
isFolder: false,
|
|
108
|
-
name: '',
|
|
109
|
-
isMobile: window.innerWidth < 800
|
|
110
|
-
};
|
|
111
|
-
return _this;
|
|
112
|
-
}
|
|
113
|
-
(0, _createClass2["default"])(DialogFileSelect, [{
|
|
114
|
-
key: "handleCancel",
|
|
115
|
-
value: function handleCancel() {
|
|
116
|
-
this.props.onClose();
|
|
117
|
-
}
|
|
118
|
-
}, {
|
|
119
|
-
key: "handleOk",
|
|
120
|
-
value: function handleOk() {
|
|
121
|
-
this.props.onOk(this.state.selected || '');
|
|
122
|
-
this.props.onClose();
|
|
123
|
-
}
|
|
124
|
-
}, {
|
|
125
|
-
key: "render",
|
|
126
|
-
value: function render() {
|
|
127
|
-
var _this2 = this;
|
|
128
|
-
var title;
|
|
129
|
-
if (this.state.name || this.state.selected.length) {
|
|
130
|
-
title = [/*#__PURE__*/_react["default"].createElement("span", {
|
|
131
|
-
key: "selected"
|
|
132
|
-
}, _i18n["default"].t('ra_Selected'), " "), /*#__PURE__*/_react["default"].createElement("span", {
|
|
133
|
-
key: "id",
|
|
134
|
-
className: this.props.classes.headerID
|
|
135
|
-
}, this.state.selected)];
|
|
136
|
-
} else {
|
|
137
|
-
title = this.props.title || _i18n["default"].t('ra_Please select file...');
|
|
138
|
-
}
|
|
139
|
-
return /*#__PURE__*/_react["default"].createElement(_Dialog["default"], {
|
|
140
|
-
onClose: function onClose() {},
|
|
141
|
-
maxWidth: false,
|
|
142
|
-
classes: {
|
|
143
|
-
paper: _Utils["default"].clsx(this.props.classes.dialog, this.props.classes.dialogMobile)
|
|
144
|
-
},
|
|
145
|
-
fullWidth: true,
|
|
146
|
-
open: !0,
|
|
147
|
-
"aria-labelledby": "file-dialog-title"
|
|
148
|
-
}, /*#__PURE__*/_react["default"].createElement(_DialogTitle["default"], {
|
|
149
|
-
id: "file-dialog-title",
|
|
150
|
-
classes: {
|
|
151
|
-
root: this.props.classes.titleRoot
|
|
152
|
-
}
|
|
153
|
-
}, title), /*#__PURE__*/_react["default"].createElement(_DialogContent["default"], {
|
|
154
|
-
className: _Utils["default"].clsx(this.props.classes.content, this.props.classes.contentMobile)
|
|
155
|
-
}, /*#__PURE__*/_react["default"].createElement(_FileBrowser["default"], {
|
|
156
|
-
ready: true,
|
|
157
|
-
imagePrefix: this.props.imagePrefix,
|
|
158
|
-
allowUpload: !!this.props.allowUpload,
|
|
159
|
-
allowDownload: this.props.allowDownload !== false,
|
|
160
|
-
allowCreateFolder: !!this.props.allowCreateFolder,
|
|
161
|
-
allowDelete: !!this.props.allowDelete,
|
|
162
|
-
showViewTypeButton: this.props.allowView !== false,
|
|
163
|
-
showToolbar: this.props.showToolbar !== false,
|
|
164
|
-
limitPath: this.props.limitPath,
|
|
165
|
-
filterFiles: this.props.filterFiles,
|
|
166
|
-
filterByType: this.props.filterByType,
|
|
167
|
-
selected: this.props.selected,
|
|
168
|
-
onSelect: function onSelect(selected, isDoubleClick, isFolder) {
|
|
169
|
-
_this2.setState({
|
|
170
|
-
selected: selected,
|
|
171
|
-
isFolder: isFolder
|
|
172
|
-
}, function () {
|
|
173
|
-
return isDoubleClick && (_this2.props.selectOnlyFolders && isFolder || !_this2.props.selectOnlyFolders && !isFolder) && _this2.handleOk();
|
|
174
|
-
});
|
|
175
|
-
},
|
|
176
|
-
t: _i18n["default"].t,
|
|
177
|
-
lang: _i18n["default"].getLanguage(),
|
|
178
|
-
socket: this.props.socket
|
|
179
|
-
})), /*#__PURE__*/_react["default"].createElement(_DialogActions["default"], null, /*#__PURE__*/_react["default"].createElement(_Button["default"], {
|
|
180
|
-
variant: "contained",
|
|
181
|
-
onClick: function onClick() {
|
|
182
|
-
return _this2.handleOk();
|
|
183
|
-
},
|
|
184
|
-
startIcon: /*#__PURE__*/_react["default"].createElement(_Check["default"], null),
|
|
185
|
-
disabled: !this.state.selected || this.props.selectOnlyFolders && !this.state.isFolder || !this.props.selectOnlyFolders && this.state.isFolder,
|
|
186
|
-
color: "primary"
|
|
187
|
-
}, this.props.ok || _i18n["default"].t('ra_Ok')), /*#__PURE__*/_react["default"].createElement(_Button["default"], {
|
|
188
|
-
color: "grey",
|
|
189
|
-
variant: "contained",
|
|
190
|
-
onClick: function onClick() {
|
|
191
|
-
return _this2.handleCancel();
|
|
192
|
-
},
|
|
193
|
-
startIcon: /*#__PURE__*/_react["default"].createElement(_Cancel["default"], null)
|
|
194
|
-
}, this.props.cancel || _i18n["default"].t('ra_Cancel'))));
|
|
195
|
-
}
|
|
196
|
-
}]);
|
|
197
|
-
return DialogFileSelect;
|
|
198
|
-
}(_react["default"].Component);
|
|
199
|
-
DialogFileSelect.propTypes = {
|
|
200
|
-
imagePrefix: _propTypes["default"].string,
|
|
201
|
-
dialogName: _propTypes["default"].string,
|
|
202
|
-
// where to store settings in localStorage
|
|
203
|
-
selected: _propTypes["default"].string,
|
|
204
|
-
onClose: _propTypes["default"].func.isRequired,
|
|
205
|
-
onOk: _propTypes["default"].func.isRequired,
|
|
206
|
-
ok: _propTypes["default"].string,
|
|
207
|
-
cancel: _propTypes["default"].string,
|
|
208
|
-
socket: _propTypes["default"].object.isRequired,
|
|
209
|
-
allowUpload: _propTypes["default"].bool,
|
|
210
|
-
allowDownload: _propTypes["default"].bool,
|
|
211
|
-
allowCreateFolder: _propTypes["default"].bool,
|
|
212
|
-
allowDelete: _propTypes["default"].bool,
|
|
213
|
-
allowView: _propTypes["default"].bool,
|
|
214
|
-
showToolbar: _propTypes["default"].bool,
|
|
215
|
-
objectID: _propTypes["default"].string,
|
|
216
|
-
filterFiles: _propTypes["default"].arrayOf(_propTypes["default"].string),
|
|
217
|
-
filterByType: _propTypes["default"].string,
|
|
218
|
-
limitPath: _propTypes["default"].string,
|
|
219
|
-
selectOnlyFolders: _propTypes["default"].bool
|
|
220
|
-
};
|
|
221
|
-
|
|
222
|
-
/** @type {typeof DialogFileSelect} */
|
|
223
|
-
var _export = (0, _withStyles["default"])(styles)(DialogFileSelect);
|
|
224
|
-
var _default = _export;
|
|
225
|
-
exports["default"] = _default;
|
|
226
|
-
//# sourceMappingURL=FileSelect.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"FileSelect.js","names":["styles","theme","headerID","fontWeight","fontStyle","dialog","height","backgroundColor","palette","mode","dialogMobile","padding","width","maxWidth","maxHeight","content","overflow","contentMobile","titleRoot","whiteSpace","display","textOverflow","DialogFileSelect","props","dialogName","filters","window","_localStorage","localStorage","getItem","JSON","parse","e","state","selected","isFolder","name","isMobile","innerWidth","onClose","onOk","title","length","I18n","t","classes","paper","Utils","clsx","root","imagePrefix","allowUpload","allowDownload","allowCreateFolder","allowDelete","allowView","showToolbar","limitPath","filterFiles","filterByType","isDoubleClick","setState","selectOnlyFolders","handleOk","getLanguage","socket","ok","handleCancel","cancel","React","Component","propTypes","PropTypes","string","func","isRequired","object","bool","objectID","arrayOf","_export","withStyles"],"sources":["FileSelect.js"],"sourcesContent":["/**\n * Copyright 2022 bluefox <dogafox@gmail.com>\n *\n * MIT License\n *\n **/\n// please do not delete React, as without it other projects could not be compiled: ReferenceError: React is not defined\nimport React from 'react';\nimport PropTypes from 'prop-types';\nimport withStyles from '@mui/styles/withStyles';\n\nimport Button from '@mui/material/Button';\nimport DialogTitle from '@mui/material/DialogTitle';\nimport DialogContent from '@mui/material/DialogContent';\nimport DialogActions from '@mui/material/DialogActions';\nimport Dialog from '@mui/material/Dialog';\n\nimport IconCancel from '@mui/icons-material/Cancel';\nimport IconOk from '@mui/icons-material/Check';\n\nimport I18n from '../i18n';\nimport Utils from '../Components/Utils';\nimport FileBrowser from '../Components/FileBrowser';\n\nconst styles = theme => ({\n headerID: {\n fontWeight: 'bold',\n fontStyle: 'italic'\n },\n dialog: {\n height: '95%',\n backgroundColor: theme.palette.mode === 'dark' ? '#303030' : '#fafafa',\n },\n dialogMobile: {\n padding: 4,\n width: '100%',\n maxWidth: '100%',\n maxHeight: 'calc(100% - 16px)',\n height: '100%'\n },\n content: {\n height: '100%',\n overflow: 'hidden'\n },\n contentMobile: {\n padding: '8px 4px'\n },\n titleRoot: {\n whiteSpace: 'nowrap',\n width: 'calc(100% - 72px)',\n overflow: 'hidden',\n display: 'inline-block',\n textOverflow: 'ellipsis',\n }\n});\n\n/**\n * @typedef {object} FileSelectDialogProps\n * @property {string} [dialogName] The internal name of the dialog; default: \"default\"\n * @property {string} [title] The dialog title; default: Please select object ID... (translated)\n * @property {string} [imagePrefix] Prefix (default: '.')\n * @property {boolean} [dialogName] PropTypes.string, // where to store settings in localStorage\n * @property {boolean} [selected] Pre-selected file\n * @property {() => void} onClose Close handler that is always called when the dialog is closed.\n * @property {(selected: string | undefined) => void} onOk Handler that is called when the user presses OK.\n * @property {string} [ok] The ok button text; default: OK (translated)\n * @property {string} [cancel] The cancel button text; default: Cancel (translated)\n * @property {boolean} [socket] Socket class (required)\n * @property {boolean} [allowUpload] If download of files enabled\n * @property {boolean} [allowDownload] If download of files enabled\n * @property {boolean} [allowCreateFolder] If creation of folders enabled\n * @property {boolean} [allowDelete] If creation of folders enabled\n * @property {boolean} [allowView] if tile view enabled (default true)\n * @property {boolean} [showToolbar] Show toolbar (default true)\n * @property {array} [limitPath] Limit file browser to one specific objectID of type meta and following path (like vis.0/main)\n * @property {array} [filterFiles] like `['png', 'svg', 'bmp', 'jpg', 'jpeg']`\n * @property {string} [filterByType] images, code, txt, audio, video\n * @property {bool} [selectOnlyFolders] allow only folders selection\n *\n * @extends {React.Component<FileSelectDialogProps>}\n */\nclass DialogFileSelect extends React.Component {\n /**\n * @param {FileSelectDialogProps} props\n */\n constructor(props) {\n super(props);\n this.dialogName = this.props.dialogName || 'default';\n this.dialogName = 'FileSelect.' + this.dialogName;\n\n this.filters = (window._localStorage || window.localStorage).getItem(this.dialogName) || '{}';\n\n try {\n this.filters = JSON.parse(this.filters);\n } catch (e) {\n this.filters = {};\n }\n\n this.state = {\n selected: this.props.selected || '',\n isFolder: false,\n name: '',\n isMobile: window.innerWidth < 800\n };\n }\n\n handleCancel() {\n this.props.onClose();\n };\n\n handleOk() {\n this.props.onOk(this.state.selected || '');\n this.props.onClose();\n };\n\n render() {\n let title;\n if (this.state.name || this.state.selected.length) {\n title = [\n <span key=\"selected\">{ I18n.t('ra_Selected') } </span>,\n <span key=\"id\" className={ this.props.classes.headerID }>{this.state.selected}</span>\n ];\n } else {\n title = this.props.title || I18n.t('ra_Please select file...');\n }\n\n return <Dialog\n onClose={() => {}}\n maxWidth={false}\n classes={{ paper: Utils.clsx(this.props.classes.dialog, this.props.classes.dialogMobile) }}\n fullWidth\n open={!0}\n aria-labelledby=\"file-dialog-title\"\n >\n <DialogTitle id=\"file-dialog-title\" classes={{ root: this.props.classes.titleRoot }}>{ title }</DialogTitle>\n <DialogContent className={Utils.clsx(this.props.classes.content, this.props.classes.contentMobile)}>\n <FileBrowser\n ready\n imagePrefix={this.props.imagePrefix}\n allowUpload={!!this.props.allowUpload}\n allowDownload={this.props.allowDownload !== false}\n allowCreateFolder={!!this.props.allowCreateFolder}\n allowDelete={!!this.props.allowDelete}\n showViewTypeButton={this.props.allowView !== false}\n showToolbar={this.props.showToolbar !== false}\n limitPath={this.props.limitPath}\n filterFiles={this.props.filterFiles}\n filterByType={this.props.filterByType}\n selected={this.props.selected}\n onSelect={(selected, isDoubleClick, isFolder) => {\n this.setState({ selected, isFolder }, () =>\n isDoubleClick && ((this.props.selectOnlyFolders && isFolder) || (!this.props.selectOnlyFolders && !isFolder)) && this.handleOk());\n }}\n t={I18n.t}\n lang={I18n.getLanguage()}\n socket={this.props.socket}\n />\n </DialogContent>\n <DialogActions>\n <Button variant=\"contained\" onClick={ () => this.handleOk() } startIcon={<IconOk />} disabled={ !this.state.selected || ((this.props.selectOnlyFolders && !this.state.isFolder) || (!this.props.selectOnlyFolders && this.state.isFolder)) } color=\"primary\">{ this.props.ok || I18n.t('ra_Ok') }</Button>\n <Button color=\"grey\" variant=\"contained\" onClick={ () => this.handleCancel() } startIcon={<IconCancel />}>{ this.props.cancel || I18n.t('ra_Cancel') }</Button>\n </DialogActions>\n </Dialog>;\n }\n}\n\nDialogFileSelect.propTypes = {\n imagePrefix: PropTypes.string,\n dialogName: PropTypes.string, // where to store settings in localStorage\n selected: PropTypes.string,\n onClose: PropTypes.func.isRequired,\n onOk: PropTypes.func.isRequired,\n ok: PropTypes.string,\n cancel: PropTypes.string,\n socket: PropTypes.object.isRequired,\n allowUpload: PropTypes.bool,\n allowDownload: PropTypes.bool,\n allowCreateFolder: PropTypes.bool,\n allowDelete: PropTypes.bool,\n allowView: PropTypes.bool,\n showToolbar: PropTypes.bool,\n objectID: PropTypes.string,\n filterFiles: PropTypes.arrayOf(PropTypes.string),\n filterByType: PropTypes.string,\n limitPath: PropTypes.string,\n selectOnlyFolders: PropTypes.bool,\n};\n\n/** @type {typeof DialogFileSelect} */\nconst _export = withStyles(styles)(DialogFileSelect);\nexport default _export;\n"],"mappings":";;;;;;;;;;;;AAOA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AAEA;AACA;AAEA;AACA;AACA;AAAoD;AAAA;AAEpD,IAAMA,MAAM,GAAG,SAATA,MAAM,CAAGC,KAAK;EAAA,OAAK;IACrBC,QAAQ,EAAE;MACNC,UAAU,EAAE,MAAM;MAClBC,SAAS,EAAE;IACf,CAAC;IACDC,MAAM,EAAE;MACJC,MAAM,EAAE,KAAK;MACbC,eAAe,EAAEN,KAAK,CAACO,OAAO,CAACC,IAAI,KAAK,MAAM,GAAG,SAAS,GAAG;IACjE,CAAC;IACDC,YAAY,EAAE;MACVC,OAAO,EAAE,CAAC;MACVC,KAAK,EAAE,MAAM;MACbC,QAAQ,EAAE,MAAM;MAChBC,SAAS,EAAE,mBAAmB;MAC9BR,MAAM,EAAE;IACZ,CAAC;IACDS,OAAO,EAAE;MACLT,MAAM,EAAE,MAAM;MACdU,QAAQ,EAAE;IACd,CAAC;IACDC,aAAa,EAAE;MACXN,OAAO,EAAE;IACb,CAAC;IACDO,SAAS,EAAE;MACPC,UAAU,EAAE,QAAQ;MACpBP,KAAK,EAAE,mBAAmB;MAC1BI,QAAQ,EAAE,Q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