@nivaro/react 0.3.123 → 0.3.124

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,229 @@
1
+ const A = "$step", L = "Pipeline step";
2
+ const R = (e) => e.id != null && (e.action === "create" || e.action === "update" || e.action === "delete" || e.action === "restore"), m = (e) => e.timestamp ? new Date(e.timestamp).getTime() : 0, G = (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 P(e) {
7
+ return [e.first_name, e.last_name].filter(Boolean).join(" ").trim() || e.user_email || (e.user_id ? "Someone" : "System");
8
+ }
9
+ function U(e, o = {}) {
10
+ const a = o.name ?? P, t = [...e].sort((n, c) => m(c) - m(n)), s = t.filter(R), i = t.filter((n) => /^o2m-/.test(String(n.action ?? "")) && n.o2m), r = t.filter((n) => n.event && !n.event.addendum && n.event.to_label).sort((n, c) => m(n) - m(c)), l = (n) => {
11
+ var f;
12
+ let c = null;
13
+ for (const h of r) {
14
+ if (m(h) > n) break;
15
+ c = ((f = h.event) == null ? void 0 : f.to_label) ?? c;
16
+ }
17
+ return c;
18
+ }, u = s.map((n, c) => {
19
+ const f = s[c + 1], h = n.data ?? {}, _ = n.action === "create" ? "created" : n.action === "delete" ? "deleted" : n.action === "restore" ? "restored" : "changed", $ = /* @__PURE__ */ new Set(), S = /* @__PURE__ */ new Set(), g = /* @__PURE__ */ new Map();
20
+ if (f && _ !== "created") {
21
+ const y = f.data ?? {}, T = new Set(Object.keys(n.delta ?? {}));
22
+ for (const p of /* @__PURE__ */ new Set([...Object.keys(y), ...Object.keys(h)])) {
23
+ if (p === "id" || G(y[p], h[p]) || !(p in y) && !T.has(p)) continue;
24
+ if (T.has(p)) {
25
+ $.add(p);
26
+ continue;
27
+ }
28
+ S.add(p);
29
+ const M = m(f), v = m(n), O = i.filter((b) => {
30
+ var I;
31
+ const k = m(b);
32
+ return k > M && k <= v && (((I = b.o2m) == null ? void 0 : I.totals) ?? []).some((j) => j.field === p);
33
+ }).map((b) => {
34
+ var k, I, j, D;
35
+ return {
36
+ name: a(b),
37
+ userId: b.user_id ?? null,
38
+ row: ((k = b.o2m) == null ? void 0 : k.row_label) || ((I = b.o2m) == null ? void 0 : I.collection_label) || "a related row",
39
+ delta: ((D = (((j = b.o2m) == null ? void 0 : j.totals) ?? []).find((E) => E.field === p)) == null ? void 0 : D.delta) ?? 0
40
+ };
41
+ }).reverse();
42
+ O.length && g.set(p, O);
43
+ }
44
+ }
45
+ return {
46
+ key: `${n.id}|${n.timestamp ?? ""}`,
47
+ timestamp: n.timestamp,
48
+ who: a(n),
49
+ userId: n.user_id ?? null,
50
+ action: _,
51
+ values: r.length ? { ...h, [A]: l(m(n)) } : h,
52
+ changed: $,
53
+ recalculated: S,
54
+ via: g
55
+ };
56
+ });
57
+ if (!o.withMoves || r.length === 0) return u;
58
+ const d = t.filter((n) => n.user_id && (R(n) || n.event || n.o2m)), w = r.map((n) => {
59
+ var $, S;
60
+ const c = m(n), f = u.find((g) => (g.timestamp ? new Date(g.timestamp).getTime() : 0) <= c), h = !n.user_id, _ = h ? d.filter((g) => g !== n && m(g) <= c + 2e3 && c - m(g) <= 15e3).sort((g, y) => Math.abs(c - m(g)) - Math.abs(c - m(y)))[0] : void 0;
61
+ return {
62
+ key: `move|${n.timestamp ?? ""}|${(($ = n.event) == null ? void 0 : $.to_label) ?? ""}`,
63
+ timestamp: n.timestamp,
64
+ who: h ? "Automatic" : a(n),
65
+ userId: n.user_id ?? null,
66
+ trigger: _ ? { name: a(_), userId: _.user_id ?? null } : null,
67
+ action: "moved",
68
+ values: { ...(f == null ? void 0 : f.values) ?? {}, [A]: ((S = n.event) == null ? void 0 : S.to_label) ?? null },
69
+ changed: /* @__PURE__ */ new Set([A]),
70
+ recalculated: /* @__PURE__ */ new Set(),
71
+ via: /* @__PURE__ */ new Map()
72
+ };
73
+ });
74
+ return [...u, ...w].sort(
75
+ (n, c) => (c.timestamp ? new Date(c.timestamp).getTime() : 0) - (n.timestamp ? new Date(n.timestamp).getTime() : 0)
76
+ );
77
+ }
78
+ function Y(e, o) {
79
+ const a = /* @__PURE__ */ new Map();
80
+ for (const s of e) {
81
+ for (const i of Object.keys(s.values)) a.has(i) || a.set(i, 0);
82
+ for (const i of [...s.changed, ...s.recalculated]) a.set(i, (a.get(i) ?? 0) + 1);
83
+ }
84
+ const t = (s) => s === A ? { label: L, system: !1, order: -1 } : o(s);
85
+ return [...a].filter(([s]) => s !== "id" && !t(s).system).map(([s, i]) => ({ field: s, label: t(s).label, changes: i })).sort((s, i) => {
86
+ const r = t(s.field).order ?? Number.POSITIVE_INFINITY, l = t(i.field).order ?? Number.POSITIVE_INFINITY;
87
+ return r - l || s.label.localeCompare(i.label);
88
+ });
89
+ }
90
+ function z(e, o) {
91
+ return e.filter(
92
+ (a) => a.action !== "changed" && a.action !== "moved" || o.some((t) => a.changed.has(t) || a.recalculated.has(t))
93
+ );
94
+ }
95
+ function C(e) {
96
+ const o = Math.abs(e).toLocaleString("en-US", { maximumFractionDigits: 2 });
97
+ return `${e > 0 ? "+" : e < 0 ? "−" : ""}${o}`;
98
+ }
99
+ function B(e) {
100
+ return e != null && e.length ? `Recalculated after ${e.map((o) => `${o.name} · ${o.row} ${C(o.delta)}`).join(", ")}` : "Recalculated";
101
+ }
102
+ const V = {
103
+ created: "Created",
104
+ changed: "Changed",
105
+ deleted: "Deleted",
106
+ restored: "Restored",
107
+ moved: "Moved"
108
+ }, x = (e) => V[e];
109
+ function F(e) {
110
+ let o = e;
111
+ return /^[=+\-@\t\r]/.test(o) && !/^-?\d[\d,]*(\.\d+)?$/.test(o) && (o = `'${o}`), /[",\n\r]/.test(o) ? `"${o.replace(/"/g, '""')}"` : o;
112
+ }
113
+ function H(e, o, a, t) {
114
+ const s = F, r = [["When", "Changed by", "Action", ...o.map((l) => l.label), "Recalculated"].map(s).join(",")];
115
+ for (const l of e) {
116
+ const u = [...l.recalculated].filter((d) => o.some((w) => w.field === d)).map((d) => {
117
+ var c;
118
+ const w = ((c = o.find((f) => f.field === d)) == null ? void 0 : c.label) ?? d;
119
+ if (!t) return `${w}: ${B(l.via.get(d))}`;
120
+ const n = t(d, l);
121
+ return `${w}: ${n.why}${n.because ? ` — ${n.because}` : ""}`;
122
+ }).join("; ");
123
+ r.push(
124
+ [
125
+ l.timestamp ? new Date(l.timestamp).toLocaleString("en-US") : "",
126
+ l.who,
127
+ x(l.action),
128
+ ...o.map((d) => a(d.field, l.values[d.field])),
129
+ u
130
+ ].map((d) => s(String(d ?? ""))).join(",")
131
+ );
132
+ }
133
+ return `${r.join(`\r
134
+ `)}\r
135
+ `;
136
+ }
137
+ const N = (e) => {
138
+ if (e && typeof e == "object" && !Array.isArray(e)) return e;
139
+ if (typeof e != "string" || !e.trim()) return null;
140
+ try {
141
+ const o = JSON.parse(e);
142
+ return o && typeof o == "object" && !Array.isArray(o) ? o : null;
143
+ } catch {
144
+ return null;
145
+ }
146
+ };
147
+ function Z(e, o) {
148
+ const a = String(e ?? "");
149
+ if (a === "rollup") {
150
+ const t = N(o), i = (Array.isArray(t == null ? void 0 : t.sources) ? t == null ? void 0 : t.sources : []).filter((r) => typeof r.related_collection == "string").map((r) => ({
151
+ collection: String(r.related_collection),
152
+ field: String(r.value_field ?? ""),
153
+ aggregate: String(r.aggregate ?? "sum"),
154
+ filtered: !!r.filter && Object.keys(r.filter).length > 0
155
+ }));
156
+ return i.length ? { kind: "rollup", sources: i } : null;
157
+ }
158
+ if (a === "lookup") {
159
+ const t = N(o);
160
+ return !(t != null && t.fk_field) || !(t != null && t.source_field) ? null : { kind: "lookup", fk: String(t.fk_field), source: String(t.source_field) };
161
+ }
162
+ return a === "write" || a === "read" ? { kind: "formula", inputs: [
163
+ ...new Set(
164
+ [...String(o ?? "").matchAll(/\{\{\s*([A-Za-z_][\w]*)/g)].map((s) => s[1])
165
+ )
166
+ ] } : null;
167
+ }
168
+ const J = {
169
+ sum: "Sum",
170
+ count: "Count",
171
+ avg: "Average",
172
+ min: "Lowest",
173
+ max: "Highest",
174
+ median: "Median",
175
+ distinct_count: "Distinct count",
176
+ weighted_avg: "Weighted average"
177
+ }, W = (e) => e.length <= 1 ? e[0] ?? "" : `${e.slice(0, -1).join(", ")} and ${e[e.length - 1]}`;
178
+ function q(e, o, a, t, s = C) {
179
+ const i = o.via.get(e), r = i != null && i.length ? i.map((l) => `${l.name} changed ${l.row} (${s(l.delta)})`).join("; ") : void 0;
180
+ if ((a == null ? void 0 : a.kind) === "rollup")
181
+ return {
182
+ why: a.sources.map((u) => {
183
+ const d = J[u.aggregate] ?? "Total", w = u.aggregate === "count" ? t(u.collection) : `${t(u.collection)} · ${t(u.collection, u.field)}`;
184
+ return `${d} of ${w}${u.filtered ? " (filtered)" : ""}`;
185
+ }).join(" + "),
186
+ because: r ?? "Its rows changed between these two saves"
187
+ };
188
+ if ((a == null ? void 0 : a.kind) === "formula") {
189
+ const l = a.inputs.filter((u) => o.changed.has(u) || o.recalculated.has(u));
190
+ return {
191
+ why: a.inputs.length ? `Worked out from ${W(a.inputs.map((u) => t(null, u)))}` : "Worked out by a formula",
192
+ because: l.length ? `${W(l.map((u) => t(null, u)))} changed` : r ?? void 0
193
+ };
194
+ }
195
+ return (a == null ? void 0 : a.kind) === "lookup" ? {
196
+ why: `Copied from ${t(null, a.fk)} (${a.source.replace(/_/g, " ")})`,
197
+ because: o.changed.has(a.fk) ? `${t(null, a.fk)} changed` : void 0
198
+ } : {
199
+ why: "Set automatically (rule, job or integration)",
200
+ because: r
201
+ };
202
+ }
203
+ function K(e, o) {
204
+ if (!o) return null;
205
+ const a = new Date(o).getTime();
206
+ let t = null;
207
+ for (const s of e) {
208
+ if (new Date(s.t).getTime() > a) break;
209
+ t = s.v;
210
+ }
211
+ return t;
212
+ }
213
+ export {
214
+ A as STEP_FIELD,
215
+ L as STEP_LABEL,
216
+ U as buildSaveRows,
217
+ F as csvCell,
218
+ Z as deriveOf,
219
+ Y as matrixColumns,
220
+ H as matrixCsv,
221
+ P as personName,
222
+ q as recalcReason,
223
+ z as rowsChanging,
224
+ G as sameValue,
225
+ x as saveActionLabel,
226
+ C as signedAmount,
227
+ K as valueAt,
228
+ B as viaText
229
+ };
@@ -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
+ };