@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 b, jsx as a } from "react/jsx-runtime";
2
- import { forwardRef as h, useRef as I, useState as v, useEffect as x } from "react";
3
- import { getCommonProps as y } from "../../utils/index.js";
4
- import n from "../../node_modules/classnames/index.js";
5
- const E = h(
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: f,
13
+ className: i,
8
14
  aspectRatio: d = "none",
9
- objectFit: l = "none",
10
- hasBlurBackground: $ = !1,
15
+ objectFit: a = "none",
16
+ hasBlurBackground: r = !1,
11
17
  imageClassName: u,
12
- imageStyle: p,
13
- src: s,
14
- alt: m,
15
- errorText: N = "Error loading image",
16
- ...i
17
- }, S) => {
18
- const { className: e, ...t } = y(i, "SeldonImage"), g = I(null), [r, o] = v("loading");
19
- return x(() => {
20
- var c;
21
- (c = g.current) != null && c.complete && o("loaded");
22
- }, []), /* @__PURE__ */ b(
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: S,
26
- className: n(e, f, {
27
- [`${e}--hidden`]: r === "loading" || r === "error",
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": m,
32
- ...i,
33
- ...t,
39
+ "aria-label": t,
40
+ ...g,
41
+ ...c,
34
42
  children: [
35
- $ && /* @__PURE__ */ a(
43
+ r && /* @__PURE__ */ l(
36
44
  "div",
37
45
  {
38
- className: n(`${e}-blur`, {
39
- [`${e}-blur--hidden`]: r === "loading" || r === "error"
46
+ className: m(`${e}-blur`, {
47
+ [`${e}-blur--hidden`]: o === "loading" || o === "error"
40
48
  }),
41
- style: { backgroundImage: `url(${s})` }
49
+ style: { backgroundImage: `url(${n})` }
42
50
  }
43
51
  ),
44
- r === "error" && /* @__PURE__ */ a("div", { className: `${e}--error`, children: `${N}` }),
45
- /* @__PURE__ */ a(
52
+ o === "error" && /* @__PURE__ */ l("div", { className: `${e}--error`, children: `${p}` }),
53
+ /* @__PURE__ */ l(
46
54
  "img",
47
55
  {
48
- className: n(`${e}-img`, u, {
49
- [`${e}-img--hidden`]: r === "loading" || r === "error",
50
- [`${e}-img--object-fit-${l}`]: l !== "none"
56
+ className: m(`${e}-img`, u, {
57
+ [`${e}-img--hidden`]: o !== "loaded",
58
+ [`${e}-img--object-fit-${a}`]: a !== "none"
51
59
  }),
52
- style: p,
53
- src: s,
54
- alt: m,
55
- "data-testid": `${t["data-testid"]}-img`,
56
- ref: g,
60
+ style: $,
61
+ src: n,
62
+ alt: t,
63
+ "data-testid": `${c["data-testid"]}-img`,
64
+ ref: b,
57
65
  onLoad: () => {
58
- o("loaded");
66
+ s("loaded");
59
67
  },
60
68
  onError: () => {
61
- o("error");
69
+ s("error");
62
70
  }
63
71
  }
64
72
  )
@@ -67,7 +75,7 @@ const E = h(
67
75
  );
68
76
  }
69
77
  );
70
- E.displayName = "SeldonImage";
78
+ P.displayName = "SeldonImage";
71
79
  export {
72
- E as default
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
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@phillips/seldon",
3
- "version": "1.84.0",
3
+ "version": "1.84.1",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/PhillipsAuctionHouse/seldon"