@iobroker/adapter-react-v5 4.10.2 → 4.10.4
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/CustomModal.d.ts +24 -2
- package/Components/CustomModal.js +77 -145
- package/Components/FileBrowser.d.ts +3 -3
- package/Components/IconSelector.d.ts +28 -22
- package/Components/IconSelector.js +2122 -2073
- package/Components/Loader.d.ts +8 -3
- package/Components/Loader.js +4 -2
- package/Components/Loaders/MV.d.ts +6 -1
- package/Components/Loaders/MV.js +6 -2
- package/Components/Loaders/PT.d.ts +7 -2
- package/Components/Loaders/PT.js +7 -1
- package/Components/Loaders/Vendor.d.ts +7 -2
- package/Components/Loaders/Vendor.js +5 -0
- package/Components/SelectWithIcon.d.ts +23 -20
- package/Components/SelectWithIcon.js +143 -204
- package/Components/types.d.ts +0 -53
- package/README.md +1 -1
- package/package.json +1 -1
- package/types.d.ts +9 -7
- package/Components/CustomModal.js.map +0 -1
- package/Components/IconSelector.js.map +0 -1
- package/Components/SelectWithIcon.js.map +0 -1
package/Components/Loader.d.ts
CHANGED
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
*
|
|
6
6
|
**/
|
|
7
7
|
import React from 'react';
|
|
8
|
+
import { ThemeName, ThemeType } from '../types';
|
|
8
9
|
declare global {
|
|
9
10
|
interface Window {
|
|
10
11
|
loadingBackgroundImage: undefined | string;
|
|
@@ -16,11 +17,15 @@ interface LoaderProps {
|
|
|
16
17
|
/** The size in pixels of this loader. */
|
|
17
18
|
size?: number;
|
|
18
19
|
/** The chosen theme type. */
|
|
19
|
-
themeType?:
|
|
20
|
+
themeType?: ThemeType;
|
|
20
21
|
/** Theme name*/
|
|
21
|
-
themeName?:
|
|
22
|
+
themeName?: ThemeName;
|
|
22
23
|
/** @deprecated Theme name. use themeName instead */
|
|
23
|
-
theme?:
|
|
24
|
+
theme?: ThemeName;
|
|
25
|
+
/** Background color */
|
|
26
|
+
backgroundColor?: string;
|
|
27
|
+
/** Background image URL */
|
|
28
|
+
backgroundImage?: string;
|
|
24
29
|
}
|
|
25
30
|
declare function Loader(props: LoaderProps): React.JSX.Element;
|
|
26
31
|
export default Loader;
|
package/Components/Loader.js
CHANGED
|
@@ -266,8 +266,10 @@ function Loader(props) {
|
|
|
266
266
|
const size = props.size || 234;
|
|
267
267
|
const theme = props.themeName || props.theme || props.themeType || 'light';
|
|
268
268
|
return react_1.default.createElement("div", { className: `logo-back logo-background-${theme}`, style: {
|
|
269
|
-
backgroundImage:
|
|
270
|
-
|
|
269
|
+
backgroundImage: (props.backgroundImage && props.backgroundImage !== '@@loginBackgroundImage@@') ? props.backgroundImage :
|
|
270
|
+
(window.loadingBackgroundImage && window.loadingBackgroundImage !== '@@loginBackgroundImage@@' ? `url(${window.loadingBackgroundImage})` : undefined),
|
|
271
|
+
backgroundColor: (props.backgroundColor && props.backgroundColor !== '@@loginBackgroundColor@@') ? props.backgroundColor :
|
|
272
|
+
(window.loadingBackgroundColor && window.loadingBackgroundColor !== '@@loginBackgroundColor@@' ? window.loadingBackgroundColor : undefined),
|
|
271
273
|
backgroundSize: 'cover',
|
|
272
274
|
} }, window.loadingHideLogo === 'true' ?
|
|
273
275
|
null
|
|
@@ -1,7 +1,12 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
+
import { ThemeType } from '../../types';
|
|
2
3
|
interface LogoProps {
|
|
3
|
-
themeType?:
|
|
4
|
+
themeType?: ThemeType;
|
|
4
5
|
size?: number;
|
|
6
|
+
/** Background color */
|
|
7
|
+
backgroundColor?: string;
|
|
8
|
+
/** Background image URL */
|
|
9
|
+
backgroundImage?: string;
|
|
5
10
|
}
|
|
6
11
|
declare function LoaderMV(props: LogoProps): React.JSX.Element;
|
|
7
12
|
export default LoaderMV;
|
package/Components/Loaders/MV.js
CHANGED
|
@@ -5,7 +5,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
const react_1 = __importDefault(require("react"));
|
|
7
7
|
function LoaderMV(props) {
|
|
8
|
-
const
|
|
8
|
+
const themeType = props.themeType || 'light';
|
|
9
9
|
const size = props.size || 200;
|
|
10
10
|
return react_1.default.createElement("div", { style: {
|
|
11
11
|
width: '100%',
|
|
@@ -13,7 +13,11 @@ function LoaderMV(props) {
|
|
|
13
13
|
position: 'absolute',
|
|
14
14
|
top: 0,
|
|
15
15
|
left: 0,
|
|
16
|
-
|
|
16
|
+
backgroundImage: (props.backgroundImage && props.backgroundImage !== '@@loginBackgroundImage@@') ? props.backgroundImage :
|
|
17
|
+
(window.loadingBackgroundImage && window.loadingBackgroundImage !== '@@loginBackgroundImage@@' ? `url(${window.loadingBackgroundImage})` : undefined),
|
|
18
|
+
backgroundColor: (props.backgroundColor && props.backgroundColor !== '@@loginBackgroundColor@@') ? props.backgroundColor :
|
|
19
|
+
(window.loadingBackgroundColor && window.loadingBackgroundColor !== '@@loginBackgroundColor@@' ? window.loadingBackgroundColor : (themeType === 'dark' ? '#000' : '#FFF')),
|
|
20
|
+
backgroundSize: 'cover',
|
|
17
21
|
} },
|
|
18
22
|
react_1.default.createElement("div", { style: {
|
|
19
23
|
width: size,
|
|
@@ -5,13 +5,18 @@
|
|
|
5
5
|
*
|
|
6
6
|
**/
|
|
7
7
|
import React from 'react';
|
|
8
|
+
import { ThemeType, ThemeName } from '../../types';
|
|
8
9
|
interface LoaderPTProps {
|
|
9
10
|
/** The size in pixels of this loader. */
|
|
10
11
|
size?: number;
|
|
11
12
|
/** The chosen theme type. */
|
|
12
|
-
themeType?:
|
|
13
|
+
themeType?: ThemeType;
|
|
13
14
|
/** The chosen theme name. */
|
|
14
|
-
themeName?:
|
|
15
|
+
themeName?: ThemeName;
|
|
16
|
+
/** Background color */
|
|
17
|
+
backgroundColor?: string;
|
|
18
|
+
/** Background image URL */
|
|
19
|
+
backgroundImage?: string;
|
|
15
20
|
}
|
|
16
21
|
declare function LoaderPT(props: LoaderPTProps): React.JSX.Element;
|
|
17
22
|
export default LoaderPT;
|
package/Components/Loaders/PT.js
CHANGED
|
@@ -146,7 +146,13 @@ function LoaderPT(props) {
|
|
|
146
146
|
}
|
|
147
147
|
}, []);
|
|
148
148
|
const themeName = props.themeType || props.themeName || 'light';
|
|
149
|
-
return react_1.default.createElement("div", { className: `pt-logo-back logo-background-${themeName}
|
|
149
|
+
return react_1.default.createElement("div", { className: `pt-logo-back logo-background-${themeName}`, style: {
|
|
150
|
+
backgroundImage: (props.backgroundImage && props.backgroundImage !== '@@loginBackgroundImage@@') ? props.backgroundImage :
|
|
151
|
+
(window.loadingBackgroundImage && window.loadingBackgroundImage !== '@@loginBackgroundImage@@' ? `url(${window.loadingBackgroundImage})` : undefined),
|
|
152
|
+
backgroundColor: (props.backgroundColor && props.backgroundColor !== '@@loginBackgroundColor@@') ? props.backgroundColor :
|
|
153
|
+
(window.loadingBackgroundColor && window.loadingBackgroundColor !== '@@loginBackgroundColor@@' ? window.loadingBackgroundColor : (props.themeType === 'dark' ? '#000' : '#FFF')),
|
|
154
|
+
backgroundSize: 'cover',
|
|
155
|
+
} },
|
|
150
156
|
react_1.default.createElement("div", { className: "pt-logo-div", style: { width: size, height: size } },
|
|
151
157
|
react_1.default.createElement("div", { style: { width: 200, height: 200 } },
|
|
152
158
|
react_1.default.createElement("div", { className: "pt-loader-blue pt-loader-block" }),
|
|
@@ -5,13 +5,18 @@
|
|
|
5
5
|
*
|
|
6
6
|
**/
|
|
7
7
|
import React from 'react';
|
|
8
|
+
import { ThemeType, ThemeName } from '../../types';
|
|
8
9
|
interface LoaderVendorProps {
|
|
9
10
|
/** The size in pixels of this loader. */
|
|
10
11
|
size?: number;
|
|
11
12
|
/** The chosen theme type. */
|
|
12
|
-
themeType?:
|
|
13
|
+
themeType?: ThemeType;
|
|
13
14
|
/** The chosen theme name. */
|
|
14
|
-
themeName?:
|
|
15
|
+
themeName?: ThemeName;
|
|
16
|
+
/** Background color */
|
|
17
|
+
backgroundColor?: string;
|
|
18
|
+
/** Background image URL */
|
|
19
|
+
backgroundImage?: string;
|
|
15
20
|
}
|
|
16
21
|
declare function LoaderVendor(props: LoaderVendorProps): React.JSX.Element;
|
|
17
22
|
export default LoaderVendor;
|
|
@@ -56,6 +56,11 @@ function LoaderVendor(props) {
|
|
|
56
56
|
height: '100%',
|
|
57
57
|
width: '10%',
|
|
58
58
|
margin: 'auto',
|
|
59
|
+
backgroundImage: (props.backgroundImage && props.backgroundImage !== '@@loginBackgroundImage@@') ? props.backgroundImage :
|
|
60
|
+
(window.loadingBackgroundImage && window.loadingBackgroundImage !== '@@loginBackgroundImage@@' ? `url(${window.loadingBackgroundImage})` : undefined),
|
|
61
|
+
backgroundColor: (props.backgroundColor && props.backgroundColor !== '@@loginBackgroundColor@@') ? props.backgroundColor :
|
|
62
|
+
(window.loadingBackgroundColor && window.loadingBackgroundColor !== '@@loginBackgroundColor@@' ? window.loadingBackgroundColor : (props.themeType === 'dark' ? '#000' : '#FFF')),
|
|
63
|
+
backgroundSize: 'cover',
|
|
59
64
|
} },
|
|
60
65
|
react_1.default.createElement("div", { style: { flexGrow: 1 } }),
|
|
61
66
|
react_1.default.createElement(material_1.CircularProgress, { color: "secondary", size: 200, thickness: 5 }),
|
|
@@ -1,21 +1,24 @@
|
|
|
1
|
-
declare const _default: React.JSXElementConstructor<Omit<PropTypes.InferProps<{
|
|
2
|
-
t: PropTypes.Validator<(...args: any[]) => any>;
|
|
3
|
-
lang: PropTypes.Validator<string>;
|
|
4
|
-
themeType: PropTypes.Requireable<string>;
|
|
5
|
-
value: PropTypes.Requireable<string>;
|
|
6
|
-
onChange: PropTypes.Validator<(...args: any[]) => any>;
|
|
7
|
-
disabled: PropTypes.Requireable<boolean>;
|
|
8
|
-
list: PropTypes.Requireable<object>;
|
|
9
|
-
options: PropTypes.Requireable<object>;
|
|
10
|
-
different: PropTypes.Requireable<NonNullable<string | boolean>>;
|
|
11
|
-
label: PropTypes.Requireable<string>;
|
|
12
|
-
fullWidth: PropTypes.Requireable<boolean>;
|
|
13
|
-
className: PropTypes.Requireable<string>;
|
|
14
|
-
style: PropTypes.Requireable<object>;
|
|
15
|
-
removePrefix: PropTypes.Requireable<string>;
|
|
16
|
-
allowNone: PropTypes.Requireable<boolean>;
|
|
17
|
-
inputProps: PropTypes.Requireable<object>;
|
|
18
|
-
}>, "classes"> & import("@mui/styles").StyledComponentProps<"icon" | "different"> & object>;
|
|
19
|
-
export default _default;
|
|
20
|
-
import PropTypes from 'prop-types';
|
|
21
1
|
import React from 'react';
|
|
2
|
+
import { ThemeType, Translator } from '../types';
|
|
3
|
+
interface SelectWithIconProps {
|
|
4
|
+
t: Translator;
|
|
5
|
+
lang: ioBroker.Languages;
|
|
6
|
+
themeType: ThemeType;
|
|
7
|
+
value?: string;
|
|
8
|
+
onChange: (id: string) => void;
|
|
9
|
+
disabled?: boolean;
|
|
10
|
+
list?: ioBroker.Object[] | Record<string, ioBroker.Object>;
|
|
11
|
+
options?: Record<string, any>;
|
|
12
|
+
different?: string | boolean;
|
|
13
|
+
label?: string;
|
|
14
|
+
fullWidth?: boolean;
|
|
15
|
+
className?: string;
|
|
16
|
+
style?: React.CSSProperties;
|
|
17
|
+
removePrefix?: string;
|
|
18
|
+
allowNone?: boolean;
|
|
19
|
+
inputProps: any;
|
|
20
|
+
classes: Record<string, string>;
|
|
21
|
+
dense?: boolean;
|
|
22
|
+
}
|
|
23
|
+
declare const _default: React.JSXElementConstructor<Omit<SelectWithIconProps, "classes"> & import("@mui/styles").StyledComponentProps<string> & object>;
|
|
24
|
+
export default _default;
|
|
@@ -1,214 +1,153 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
var
|
|
5
|
-
|
|
6
|
-
|
|
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]; } };
|
|
7
|
+
}
|
|
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;
|
|
7
17
|
});
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
var
|
|
11
|
-
var
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
var
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
return {
|
|
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 };
|
|
27
|
+
};
|
|
28
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
+
const react_1 = __importStar(require("react"));
|
|
30
|
+
const styles_1 = require("@mui/styles");
|
|
31
|
+
const material_1 = require("@mui/material");
|
|
32
|
+
const Icon_1 = __importDefault(require("./Icon"));
|
|
33
|
+
const Utils_1 = __importDefault(require("./Utils"));
|
|
34
|
+
const i18n_1 = __importDefault(require("../i18n"));
|
|
35
|
+
const styles = {
|
|
27
36
|
different: {
|
|
28
|
-
|
|
37
|
+
opacity: 0.5,
|
|
29
38
|
},
|
|
30
39
|
icon: {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
}
|
|
35
|
-
};
|
|
40
|
+
width: 16,
|
|
41
|
+
height: 16,
|
|
42
|
+
marginRight: 8,
|
|
43
|
+
},
|
|
36
44
|
};
|
|
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
|
-
|
|
64
|
-
|
|
45
|
+
class SelectWithIcon extends react_1.Component {
|
|
46
|
+
constructor(props) {
|
|
47
|
+
super(props);
|
|
48
|
+
this.timeout = null;
|
|
49
|
+
if (props.different) {
|
|
50
|
+
this.wordDifferent = props.t('ra___different__');
|
|
51
|
+
}
|
|
52
|
+
let list;
|
|
53
|
+
if (Array.isArray(props.list || props.options)) {
|
|
54
|
+
list = (props.list || props.options)
|
|
55
|
+
.map(obj => {
|
|
56
|
+
var _a, _b;
|
|
57
|
+
return ({
|
|
58
|
+
name: Utils_1.default.getObjectNameFromObj(obj, props.lang)
|
|
59
|
+
.replace('system.group.', '')
|
|
60
|
+
.replace('system.user.', '')
|
|
61
|
+
.replace('enum.rooms.', '')
|
|
62
|
+
.replace('enum.functions.', ''),
|
|
63
|
+
value: obj._id,
|
|
64
|
+
icon: (_a = obj.common) === null || _a === void 0 ? void 0 : _a.icon,
|
|
65
|
+
color: (_b = obj.common) === null || _b === void 0 ? void 0 : _b.color,
|
|
66
|
+
});
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
else {
|
|
70
|
+
list = Object.values((props.list || props.options))
|
|
71
|
+
.map(obj => {
|
|
72
|
+
var _a, _b;
|
|
73
|
+
return ({
|
|
74
|
+
name: Utils_1.default.getObjectNameFromObj(obj, props.lang)
|
|
75
|
+
.replace('system.group.', '')
|
|
76
|
+
.replace('system.user.', '')
|
|
77
|
+
.replace('enum.rooms.', '')
|
|
78
|
+
.replace('enum.functions.', ''),
|
|
79
|
+
value: obj._id,
|
|
80
|
+
icon: (_a = obj.common) === null || _a === void 0 ? void 0 : _a.icon,
|
|
81
|
+
color: (_b = obj.common) === null || _b === void 0 ? void 0 : _b.color,
|
|
82
|
+
});
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
if (props.different && props.value === props.different) {
|
|
86
|
+
list.unshift({ value: props.different, name: this.wordDifferent || '' });
|
|
87
|
+
}
|
|
88
|
+
if (props.allowNone) {
|
|
89
|
+
list.unshift({ value: '', name: i18n_1.default.t('ra_none') });
|
|
90
|
+
}
|
|
91
|
+
this.state = {
|
|
92
|
+
list,
|
|
65
93
|
};
|
|
66
|
-
});
|
|
67
|
-
}
|
|
68
|
-
if (_this.props.different && _this.props.value === _this.props.different) {
|
|
69
|
-
list.unshift({
|
|
70
|
-
value: _this.props.different,
|
|
71
|
-
name: _this.wordDifferent
|
|
72
|
-
});
|
|
73
94
|
}
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
})) {
|
|
92
|
-
this.timeout = this.timeout || setTimeout(function () {
|
|
93
|
-
_this2.timeout = null;
|
|
94
|
-
var list = JSON.parse(JSON.stringify(_this2.state.list));
|
|
95
|
-
list.unshift({
|
|
96
|
-
value: '',
|
|
97
|
-
name: _i18n["default"].t('ra_none')
|
|
98
|
-
});
|
|
99
|
-
_this2.setState({
|
|
100
|
-
list: list
|
|
101
|
-
});
|
|
102
|
-
}, 100);
|
|
103
|
-
} else if (!this.props.allowNone && this.state.list.find(function (obj) {
|
|
104
|
-
return obj.value === '';
|
|
105
|
-
})) {
|
|
106
|
-
this.timeout = this.timeout || setTimeout(function () {
|
|
107
|
-
_this2.timeout = null;
|
|
108
|
-
var list = JSON.parse(JSON.stringify(_this2.state.list));
|
|
109
|
-
var i = _this2.state.list.findIndex(function (obj) {
|
|
110
|
-
return obj.value === '';
|
|
111
|
-
});
|
|
112
|
-
list.splice(i, 1);
|
|
113
|
-
_this2.setState({
|
|
114
|
-
list: list
|
|
115
|
-
});
|
|
116
|
-
}, 100);
|
|
117
|
-
}
|
|
118
|
-
var item = this.state.list.find(function (it) {
|
|
119
|
-
return it.value === _this2.props.value || _this2.props.removePrefix && it.value.replace(_this2.props.removePrefix, '') === _this2.props.value;
|
|
120
|
-
});
|
|
121
|
-
var style = this.props.value === this.props.different ? {} : {
|
|
122
|
-
color: (item === null || item === void 0 ? void 0 : item.color) || undefined,
|
|
123
|
-
backgroundColor: _Utils["default"].getInvertedColor(item === null || item === void 0 ? void 0 : item.color, this.props.themeType)
|
|
124
|
-
};
|
|
125
|
-
if (this.props.dense && this.props.style) {
|
|
126
|
-
Object.assign(style, this.props.style);
|
|
127
|
-
}
|
|
128
|
-
var select = /*#__PURE__*/_react["default"].createElement(_material.Select, {
|
|
129
|
-
variant: "standard",
|
|
130
|
-
disabled: this.props.disabled,
|
|
131
|
-
value: this.props.value,
|
|
132
|
-
inputProps: this.props.inputProps,
|
|
133
|
-
renderValue: function renderValue( /* value */
|
|
134
|
-
) {
|
|
135
|
-
return /*#__PURE__*/_react["default"].createElement("span", null, item !== null && item !== void 0 && item.icon ? /*#__PURE__*/_react["default"].createElement(_Icon["default"], {
|
|
136
|
-
src: item === null || item === void 0 ? void 0 : item.icon,
|
|
137
|
-
className: _this2.props.classes.icon
|
|
138
|
-
}) : null, item === null || item === void 0 ? void 0 : item.name);
|
|
139
|
-
},
|
|
140
|
-
classes: {
|
|
141
|
-
root: _Utils["default"].clsx(this.props.value === this.props.different ? this.props.classes.different : '', this.props.dense ? this.props.className : '')
|
|
142
|
-
},
|
|
143
|
-
style: style,
|
|
144
|
-
onChange: function onChange(el) {
|
|
145
|
-
if (_this2.props.different && el.target.value !== _this2.props.different) {
|
|
146
|
-
var pos = null;
|
|
147
|
-
for (var i = 0; i < _this2.state.list.length; i++) {
|
|
148
|
-
if (_this2.state.list[i].value === _this2.props.different) {
|
|
149
|
-
pos = i;
|
|
150
|
-
break;
|
|
151
|
-
}
|
|
152
|
-
}
|
|
153
|
-
if (pos !== null) {
|
|
154
|
-
var list = _Utils["default"].clone(_this2.state.list);
|
|
155
|
-
list.splice(pos, 1);
|
|
156
|
-
_this2.setState({
|
|
157
|
-
list: list
|
|
158
|
-
}, function () {
|
|
159
|
-
return _this2.props.onChange(el.target.value);
|
|
160
|
-
});
|
|
161
|
-
return;
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
_this2.props.onChange(_this2.props.removePrefix ? el.target.value.replace(_this2.props.removePrefix, '') : el.target.value);
|
|
95
|
+
render() {
|
|
96
|
+
if (this.props.allowNone && !this.state.list.find(obj => obj.value === '')) {
|
|
97
|
+
this.timeout = this.timeout || setTimeout(() => {
|
|
98
|
+
this.timeout = null;
|
|
99
|
+
const list = JSON.parse(JSON.stringify(this.state.list));
|
|
100
|
+
list.unshift({ value: '', name: i18n_1.default.t('ra_none') });
|
|
101
|
+
this.setState({ list });
|
|
102
|
+
}, 100);
|
|
103
|
+
}
|
|
104
|
+
else if (!this.props.allowNone && this.state.list.find(obj => obj.value === '')) {
|
|
105
|
+
this.timeout = this.timeout || setTimeout(() => {
|
|
106
|
+
this.timeout = null;
|
|
107
|
+
const list = JSON.parse(JSON.stringify(this.state.list));
|
|
108
|
+
const i = this.state.list.findIndex(obj => obj.value === '');
|
|
109
|
+
list.splice(i, 1);
|
|
110
|
+
this.setState({ list });
|
|
111
|
+
}, 100);
|
|
165
112
|
}
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
113
|
+
const item = this.state.list.find(it => it.value === this.props.value || (this.props.removePrefix && it.value.replace(this.props.removePrefix, '') === this.props.value));
|
|
114
|
+
const style = this.props.value === this.props.different ? {} : {
|
|
115
|
+
color: (item === null || item === void 0 ? void 0 : item.color) || undefined,
|
|
116
|
+
backgroundColor: Utils_1.default.getInvertedColor((item === null || item === void 0 ? void 0 : item.color) || '', this.props.themeType),
|
|
117
|
+
};
|
|
118
|
+
if (this.props.dense && this.props.style) {
|
|
119
|
+
Object.assign(style, this.props.style);
|
|
120
|
+
}
|
|
121
|
+
const select = react_1.default.createElement(material_1.Select, { variant: "standard", disabled: this.props.disabled, value: this.props.value, inputProps: this.props.inputProps, renderValue: ( /* value */) => react_1.default.createElement("span", null,
|
|
122
|
+
(item === null || item === void 0 ? void 0 : item.icon) ? react_1.default.createElement(Icon_1.default, { src: item === null || item === void 0 ? void 0 : item.icon, className: this.props.classes.icon }) : null, item === null || item === void 0 ? void 0 :
|
|
123
|
+
item.name), classes: {
|
|
124
|
+
root: Utils_1.default.clsx(this.props.value === this.props.different ? this.props.classes.different : '', this.props.dense ? this.props.className : ''),
|
|
125
|
+
}, style: style, onChange: el => {
|
|
126
|
+
if (this.props.different && el.target.value !== this.props.different) {
|
|
127
|
+
let pos = null;
|
|
128
|
+
for (let i = 0; i < this.state.list.length; i++) {
|
|
129
|
+
if (this.state.list[i].value === this.props.different) {
|
|
130
|
+
pos = i;
|
|
131
|
+
break;
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
if (pos !== null) {
|
|
135
|
+
const list = Utils_1.default.clone(this.state.list);
|
|
136
|
+
list.splice(pos, 1);
|
|
137
|
+
this.setState({ list }, () => this.props.onChange(el.target.value));
|
|
138
|
+
return;
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
this.props.onChange(this.props.removePrefix ? el.target.value.replace(this.props.removePrefix, '') : el.target.value);
|
|
142
|
+
} }, this.state.list.map(el => react_1.default.createElement(material_1.MenuItem, { className: this.props.different && el.value === this.props.different ? this.props.classes.different : '', style: this.props.different && el.value === this.props.different ? {} : { color: el.color || undefined, backgroundColor: Utils_1.default.getInvertedColor(el.color || '', this.props.themeType) }, key: el.value, value: el.value },
|
|
143
|
+
el.icon ? react_1.default.createElement(Icon_1.default, { src: el.icon, className: this.props.classes.icon }) : null,
|
|
144
|
+
el.name)));
|
|
145
|
+
if (this.props.dense) {
|
|
146
|
+
return select;
|
|
147
|
+
}
|
|
148
|
+
return react_1.default.createElement(material_1.FormControl, { variant: "standard", fullWidth: !!this.props.fullWidth, style: this.props.style, className: this.props.className },
|
|
149
|
+
react_1.default.createElement(material_1.InputLabel, null, this.props.label),
|
|
150
|
+
select);
|
|
189
151
|
}
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
}(_react.Component);
|
|
193
|
-
SelectWithIcon.propTypes = {
|
|
194
|
-
t: _propTypes["default"].func.isRequired,
|
|
195
|
-
lang: _propTypes["default"].string.isRequired,
|
|
196
|
-
themeType: _propTypes["default"].string,
|
|
197
|
-
value: _propTypes["default"].string,
|
|
198
|
-
onChange: _propTypes["default"].func.isRequired,
|
|
199
|
-
disabled: _propTypes["default"].bool,
|
|
200
|
-
list: _propTypes["default"].oneOfType([_propTypes["default"].array, _propTypes["default"].object]),
|
|
201
|
-
// one of "list"(Array) or "options"(object) is required
|
|
202
|
-
options: _propTypes["default"].oneOfType([_propTypes["default"].array, _propTypes["default"].object]),
|
|
203
|
-
// one of "list"(Array) or "options"(object) is required
|
|
204
|
-
different: _propTypes["default"].oneOfType([_propTypes["default"].string, _propTypes["default"].bool]),
|
|
205
|
-
label: _propTypes["default"].string,
|
|
206
|
-
fullWidth: _propTypes["default"].bool,
|
|
207
|
-
className: _propTypes["default"].string,
|
|
208
|
-
style: _propTypes["default"].object,
|
|
209
|
-
removePrefix: _propTypes["default"].string,
|
|
210
|
-
allowNone: _propTypes["default"].bool,
|
|
211
|
-
inputProps: _propTypes["default"].object
|
|
212
|
-
};
|
|
213
|
-
var _default = exports["default"] = (0, _styles.withStyles)(styles)(SelectWithIcon);
|
|
214
|
-
//# sourceMappingURL=SelectWithIcon.js.map
|
|
152
|
+
}
|
|
153
|
+
exports.default = (0, styles_1.withStyles)(styles)(SelectWithIcon);
|
package/Components/types.d.ts
CHANGED
|
@@ -2,59 +2,6 @@ import { Translator, Width } from '../types';
|
|
|
2
2
|
import Connection from '../Connection';
|
|
3
3
|
import Router from './Router';
|
|
4
4
|
|
|
5
|
-
export interface FileBrowserProps {
|
|
6
|
-
/** The key to identify this component. */
|
|
7
|
-
key?: string;
|
|
8
|
-
/** Additional styling for this component. */
|
|
9
|
-
style?: React.CSSProperties;
|
|
10
|
-
/** The CSS class name. */
|
|
11
|
-
className?: string;
|
|
12
|
-
/** Translation function. */
|
|
13
|
-
t: Translator;
|
|
14
|
-
/** The selected language. */
|
|
15
|
-
lang: ioBroker.Languages;
|
|
16
|
-
/** The socket connection. */
|
|
17
|
-
socket: Connection;
|
|
18
|
-
/** Is the component data ready. */
|
|
19
|
-
ready?: boolean;
|
|
20
|
-
/** Is expert mode enabled? (default: false) */
|
|
21
|
-
expertMode?: boolean;
|
|
22
|
-
/** Show the toolbar? (default: false) */
|
|
23
|
-
showToolbar?: boolean;
|
|
24
|
-
/** If defined, allow selecting only files from this folder and subfolders */
|
|
25
|
-
limitPath?: string;
|
|
26
|
-
/** Allow upload of new files? (default: false) */
|
|
27
|
-
allowUpload?: boolean;
|
|
28
|
-
/** Allow download of files? (default: false) */
|
|
29
|
-
allowDownload?: boolean;
|
|
30
|
-
/** Allow creation of new folders? (default: false) */
|
|
31
|
-
allowCreateFolder?: boolean;
|
|
32
|
-
/** Allow deleting files? (default: false) */
|
|
33
|
-
allowDelete?: boolean;
|
|
34
|
-
/** Allow viewing files? (default: false) */
|
|
35
|
-
allowView?: boolean;
|
|
36
|
-
/** Prefix (default: '.') */
|
|
37
|
-
imagePrefix?: string;
|
|
38
|
-
/** Show the expert button? */
|
|
39
|
-
showExpertButton?: boolean;
|
|
40
|
-
/** Type of view */
|
|
41
|
-
viewType?: 'Table' | 'Tile';
|
|
42
|
-
/** Show the buttons to switch the view from table to tile? (default: false) */
|
|
43
|
-
showViewTypeButton?: boolean;
|
|
44
|
-
/** The ID of the selected file. */
|
|
45
|
-
selected?: string | string[];
|
|
46
|
-
/** The file extensions to show, like ['png', 'svg', 'bmp', 'jpg', 'jpeg', 'gif']. */
|
|
47
|
-
filterFiles?: string[];
|
|
48
|
-
/** The file extension categories to show. */
|
|
49
|
-
filterByType?: 'images' | 'code' | 'txt';
|
|
50
|
-
/** Callback for file selection. */
|
|
51
|
-
onSelect?: (id: string | string[], isDoubleClick?: boolean, isFolder?: boolean) => void;
|
|
52
|
-
/** Theme name */
|
|
53
|
-
themeName?: string;
|
|
54
|
-
/** Theme type. */
|
|
55
|
-
themeType?: 'dark' | 'light';
|
|
56
|
-
}
|
|
57
|
-
|
|
58
5
|
export interface ObjectBrowserTableFilter {
|
|
59
6
|
id?: string;
|
|
60
7
|
name?: string;
|
package/README.md
CHANGED