@nivaro/react 0.3.79 → 0.3.81
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 +16 -1
- package/dist/shared/components/chat/ChatPanel.js +867 -833
- package/dist/shared/components/item-edit/FieldRenderer.js +25 -24
- package/dist/shared/components/item-edit/InlineTableField.js +2464 -2445
- package/dist/shared/components/item-edit/MembershipSetField.js +165 -147
- package/dist/shared/components/item-edit/SetAllRowsButton.js +120 -0
- package/dist/shared/components/queue/QueueBulkBar.js +70 -66
- package/package.json +1 -1
|
@@ -1,88 +1,88 @@
|
|
|
1
|
-
import { jsxs as
|
|
1
|
+
import { jsxs as b, jsx as n } from "react/jsx-runtime";
|
|
2
2
|
import { useQueryClient as ye, useQuery as K } from "@tanstack/react-query";
|
|
3
|
-
import { Search as ge, X as ve, Check as
|
|
4
|
-
import { useState as C, useMemo as
|
|
3
|
+
import { Search as ge, X as ve, Check as O, ChevronsUpDown as we } from "lucide-react";
|
|
4
|
+
import { useState as C, useMemo as $ } from "react";
|
|
5
5
|
import { useNivaroClient as ce } from "../../context.js";
|
|
6
|
-
import { get as
|
|
6
|
+
import { get as R, patch as ke, post as se, del as ne } from "../../lib/commands.js";
|
|
7
7
|
import { userErrorMessage as Ne } from "../../lib/safe-error.js";
|
|
8
|
-
import { matchesAllTokens as de, titleCase as
|
|
8
|
+
import { matchesAllTokens as de, titleCase as P, cn as _ } from "../../lib/utils.js";
|
|
9
9
|
import { Popover as _e, PopoverTrigger as $e, PopoverContent as Se } from "../ui/popover.js";
|
|
10
10
|
import { applyDisplayTemplate as qe } from "./helpers.js";
|
|
11
11
|
import { RelationCombobox as Ce } from "./RelationCombobox.js";
|
|
12
12
|
const oe = (a, l) => `${a ?? ""}\0${l ?? ""}`;
|
|
13
13
|
function Le(a, l) {
|
|
14
|
-
const
|
|
15
|
-
for (const
|
|
16
|
-
const
|
|
17
|
-
|
|
14
|
+
const u = new Map(l.map((y) => [oe(y[0], y[1]), y])), i = /* @__PURE__ */ new Set(), o = [];
|
|
15
|
+
for (const y of a) {
|
|
16
|
+
const h = oe(y.value, y.value2);
|
|
17
|
+
u.has(h) && !i.has(h) ? i.add(h) : o.push(y.id);
|
|
18
18
|
}
|
|
19
|
-
const
|
|
20
|
-
for (const [
|
|
21
|
-
if (i.has(
|
|
19
|
+
const m = [], g = [];
|
|
20
|
+
for (const [y, h] of u) {
|
|
21
|
+
if (i.has(y)) continue;
|
|
22
22
|
const c = o.shift();
|
|
23
|
-
c !== void 0 ?
|
|
23
|
+
c !== void 0 ? m.push({ id: c, pair: h }) : g.push(h);
|
|
24
24
|
}
|
|
25
|
-
return { repoint:
|
|
25
|
+
return { repoint: m, create: g, remove: o };
|
|
26
26
|
}
|
|
27
27
|
const Te = (a, l) => {
|
|
28
|
-
const
|
|
29
|
-
return
|
|
28
|
+
const u = a.size ? [...a] : [null], i = l.size ? [...l] : [null];
|
|
29
|
+
return u.flatMap((o) => i.map((m) => [o, m]));
|
|
30
30
|
}, Ke = 10;
|
|
31
|
-
async function
|
|
31
|
+
async function Q(a, l, u) {
|
|
32
32
|
const i = [];
|
|
33
33
|
for (let o = 1; o <= 50; o++) {
|
|
34
|
-
const
|
|
35
|
-
if (i.push(...
|
|
34
|
+
const m = await a.request(R(l, { ...u, limit: 1e3, page: o })).then((g) => g.data ?? []);
|
|
35
|
+
if (i.push(...m), m.length < 1e3) break;
|
|
36
36
|
}
|
|
37
37
|
return i;
|
|
38
38
|
}
|
|
39
39
|
const Me = (a) => [...(a ?? "").matchAll(/\{\{([\w.]+)\}\}/g)].map((l) => l[1]);
|
|
40
|
-
function
|
|
41
|
-
const
|
|
40
|
+
function A(a, l) {
|
|
41
|
+
const u = ce(), { data: i } = K({
|
|
42
42
|
queryKey: ["collection-display-meta", a],
|
|
43
|
-
queryFn: () =>
|
|
43
|
+
queryFn: () => u.request(R(`/collections/${a}`)).then((c) => {
|
|
44
44
|
var s;
|
|
45
45
|
return { display_template: ((s = c.data) == null ? void 0 : s.display_template) ?? null };
|
|
46
46
|
}),
|
|
47
47
|
enabled: !!a,
|
|
48
48
|
staleTime: 10 * 6e4
|
|
49
|
-
}), o = (i == null ? void 0 : i.display_template) ?? null,
|
|
50
|
-
queryKey: ["membership-set-labels", a, o,
|
|
49
|
+
}), o = (i == null ? void 0 : i.display_template) ?? null, m = l === "all" ? "all" : [...l].sort().join(","), { data: g = [], isLoading: y } = K({
|
|
50
|
+
queryKey: ["membership-set-labels", a, o, m],
|
|
51
51
|
queryFn: async () => {
|
|
52
52
|
const c = Me(o), s = c.length ? { fields: ["id", ...c].join(",") } : {};
|
|
53
|
-
if (l === "all") return
|
|
54
|
-
const
|
|
53
|
+
if (l === "all") return Q(u, `/items/${a}`, s);
|
|
54
|
+
const f = [];
|
|
55
55
|
for (let w = 0; w < l.length; w += 150)
|
|
56
|
-
|
|
57
|
-
...await
|
|
56
|
+
f.push(
|
|
57
|
+
...await Q(u, `/items/${a}`, {
|
|
58
58
|
...s,
|
|
59
59
|
filter: JSON.stringify({ id: { _in: l.slice(w, w + 150) } })
|
|
60
60
|
})
|
|
61
61
|
);
|
|
62
|
-
return
|
|
62
|
+
return f;
|
|
63
63
|
},
|
|
64
64
|
enabled: !!a && i !== void 0 && (l === "all" || l.length > 0),
|
|
65
65
|
staleTime: 6e4
|
|
66
66
|
});
|
|
67
|
-
return { labels:
|
|
67
|
+
return { labels: $(() => {
|
|
68
68
|
const c = /* @__PURE__ */ new Map();
|
|
69
69
|
for (const s of g) {
|
|
70
|
-
const
|
|
71
|
-
c.set(String(s.id), (o ? qe(o, s) : "").trim() ||
|
|
70
|
+
const f = String(s.name ?? s.title ?? s.label ?? `#${s.id}`);
|
|
71
|
+
c.set(String(s.id), (o ? qe(o, s) : "").trim() || f);
|
|
72
72
|
}
|
|
73
73
|
return c;
|
|
74
|
-
}, [g, o]), isLoading:
|
|
74
|
+
}, [g, o]), isLoading: y };
|
|
75
75
|
}
|
|
76
76
|
function Je({
|
|
77
77
|
relatedCollection: a,
|
|
78
78
|
manyField: l,
|
|
79
|
-
parentId:
|
|
79
|
+
parentId: u,
|
|
80
80
|
config: i,
|
|
81
81
|
readOnly: o
|
|
82
82
|
}) {
|
|
83
|
-
const
|
|
83
|
+
const m = ce(), g = ye(), y = u === "new", { key_field: h, value_field: c } = i, s = i.value_field_2 || null, f = i.empty_label ?? "All", w = i.empty_label_2 ?? f, [S, p] = C(""), [k, z] = C(null), [B, D] = C(null), { data: ue = [] } = K({
|
|
84
84
|
queryKey: ["collection-relations", a],
|
|
85
|
-
queryFn: () =>
|
|
85
|
+
queryFn: () => m.request(R(`/collections/${a}`)).then((e) => {
|
|
86
86
|
var r;
|
|
87
87
|
return ((r = e.data) == null ? void 0 : r.relations) ?? [];
|
|
88
88
|
}),
|
|
@@ -90,36 +90,36 @@ function Je({
|
|
|
90
90
|
}), M = (e) => {
|
|
91
91
|
var r;
|
|
92
92
|
return ((r = ue.find((t) => t.many_collection === a && t.many_field === e)) == null ? void 0 : r.one_collection) ?? null;
|
|
93
|
-
}, L = M(
|
|
94
|
-
queryKey:
|
|
95
|
-
queryFn: async () => (await
|
|
96
|
-
fields: ["id",
|
|
97
|
-
filter: JSON.stringify({ [l]: { _eq:
|
|
98
|
-
})).filter((e) => e[
|
|
93
|
+
}, L = M(h), E = M(c), J = s ? M(s) : null, V = ["membership-set-rows", a, l, String(u)], { data: H = [], isLoading: me } = K({
|
|
94
|
+
queryKey: V,
|
|
95
|
+
queryFn: async () => (await Q(m, `/items/${a}`, {
|
|
96
|
+
fields: ["id", h, c, ...s ? [s] : []].join(","),
|
|
97
|
+
filter: JSON.stringify({ [l]: { _eq: u } })
|
|
98
|
+
})).filter((e) => e[h] != null).map((e) => ({
|
|
99
99
|
id: e.id,
|
|
100
|
-
key: String(e[
|
|
100
|
+
key: String(e[h]),
|
|
101
101
|
value: e[c] == null ? null : String(e[c]),
|
|
102
102
|
value2: !s || e[s] == null ? null : String(e[s])
|
|
103
103
|
})),
|
|
104
|
-
enabled: !
|
|
104
|
+
enabled: !y,
|
|
105
105
|
staleTime: 15e3
|
|
106
|
-
}), N =
|
|
106
|
+
}), N = $(() => {
|
|
107
107
|
const e = /* @__PURE__ */ new Map();
|
|
108
|
-
for (const r of
|
|
108
|
+
for (const r of H) e.set(r.key, [...e.get(r.key) ?? [], r]);
|
|
109
109
|
return e;
|
|
110
|
-
}, [
|
|
111
|
-
g.invalidateQueries({ queryKey:
|
|
110
|
+
}, [H]), v = $(() => [...N.keys()], [N]), { labels: U } = A(L, v), { labels: X } = A(E, "all"), { labels: G } = A(J, "all"), W = (e) => [...e.entries()].map(([r, t]) => ({ id: r, label: t })).sort((r, t) => r.label.localeCompare(t.label, void 0, { numeric: !0 })), pe = $(() => W(X), [X]), be = $(() => W(G), [G]), he = () => {
|
|
111
|
+
g.invalidateQueries({ queryKey: V }), g.invalidateQueries({ queryKey: ["o2m-rows", a] });
|
|
112
112
|
}, j = async (e, r) => {
|
|
113
|
-
|
|
113
|
+
z(e), D(null);
|
|
114
114
|
try {
|
|
115
115
|
await r();
|
|
116
116
|
} catch (t) {
|
|
117
|
-
const
|
|
118
|
-
|
|
117
|
+
const x = t == null ? void 0 : t.response;
|
|
118
|
+
D((x == null ? void 0 : x.error) ?? Ne(t, "Could not save"));
|
|
119
119
|
} finally {
|
|
120
|
-
|
|
120
|
+
z(null), he();
|
|
121
121
|
}
|
|
122
|
-
},
|
|
122
|
+
}, Y = (e) => {
|
|
123
123
|
const r = N.get(e) ?? [];
|
|
124
124
|
return {
|
|
125
125
|
a: new Set(r.filter((t) => t.value !== null).map((t) => t.value)),
|
|
@@ -129,52 +129,52 @@ function Je({
|
|
|
129
129
|
[c]: e,
|
|
130
130
|
...s ? { [s]: r } : {}
|
|
131
131
|
}), T = (e, r, t) => j(e, async () => {
|
|
132
|
-
const
|
|
133
|
-
for (const d of
|
|
134
|
-
await
|
|
135
|
-
for (const d of
|
|
136
|
-
await
|
|
132
|
+
const x = Le(N.get(e) ?? [], Te(r, t));
|
|
133
|
+
for (const d of x.repoint)
|
|
134
|
+
await m.request(ke(`/items/${a}/${d.id}`, F(d.pair)));
|
|
135
|
+
for (const d of x.create)
|
|
136
|
+
await m.request(
|
|
137
137
|
se(`/items/${a}`, {
|
|
138
|
-
[l]:
|
|
139
|
-
[
|
|
138
|
+
[l]: u,
|
|
139
|
+
[h]: e,
|
|
140
140
|
...F(d)
|
|
141
141
|
})
|
|
142
142
|
);
|
|
143
|
-
for (const d of
|
|
144
|
-
}),
|
|
143
|
+
for (const d of x.remove) await m.request(ne(`/items/${a}/${d}`));
|
|
144
|
+
}), Z = (e, r) => {
|
|
145
145
|
const t = new Set(e);
|
|
146
146
|
return t.has(r) ? t.delete(r) : t.add(r), t;
|
|
147
|
-
},
|
|
148
|
-
const { a:
|
|
149
|
-
return t === 1 ? T(e,
|
|
150
|
-
},
|
|
151
|
-
const { a: t, b:
|
|
152
|
-
if ((r === 1 ? t :
|
|
153
|
-
return r === 1 ? T(e, /* @__PURE__ */ new Set(),
|
|
147
|
+
}, I = (e, r, t = 1) => {
|
|
148
|
+
const { a: x, b: d } = Y(e);
|
|
149
|
+
return t === 1 ? T(e, Z(x, r), d) : T(e, x, Z(d, r));
|
|
150
|
+
}, ee = (e, r = 1) => {
|
|
151
|
+
const { a: t, b: x } = Y(e);
|
|
152
|
+
if ((r === 1 ? t : x).size !== 0)
|
|
153
|
+
return r === 1 ? T(e, /* @__PURE__ */ new Set(), x) : T(e, t, /* @__PURE__ */ new Set());
|
|
154
154
|
}, fe = (e) => j(e, async () => {
|
|
155
155
|
for (const r of N.get(e) ?? [])
|
|
156
|
-
await
|
|
156
|
+
await m.request(ne(`/items/${a}/${r.id}`));
|
|
157
157
|
}), xe = (e) => {
|
|
158
158
|
e == null || e === "" || N.has(String(e)) || j(
|
|
159
159
|
String(e),
|
|
160
|
-
() =>
|
|
160
|
+
() => m.request(
|
|
161
161
|
se(`/items/${a}`, {
|
|
162
|
-
[l]:
|
|
163
|
-
[
|
|
162
|
+
[l]: u,
|
|
163
|
+
[h]: e,
|
|
164
164
|
...F([null, null])
|
|
165
165
|
})
|
|
166
166
|
)
|
|
167
167
|
);
|
|
168
|
-
},
|
|
169
|
-
const e = v.map((t) => ({ key: t, label:
|
|
168
|
+
}, te = $(() => {
|
|
169
|
+
const e = v.map((t) => ({ key: t, label: U.get(t) ?? `#${t}` })).sort((t, x) => t.label.localeCompare(x.label, void 0, { numeric: !0 })), r = S.trim();
|
|
170
170
|
return r ? e.filter((t) => de(t.label, r)) : e;
|
|
171
|
-
}, [v,
|
|
172
|
-
return
|
|
171
|
+
}, [v, U, S]), q = i.key_label ?? P(L ?? h), re = i.value_label ?? P(E ?? c), ae = s ? i.value_label_2 ?? P(J ?? s) : "", le = s ? "grid-cols-[minmax(140px,1fr)_minmax(0,1.5fr)_minmax(0,1.5fr)_28px]" : "grid-cols-[minmax(140px,1fr)_minmax(0,2fr)_28px]";
|
|
172
|
+
return y ? /* @__PURE__ */ b("p", { className: "rounded-lg border border-dashed border-slate-200 px-3 py-4 text-[12px] text-slate-500 dark:border-border dark:text-muted-foreground", children: [
|
|
173
173
|
"Save this record first, then add ",
|
|
174
174
|
q.toLowerCase(),
|
|
175
175
|
" here."
|
|
176
|
-
] }) : /* @__PURE__ */
|
|
177
|
-
!o && L && /* @__PURE__ */
|
|
176
|
+
] }) : /* @__PURE__ */ b("div", { "data-membership-set": `${a}:${l}`, className: "space-y-2", children: [
|
|
177
|
+
!o && L && /* @__PURE__ */ b("div", { className: "flex flex-wrap items-center gap-2", children: [
|
|
178
178
|
/* @__PURE__ */ n("div", { className: "w-[320px] max-w-full", children: /* @__PURE__ */ n(
|
|
179
179
|
Ce,
|
|
180
180
|
{
|
|
@@ -186,13 +186,13 @@ function Je({
|
|
|
186
186
|
},
|
|
187
187
|
v.length
|
|
188
188
|
) }),
|
|
189
|
-
v.length > 8 && /* @__PURE__ */
|
|
189
|
+
v.length > 8 && /* @__PURE__ */ b("label", { className: "relative ml-auto block w-[220px] max-w-full", children: [
|
|
190
190
|
/* @__PURE__ */ n(ge, { className: "pointer-events-none absolute left-2 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-slate-400" }),
|
|
191
191
|
/* @__PURE__ */ n(
|
|
192
192
|
"input",
|
|
193
193
|
{
|
|
194
194
|
value: S,
|
|
195
|
-
onChange: (e) =>
|
|
195
|
+
onChange: (e) => p(e.target.value),
|
|
196
196
|
placeholder: `Filter ${v.length}…`,
|
|
197
197
|
"aria-label": `Filter ${q}`,
|
|
198
198
|
className: "h-8 w-full rounded-md border border-slate-200 bg-background pl-7 pr-2 text-[12px] outline-none focus:border-nvr-cyan dark:border-border"
|
|
@@ -200,28 +200,28 @@ function Je({
|
|
|
200
200
|
)
|
|
201
201
|
] })
|
|
202
202
|
] }),
|
|
203
|
-
/* @__PURE__ */
|
|
204
|
-
/* @__PURE__ */
|
|
203
|
+
/* @__PURE__ */ b("div", { className: "overflow-hidden rounded-lg border border-slate-200 dark:border-border", children: [
|
|
204
|
+
/* @__PURE__ */ b(
|
|
205
205
|
"div",
|
|
206
206
|
{
|
|
207
|
-
className:
|
|
208
|
-
|
|
207
|
+
className: _(
|
|
208
|
+
le,
|
|
209
209
|
"grid gap-3 border-b border-slate-200 bg-slate-50 px-3 py-1.5 text-[10.5px] font-medium uppercase tracking-wide text-slate-500 dark:border-border dark:bg-muted dark:text-muted-foreground"
|
|
210
210
|
),
|
|
211
211
|
children: [
|
|
212
212
|
/* @__PURE__ */ n("span", { children: q }),
|
|
213
|
-
/* @__PURE__ */
|
|
214
|
-
|
|
213
|
+
/* @__PURE__ */ b("span", { children: [
|
|
214
|
+
re,
|
|
215
215
|
" ",
|
|
216
|
-
/* @__PURE__ */
|
|
216
|
+
/* @__PURE__ */ b("span", { className: "normal-case tracking-normal text-slate-400", children: [
|
|
217
217
|
"· none picked = ",
|
|
218
|
-
|
|
218
|
+
f.toLowerCase()
|
|
219
219
|
] })
|
|
220
220
|
] }),
|
|
221
|
-
s && /* @__PURE__ */
|
|
222
|
-
|
|
221
|
+
s && /* @__PURE__ */ b("span", { children: [
|
|
222
|
+
ae,
|
|
223
223
|
" ",
|
|
224
|
-
/* @__PURE__ */
|
|
224
|
+
/* @__PURE__ */ b("span", { className: "normal-case tracking-normal text-slate-400", children: [
|
|
225
225
|
"· none picked = ",
|
|
226
226
|
w.toLowerCase()
|
|
227
227
|
] })
|
|
@@ -230,18 +230,18 @@ function Je({
|
|
|
230
230
|
]
|
|
231
231
|
}
|
|
232
232
|
),
|
|
233
|
-
me ? /* @__PURE__ */ n("div", { className: "space-y-2 p-3", children: [0, 1, 2].map((e) => /* @__PURE__ */ n("div", { className: "h-6 animate-pulse rounded bg-[hsl(var(--nvr-skeleton))]" }, e)) }) :
|
|
233
|
+
me ? /* @__PURE__ */ n("div", { className: "space-y-2 p-3", children: [0, 1, 2].map((e) => /* @__PURE__ */ n("div", { className: "h-6 animate-pulse rounded bg-[hsl(var(--nvr-skeleton))]" }, e)) }) : te.length === 0 ? /* @__PURE__ */ n("p", { className: "px-3 py-5 text-center text-[12px] text-slate-500 dark:text-muted-foreground", children: v.length ? "Nothing matches that filter." : `No ${q.toLowerCase()} yet.` }) : /* @__PURE__ */ n("ul", { className: "max-h-[480px] divide-y divide-slate-100 overflow-y-auto dark:divide-border", children: te.map((e) => {
|
|
234
234
|
const r = N.get(e.key) ?? [], t = new Set(
|
|
235
235
|
r.filter((d) => d.value !== null).map((d) => d.value)
|
|
236
|
-
),
|
|
236
|
+
), x = new Set(
|
|
237
237
|
r.filter((d) => d.value2 !== null).map((d) => d.value2)
|
|
238
238
|
);
|
|
239
|
-
return /* @__PURE__ */
|
|
239
|
+
return /* @__PURE__ */ b(
|
|
240
240
|
"li",
|
|
241
241
|
{
|
|
242
242
|
"data-membership-key": e.key,
|
|
243
|
-
className:
|
|
244
|
-
|
|
243
|
+
className: _(
|
|
244
|
+
le,
|
|
245
245
|
"grid items-center gap-3 px-3 py-1.5 text-[12px]",
|
|
246
246
|
k === e.key && "opacity-60"
|
|
247
247
|
),
|
|
@@ -259,23 +259,23 @@ function Je({
|
|
|
259
259
|
{
|
|
260
260
|
options: pe,
|
|
261
261
|
picked: t,
|
|
262
|
-
emptyLabel:
|
|
263
|
-
valueTitle:
|
|
262
|
+
emptyLabel: f,
|
|
263
|
+
valueTitle: re,
|
|
264
264
|
disabled: !!o || k === e.key,
|
|
265
|
-
onToggle: (d) =>
|
|
266
|
-
onClear: () =>
|
|
265
|
+
onToggle: (d) => I(e.key, d),
|
|
266
|
+
onClear: () => ee(e.key)
|
|
267
267
|
}
|
|
268
268
|
),
|
|
269
269
|
s && /* @__PURE__ */ n(
|
|
270
270
|
ie,
|
|
271
271
|
{
|
|
272
272
|
options: be,
|
|
273
|
-
picked:
|
|
273
|
+
picked: x,
|
|
274
274
|
emptyLabel: w,
|
|
275
|
-
valueTitle:
|
|
275
|
+
valueTitle: ae,
|
|
276
276
|
disabled: !!o || k === e.key,
|
|
277
|
-
onToggle: (d) =>
|
|
278
|
-
onClear: () =>
|
|
277
|
+
onToggle: (d) => I(e.key, d, 2),
|
|
278
|
+
onClear: () => ee(e.key, 2)
|
|
279
279
|
}
|
|
280
280
|
),
|
|
281
281
|
o ? /* @__PURE__ */ n("span", {}) : /* @__PURE__ */ n(
|
|
@@ -296,99 +296,117 @@ function Je({
|
|
|
296
296
|
);
|
|
297
297
|
}) })
|
|
298
298
|
] }),
|
|
299
|
-
|
|
299
|
+
B && /* @__PURE__ */ n("p", { className: "text-[12px] text-red-600 dark:text-red-400", children: B })
|
|
300
300
|
] });
|
|
301
301
|
}
|
|
302
302
|
function ie({
|
|
303
303
|
options: a,
|
|
304
304
|
picked: l,
|
|
305
|
-
emptyLabel:
|
|
305
|
+
emptyLabel: u,
|
|
306
306
|
valueTitle: i,
|
|
307
307
|
disabled: o,
|
|
308
|
-
onToggle:
|
|
308
|
+
onToggle: m,
|
|
309
309
|
onClear: g
|
|
310
310
|
}) {
|
|
311
|
-
const [
|
|
311
|
+
const [y, h] = C(!1), [c, s] = C(""), f = l.size === 0;
|
|
312
312
|
if (a.length <= Ke)
|
|
313
|
-
return /* @__PURE__ */
|
|
313
|
+
return /* @__PURE__ */ b("div", { className: "flex flex-wrap items-center gap-1", "data-membership-values": !0, children: [
|
|
314
314
|
/* @__PURE__ */ n(
|
|
315
315
|
"button",
|
|
316
316
|
{
|
|
317
317
|
type: "button",
|
|
318
|
-
disabled: o ||
|
|
319
|
-
"aria-pressed":
|
|
318
|
+
disabled: o || f,
|
|
319
|
+
"aria-pressed": f,
|
|
320
320
|
onClick: g,
|
|
321
|
-
className:
|
|
321
|
+
className: _(
|
|
322
322
|
"h-6 rounded-full border px-2 text-[11px] transition-colors",
|
|
323
|
-
|
|
323
|
+
f ? "border-nvr-cyan/40 bg-nvr-cyan/10 font-medium text-slate-800 dark:text-foreground" : "border-slate-200 text-slate-500 hover:bg-muted dark:border-border dark:text-muted-foreground"
|
|
324
324
|
),
|
|
325
|
-
children:
|
|
325
|
+
children: u
|
|
326
326
|
}
|
|
327
327
|
),
|
|
328
|
-
a.map((
|
|
329
|
-
const k = l.has(
|
|
330
|
-
return /* @__PURE__ */
|
|
328
|
+
a.map((p) => {
|
|
329
|
+
const k = l.has(p.id);
|
|
330
|
+
return /* @__PURE__ */ b(
|
|
331
331
|
"button",
|
|
332
332
|
{
|
|
333
333
|
type: "button",
|
|
334
334
|
disabled: o,
|
|
335
335
|
"aria-pressed": k,
|
|
336
|
-
"data-membership-value":
|
|
337
|
-
onClick: () =>
|
|
338
|
-
className:
|
|
336
|
+
"data-membership-value": p.id,
|
|
337
|
+
onClick: () => m(p.id),
|
|
338
|
+
className: _(
|
|
339
339
|
"inline-flex h-6 items-center gap-1 rounded-full border px-2 text-[11px] transition-colors",
|
|
340
340
|
k ? "border-nvr-cyan/40 bg-nvr-cyan/10 font-medium text-slate-800 dark:text-foreground" : "border-slate-200 text-slate-500 hover:bg-muted dark:border-border dark:text-muted-foreground"
|
|
341
341
|
),
|
|
342
342
|
children: [
|
|
343
|
-
k && /* @__PURE__ */ n(
|
|
344
|
-
|
|
343
|
+
k && /* @__PURE__ */ n(O, { className: "h-3 w-3" }),
|
|
344
|
+
p.label
|
|
345
345
|
]
|
|
346
346
|
},
|
|
347
|
-
|
|
347
|
+
p.id
|
|
348
348
|
);
|
|
349
349
|
})
|
|
350
350
|
] });
|
|
351
|
-
const w = c.trim() ? a.filter((
|
|
352
|
-
return /* @__PURE__ */
|
|
353
|
-
/* @__PURE__ */ n($e, { asChild: !0, children: /* @__PURE__ */
|
|
351
|
+
const w = c.trim() ? a.filter((p) => de(p.label, c)) : a, S = f ? u : a.filter((p) => l.has(p.id)).map((p) => p.label).join(", ");
|
|
352
|
+
return /* @__PURE__ */ b(_e, { open: y, onOpenChange: h, children: [
|
|
353
|
+
/* @__PURE__ */ n($e, { asChild: !0, children: /* @__PURE__ */ b(
|
|
354
354
|
"button",
|
|
355
355
|
{
|
|
356
356
|
type: "button",
|
|
357
357
|
disabled: o,
|
|
358
358
|
className: "flex h-7 w-full items-center justify-between gap-2 rounded-md border border-slate-200 bg-background px-2 text-left text-[12px] dark:border-border",
|
|
359
359
|
children: [
|
|
360
|
-
/* @__PURE__ */ n("span", { className:
|
|
360
|
+
/* @__PURE__ */ n("span", { className: _("truncate", f && "text-slate-500 dark:text-muted-foreground"), children: S }),
|
|
361
361
|
/* @__PURE__ */ n(we, { className: "h-3.5 w-3.5 shrink-0 text-slate-400" })
|
|
362
362
|
]
|
|
363
363
|
}
|
|
364
364
|
) }),
|
|
365
|
-
/* @__PURE__ */
|
|
365
|
+
/* @__PURE__ */ b(Se, { align: "start", className: "w-[260px] p-1", children: [
|
|
366
366
|
/* @__PURE__ */ n(
|
|
367
367
|
"input",
|
|
368
368
|
{
|
|
369
369
|
value: c,
|
|
370
|
-
onChange: (
|
|
370
|
+
onChange: (p) => s(p.target.value),
|
|
371
371
|
placeholder: `Search ${i.toLowerCase()}…`,
|
|
372
372
|
className: "mb-1 h-7 w-full rounded border border-slate-200 bg-background px-2 text-[12px] outline-none dark:border-border"
|
|
373
373
|
}
|
|
374
374
|
),
|
|
375
|
-
/* @__PURE__ */
|
|
376
|
-
"
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
375
|
+
/* @__PURE__ */ b("ul", { className: "max-h-[240px] overflow-y-auto", children: [
|
|
376
|
+
!c.trim() && /* @__PURE__ */ n("li", { className: "mb-1 border-b border-slate-100 pb-1 dark:border-border", children: /* @__PURE__ */ b(
|
|
377
|
+
"button",
|
|
378
|
+
{
|
|
379
|
+
type: "button",
|
|
380
|
+
onClick: () => {
|
|
381
|
+
f || g();
|
|
382
|
+
},
|
|
383
|
+
"aria-pressed": f,
|
|
384
|
+
"data-membership-clear": !0,
|
|
385
|
+
className: "flex w-full items-center gap-2 rounded px-2 py-1 text-left text-[12px] font-medium hover:bg-muted",
|
|
386
|
+
children: [
|
|
387
|
+
/* @__PURE__ */ n(O, { className: _("h-3.5 w-3.5", f ? "opacity-100" : "opacity-0") }),
|
|
388
|
+
u
|
|
389
|
+
]
|
|
390
|
+
}
|
|
391
|
+
) }),
|
|
392
|
+
w.map((p) => /* @__PURE__ */ n("li", { children: /* @__PURE__ */ b(
|
|
393
|
+
"button",
|
|
394
|
+
{
|
|
395
|
+
type: "button",
|
|
396
|
+
onClick: () => m(p.id),
|
|
397
|
+
className: "flex w-full items-center gap-2 rounded px-2 py-1 text-left text-[12px] hover:bg-muted",
|
|
398
|
+
children: [
|
|
399
|
+
/* @__PURE__ */ n(
|
|
400
|
+
O,
|
|
401
|
+
{
|
|
402
|
+
className: _("h-3.5 w-3.5", l.has(p.id) ? "opacity-100" : "opacity-0")
|
|
403
|
+
}
|
|
404
|
+
),
|
|
405
|
+
p.label
|
|
406
|
+
]
|
|
407
|
+
}
|
|
408
|
+
) }, p.id))
|
|
409
|
+
] })
|
|
392
410
|
] })
|
|
393
411
|
] });
|
|
394
412
|
}
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import { jsxs as o, jsx as s } from "react/jsx-runtime";
|
|
2
|
+
import { PenLine as h } from "lucide-react";
|
|
3
|
+
import { useState as p } from "react";
|
|
4
|
+
import { cn as g } from "../../lib/utils.js";
|
|
5
|
+
import { Popover as v, PopoverTrigger as $, PopoverContent as k } from "../ui/popover.js";
|
|
6
|
+
function S(r) {
|
|
7
|
+
if (!Array.isArray(r)) return [];
|
|
8
|
+
const t = [];
|
|
9
|
+
for (const n of r) {
|
|
10
|
+
const e = typeof n == "string" ? { field: n } : n;
|
|
11
|
+
!e || typeof e.field != "string" || !e.field || e.field.includes(".") || t.push({
|
|
12
|
+
field: e.field,
|
|
13
|
+
...typeof e.label == "string" && e.label.trim() ? { label: e.label.trim() } : {},
|
|
14
|
+
admin_only: e.admin_only !== !1
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
return t;
|
|
18
|
+
}
|
|
19
|
+
function j({
|
|
20
|
+
label: r,
|
|
21
|
+
count: t,
|
|
22
|
+
scope: n,
|
|
23
|
+
commonValue: e,
|
|
24
|
+
disabled: b,
|
|
25
|
+
onApply: y
|
|
26
|
+
}) {
|
|
27
|
+
const [u, i] = p(!1), [a, f] = p(""), [m, x] = p(!1), d = n === "selected" ? `${t} selected` : `all ${t}`, c = t === 1 ? "line" : "lines";
|
|
28
|
+
return /* @__PURE__ */ o(
|
|
29
|
+
v,
|
|
30
|
+
{
|
|
31
|
+
open: u,
|
|
32
|
+
onOpenChange: (l) => {
|
|
33
|
+
i(l), l && f(e ?? "");
|
|
34
|
+
},
|
|
35
|
+
children: [
|
|
36
|
+
/* @__PURE__ */ s($, { asChild: !0, children: /* @__PURE__ */ o(
|
|
37
|
+
"button",
|
|
38
|
+
{
|
|
39
|
+
type: "button",
|
|
40
|
+
disabled: b || t === 0,
|
|
41
|
+
"data-grid-set-all": !0,
|
|
42
|
+
"data-tip": `Put one ${r} on ${d} ${c}, or clear it`,
|
|
43
|
+
className: g(
|
|
44
|
+
"inline-flex h-6 items-center gap-1 rounded border px-2 transition-colors disabled:opacity-50",
|
|
45
|
+
u ? "border-nvr-cyan bg-nvr-cyan/10 text-nvr-cyan" : "border-slate-200 text-slate-600 hover:border-slate-400 hover:text-slate-800 dark:border-border dark:text-slate-300"
|
|
46
|
+
),
|
|
47
|
+
children: [
|
|
48
|
+
/* @__PURE__ */ s(h, { className: "h-3 w-3", "aria-hidden": "true" }),
|
|
49
|
+
"Set ",
|
|
50
|
+
r,
|
|
51
|
+
"…"
|
|
52
|
+
]
|
|
53
|
+
}
|
|
54
|
+
) }),
|
|
55
|
+
/* @__PURE__ */ s(k, { align: "start", className: "w-[300px] space-y-2 p-3", children: /* @__PURE__ */ o(
|
|
56
|
+
"form",
|
|
57
|
+
{
|
|
58
|
+
className: "space-y-2",
|
|
59
|
+
onSubmit: async (l) => {
|
|
60
|
+
l.preventDefault(), x(!0);
|
|
61
|
+
try {
|
|
62
|
+
await y(a.trim() === "" ? null : a.trim()), i(!1);
|
|
63
|
+
} finally {
|
|
64
|
+
x(!1);
|
|
65
|
+
}
|
|
66
|
+
},
|
|
67
|
+
children: [
|
|
68
|
+
/* @__PURE__ */ o("label", { className: "block text-[12px] font-medium text-slate-700 dark:text-foreground", children: [
|
|
69
|
+
r,
|
|
70
|
+
" for ",
|
|
71
|
+
d,
|
|
72
|
+
" ",
|
|
73
|
+
c,
|
|
74
|
+
/* @__PURE__ */ s(
|
|
75
|
+
"input",
|
|
76
|
+
{
|
|
77
|
+
autoFocus: !0,
|
|
78
|
+
value: a,
|
|
79
|
+
onChange: (l) => f(l.target.value),
|
|
80
|
+
placeholder: `New ${r} — blank clears it`,
|
|
81
|
+
className: "mt-1 h-8 w-full rounded-md border border-slate-200 bg-background px-2 text-[12.5px] font-normal outline-none focus:border-nvr-cyan dark:border-border"
|
|
82
|
+
}
|
|
83
|
+
)
|
|
84
|
+
] }),
|
|
85
|
+
/* @__PURE__ */ o("p", { className: "text-[11.5px] text-slate-500 dark:text-muted-foreground", children: [
|
|
86
|
+
a.trim() === "" ? `Leaving it blank clears ${r} on ${d} ${c}.` : `Every ${n === "selected" ? "selected " : ""}line gets “${a.trim()}”.`,
|
|
87
|
+
" ",
|
|
88
|
+
"The grid’s rules and save mode apply as if typed on each line."
|
|
89
|
+
] }),
|
|
90
|
+
/* @__PURE__ */ o("div", { className: "flex justify-end gap-2", children: [
|
|
91
|
+
/* @__PURE__ */ s(
|
|
92
|
+
"button",
|
|
93
|
+
{
|
|
94
|
+
type: "button",
|
|
95
|
+
onClick: () => i(!1),
|
|
96
|
+
className: "h-7 px-2 text-[12px] text-slate-500 hover:text-slate-800 dark:text-muted-foreground dark:hover:text-foreground",
|
|
97
|
+
children: "Cancel"
|
|
98
|
+
}
|
|
99
|
+
),
|
|
100
|
+
/* @__PURE__ */ s(
|
|
101
|
+
"button",
|
|
102
|
+
{
|
|
103
|
+
type: "submit",
|
|
104
|
+
disabled: m,
|
|
105
|
+
className: "h-7 rounded-md bg-nvr-cyan px-3 text-[12px] font-semibold text-white disabled:opacity-50",
|
|
106
|
+
children: m ? "Applying…" : a.trim() === "" ? `Clear on ${t}` : `Apply to ${t}`
|
|
107
|
+
}
|
|
108
|
+
)
|
|
109
|
+
] })
|
|
110
|
+
]
|
|
111
|
+
}
|
|
112
|
+
) })
|
|
113
|
+
]
|
|
114
|
+
}
|
|
115
|
+
);
|
|
116
|
+
}
|
|
117
|
+
export {
|
|
118
|
+
j as SetAllRowsButton,
|
|
119
|
+
S as normalizeSetAllRows
|
|
120
|
+
};
|