@temp-spotwork/ui 1.9.0 → 1.9.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.
@@ -35,5 +35,10 @@ export type AvatarProps = {
35
35
  * Size of the avatar container in rem. Default is 5.5rem for square and 5rem for circular.
36
36
  */
37
37
  size?: number;
38
+ /**
39
+ * Loads the image only when the avatar is near the viewport, and decodes it off the main thread.
40
+ * For long lists. Default is false, which loads the image immediately.
41
+ */
42
+ lazyLoad?: boolean;
38
43
  };
39
- export declare function Avatar({ id, hasBorder, variant, image, textView, isActive, isOnline, onClick, size, }: AvatarProps): import("react/jsx-runtime").JSX.Element;
44
+ export declare function Avatar({ id, hasBorder, variant, image, textView, isActive, isOnline, onClick, size, lazyLoad, }: AvatarProps): import("react/jsx-runtime").JSX.Element;
@@ -1,79 +1,82 @@
1
- import { jsx as r, Fragment as b, jsxs as _ } from "react/jsx-runtime";
1
+ import { jsx as r, Fragment as b, jsxs as y } from "react/jsx-runtime";
2
2
  import { Typography as I } from "../../styles/typography/typography.js";
3
- import { classesMap as y } from "./styles.js";
4
- import D from "./statusIndicatorIcon.js";
3
+ import { classesMap as D } from "./styles.js";
4
+ import F from "./statusIndicatorIcon.js";
5
5
  import { t as c } from "../../../bundle-mjs-BjFsLjkg.js";
6
- function j({
7
- id: g,
6
+ function B({
7
+ id: v,
8
8
  hasBorder: i = !1,
9
9
  variant: d,
10
10
  image: m,
11
11
  textView: E = "NN",
12
12
  isActive: n,
13
- isOnline: v = !1,
13
+ isOnline: C = !1,
14
14
  onClick: s,
15
- size: t
15
+ size: t,
16
+ lazyLoad: u = !1
16
17
  }) {
17
- const C = (() => {
18
+ const S = (() => {
18
19
  const e = (E ?? "").trim().split(/\s+/).filter(Boolean);
19
20
  return e.length === 0 ? "NN" : e.length === 1 ? e[0][0].toUpperCase() : (e[0][0] + e[e.length - 1][0]).toUpperCase();
20
- })(), a = d === "circular", o = a ? 5 : 5.5, l = t ? t / o : 1, u = y[d](i), p = !a && i && n ? "border-bcolor-active" : "border-bcolor-divider", S = t && o > t ? 1 : 7, U = () => {
21
- s && s(g);
22
- }, x = m ? /* @__PURE__ */ r(b, { children: /* @__PURE__ */ r(
21
+ })(), a = d === "circular", o = a ? 5 : 5.5, l = t ? t / o : 1, p = D[d](i), f = !a && i && n ? "border-bcolor-active" : "border-bcolor-divider", U = t && o > t ? 1 : 7, x = () => {
22
+ s && s(v);
23
+ }, A = m ? /* @__PURE__ */ r(b, { children: /* @__PURE__ */ r(
23
24
  "img",
24
25
  {
25
- className: c(u.image, p),
26
+ className: c(p.image, f),
26
27
  src: m,
27
- alt: "avatar-image"
28
+ alt: "avatar-image",
29
+ loading: u ? "lazy" : void 0,
30
+ decoding: u ? "async" : void 0
28
31
  }
29
32
  ) }) : /* @__PURE__ */ r(b, { children: /* @__PURE__ */ r(
30
33
  "div",
31
34
  {
32
35
  "data-testid": "avatar-text-box",
33
- className: c(u.textBox, p),
36
+ className: c(p.textBox, f),
34
37
  children: /* @__PURE__ */ r(
35
38
  I,
36
39
  {
37
- swStyle: S,
38
- children: C,
40
+ swStyle: U,
41
+ children: S,
39
42
  color: "visualPlaceholderDefault"
40
43
  }
41
44
  )
42
45
  }
43
- ) }), f = 0.25, A = a && v && !n && /* @__PURE__ */ r(
46
+ ) }), h = 0.25, N = a && C && !n && /* @__PURE__ */ r(
44
47
  "div",
45
48
  {
46
49
  className: "absolute",
47
50
  style: {
48
- bottom: `${l * f}rem`,
49
- right: `${l * f}rem`
51
+ bottom: `${l * h}rem`,
52
+ right: `${l * h}rem`
50
53
  },
51
54
  "data-testid": "avatar-online-status",
52
- children: /* @__PURE__ */ r(D, { scalingFactor: l })
55
+ children: /* @__PURE__ */ r(F, { scalingFactor: l })
53
56
  }
54
- ), h = s ? "button" : "div", N = () => a && n ? "border-bcolor-active" : "border-[transparent]";
55
- return /* @__PURE__ */ _(
56
- h,
57
+ ), g = s ? "button" : "div", _ = () => a && n ? "border-bcolor-active" : "border-[transparent]";
58
+ return /* @__PURE__ */ y(
59
+ g,
57
60
  {
58
61
  "data-testid": "avatar-container",
59
- onClick: U,
62
+ onClick: x,
60
63
  style: {
61
64
  width: `${t || o}rem`,
62
65
  height: `${t || o}rem`
63
66
  },
64
67
  className: c(
65
68
  "flex items-center justify-center flex-shrink-0 flex-grow-0 relative",
66
- N(),
69
+ _(),
67
70
  "aspect-square"
68
71
  ),
69
- ...h === "button" ? { type: "button" } : {},
72
+ ...g === "button" ? { type: "button" } : {},
70
73
  children: [
71
- x,
72
- A
74
+ A,
75
+ N
73
76
  ]
74
77
  }
75
78
  );
76
79
  }
77
80
  export {
78
- j as Avatar
81
+ B as Avatar
79
82
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@temp-spotwork/ui",
3
3
  "private": false,
4
- "version": "1.9.0",
4
+ "version": "1.9.1",
5
5
  "type": "module",
6
6
  "main": "dist/main.js",
7
7
  "types": "dist/main.d.ts",