@temp-spotwork/ui 1.7.8 → 1.8.0

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,3 +1,4 @@
1
+ import { ReactNode } from 'react';
1
2
  import { LabelValuePair } from '../form-types';
2
3
 
3
4
  export type SpotterDropdownOption = LabelValuePair & {
@@ -6,9 +7,9 @@ export type SpotterDropdownOption = LabelValuePair & {
6
7
  */
7
8
  image?: string;
8
9
  /**
9
- * Optional secondary line (e.g. email, role, location).
10
+ * Optional secondary line (e.g. email, role, location) or custom React node.
10
11
  */
11
- subtitle?: string;
12
+ subtitle?: ReactNode;
12
13
  };
13
14
  export type DropdownItemProps = {
14
15
  /**
@@ -28,9 +29,9 @@ export type DropdownItemProps = {
28
29
  */
29
30
  textView?: string;
30
31
  /**
31
- * Optional secondary line displayed below the name.
32
+ * Optional secondary line displayed below the name, or a custom React node.
32
33
  */
33
- subtitle?: string;
34
+ subtitle?: ReactNode;
34
35
  /**
35
36
  * Optional classes for the container.
36
37
  */
@@ -1,45 +1,45 @@
1
- import { jsxs as o, jsx as r } from "react/jsx-runtime";
1
+ import { jsxs as o, jsx as t } from "react/jsx-runtime";
2
2
  import { t as c } from "../../../../bundle-mjs-BjFsLjkg.js";
3
3
  import { Avatar as p } from "../../avatar/avatar.js";
4
4
  import { Typography as s } from "../../../styles/typography/typography.js";
5
- import { getStyles as u } from "./styles.js";
5
+ import { getStyles as f } from "./styles.js";
6
6
  function n({
7
- avatarId: e,
8
- name: t,
7
+ avatarId: r,
8
+ name: e,
9
9
  image: l,
10
- textView: m,
11
- subtitle: i,
12
- className: d
10
+ textView: d,
11
+ subtitle: a,
12
+ className: m
13
13
  }) {
14
- const a = u();
15
- return /* @__PURE__ */ o("div", { className: c(a.container, d), "data-testid": "dropdown-item", children: [
16
- /* @__PURE__ */ r(
14
+ const i = f();
15
+ return /* @__PURE__ */ o("div", { className: c(i.container, m), "data-testid": "dropdown-item", children: [
16
+ /* @__PURE__ */ t(
17
17
  p,
18
18
  {
19
- id: e,
19
+ id: r,
20
20
  variant: "circular",
21
21
  image: l,
22
- textView: m ?? t,
22
+ textView: d ?? e,
23
23
  size: 3.5
24
24
  }
25
25
  ),
26
- /* @__PURE__ */ o("div", { className: a.textContainer, children: [
27
- /* @__PURE__ */ r(s, { swStyle: 5, color: "default", className: a.name, children: t }),
28
- i && /* @__PURE__ */ r(s, { swStyle: 6, color: "subdued", className: a.subtitle, children: i })
26
+ /* @__PURE__ */ o("div", { className: i.textContainer, children: [
27
+ /* @__PURE__ */ t(s, { swStyle: 5, color: "default", className: i.name, children: e }),
28
+ a != null && a !== "" && (typeof a == "string" ? /* @__PURE__ */ t(s, { swStyle: 6, color: "subdued", className: i.subtitle, children: a }) : /* @__PURE__ */ t("div", { className: i.subtitle, children: a }))
29
29
  ] })
30
30
  ] });
31
31
  }
32
- function h(e) {
33
- if (typeof e == "string")
34
- return /* @__PURE__ */ r(n, { avatarId: e, name: e });
35
- const t = e;
36
- return /* @__PURE__ */ r(
32
+ function h(r) {
33
+ if (typeof r == "string")
34
+ return /* @__PURE__ */ t(n, { avatarId: r, name: r });
35
+ const e = r;
36
+ return /* @__PURE__ */ t(
37
37
  n,
38
38
  {
39
- avatarId: t.value,
40
- name: t.label,
41
- image: t.image,
42
- subtitle: t.subtitle
39
+ avatarId: e.value,
40
+ name: e.label,
41
+ image: e.image,
42
+ subtitle: e.subtitle
43
43
  }
44
44
  );
45
45
  }
@@ -7,5 +7,8 @@ type Story = StoryObj<typeof meta>;
7
7
  export declare const Default: Story;
8
8
  export declare const WithoutImage: Story;
9
9
  export declare const WithoutSubtitle: Story;
10
+ export declare const WithTextSubtitle: Story;
11
+ export declare const WithChipsSubtitle: Story;
12
+ export declare const SubtitleVariants: Story;
10
13
  export declare const WithDropdownSearch: Story;
11
14
  export declare const WithTypeahead: Story;
@@ -1,9 +1,11 @@
1
- import { jsx as e } from "react/jsx-runtime";
2
- import { useState as o } from "react";
3
- import { DropdownItem as l, renderSpotterDropdownOption as a } from "./dropdown-item.js";
4
- import { DropdownSearch as p } from "../dropdown-search/dropdown-search.js";
5
- import { Typeahead as c } from "../typeahead/typeahead.js";
6
- const s = [
1
+ import { jsx as e, jsxs as p } from "react/jsx-runtime";
2
+ import { a as c } from "../../../../index-CSucbNlF.js";
3
+ import { useState as s } from "react";
4
+ import { DropdownItem as o, renderSpotterDropdownOption as i } from "./dropdown-item.js";
5
+ import { Chips as l } from "../chips/chips.js";
6
+ import { DropdownSearch as d } from "../dropdown-search/dropdown-search.js";
7
+ import { Typeahead as m } from "../typeahead/typeahead.js";
8
+ const n = [
7
9
  {
8
10
  label: "Sarah Johnson",
9
11
  value: "spotter-1",
@@ -26,24 +28,27 @@ const s = [
26
28
  value: "spotter-4",
27
29
  image: "https://i.pravatar.cc/150?u=spotter-4"
28
30
  }
29
- ], g = {
31
+ ], x = {
30
32
  title: "@spotwork-ui/atoms/form/DropdownItem",
31
- component: l,
33
+ component: o,
32
34
  parameters: {
33
35
  layout: "centered",
34
36
  docs: {
35
37
  description: {
36
- component: "A reusable dropdown row for spotter search results. Displays an avatar, name, and optional subtitle using design tokens."
38
+ component: "A reusable dropdown row for spotter search results. Displays an avatar, name, and optional subtitle. The subtitle accepts plain text or any React node (e.g. Typography, Chips)."
37
39
  }
38
40
  }
39
41
  },
40
42
  tags: ["autodocs"],
43
+ decorators: [
44
+ (t) => /* @__PURE__ */ e(c, { children: /* @__PURE__ */ e(t, {}) })
45
+ ],
41
46
  argTypes: {
42
47
  name: { control: "text" },
43
48
  subtitle: { control: "text" },
44
49
  image: { control: "text" }
45
50
  }
46
- }, n = {
51
+ }, a = {
47
52
  args: {
48
53
  avatarId: "spotter-1",
49
54
  name: "Sarah Johnson",
@@ -53,57 +58,113 @@ const s = [
53
58
  decorators: [
54
59
  (t) => /* @__PURE__ */ e("div", { className: "w-[32rem] border border-bcolor-subdued rounded", children: /* @__PURE__ */ e("div", { className: "min-h-[4rem] w-full flex items-center border-b border-bcolor-subdued py-[0.75rem] px-[1rem]", children: /* @__PURE__ */ e(t, {}) }) })
55
60
  ]
56
- }, w = {
61
+ }, T = {
57
62
  args: {
58
63
  avatarId: "spotter-3",
59
64
  name: "Emily Rodriguez",
60
65
  subtitle: "Calgary, AB"
61
66
  },
62
- decorators: n.decorators
63
- }, y = {
67
+ decorators: a.decorators
68
+ }, C = {
64
69
  args: {
65
70
  avatarId: "spotter-4",
66
71
  name: "James Wilson",
67
72
  image: "https://i.pravatar.cc/150?u=spotter-4"
68
73
  },
69
- decorators: n.decorators
70
- }, i = () => {
71
- const [t, r] = o("");
74
+ decorators: a.decorators
75
+ }, N = {
76
+ args: {
77
+ avatarId: "spotter-1",
78
+ name: "Sarah Johnson",
79
+ image: "https://i.pravatar.cc/150?u=spotter-1",
80
+ subtitle: "Toronto, ON"
81
+ },
82
+ decorators: a.decorators
83
+ }, I = {
84
+ args: {
85
+ avatarId: "spotter-2",
86
+ name: "Michael Chen",
87
+ image: "https://i.pravatar.cc/150?u=spotter-2",
88
+ subtitle: /* @__PURE__ */ e(
89
+ l,
90
+ {
91
+ id: "spotter-2-ready-to-work",
92
+ chipText: "Ready to Work",
93
+ color: "paidBackup",
94
+ variant: "pill"
95
+ }
96
+ )
97
+ },
98
+ decorators: a.decorators
99
+ }, W = {
100
+ render: () => /* @__PURE__ */ p("div", { className: "w-[32rem] border border-bcolor-subdued rounded", children: [
101
+ /* @__PURE__ */ e("div", { className: "min-h-[4rem] w-full flex items-center border-b border-bcolor-subdued py-[0.75rem] px-[1rem]", children: /* @__PURE__ */ e(
102
+ o,
103
+ {
104
+ avatarId: "spotter-1",
105
+ name: "Sarah Johnson",
106
+ image: "https://i.pravatar.cc/150?u=spotter-1",
107
+ subtitle: "Toronto, ON"
108
+ }
109
+ ) }),
110
+ /* @__PURE__ */ e("div", { className: "min-h-[4rem] w-full flex items-center py-[0.75rem] px-[1rem]", children: /* @__PURE__ */ e(
111
+ o,
112
+ {
113
+ avatarId: "spotter-2",
114
+ name: "Michael Chen",
115
+ image: "https://i.pravatar.cc/150?u=spotter-2",
116
+ subtitle: /* @__PURE__ */ e(
117
+ l,
118
+ {
119
+ id: "spotter-2-ready-to-work",
120
+ chipText: "Ready to Work",
121
+ color: "paidBackup",
122
+ variant: "pill"
123
+ }
124
+ )
125
+ }
126
+ ) })
127
+ ] })
128
+ }, u = () => {
129
+ const [t, r] = s("");
72
130
  return /* @__PURE__ */ e("div", { className: "w-[36rem]", children: /* @__PURE__ */ e(
73
- p,
131
+ d,
74
132
  {
75
133
  label: "Search spotters",
76
134
  placeholder: "Search by name...",
77
- options: s,
135
+ options: n,
78
136
  value: t,
79
137
  selectValue: r,
80
- renderOption: a
138
+ renderOption: i
81
139
  }
82
140
  ) });
83
- }, S = {
84
- render: () => /* @__PURE__ */ e(i, {})
85
- }, d = () => {
86
- const [t, r] = o("");
141
+ }, D = {
142
+ render: () => /* @__PURE__ */ e(u, {})
143
+ }, h = () => {
144
+ const [t, r] = s("");
87
145
  return /* @__PURE__ */ e("div", { className: "w-[36rem]", children: /* @__PURE__ */ e(
88
- c,
146
+ m,
89
147
  {
90
148
  label: "Search spotters",
91
149
  placeholder: "Search by name...",
92
- options: s,
150
+ options: n,
93
151
  value: t,
94
152
  onChange: r,
95
153
  selectValue: r,
96
- renderOption: a
154
+ renderOption: i
97
155
  }
98
156
  ) });
99
- }, f = {
100
- render: () => /* @__PURE__ */ e(d, {})
157
+ }, O = {
158
+ render: () => /* @__PURE__ */ e(h, {})
101
159
  };
102
160
  export {
103
- n as Default,
104
- S as WithDropdownSearch,
105
- f as WithTypeahead,
106
- w as WithoutImage,
107
- y as WithoutSubtitle,
108
- g as default
161
+ a as Default,
162
+ W as SubtitleVariants,
163
+ I as WithChipsSubtitle,
164
+ D as WithDropdownSearch,
165
+ N as WithTextSubtitle,
166
+ O as WithTypeahead,
167
+ T as WithoutImage,
168
+ C as WithoutSubtitle,
169
+ x as default
109
170
  };
@@ -11,3 +11,4 @@ export declare const WithLabelColorAlert: Story;
11
11
  export declare const WithLabelColorWarning: Story;
12
12
  export declare const WithLabelColorActive: Story;
13
13
  export declare const WithTotalCount: Story;
14
+ export declare const WithTextClassName: Story;
@@ -1,9 +1,13 @@
1
- import { ProgressBar as o } from "./progress-bar.js";
1
+ import t from "react";
2
+ import { ProgressBar as e } from "./progress-bar.js";
2
3
  import "../../../styles/colors/colors.js";
3
- import { glyphColorsKeys as t } from "../../../styles/colors/colormap.js";
4
- const s = {
4
+ import { glyphColorsKeys as l } from "../../../styles/colors/colormap.js";
5
+ const n = {
5
6
  title: "@spotwork-ui/ProgresBar",
6
- component: o,
7
+ component: e,
8
+ decorators: [
9
+ (o) => t.createElement("div", { style: { width: 100 } }, t.createElement(o))
10
+ ],
7
11
  parameters: {
8
12
  layout: "centered"
9
13
  },
@@ -11,7 +15,7 @@ const s = {
11
15
  argTypes: {
12
16
  labelColor: {
13
17
  control: "select",
14
- options: t,
18
+ options: l,
15
19
  description: 'Custom color for the label. Defaults to "subdued" if not provided.'
16
20
  },
17
21
  progress: {
@@ -27,47 +31,47 @@ const s = {
27
31
  control: "text"
28
32
  }
29
33
  }
30
- }, a = {
34
+ }, c = {
31
35
  args: {
32
36
  progress: 50,
33
37
  total: 100,
34
38
  text: "Filled"
35
39
  }
36
- }, n = {
40
+ }, g = {
37
41
  args: {
38
42
  progress: 75,
39
43
  total: 100,
40
44
  text: "Filled"
41
45
  }
42
- }, i = {
46
+ }, p = {
43
47
  args: {
44
48
  progress: 80,
45
49
  total: 100,
46
50
  text: "Filled",
47
51
  labelColor: "success"
48
52
  }
49
- }, c = {
53
+ }, u = {
50
54
  args: {
51
55
  progress: 30,
52
56
  total: 100,
53
57
  text: "Filled",
54
58
  labelColor: "alert"
55
59
  }
56
- }, g = {
60
+ }, C = {
57
61
  args: {
58
62
  progress: 60,
59
63
  total: 100,
60
64
  text: "Filled",
61
65
  labelColor: "warning"
62
66
  }
63
- }, p = {
67
+ }, d = {
64
68
  args: {
65
69
  progress: 90,
66
70
  total: 100,
67
71
  text: "Filled",
68
72
  labelColor: "active"
69
73
  }
70
- }, u = {
74
+ }, m = {
71
75
  args: {
72
76
  progress: 75,
73
77
  total: 100,
@@ -75,14 +79,24 @@ const s = {
75
79
  hasTotalCount: !0,
76
80
  labelColor: "active"
77
81
  }
82
+ }, b = {
83
+ args: {
84
+ progress: 75,
85
+ total: 100,
86
+ text: "",
87
+ hasTotalCount: !0,
88
+ labelColor: "active",
89
+ textClassName: "flex justify-center items-center"
90
+ }
78
91
  };
79
92
  export {
80
- a as Default,
81
- p as WithLabelColorActive,
82
- c as WithLabelColorAlert,
83
- i as WithLabelColorSuccess,
84
- g as WithLabelColorWarning,
85
- u as WithTotalCount,
86
- n as WithoutLabelColor,
87
- s as default
93
+ c as Default,
94
+ d as WithLabelColorActive,
95
+ u as WithLabelColorAlert,
96
+ p as WithLabelColorSuccess,
97
+ C as WithLabelColorWarning,
98
+ b as WithTextClassName,
99
+ m as WithTotalCount,
100
+ g as WithoutLabelColor,
101
+ n as default
88
102
  };
@@ -30,5 +30,9 @@ export type ProgressBarProps = {
30
30
  * Custom class name for the component
31
31
  */
32
32
  className?: string;
33
+ /**
34
+ * Custom class name for the text label
35
+ */
36
+ textClassName?: string;
33
37
  };
34
- export declare function ProgressBar({ progress, total, hasTotalCount, text, swStyle, labelColor, className, }: ProgressBarProps): import("react/jsx-runtime").JSX.Element;
38
+ export declare function ProgressBar({ progress, total, hasTotalCount, text, swStyle, labelColor, className, textClassName, }: ProgressBarProps): import("react/jsx-runtime").JSX.Element;
@@ -1,41 +1,42 @@
1
- import { jsx as a, jsxs as c } from "react/jsx-runtime";
2
- import { Typography as h } from "../../../styles/typography/typography.js";
1
+ import { jsx as d, jsxs as t } from "react/jsx-runtime";
2
+ import { Typography as b } from "../../../styles/typography/typography.js";
3
3
  import "../../../styles/colors/colors.js";
4
- import { surface as b, crusta as B, sun as v, apple as y } from "../../../styles/colors/colormap.js";
4
+ import { surface as B, crusta as v, sun as y, apple as N } from "../../../styles/colors/colormap.js";
5
5
  import { getStyles as $ } from "./styles.js";
6
6
  import { t as o } from "../../../../bundle-mjs-BjFsLjkg.js";
7
- function P({
7
+ function W({
8
8
  progress: e,
9
9
  total: r,
10
- hasTotalCount: n = !1,
11
- text: l = "Filled",
10
+ hasTotalCount: l = !1,
11
+ text: n = "Filled",
12
12
  swStyle: m = 1,
13
13
  labelColor: u,
14
- className: p
14
+ className: p,
15
+ textClassName: f
15
16
  }) {
16
- const s = e && r > 0 ? e / r * 100 : 0, i = 100 - s, f = s <= 33.99 ? b.badge : s <= 66.99 ? B[400] : s <= 99.99 ? v[400] : y[600], g = (n ? `${e > r ? r : e}/${r}` : `${e > r ? r : e}`) + " " + l, t = u ?? "subdued", d = $();
17
- return /* @__PURE__ */ a("div", { children: /* @__PURE__ */ c("div", { className: o(d.container, p), children: [
18
- /* @__PURE__ */ a(h, { swStyle: m, color: t, children: g }),
19
- /* @__PURE__ */ c("div", { className: d.chartBox, children: [
20
- /* @__PURE__ */ a(
17
+ const s = e && r > 0 ? e / r * 100 : 0, i = 100 - s, g = s <= 33.99 ? B.badge : s <= 66.99 ? v[400] : s <= 99.99 ? y[400] : N[600], h = (l ? `${e > r ? r : e}/${r}` : `${e > r ? r : e}`) + " " + n, c = u ?? "subdued", a = $();
18
+ return /* @__PURE__ */ d("div", { children: /* @__PURE__ */ t("div", { className: o(a.container, p), children: [
19
+ /* @__PURE__ */ d(b, { swStyle: m, className: f, color: c, children: h }),
20
+ /* @__PURE__ */ t("div", { className: a.chartBox, children: [
21
+ /* @__PURE__ */ d(
21
22
  "div",
22
23
  {
23
24
  "data-testid": "progress-bar",
24
- style: { width: `${s}%`, background: f },
25
+ style: { width: `${s}%`, background: g },
25
26
  className: o(
26
- d.progressBar,
27
+ a.progressBar,
27
28
  s >= 100 ? "rounded-r-[0.3rem] rounded-l-[0.3rem]" : "rounded-l-[0.3rem]"
28
29
  )
29
30
  }
30
31
  ),
31
- /* @__PURE__ */ a(
32
+ /* @__PURE__ */ d(
32
33
  "div",
33
34
  {
34
35
  "data-testid": "unfilled-progress-bar",
35
36
  style: { width: `${i}%` },
36
37
  className: o(
37
- d.progressBar,
38
- t === "active" ? "bg-progressBar-trackActive" : "bg-progressBar-trackDefault",
38
+ a.progressBar,
39
+ c === "active" ? "bg-progressBar-trackActive" : "bg-progressBar-trackDefault",
39
40
  i >= 100 ? "rounded-[0.3rem]" : "rounded-r-[0.3rem]"
40
41
  )
41
42
  }
@@ -44,5 +45,5 @@ function P({
44
45
  ] }) });
45
46
  }
46
47
  export {
47
- P as ProgressBar
48
+ W as ProgressBar
48
49
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@temp-spotwork/ui",
3
3
  "private": false,
4
- "version": "1.7.8",
4
+ "version": "1.8.0",
5
5
  "type": "module",
6
6
  "main": "dist/main.js",
7
7
  "types": "dist/main.d.ts",