@nivaro/react 0.3.77 → 0.3.78
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,222 +1,293 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import { useQueryClient as
|
|
3
|
-
import { Search as
|
|
4
|
-
import { useState as
|
|
5
|
-
import { useNivaroClient as
|
|
6
|
-
import { get as Q, patch as
|
|
7
|
-
import { userErrorMessage as
|
|
8
|
-
import { matchesAllTokens as
|
|
9
|
-
import { Popover as
|
|
10
|
-
import { applyDisplayTemplate as
|
|
11
|
-
import { RelationCombobox as
|
|
12
|
-
const
|
|
13
|
-
|
|
14
|
-
const
|
|
15
|
-
for (
|
|
16
|
-
const
|
|
17
|
-
|
|
1
|
+
import { jsxs as f, jsx as n } from "react/jsx-runtime";
|
|
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";
|
|
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";
|
|
7
|
+
import { userErrorMessage as Ne } from "../../lib/safe-error.js";
|
|
8
|
+
import { matchesAllTokens as de, titleCase as O, cn as $ } from "../../lib/utils.js";
|
|
9
|
+
import { Popover as _e, PopoverTrigger as $e, PopoverContent as Se } from "../ui/popover.js";
|
|
10
|
+
import { applyDisplayTemplate as qe } from "./helpers.js";
|
|
11
|
+
import { RelationCombobox as Ce } from "./RelationCombobox.js";
|
|
12
|
+
const oe = (a, l) => `${a ?? ""}\0${l ?? ""}`;
|
|
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);
|
|
18
18
|
}
|
|
19
|
-
|
|
19
|
+
const u = [], g = [];
|
|
20
|
+
for (const [x, b] of p) {
|
|
21
|
+
if (i.has(x)) continue;
|
|
22
|
+
const c = o.shift();
|
|
23
|
+
c !== void 0 ? u.push({ id: c, pair: b }) : g.push(b);
|
|
24
|
+
}
|
|
25
|
+
return { repoint: u, create: g, remove: o };
|
|
26
|
+
}
|
|
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]));
|
|
30
|
+
}, Ke = 10;
|
|
31
|
+
async function A(a, l, p) {
|
|
32
|
+
const i = [];
|
|
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;
|
|
36
|
+
}
|
|
37
|
+
return i;
|
|
20
38
|
}
|
|
21
|
-
const
|
|
22
|
-
function
|
|
23
|
-
const p =
|
|
24
|
-
queryKey: ["collection-display-meta",
|
|
25
|
-
queryFn: () => p.request(Q(`/collections/${
|
|
26
|
-
var
|
|
27
|
-
return { display_template: ((
|
|
39
|
+
const Me = (a) => [...(a ?? "").matchAll(/\{\{([\w.]+)\}\}/g)].map((l) => l[1]);
|
|
40
|
+
function P(a, l) {
|
|
41
|
+
const p = ce(), { data: i } = K({
|
|
42
|
+
queryKey: ["collection-display-meta", a],
|
|
43
|
+
queryFn: () => p.request(Q(`/collections/${a}`)).then((c) => {
|
|
44
|
+
var s;
|
|
45
|
+
return { display_template: ((s = c.data) == null ? void 0 : s.display_template) ?? null };
|
|
28
46
|
}),
|
|
29
|
-
enabled: !!
|
|
47
|
+
enabled: !!a,
|
|
30
48
|
staleTime: 10 * 6e4
|
|
31
|
-
}),
|
|
32
|
-
queryKey: ["membership-set-labels",
|
|
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],
|
|
33
51
|
queryFn: async () => {
|
|
34
|
-
const
|
|
35
|
-
if (l === "all") return
|
|
36
|
-
const
|
|
37
|
-
for (let
|
|
38
|
-
|
|
39
|
-
...await
|
|
40
|
-
...
|
|
41
|
-
filter: JSON.stringify({ id: { _in: l.slice(
|
|
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 = [];
|
|
55
|
+
for (let w = 0; w < l.length; w += 150)
|
|
56
|
+
y.push(
|
|
57
|
+
...await A(p, `/items/${a}`, {
|
|
58
|
+
...s,
|
|
59
|
+
filter: JSON.stringify({ id: { _in: l.slice(w, w + 150) } })
|
|
42
60
|
})
|
|
43
61
|
);
|
|
44
|
-
return
|
|
62
|
+
return y;
|
|
45
63
|
},
|
|
46
|
-
enabled: !!
|
|
64
|
+
enabled: !!a && i !== void 0 && (l === "all" || l.length > 0),
|
|
47
65
|
staleTime: 6e4
|
|
48
66
|
});
|
|
49
|
-
return { labels:
|
|
50
|
-
const
|
|
51
|
-
for (const
|
|
52
|
-
const
|
|
53
|
-
|
|
67
|
+
return { labels: _(() => {
|
|
68
|
+
const c = /* @__PURE__ */ new Map();
|
|
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);
|
|
54
72
|
}
|
|
55
|
-
return
|
|
56
|
-
}, [
|
|
73
|
+
return c;
|
|
74
|
+
}, [g, o]), isLoading: x };
|
|
57
75
|
}
|
|
58
|
-
function
|
|
59
|
-
relatedCollection:
|
|
76
|
+
function Je({
|
|
77
|
+
relatedCollection: a,
|
|
60
78
|
manyField: l,
|
|
61
79
|
parentId: p,
|
|
62
|
-
config:
|
|
63
|
-
readOnly:
|
|
80
|
+
config: i,
|
|
81
|
+
readOnly: o
|
|
64
82
|
}) {
|
|
65
|
-
const
|
|
66
|
-
queryKey: ["collection-relations",
|
|
67
|
-
queryFn: () =>
|
|
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({
|
|
84
|
+
queryKey: ["collection-relations", a],
|
|
85
|
+
queryFn: () => u.request(Q(`/collections/${a}`)).then((e) => {
|
|
68
86
|
var r;
|
|
69
87
|
return ((r = e.data) == null ? void 0 : r.relations) ?? [];
|
|
70
88
|
}),
|
|
71
89
|
staleTime: 10 * 6e4
|
|
72
|
-
}),
|
|
90
|
+
}), M = (e) => {
|
|
73
91
|
var r;
|
|
74
|
-
return ((r =
|
|
75
|
-
},
|
|
76
|
-
queryKey:
|
|
77
|
-
queryFn: async () => (await
|
|
78
|
-
fields:
|
|
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(","),
|
|
79
97
|
filter: JSON.stringify({ [l]: { _eq: p } })
|
|
80
|
-
})).filter((e) => e[
|
|
98
|
+
})).filter((e) => e[b] != null).map((e) => ({
|
|
81
99
|
id: e.id,
|
|
82
|
-
key: String(e[
|
|
83
|
-
value: e[
|
|
100
|
+
key: String(e[b]),
|
|
101
|
+
value: e[c] == null ? null : String(e[c]),
|
|
102
|
+
value2: !s || e[s] == null ? null : String(e[s])
|
|
84
103
|
})),
|
|
85
|
-
enabled: !
|
|
104
|
+
enabled: !x,
|
|
86
105
|
staleTime: 15e3
|
|
87
|
-
}),
|
|
106
|
+
}), N = _(() => {
|
|
88
107
|
const e = /* @__PURE__ */ new Map();
|
|
89
|
-
for (const r of
|
|
108
|
+
for (const r of V) e.set(r.key, [...e.get(r.key) ?? [], r]);
|
|
90
109
|
return e;
|
|
91
|
-
}, [
|
|
92
|
-
|
|
93
|
-
[z]
|
|
94
|
-
), re = () => {
|
|
95
|
-
y.invalidateQueries({ queryKey: E }), y.invalidateQueries({ queryKey: ["o2m-rows", t] });
|
|
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] });
|
|
96
112
|
}, j = async (e, r) => {
|
|
97
|
-
|
|
113
|
+
R(e), B(null);
|
|
98
114
|
try {
|
|
99
115
|
await r();
|
|
100
|
-
} catch (
|
|
101
|
-
const
|
|
102
|
-
|
|
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"));
|
|
103
119
|
} finally {
|
|
104
|
-
|
|
120
|
+
R(null), he();
|
|
105
121
|
}
|
|
106
|
-
},
|
|
107
|
-
const
|
|
108
|
-
|
|
109
|
-
a.filter((
|
|
110
|
-
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
}),
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
}
|
|
132
|
-
|
|
122
|
+
}, W = (e) => {
|
|
123
|
+
const r = N.get(e) ?? [];
|
|
124
|
+
return {
|
|
125
|
+
a: new Set(r.filter((t) => t.value !== null).map((t) => t.value)),
|
|
126
|
+
b: new Set(r.filter((t) => t.value2 !== null).map((t) => t.value2))
|
|
127
|
+
};
|
|
128
|
+
}, F = ([e, r]) => ({
|
|
129
|
+
[c]: e,
|
|
130
|
+
...s ? { [s]: r } : {}
|
|
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(
|
|
137
|
+
se(`/items/${a}`, {
|
|
138
|
+
[l]: p,
|
|
139
|
+
[b]: e,
|
|
140
|
+
...F(d)
|
|
141
|
+
})
|
|
142
|
+
);
|
|
143
|
+
for (const d of h.remove) await u.request(ne(`/items/${a}/${d}`));
|
|
144
|
+
}), Y = (e, r) => {
|
|
145
|
+
const t = new Set(e);
|
|
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());
|
|
154
|
+
}, fe = (e) => j(e, async () => {
|
|
155
|
+
for (const r of N.get(e) ?? [])
|
|
156
|
+
await u.request(ne(`/items/${a}/${r.id}`));
|
|
157
|
+
}), xe = (e) => {
|
|
158
|
+
e == null || e === "" || N.has(String(e)) || j(
|
|
133
159
|
String(e),
|
|
134
|
-
() =>
|
|
135
|
-
|
|
160
|
+
() => u.request(
|
|
161
|
+
se(`/items/${a}`, {
|
|
162
|
+
[l]: p,
|
|
163
|
+
[b]: e,
|
|
164
|
+
...F([null, null])
|
|
165
|
+
})
|
|
136
166
|
)
|
|
137
167
|
);
|
|
138
|
-
},
|
|
139
|
-
const e =
|
|
140
|
-
return r ? e.filter((
|
|
141
|
-
}, [
|
|
142
|
-
return
|
|
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();
|
|
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: [
|
|
143
173
|
"Save this record first, then add ",
|
|
144
|
-
|
|
174
|
+
q.toLowerCase(),
|
|
145
175
|
" here."
|
|
146
|
-
] }) : /* @__PURE__ */
|
|
147
|
-
!
|
|
148
|
-
/* @__PURE__ */
|
|
149
|
-
|
|
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: [
|
|
178
|
+
/* @__PURE__ */ n("div", { className: "w-[320px] max-w-full", children: /* @__PURE__ */ n(
|
|
179
|
+
Ce,
|
|
150
180
|
{
|
|
151
|
-
collection:
|
|
181
|
+
collection: L,
|
|
152
182
|
value: null,
|
|
153
|
-
onChange:
|
|
154
|
-
placeholder: `Add ${
|
|
155
|
-
extraFilter:
|
|
183
|
+
onChange: xe,
|
|
184
|
+
placeholder: `Add ${q.toLowerCase()}…`,
|
|
185
|
+
extraFilter: v.length && v.length <= 400 ? { id: { _nin: v } } : void 0
|
|
156
186
|
},
|
|
157
|
-
|
|
187
|
+
v.length
|
|
158
188
|
) }),
|
|
159
|
-
|
|
160
|
-
/* @__PURE__ */
|
|
161
|
-
/* @__PURE__ */
|
|
189
|
+
v.length > 8 && /* @__PURE__ */ f("label", { className: "relative ml-auto block w-[220px] max-w-full", children: [
|
|
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
|
+
/* @__PURE__ */ n(
|
|
162
192
|
"input",
|
|
163
193
|
{
|
|
164
|
-
value:
|
|
165
|
-
onChange: (e) =>
|
|
166
|
-
placeholder: `Filter ${
|
|
167
|
-
"aria-label": `Filter ${
|
|
194
|
+
value: S,
|
|
195
|
+
onChange: (e) => m(e.target.value),
|
|
196
|
+
placeholder: `Filter ${v.length}…`,
|
|
197
|
+
"aria-label": `Filter ${q}`,
|
|
168
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"
|
|
169
199
|
}
|
|
170
200
|
)
|
|
171
201
|
] })
|
|
172
202
|
] }),
|
|
173
|
-
/* @__PURE__ */
|
|
174
|
-
/* @__PURE__ */
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
203
|
+
/* @__PURE__ */ f("div", { className: "overflow-hidden rounded-lg border border-slate-200 dark:border-border", children: [
|
|
204
|
+
/* @__PURE__ */ f(
|
|
205
|
+
"div",
|
|
206
|
+
{
|
|
207
|
+
className: $(
|
|
208
|
+
ae,
|
|
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
|
+
),
|
|
211
|
+
children: [
|
|
212
|
+
/* @__PURE__ */ n("span", { children: q }),
|
|
213
|
+
/* @__PURE__ */ f("span", { children: [
|
|
214
|
+
te,
|
|
215
|
+
" ",
|
|
216
|
+
/* @__PURE__ */ f("span", { className: "normal-case tracking-normal text-slate-400", children: [
|
|
217
|
+
"· none picked = ",
|
|
218
|
+
y.toLowerCase()
|
|
219
|
+
] })
|
|
220
|
+
] }),
|
|
221
|
+
s && /* @__PURE__ */ f("span", { children: [
|
|
222
|
+
re,
|
|
223
|
+
" ",
|
|
224
|
+
/* @__PURE__ */ f("span", { className: "normal-case tracking-normal text-slate-400", children: [
|
|
225
|
+
"· none picked = ",
|
|
226
|
+
w.toLowerCase()
|
|
227
|
+
] })
|
|
228
|
+
] }),
|
|
229
|
+
/* @__PURE__ */ n("span", {})
|
|
230
|
+
]
|
|
231
|
+
}
|
|
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) => {
|
|
234
|
+
const r = N.get(e.key) ?? [], t = new Set(
|
|
235
|
+
r.filter((d) => d.value !== null).map((d) => d.value)
|
|
236
|
+
), h = new Set(
|
|
237
|
+
r.filter((d) => d.value2 !== null).map((d) => d.value2)
|
|
238
|
+
);
|
|
239
|
+
return /* @__PURE__ */ f(
|
|
189
240
|
"li",
|
|
190
241
|
{
|
|
191
242
|
"data-membership-key": e.key,
|
|
192
|
-
className:
|
|
193
|
-
|
|
194
|
-
|
|
243
|
+
className: $(
|
|
244
|
+
ae,
|
|
245
|
+
"grid items-center gap-3 px-3 py-1.5 text-[12px]",
|
|
246
|
+
k === e.key && "opacity-60"
|
|
195
247
|
),
|
|
196
248
|
children: [
|
|
197
|
-
/* @__PURE__ */
|
|
198
|
-
|
|
199
|
-
|
|
249
|
+
/* @__PURE__ */ n(
|
|
250
|
+
"span",
|
|
251
|
+
{
|
|
252
|
+
className: "truncate font-medium text-slate-800 dark:text-foreground",
|
|
253
|
+
"data-tip": e.label,
|
|
254
|
+
children: e.label
|
|
255
|
+
}
|
|
256
|
+
),
|
|
257
|
+
/* @__PURE__ */ n(
|
|
258
|
+
ie,
|
|
200
259
|
{
|
|
201
|
-
options:
|
|
202
|
-
picked:
|
|
203
|
-
emptyLabel:
|
|
204
|
-
valueTitle:
|
|
205
|
-
disabled: !!
|
|
206
|
-
onToggle: (d) =>
|
|
207
|
-
onClear: () =>
|
|
260
|
+
options: pe,
|
|
261
|
+
picked: t,
|
|
262
|
+
emptyLabel: y,
|
|
263
|
+
valueTitle: te,
|
|
264
|
+
disabled: !!o || k === e.key,
|
|
265
|
+
onToggle: (d) => Z(e.key, d),
|
|
266
|
+
onClear: () => I(e.key)
|
|
208
267
|
}
|
|
209
268
|
),
|
|
210
|
-
|
|
269
|
+
s && /* @__PURE__ */ n(
|
|
270
|
+
ie,
|
|
271
|
+
{
|
|
272
|
+
options: be,
|
|
273
|
+
picked: h,
|
|
274
|
+
emptyLabel: w,
|
|
275
|
+
valueTitle: re,
|
|
276
|
+
disabled: !!o || k === e.key,
|
|
277
|
+
onToggle: (d) => Z(e.key, d, 2),
|
|
278
|
+
onClear: () => I(e.key, 2)
|
|
279
|
+
}
|
|
280
|
+
),
|
|
281
|
+
o ? /* @__PURE__ */ n("span", {}) : /* @__PURE__ */ n(
|
|
211
282
|
"button",
|
|
212
283
|
{
|
|
213
284
|
type: "button",
|
|
214
|
-
onClick: () =>
|
|
215
|
-
disabled:
|
|
285
|
+
onClick: () => fe(e.key),
|
|
286
|
+
disabled: k === e.key,
|
|
216
287
|
"aria-label": `Remove ${e.label}`,
|
|
217
288
|
"data-tip": "Remove",
|
|
218
289
|
className: "flex h-6 w-6 items-center justify-center rounded text-slate-400 hover:bg-red-50 hover:text-red-600 dark:hover:bg-red-500/10",
|
|
219
|
-
children: /* @__PURE__ */
|
|
290
|
+
children: /* @__PURE__ */ n(ve, { className: "h-3.5 w-3.5" })
|
|
220
291
|
}
|
|
221
292
|
)
|
|
222
293
|
]
|
|
@@ -225,97 +296,103 @@ function Te({
|
|
|
225
296
|
);
|
|
226
297
|
}) })
|
|
227
298
|
] }),
|
|
228
|
-
|
|
299
|
+
z && /* @__PURE__ */ n("p", { className: "text-[12px] text-red-600 dark:text-red-400", children: z })
|
|
229
300
|
] });
|
|
230
301
|
}
|
|
231
|
-
function
|
|
232
|
-
options:
|
|
302
|
+
function ie({
|
|
303
|
+
options: a,
|
|
233
304
|
picked: l,
|
|
234
305
|
emptyLabel: p,
|
|
235
|
-
valueTitle:
|
|
236
|
-
disabled:
|
|
237
|
-
onToggle:
|
|
238
|
-
onClear:
|
|
306
|
+
valueTitle: i,
|
|
307
|
+
disabled: o,
|
|
308
|
+
onToggle: u,
|
|
309
|
+
onClear: g
|
|
239
310
|
}) {
|
|
240
|
-
const [
|
|
241
|
-
if (
|
|
242
|
-
return /* @__PURE__ */
|
|
243
|
-
/* @__PURE__ */
|
|
311
|
+
const [x, b] = C(!1), [c, s] = C(""), y = l.size === 0;
|
|
312
|
+
if (a.length <= Ke)
|
|
313
|
+
return /* @__PURE__ */ f("div", { className: "flex flex-wrap items-center gap-1", "data-membership-values": !0, children: [
|
|
314
|
+
/* @__PURE__ */ n(
|
|
244
315
|
"button",
|
|
245
316
|
{
|
|
246
317
|
type: "button",
|
|
247
|
-
disabled:
|
|
248
|
-
"aria-pressed":
|
|
249
|
-
onClick:
|
|
250
|
-
className:
|
|
318
|
+
disabled: o || y,
|
|
319
|
+
"aria-pressed": y,
|
|
320
|
+
onClick: g,
|
|
321
|
+
className: $(
|
|
251
322
|
"h-6 rounded-full border px-2 text-[11px] transition-colors",
|
|
252
|
-
|
|
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"
|
|
253
324
|
),
|
|
254
325
|
children: p
|
|
255
326
|
}
|
|
256
327
|
),
|
|
257
|
-
|
|
258
|
-
const
|
|
259
|
-
return /* @__PURE__ */
|
|
328
|
+
a.map((m) => {
|
|
329
|
+
const k = l.has(m.id);
|
|
330
|
+
return /* @__PURE__ */ f(
|
|
260
331
|
"button",
|
|
261
332
|
{
|
|
262
333
|
type: "button",
|
|
263
|
-
disabled:
|
|
264
|
-
"aria-pressed":
|
|
265
|
-
"data-membership-value":
|
|
266
|
-
onClick: () =>
|
|
267
|
-
className:
|
|
334
|
+
disabled: o,
|
|
335
|
+
"aria-pressed": k,
|
|
336
|
+
"data-membership-value": m.id,
|
|
337
|
+
onClick: () => u(m.id),
|
|
338
|
+
className: $(
|
|
268
339
|
"inline-flex h-6 items-center gap-1 rounded-full border px-2 text-[11px] transition-colors",
|
|
269
|
-
|
|
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"
|
|
270
341
|
),
|
|
271
342
|
children: [
|
|
272
|
-
|
|
273
|
-
|
|
343
|
+
k && /* @__PURE__ */ n(le, { className: "h-3 w-3" }),
|
|
344
|
+
m.label
|
|
274
345
|
]
|
|
275
346
|
},
|
|
276
|
-
|
|
347
|
+
m.id
|
|
277
348
|
);
|
|
278
349
|
})
|
|
279
350
|
] });
|
|
280
|
-
const
|
|
281
|
-
return /* @__PURE__ */
|
|
282
|
-
/* @__PURE__ */
|
|
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(
|
|
283
354
|
"button",
|
|
284
355
|
{
|
|
285
356
|
type: "button",
|
|
286
|
-
disabled:
|
|
357
|
+
disabled: o,
|
|
287
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",
|
|
288
359
|
children: [
|
|
289
|
-
/* @__PURE__ */
|
|
290
|
-
/* @__PURE__ */
|
|
360
|
+
/* @__PURE__ */ n("span", { className: $("truncate", y && "text-slate-500 dark:text-muted-foreground"), children: S }),
|
|
361
|
+
/* @__PURE__ */ n(we, { className: "h-3.5 w-3.5 shrink-0 text-slate-400" })
|
|
291
362
|
]
|
|
292
363
|
}
|
|
293
364
|
) }),
|
|
294
|
-
/* @__PURE__ */
|
|
295
|
-
/* @__PURE__ */
|
|
365
|
+
/* @__PURE__ */ f(Se, { align: "start", className: "w-[260px] p-1", children: [
|
|
366
|
+
/* @__PURE__ */ n(
|
|
296
367
|
"input",
|
|
297
368
|
{
|
|
298
|
-
value:
|
|
299
|
-
onChange: (
|
|
300
|
-
placeholder: `Search ${
|
|
369
|
+
value: c,
|
|
370
|
+
onChange: (m) => s(m.target.value),
|
|
371
|
+
placeholder: `Search ${i.toLowerCase()}…`,
|
|
301
372
|
className: "mb-1 h-7 w-full rounded border border-slate-200 bg-background px-2 text-[12px] outline-none dark:border-border"
|
|
302
373
|
}
|
|
303
374
|
),
|
|
304
|
-
/* @__PURE__ */
|
|
375
|
+
/* @__PURE__ */ n("ul", { className: "max-h-[240px] overflow-y-auto", children: w.map((m) => /* @__PURE__ */ n("li", { children: /* @__PURE__ */ f(
|
|
305
376
|
"button",
|
|
306
377
|
{
|
|
307
378
|
type: "button",
|
|
308
|
-
onClick: () =>
|
|
379
|
+
onClick: () => u(m.id),
|
|
309
380
|
className: "flex w-full items-center gap-2 rounded px-2 py-1 text-left text-[12px] hover:bg-muted",
|
|
310
381
|
children: [
|
|
311
|
-
/* @__PURE__ */
|
|
312
|
-
|
|
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
|
|
313
389
|
]
|
|
314
390
|
}
|
|
315
|
-
) },
|
|
391
|
+
) }, m.id)) })
|
|
316
392
|
] })
|
|
317
393
|
] });
|
|
318
394
|
}
|
|
319
395
|
export {
|
|
320
|
-
|
|
396
|
+
Je as MembershipSetField,
|
|
397
|
+
Le as planMembershipRows
|
|
321
398
|
};
|