@balena/ui-shared-components 2.2.0 → 2.2.1
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/dist/components/Img/Img.stories.d.ts +1 -1
- package/dist/components/Img/index.d.ts +1 -1
- package/dist/components/Img/index.js +3 -2
- package/dist_esm5/components/Img/Img.stories.d.ts +1 -1
- package/dist_esm5/components/Img/index.d.ts +1 -1
- package/dist_esm5/components/Img/index.js +3 -2
- package/package.json +2 -2
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { StoryObj } from '@storybook/react';
|
|
2
2
|
declare const meta: {
|
|
3
3
|
title: string;
|
|
4
|
-
component: ({ src: srcProp, fallback, ...props }: import(".").ImgProps) => import("react/jsx-runtime").JSX.Element;
|
|
4
|
+
component: ({ src: srcProp, onError, fallback, ...props }: import(".").ImgProps) => import("react/jsx-runtime").JSX.Element;
|
|
5
5
|
tags: string[];
|
|
6
6
|
};
|
|
7
7
|
export default meta;
|
|
@@ -6,4 +6,4 @@ export interface ImgProps extends BoxProps<'img'> {
|
|
|
6
6
|
* This component will display an image given an src.
|
|
7
7
|
* The `fallback` prop has been added to make it easier to update the image in case the primary src fails.
|
|
8
8
|
*/
|
|
9
|
-
export declare const Img: ({ src: srcProp, fallback, ...props }: ImgProps) => import("react/jsx-runtime").JSX.Element;
|
|
9
|
+
export declare const Img: ({ src: srcProp, onError, fallback, ...props }: ImgProps) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -44,11 +44,12 @@ import { useState } from 'react';
|
|
|
44
44
|
* The `fallback` prop has been added to make it easier to update the image in case the primary src fails.
|
|
45
45
|
*/
|
|
46
46
|
export var Img = function (_a) {
|
|
47
|
-
var srcProp = _a.src, fallback = _a.fallback, props = __rest(_a, ["src", "fallback"]);
|
|
47
|
+
var srcProp = _a.src, onError = _a.onError, fallback = _a.fallback, props = __rest(_a, ["src", "onError", "fallback"]);
|
|
48
48
|
var _b = __read(useState(srcProp), 2), src = _b[0], setSrc = _b[1];
|
|
49
|
-
return (_jsx(Box, __assign({ component: "img", src: src }, props, {
|
|
49
|
+
return (_jsx(Box, __assign({ component: "img", src: src }, props, { onError: function (e) {
|
|
50
50
|
if (fallback != null) {
|
|
51
51
|
setSrc(fallback);
|
|
52
52
|
}
|
|
53
|
+
onError === null || onError === void 0 ? void 0 : onError(e);
|
|
53
54
|
} })));
|
|
54
55
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { StoryObj } from '@storybook/react';
|
|
2
2
|
declare const meta: {
|
|
3
3
|
title: string;
|
|
4
|
-
component: ({ src: srcProp, fallback, ...props }: import(".").ImgProps) => import("react/jsx-runtime").JSX.Element;
|
|
4
|
+
component: ({ src: srcProp, onError, fallback, ...props }: import(".").ImgProps) => import("react/jsx-runtime").JSX.Element;
|
|
5
5
|
tags: string[];
|
|
6
6
|
};
|
|
7
7
|
export default meta;
|
|
@@ -6,4 +6,4 @@ export interface ImgProps extends BoxProps<'img'> {
|
|
|
6
6
|
* This component will display an image given an src.
|
|
7
7
|
* The `fallback` prop has been added to make it easier to update the image in case the primary src fails.
|
|
8
8
|
*/
|
|
9
|
-
export declare const Img: ({ src: srcProp, fallback, ...props }: ImgProps) => import("react/jsx-runtime").JSX.Element;
|
|
9
|
+
export declare const Img: ({ src: srcProp, onError, fallback, ...props }: ImgProps) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -7,11 +7,12 @@ import { useState } from 'react';
|
|
|
7
7
|
* The `fallback` prop has been added to make it easier to update the image in case the primary src fails.
|
|
8
8
|
*/
|
|
9
9
|
export var Img = function (_a) {
|
|
10
|
-
var srcProp = _a.src, fallback = _a.fallback, props = __rest(_a, ["src", "fallback"]);
|
|
10
|
+
var srcProp = _a.src, onError = _a.onError, fallback = _a.fallback, props = __rest(_a, ["src", "onError", "fallback"]);
|
|
11
11
|
var _b = __read(useState(srcProp), 2), src = _b[0], setSrc = _b[1];
|
|
12
|
-
return (_jsx(Box, __assign({ component: "img", src: src }, props, {
|
|
12
|
+
return (_jsx(Box, __assign({ component: "img", src: src }, props, { onError: function (e) {
|
|
13
13
|
if (fallback != null) {
|
|
14
14
|
setSrc(fallback);
|
|
15
15
|
}
|
|
16
|
+
onError === null || onError === void 0 ? void 0 : onError(e);
|
|
16
17
|
} })));
|
|
17
18
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@balena/ui-shared-components",
|
|
3
|
-
"version": "2.2.
|
|
3
|
+
"version": "2.2.1",
|
|
4
4
|
"main": "./dist/index.js",
|
|
5
5
|
"module": "./dist_esm5/index.js",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -112,6 +112,6 @@
|
|
|
112
112
|
},
|
|
113
113
|
"homepage": "https://github.com/balena-io/ui-shared-components#readme",
|
|
114
114
|
"versionist": {
|
|
115
|
-
"publishedAt": "2024-02-15T13:
|
|
115
|
+
"publishedAt": "2024-02-15T13:31:52.280Z"
|
|
116
116
|
}
|
|
117
117
|
}
|