@nivaro/react 0.3.29 → 0.3.31

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,66 +1,67 @@
1
1
  import { jsxs as t, jsx as n } from "react/jsx-runtime";
2
- import { useState as a, useRef as E, useEffect as g, useCallback as W } from "react";
3
- import { get as _, del as F, post as H } from "../../../lib/commands.js";
4
- import { initials as U } from "./HistoryTimeline.js";
5
- import { userErrorMessage as N } from "../../../shared/lib/safe-error.js";
6
- function K({
2
+ import { useState as a, useRef as E, useEffect as g, useCallback as U } from "react";
3
+ import { get as A, del as W, post as F } from "../../../lib/commands.js";
4
+ import { initials as H } from "./HistoryTimeline.js";
5
+ import { UserChip as N } from "../../../shared/components/item-edit/UserChip.js";
6
+ import { userErrorMessage as I } from "../../../shared/lib/safe-error.js";
7
+ function Q({
7
8
  collection: l,
8
9
  itemId: u,
9
10
  states: c,
10
11
  client: r
11
12
  }) {
12
- const [f, k] = a([]), [j, S] = a([]), [b, B] = a(!0), [x, h] = a(!1), [o, p] = a(""), [C, w] = a(""), [m, A] = a(!1), [O, M] = a(!1), [L, v] = a(null), i = E(!0);
13
+ const [f, b] = a([]), [L, B] = a([]), [k, S] = a(!0), [x, h] = a(!1), [s, p] = a(""), [C, m] = a(""), [w, _] = a(!1), [O, $] = a(!1), [j, v] = a(null), i = E(!0);
13
14
  g(() => (i.current = !0, () => {
14
15
  i.current = !1;
15
16
  }), []);
16
- const s = W(async () => {
17
+ const d = U(async () => {
17
18
  var e;
18
19
  if (r)
19
20
  try {
20
- const d = await r.request(
21
- _(`/pipelines/instance/${l}/${u}/owners`)
21
+ const o = await r.request(
22
+ A(`/pipelines/instance/${l}/${u}/owners`)
22
23
  );
23
- i.current && (k(d.data ?? []), M(((e = d.meta) == null ? void 0 : e.can_add) === !0));
24
+ i.current && (b(o.data ?? []), $(((e = o.meta) == null ? void 0 : e.can_add) === !0));
24
25
  } catch {
25
- i.current && k([]);
26
+ i.current && b([]);
26
27
  } finally {
27
- i.current && B(!1);
28
+ i.current && S(!1);
28
29
  }
29
30
  }, [r, l, u]);
30
31
  g(() => {
31
- s();
32
- }, [s]), g(() => {
33
- r && r.request(_("/users", { limit: 200, sort: "first_name" })).then((e) => {
34
- i.current && S(e.data ?? []);
32
+ d();
33
+ }, [d]), g(() => {
34
+ r && r.request(A("/users", { limit: 200, sort: "first_name" })).then((e) => {
35
+ i.current && B(e.data ?? []);
35
36
  }).catch(() => {
36
37
  });
37
38
  }, [r]);
38
- const R = (e) => {
39
+ const M = (e) => {
39
40
  if (!e) return null;
40
- const d = c.find((y) => y.id === e) ?? c.find((y) => y.key === e);
41
- return (d == null ? void 0 : d.label) ?? e;
41
+ const o = c.find((y) => y.id === e) ?? c.find((y) => y.key === e);
42
+ return (o == null ? void 0 : o.label) ?? e;
42
43
  };
43
- async function $() {
44
- if (!(!r || !o || m)) {
45
- A(!0), v(null);
44
+ async function R() {
45
+ if (!(!r || !s || w)) {
46
+ _(!0), v(null);
46
47
  try {
47
48
  await r.request(
48
- H(`/pipelines/instance/${l}/${u}/owners`, {
49
- user: o,
49
+ F(`/pipelines/instance/${l}/${u}/owners`, {
50
+ user: s,
50
51
  state: C || void 0
51
52
  })
52
- ), h(!1), p(""), w(""), await s();
53
+ ), h(!1), p(""), m(""), await d();
53
54
  } catch (e) {
54
- i.current && v(N(e, "Failed to add owner"));
55
+ i.current && v(I(e, "Failed to add owner"));
55
56
  } finally {
56
- i.current && A(!1);
57
+ i.current && _(!1);
57
58
  }
58
59
  }
59
60
  }
60
61
  async function q(e) {
61
62
  if (r)
62
63
  try {
63
- await r.request(F(`/pipelines/instance-owners/${e}`)), await s();
64
+ await r.request(W(`/pipelines/instance-owners/${e}`)), await d();
64
65
  } catch {
65
66
  }
66
67
  }
@@ -88,7 +89,7 @@ function K({
88
89
  }
89
90
  ),
90
91
  "Owners",
91
- b ? /* @__PURE__ */ n("span", { "data-nf-skeleton": !0, style: { display: "inline-block", width: 16, height: 10 } }) : /* @__PURE__ */ t("span", { "data-nf-owners-count": !0, children: [
92
+ k ? /* @__PURE__ */ n("span", { "data-nf-skeleton": !0, style: { display: "inline-block", width: 16, height: 10 } }) : /* @__PURE__ */ t("span", { "data-nf-owners-count": !0, children: [
92
93
  "(",
93
94
  f.length,
94
95
  ")"
@@ -118,7 +119,7 @@ function K({
118
119
  "Add"
119
120
  ] })
120
121
  ] }),
121
- b ? /* @__PURE__ */ t("div", { "data-nf-owners-loading": !0, children: [
122
+ k ? /* @__PURE__ */ t("div", { "data-nf-owners-loading": !0, children: [
122
123
  /* @__PURE__ */ n(
123
124
  "span",
124
125
  {
@@ -134,12 +135,23 @@ function K({
134
135
  }
135
136
  )
136
137
  ] }) : f.length === 0 ? /* @__PURE__ */ n("p", { "data-nf-empty": !0, children: "No owners assigned." }) : /* @__PURE__ */ n("div", { "data-nf-owner-list": !0, children: f.map((e) => /* @__PURE__ */ t("div", { "data-nf-owner-row": !0, children: [
137
- /* @__PURE__ */ n("span", { "data-nf-owner-avatar": !0, children: U(e.first_name, e.last_name, e.email) }),
138
- /* @__PURE__ */ t("div", { "data-nf-owner-info": !0, children: [
139
- /* @__PURE__ */ n("span", { "data-nf-owner-name": !0, children: [e.first_name, e.last_name].filter(Boolean).join(" ") || e.email }),
140
- /* @__PURE__ */ n("span", { "data-nf-owner-email": !0, children: e.email })
141
- ] }),
142
- /* @__PURE__ */ n("span", { "data-nf-owner-scope": !0, children: e.state ? R(e.state) : "all states" }),
138
+ /* @__PURE__ */ n(N, { userId: e.user, children: /* @__PURE__ */ t(
139
+ "button",
140
+ {
141
+ type: "button",
142
+ "data-nf-owner-person": !0,
143
+ "aria-label": `${[e.first_name, e.last_name].filter(Boolean).join(" ") || e.email} — profile`,
144
+ className: "flex min-w-0 flex-1 cursor-pointer items-center gap-2 rounded-md border-0 bg-transparent p-0 text-left text-inherit [font:inherit] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-nvr-cyan",
145
+ children: [
146
+ /* @__PURE__ */ n("span", { "data-nf-owner-avatar": !0, children: H(e.first_name, e.last_name, e.email) }),
147
+ /* @__PURE__ */ t("span", { "data-nf-owner-info": !0, children: [
148
+ /* @__PURE__ */ n("span", { "data-nf-owner-name": !0, children: [e.first_name, e.last_name].filter(Boolean).join(" ") || e.email }),
149
+ /* @__PURE__ */ n("span", { "data-nf-owner-email": !0, children: e.email })
150
+ ] })
151
+ ]
152
+ }
153
+ ) }),
154
+ /* @__PURE__ */ n("span", { "data-nf-owner-scope": !0, children: e.state ? M(e.state) : "all states" }),
143
155
  /* @__PURE__ */ n(
144
156
  "button",
145
157
  {
@@ -171,18 +183,18 @@ function K({
171
183
  ] }, e.id)) }),
172
184
  x && /* @__PURE__ */ t("div", { "data-nf-owners-form": !0, children: [
173
185
  /* @__PURE__ */ n("p", { "data-nf-owners-form-title": !0, children: "Add owner" }),
174
- /* @__PURE__ */ t("select", { value: o, onChange: (e) => p(e.target.value), "data-nf-task-input": !0, children: [
186
+ /* @__PURE__ */ t("select", { value: s, onChange: (e) => p(e.target.value), "data-nf-task-input": !0, children: [
175
187
  /* @__PURE__ */ n("option", { value: "", children: "Select a user…" }),
176
- j.map((e) => {
177
- const d = [e.first_name, e.last_name].filter(Boolean).join(" ") || e.email;
178
- return /* @__PURE__ */ n("option", { value: e.id, children: d }, e.id);
188
+ L.map((e) => {
189
+ const o = [e.first_name, e.last_name].filter(Boolean).join(" ") || e.email;
190
+ return /* @__PURE__ */ n("option", { value: e.id, children: o }, e.id);
179
191
  })
180
192
  ] }),
181
193
  /* @__PURE__ */ t(
182
194
  "select",
183
195
  {
184
196
  value: C,
185
- onChange: (e) => w(e.target.value),
197
+ onChange: (e) => m(e.target.value),
186
198
  "data-nf-task-input": !0,
187
199
  children: [
188
200
  /* @__PURE__ */ n("option", { value: "", children: "All states" }),
@@ -190,7 +202,7 @@ function K({
190
202
  ]
191
203
  }
192
204
  ),
193
- L ? /* @__PURE__ */ n("span", { role: "alert", "data-nf-owners-error": !0, children: L }) : null,
205
+ j ? /* @__PURE__ */ n("span", { role: "alert", "data-nf-owners-error": !0, children: j }) : null,
194
206
  /* @__PURE__ */ t("div", { "data-nf-confirm-actions": !0, children: [
195
207
  /* @__PURE__ */ n(
196
208
  "button",
@@ -198,7 +210,7 @@ function K({
198
210
  type: "button",
199
211
  "data-nf-btn-ghost": !0,
200
212
  onClick: () => {
201
- h(!1), p(""), w(""), v(null);
213
+ h(!1), p(""), m(""), v(null);
202
214
  },
203
215
  children: "Cancel"
204
216
  }
@@ -208,9 +220,9 @@ function K({
208
220
  {
209
221
  type: "button",
210
222
  "data-nf-btn-primary": !0,
211
- disabled: !o || m,
212
- onClick: () => void $(),
213
- children: m ? "…" : "Add"
223
+ disabled: !s || w,
224
+ onClick: () => void R(),
225
+ children: w ? "…" : "Add"
214
226
  }
215
227
  )
216
228
  ] })
@@ -218,5 +230,5 @@ function K({
218
230
  ] });
219
231
  }
220
232
  export {
221
- K as OwnersSection
233
+ Q as OwnersSection
222
234
  };