@nivaro/react 0.3.45 → 0.3.47

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.
Files changed (90) hide show
  1. package/dist/full.css +1 -1
  2. package/dist/hooks/useSessionRecorder.js +1 -1
  3. package/dist/index.d.ts +290 -23
  4. package/dist/index.js +679 -659
  5. package/dist/shared/components/BaseMap.js +149 -103
  6. package/dist/shared/components/CollectionBrowserView.js +813 -826
  7. package/dist/shared/components/ErrorNotice.js +169 -0
  8. package/dist/shared/components/ErrorSurface.js +23 -17
  9. package/dist/shared/components/ListLoadError.js +8 -29
  10. package/dist/shared/components/LoadErrorNote.js +38 -21
  11. package/dist/shared/components/QueryErrorState.js +8 -11
  12. package/dist/shared/components/ReportView.js +1320 -1291
  13. package/dist/shared/components/chat/ChannelArchive.js +60 -60
  14. package/dist/shared/components/chat/ChannelExtras.js +74 -74
  15. package/dist/shared/components/chat/ChatPanel.js +368 -367
  16. package/dist/shared/components/command-center/CommandCenterView.js +313 -69
  17. package/dist/shared/components/command-center/Customize.js +353 -0
  18. package/dist/shared/components/command-center/Header.js +279 -53
  19. package/dist/shared/components/command-center/KioskLinks.js +198 -0
  20. package/dist/shared/components/command-center/PeekPanel.js +144 -3
  21. package/dist/shared/components/command-center/announce.js +13 -0
  22. package/dist/shared/components/command-center/board-prefs.js +99 -0
  23. package/dist/shared/components/command-center/freshness.js +29 -0
  24. package/dist/shared/components/command-center/layout.js +56 -0
  25. package/dist/shared/components/command-center/panels/AttentionPanel.js +132 -3
  26. package/dist/shared/components/command-center/panels/Banner.js +75 -0
  27. package/dist/shared/components/command-center/panels/BoardSettings.js +224 -0
  28. package/dist/shared/components/command-center/panels/FeedPanel.js +145 -29
  29. package/dist/shared/components/command-center/panels/FlowPanel.js +154 -56
  30. package/dist/shared/components/command-center/panels/ForecastPanel.js +244 -3
  31. package/dist/shared/components/command-center/panels/MapLegend.js +266 -0
  32. package/dist/shared/components/command-center/panels/MapPanel.js +216 -66
  33. package/dist/shared/components/command-center/panels/PartnersPanel.js +49 -3
  34. package/dist/shared/components/command-center/panels/PeoplePanel.js +258 -40
  35. package/dist/shared/components/command-center/panels/RegionPicker.js +88 -3
  36. package/dist/shared/components/command-center/panels/SystemPanel.js +158 -38
  37. package/dist/shared/components/command-center/panels/ThroughputPanel.js +307 -3
  38. package/dist/shared/components/command-center/panels/TimeBar.js +227 -6
  39. package/dist/shared/components/command-center/panels/TrafficPanel.js +12 -8
  40. package/dist/shared/components/command-center/panels/WorkloadPanel.js +82 -3
  41. package/dist/shared/components/command-center/panels/attention-actions.js +267 -0
  42. package/dist/shared/components/command-center/panels/map-shared.js +95 -0
  43. package/dist/shared/components/command-center/panels/registry.js +87 -19
  44. package/dist/shared/components/command-center/shell-hooks.js +118 -0
  45. package/dist/shared/components/command-center/shortcuts.js +37 -0
  46. package/dist/shared/components/command-center/theme.js +39 -21
  47. package/dist/shared/components/command-center/time.js +52 -0
  48. package/dist/shared/components/command-center/url-state.js +54 -0
  49. package/dist/shared/components/command-center/work-links.js +32 -0
  50. package/dist/shared/components/help-videos/editor/ClipsPanel.js +49 -48
  51. package/dist/shared/components/help-videos/editor/PublishButton.js +37 -36
  52. package/dist/shared/components/help-videos/editor/StatsTab.js +45 -44
  53. package/dist/shared/components/help-videos/editor/VersionsTab.js +29 -28
  54. package/dist/shared/components/help-videos/library/AuthorRolesButton.js +19 -18
  55. package/dist/shared/components/help-videos/library/HelpVideoLibrary.js +132 -129
  56. package/dist/shared/components/help-videos/library/LearningPathsPanel.js +42 -41
  57. package/dist/shared/components/help-videos/settings/HouseStyleButton.js +21 -20
  58. package/dist/shared/components/help-videos/settings/RenderSettingsButton.js +22 -21
  59. package/dist/shared/components/import/DocumentAutofillButton.js +24 -20
  60. package/dist/shared/components/import/ImportFromFileButton.js +61 -60
  61. package/dist/shared/components/imports/ImportStalenessControl.js +20 -21
  62. package/dist/shared/components/imports/NewImportDialog.js +29 -28
  63. package/dist/shared/components/imports/RunDetailSheet.js +63 -63
  64. package/dist/shared/components/item-edit/FieldRow.js +329 -329
  65. package/dist/shared/components/item-edit/InlineTableField.js +898 -898
  66. package/dist/shared/components/item-edit/PersonalDefaultControl.js +57 -56
  67. package/dist/shared/components/item-edit/PlanGrid.js +220 -221
  68. package/dist/shared/components/item-edit/RecordGrantTools.js +49 -48
  69. package/dist/shared/components/item-edit/placement-behaviour.js +68 -67
  70. package/dist/shared/components/layout-editor/inspector/ColumnFit.js +24 -23
  71. package/dist/shared/components/layout-editor/inspector/PickerPreview.js +17 -16
  72. package/dist/shared/components/layout-editor/matrix/FieldStateMatrix.js +41 -41
  73. package/dist/shared/components/layout-editor/outputs/output-api.js +33 -31
  74. package/dist/shared/components/layout-editor/overview/overview-api.js +84 -83
  75. package/dist/shared/components/layout-editor/useLayoutDraft.js +47 -42
  76. package/dist/shared/components/monitoring/InactiveUserLinksView.js +10 -9
  77. package/dist/shared/components/monitoring/TrafficMiniMap.js +111 -70
  78. package/dist/shared/components/panels/SlaClock.js +35 -36
  79. package/dist/shared/components/pipeline/PipelineEditorView.js +311 -312
  80. package/dist/shared/components/pipeline/TeamSuggestions.js +31 -30
  81. package/dist/shared/components/profile/AgentsPanel.js +73 -72
  82. package/dist/shared/components/profile/MailSuppressedPill.js +22 -21
  83. package/dist/shared/components/support/SupportRequestDialog.js +85 -81
  84. package/dist/shared/components/support/SupportView.js +94 -87
  85. package/dist/shared/lib/autofill-poll.js +21 -18
  86. package/dist/shared/lib/error-actions.js +85 -0
  87. package/dist/shared/lib/error-message.js +223 -82
  88. package/dist/shared/lib/error-toast.js +71 -13
  89. package/dist/shared/lib/safe-error.js +136 -38
  90. package/package.json +1 -1
@@ -0,0 +1,224 @@
1
+ import { jsxs as o, jsx as n } from "react/jsx-runtime";
2
+ import { useQueryClient as M, useMutation as P } from "@tanstack/react-query";
3
+ import { useState as C, useEffect as B } from "react";
4
+ import { toast as w } from "sonner";
5
+ import { useNivaroClient as D } from "../../../context.js";
6
+ import { put as I } from "../../../lib/commands.js";
7
+ import { toastError as U } from "../../../lib/error-toast.js";
8
+ import { cn as a } from "../../../lib/utils.js";
9
+ import { useCcQuery as _ } from "../api.js";
10
+ import { MUTED as S, FAINT as i, FOCUS as l, BUTTON as q } from "../theme.js";
11
+ import { CcSidePanel as A } from "./map-shared.js";
12
+ const G = (d, u) => JSON.stringify(d) === JSON.stringify(u);
13
+ function Y({ onClose: d }) {
14
+ const u = D(), O = M(), p = _("/config/candidates", void 0, {
15
+ lenses: !1,
16
+ staleTime: 0
17
+ }), c = p.data, [h, f] = C(null), [t, m] = C(null), [g, $] = C("");
18
+ B(() => {
19
+ c && (f((e) => e ?? c.config.geo_collections), $((e) => e || String(c.config.stuck_days)), m((e) => {
20
+ if (e) return e;
21
+ const s = c.config.region;
22
+ if (s === !1) return { mode: "none" };
23
+ if (!s) return { mode: "auto" };
24
+ const r = c.regions.findIndex((k) => G(k.source, s));
25
+ return r >= 0 ? { mode: "source", index: r } : { mode: "auto" };
26
+ }));
27
+ }, [c]);
28
+ const b = P({
29
+ mutationFn: () => {
30
+ var s;
31
+ const e = Math.round(Number(g));
32
+ return u.request(
33
+ I("/command-center/config", {
34
+ geo_collections: h ?? [],
35
+ region: (t == null ? void 0 : t.mode) === "none" ? !1 : (t == null ? void 0 : t.mode) === "source" && c ? ((s = c.regions[t.index]) == null ? void 0 : s.source) ?? null : null,
36
+ stuck_days: Number.isFinite(e) ? e : 7
37
+ })
38
+ );
39
+ },
40
+ onSuccess: () => {
41
+ w.success("Board settings saved"), O.invalidateQueries({ queryKey: ["command-center"] }), d();
42
+ },
43
+ onError: (e) => {
44
+ const s = e;
45
+ s.code === "MIGRATION_PENDING" || s.status === 409 ? w.error("These settings can be saved once this instance finishes its update.") : U(e, "Could not save the board settings", { action: "Save board settings" });
46
+ }
47
+ }), N = c == null ? void 0 : c.regions.find((e) => e.suggested), T = (h ?? []).length === 0, E = (e) => f((s) => {
48
+ const r = s ?? [];
49
+ return r.includes(e) ? r.filter((k) => k !== e) : [...r, e];
50
+ }), F = (e) => f((s) => [e, ...(s ?? []).filter((r) => r !== e)]), x = Number(g), y = Number.isFinite(x) && x >= 1 && x <= 365, v = (e) => a(
51
+ "flex w-full cursor-pointer items-start gap-2 rounded-md border px-2.5 py-2 text-left",
52
+ e ? "border-nvr-cyan bg-nvr-cyan/10" : "border-[var(--cc-border)] hover:bg-[var(--cc-chip)]"
53
+ );
54
+ return /* @__PURE__ */ o(
55
+ A,
56
+ {
57
+ open: !0,
58
+ label: "Board settings",
59
+ title: "Board settings",
60
+ subtitle: "For everyone who opens the Command Center",
61
+ onClose: d,
62
+ width: 460,
63
+ footer: /* @__PURE__ */ o("div", { className: "flex items-center justify-end gap-2", children: [
64
+ /* @__PURE__ */ n("button", { type: "button", onClick: d, className: a(q, l), children: "Cancel" }),
65
+ /* @__PURE__ */ n(
66
+ "button",
67
+ {
68
+ type: "button",
69
+ disabled: !c || !y || b.isPending,
70
+ onClick: () => b.mutate(),
71
+ className: a(
72
+ "rounded-md bg-nvr-cyan px-3 py-1 text-[11.5px] font-medium text-white disabled:opacity-50",
73
+ l
74
+ ),
75
+ children: b.isPending ? "Saving…" : "Save"
76
+ }
77
+ )
78
+ ] }),
79
+ children: [
80
+ p.isLoading && /* @__PURE__ */ n("p", { className: `text-[12px] ${S}`, children: "Looking at the data model…" }),
81
+ p.isError && /* @__PURE__ */ n("p", { className: "text-[12px] text-[var(--cc-bad-text)]", children: "Could not load the choices." }),
82
+ c && /* @__PURE__ */ o("div", { className: "space-y-5 text-[12px]", children: [
83
+ /* @__PURE__ */ o("section", { "aria-labelledby": "cc-set-map", children: [
84
+ /* @__PURE__ */ n("h3", { id: "cc-set-map", className: "mb-1 font-semibold text-[var(--cc-strong)]", children: "Map collections" }),
85
+ /* @__PURE__ */ n("p", { className: `mb-2 ${i}`, children: "Collections with a latitude and longitude field. Pick the ones to offer on the map; the first is shown by default. Pick none to offer every one found." }),
86
+ c.geo.length === 0 && /* @__PURE__ */ n("p", { className: S, children: "No collection has latitude and longitude fields yet." }),
87
+ /* @__PURE__ */ n("ul", { className: "space-y-1", children: c.geo.map((e) => {
88
+ const s = (h ?? []).indexOf(e.key);
89
+ return /* @__PURE__ */ o("li", { className: "flex items-center gap-2", children: [
90
+ /* @__PURE__ */ o("label", { className: "flex flex-1 cursor-pointer items-center gap-2", children: [
91
+ /* @__PURE__ */ n(
92
+ "input",
93
+ {
94
+ type: "checkbox",
95
+ checked: s >= 0,
96
+ onChange: () => E(e.key),
97
+ className: a("h-3.5 w-3.5 accent-[#00a5cc]", l)
98
+ }
99
+ ),
100
+ /* @__PURE__ */ n("span", { children: e.label })
101
+ ] }),
102
+ s === 0 && /* @__PURE__ */ n("span", { className: `text-[11px] ${i}`, children: "Default" }),
103
+ s > 0 && /* @__PURE__ */ n(
104
+ "button",
105
+ {
106
+ type: "button",
107
+ onClick: () => F(e.key),
108
+ className: a(
109
+ "text-[11px] underline-offset-2 hover:underline",
110
+ S,
111
+ l
112
+ ),
113
+ children: "Make default"
114
+ }
115
+ )
116
+ ] }, e.key);
117
+ }) }),
118
+ T && c.geo.length > 0 && /* @__PURE__ */ o("p", { className: `mt-1.5 text-[11px] ${i}`, children: [
119
+ "Offering all ",
120
+ c.geo.length,
121
+ " found."
122
+ ] })
123
+ ] }),
124
+ /* @__PURE__ */ o("section", { "aria-labelledby": "cc-set-region", children: [
125
+ /* @__PURE__ */ n("h3", { id: "cc-set-region", className: "mb-1 font-semibold text-[var(--cc-strong)]", children: "Regions" }),
126
+ /* @__PURE__ */ n("p", { className: `mb-2 ${i}`, children: "Regions group the map and the people on it, and let the board focus on one place." }),
127
+ /* @__PURE__ */ o("div", { className: "space-y-1.5", role: "radiogroup", "aria-labelledby": "cc-set-region", children: [
128
+ /* @__PURE__ */ o("label", { className: v((t == null ? void 0 : t.mode) === "auto"), children: [
129
+ /* @__PURE__ */ n(
130
+ "input",
131
+ {
132
+ type: "radio",
133
+ name: "cc-region",
134
+ checked: (t == null ? void 0 : t.mode) === "auto",
135
+ onChange: () => m({ mode: "auto" }),
136
+ className: a("mt-0.5", l)
137
+ }
138
+ ),
139
+ /* @__PURE__ */ o("span", { children: [
140
+ /* @__PURE__ */ n("span", { className: "font-medium text-[var(--cc-strong)]", children: "Work it out for me" }),
141
+ /* @__PURE__ */ n("span", { className: `block ${i}`, children: N ? `Uses ${N.label}: ${N.description}` : "Nothing in the data model looks like a region yet." })
142
+ ] })
143
+ ] }),
144
+ c.regions.map((e, s) => /* @__PURE__ */ o(
145
+ "label",
146
+ {
147
+ className: v((t == null ? void 0 : t.mode) === "source" && t.index === s),
148
+ children: [
149
+ /* @__PURE__ */ n(
150
+ "input",
151
+ {
152
+ type: "radio",
153
+ name: "cc-region",
154
+ checked: (t == null ? void 0 : t.mode) === "source" && t.index === s,
155
+ onChange: () => m({ mode: "source", index: s }),
156
+ className: a("mt-0.5", l)
157
+ }
158
+ ),
159
+ /* @__PURE__ */ o("span", { children: [
160
+ /* @__PURE__ */ o("span", { className: "font-medium text-[var(--cc-strong)]", children: [
161
+ e.label,
162
+ e.suggested && /* @__PURE__ */ n("span", { className: `ml-1.5 font-normal ${i}`, children: "(suggested)" })
163
+ ] }),
164
+ /* @__PURE__ */ n("span", { className: `block ${i}`, children: e.description })
165
+ ] })
166
+ ]
167
+ },
168
+ JSON.stringify(e.source)
169
+ )),
170
+ /* @__PURE__ */ o("label", { className: v((t == null ? void 0 : t.mode) === "none"), children: [
171
+ /* @__PURE__ */ n(
172
+ "input",
173
+ {
174
+ type: "radio",
175
+ name: "cc-region",
176
+ checked: (t == null ? void 0 : t.mode) === "none",
177
+ onChange: () => m({ mode: "none" }),
178
+ className: a("mt-0.5", l)
179
+ }
180
+ ),
181
+ /* @__PURE__ */ o("span", { children: [
182
+ /* @__PURE__ */ n("span", { className: "font-medium text-[var(--cc-strong)]", children: "No regions" }),
183
+ /* @__PURE__ */ n("span", { className: `block ${i}`, children: "Show records and people without grouping them." })
184
+ ] })
185
+ ] })
186
+ ] })
187
+ ] }),
188
+ /* @__PURE__ */ o("section", { "aria-labelledby": "cc-set-stuck", children: [
189
+ /* @__PURE__ */ n("h3", { id: "cc-set-stuck", className: "mb-1 font-semibold text-[var(--cc-strong)]", children: "Stuck after" }),
190
+ /* @__PURE__ */ o("label", { className: "flex items-center gap-2", children: [
191
+ /* @__PURE__ */ n(
192
+ "input",
193
+ {
194
+ type: "number",
195
+ min: 1,
196
+ max: 365,
197
+ value: g,
198
+ onChange: (e) => $(e.target.value),
199
+ "aria-describedby": "cc-set-stuck-help",
200
+ className: a(
201
+ "w-20 rounded-md border border-[var(--cc-border)] bg-[var(--cc-panel)] px-2 py-1 text-[12px] text-[var(--cc-text)]",
202
+ l
203
+ )
204
+ }
205
+ ),
206
+ /* @__PURE__ */ n("span", { children: "days in one step" })
207
+ ] }),
208
+ /* @__PURE__ */ n(
209
+ "p",
210
+ {
211
+ id: "cc-set-stuck-help",
212
+ className: `mt-1 ${y ? i : "text-[var(--cc-bad-text)]"}`,
213
+ children: y ? "A record waiting this long in one step counts as stuck." : "Use a number from 1 to 365."
214
+ }
215
+ )
216
+ ] })
217
+ ] })
218
+ ]
219
+ }
220
+ );
221
+ }
222
+ export {
223
+ Y as BoardSettings
224
+ };
@@ -1,33 +1,149 @@
1
- import { jsx as t, jsxs as c, Fragment as r } from "react/jsx-runtime";
2
- import { useCc as o } from "../state.js";
3
- import { PANEL as a, FAINT as i, rel as m } from "../theme.js";
4
- function x() {
5
- const { snapshot: n, setPeek: l } = o(), s = (n == null ? void 0 : n.activity) ?? [];
6
- return /* @__PURE__ */ t("section", { className: `${a} shrink-0`, "data-cc-panel": "feed", children: /* @__PURE__ */ c("div", { className: "flex items-center gap-3 overflow-x-auto px-3 py-2", children: [
7
- /* @__PURE__ */ t("h2", { className: "shrink-0 text-[12.5px] font-semibold text-[var(--cc-strong)]", children: "Live" }),
8
- s.map((e) => /* @__PURE__ */ c(
9
- "button",
10
- {
11
- type: "button",
12
- onClick: () => e.collection && e.item ? l({ collection: e.collection, id: e.item }) : void 0,
13
- className: "flex shrink-0 items-center gap-1.5 rounded-full bg-[var(--cc-chip)] px-2.5 py-1 text-[11.5px] text-[var(--cc-text)] hover:bg-[var(--cc-chip-hover)]",
14
- children: [
15
- /* @__PURE__ */ t("span", { className: `tabular-nums ${i}`, children: m(e.timestamp) }),
16
- e.sentence ? /* @__PURE__ */ t("span", { children: e.sentence }) : /* @__PURE__ */ c(r, { children: [
17
- /* @__PURE__ */ t("span", { className: "font-medium", children: e.user_name || "System" }),
18
- /* @__PURE__ */ t("span", { className: "text-[var(--cc-muted)]", children: e.action.replace(/-/g, " ") }),
19
- e.collection && /* @__PURE__ */ c("span", { className: "text-[var(--cc-muted)]", children: [
20
- e.collection.replace(/_/g, " "),
21
- e.item ? ` #${e.item}` : ""
22
- ] })
1
+ import { jsxs as u, jsx as n, Fragment as P } from "react/jsx-runtime";
2
+ import { useQueryClient as S } from "@tanstack/react-query";
3
+ import { useState as d, useRef as m, useCallback as A, useEffect as D, useMemo as _ } from "react";
4
+ import { useCcQuery as I } from "../api.js";
5
+ import { useCc as R } from "../state.js";
6
+ import { PANEL as U, PANEL_HEAD as B, TITLE as M, FAINT as v, FOCUS as y, BUTTON as O, rel as Q, MUTED as q } from "../theme.js";
7
+ import { useCcPulse as j, clockLabel as $ } from "../time.js";
8
+ import { LiveOnlyBadge as H } from "./TimeBar.js";
9
+ const K = /* @__PURE__ */ new Set(["create", "update", "delete", "pipeline-transition", "transition"]), z = [
10
+ { key: "all", label: "Everything" },
11
+ { key: "records", label: "Records" },
12
+ { key: "transitions", label: "Pipeline moves" },
13
+ { key: "team", label: "My team" }
14
+ ];
15
+ function G(e, s) {
16
+ return !e.action || !K.has(e.action) || !e.collection || /^(nivaro|directus)_/.test(e.collection) ? !1 : s === "records" ? ["create", "update", "delete"].includes(e.action) : s === "transitions" ? /transition/.test(e.action) : !0;
17
+ }
18
+ function J(e, s) {
19
+ var c;
20
+ const r = new Set(e.map((a) => a.id)), i = ((c = e[0]) == null ? void 0 : c.id) ?? 0;
21
+ return s.filter((a) => !r.has(a.id) && a.id > i).length;
22
+ }
23
+ function ie() {
24
+ var k;
25
+ const e = R(), s = S(), [r, i] = d("all"), [c, a] = d(!1), [T, x] = d(!1), [L, b] = d(!1), o = e.at != null, p = c || T || L, E = W(
26
+ () => void s.invalidateQueries({ queryKey: ["command-center", "/activity"] }),
27
+ 1500
28
+ ), f = j(e.isAdmin && !o && !e.kiosk, (t) => {
29
+ G(t, r) && E();
30
+ }), w = I(
31
+ "/activity",
32
+ { filter: r, limit: 40 },
33
+ {
34
+ refetchInterval: o ? !1 : f ? 6e4 : 1e4,
35
+ placeholderData: (t) => t
36
+ }
37
+ ), h = w.data ?? ((k = e.snapshot) == null ? void 0 : k.activity) ?? [], l = m(null);
38
+ p && !l.current && (l.current = h), !p && l.current && (l.current = null);
39
+ const N = l.current ?? h, g = l.current ? J(l.current, h) : 0, F = A(
40
+ (t) => {
41
+ t.collection && t.item && e.setPeek({ collection: t.collection, id: t.item });
42
+ },
43
+ [e]
44
+ ), C = o ? `As of ${$(e.at)}` : p ? g > 0 ? `Paused · ${g} new` : "Paused" : f ? "Live" : "Updates every 10 s";
45
+ return /* @__PURE__ */ u(
46
+ "section",
47
+ {
48
+ className: `${U} flex min-h-0 shrink-0 flex-col`,
49
+ "data-cc-panel": "feed",
50
+ "aria-label": "Live feed",
51
+ children: [
52
+ /* @__PURE__ */ u("div", { className: `${B} flex-wrap`, children: [
53
+ /* @__PURE__ */ u("div", { className: "flex min-w-0 items-center gap-2", children: [
54
+ /* @__PURE__ */ n("h2", { className: M, children: "Live feed" }),
55
+ /* @__PURE__ */ n("span", { className: `text-[11.5px] ${v}`, "aria-live": "polite", children: C })
56
+ ] }),
57
+ /* @__PURE__ */ u("div", { className: "flex flex-wrap items-center gap-1.5", children: [
58
+ /* @__PURE__ */ n("fieldset", { className: "flex flex-wrap items-center gap-1", "aria-label": "Show", children: z.map((t) => /* @__PURE__ */ n(
59
+ "button",
60
+ {
61
+ type: "button",
62
+ "aria-pressed": r === t.key,
63
+ onClick: () => i(t.key),
64
+ className: `rounded-full px-2 py-0.5 text-[11.5px] ${y} ${r === t.key ? "bg-nvr-cyan/15 font-medium text-[var(--cc-strong)]" : "bg-[var(--cc-chip)] text-[var(--cc-text)] hover:bg-[var(--cc-chip-hover)]"}`,
65
+ children: t.label
66
+ },
67
+ t.key
68
+ )) }),
69
+ !o && /* @__PURE__ */ n(
70
+ "button",
71
+ {
72
+ type: "button",
73
+ className: `${O} ${y}`,
74
+ "aria-pressed": c,
75
+ onClick: () => a((t) => !t),
76
+ children: c ? "Resume" : "Pause"
77
+ }
78
+ )
23
79
  ] })
24
- ]
25
- },
26
- e.id
27
- )),
28
- s.length === 0 && /* @__PURE__ */ t("span", { className: `text-[12px] ${i}`, children: "Quiet — no recent activity you can see." })
29
- ] }) });
80
+ ] }),
81
+ /* @__PURE__ */ n(
82
+ "div",
83
+ {
84
+ className: "max-h-[240px] min-h-[64px] overflow-y-auto",
85
+ onMouseEnter: () => x(!0),
86
+ onMouseLeave: () => x(!1),
87
+ onFocus: () => b(!0),
88
+ onBlur: (t) => {
89
+ t.currentTarget.contains(t.relatedTarget) || b(!1);
90
+ },
91
+ children: N.length === 0 ? /* @__PURE__ */ n("p", { className: `px-3 py-3 text-[12px] ${v}`, children: w.isLoading ? "Loading…" : o ? "Nothing you can see was written before then." : "Quiet — no recent activity you can see." }) : /* @__PURE__ */ n("ul", { className: "divide-y divide-[var(--cc-border)]", children: N.map((t) => /* @__PURE__ */ n("li", { children: /* @__PURE__ */ n(V, { entry: t, onOpen: F }) }, t.id)) })
92
+ }
93
+ ),
94
+ e.isAdmin && !o && !f && /* @__PURE__ */ n("div", { className: "border-t border-[var(--cc-border)] px-3 py-1.5", children: /* @__PURE__ */ n(H, { label: "Refreshes every 10 s" }) })
95
+ ]
96
+ }
97
+ );
98
+ }
99
+ function V({ entry: e, onOpen: s }) {
100
+ const r = e.sentence || `${e.user_name || "System"} ${e.action.replace(/-/g, " ")}${e.collection ? ` ${e.collection_label ?? e.collection.replace(/_/g, " ")}` : ""}`, i = new Date(e.timestamp).getTime(), c = /* @__PURE__ */ u(P, { children: [
101
+ /* @__PURE__ */ n(
102
+ "span",
103
+ {
104
+ className: `w-9 shrink-0 text-right tabular-nums text-[11px] ${v}`,
105
+ "data-tip": Number.isFinite(i) ? $(i) : void 0,
106
+ children: Q(e.timestamp)
107
+ }
108
+ ),
109
+ /* @__PURE__ */ n("span", { className: "min-w-0 flex-1 truncate", children: r }),
110
+ e.collection_label && /* @__PURE__ */ n("span", { className: `hidden shrink-0 text-[11px] sm:inline ${q}`, children: e.collection_label })
111
+ ] }), a = "flex w-full items-center gap-2.5 px-3 py-1.5 text-left text-[12px] text-[var(--cc-text)]";
112
+ return !e.collection || !e.item ? /* @__PURE__ */ n("div", { className: a, "data-cc-feed-entry": e.id, children: c }) : /* @__PURE__ */ n(
113
+ "button",
114
+ {
115
+ type: "button",
116
+ onClick: () => s(e),
117
+ className: `${a} hover:bg-[var(--cc-chip)] ${y}`,
118
+ "aria-label": `${r} — open`,
119
+ "data-cc-feed-entry": e.id,
120
+ children: c
121
+ }
122
+ );
123
+ }
124
+ function W(e, s) {
125
+ const r = m(0), i = m(null), c = m(e);
126
+ return c.current = e, D(
127
+ () => () => {
128
+ i.current && clearTimeout(i.current);
129
+ },
130
+ []
131
+ ), _(
132
+ () => () => {
133
+ const a = r.current + s - Date.now();
134
+ if (a <= 0) {
135
+ r.current = Date.now(), c.current();
136
+ return;
137
+ }
138
+ i.current || (i.current = setTimeout(() => {
139
+ i.current = null, r.current = Date.now(), c.current();
140
+ }, a));
141
+ },
142
+ [s]
143
+ );
30
144
  }
31
145
  export {
32
- x as FeedPanel
146
+ ie as FeedPanel,
147
+ J as newSince,
148
+ G as pulseMatters
33
149
  };
@@ -1,61 +1,159 @@
1
- import { jsxs as l, jsx as a } from "react/jsx-runtime";
2
- import { useCc as m } from "../state.js";
3
- import { PANEL as d, PANEL_HEAD as p, TITLE as u, FAINT as s } from "../theme.js";
4
- function b() {
5
- const { snapshot: c, navigate: i } = m(), n = (c == null ? void 0 : c.flow) ?? [];
6
- return /* @__PURE__ */ l("section", { className: d, "data-cc-panel": "flow", children: [
7
- /* @__PURE__ */ a("div", { className: p, children: /* @__PURE__ */ a("h2", { className: u, children: "Pipeline flow" }) }),
8
- /* @__PURE__ */ l("div", { className: "space-y-3 p-3", children: [
9
- n.map((t) => {
10
- const o = t.states.reduce((e, r) => e + r.count, 0);
11
- return /* @__PURE__ */ l("div", { children: [
12
- /* @__PURE__ */ l("div", { className: "mb-1 flex items-baseline justify-between", children: [
13
- /* @__PURE__ */ a("span", { className: "text-[12px] font-medium text-[var(--cc-text)]", children: t.template_name }),
14
- /* @__PURE__ */ l("span", { className: `text-[11px] tabular-nums ${s}`, children: [
15
- o,
16
- " open"
17
- ] })
18
- ] }),
19
- /* @__PURE__ */ a("div", { className: "flex h-2.5 overflow-hidden rounded-full bg-[var(--cc-chip)]", children: t.states.map((e) => /* @__PURE__ */ a(
20
- "button",
21
- {
22
- type: "button",
23
- onClick: () => i(`/collections/${t.collection}`),
24
- className: "h-full transition-opacity hover:opacity-75",
25
- style: {
26
- width: `${Math.max(2, e.count / Math.max(1, o) * 100)}%`,
27
- background: e.color ?? "#00a5cc"
28
- },
29
- "aria-label": `${e.label}: ${e.count}`,
30
- "data-tip": `${e.label}: ${e.count}`
31
- },
32
- e.key
33
- )) }),
34
- /* @__PURE__ */ a("div", { className: "mt-1 flex flex-wrap gap-x-3 gap-y-0.5", children: t.states.map((e) => /* @__PURE__ */ l(
35
- "span",
36
- {
37
- className: "flex items-center gap-1 text-[11px] text-[var(--cc-muted)]",
38
- children: [
39
- /* @__PURE__ */ a(
40
- "span",
41
- {
42
- className: "h-1.5 w-1.5 rounded-full",
43
- style: { background: e.color ?? "#00a5cc" }
44
- }
45
- ),
46
- e.label,
47
- " ",
48
- /* @__PURE__ */ a("b", { className: "tabular-nums text-[var(--cc-text)]", children: e.count })
49
- ]
50
- },
51
- e.key
52
- )) })
53
- ] }, t.collection);
54
- }),
55
- n.length === 0 && /* @__PURE__ */ a("p", { className: `text-[12px] ${s}`, children: "No workflow-bound collections visible to you." })
1
+ import { jsxs as o, jsx as n, Fragment as w } from "react/jsx-runtime";
2
+ import { Bell as y, ArrowRight as $, ArrowUpRight as k, ArrowDownRight as N } from "lucide-react";
3
+ import { useState as f } from "react";
4
+ import { useCcQuery as A } from "../api.js";
5
+ import { useCc as b } from "../state.js";
6
+ import { PANEL as C, PANEL_HEAD as L, TITLE as O, FAINT as u, FOCUS as d, MUTED as v } from "../theme.js";
7
+ import { ageShort as g, ageWords as x, stateListUrl as M } from "../work-links.js";
8
+ const _ = "#00a5cc";
9
+ function j() {
10
+ var i;
11
+ const t = b(), a = A("/flow", void 0, { refetchInterval: 6e4 }), c = a.data ?? (((i = t.snapshot) == null ? void 0 : i.flow) ?? []).map((l) => ({
12
+ collection: l.collection,
13
+ collection_label: l.collection,
14
+ template_name: l.template_name,
15
+ states: l.states.map((r) => ({ ...r, oldest_age_s: null, median_age_s: null, stuck: 0 })),
16
+ open: l.states.reduce((r, m) => r + m.count, 0),
17
+ wip_7d_delta: null,
18
+ completed_7d: 0,
19
+ clears_in_days: null
20
+ })), s = c.some((l) => l.live_only), p = !!t.region && c.length > 0 && c.every((l) => l.region_applies === !1);
21
+ return /* @__PURE__ */ o("section", { className: C, "data-cc-panel": "flow", "aria-busy": a.isLoading, children: [
22
+ /* @__PURE__ */ o("div", { className: L, children: [
23
+ /* @__PURE__ */ n("h2", { className: O, children: "Pipeline flow" }),
24
+ s && /* @__PURE__ */ n("span", { className: `text-[11px] ${u}`, children: "Live — can't rewind this" }),
25
+ !s && p && /* @__PURE__ */ n("span", { className: `text-[11px] ${u}`, children: "Not placed in regions — showing everywhere" })
26
+ ] }),
27
+ /* @__PURE__ */ o("div", { className: "space-y-4 p-3", children: [
28
+ c.map((l) => /* @__PURE__ */ n(F, { f: l }, `${l.collection}:${l.template_name}`)),
29
+ c.length === 0 && !a.isLoading && /* @__PURE__ */ n("p", { className: `text-[12px] ${u}`, children: "No workflow-bound collections visible to you." })
56
30
  ] })
57
31
  ] });
58
32
  }
33
+ function F({ f: t }) {
34
+ var m;
35
+ const a = b(), [c, s] = f(!1), p = Math.max(
36
+ 1,
37
+ t.states.reduce((e, h) => e + h.count, 0)
38
+ ), i = (e, h) => a.navigate(M(t.collection, { state: e, minAgeHours: h })), l = t.states.filter((e) => e.count > 0), r = ((m = a.config) == null ? void 0 : m.stuck_days) ?? 7;
39
+ return /* @__PURE__ */ o("div", { children: [
40
+ /* @__PURE__ */ o("div", { className: "mb-1 flex items-baseline justify-between gap-2", children: [
41
+ /* @__PURE__ */ n(
42
+ "button",
43
+ {
44
+ type: "button",
45
+ onClick: () => i(null),
46
+ className: `truncate rounded text-left text-[12px] font-medium text-[var(--cc-text)] hover:underline ${d}`,
47
+ "data-tip": `Open ${t.collection_label}`,
48
+ children: t.template_name
49
+ }
50
+ ),
51
+ /* @__PURE__ */ o("span", { className: `shrink-0 text-[11px] tabular-nums ${u}`, children: [
52
+ t.open,
53
+ " open"
54
+ ] })
55
+ ] }),
56
+ /* @__PURE__ */ n("div", { className: "flex h-2.5 gap-[2px] overflow-hidden rounded-full bg-[var(--cc-chip)]", children: l.map((e) => /* @__PURE__ */ n(
57
+ "button",
58
+ {
59
+ type: "button",
60
+ onClick: () => i(e.key),
61
+ className: `h-full transition-opacity hover:opacity-75 ${d}`,
62
+ style: {
63
+ width: `${Math.max(2, e.count / p * 100)}%`,
64
+ background: e.color ?? _
65
+ },
66
+ "aria-label": `${e.label}: ${e.count} open. Open the list filtered to ${e.label}`,
67
+ "data-tip": `${e.label}: ${e.count} — open the list`
68
+ },
69
+ e.key
70
+ )) }),
71
+ /* @__PURE__ */ n("ul", { className: "mt-1.5 space-y-0.5", children: (c ? t.states : l).map((e) => /* @__PURE__ */ o("li", { className: "group flex items-center gap-1.5 text-[11.5px]", children: [
72
+ /* @__PURE__ */ o(
73
+ "button",
74
+ {
75
+ type: "button",
76
+ onClick: () => i(e.key),
77
+ className: `flex min-w-0 flex-1 items-center gap-1.5 rounded px-0.5 text-left hover:bg-[var(--cc-chip)] ${d}`,
78
+ "aria-label": `${e.label}: ${e.count} open, oldest ${x(e.oldest_age_s)}, ${e.stuck} stuck. Open the list`,
79
+ children: [
80
+ /* @__PURE__ */ n(
81
+ "span",
82
+ {
83
+ className: "h-1.5 w-1.5 shrink-0 rounded-full",
84
+ style: { background: e.color ?? _ },
85
+ "aria-hidden": !0
86
+ }
87
+ ),
88
+ /* @__PURE__ */ n("span", { className: "min-w-0 flex-1 truncate text-[var(--cc-muted)]", children: e.label }),
89
+ /* @__PURE__ */ n("b", { className: "tabular-nums text-[var(--cc-text)]", children: e.count }),
90
+ /* @__PURE__ */ n(
91
+ "span",
92
+ {
93
+ className: `w-[64px] shrink-0 text-right tabular-nums ${u}`,
94
+ "data-tip": e.count ? `Oldest ${x(e.oldest_age_s)} · median ${x(e.median_age_s)}` : void 0,
95
+ children: e.count ? `${g(e.oldest_age_s)} / ${g(e.median_age_s)}` : ""
96
+ }
97
+ )
98
+ ]
99
+ }
100
+ ),
101
+ e.stuck > 0 ? /* @__PURE__ */ o(
102
+ "button",
103
+ {
104
+ type: "button",
105
+ onClick: () => i(e.key, r * 24),
106
+ className: `shrink-0 rounded px-1 text-[11px] font-medium text-[var(--cc-warn-text)] hover:underline ${d}`,
107
+ "data-tip": `In ${e.label} longer than ${r} days — open them`,
108
+ children: [
109
+ e.stuck,
110
+ " stuck"
111
+ ]
112
+ }
113
+ ) : null,
114
+ a.isAdmin && !a.kiosk && e.alert_href ? /* @__PURE__ */ n(
115
+ "button",
116
+ {
117
+ type: "button",
118
+ onClick: () => a.navigate(e.alert_href),
119
+ className: `invisible shrink-0 rounded p-0.5 text-[var(--cc-faint)] hover:text-[var(--cc-text)] group-focus-within:visible group-hover:visible ${d}`,
120
+ "aria-label": `Alert me about ${e.label}`,
121
+ "data-tip": "Alert me",
122
+ children: /* @__PURE__ */ n(y, { className: "h-3 w-3", "aria-hidden": !0 })
123
+ }
124
+ ) : null
125
+ ] }, e.key)) }),
126
+ /* @__PURE__ */ o("div", { className: "mt-1.5 flex flex-wrap items-center gap-x-3 gap-y-0.5 text-[11px]", children: [
127
+ /* @__PURE__ */ n(R, { f: t }),
128
+ t.states.length > l.length && /* @__PURE__ */ n(
129
+ "button",
130
+ {
131
+ type: "button",
132
+ onClick: () => s((e) => !e),
133
+ className: `ml-auto rounded ${v} hover:underline ${d}`,
134
+ "aria-expanded": c,
135
+ children: c ? "Hide empty states" : `Show all ${t.states.length} states`
136
+ }
137
+ )
138
+ ] })
139
+ ] });
140
+ }
141
+ function R({ f: t }) {
142
+ const a = t.wip_7d_delta;
143
+ if (a == null && t.completed_7d === 0) return null;
144
+ const c = a != null && a > 0, s = a == null || a === 0 ? $ : c ? k : N, p = c ? "text-[var(--cc-warn-text)]" : "text-[var(--cc-muted)]";
145
+ return /* @__PURE__ */ o(w, { children: [
146
+ a != null && /* @__PURE__ */ o("span", { className: `flex items-center gap-0.5 ${p}`, children: [
147
+ /* @__PURE__ */ n(s, { className: "h-3 w-3", "aria-hidden": !0 }),
148
+ a === 0 ? "steady this week" : `${a > 0 ? "+" : "−"}${Math.abs(a)} open this week`
149
+ ] }),
150
+ /* @__PURE__ */ o("span", { className: u, children: [
151
+ t.completed_7d,
152
+ " done in 7 days"
153
+ ] }),
154
+ /* @__PURE__ */ n("span", { className: c ? "font-medium text-[var(--cc-warn-text)]" : v, children: c ? "growing" : t.clears_in_days == null ? "not clearing" : t.clears_in_days === 0 ? "clear" : `clears in ~${Math.max(1, Math.round(t.clears_in_days))} day${Math.round(t.clears_in_days) === 1 ? "" : "s"}` })
155
+ ] });
156
+ }
59
157
  export {
60
- b as FlowPanel
158
+ j as FlowPanel
61
159
  };