@temp-spotwork/ui 1.8.3 → 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
  };
@@ -1,6 +1,7 @@
1
1
  import { ReactNode } from 'react';
2
2
  import { AvatarProps } from '../../atoms/avatar';
3
3
  import { ButtonProps } from '../button';
4
+ import { GlyphColor } from '../../styles/colors/colormap';
4
5
  import { ProgressBarProps } from '../dataviz/progress-bar';
5
6
 
6
7
  export type CollapsibleCardProps = {
@@ -13,13 +14,22 @@ export type CollapsibleCardProps = {
13
14
  */
14
15
  setOpen: () => void;
15
16
  /**
16
- * The avatar to be displayed on the card (object).
17
+ * The avatar to be displayed on the card (object). Omit it when using `leadingContent` instead.
17
18
  */
18
- avatar: AvatarProps;
19
+ avatar?: AvatarProps;
20
+ /**
21
+ * Optional interactive content (e.g. a select-all checkbox) rendered before the title, in the
22
+ * avatar's place. Clicks inside it don't toggle the card open/closed.
23
+ */
24
+ leadingContent?: ReactNode;
19
25
  /**
20
26
  * The title of the card.
21
27
  */
22
28
  title: string;
29
+ /**
30
+ * Text color for the title. Defaults to 'active'.
31
+ */
32
+ titleColor?: GlyphColor;
23
33
  /**
24
34
  * An optional subtitle for the card.
25
35
  */
@@ -41,4 +51,4 @@ export type CollapsibleCardProps = {
41
51
  */
42
52
  expandedContent: ReactNode;
43
53
  };
44
- export declare function CollapsibleCard({ open, setOpen, avatar, title, subtitle, buttonGroup, dataViz, expandedContent, additionalHeaderRightSideContent, }: CollapsibleCardProps): import("react/jsx-runtime").JSX.Element;
54
+ export declare function CollapsibleCard({ open, setOpen, avatar, leadingContent, title, titleColor, subtitle, buttonGroup, dataViz, expandedContent, additionalHeaderRightSideContent, }: CollapsibleCardProps): import("react/jsx-runtime").JSX.Element;
@@ -1,21 +1,23 @@
1
1
  import { jsxs as r, jsx as e } from "react/jsx-runtime";
2
- import { Avatar as h } from "../../atoms/avatar/avatar.js";
3
- import { Icons as w } from "../../atoms/icons/icons.js";
2
+ import { Avatar as w } from "../../atoms/avatar/avatar.js";
3
+ import { Icons as x } from "../../atoms/icons/icons.js";
4
4
  import "../../atoms/icons/iconsSVGs/Large/Profile.js";
5
5
  import "../../atoms/icons/iconsSVGs/Small/Profile.js";
6
- import { Button as x } from "../button/button.js";
7
- import { Typography as c } from "../../styles/typography/typography.js";
8
- import { ProgressBar as p } from "../dataviz/progress-bar/progress-bar.js";
9
- function b({
10
- open: l,
11
- setOpen: i,
12
- avatar: d,
13
- title: n,
14
- subtitle: s,
15
- buttonGroup: o,
16
- dataViz: a,
17
- expandedContent: f,
18
- additionalHeaderRightSideContent: t
6
+ import { Button as v } from "../button/button.js";
7
+ import { Typography as n } from "../../styles/typography/typography.js";
8
+ import { ProgressBar as C } from "../dataviz/progress-bar/progress-bar.js";
9
+ function D({
10
+ open: i,
11
+ setOpen: o,
12
+ avatar: c,
13
+ leadingContent: m,
14
+ title: f,
15
+ titleColor: t = "active",
16
+ subtitle: a,
17
+ buttonGroup: s,
18
+ dataViz: d,
19
+ expandedContent: h,
20
+ additionalHeaderRightSideContent: p
19
21
  }) {
20
22
  return /* @__PURE__ */ r(
21
23
  "div",
@@ -27,24 +29,26 @@ function b({
27
29
  "div",
28
30
  {
29
31
  className: "flex flex-row gap-[1rem] items-center cursor-pointer min-w-0 grow",
30
- onClick: i,
32
+ onClick: o,
31
33
  children: [
32
- /* @__PURE__ */ e("div", { children: /* @__PURE__ */ e(h, { ...d }) }),
34
+ m && // The whole header toggles the card; stop clicks on interactive leading content from bubbling into it.
35
+ /* @__PURE__ */ e("div", { onClick: (l) => l.stopPropagation(), children: m }),
36
+ c && /* @__PURE__ */ e("div", { children: /* @__PURE__ */ e(w, { ...c }) }),
33
37
  /* @__PURE__ */ r("div", { className: "flex flex-col justify-between min-w-0", children: [
34
38
  /* @__PURE__ */ e(
35
- c,
39
+ n,
36
40
  {
37
41
  swStyle: 8,
38
- children: n,
39
- color: "active",
42
+ children: f,
43
+ color: t,
40
44
  className: "whitespace-nowrap overflow-hidden text-ellipsis"
41
45
  }
42
46
  ),
43
- s && !l && /* @__PURE__ */ e(
44
- c,
47
+ a && !i && /* @__PURE__ */ e(
48
+ n,
45
49
  {
46
50
  swStyle: 1,
47
- children: s,
51
+ children: a,
48
52
  color: "subdued",
49
53
  className: "whitespace-nowrap overflow-hidden text-ellipsis"
50
54
  }
@@ -54,34 +58,34 @@ function b({
54
58
  }
55
59
  ),
56
60
  /* @__PURE__ */ r("div", { className: "flex flex-row gap-[2rem] items-center flex-shrink-0", children: [
57
- t,
58
- !l && a && /* @__PURE__ */ e(
61
+ p,
62
+ !i && d && /* @__PURE__ */ e(
59
63
  "div",
60
64
  {
61
65
  className: "w-[16rem] flex-shrink-0 cursor-pointer",
62
- onClick: i,
63
- children: /* @__PURE__ */ e(p, { hasTotalCount: !0, ...a })
66
+ onClick: o,
67
+ children: /* @__PURE__ */ e(C, { hasTotalCount: !0, ...d })
64
68
  }
65
69
  ),
66
70
  /* @__PURE__ */ r("div", { className: "flex flex-row gap-[1rem]", children: [
67
- o == null ? void 0 : o.map((m) => /* @__PURE__ */ e(x, { ...m }, m.text)),
71
+ s == null ? void 0 : s.map((l) => /* @__PURE__ */ e(v, { ...l }, l.text)),
68
72
  /* @__PURE__ */ e(
69
- w,
73
+ x,
70
74
  {
71
- id: l ? "ChevronUp" : "ChevronDown",
72
- icon: l ? "ChevronUp" : "ChevronDown",
75
+ id: i ? "ChevronUp" : "ChevronDown",
76
+ icon: i ? "ChevronUp" : "ChevronDown",
73
77
  button: !0,
74
- handleClick: i
78
+ handleClick: o
75
79
  }
76
80
  )
77
81
  ] })
78
82
  ] })
79
83
  ] }),
80
- l && f
84
+ i && h
81
85
  ]
82
86
  }
83
87
  );
84
88
  }
85
89
  export {
86
- b as CollapsibleCard
90
+ D as CollapsibleCard
87
91
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@temp-spotwork/ui",
3
3
  "private": false,
4
- "version": "1.8.3",
4
+ "version": "1.9.1",
5
5
  "type": "module",
6
6
  "main": "dist/main.js",
7
7
  "types": "dist/main.d.ts",