@phillips/seldon 1.84.0 → 1.84.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.
|
@@ -1,64 +1,72 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import { forwardRef as h, useRef as
|
|
3
|
-
import { getCommonProps as
|
|
4
|
-
import
|
|
5
|
-
|
|
1
|
+
import { jsxs as S, jsx as l } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef as h, useRef as y, useState as E, useCallback as v, useEffect as w } from "react";
|
|
3
|
+
import { getCommonProps as x } from "../../utils/index.js";
|
|
4
|
+
import m from "../../node_modules/classnames/index.js";
|
|
5
|
+
function C(i) {
|
|
6
|
+
return new Promise((a) => {
|
|
7
|
+
const r = document.createElement("img");
|
|
8
|
+
r.onerror = () => a(!1), r.onload = () => a(!0), r.src = i;
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
const P = h(
|
|
6
12
|
({
|
|
7
|
-
className:
|
|
13
|
+
className: i,
|
|
8
14
|
aspectRatio: d = "none",
|
|
9
|
-
objectFit:
|
|
10
|
-
hasBlurBackground:
|
|
15
|
+
objectFit: a = "none",
|
|
16
|
+
hasBlurBackground: r = !1,
|
|
11
17
|
imageClassName: u,
|
|
12
|
-
imageStyle:
|
|
13
|
-
src:
|
|
14
|
-
alt:
|
|
15
|
-
errorText:
|
|
16
|
-
...
|
|
17
|
-
},
|
|
18
|
-
const { className: e, ...
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
18
|
+
imageStyle: $,
|
|
19
|
+
src: n,
|
|
20
|
+
alt: t,
|
|
21
|
+
errorText: p = "Error loading image",
|
|
22
|
+
...g
|
|
23
|
+
}, N) => {
|
|
24
|
+
const { className: e, ...c } = x(g, "SeldonImage"), b = y(null), [o, s] = E("loading"), f = v(async () => {
|
|
25
|
+
const I = await C(n);
|
|
26
|
+
s(I ? "loaded" : "error");
|
|
27
|
+
}, [n]);
|
|
28
|
+
return w(() => {
|
|
29
|
+
f();
|
|
30
|
+
}, [f]), /* @__PURE__ */ S(
|
|
23
31
|
"div",
|
|
24
32
|
{
|
|
25
|
-
ref:
|
|
26
|
-
className:
|
|
27
|
-
[`${e}--hidden`]:
|
|
33
|
+
ref: N,
|
|
34
|
+
className: m(e, i, {
|
|
35
|
+
[`${e}--hidden`]: o === "loading" || o === "error",
|
|
28
36
|
[`${e}--aspect-ratio-${d.replace("/", "-")}`]: d !== "none"
|
|
29
37
|
}),
|
|
30
38
|
role: "img",
|
|
31
|
-
"aria-label":
|
|
32
|
-
...
|
|
33
|
-
...
|
|
39
|
+
"aria-label": t,
|
|
40
|
+
...g,
|
|
41
|
+
...c,
|
|
34
42
|
children: [
|
|
35
|
-
|
|
43
|
+
r && /* @__PURE__ */ l(
|
|
36
44
|
"div",
|
|
37
45
|
{
|
|
38
|
-
className:
|
|
39
|
-
[`${e}-blur--hidden`]:
|
|
46
|
+
className: m(`${e}-blur`, {
|
|
47
|
+
[`${e}-blur--hidden`]: o === "loading" || o === "error"
|
|
40
48
|
}),
|
|
41
|
-
style: { backgroundImage: `url(${
|
|
49
|
+
style: { backgroundImage: `url(${n})` }
|
|
42
50
|
}
|
|
43
51
|
),
|
|
44
|
-
|
|
45
|
-
/* @__PURE__ */
|
|
52
|
+
o === "error" && /* @__PURE__ */ l("div", { className: `${e}--error`, children: `${p}` }),
|
|
53
|
+
/* @__PURE__ */ l(
|
|
46
54
|
"img",
|
|
47
55
|
{
|
|
48
|
-
className:
|
|
49
|
-
[`${e}-img--hidden`]:
|
|
50
|
-
[`${e}-img--object-fit-${
|
|
56
|
+
className: m(`${e}-img`, u, {
|
|
57
|
+
[`${e}-img--hidden`]: o !== "loaded",
|
|
58
|
+
[`${e}-img--object-fit-${a}`]: a !== "none"
|
|
51
59
|
}),
|
|
52
|
-
style:
|
|
53
|
-
src:
|
|
54
|
-
alt:
|
|
55
|
-
"data-testid": `${
|
|
56
|
-
ref:
|
|
60
|
+
style: $,
|
|
61
|
+
src: n,
|
|
62
|
+
alt: t,
|
|
63
|
+
"data-testid": `${c["data-testid"]}-img`,
|
|
64
|
+
ref: b,
|
|
57
65
|
onLoad: () => {
|
|
58
|
-
|
|
66
|
+
s("loaded");
|
|
59
67
|
},
|
|
60
68
|
onError: () => {
|
|
61
|
-
|
|
69
|
+
s("error");
|
|
62
70
|
}
|
|
63
71
|
}
|
|
64
72
|
)
|
|
@@ -67,7 +75,7 @@ const E = h(
|
|
|
67
75
|
);
|
|
68
76
|
}
|
|
69
77
|
);
|
|
70
|
-
|
|
78
|
+
P.displayName = "SeldonImage";
|
|
71
79
|
export {
|
|
72
|
-
|
|
80
|
+
P as default
|
|
73
81
|
};
|
|
@@ -34,3 +34,12 @@ export declare const BlurBackground: {
|
|
|
34
34
|
};
|
|
35
35
|
argTypes: {};
|
|
36
36
|
};
|
|
37
|
+
export declare const BrokenImage: {
|
|
38
|
+
(props: SeldonImageProps): import("react/jsx-runtime").JSX.Element;
|
|
39
|
+
args: {
|
|
40
|
+
src: string;
|
|
41
|
+
aspectRatio: string;
|
|
42
|
+
objectFit: string;
|
|
43
|
+
};
|
|
44
|
+
argTypes: {};
|
|
45
|
+
};
|