@nivaro/react 0.3.128 → 0.3.129

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.
@@ -0,0 +1,168 @@
1
+ import { jsxs as a, jsx as n, Fragment as h } from "react/jsx-runtime";
2
+ import { Gitlab as l, Link2 as x } from "lucide-react";
3
+ import { useMemo as m } from "react";
4
+ import { useHeaderAnchor as f } from "../item-edit/HeaderTools.js";
5
+ import { Popover as b, PopoverAnchor as g, PopoverContent as v } from "../ui/popover.js";
6
+ import { TrackerLinkPanel as k } from "./TrackerLinkPanel.js";
7
+ import { ticketLabelsFor as N } from "./tracker-model.js";
8
+ function p({
9
+ tracker: e,
10
+ source: i,
11
+ sourceTitle: r,
12
+ fixedLabels: t,
13
+ initialMode: o,
14
+ onClose: s
15
+ }) {
16
+ if (!e.canCreate) return null;
17
+ const c = e.isAdmin ? null : e.chips[0] ?? null;
18
+ return /* @__PURE__ */ n(
19
+ k,
20
+ {
21
+ source: i,
22
+ admin: e.isAdmin,
23
+ connections: e.connections,
24
+ link: e.link,
25
+ chip: c,
26
+ pending: e.failed,
27
+ creating: e.creating,
28
+ slow: e.slow,
29
+ onCheckAgain: e.checkAgain,
30
+ sourceTitle: r,
31
+ fixedLabels: t,
32
+ initialMode: o,
33
+ onClose: s,
34
+ onCreated: e.markCreating,
35
+ onChanged: e.refresh
36
+ }
37
+ );
38
+ }
39
+ function P({
40
+ tracker: e,
41
+ ticket: i
42
+ }) {
43
+ const r = m(
44
+ () => (t) => N(i, t),
45
+ [i]
46
+ );
47
+ return e.canCreate ? /* @__PURE__ */ a("section", { "data-ticket-gitlab": !0, children: [
48
+ /* @__PURE__ */ a("h3", { className: "mb-2 flex items-center gap-1.5 text-[12.5px] font-semibold text-slate-800 dark:text-slate-100", children: [
49
+ /* @__PURE__ */ n(l, { className: "h-3.5 w-3.5 text-orange-600 dark:text-orange-400", "aria-hidden": !0 }),
50
+ "GitLab"
51
+ ] }),
52
+ /* @__PURE__ */ n(
53
+ p,
54
+ {
55
+ tracker: e,
56
+ source: { kind: "ticket", id: String(i.id) },
57
+ sourceTitle: i.title,
58
+ fixedLabels: r
59
+ }
60
+ )
61
+ ] }) : null;
62
+ }
63
+ function R({
64
+ tracker: e,
65
+ recordId: i,
66
+ recordLabel: r,
67
+ mode: t,
68
+ anchor: o,
69
+ onOpenChange: s
70
+ }) {
71
+ const c = m(() => ({ current: o }), [o]);
72
+ if (!t || !e.canCreate) return null;
73
+ const u = t === "create" ? "Create GitLab issue" : t === "link" ? "Link GitLab issue" : "GitLab issue";
74
+ return /* @__PURE__ */ a(b, { open: !0, onOpenChange: s, children: [
75
+ /* @__PURE__ */ n(g, { virtualRef: c }),
76
+ /* @__PURE__ */ a(
77
+ v,
78
+ {
79
+ align: "end",
80
+ role: "dialog",
81
+ "aria-label": u,
82
+ className: "max-h-[min(80vh,640px)] w-[460px] max-w-[calc(100vw-24px)] overflow-y-auto overscroll-contain p-0",
83
+ "data-record-gitlab": t,
84
+ children: [
85
+ /* @__PURE__ */ a("div", { className: "px-4 pt-3.5", children: [
86
+ /* @__PURE__ */ a("p", { className: "flex items-center gap-1.5 text-[13.5px] font-semibold text-slate-900 dark:text-slate-100", children: [
87
+ /* @__PURE__ */ n(l, { className: "h-3.5 w-3.5 text-orange-600 dark:text-orange-400", "aria-hidden": !0 }),
88
+ u
89
+ ] }),
90
+ r && /* @__PURE__ */ n("p", { className: "mt-0.5 truncate text-[12px] text-slate-500 dark:text-muted-foreground", children: r })
91
+ ] }),
92
+ /* @__PURE__ */ n("div", { className: "px-4 pb-4 pt-3", children: /* @__PURE__ */ n(
93
+ p,
94
+ {
95
+ tracker: e,
96
+ source: { kind: "record", id: i },
97
+ sourceTitle: r,
98
+ initialMode: t,
99
+ onClose: () => s(!1)
100
+ }
101
+ ) })
102
+ ]
103
+ }
104
+ )
105
+ ] });
106
+ }
107
+ const d = "inline-flex h-9 items-center gap-1.5 rounded-md border border-input bg-background px-3 text-sm font-medium shadow-sm transition-colors hover:bg-accent hover:text-accent-foreground";
108
+ function M({
109
+ tracker: e,
110
+ onOpen: i
111
+ }) {
112
+ const r = f();
113
+ if (!e.canCreate) return null;
114
+ const t = (o) => (s) => i(o, r() ?? s.currentTarget);
115
+ return e.link ? /* @__PURE__ */ a(
116
+ "button",
117
+ {
118
+ type: "button",
119
+ "data-nvr-menu-close": !0,
120
+ "data-record-gitlab-open": !0,
121
+ "data-tip": "Resync, unlink or see what else is on it",
122
+ onClick: t("idle"),
123
+ className: d,
124
+ children: [
125
+ /* @__PURE__ */ n(l, { className: "h-3.5 w-3.5" }),
126
+ "GitLab issue #",
127
+ e.link.iid
128
+ ]
129
+ }
130
+ ) : e.chips.length > 0 || e.creating ? null : /* @__PURE__ */ a(h, { children: [
131
+ /* @__PURE__ */ a(
132
+ "button",
133
+ {
134
+ type: "button",
135
+ "data-nvr-menu-close": !0,
136
+ "data-record-gitlab-create": !0,
137
+ "data-tip": "Open a GitLab issue about this record",
138
+ onClick: t("create"),
139
+ className: d,
140
+ children: [
141
+ /* @__PURE__ */ n(l, { className: "h-3.5 w-3.5" }),
142
+ "Create GitLab issue"
143
+ ]
144
+ }
145
+ ),
146
+ /* @__PURE__ */ a(
147
+ "button",
148
+ {
149
+ type: "button",
150
+ "data-nvr-menu-close": !0,
151
+ "data-record-gitlab-link": !0,
152
+ "data-tip": "Link a GitLab issue that already exists",
153
+ onClick: t("link"),
154
+ className: d,
155
+ children: [
156
+ /* @__PURE__ */ n(x, { className: "h-3.5 w-3.5" }),
157
+ "Link GitLab issue"
158
+ ]
159
+ }
160
+ )
161
+ ] });
162
+ }
163
+ export {
164
+ M as RecordGitlabMenuEntries,
165
+ R as RecordTrackerPopover,
166
+ p as SourceTrackerPanel,
167
+ P as TicketTrackerSection
168
+ };
@@ -0,0 +1,71 @@
1
+ import { jsxs as o, Fragment as u, jsx as t } from "react/jsx-runtime";
2
+ import { Gitlab as p } from "lucide-react";
3
+ import { cn as d } from "../../lib/utils.js";
4
+ import { chipOf as h, chipTone as m, safeHref as f, stateWord as x, isLink as k } from "./tracker-model.js";
5
+ const w = {
6
+ open: "border-orange-500/30 bg-orange-50 text-orange-800 dark:border-orange-400/30 dark:bg-orange-500/10 dark:text-orange-300",
7
+ closed: "border-slate-300/70 bg-slate-50 text-slate-500 dark:border-border dark:bg-muted/40 dark:text-muted-foreground",
8
+ error: "border-red-300 bg-red-50 text-red-700 dark:border-red-500/40 dark:bg-red-500/10 dark:text-red-300"
9
+ };
10
+ function N({
11
+ tracker: r,
12
+ className: n
13
+ }) {
14
+ if (!r) return null;
15
+ const e = h(r), a = m(r), s = f(e.web_url), l = a === "error" ? "sync error" : x(e.state), i = k(r) ? r.sync_error : null, c = /* @__PURE__ */ o(u, { children: [
16
+ /* @__PURE__ */ t(p, { className: "h-3 w-3 shrink-0", "aria-hidden": !0 }),
17
+ /* @__PURE__ */ o("span", { className: "tabular-nums", children: [
18
+ "#",
19
+ e.iid
20
+ ] }),
21
+ /* @__PURE__ */ t("span", { "aria-hidden": !0, className: "opacity-60", children: "·" }),
22
+ /* @__PURE__ */ t("span", { children: l })
23
+ ] }), b = d(
24
+ "inline-flex h-5 shrink-0 items-center gap-1 whitespace-nowrap rounded border px-1.5 text-[10.5px] font-medium",
25
+ w[a],
26
+ n
27
+ ), g = i ? `Could not read it from GitLab: ${i}` : e.title ? `${e.title} — opens GitLab` : "Opens GitLab";
28
+ return s ? /* @__PURE__ */ t(
29
+ "a",
30
+ {
31
+ href: s,
32
+ target: "_blank",
33
+ rel: "noreferrer noopener",
34
+ className: d(
35
+ b,
36
+ "hover:underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-nvr-cyan"
37
+ ),
38
+ "data-tip": g,
39
+ "aria-label": `GitLab issue #${e.iid}, ${l}${e.title ? `: ${e.title}` : ""} (opens GitLab)`,
40
+ "data-gitlab-chip": e.iid,
41
+ "data-gitlab-chip-state": a,
42
+ children: c
43
+ }
44
+ ) : /* @__PURE__ */ t(
45
+ "span",
46
+ {
47
+ className: b,
48
+ "data-tip": i ?? (e.title || void 0),
49
+ "data-gitlab-chip": e.iid,
50
+ "data-gitlab-chip-state": a,
51
+ children: c
52
+ }
53
+ );
54
+ }
55
+ function y({
56
+ tracker: r,
57
+ className: n
58
+ }) {
59
+ return r.shown.length ? /* @__PURE__ */ t("span", { className: d("inline-flex flex-wrap items-center gap-1", n), children: r.shown.map((e) => /* @__PURE__ */ t(N, { tracker: e }, `${e.web_url}:${e.iid}`)) }) : null;
60
+ }
61
+ function T() {
62
+ return /* @__PURE__ */ o("span", { className: "inline-flex items-center gap-1 rounded border border-orange-500/30 bg-orange-50 px-1 text-[10px] font-medium text-orange-800 dark:border-orange-400/30 dark:bg-orange-500/10 dark:text-orange-300", children: [
63
+ /* @__PURE__ */ t(p, { className: "h-2.5 w-2.5", "aria-hidden": !0 }),
64
+ "GitLab"
65
+ ] });
66
+ }
67
+ export {
68
+ T as GitlabBadge,
69
+ N as TrackerChip,
70
+ y as TrackerChips
71
+ };