@iobroker/adapter-react-v5 4.9.11 → 4.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Components/404.d.ts +5 -2
- package/Components/404.js +83 -105
- package/Components/ColorPicker.js.map +1 -1
- package/Components/FileViewer.d.ts +0 -1
- package/Components/FileViewer.js +1 -2
- package/Components/FileViewer.js.map +1 -1
- package/Components/Icon.d.ts +10 -17
- package/Components/Icon.js +104 -161
- package/Components/IconPicker.d.ts +16 -61
- package/Components/IconPicker.js +100 -158
- package/Components/Loader.d.ts +22 -33
- package/Components/Loader.js +276 -102
- package/Components/TabContainer.d.ts +1 -1
- package/Components/TextWithIcon.d.ts +21 -16
- package/Components/TextWithIcon.js +104 -125
- package/Components/UploadImage.d.ts +13 -1
- package/Components/UploadImage.js +499 -292
- package/Dialogs/TextInput.d.ts +2 -86
- package/Dialogs/TextInput.js +37 -130
- package/LegacyConnection.d.ts +3 -3
- package/README.md +6 -3
- package/Theme.d.ts +3 -4
- package/Theme.js +389 -382
- package/i18n.d.ts +38 -55
- package/i18n.js +164 -189
- package/package.json +1 -1
- package/types.d.ts +4 -2
- package/Components/404.js.map +0 -1
- package/Components/Icon.js.map +0 -1
- package/Components/IconPicker.js.map +0 -1
- package/Components/Loader.js.map +0 -1
- package/Components/TextWithIcon.js.map +0 -1
- package/Components/UploadImage.js.map +0 -1
- package/Dialogs/TextInput.js.map +0 -1
- package/Theme.js.map +0 -1
- package/i18n.js.map +0 -1
package/Components/Icon.js
CHANGED
|
@@ -1,173 +1,116 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
13
|
-
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
|
|
14
|
-
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
|
|
15
|
-
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
|
|
16
|
-
var _react = _interopRequireDefault(require("react"));
|
|
17
|
-
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
18
|
-
var _reactInlinesvg = _interopRequireDefault(require("react-inlinesvg"));
|
|
19
|
-
var _iconsMaterial = require("@mui/icons-material");
|
|
20
|
-
var _IconAlias = _interopRequireDefault(require("../icons/IconAlias"));
|
|
21
|
-
var _Utils = _interopRequireDefault(require("./Utils"));
|
|
22
|
-
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
23
|
-
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2["default"])(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
24
|
-
function _callSuper(t, o, e) { return o = (0, _getPrototypeOf2["default"])(o), (0, _possibleConstructorReturn2["default"])(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], (0, _getPrototypeOf2["default"])(t).constructor) : o.apply(t, e)); }
|
|
25
|
-
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.getSelectIdIcon = exports.getSystemIcon = void 0;
|
|
7
|
+
const react_1 = __importDefault(require("react"));
|
|
8
|
+
const react_inlinesvg_1 = __importDefault(require("react-inlinesvg"));
|
|
9
|
+
const icons_material_1 = require("@mui/icons-material");
|
|
10
|
+
const IconAlias_1 = __importDefault(require("../icons/IconAlias"));
|
|
11
|
+
const Utils_1 = __importDefault(require("./Utils"));
|
|
26
12
|
function getSystemIcon(obj) {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
icon
|
|
64
|
-
className: "iconOwn"
|
|
65
|
-
});
|
|
66
|
-
} else if (id.endsWith('.info')) {
|
|
67
|
-
icon = /*#__PURE__*/_react["default"].createElement(_iconsMaterial.Info, {
|
|
68
|
-
className: "iconOwn"
|
|
69
|
-
});
|
|
70
|
-
} else if ((obj === null || obj === void 0 ? void 0 : obj.type) === 'meta') {
|
|
71
|
-
icon = /*#__PURE__*/_react["default"].createElement(_iconsMaterial.Description, {
|
|
72
|
-
className: "iconOwn"
|
|
73
|
-
});
|
|
74
|
-
}
|
|
75
|
-
return icon || null;
|
|
13
|
+
let icon;
|
|
14
|
+
const id = obj === null || obj === void 0 ? void 0 : obj._id;
|
|
15
|
+
if (!id) {
|
|
16
|
+
return null;
|
|
17
|
+
}
|
|
18
|
+
// system or design has special icons
|
|
19
|
+
if (id.startsWith('_design/') || (id === 'system')) {
|
|
20
|
+
icon = react_1.default.createElement(icons_material_1.SettingsApplications, { className: "iconOwn" });
|
|
21
|
+
}
|
|
22
|
+
else if (id === '0_userdata' || id === '0_userdata.0') {
|
|
23
|
+
icon = react_1.default.createElement(icons_material_1.Photo, { className: "iconOwn" });
|
|
24
|
+
}
|
|
25
|
+
else if (id === 'alias' || id === 'alias.0') {
|
|
26
|
+
icon = react_1.default.createElement(IconAlias_1.default, { className: "iconOwn" });
|
|
27
|
+
}
|
|
28
|
+
else if (id === 'system.adapter') {
|
|
29
|
+
icon = react_1.default.createElement(icons_material_1.SettingsApplications, { className: "iconOwn" });
|
|
30
|
+
}
|
|
31
|
+
else if (id === 'system.group') {
|
|
32
|
+
icon = react_1.default.createElement(icons_material_1.SupervisedUserCircle, { className: "iconOwn" });
|
|
33
|
+
}
|
|
34
|
+
else if (id === 'system.user') {
|
|
35
|
+
icon = react_1.default.createElement(icons_material_1.PersonOutlined, { className: "iconOwn" });
|
|
36
|
+
}
|
|
37
|
+
else if (id === 'system.host') {
|
|
38
|
+
icon = react_1.default.createElement(icons_material_1.Router, { className: "iconOwn" });
|
|
39
|
+
}
|
|
40
|
+
else if (id.endsWith('.connection') || id.endsWith('.connected')) {
|
|
41
|
+
icon = react_1.default.createElement(icons_material_1.Wifi, { className: "iconOwn" });
|
|
42
|
+
}
|
|
43
|
+
else if (id.endsWith('.info')) {
|
|
44
|
+
icon = react_1.default.createElement(icons_material_1.Info, { className: "iconOwn" });
|
|
45
|
+
}
|
|
46
|
+
else if ((obj === null || obj === void 0 ? void 0 : obj.type) === 'meta') {
|
|
47
|
+
icon = react_1.default.createElement(icons_material_1.Description, { className: "iconOwn" });
|
|
48
|
+
}
|
|
49
|
+
return icon || null;
|
|
76
50
|
}
|
|
51
|
+
exports.getSystemIcon = getSystemIcon;
|
|
77
52
|
function getSelectIdIcon(obj, imagePrefix) {
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
53
|
+
imagePrefix = imagePrefix || '.'; // http://localhost:8081';
|
|
54
|
+
let src = '';
|
|
55
|
+
const common = obj === null || obj === void 0 ? void 0 : obj.common;
|
|
56
|
+
if (common) {
|
|
57
|
+
const cIcon = common.icon;
|
|
58
|
+
if (cIcon) {
|
|
59
|
+
if (!cIcon.startsWith('data:image/')) {
|
|
60
|
+
if (cIcon.includes('.')) {
|
|
61
|
+
let instance;
|
|
62
|
+
if (obj.type === 'instance' || obj.type === 'adapter') {
|
|
63
|
+
src = `${imagePrefix}/adapter/${common.name}/${cIcon}`;
|
|
64
|
+
}
|
|
65
|
+
else if (obj._id && obj._id.startsWith('system.adapter.')) {
|
|
66
|
+
instance = obj._id.split('.', 3);
|
|
67
|
+
if (cIcon[0] === '/') {
|
|
68
|
+
instance[2] += cIcon;
|
|
69
|
+
}
|
|
70
|
+
else {
|
|
71
|
+
instance[2] += `/${cIcon}`;
|
|
72
|
+
}
|
|
73
|
+
src = `${imagePrefix}/adapter/${instance[2]}`;
|
|
74
|
+
}
|
|
75
|
+
else {
|
|
76
|
+
instance = obj._id.split('.', 2);
|
|
77
|
+
if (cIcon[0] === '/') {
|
|
78
|
+
instance[0] += cIcon;
|
|
79
|
+
}
|
|
80
|
+
else {
|
|
81
|
+
instance[0] += `/${cIcon}`;
|
|
82
|
+
}
|
|
83
|
+
src = `${imagePrefix}/adapter/${instance[0]}`;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
else {
|
|
87
|
+
return null;
|
|
88
|
+
}
|
|
95
89
|
}
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
if (cIcon[0] === '/') {
|
|
100
|
-
instance[0] += cIcon;
|
|
101
|
-
} else {
|
|
102
|
-
instance[0] += "/".concat(cIcon);
|
|
90
|
+
else {
|
|
91
|
+
// base 64 image
|
|
92
|
+
src = cIcon;
|
|
103
93
|
}
|
|
104
|
-
src = "".concat(imagePrefix, "/adapter/").concat(instance[0]);
|
|
105
|
-
}
|
|
106
|
-
} else {
|
|
107
|
-
return null;
|
|
108
94
|
}
|
|
109
|
-
} else {
|
|
110
|
-
// base 64 image
|
|
111
|
-
src = cIcon;
|
|
112
|
-
}
|
|
113
95
|
}
|
|
114
|
-
|
|
115
|
-
return src || null;
|
|
96
|
+
return src || null;
|
|
116
97
|
}
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
(
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
return /*#__PURE__*/_react["default"].createElement("span", {
|
|
131
|
-
title: this.props.title || undefined,
|
|
132
|
-
style: _objectSpread({
|
|
133
|
-
height: 27,
|
|
134
|
-
marginTop: -8
|
|
135
|
-
}, this.props.styleUTF8 || this.props.style),
|
|
136
|
-
className: _Utils["default"].clsx(this.props.className, 'iconOwn')
|
|
137
|
-
}, this.props.src);
|
|
138
|
-
}
|
|
139
|
-
if (this.props.src.startsWith('data:image/svg')) {
|
|
140
|
-
var _this$props$style, _this$props$style2, _this$props$style3;
|
|
141
|
-
return /*#__PURE__*/_react["default"].createElement(_reactInlinesvg["default"], {
|
|
142
|
-
title: this.props.title || undefined,
|
|
143
|
-
src: this.props.src,
|
|
144
|
-
className: _Utils["default"].clsx(this.props.className, 'iconOwn'),
|
|
145
|
-
width: ((_this$props$style = this.props.style) === null || _this$props$style === void 0 ? void 0 : _this$props$style.width) || 28,
|
|
146
|
-
height: ((_this$props$style2 = this.props.style) === null || _this$props$style2 === void 0 ? void 0 : _this$props$style2.height) || ((_this$props$style3 = this.props.style) === null || _this$props$style3 === void 0 ? void 0 : _this$props$style3.width) || 28,
|
|
147
|
-
style: this.props.style || {}
|
|
148
|
-
});
|
|
149
|
-
}
|
|
150
|
-
return /*#__PURE__*/_react["default"].createElement("img", {
|
|
151
|
-
title: this.props.title || undefined,
|
|
152
|
-
style: this.props.style || {},
|
|
153
|
-
className: _Utils["default"].clsx(this.props.className, 'iconOwn'),
|
|
154
|
-
src: this.props.src,
|
|
155
|
-
alt: ""
|
|
156
|
-
});
|
|
98
|
+
exports.getSelectIdIcon = getSelectIdIcon;
|
|
99
|
+
const Icon = (props) => {
|
|
100
|
+
var _a, _b, _c;
|
|
101
|
+
if (props.src) {
|
|
102
|
+
if (typeof props.src === 'string') {
|
|
103
|
+
if (props.src.length < 3) {
|
|
104
|
+
// utf-8 char
|
|
105
|
+
return react_1.default.createElement("span", { title: props.title || undefined, style: Object.assign({ height: 27, marginTop: -8 }, (props.styleUTF8 || props.style)), className: Utils_1.default.clsx(props.className, 'iconOwn') }, props.src);
|
|
106
|
+
}
|
|
107
|
+
if (props.src.startsWith('data:image/svg')) {
|
|
108
|
+
return react_1.default.createElement(react_inlinesvg_1.default, { title: props.title || undefined, src: props.src, className: Utils_1.default.clsx(props.className, 'iconOwn'), width: ((_a = props.style) === null || _a === void 0 ? void 0 : _a.width) || 28, height: ((_b = props.style) === null || _b === void 0 ? void 0 : _b.height) || ((_c = props.style) === null || _c === void 0 ? void 0 : _c.width) || 28, style: props.style || {} });
|
|
109
|
+
}
|
|
110
|
+
return react_1.default.createElement("img", { title: props.title || undefined, style: props.style || {}, className: Utils_1.default.clsx(props.className, 'iconOwn'), src: props.src, alt: "" });
|
|
157
111
|
}
|
|
158
|
-
return
|
|
159
|
-
}
|
|
160
|
-
return null;
|
|
112
|
+
return props.src;
|
|
161
113
|
}
|
|
162
|
-
|
|
163
|
-
return Icon;
|
|
164
|
-
}(_react["default"].Component);
|
|
165
|
-
Icon.propTypes = {
|
|
166
|
-
title: _propTypes["default"].string,
|
|
167
|
-
src: _propTypes["default"].oneOfType([_propTypes["default"].string, _propTypes["default"].object]).isRequired,
|
|
168
|
-
className: _propTypes["default"].string,
|
|
169
|
-
style: _propTypes["default"].object,
|
|
170
|
-
styleUTF8: _propTypes["default"].object
|
|
114
|
+
return null;
|
|
171
115
|
};
|
|
172
|
-
|
|
173
|
-
//# sourceMappingURL=Icon.js.map
|
|
116
|
+
exports.default = Icon;
|
|
@@ -1,65 +1,20 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* The label.
|
|
9
|
-
*/
|
|
1
|
+
import React from 'react';
|
|
2
|
+
interface IconPickerProps {
|
|
3
|
+
previewClassName?: string;
|
|
4
|
+
/** Custom icon element. */
|
|
5
|
+
icon?: React.ComponentType<any>;
|
|
6
|
+
customClasses?: Record<string, string>;
|
|
7
|
+
/** The label. */
|
|
10
8
|
label?: string;
|
|
11
|
-
/**
|
|
12
|
-
|
|
13
|
-
|
|
9
|
+
/** The value. */
|
|
10
|
+
value?: any;
|
|
11
|
+
/** Set to true to disable the icon picker. */
|
|
14
12
|
disabled?: boolean;
|
|
15
|
-
/**
|
|
16
|
-
* The icon change callback.
|
|
17
|
-
*/
|
|
13
|
+
/** The icon change callback. */
|
|
18
14
|
onChange: (icon: string) => void;
|
|
19
|
-
|
|
20
|
-
|
|
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): React.JSX.Element;
|
|
50
|
-
declare namespace IconPicker {
|
|
51
|
-
namespace propTypes {
|
|
52
|
-
let previewClassName: PropTypes.Requireable<string>;
|
|
53
|
-
let icon: PropTypes.Requireable<object>;
|
|
54
|
-
let customClasses: PropTypes.Requireable<object>;
|
|
55
|
-
let label: PropTypes.Requireable<string>;
|
|
56
|
-
let value: PropTypes.Requireable<any>;
|
|
57
|
-
let disabled: PropTypes.Requireable<boolean>;
|
|
58
|
-
let onChange: PropTypes.Validator<(...args: any[]) => any>;
|
|
59
|
-
let icons: PropTypes.Requireable<any[]>;
|
|
60
|
-
let onlyRooms: PropTypes.Requireable<boolean>;
|
|
61
|
-
let onlyDevices: PropTypes.Requireable<boolean>;
|
|
62
|
-
}
|
|
15
|
+
icons: any[];
|
|
16
|
+
onlyRooms: boolean;
|
|
17
|
+
onlyDevices: boolean;
|
|
63
18
|
}
|
|
64
|
-
|
|
65
|
-
|
|
19
|
+
declare const IconPicker: (props: IconPickerProps) => React.JSX.Element;
|
|
20
|
+
export default IconPicker;
|
package/Components/IconPicker.js
CHANGED
|
@@ -1,162 +1,104 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
var
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
});
|
|
8
|
-
exports["default"] = void 0;
|
|
9
|
-
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
10
|
-
var _react = _interopRequireWildcard(require("react"));
|
|
11
|
-
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
12
|
-
var _reactDropzone = require("react-dropzone");
|
|
13
|
-
var _makeStyles = _interopRequireDefault(require("@mui/styles/makeStyles"));
|
|
14
|
-
var _material = require("@mui/material");
|
|
15
|
-
var _iconsMaterial = require("@mui/icons-material");
|
|
16
|
-
var _IconSelector = _interopRequireDefault(require("./IconSelector"));
|
|
17
|
-
var _Icon = _interopRequireDefault(require("./Icon"));
|
|
18
|
-
var _i18n = _interopRequireDefault(require("../i18n"));
|
|
19
|
-
var _Utils = _interopRequireDefault(require("./Utils"));
|
|
20
|
-
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
|
|
21
|
-
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { "default": e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n["default"] = e, t && t.set(e, n), n; }
|
|
22
|
-
/**
|
|
23
|
-
* @typedef {object} IconPickerProps
|
|
24
|
-
* @property {string} [value] The value.
|
|
25
|
-
* @property {string} [label] The label.
|
|
26
|
-
* @property {boolean} [disabled] Set to true to disable the icon picker.
|
|
27
|
-
* @property {(icon: string) => void} onChange The icon change callback.
|
|
28
|
-
* @property {import('../Connection').default} socket The socket connection.
|
|
29
|
-
* @property {string} [imagePrefix] The image prefix (default: './files/')
|
|
30
|
-
* @property {React.CSSProperties} [style] Additional styling for this component.
|
|
31
|
-
* @property {string} [className] The CSS class name.
|
|
32
|
-
*
|
|
33
|
-
* @extends {React.Component<IconPickerProps>}
|
|
34
|
-
*/
|
|
35
|
-
var IconPicker = function IconPicker(props) {
|
|
36
|
-
var _props$customClasses, _props$customClasses2;
|
|
37
|
-
var IconCustom = props.icon;
|
|
38
|
-
var useStyles = (0, _makeStyles["default"])(function () {
|
|
39
|
-
return {
|
|
40
|
-
formContainer: {
|
|
41
|
-
display: 'flex',
|
|
42
|
-
justifyContent: 'left',
|
|
43
|
-
alignItems: 'center'
|
|
44
|
-
},
|
|
45
|
-
formControl: {
|
|
46
|
-
display: 'flex',
|
|
47
|
-
padding: 24,
|
|
48
|
-
flexGrow: 1000
|
|
49
|
-
},
|
|
50
|
-
divContainer: {
|
|
51
|
-
width: 32 + 24,
|
|
52
|
-
height: 32,
|
|
53
|
-
whiteSpace: 'nowrap',
|
|
54
|
-
lineHeight: '32px',
|
|
55
|
-
marginRight: 8
|
|
56
|
-
},
|
|
57
|
-
dragField: {
|
|
58
|
-
textAlign: 'center',
|
|
59
|
-
display: 'table',
|
|
60
|
-
minHeight: 90,
|
|
61
|
-
width: 'calc(100% - 60px)',
|
|
62
|
-
border: '2px dashed #777',
|
|
63
|
-
borderRadius: 10,
|
|
64
|
-
padding: 4
|
|
65
|
-
},
|
|
66
|
-
formIcon: {
|
|
67
|
-
margin: 10,
|
|
68
|
-
opacity: 0.6
|
|
69
|
-
},
|
|
70
|
-
text: {
|
|
71
|
-
display: 'table-cell',
|
|
72
|
-
verticalAlign: 'middle'
|
|
73
|
-
}
|
|
74
|
-
};
|
|
75
|
-
});
|
|
76
|
-
var classes = useStyles();
|
|
77
|
-
var onDrop = (0, _react.useCallback)(function (acceptedFiles) {
|
|
78
|
-
var reader = new FileReader();
|
|
79
|
-
reader.addEventListener('load', function () {
|
|
80
|
-
return props.onChange(reader.result);
|
|
81
|
-
}, false);
|
|
82
|
-
if (acceptedFiles[0]) {
|
|
83
|
-
reader.readAsDataURL(acceptedFiles[0]);
|
|
84
|
-
}
|
|
85
|
-
}, []); // eslint-disable-line react-hooks/exhaustive-deps
|
|
86
|
-
|
|
87
|
-
var _useDropzone = (0, _reactDropzone.useDropzone)({
|
|
88
|
-
onDrop: onDrop
|
|
89
|
-
}),
|
|
90
|
-
getRootProps = _useDropzone.getRootProps,
|
|
91
|
-
getInputProps = _useDropzone.getInputProps,
|
|
92
|
-
isDragActive = _useDropzone.isDragActive;
|
|
93
|
-
return /*#__PURE__*/_react["default"].createElement("div", {
|
|
94
|
-
className: classes.formContainer
|
|
95
|
-
}, IconCustom ? /*#__PURE__*/_react["default"].createElement(IconCustom, {
|
|
96
|
-
className: classes.formIcon
|
|
97
|
-
}) : null, /*#__PURE__*/_react["default"].createElement(_material.FormControl, {
|
|
98
|
-
variant: "standard",
|
|
99
|
-
className: classes.formControl,
|
|
100
|
-
style: {
|
|
101
|
-
padding: 3
|
|
102
|
-
}
|
|
103
|
-
}, /*#__PURE__*/_react["default"].createElement(_material.InputLabel, {
|
|
104
|
-
shrink: true,
|
|
105
|
-
classes: {
|
|
106
|
-
root: (_props$customClasses = props.customClasses) === null || _props$customClasses === void 0 ? void 0 : _props$customClasses.label
|
|
107
|
-
}
|
|
108
|
-
}, props.label), /*#__PURE__*/_react["default"].createElement("div", {
|
|
109
|
-
className: classes.formContainer
|
|
110
|
-
}, props.value ? /*#__PURE__*/_react["default"].createElement("div", {
|
|
111
|
-
className: classes.divContainer
|
|
112
|
-
}, /*#__PURE__*/_react["default"].createElement(_Icon["default"], {
|
|
113
|
-
alt: "",
|
|
114
|
-
className: _Utils["default"].clsx(props.previewClassName, (_props$customClasses2 = props.customClasses) === null || _props$customClasses2 === void 0 ? void 0 : _props$customClasses2.icon),
|
|
115
|
-
src: props.value
|
|
116
|
-
}), !props.disabled && /*#__PURE__*/_react["default"].createElement(_material.IconButton, {
|
|
117
|
-
style: {
|
|
118
|
-
verticalAlign: 'top'
|
|
119
|
-
},
|
|
120
|
-
title: _i18n["default"].t('ra_Clear icon'),
|
|
121
|
-
size: "small",
|
|
122
|
-
onClick: function onClick() {
|
|
123
|
-
return props.onChange('');
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
124
7
|
}
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
className: classes.text
|
|
145
|
-
}, _i18n["default"].t('ra_Drag \'n\' drop some files here, or click to select files'))))));
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
146
27
|
};
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
28
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
+
const react_1 = __importStar(require("react"));
|
|
30
|
+
const react_dropzone_1 = require("react-dropzone");
|
|
31
|
+
const styles_1 = require("@mui/styles");
|
|
32
|
+
const material_1 = require("@mui/material");
|
|
33
|
+
const icons_material_1 = require("@mui/icons-material");
|
|
34
|
+
const IconSelector_1 = __importDefault(require("./IconSelector"));
|
|
35
|
+
const Icon_1 = __importDefault(require("./Icon"));
|
|
36
|
+
const i18n_1 = __importDefault(require("../i18n"));
|
|
37
|
+
const Utils_1 = __importDefault(require("./Utils"));
|
|
38
|
+
const IconPicker = (props) => {
|
|
39
|
+
var _a, _b;
|
|
40
|
+
const IconCustom = props.icon;
|
|
41
|
+
const useStyles = (0, styles_1.makeStyles)(() => ({
|
|
42
|
+
formContainer: {
|
|
43
|
+
display: 'flex',
|
|
44
|
+
justifyContent: 'left',
|
|
45
|
+
alignItems: 'center',
|
|
46
|
+
},
|
|
47
|
+
formControl: {
|
|
48
|
+
display: 'flex',
|
|
49
|
+
padding: 24,
|
|
50
|
+
flexGrow: 1000,
|
|
51
|
+
},
|
|
52
|
+
divContainer: {
|
|
53
|
+
width: 32 + 24,
|
|
54
|
+
height: 32,
|
|
55
|
+
whiteSpace: 'nowrap',
|
|
56
|
+
lineHeight: '32px',
|
|
57
|
+
marginRight: 8,
|
|
58
|
+
},
|
|
59
|
+
dragField: {
|
|
60
|
+
textAlign: 'center',
|
|
61
|
+
display: 'table',
|
|
62
|
+
minHeight: 90,
|
|
63
|
+
width: 'calc(100% - 60px)',
|
|
64
|
+
border: '2px dashed #777',
|
|
65
|
+
borderRadius: 10,
|
|
66
|
+
padding: 4,
|
|
67
|
+
},
|
|
68
|
+
formIcon: {
|
|
69
|
+
margin: 10,
|
|
70
|
+
opacity: 0.6,
|
|
71
|
+
},
|
|
72
|
+
text: {
|
|
73
|
+
display: 'table-cell',
|
|
74
|
+
verticalAlign: 'middle',
|
|
75
|
+
},
|
|
76
|
+
}));
|
|
77
|
+
const classes = useStyles();
|
|
78
|
+
const onDrop = (0, react_1.useCallback)((acceptedFiles) => {
|
|
79
|
+
const reader = new FileReader();
|
|
80
|
+
reader.addEventListener('load', () => props.onChange(reader.result), false);
|
|
81
|
+
if (acceptedFiles[0]) {
|
|
82
|
+
reader.readAsDataURL(acceptedFiles[0]);
|
|
83
|
+
}
|
|
84
|
+
}, []); // eslint-disable-line react-hooks/exhaustive-deps
|
|
85
|
+
const { getRootProps, getInputProps, isDragActive } = (0, react_dropzone_1.useDropzone)({ onDrop });
|
|
86
|
+
return react_1.default.createElement("div", { className: classes.formContainer },
|
|
87
|
+
IconCustom ? react_1.default.createElement(IconCustom, { className: classes.formIcon }) : null,
|
|
88
|
+
react_1.default.createElement(material_1.FormControl, { variant: "standard", className: classes.formControl, style: { padding: 3 } },
|
|
89
|
+
react_1.default.createElement(material_1.InputLabel, { shrink: true, classes: { root: (_a = props.customClasses) === null || _a === void 0 ? void 0 : _a.label } }, props.label),
|
|
90
|
+
react_1.default.createElement("div", { className: classes.formContainer },
|
|
91
|
+
props.value ?
|
|
92
|
+
react_1.default.createElement("div", { className: classes.divContainer },
|
|
93
|
+
react_1.default.createElement(Icon_1.default, { className: Utils_1.default.clsx(props.previewClassName, (_b = props.customClasses) === null || _b === void 0 ? void 0 : _b.icon), src: props.value }),
|
|
94
|
+
!props.disabled && react_1.default.createElement(material_1.IconButton, { style: { verticalAlign: 'top' }, title: i18n_1.default.t('ra_Clear icon'), size: "small", onClick: () => props.onChange('') },
|
|
95
|
+
react_1.default.createElement(icons_material_1.Clear, null)))
|
|
96
|
+
:
|
|
97
|
+
(!props.disabled && react_1.default.createElement(IconSelector_1.default, { icons: props.icons, onlyRooms: props.onlyRooms, onlyDevices: props.onlyDevices, onSelect: (base64) => props.onChange(base64), t: i18n_1.default.t, lang: i18n_1.default.getLanguage() })),
|
|
98
|
+
!props.disabled && react_1.default.createElement("div", Object.assign({}, getRootProps(), { className: classes.dragField, style: isDragActive ? { backgroundColor: 'rgba(0, 255, 0, 0.1)' } : { cursor: 'pointer' } }),
|
|
99
|
+
react_1.default.createElement("input", Object.assign({}, getInputProps())),
|
|
100
|
+
isDragActive ?
|
|
101
|
+
react_1.default.createElement("span", { className: classes.text }, i18n_1.default.t('ra_Drop the files here...')) :
|
|
102
|
+
react_1.default.createElement("span", { className: classes.text }, i18n_1.default.t('ra_Drag \'n\' drop some files here, or click to select files'))))));
|
|
158
103
|
};
|
|
159
|
-
|
|
160
|
-
/** @type {typeof IconPicker} */
|
|
161
|
-
var _default = exports["default"] = IconPicker;
|
|
162
|
-
//# sourceMappingURL=IconPicker.js.map
|
|
104
|
+
exports.default = IconPicker;
|