@nivaro/react 0.3.123 → 0.3.125
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.
- package/dist/full.css +1 -1
- package/dist/hooks/useSessionRecorder.js +1 -1
- package/dist/index.d.ts +10 -0
- package/dist/shared/components/CollectionBrowserView.js +93 -91
- package/dist/shared/components/DataTable.js +240 -228
- package/dist/shared/components/RecordReadView.js +1 -1
- package/dist/shared/components/TipLayer.js +86 -63
- package/dist/shared/components/integrations/IntegrationDots.js +1 -0
- package/dist/shared/components/item-edit/HeaderRollupExplainer.js +156 -119
- package/dist/shared/components/item-edit/InlineGridField.js +1 -1
- package/dist/shared/components/item-edit/RichTextEditorImpl.js +154 -179
- package/dist/shared/components/item-edit/UserChip.js +248 -232
- package/dist/shared/components/panels/PipelinePanel.js +252 -243
- package/dist/shared/components/panels/RevisionsPanel.js +1816 -661
- package/dist/shared/components/panels/revision-changes.js +242 -0
- package/dist/shared/components/panels/revision-table-parts.js +448 -0
- package/dist/shared/lib/activity-sentence.js +74 -68
- package/dist/shared/lib/editorjs.js +68 -0
- package/dist/shared/lib/revision-prefs.js +81 -0
- package/dist/shared/lib/xlsx-lite.js +125 -0
- package/package.json +1 -1
|
@@ -0,0 +1,242 @@
|
|
|
1
|
+
const $ = "$step", V = "Pipeline step";
|
|
2
|
+
const D = (e) => e.id != null && (e.action === "create" || e.action === "update" || e.action === "delete" || e.action === "restore"), f = (e) => e.timestamp ? new Date(e.timestamp).getTime() : 0, x = (e, o) => {
|
|
3
|
+
const a = (t) => t == null || t === "" ? "" : typeof t == "object" ? JSON.stringify(t) : String(t);
|
|
4
|
+
return a(e) === a(o);
|
|
5
|
+
};
|
|
6
|
+
function F(e) {
|
|
7
|
+
return [e.first_name, e.last_name].filter(Boolean).join(" ").trim() || e.user_email || (e.user_id ? "Someone" : "System");
|
|
8
|
+
}
|
|
9
|
+
function K(e, o = {}) {
|
|
10
|
+
var v, M;
|
|
11
|
+
const a = o.name ?? F, t = [...e].sort((n, i) => f(i) - f(n)), s = t.filter(D), c = t.filter((n) => /^o2m-/.test(String(n.action ?? "")) && n.o2m), l = t.filter((n) => n.event && !n.event.addendum && n.event.to_label).sort((n, i) => f(n) - f(i)), r = (n) => {
|
|
12
|
+
var d;
|
|
13
|
+
let i = null;
|
|
14
|
+
for (const h of l) {
|
|
15
|
+
if (f(h) > n) break;
|
|
16
|
+
i = ((d = h.event) == null ? void 0 : d.to_label) ?? i;
|
|
17
|
+
}
|
|
18
|
+
return i;
|
|
19
|
+
}, u = s.map((n, i) => {
|
|
20
|
+
const d = s[i + 1], h = n.data ?? {}, w = n.action === "create" ? "created" : n.action === "delete" ? "deleted" : n.action === "restore" ? "restored" : "changed", k = /* @__PURE__ */ new Set(), I = /* @__PURE__ */ new Set(), g = /* @__PURE__ */ new Map();
|
|
21
|
+
if (d && w !== "created") {
|
|
22
|
+
const T = d.data ?? {}, R = new Set(Object.keys(n.delta ?? {}));
|
|
23
|
+
for (const p of /* @__PURE__ */ new Set([...Object.keys(T), ...Object.keys(h)])) {
|
|
24
|
+
if (p === "id" || x(T[p], h[p]) || !(p in T) && !R.has(p)) continue;
|
|
25
|
+
if (R.has(p)) {
|
|
26
|
+
k.add(p);
|
|
27
|
+
continue;
|
|
28
|
+
}
|
|
29
|
+
I.add(p);
|
|
30
|
+
const G = f(d), P = f(n), N = c.filter((_) => {
|
|
31
|
+
var A;
|
|
32
|
+
const j = f(_);
|
|
33
|
+
return j > G && j <= P && (((A = _.o2m) == null ? void 0 : A.totals) ?? []).some((O) => O.field === p);
|
|
34
|
+
}).map((_) => {
|
|
35
|
+
var j, A, O, W;
|
|
36
|
+
return {
|
|
37
|
+
name: a(_),
|
|
38
|
+
userId: _.user_id ?? null,
|
|
39
|
+
row: ((j = _.o2m) == null ? void 0 : j.row_label) || ((A = _.o2m) == null ? void 0 : A.collection_label) || "a related row",
|
|
40
|
+
delta: ((W = (((O = _.o2m) == null ? void 0 : O.totals) ?? []).find((B) => B.field === p)) == null ? void 0 : W.delta) ?? 0
|
|
41
|
+
};
|
|
42
|
+
}).reverse();
|
|
43
|
+
N.length && g.set(p, N);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
return {
|
|
47
|
+
key: `${n.id}|${n.timestamp ?? ""}`,
|
|
48
|
+
timestamp: n.timestamp,
|
|
49
|
+
who: a(n),
|
|
50
|
+
userId: n.user_id ?? null,
|
|
51
|
+
action: w,
|
|
52
|
+
values: l.length ? { ...h, [$]: r(f(n)) } : h,
|
|
53
|
+
changed: k,
|
|
54
|
+
recalculated: I,
|
|
55
|
+
via: g
|
|
56
|
+
};
|
|
57
|
+
});
|
|
58
|
+
if (!o.withMoves || l.length === 0) return u;
|
|
59
|
+
const m = t.filter((n) => n.user_id && (D(n) || n.event || n.o2m)), b = l.map((n) => {
|
|
60
|
+
var k, I;
|
|
61
|
+
const i = f(n), d = u.find((g) => (g.timestamp ? new Date(g.timestamp).getTime() : 0) <= i), h = !n.user_id, w = h ? m.filter((g) => g !== n && f(g) <= i + 2e3 && i - f(g) <= 15e3).sort((g, T) => Math.abs(i - f(g)) - Math.abs(i - f(T)))[0] : void 0;
|
|
62
|
+
return {
|
|
63
|
+
key: `move|${n.timestamp ?? ""}|${((k = n.event) == null ? void 0 : k.to_label) ?? ""}`,
|
|
64
|
+
timestamp: n.timestamp,
|
|
65
|
+
who: h ? "Automatic" : a(n),
|
|
66
|
+
userId: n.user_id ?? null,
|
|
67
|
+
trigger: w ? { name: a(w), userId: w.user_id ?? null } : null,
|
|
68
|
+
linkedTo: w && D(w) ? `${w.id}|${w.timestamp ?? ""}` : null,
|
|
69
|
+
action: "moved",
|
|
70
|
+
values: { ...(d == null ? void 0 : d.values) ?? {}, [$]: ((I = n.event) == null ? void 0 : I.to_label) ?? null },
|
|
71
|
+
changed: /* @__PURE__ */ new Set([$]),
|
|
72
|
+
recalculated: /* @__PURE__ */ new Set(),
|
|
73
|
+
via: /* @__PURE__ */ new Map()
|
|
74
|
+
};
|
|
75
|
+
}), y = new Map(u.map((n) => [n.key, n])), S = [];
|
|
76
|
+
for (const [n, i] of b.entries()) {
|
|
77
|
+
const d = i.linkedTo ? y.get(i.linkedTo) : void 0;
|
|
78
|
+
if (!d) {
|
|
79
|
+
S.push(i);
|
|
80
|
+
continue;
|
|
81
|
+
}
|
|
82
|
+
d.values = { ...d.values, [$]: i.values[$] ?? null }, d.changed = /* @__PURE__ */ new Set([...d.changed, $]), d.autoMove = {
|
|
83
|
+
from: ((v = l[n].event) == null ? void 0 : v.from_label) ?? null,
|
|
84
|
+
to: ((M = l[n].event) == null ? void 0 : M.to_label) ?? null
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
return [...u, ...S].sort(
|
|
88
|
+
(n, i) => (i.timestamp ? new Date(i.timestamp).getTime() : 0) - (n.timestamp ? new Date(n.timestamp).getTime() : 0)
|
|
89
|
+
);
|
|
90
|
+
}
|
|
91
|
+
function Z(e, o) {
|
|
92
|
+
const a = /* @__PURE__ */ new Map();
|
|
93
|
+
for (const s of e) {
|
|
94
|
+
for (const c of Object.keys(s.values)) a.has(c) || a.set(c, 0);
|
|
95
|
+
for (const c of [...s.changed, ...s.recalculated]) a.set(c, (a.get(c) ?? 0) + 1);
|
|
96
|
+
}
|
|
97
|
+
const t = (s) => s === $ ? { label: V, system: !1, order: -1 } : o(s);
|
|
98
|
+
return [...a].filter(([s]) => s !== "id" && !t(s).system).map(([s, c]) => ({ field: s, label: t(s).label, changes: c })).sort((s, c) => {
|
|
99
|
+
const l = t(s.field).order ?? Number.POSITIVE_INFINITY, r = t(c.field).order ?? Number.POSITIVE_INFINITY;
|
|
100
|
+
return l - r || s.label.localeCompare(c.label);
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
function q(e, o) {
|
|
104
|
+
return e.filter(
|
|
105
|
+
(a) => a.action !== "changed" && a.action !== "moved" || o.some((t) => a.changed.has(t) || a.recalculated.has(t))
|
|
106
|
+
);
|
|
107
|
+
}
|
|
108
|
+
function L(e) {
|
|
109
|
+
const o = Math.abs(e).toLocaleString("en-US", { maximumFractionDigits: 2 });
|
|
110
|
+
return `${e > 0 ? "+" : e < 0 ? "−" : ""}${o}`;
|
|
111
|
+
}
|
|
112
|
+
function J(e) {
|
|
113
|
+
return e != null && e.length ? `Recalculated after ${e.map((o) => `${o.name} · ${o.row} ${L(o.delta)}`).join(", ")}` : "Recalculated";
|
|
114
|
+
}
|
|
115
|
+
const U = {
|
|
116
|
+
created: "Created",
|
|
117
|
+
changed: "Changed",
|
|
118
|
+
deleted: "Deleted",
|
|
119
|
+
restored: "Restored",
|
|
120
|
+
moved: "Moved"
|
|
121
|
+
}, Y = (e) => U[e];
|
|
122
|
+
function z(e) {
|
|
123
|
+
let o = e;
|
|
124
|
+
return /^[=+\-@\t\r]/.test(o) && !/^-?\d[\d,]*(\.\d+)?$/.test(o) && (o = `'${o}`), /[",\n\r]/.test(o) ? `"${o.replace(/"/g, '""')}"` : o;
|
|
125
|
+
}
|
|
126
|
+
function Q(e, o, a, t) {
|
|
127
|
+
const s = z, l = [["When", "Changed by", "Action", ...o.map((r) => r.label), "Recalculated"].map(s).join(",")];
|
|
128
|
+
for (const r of e) {
|
|
129
|
+
const u = [...r.recalculated].filter((m) => o.some((b) => b.field === m)).map((m) => {
|
|
130
|
+
var S;
|
|
131
|
+
const b = ((S = o.find((v) => v.field === m)) == null ? void 0 : S.label) ?? m;
|
|
132
|
+
if (!t) return `${b}: ${J(r.via.get(m))}`;
|
|
133
|
+
const y = t(m, r);
|
|
134
|
+
return `${b}: ${y.why}${y.because ? ` — ${y.because}` : ""}`;
|
|
135
|
+
}).join("; ");
|
|
136
|
+
l.push(
|
|
137
|
+
[
|
|
138
|
+
r.timestamp ? new Date(r.timestamp).toLocaleString("en-US") : "",
|
|
139
|
+
r.who,
|
|
140
|
+
Y(r.action),
|
|
141
|
+
...o.map((m) => a(m.field, r.values[m.field])),
|
|
142
|
+
u
|
|
143
|
+
].map((m) => s(String(m ?? ""))).join(",")
|
|
144
|
+
);
|
|
145
|
+
}
|
|
146
|
+
return `${l.join(`\r
|
|
147
|
+
`)}\r
|
|
148
|
+
`;
|
|
149
|
+
}
|
|
150
|
+
const C = (e) => {
|
|
151
|
+
if (e && typeof e == "object" && !Array.isArray(e)) return e;
|
|
152
|
+
if (typeof e != "string" || !e.trim()) return null;
|
|
153
|
+
try {
|
|
154
|
+
const o = JSON.parse(e);
|
|
155
|
+
return o && typeof o == "object" && !Array.isArray(o) ? o : null;
|
|
156
|
+
} catch {
|
|
157
|
+
return null;
|
|
158
|
+
}
|
|
159
|
+
};
|
|
160
|
+
function X(e, o) {
|
|
161
|
+
const a = String(e ?? "");
|
|
162
|
+
if (a === "rollup") {
|
|
163
|
+
const t = C(o), c = (Array.isArray(t == null ? void 0 : t.sources) ? t == null ? void 0 : t.sources : []).filter((l) => typeof l.related_collection == "string").map((l) => ({
|
|
164
|
+
collection: String(l.related_collection),
|
|
165
|
+
field: String(l.value_field ?? ""),
|
|
166
|
+
aggregate: String(l.aggregate ?? "sum"),
|
|
167
|
+
filtered: !!l.filter && Object.keys(l.filter).length > 0
|
|
168
|
+
}));
|
|
169
|
+
return c.length ? { kind: "rollup", sources: c } : null;
|
|
170
|
+
}
|
|
171
|
+
if (a === "lookup") {
|
|
172
|
+
const t = C(o);
|
|
173
|
+
return !(t != null && t.fk_field) || !(t != null && t.source_field) ? null : { kind: "lookup", fk: String(t.fk_field), source: String(t.source_field) };
|
|
174
|
+
}
|
|
175
|
+
return a === "write" || a === "read" ? { kind: "formula", inputs: [
|
|
176
|
+
...new Set(
|
|
177
|
+
[...String(o ?? "").matchAll(/\{\{\s*([A-Za-z_][\w]*)/g)].map((s) => s[1])
|
|
178
|
+
)
|
|
179
|
+
] } : null;
|
|
180
|
+
}
|
|
181
|
+
const H = {
|
|
182
|
+
sum: "Sum",
|
|
183
|
+
count: "Count",
|
|
184
|
+
avg: "Average",
|
|
185
|
+
min: "Lowest",
|
|
186
|
+
max: "Highest",
|
|
187
|
+
median: "Median",
|
|
188
|
+
distinct_count: "Distinct count",
|
|
189
|
+
weighted_avg: "Weighted average"
|
|
190
|
+
}, E = (e) => e.length <= 1 ? e[0] ?? "" : `${e.slice(0, -1).join(", ")} and ${e[e.length - 1]}`;
|
|
191
|
+
function ee(e, o, a, t, s = L) {
|
|
192
|
+
const c = o.via.get(e), l = c != null && c.length ? c.map((r) => `${r.name} changed ${r.row} (${s(r.delta)})`).join("; ") : void 0;
|
|
193
|
+
if ((a == null ? void 0 : a.kind) === "rollup")
|
|
194
|
+
return {
|
|
195
|
+
why: a.sources.map((u) => {
|
|
196
|
+
const m = H[u.aggregate] ?? "Total", b = u.aggregate === "count" ? t(u.collection) : `${t(u.collection)} · ${t(u.collection, u.field)}`;
|
|
197
|
+
return `${m} of ${b}${u.filtered ? " (filtered)" : ""}`;
|
|
198
|
+
}).join(" + "),
|
|
199
|
+
because: l ?? "Its rows changed between these two saves"
|
|
200
|
+
};
|
|
201
|
+
if ((a == null ? void 0 : a.kind) === "formula") {
|
|
202
|
+
const r = a.inputs.filter((u) => o.changed.has(u) || o.recalculated.has(u));
|
|
203
|
+
return {
|
|
204
|
+
why: a.inputs.length ? `Worked out from ${E(a.inputs.map((u) => t(null, u)))}` : "Worked out by a formula",
|
|
205
|
+
because: r.length ? `${E(r.map((u) => t(null, u)))} changed` : l ?? void 0
|
|
206
|
+
};
|
|
207
|
+
}
|
|
208
|
+
return (a == null ? void 0 : a.kind) === "lookup" ? {
|
|
209
|
+
why: `Copied from ${t(null, a.fk)} (${a.source.replace(/_/g, " ")})`,
|
|
210
|
+
because: o.changed.has(a.fk) ? `${t(null, a.fk)} changed` : void 0
|
|
211
|
+
} : {
|
|
212
|
+
why: "Set automatically (rule, job or integration)",
|
|
213
|
+
because: l
|
|
214
|
+
};
|
|
215
|
+
}
|
|
216
|
+
function te(e, o) {
|
|
217
|
+
if (!o) return null;
|
|
218
|
+
const a = new Date(o).getTime();
|
|
219
|
+
let t = null;
|
|
220
|
+
for (const s of e) {
|
|
221
|
+
if (new Date(s.t).getTime() > a) break;
|
|
222
|
+
t = s.v;
|
|
223
|
+
}
|
|
224
|
+
return t;
|
|
225
|
+
}
|
|
226
|
+
export {
|
|
227
|
+
$ as STEP_FIELD,
|
|
228
|
+
V as STEP_LABEL,
|
|
229
|
+
K as buildSaveRows,
|
|
230
|
+
z as csvCell,
|
|
231
|
+
X as deriveOf,
|
|
232
|
+
Z as matrixColumns,
|
|
233
|
+
Q as matrixCsv,
|
|
234
|
+
F as personName,
|
|
235
|
+
ee as recalcReason,
|
|
236
|
+
q as rowsChanging,
|
|
237
|
+
x as sameValue,
|
|
238
|
+
Y as saveActionLabel,
|
|
239
|
+
L as signedAmount,
|
|
240
|
+
te as valueAt,
|
|
241
|
+
J as viaText
|
|
242
|
+
};
|
|
@@ -0,0 +1,448 @@
|
|
|
1
|
+
import { jsxs as l, jsx as e } from "react/jsx-runtime";
|
|
2
|
+
import { Bookmark as H, ChevronsUpDown as R, Trash2 as j, Star as W, Check as T, Share2 as z, Users as V, X as F } from "lucide-react";
|
|
3
|
+
import { useState as k, useMemo as X } from "react";
|
|
4
|
+
import { cn as y } from "../../lib/utils.js";
|
|
5
|
+
import { Popover as O, PopoverTrigger as P, PopoverContent as L } from "../ui/popover.js";
|
|
6
|
+
const U = "inline-flex h-8 shrink-0 items-center gap-2 whitespace-nowrap rounded-md border px-2.5 text-[12px] transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-nvr-cyan", B = "border-slate-200 bg-white text-slate-700 hover:border-slate-300 dark:border-border dark:bg-card dark:text-slate-200", Y = "border-nvr-cyan/50 bg-nvr-cyan/[0.06] text-slate-800 dark:text-slate-100";
|
|
7
|
+
function Q({
|
|
8
|
+
people: o,
|
|
9
|
+
value: a,
|
|
10
|
+
onChange: d
|
|
11
|
+
}) {
|
|
12
|
+
const [n, i] = k(!1), m = a.size === 0 ? "Everyone" : a.size === 1 ? [...a][0] : `${a.size} people`;
|
|
13
|
+
return /* @__PURE__ */ l(O, { open: n, onOpenChange: i, children: [
|
|
14
|
+
/* @__PURE__ */ e(P, { asChild: !0, children: /* @__PURE__ */ l(
|
|
15
|
+
"button",
|
|
16
|
+
{
|
|
17
|
+
type: "button",
|
|
18
|
+
"data-revision-people-filter": !0,
|
|
19
|
+
className: y(U, a.size ? Y : B),
|
|
20
|
+
children: [
|
|
21
|
+
/* @__PURE__ */ e(V, { className: "h-3.5 w-3.5 text-slate-400" }),
|
|
22
|
+
/* @__PURE__ */ e("span", { className: "max-w-[160px] truncate", children: m }),
|
|
23
|
+
/* @__PURE__ */ e(R, { className: "h-3.5 w-3.5 text-slate-400" })
|
|
24
|
+
]
|
|
25
|
+
}
|
|
26
|
+
) }),
|
|
27
|
+
/* @__PURE__ */ l(L, { align: "start", className: "w-[260px] p-1", children: [
|
|
28
|
+
/* @__PURE__ */ e("div", { className: "max-h-[300px] overflow-y-auto", children: o.map((c) => {
|
|
29
|
+
const u = a.has(c.name);
|
|
30
|
+
return /* @__PURE__ */ l(
|
|
31
|
+
"button",
|
|
32
|
+
{
|
|
33
|
+
type: "button",
|
|
34
|
+
onClick: () => {
|
|
35
|
+
const x = new Set(a);
|
|
36
|
+
u ? x.delete(c.name) : x.add(c.name), d(x);
|
|
37
|
+
},
|
|
38
|
+
className: "flex w-full items-center gap-2 rounded-sm px-2 py-1.5 text-left text-[12px] hover:bg-slate-100 dark:hover:bg-muted",
|
|
39
|
+
children: [
|
|
40
|
+
/* @__PURE__ */ e(
|
|
41
|
+
"span",
|
|
42
|
+
{
|
|
43
|
+
className: y(
|
|
44
|
+
"flex h-3.5 w-3.5 shrink-0 items-center justify-center rounded-sm border",
|
|
45
|
+
u ? "border-nvr-cyan bg-nvr-cyan text-white" : "border-slate-300 dark:border-slate-600"
|
|
46
|
+
),
|
|
47
|
+
children: u && /* @__PURE__ */ e(T, { className: "h-3 w-3" })
|
|
48
|
+
}
|
|
49
|
+
),
|
|
50
|
+
/* @__PURE__ */ e("span", { className: "min-w-0 flex-1 truncate", children: c.name }),
|
|
51
|
+
/* @__PURE__ */ e("span", { className: "tabular-nums text-[11px] text-slate-400", children: c.count })
|
|
52
|
+
]
|
|
53
|
+
},
|
|
54
|
+
c.name
|
|
55
|
+
);
|
|
56
|
+
}) }),
|
|
57
|
+
a.size > 0 && /* @__PURE__ */ e(
|
|
58
|
+
"button",
|
|
59
|
+
{
|
|
60
|
+
type: "button",
|
|
61
|
+
onClick: () => d(/* @__PURE__ */ new Set()),
|
|
62
|
+
className: "mt-1 w-full rounded-sm border-t border-slate-100 px-2 py-1.5 text-left text-[11.5px] text-slate-500 hover:bg-slate-50 dark:border-border/60 dark:hover:bg-muted",
|
|
63
|
+
children: "Show everyone"
|
|
64
|
+
}
|
|
65
|
+
)
|
|
66
|
+
] })
|
|
67
|
+
] });
|
|
68
|
+
}
|
|
69
|
+
function Z({
|
|
70
|
+
from: o,
|
|
71
|
+
to: a,
|
|
72
|
+
onChange: d
|
|
73
|
+
}) {
|
|
74
|
+
const n = "h-8 rounded-md border border-slate-200 bg-white px-2 text-[12px] text-slate-700 dark:border-border dark:bg-card dark:text-slate-200";
|
|
75
|
+
return /* @__PURE__ */ l("span", { className: "inline-flex shrink-0 items-center gap-1.5 whitespace-nowrap text-[12px] text-slate-500 dark:text-slate-400", children: [
|
|
76
|
+
/* @__PURE__ */ e(
|
|
77
|
+
"input",
|
|
78
|
+
{
|
|
79
|
+
type: "date",
|
|
80
|
+
value: o,
|
|
81
|
+
max: a || void 0,
|
|
82
|
+
onChange: (i) => d(i.target.value, a),
|
|
83
|
+
"aria-label": "Saves from",
|
|
84
|
+
className: n
|
|
85
|
+
}
|
|
86
|
+
),
|
|
87
|
+
/* @__PURE__ */ e("span", { children: "to" }),
|
|
88
|
+
/* @__PURE__ */ e(
|
|
89
|
+
"input",
|
|
90
|
+
{
|
|
91
|
+
type: "date",
|
|
92
|
+
value: a,
|
|
93
|
+
min: o || void 0,
|
|
94
|
+
onChange: (i) => d(o, i.target.value),
|
|
95
|
+
"aria-label": "Saves to",
|
|
96
|
+
className: n
|
|
97
|
+
}
|
|
98
|
+
),
|
|
99
|
+
(o || a) && /* @__PURE__ */ e(
|
|
100
|
+
"button",
|
|
101
|
+
{
|
|
102
|
+
type: "button",
|
|
103
|
+
onClick: () => d("", ""),
|
|
104
|
+
"aria-label": "Clear the dates",
|
|
105
|
+
className: "rounded p-1 text-slate-400 hover:bg-slate-100 hover:text-slate-700 dark:hover:bg-muted dark:hover:text-slate-200",
|
|
106
|
+
children: /* @__PURE__ */ e(F, { className: "h-3.5 w-3.5" })
|
|
107
|
+
}
|
|
108
|
+
)
|
|
109
|
+
] });
|
|
110
|
+
}
|
|
111
|
+
function A(o, a, d) {
|
|
112
|
+
if (!a && !d) return !0;
|
|
113
|
+
if (!o) return !1;
|
|
114
|
+
const n = new Date(o).getTime();
|
|
115
|
+
return !(a && n < (/* @__PURE__ */ new Date(`${a}T00:00:00`)).getTime() || d && n > (/* @__PURE__ */ new Date(`${d}T23:59:59.999`)).getTime());
|
|
116
|
+
}
|
|
117
|
+
function ee({
|
|
118
|
+
label: o,
|
|
119
|
+
points: a,
|
|
120
|
+
onClose: d
|
|
121
|
+
}) {
|
|
122
|
+
var D, _, N, f;
|
|
123
|
+
const n = a.map(
|
|
124
|
+
(r) => r.v === null || r.v === void 0 || r.v === "" ? null : Number(r.v)
|
|
125
|
+
), i = a.length > 1 && n.every((r) => r === null || Number.isFinite(r)), m = X(() => {
|
|
126
|
+
const r = [];
|
|
127
|
+
for (const h of a) (!r.length || r[r.length - 1].text !== h.text) && r.push(h);
|
|
128
|
+
return r;
|
|
129
|
+
}, [a]), c = 640, u = 72, x = 6;
|
|
130
|
+
let $ = null;
|
|
131
|
+
if (i) {
|
|
132
|
+
const r = n.map((s) => s ?? 0), h = Math.min(...r), C = Math.max(...r) - h || 1, v = (s) => x + s / Math.max(1, a.length - 1) * (c - x * 2), g = (s) => u - x - (s - h) / C * (u - x * 2);
|
|
133
|
+
let w = `M ${v(0)} ${g(r[0])}`;
|
|
134
|
+
for (let s = 1; s < r.length; s++) w += ` H ${v(s)} V ${g(r[s])}`;
|
|
135
|
+
$ = /* @__PURE__ */ l("div", { className: "relative h-[72px] w-full", children: [
|
|
136
|
+
/* @__PURE__ */ e(
|
|
137
|
+
"svg",
|
|
138
|
+
{
|
|
139
|
+
viewBox: `0 0 ${c} ${u}`,
|
|
140
|
+
preserveAspectRatio: "none",
|
|
141
|
+
className: "absolute inset-0 h-full w-full",
|
|
142
|
+
role: "img",
|
|
143
|
+
"aria-label": `${o} over ${a.length} saves, from ${((D = a[0]) == null ? void 0 : D.text) || "empty"} to ${((_ = a[a.length - 1]) == null ? void 0 : _.text) || "empty"}`,
|
|
144
|
+
children: /* @__PURE__ */ e(
|
|
145
|
+
"path",
|
|
146
|
+
{
|
|
147
|
+
d: w,
|
|
148
|
+
fill: "none",
|
|
149
|
+
className: "stroke-nvr-cyan",
|
|
150
|
+
strokeWidth: 2,
|
|
151
|
+
vectorEffect: "non-scaling-stroke"
|
|
152
|
+
}
|
|
153
|
+
)
|
|
154
|
+
}
|
|
155
|
+
),
|
|
156
|
+
r.map(
|
|
157
|
+
(s, p) => p === 0 || s !== r[p - 1] ? /* @__PURE__ */ e(
|
|
158
|
+
"span",
|
|
159
|
+
{
|
|
160
|
+
"data-tip": `${a[p].t ? new Date(a[p].t).toLocaleString() : ""} — ${a[p].text}`,
|
|
161
|
+
className: "absolute h-2.5 w-2.5 -translate-x-1/2 -translate-y-1/2 rounded-full border-2 border-nvr-cyan bg-white dark:bg-card",
|
|
162
|
+
style: { left: `${v(p) / c * 100}%`, top: `${g(s) / u * 100}%` }
|
|
163
|
+
},
|
|
164
|
+
p
|
|
165
|
+
) : null
|
|
166
|
+
)
|
|
167
|
+
] });
|
|
168
|
+
}
|
|
169
|
+
return /* @__PURE__ */ l(
|
|
170
|
+
"div",
|
|
171
|
+
{
|
|
172
|
+
className: "mb-3 rounded-lg border border-slate-200 bg-white p-3 dark:border-border dark:bg-card",
|
|
173
|
+
"data-field-trend": !0,
|
|
174
|
+
children: [
|
|
175
|
+
/* @__PURE__ */ l("div", { className: "mb-1 flex items-center gap-2", children: [
|
|
176
|
+
/* @__PURE__ */ l("p", { className: "text-[12.5px] font-medium text-slate-800 dark:text-slate-100", children: [
|
|
177
|
+
o,
|
|
178
|
+
" over time"
|
|
179
|
+
] }),
|
|
180
|
+
/* @__PURE__ */ l("span", { className: "text-[11.5px] text-slate-500 dark:text-slate-400", children: [
|
|
181
|
+
m.length - 1,
|
|
182
|
+
" change",
|
|
183
|
+
m.length - 1 === 1 ? "" : "s",
|
|
184
|
+
" · ",
|
|
185
|
+
((N = m[0]) == null ? void 0 : N.text) || "—",
|
|
186
|
+
" →",
|
|
187
|
+
" ",
|
|
188
|
+
((f = m[m.length - 1]) == null ? void 0 : f.text) || "—"
|
|
189
|
+
] }),
|
|
190
|
+
/* @__PURE__ */ e(
|
|
191
|
+
"button",
|
|
192
|
+
{
|
|
193
|
+
type: "button",
|
|
194
|
+
onClick: d,
|
|
195
|
+
"aria-label": "Close",
|
|
196
|
+
className: "ml-auto rounded p-1 text-slate-400 hover:bg-slate-100 hover:text-slate-700 dark:hover:bg-muted dark:hover:text-slate-200",
|
|
197
|
+
children: /* @__PURE__ */ e(F, { className: "h-3.5 w-3.5" })
|
|
198
|
+
}
|
|
199
|
+
)
|
|
200
|
+
] }),
|
|
201
|
+
i ? $ : /* @__PURE__ */ e("ol", { className: "flex flex-wrap items-center gap-1.5 text-[11.5px]", children: m.map((r, h) => /* @__PURE__ */ l(
|
|
202
|
+
"li",
|
|
203
|
+
{
|
|
204
|
+
className: "flex items-center gap-1.5",
|
|
205
|
+
children: [
|
|
206
|
+
h > 0 && /* @__PURE__ */ e("span", { className: "text-slate-300 dark:text-slate-600", children: "→" }),
|
|
207
|
+
/* @__PURE__ */ e("span", { className: "rounded bg-slate-100 px-1.5 py-0.5 text-slate-700 dark:bg-muted dark:text-slate-200", children: r.text || "—" }),
|
|
208
|
+
/* @__PURE__ */ e("span", { className: "tabular-nums text-[10.5px] text-slate-400", children: r.t ? new Date(r.t).toLocaleDateString() : "" })
|
|
209
|
+
]
|
|
210
|
+
},
|
|
211
|
+
h
|
|
212
|
+
)) })
|
|
213
|
+
]
|
|
214
|
+
}
|
|
215
|
+
);
|
|
216
|
+
}
|
|
217
|
+
function te({
|
|
218
|
+
personal: o,
|
|
219
|
+
shared: a,
|
|
220
|
+
roleDefaultName: d,
|
|
221
|
+
isAdmin: n,
|
|
222
|
+
roles: i,
|
|
223
|
+
onApply: m,
|
|
224
|
+
onSavePersonal: c,
|
|
225
|
+
onDeletePersonal: u,
|
|
226
|
+
onShare: x,
|
|
227
|
+
onDeleteShared: $,
|
|
228
|
+
onSetDefault: D
|
|
229
|
+
}) {
|
|
230
|
+
const [_, N] = k(!1), [f, r] = k(""), [h, M] = k(!1), [C, v] = k(/* @__PURE__ */ new Set()), [g, w] = k(!1), s = "group/set flex w-full items-center gap-2 rounded-sm px-2 py-1.5 text-left text-[12px] hover:bg-slate-100 dark:hover:bg-muted", p = "px-2 pb-1 pt-2 text-[11px] font-medium text-slate-500 dark:text-slate-400", E = (t) => {
|
|
231
|
+
var b;
|
|
232
|
+
return ((b = i.find((S) => S.id.toUpperCase() === t)) == null ? void 0 : b.name) ?? "a role";
|
|
233
|
+
};
|
|
234
|
+
return /* @__PURE__ */ l(
|
|
235
|
+
O,
|
|
236
|
+
{
|
|
237
|
+
open: _,
|
|
238
|
+
onOpenChange: (t) => {
|
|
239
|
+
N(t), t || (r(""), M(!1), v(/* @__PURE__ */ new Set()), w(!1));
|
|
240
|
+
},
|
|
241
|
+
children: [
|
|
242
|
+
/* @__PURE__ */ e(P, { asChild: !0, children: /* @__PURE__ */ l("button", { type: "button", "data-revision-column-sets": !0, className: y(U, B), children: [
|
|
243
|
+
/* @__PURE__ */ e(H, { className: "h-3.5 w-3.5 text-slate-400" }),
|
|
244
|
+
"Column sets",
|
|
245
|
+
/* @__PURE__ */ e(R, { className: "h-3.5 w-3.5 text-slate-400" })
|
|
246
|
+
] }) }),
|
|
247
|
+
/* @__PURE__ */ l(L, { align: "start", className: "w-[320px] p-1", children: [
|
|
248
|
+
/* @__PURE__ */ l("div", { className: "max-h-[360px] overflow-y-auto", children: [
|
|
249
|
+
/* @__PURE__ */ e("p", { className: p, children: "Yours" }),
|
|
250
|
+
o.length === 0 && /* @__PURE__ */ e("p", { className: "px-2 pb-1 text-[11.5px] text-slate-400", children: "Save the columns you have now to come back to them." }),
|
|
251
|
+
o.map((t) => /* @__PURE__ */ l("div", { className: s, children: [
|
|
252
|
+
/* @__PURE__ */ l(
|
|
253
|
+
"button",
|
|
254
|
+
{
|
|
255
|
+
type: "button",
|
|
256
|
+
className: "min-w-0 flex-1 truncate text-left",
|
|
257
|
+
onClick: () => {
|
|
258
|
+
m(t.fields), N(!1);
|
|
259
|
+
},
|
|
260
|
+
children: [
|
|
261
|
+
t.name,
|
|
262
|
+
/* @__PURE__ */ e("span", { className: "ml-1.5 text-[11px] text-slate-400", children: t.fields.length })
|
|
263
|
+
]
|
|
264
|
+
}
|
|
265
|
+
),
|
|
266
|
+
/* @__PURE__ */ e(
|
|
267
|
+
"button",
|
|
268
|
+
{
|
|
269
|
+
type: "button",
|
|
270
|
+
"aria-label": `Delete ${t.name}`,
|
|
271
|
+
onClick: () => u(t.name),
|
|
272
|
+
className: "rounded p-0.5 text-slate-400 opacity-0 hover:text-red-600 group-hover/set:opacity-100 focus:opacity-100",
|
|
273
|
+
children: /* @__PURE__ */ e(j, { className: "h-3.5 w-3.5" })
|
|
274
|
+
}
|
|
275
|
+
)
|
|
276
|
+
] }, t.name)),
|
|
277
|
+
/* @__PURE__ */ l("p", { className: p, children: [
|
|
278
|
+
"Shared",
|
|
279
|
+
d ? ` · you start with ${d}` : ""
|
|
280
|
+
] }),
|
|
281
|
+
a.length === 0 && /* @__PURE__ */ e("p", { className: "px-2 pb-1 text-[11.5px] text-slate-400", children: n ? "Share a set so everyone can pick it." : "None shared yet." }),
|
|
282
|
+
a.map((t) => {
|
|
283
|
+
var b;
|
|
284
|
+
return /* @__PURE__ */ l("div", { className: s, children: [
|
|
285
|
+
/* @__PURE__ */ l(
|
|
286
|
+
"button",
|
|
287
|
+
{
|
|
288
|
+
type: "button",
|
|
289
|
+
className: "min-w-0 flex-1 truncate text-left",
|
|
290
|
+
onClick: () => {
|
|
291
|
+
m(t.fields), N(!1);
|
|
292
|
+
},
|
|
293
|
+
children: [
|
|
294
|
+
t.name,
|
|
295
|
+
/* @__PURE__ */ e("span", { className: "ml-1.5 text-[11px] text-slate-400", children: t.fields.length }),
|
|
296
|
+
t.is_default && /* @__PURE__ */ e("span", { className: "ml-1.5 rounded bg-nvr-cyan/10 px-1 py-px text-[10.5px] font-medium text-nvr-navy dark:text-nvr-cyan", children: "Default" }),
|
|
297
|
+
n && ((b = t.default_roles) != null && b.length) ? /* @__PURE__ */ l("span", { className: "ml-1.5 text-[10.5px] text-slate-500", children: [
|
|
298
|
+
"default for ",
|
|
299
|
+
t.default_roles.map(E).join(", ")
|
|
300
|
+
] }) : null
|
|
301
|
+
]
|
|
302
|
+
}
|
|
303
|
+
),
|
|
304
|
+
n && t.id && /* @__PURE__ */ e(
|
|
305
|
+
"button",
|
|
306
|
+
{
|
|
307
|
+
type: "button",
|
|
308
|
+
"aria-pressed": !!t.is_default,
|
|
309
|
+
"aria-label": t.is_default ? `${t.name} is the default for everyone — stop` : `Make ${t.name} the default for everyone`,
|
|
310
|
+
"data-tip": t.is_default ? "Default for everyone (a role’s own default and a person’s own columns win) — click to stop" : "Make this the default for everyone",
|
|
311
|
+
onClick: () => D(t.is_default ? null : t.id),
|
|
312
|
+
className: y(
|
|
313
|
+
"rounded p-0.5 hover:text-amber-600",
|
|
314
|
+
t.is_default ? "text-amber-500" : "text-slate-400 opacity-0 group-hover/set:opacity-100 focus:opacity-100"
|
|
315
|
+
),
|
|
316
|
+
children: /* @__PURE__ */ e(W, { className: y("h-3.5 w-3.5", t.is_default && "fill-current") })
|
|
317
|
+
}
|
|
318
|
+
),
|
|
319
|
+
n && t.id && /* @__PURE__ */ e(
|
|
320
|
+
"button",
|
|
321
|
+
{
|
|
322
|
+
type: "button",
|
|
323
|
+
"aria-label": `Delete ${t.name}`,
|
|
324
|
+
onClick: () => $(t.id),
|
|
325
|
+
className: "rounded p-0.5 text-slate-400 opacity-0 hover:text-red-600 group-hover/set:opacity-100 focus:opacity-100",
|
|
326
|
+
children: /* @__PURE__ */ e(j, { className: "h-3.5 w-3.5" })
|
|
327
|
+
}
|
|
328
|
+
)
|
|
329
|
+
] }, t.id ?? t.name);
|
|
330
|
+
})
|
|
331
|
+
] }),
|
|
332
|
+
/* @__PURE__ */ l("div", { className: "mt-1 border-t border-slate-100 p-2 dark:border-border/60", children: [
|
|
333
|
+
/* @__PURE__ */ e(
|
|
334
|
+
"input",
|
|
335
|
+
{
|
|
336
|
+
value: f,
|
|
337
|
+
onChange: (t) => r(t.target.value),
|
|
338
|
+
placeholder: "Name the columns you have now…",
|
|
339
|
+
maxLength: 60,
|
|
340
|
+
className: "h-8 w-full rounded-md border border-slate-200 bg-white px-2 text-[12px] dark:border-border dark:bg-card",
|
|
341
|
+
"aria-label": "Column set name"
|
|
342
|
+
}
|
|
343
|
+
),
|
|
344
|
+
h && /* @__PURE__ */ l("div", { className: "mt-2", children: [
|
|
345
|
+
/* @__PURE__ */ l(
|
|
346
|
+
"button",
|
|
347
|
+
{
|
|
348
|
+
type: "button",
|
|
349
|
+
onClick: () => w((t) => !t),
|
|
350
|
+
className: "mb-1.5 flex w-full items-center gap-2 rounded-sm px-1 py-1 text-left text-[12px] hover:bg-slate-100 dark:hover:bg-muted",
|
|
351
|
+
children: [
|
|
352
|
+
/* @__PURE__ */ e(
|
|
353
|
+
"span",
|
|
354
|
+
{
|
|
355
|
+
className: y(
|
|
356
|
+
"flex h-3.5 w-3.5 shrink-0 items-center justify-center rounded-sm border",
|
|
357
|
+
g ? "border-nvr-cyan bg-nvr-cyan text-white" : "border-slate-300 dark:border-slate-600"
|
|
358
|
+
),
|
|
359
|
+
children: g && /* @__PURE__ */ e(T, { className: "h-3 w-3" })
|
|
360
|
+
}
|
|
361
|
+
),
|
|
362
|
+
"Default for everyone"
|
|
363
|
+
]
|
|
364
|
+
}
|
|
365
|
+
),
|
|
366
|
+
/* @__PURE__ */ e("p", { className: "mb-1 text-[11px] text-slate-500 dark:text-slate-400", children: "Default for these roles (optional)" }),
|
|
367
|
+
/* @__PURE__ */ e("div", { className: "max-h-[120px] overflow-y-auto", children: i.map((t) => {
|
|
368
|
+
const b = C.has(t.id);
|
|
369
|
+
return /* @__PURE__ */ l(
|
|
370
|
+
"button",
|
|
371
|
+
{
|
|
372
|
+
type: "button",
|
|
373
|
+
onClick: () => {
|
|
374
|
+
const S = new Set(C);
|
|
375
|
+
b ? S.delete(t.id) : S.add(t.id), v(S);
|
|
376
|
+
},
|
|
377
|
+
className: "flex w-full items-center gap-2 rounded-sm px-1 py-1 text-left text-[12px] hover:bg-slate-100 dark:hover:bg-muted",
|
|
378
|
+
children: [
|
|
379
|
+
/* @__PURE__ */ e(
|
|
380
|
+
"span",
|
|
381
|
+
{
|
|
382
|
+
className: y(
|
|
383
|
+
"flex h-3.5 w-3.5 shrink-0 items-center justify-center rounded-sm border",
|
|
384
|
+
b ? "border-nvr-cyan bg-nvr-cyan text-white" : "border-slate-300 dark:border-slate-600"
|
|
385
|
+
),
|
|
386
|
+
children: b && /* @__PURE__ */ e(T, { className: "h-3 w-3" })
|
|
387
|
+
}
|
|
388
|
+
),
|
|
389
|
+
t.name
|
|
390
|
+
]
|
|
391
|
+
},
|
|
392
|
+
t.id
|
|
393
|
+
);
|
|
394
|
+
}) })
|
|
395
|
+
] }),
|
|
396
|
+
/* @__PURE__ */ l("div", { className: "mt-2 flex items-center gap-1.5", children: [
|
|
397
|
+
/* @__PURE__ */ e(
|
|
398
|
+
"button",
|
|
399
|
+
{
|
|
400
|
+
type: "button",
|
|
401
|
+
disabled: !f.trim(),
|
|
402
|
+
onClick: () => {
|
|
403
|
+
c(f.trim()), r("");
|
|
404
|
+
},
|
|
405
|
+
className: "rounded-md bg-nvr-cyan px-2.5 py-1 text-[12px] font-medium text-white disabled:opacity-40",
|
|
406
|
+
children: "Save for me"
|
|
407
|
+
}
|
|
408
|
+
),
|
|
409
|
+
n && (h ? /* @__PURE__ */ l(
|
|
410
|
+
"button",
|
|
411
|
+
{
|
|
412
|
+
type: "button",
|
|
413
|
+
disabled: !f.trim(),
|
|
414
|
+
onClick: () => {
|
|
415
|
+
x(f.trim(), [...C], g), r(""), M(!1), v(/* @__PURE__ */ new Set()), w(!1);
|
|
416
|
+
},
|
|
417
|
+
className: "inline-flex items-center gap-1 rounded-md border border-slate-200 px-2.5 py-1 text-[12px] text-slate-700 disabled:opacity-40 dark:border-border dark:text-slate-200",
|
|
418
|
+
children: [
|
|
419
|
+
/* @__PURE__ */ e(z, { className: "h-3.5 w-3.5" }),
|
|
420
|
+
"Share with everyone"
|
|
421
|
+
]
|
|
422
|
+
}
|
|
423
|
+
) : /* @__PURE__ */ l(
|
|
424
|
+
"button",
|
|
425
|
+
{
|
|
426
|
+
type: "button",
|
|
427
|
+
onClick: () => M(!0),
|
|
428
|
+
className: "inline-flex items-center gap-1 rounded-md px-2 py-1 text-[12px] text-slate-600 hover:bg-slate-100 dark:text-slate-300 dark:hover:bg-muted",
|
|
429
|
+
children: [
|
|
430
|
+
/* @__PURE__ */ e(z, { className: "h-3.5 w-3.5" }),
|
|
431
|
+
"Share…"
|
|
432
|
+
]
|
|
433
|
+
}
|
|
434
|
+
))
|
|
435
|
+
] })
|
|
436
|
+
] })
|
|
437
|
+
] })
|
|
438
|
+
]
|
|
439
|
+
}
|
|
440
|
+
);
|
|
441
|
+
}
|
|
442
|
+
export {
|
|
443
|
+
te as ColumnSetsMenu,
|
|
444
|
+
Z as DateRangeFilter,
|
|
445
|
+
ee as FieldTrend,
|
|
446
|
+
Q as PeopleFilter,
|
|
447
|
+
A as inDateRange
|
|
448
|
+
};
|