@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.
@@ -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?: 'dark' | 'light';
20
+ themeType?: ThemeType;
20
21
  /** Theme name*/
21
- themeName?: 'dark' | 'light' | 'colored' | 'blue';
22
+ themeName?: ThemeName;
22
23
  /** @deprecated Theme name. use themeName instead */
23
- theme?: 'dark' | 'light' | 'colored' | 'blue';
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;
@@ -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: window.loadingBackgroundImage && window.loadingBackgroundImage !== '@@loginBackgroundImage@@' ? `url(${window.loadingBackgroundImage})` : undefined,
270
- backgroundColor: window.loadingBackgroundColor && window.loadingBackgroundColor !== '@@loginBackgroundColor@@' ? window.loadingBackgroundColor : undefined,
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?: 'dark' | 'light';
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;
@@ -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 themeName = props.themeType || 'light';
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
- backgroundColor: themeName === 'dark' ? '#000' : '#FFF',
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?: 'dark' | 'light';
13
+ themeType?: ThemeType;
13
14
  /** The chosen theme name. */
14
- themeName?: string;
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;
@@ -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?: 'dark' | 'light';
13
+ themeType?: ThemeType;
13
14
  /** The chosen theme name. */
14
- themeName?: string;
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
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
- var _typeof = require("@babel/runtime/helpers/typeof");
5
- Object.defineProperty(exports, "__esModule", {
6
- value: true
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
- exports["default"] = void 0;
9
- var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
10
- var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
11
- var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
12
- var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
13
- var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
14
- var _react = _interopRequireWildcard(require("react"));
15
- var _propTypes = _interopRequireDefault(require("prop-types"));
16
- var _styles = require("@mui/styles");
17
- var _material = require("@mui/material");
18
- var _Icon = _interopRequireDefault(require("./Icon"));
19
- var _Utils = _interopRequireDefault(require("./Utils"));
20
- var _i18n = _interopRequireDefault(require("../i18n"));
21
- 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); }
22
- 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; }
23
- 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)); }
24
- function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
25
- var styles = function styles() {
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
- opacity: 0.5
37
+ opacity: 0.5,
29
38
  },
30
39
  icon: {
31
- width: 16,
32
- height: 16,
33
- marginRight: 8
34
- }
35
- };
40
+ width: 16,
41
+ height: 16,
42
+ marginRight: 8,
43
+ },
36
44
  };
37
- var SelectWithIcon = /*#__PURE__*/function (_Component) {
38
- (0, _inherits2["default"])(SelectWithIcon, _Component);
39
- function SelectWithIcon(props) {
40
- var _this;
41
- (0, _classCallCheck2["default"])(this, SelectWithIcon);
42
- _this = _callSuper(this, SelectWithIcon, [props]);
43
- if (_this.props.different) {
44
- _this.wordDifferent = _this.props.t(_this.props.different);
45
- }
46
- var list;
47
- if (Array.isArray(_this.props.list || _this.props.options)) {
48
- list = _this.props.list.map(function (obj) {
49
- var _obj$common, _obj$common2;
50
- return {
51
- name: _Utils["default"].getObjectNameFromObj(obj, _this.props.lang).replace('system.group.', '').replace('system.user.', '').replace('enum.rooms.', '').replace('enum.functions.', ''),
52
- value: obj._id,
53
- icon: (_obj$common = obj.common) === null || _obj$common === void 0 ? void 0 : _obj$common.icon,
54
- color: (_obj$common2 = obj.common) === null || _obj$common2 === void 0 ? void 0 : _obj$common2.color
55
- };
56
- });
57
- } else {
58
- list = Object.values(_this.props.list || _this.props.options).map(function (obj) {
59
- var _obj$common3, _obj$common4;
60
- return {
61
- name: _Utils["default"].getObjectNameFromObj(obj, _this.props.lang).replace('system.group.', '').replace('system.user.', '').replace('enum.rooms.', '').replace('enum.functions.', ''),
62
- value: obj._id,
63
- icon: (_obj$common3 = obj.common) === null || _obj$common3 === void 0 ? void 0 : _obj$common3.icon,
64
- color: (_obj$common4 = obj.common) === null || _obj$common4 === void 0 ? void 0 : _obj$common4.color
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
- if (_this.props.allowNone) {
75
- list.unshift({
76
- value: '',
77
- name: _i18n["default"].t('ra_none')
78
- });
79
- }
80
- _this.state = {
81
- list: list
82
- };
83
- return _this;
84
- }
85
- (0, _createClass2["default"])(SelectWithIcon, [{
86
- key: "render",
87
- value: function render() {
88
- var _this2 = this;
89
- if (this.props.allowNone && !this.state.list.find(function (obj) {
90
- return obj.value === '';
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
- }, this.state.list.map(function (el) {
167
- return /*#__PURE__*/_react["default"].createElement(_material.MenuItem, {
168
- className: _this2.props.different && el.value === _this2.props.different ? _this2.props.classes.different : '',
169
- style: _this2.props.different && el.value === _this2.props.different ? {} : {
170
- color: el.color || undefined,
171
- backgroundColor: _Utils["default"].getInvertedColor(el.color, _this2.props.themeType)
172
- },
173
- key: el.value,
174
- value: el.value
175
- }, el.icon ? /*#__PURE__*/_react["default"].createElement(_Icon["default"], {
176
- src: el.icon,
177
- className: _this2.props.classes.icon
178
- }) : null, el.name);
179
- }));
180
- if (this.props.dense) {
181
- return select;
182
- }
183
- return /*#__PURE__*/_react["default"].createElement(_material.FormControl, {
184
- variant: "standard",
185
- fullWidth: !!this.props.fullWidth,
186
- style: this.props.style,
187
- className: this.props.className
188
- }, /*#__PURE__*/_react["default"].createElement(_material.InputLabel, null, this.props.label), select);
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
- return SelectWithIcon;
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);
@@ -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
@@ -670,7 +670,7 @@ socket.getObjectViewCustom('custom', 'state', 'startKey', 'endKey')
670
670
  -->
671
671
 
672
672
  ## Changelog
673
- ### 4.10.2 (2024-03-16)
673
+ ### 4.10.4 (2024-03-16)
674
674
  * (bluefox) Migrated some components to typescript
675
675
 
676
676
  ### 4.10.1 (2024-03-11)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@iobroker/adapter-react-v5",
3
- "version": "4.10.2",
3
+ "version": "4.10.4",
4
4
  "description": "React classes to develop admin interfaces for ioBroker with react.",
5
5
  "author": {
6
6
  "name": "Denis Haev (bluefox)",