@iobroker/adapter-react-v5 4.12.0 → 4.12.2
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/Icon.d.ts +1 -0
- package/Components/Icon.js +7 -3
- package/Components/Image.d.ts +1 -0
- package/Components/Image.js +6 -2
- package/README.md +1 -1
- package/package.json +1 -1
package/Components/Icon.d.ts
CHANGED
package/Components/Icon.js
CHANGED
|
@@ -97,6 +97,7 @@ function getSelectIdIcon(obj, imagePrefix) {
|
|
|
97
97
|
}
|
|
98
98
|
exports.getSelectIdIcon = getSelectIdIcon;
|
|
99
99
|
const REMOTE_SERVER = window.location.hostname.includes('iobroker.in');
|
|
100
|
+
const REMOTE_PREFIX = window.location.pathname.substring(0, window.location.pathname.lastIndexOf('/') + 1);
|
|
100
101
|
const Icon = (props) => {
|
|
101
102
|
var _a, _b, _c;
|
|
102
103
|
if (props.src) {
|
|
@@ -111,14 +112,17 @@ const Icon = (props) => {
|
|
|
111
112
|
if (REMOTE_SERVER && !props.src.startsWith('http://') && !props.src.startsWith('https://')) {
|
|
112
113
|
let src = props.src;
|
|
113
114
|
if (src.startsWith('./')) {
|
|
114
|
-
src = src.substring(2);
|
|
115
|
+
src = REMOTE_PREFIX + src.substring(2);
|
|
115
116
|
}
|
|
116
|
-
|
|
117
|
+
else if (!src.startsWith('/')) {
|
|
118
|
+
src = REMOTE_PREFIX + src;
|
|
119
|
+
}
|
|
120
|
+
return react_1.default.createElement("img", { title: props.title || undefined, style: props.style || {}, className: Utils_1.default.clsx(props.className, 'iconOwn'), src: `https://remote-files.iobroker.in${src}`, alt: props.alt || undefined, ref: props.ref, onError: e => {
|
|
117
121
|
// analyse error
|
|
118
122
|
props.onError && props.onError(e);
|
|
119
123
|
} });
|
|
120
124
|
}
|
|
121
|
-
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: props.alt || undefined, onError: props.onError });
|
|
125
|
+
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: props.alt || undefined, ref: props.ref, onError: props.onError });
|
|
122
126
|
}
|
|
123
127
|
return props.src;
|
|
124
128
|
}
|
package/Components/Image.d.ts
CHANGED
|
@@ -17,6 +17,7 @@ interface ImageState {
|
|
|
17
17
|
declare class Image extends Component<ImageProps, ImageState> {
|
|
18
18
|
private svg;
|
|
19
19
|
static REMOTE_SERVER: boolean;
|
|
20
|
+
static REMOTE_PREFIX: string;
|
|
20
21
|
constructor(props: ImageProps);
|
|
21
22
|
static getDerivedStateFromProps(props: ImageProps, state: ImageState): ImageState;
|
|
22
23
|
getSvgFromData(src: string): React.JSX.Element | null;
|
package/Components/Image.js
CHANGED
|
@@ -132,9 +132,12 @@ class Image extends react_1.Component {
|
|
|
132
132
|
if (Image.REMOTE_SERVER && !this.state.src.startsWith('http://') && !this.state.src.startsWith('https://')) {
|
|
133
133
|
let src = (this.props.imagePrefix || '') + this.state.src;
|
|
134
134
|
if (src.startsWith('./')) {
|
|
135
|
-
src = src.substring(2);
|
|
135
|
+
src = Image.REMOTE_PREFIX + src.substring(2);
|
|
136
136
|
}
|
|
137
|
-
|
|
137
|
+
else if (!src.startsWith('/')) {
|
|
138
|
+
src = Image.REMOTE_PREFIX + src;
|
|
139
|
+
}
|
|
140
|
+
return react_1.default.createElement("img", { className: this.props.className, src: `https://remote-files.iobroker.in${src}`, alt: "", onError: () => (this.props.showError ? this.setState({ imgError: true }) : this.setState({ src: '' })) });
|
|
138
141
|
}
|
|
139
142
|
return react_1.default.createElement("img", { className: this.props.className, src: (this.props.imagePrefix || '') + this.state.src, alt: "", onError: () => (this.props.showError ? this.setState({ imgError: true }) : this.setState({ src: '' })) });
|
|
140
143
|
}
|
|
@@ -142,4 +145,5 @@ class Image extends react_1.Component {
|
|
|
142
145
|
}
|
|
143
146
|
}
|
|
144
147
|
Image.REMOTE_SERVER = window.location.hostname.includes('iobroker.in');
|
|
148
|
+
Image.REMOTE_PREFIX = window.location.pathname.substring(0, window.location.pathname.lastIndexOf('/') + 1);
|
|
145
149
|
exports.default = Image;
|
package/README.md
CHANGED