@temp-spotwork/ui 1.7.7 → 1.7.9

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,69 +1,70 @@
1
1
  import { jsxs as b, jsx as a } from "react/jsx-runtime";
2
- import A, { useState as L, useEffect as R } from "react";
3
- import { t as D } from "../../../../bundle-mjs-BjFsLjkg.js";
4
- import { Textfield as C } from "../textfield/textfield.js";
5
- import { Icons as k } from "../../icons/icons.js";
2
+ import A, { useState as L, useEffect as C } from "react";
3
+ import { t as F } from "../../../../bundle-mjs-BjFsLjkg.js";
4
+ import { Textfield as k } from "../textfield/textfield.js";
5
+ import { Icons as I } from "../../icons/icons.js";
6
6
  import "../../icons/iconsSVGs/Large/Profile.js";
7
7
  import "../../icons/iconsSVGs/Small/Profile.js";
8
8
  import { Typography as N } from "../../../styles/typography/typography.js";
9
- import { getStyles as I } from "./styles.js";
10
- function le({
11
- error: F = !1,
12
- warning: M = !1,
13
- helperText: _,
9
+ import { getStyles as V } from "./styles.js";
10
+ function fe({
11
+ error: M = !1,
12
+ warning: _ = !1,
13
+ helperText: G,
14
14
  label: O,
15
- placeholder: G = "",
16
- disabled: $ = !1,
15
+ placeholder: $ = "",
16
+ disabled: q = !1,
17
17
  options: r,
18
18
  value: s,
19
19
  selectValue: m,
20
- onChange: d,
21
- endIconClick: c,
22
- addValue: p,
20
+ onChange: c,
21
+ endIconClick: d,
22
+ addValue: E,
23
23
  inputRef: n,
24
24
  onBlur: l,
25
- loadingIcon: q,
26
- autoFocus: z,
27
- expandOnFocus: E,
28
- notFoundText: H = "No results found",
29
- disableOptionsFiltering: J = !1
25
+ loadingIcon: z,
26
+ autoFocus: H,
27
+ expandOnFocus: j,
28
+ notFoundText: J = "No results found",
29
+ disableOptionsFiltering: K = !1,
30
+ renderOption: T
30
31
  }) {
31
- const j = A.useRef(null), y = A.useRef(null), [g, h] = L(!1), [K, w] = L(!1), [T, u] = L(""), i = Array.isArray(r) && typeof r[0] == "object" && r[0] !== null && "label" in r[0] && "value" in r[0];
32
+ const p = A.useRef(null), y = A.useRef(null), [g, h] = L(!1), [P, w] = L(!1), [D, u] = L(""), f = Array.isArray(r) && typeof r[0] == "object" && r[0] !== null && "label" in r[0] && "value" in r[0];
32
33
  A.useEffect(() => {
33
34
  const e = (t) => {
34
- const f = j.current;
35
- f && t.target !== f && !f.contains(t.target) && g && (h(!1), w(!1), l == null || l());
35
+ const i = p.current;
36
+ i && t.target !== i && !i.contains(t.target) && g && (h(!1), w(!1), l == null || l());
36
37
  };
37
38
  return document.addEventListener("mousedown", e), () => {
38
39
  document.removeEventListener("mousedown", e);
39
40
  };
40
- }, [g]), R(() => {
41
- if (i && r && s) {
41
+ }, [g]), C(() => {
42
+ if (f && r && s) {
42
43
  const e = r.find(
43
44
  (t) => t.value === s
44
45
  );
45
46
  u(e.label);
46
47
  }
47
48
  }, [r]);
48
- const x = (e) => typeof e == "string" ? e : e.value, v = (e) => typeof e == "string" ? e : e.label, P = (e) => x(e) === s, o = I(), Q = s !== "" && s !== void 0 ? "Cross" : "MagnifyingGlass", U = (e) => {
49
- const t = (i ? T : s) ?? "";
49
+ const x = (e) => typeof e == "string" ? e : e.value, v = (e) => typeof e == "string" ? e : e.label, Q = (e) => x(e) === s, o = V(), U = s !== "" && s !== void 0 ? "Cross" : "MagnifyingGlass", W = (e) => {
50
+ const t = (f ? D : s) ?? "";
50
51
  return e.toLowerCase().includes(t.toLowerCase());
51
- }, W = () => {
52
+ }, X = () => {
52
53
  var e, t;
53
- i && u(""), c == null || c(), h(!0), (e = n == null ? void 0 : n.current) == null || e.focus(), (t = y == null ? void 0 : y.current) == null || t.focus();
54
- }, X = (e) => {
55
- if (m == null || m(e), i) {
54
+ f && u(""), d == null || d(), h(!0), (e = n == null ? void 0 : n.current) == null || e.focus(), (t = y == null ? void 0 : y.current) == null || t.focus();
55
+ }, Y = (e) => {
56
+ if (m == null || m(e), f) {
56
57
  const t = r.find(
57
- (f) => typeof f != "string" && f.value === e
58
+ (i) => typeof i != "string" && i.value === e
58
59
  );
59
60
  t && u(t.label);
60
61
  }
61
62
  h(!1), w(!1), l == null || l();
62
- }, Y = (e) => {
63
- d == null || d(e), w(!!e);
64
63
  }, Z = (e) => {
65
- u(e), d == null || d(e);
66
- }, S = r == null ? void 0 : r.filter((e) => J ? !0 : U(v(e))).sort(
64
+ c == null || c(e), w(!!e);
65
+ }, R = (e) => {
66
+ u(e), c == null || c(e);
67
+ }, S = r == null ? void 0 : r.filter((e) => K ? !0 : W(v(e))).sort(
67
68
  (e, t) => v(e).toLowerCase().localeCompare(v(t).toLowerCase())
68
69
  );
69
70
  return /* @__PURE__ */ b(
@@ -71,37 +72,37 @@ function le({
71
72
  {
72
73
  className: "flex flex-col w-full relative",
73
74
  onFocus: () => {
74
- E && w(!0), h(!0);
75
+ j && w(!0), h(!0);
75
76
  },
76
- ref: j,
77
+ ref: p,
77
78
  children: [
78
79
  /* @__PURE__ */ a("div", { className: o.outDiv, children: /* @__PURE__ */ a(
79
- C,
80
+ k,
80
81
  {
81
82
  ref: n ?? y,
82
- autoFocus: z,
83
+ autoFocus: H,
83
84
  fieldType: "text",
84
- placeholder: G,
85
- value: i ? T : s,
85
+ placeholder: $,
86
+ value: f ? D : s,
86
87
  endIcon: {
87
- icon: Q,
88
- handleClick: W
88
+ icon: U,
89
+ handleClick: X
89
90
  },
90
- onChange: (e) => i ? Z(e) : Y(e),
91
+ onChange: (e) => f ? R(e) : Z(e),
91
92
  label: O,
92
- helperText: _,
93
- error: F,
94
- warning: M,
95
- disabled: $,
93
+ helperText: G,
94
+ error: M,
95
+ warning: _,
96
+ disabled: q,
96
97
  externalActive: g,
97
- loadingIcon: q
98
+ loadingIcon: z
98
99
  }
99
100
  ) }),
100
- K && (s || E) && m && /* @__PURE__ */ b(
101
+ P && (s || j) && m && /* @__PURE__ */ b(
101
102
  "div",
102
103
  {
103
104
  "data-testid": "typeahead-dropdown",
104
- className: D(
105
+ className: F(
105
106
  o.dropdown,
106
107
  O ? "top-[6.8rem]" : "top-[4.5rem]"
107
108
  // if label doesn't define the height of textfield is different
@@ -111,12 +112,12 @@ function le({
111
112
  "div",
112
113
  {
113
114
  "data-testid": `typeahead-${e}`,
114
- onClick: () => X(x(e)),
115
- className: D(
115
+ onClick: () => Y(x(e)),
116
+ className: F(
116
117
  o.itemContainer,
117
- P(e) ? "bg-surface-active" : "bg-white"
118
+ Q(e) ? "bg-surface-active" : "bg-white"
118
119
  ),
119
- children: /* @__PURE__ */ a(
120
+ children: T ? T(e) : /* @__PURE__ */ a(
120
121
  N,
121
122
  {
122
123
  swStyle: 5,
@@ -127,11 +128,11 @@ function le({
127
128
  },
128
129
  x(e)
129
130
  )) : /* @__PURE__ */ b("div", { className: o.itemContainer, children: [
130
- /* @__PURE__ */ a(N, { swStyle: 5, color: "default", children: H }),
131
+ /* @__PURE__ */ a(N, { swStyle: 5, color: "default", children: J }),
131
132
  " "
132
133
  ] }),
133
- p && s && /* @__PURE__ */ b("div", { className: o.addValue, onClick: () => p(s), children: [
134
- /* @__PURE__ */ a(k, { disabled: !0, id: "addvalue", color: "active", icon: "Add" }),
134
+ E && s && /* @__PURE__ */ b("div", { className: o.addValue, onClick: () => E(s), children: [
135
+ /* @__PURE__ */ a(I, { disabled: !0, id: "addvalue", color: "active", icon: "Add" }),
135
136
  /* @__PURE__ */ a(N, { children: "Add value", swStyle: 5, color: "active" })
136
137
  ] })
137
138
  ]
@@ -142,5 +143,5 @@ function le({
142
143
  );
143
144
  }
144
145
  export {
145
- le as Typeahead
146
+ fe as Typeahead
146
147
  };
@@ -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/dist/main.d.ts CHANGED
@@ -23,6 +23,8 @@ export type { DropdownProps } from './components/atoms/form/dropdown';
23
23
  export { DropdownFilter } from './components/molecules/filter/dropdown-selector';
24
24
  export { DropdownSearch } from './components/atoms/form/dropdown-search';
25
25
  export type { DropdownSearchProps, ExtendedDropdownSearchOption, BaseDropdownSearchOption, } from './components/atoms/form/dropdown-search';
26
+ export { DropdownItem, renderSpotterDropdownOption } from './components/atoms/form/dropdown-item';
27
+ export type { DropdownItemProps, SpotterDropdownOption } from './components/atoms/form/dropdown-item';
26
28
  export { Calendar } from './components/atoms/form/calendar';
27
29
  export type { CalendarProps, CalendarDate } from './components/atoms/form/calendar';
28
30
  export type { DropdownFilterProps, DropdownFilterOption } from './components/molecules/filter/dropdown-selector';