@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.
@@ -13,6 +13,7 @@ interface IconProps {
13
13
  /** Styles for utf-8 characters */
14
14
  styleUTF8?: React.CSSProperties;
15
15
  onError?: ReactEventHandler<HTMLImageElement>;
16
+ ref?: React.RefObject<HTMLImageElement>;
16
17
  /** Alternative text for image */
17
18
  alt?: string;
18
19
  }
@@ -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
- 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${window.location.pathname}${src}`, alt: props.alt || undefined, onError: e => {
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
  }
@@ -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;
@@ -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
- return react_1.default.createElement("img", { className: this.props.className, src: src, alt: "", onError: () => (this.props.showError ? this.setState({ imgError: true }) : this.setState({ src: '' })) });
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
@@ -670,7 +670,7 @@ socket.getObjectViewCustom('custom', 'state', 'startKey', 'endKey')
670
670
  -->
671
671
 
672
672
  ## Changelog
673
- ### 4.12.0 (2024-03-24)
673
+ ### 4.12.2 (2024-03-25)
674
674
  * (bluefox) Added support for remote cloud
675
675
 
676
676
  ### 4.11.6 (2024-03-19)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@iobroker/adapter-react-v5",
3
- "version": "4.12.0",
3
+ "version": "4.12.2",
4
4
  "description": "React classes to develop admin interfaces for ioBroker with react.",
5
5
  "author": {
6
6
  "name": "Denis Haev (bluefox)",