@nivaro/react 0.3.78 → 0.3.80

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.
@@ -1,88 +1,88 @@
1
- import { jsxs as f, jsx as n } from "react/jsx-runtime";
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 le, ChevronsUpDown as we } from "lucide-react";
4
- import { useState as C, useMemo as _ } from "react";
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 Q, patch as ke, post as se, del as ne } from "../../lib/commands.js";
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 O, cn as $ } from "../../lib/utils.js";
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 p = new Map(l.map((x) => [oe(x[0], x[1]), x])), i = /* @__PURE__ */ new Set(), o = [];
15
- for (const x of a) {
16
- const b = oe(x.value, x.value2);
17
- p.has(b) && !i.has(b) ? i.add(b) : o.push(x.id);
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 u = [], g = [];
20
- for (const [x, b] of p) {
21
- if (i.has(x)) continue;
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 ? u.push({ id: c, pair: b }) : g.push(b);
23
+ c !== void 0 ? m.push({ id: c, pair: h }) : g.push(h);
24
24
  }
25
- return { repoint: u, create: g, remove: o };
25
+ return { repoint: m, create: g, remove: o };
26
26
  }
27
27
  const Te = (a, l) => {
28
- const p = a.size ? [...a] : [null], i = l.size ? [...l] : [null];
29
- return p.flatMap((o) => i.map((u) => [o, u]));
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 A(a, l, p) {
31
+ async function Q(a, l, u) {
32
32
  const i = [];
33
33
  for (let o = 1; o <= 50; o++) {
34
- const u = await a.request(Q(l, { ...p, limit: 1e3, page: o })).then((g) => g.data ?? []);
35
- if (i.push(...u), u.length < 1e3) break;
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 P(a, l) {
41
- const p = ce(), { data: i } = K({
40
+ function A(a, l) {
41
+ const u = ce(), { data: i } = K({
42
42
  queryKey: ["collection-display-meta", a],
43
- queryFn: () => p.request(Q(`/collections/${a}`)).then((c) => {
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, u = l === "all" ? "all" : [...l].sort().join(","), { data: g = [], isLoading: x } = K({
50
- queryKey: ["membership-set-labels", a, o, u],
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 A(p, `/items/${a}`, s);
54
- const y = [];
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
- y.push(
57
- ...await A(p, `/items/${a}`, {
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 y;
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 y = String(s.name ?? s.title ?? s.label ?? `#${s.id}`);
71
- c.set(String(s.id), (o ? qe(o, s) : "").trim() || y);
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: x };
74
+ }, [g, o]), isLoading: y };
75
75
  }
76
76
  function Je({
77
77
  relatedCollection: a,
78
78
  manyField: l,
79
- parentId: p,
79
+ parentId: u,
80
80
  config: i,
81
81
  readOnly: o
82
82
  }) {
83
- const u = ce(), g = ye(), x = p === "new", { key_field: b, value_field: c } = i, s = i.value_field_2 || null, y = i.empty_label ?? "All", w = i.empty_label_2 ?? y, [S, m] = C(""), [k, R] = C(null), [z, B] = C(null), { data: ue = [] } = K({
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: () => u.request(Q(`/collections/${a}`)).then((e) => {
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(b), D = M(c), E = s ? M(s) : null, J = ["membership-set-rows", a, l, String(p)], { data: V = [], isLoading: me } = K({
94
- queryKey: J,
95
- queryFn: async () => (await A(u, `/items/${a}`, {
96
- fields: ["id", b, c, ...s ? [s] : []].join(","),
97
- filter: JSON.stringify({ [l]: { _eq: p } })
98
- })).filter((e) => e[b] != null).map((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[b]),
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: !x,
104
+ enabled: !y,
105
105
  staleTime: 15e3
106
- }), N = _(() => {
106
+ }), N = $(() => {
107
107
  const e = /* @__PURE__ */ new Map();
108
- for (const r of V) e.set(r.key, [...e.get(r.key) ?? [], r]);
108
+ for (const r of H) e.set(r.key, [...e.get(r.key) ?? [], r]);
109
109
  return e;
110
- }, [V]), v = _(() => [...N.keys()], [N]), { labels: H } = P(L, v), { labels: U } = P(D, "all"), { labels: X } = P(E, "all"), G = (e) => [...e.entries()].map(([r, t]) => ({ id: r, label: t })).sort((r, t) => r.label.localeCompare(t.label, void 0, { numeric: !0 })), pe = _(() => G(U), [U]), be = _(() => G(X), [X]), he = () => {
111
- g.invalidateQueries({ queryKey: J }), g.invalidateQueries({ queryKey: ["o2m-rows", a] });
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
- R(e), B(null);
113
+ z(e), D(null);
114
114
  try {
115
115
  await r();
116
116
  } catch (t) {
117
- const h = t == null ? void 0 : t.response;
118
- B((h == null ? void 0 : h.error) ?? Ne(t, "Could not save"));
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
- R(null), he();
120
+ z(null), he();
121
121
  }
122
- }, W = (e) => {
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 h = Le(N.get(e) ?? [], Te(r, t));
133
- for (const d of h.repoint)
134
- await u.request(ke(`/items/${a}/${d.id}`, F(d.pair)));
135
- for (const d of h.create)
136
- await u.request(
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]: p,
139
- [b]: e,
138
+ [l]: u,
139
+ [h]: e,
140
140
  ...F(d)
141
141
  })
142
142
  );
143
- for (const d of h.remove) await u.request(ne(`/items/${a}/${d}`));
144
- }), Y = (e, r) => {
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
- }, Z = (e, r, t = 1) => {
148
- const { a: h, b: d } = W(e);
149
- return t === 1 ? T(e, Y(h, r), d) : T(e, h, Y(d, r));
150
- }, I = (e, r = 1) => {
151
- const { a: t, b: h } = W(e);
152
- if ((r === 1 ? t : h).size !== 0)
153
- return r === 1 ? T(e, /* @__PURE__ */ new Set(), h) : T(e, t, /* @__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 u.request(ne(`/items/${a}/${r.id}`));
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
- () => u.request(
160
+ () => m.request(
161
161
  se(`/items/${a}`, {
162
- [l]: p,
163
- [b]: e,
162
+ [l]: u,
163
+ [h]: e,
164
164
  ...F([null, null])
165
165
  })
166
166
  )
167
167
  );
168
- }, ee = _(() => {
169
- const e = v.map((t) => ({ key: t, label: H.get(t) ?? `#${t}` })).sort((t, h) => t.label.localeCompare(h.label, void 0, { numeric: !0 })), r = S.trim();
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, H, S]), q = i.key_label ?? O(L ?? b), te = i.value_label ?? O(D ?? c), re = s ? i.value_label_2 ?? O(E ?? s) : "", ae = 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 x ? /* @__PURE__ */ f("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: [
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__ */ f("div", { "data-membership-set": `${a}:${l}`, className: "space-y-2", children: [
177
- !o && L && /* @__PURE__ */ f("div", { className: "flex flex-wrap items-center gap-2", children: [
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__ */ f("label", { className: "relative ml-auto block w-[220px] max-w-full", children: [
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) => m(e.target.value),
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__ */ f("div", { className: "overflow-hidden rounded-lg border border-slate-200 dark:border-border", children: [
204
- /* @__PURE__ */ f(
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
- ae,
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__ */ f("span", { children: [
214
- te,
213
+ /* @__PURE__ */ b("span", { children: [
214
+ re,
215
215
  " ",
216
- /* @__PURE__ */ f("span", { className: "normal-case tracking-normal text-slate-400", children: [
216
+ /* @__PURE__ */ b("span", { className: "normal-case tracking-normal text-slate-400", children: [
217
217
  "· none picked = ",
218
- y.toLowerCase()
218
+ f.toLowerCase()
219
219
  ] })
220
220
  ] }),
221
- s && /* @__PURE__ */ f("span", { children: [
222
- re,
221
+ s && /* @__PURE__ */ b("span", { children: [
222
+ ae,
223
223
  " ",
224
- /* @__PURE__ */ f("span", { className: "normal-case tracking-normal text-slate-400", children: [
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)) }) : ee.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: ee.map((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
- ), h = new Set(
236
+ ), x = new Set(
237
237
  r.filter((d) => d.value2 !== null).map((d) => d.value2)
238
238
  );
239
- return /* @__PURE__ */ f(
239
+ return /* @__PURE__ */ b(
240
240
  "li",
241
241
  {
242
242
  "data-membership-key": e.key,
243
- className: $(
244
- ae,
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: y,
263
- valueTitle: te,
262
+ emptyLabel: f,
263
+ valueTitle: re,
264
264
  disabled: !!o || k === e.key,
265
- onToggle: (d) => Z(e.key, d),
266
- onClear: () => I(e.key)
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: h,
273
+ picked: x,
274
274
  emptyLabel: w,
275
- valueTitle: re,
275
+ valueTitle: ae,
276
276
  disabled: !!o || k === e.key,
277
- onToggle: (d) => Z(e.key, d, 2),
278
- onClear: () => I(e.key, 2)
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
- z && /* @__PURE__ */ n("p", { className: "text-[12px] text-red-600 dark:text-red-400", children: z })
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: p,
305
+ emptyLabel: u,
306
306
  valueTitle: i,
307
307
  disabled: o,
308
- onToggle: u,
308
+ onToggle: m,
309
309
  onClear: g
310
310
  }) {
311
- const [x, b] = C(!1), [c, s] = C(""), y = l.size === 0;
311
+ const [y, h] = C(!1), [c, s] = C(""), f = l.size === 0;
312
312
  if (a.length <= Ke)
313
- return /* @__PURE__ */ f("div", { className: "flex flex-wrap items-center gap-1", "data-membership-values": !0, children: [
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 || y,
319
- "aria-pressed": y,
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
- y ? "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"
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: p
325
+ children: u
326
326
  }
327
327
  ),
328
- a.map((m) => {
329
- const k = l.has(m.id);
330
- return /* @__PURE__ */ f(
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": m.id,
337
- onClick: () => u(m.id),
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(le, { className: "h-3 w-3" }),
344
- m.label
343
+ k && /* @__PURE__ */ n(O, { className: "h-3 w-3" }),
344
+ p.label
345
345
  ]
346
346
  },
347
- m.id
347
+ p.id
348
348
  );
349
349
  })
350
350
  ] });
351
- const w = c.trim() ? a.filter((m) => de(m.label, c)) : a, S = y ? p : a.filter((m) => l.has(m.id)).map((m) => m.label).join(", ");
352
- return /* @__PURE__ */ f(_e, { open: x, onOpenChange: b, children: [
353
- /* @__PURE__ */ n($e, { asChild: !0, children: /* @__PURE__ */ f(
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: $("truncate", y && "text-slate-500 dark:text-muted-foreground"), children: S }),
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__ */ f(Se, { align: "start", className: "w-[260px] p-1", children: [
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: (m) => s(m.target.value),
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__ */ n("ul", { className: "max-h-[240px] overflow-y-auto", children: w.map((m) => /* @__PURE__ */ n("li", { children: /* @__PURE__ */ f(
376
- "button",
377
- {
378
- type: "button",
379
- onClick: () => u(m.id),
380
- className: "flex w-full items-center gap-2 rounded px-2 py-1 text-left text-[12px] hover:bg-muted",
381
- children: [
382
- /* @__PURE__ */ n(
383
- le,
384
- {
385
- className: $("h-3.5 w-3.5", l.has(m.id) ? "opacity-100" : "opacity-0")
386
- }
387
- ),
388
- m.label
389
- ]
390
- }
391
- ) }, m.id)) })
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
  }