@nivaro/react 0.3.117 → 0.3.118

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.
Files changed (137) hide show
  1. package/dist/full.css +1 -1
  2. package/dist/hooks/useSessionRecorder.js +1 -1
  3. package/dist/index.d.ts +136 -14
  4. package/dist/index.js +488 -485
  5. package/dist/shared/components/ActivityEntry.js +130 -125
  6. package/dist/shared/components/AgentPresenceChip.js +36 -26
  7. package/dist/shared/components/CellCopyLayer.js +50 -45
  8. package/dist/shared/components/CollectionBrowserView.js +3757 -3695
  9. package/dist/shared/components/FilePreviewLightbox.js +96 -58
  10. package/dist/shared/components/InStep.js +18 -17
  11. package/dist/shared/components/ItemEditForm.js +4220 -4175
  12. package/dist/shared/components/JobsTray.js +8 -8
  13. package/dist/shared/components/LiveNewMatchesPill.js +21 -14
  14. package/dist/shared/components/LiveOffNote.js +3 -2
  15. package/dist/shared/components/LiveRowMark.js +53 -23
  16. package/dist/shared/components/LiveTraceView.js +162 -123
  17. package/dist/shared/components/MyWorkView.js +320 -299
  18. package/dist/shared/components/NotificationBell.js +14 -14
  19. package/dist/shared/components/OverflowRail.js +1 -1
  20. package/dist/shared/components/PageRenderer.js +120 -116
  21. package/dist/shared/components/ProfileView.js +203 -202
  22. package/dist/shared/components/RealtimeStatusBanner.js +31 -29
  23. package/dist/shared/components/RecordDrilldownSheet.js +7 -7
  24. package/dist/shared/components/RecordHoverCard.js +102 -84
  25. package/dist/shared/components/RecordReadView.js +146 -146
  26. package/dist/shared/components/ScreenRefreshButton.js +34 -32
  27. package/dist/shared/components/TipLayer.js +65 -58
  28. package/dist/shared/components/WidgetImageMenu.js +83 -43
  29. package/dist/shared/components/activity/RecordActivityStream.js +175 -173
  30. package/dist/shared/components/bulk/BulkSelectionNotices.js +142 -119
  31. package/dist/shared/components/change-proposals/ChangeProposalsPanel.js +158 -143
  32. package/dist/shared/components/change-proposals/ProposeChangeButton.js +17 -11
  33. package/dist/shared/components/change-proposals/ProposeChangeDialog.js +201 -173
  34. package/dist/shared/components/chat/ChatAnalyticsView.js +27 -27
  35. package/dist/shared/components/chat/HuddleAnalyticsTab.js +17 -17
  36. package/dist/shared/components/collections-directory/CollectionsToolbar.js +39 -41
  37. package/dist/shared/components/collections-directory/page-model.js +72 -67
  38. package/dist/shared/components/integrations/RecordIntegrationPreview.js +48 -56
  39. package/dist/shared/components/integrations/SendStatus.js +65 -59
  40. package/dist/shared/components/integrations/console/ReadyToSendView.js +275 -209
  41. package/dist/shared/components/integrations/console/SignalCard.js +237 -230
  42. package/dist/shared/components/item-edit/CatalogPickerField.js +227 -205
  43. package/dist/shared/components/item-edit/ChangedAfterApprovalBadge.js +131 -92
  44. package/dist/shared/components/item-edit/CloneDialog.js +191 -161
  45. package/dist/shared/components/item-edit/DerivedCauseNote.js +44 -30
  46. package/dist/shared/components/item-edit/DraftRecoveryBanner.js +153 -134
  47. package/dist/shared/components/item-edit/FieldComments.js +54 -53
  48. package/dist/shared/components/item-edit/FieldPointer.js +82 -67
  49. package/dist/shared/components/item-edit/FieldRow.js +106 -100
  50. package/dist/shared/components/item-edit/FieldSourceBadge.js +58 -56
  51. package/dist/shared/components/item-edit/FilePickerField.js +452 -387
  52. package/dist/shared/components/item-edit/HeaderSummaryChip.js +78 -56
  53. package/dist/shared/components/item-edit/HeaderTools.js +94 -85
  54. package/dist/shared/components/item-edit/InlineTableField.js +1242 -1218
  55. package/dist/shared/components/item-edit/ListNeighborNav.js +47 -50
  56. package/dist/shared/components/item-edit/LiveTraceSheet.js +15 -10
  57. package/dist/shared/components/item-edit/MembershipSetField.js +285 -254
  58. package/dist/shared/components/item-edit/OutboxReviewTray.js +155 -144
  59. package/dist/shared/components/item-edit/QueueReturnChip.js +15 -36
  60. package/dist/shared/components/item-edit/RecalcValue.js +57 -32
  61. package/dist/shared/components/item-edit/RecordHelpChip.js +21 -22
  62. package/dist/shared/components/item-edit/RecordLiveSync.js +283 -231
  63. package/dist/shared/components/item-edit/RelationCombobox.js +439 -393
  64. package/dist/shared/components/item-edit/RemoteChangeUi.js +292 -224
  65. package/dist/shared/components/item-edit/RemoteUploads.js +26 -20
  66. package/dist/shared/components/item-edit/RemovedLineNote.js +77 -67
  67. package/dist/shared/components/item-edit/RichTextEditorImpl.js +184 -179
  68. package/dist/shared/components/item-edit/ScheduledChangeChip.js +168 -134
  69. package/dist/shared/components/item-edit/SectionPresence.js +18 -10
  70. package/dist/shared/components/item-edit/SplitLinesButton.js +163 -139
  71. package/dist/shared/components/item-edit/UserChip.js +1 -1
  72. package/dist/shared/components/item-edit/file-live.js +69 -54
  73. package/dist/shared/components/item-edit/layout-switch.js +98 -89
  74. package/dist/shared/components/item-edit/partner-needs.js +12 -12
  75. package/dist/shared/components/item-edit/removed-line.js +31 -25
  76. package/dist/shared/components/layout-editor/pickers/field-picker.js +112 -104
  77. package/dist/shared/components/list/ListViewers.js +46 -35
  78. package/dist/shared/components/notifications/NotificationCenterView.js +479 -437
  79. package/dist/shared/components/panels/AccessDeniedPanel.js +176 -101
  80. package/dist/shared/components/panels/AlertBanners.js +82 -72
  81. package/dist/shared/components/panels/BranchLanes.js +22 -22
  82. package/dist/shared/components/panels/CommentImages.js +123 -102
  83. package/dist/shared/components/panels/CommentPanel.js +186 -185
  84. package/dist/shared/components/panels/ExternalRequestsChip.js +111 -119
  85. package/dist/shared/components/panels/OwnerOpenedLine.js +31 -24
  86. package/dist/shared/components/panels/PipelinePanel.js +2037 -1885
  87. package/dist/shared/components/panels/ResubmissionDiff.js +163 -142
  88. package/dist/shared/components/pipeline/OwnerMatrixSheet.js +400 -288
  89. package/dist/shared/components/pipeline/PipelineEditorView.js +7 -2
  90. package/dist/shared/components/profile/AgentNameField.js +107 -81
  91. package/dist/shared/components/profile/AgentsPanel.js +184 -184
  92. package/dist/shared/components/profile/PersonAccess.js +599 -495
  93. package/dist/shared/components/profile/SignInTroubleshooter.js +160 -127
  94. package/dist/shared/components/profile/SignedInDevices.js +17 -17
  95. package/dist/shared/components/profile/primitives.js +1 -1
  96. package/dist/shared/components/queue/OwnerAvatars.js +91 -54
  97. package/dist/shared/components/queue/QueueTeamStrip.js +56 -46
  98. package/dist/shared/components/queue/QueueWorklist.js +1002 -983
  99. package/dist/shared/components/support/AssignRules.js +1733 -0
  100. package/dist/shared/components/support/PersonPick.js +88 -0
  101. package/dist/shared/components/support/RequestList.js +790 -0
  102. package/dist/shared/components/support/ScreenShare.js +158 -152
  103. package/dist/shared/components/support/SupportRequestDialog.js +50 -48
  104. package/dist/shared/components/support/SupportView.js +140 -246
  105. package/dist/shared/components/support/TicketDetailSheet.js +82 -75
  106. package/dist/shared/components/support/TicketSlowScreens.js +9 -9
  107. package/dist/shared/components/support/assign-rules-text.js +171 -0
  108. package/dist/shared/components/support/support-list.js +125 -0
  109. package/dist/shared/components/ui/SimpleSelect.js +28 -20
  110. package/dist/shared/components/ui/checkbox.js +6 -6
  111. package/dist/shared/components/ui/select.js +43 -39
  112. package/dist/shared/components/ui/sheet.js +9 -9
  113. package/dist/shared/components/ui/switch.js +12 -11
  114. package/dist/shared/components/watch-list/WatchDock.js +532 -459
  115. package/dist/shared/components/watch-list/WatchExtras.js +332 -286
  116. package/dist/shared/components/watch-list/WatchRows.js +164 -140
  117. package/dist/shared/lib/activity-sentence.js +103 -91
  118. package/dist/shared/lib/agent-presence.js +27 -21
  119. package/dist/shared/lib/approval-progress.js +2 -2
  120. package/dist/shared/lib/copy-rules.js +31 -24
  121. package/dist/shared/lib/derived-causes.js +113 -78
  122. package/dist/shared/lib/grid-cursors.js +26 -26
  123. package/dist/shared/lib/label-flash.js +27 -0
  124. package/dist/shared/lib/list-return.js +137 -125
  125. package/dist/shared/lib/live-deltas.js +40 -34
  126. package/dist/shared/lib/live-groups.js +56 -52
  127. package/dist/shared/lib/live-preference.js +64 -59
  128. package/dist/shared/lib/live-screen.js +223 -192
  129. package/dist/shared/lib/partner-failure.js +11 -11
  130. package/dist/shared/lib/rollup-recalc.js +68 -64
  131. package/dist/shared/lib/screen-refresh.js +74 -68
  132. package/dist/shared/lib/screen-share.js +108 -104
  133. package/dist/shared/lib/send-status.js +77 -61
  134. package/dist/shared/lib/text-diff-window.js +29 -0
  135. package/dist/shared/lib/watch-list.js +210 -209
  136. package/dist/shared/lib/widget-image-render.js +72 -49
  137. package/package.json +1 -1
@@ -1,223 +1,246 @@
1
- import { jsxs as b, jsx as s } from "react/jsx-runtime";
2
- import { useQueryClient as ye, useQuery as T } from "@tanstack/react-query";
3
- import { Search as ge, X as ve, Check as R, ChevronsUpDown as we } from "lucide-react";
4
- import { useState as q, useMemo as S } from "react";
5
- import { useNivaroClient as ie } from "../../context.js";
6
- import { get as ke, patch as Ne, post as le, del as se } from "../../lib/commands.js";
7
- import { fetchCollectionRelations as Ce, queryKeys as ce, fetchCollectionMeta as Se } from "../../lib/query-keys.js";
8
- import { userErrorMessage as _e } from "../../lib/safe-error.js";
9
- import { matchesAllTokens as de, titleCase as O, cn as C } from "../../lib/utils.js";
10
- import { Popover as $e, PopoverTrigger as qe, PopoverContent as Le } from "../ui/popover.js";
11
- import { applyDisplayTemplate as Ke } from "./helpers.js";
12
- import { RelationCombobox as Te } from "./RelationCombobox.js";
13
- const ne = (r, l) => `${r ?? ""}\0${l ?? ""}`;
14
- function Me(r, l) {
15
- const u = new Map(l.map((y) => [ne(y[0], y[1]), y])), c = /* @__PURE__ */ new Set(), o = [];
16
- for (const y of r) {
17
- const h = ne(y.value, y.value2);
18
- u.has(h) && !c.has(h) ? c.add(h) : o.push(y.id);
1
+ import { jsxs as h, jsx as s } from "react/jsx-runtime";
2
+ import { useQueryClient as Ne, useQuery as M } from "@tanstack/react-query";
3
+ import { Search as Se, X as Ce, Check as O, ChevronsUpDown as $e } from "lucide-react";
4
+ import { useState as $, useRef as qe, useMemo as C, useEffect as _e } from "react";
5
+ import { useNivaroClient as pe } from "../../context.js";
6
+ import { get as Ke, patch as Te, post as ce, del as de } from "../../lib/commands.js";
7
+ import { fetchCollectionRelations as Le, queryKeys as be, fetchCollectionMeta as Me } from "../../lib/query-keys.js";
8
+ import { userErrorMessage as Fe } from "../../lib/safe-error.js";
9
+ import { matchesAllTokens as he, titleCase as P, cn as S } from "../../lib/utils.js";
10
+ import { Popover as Re, PopoverTrigger as je, PopoverContent as Ae } from "../ui/popover.js";
11
+ import { applyDisplayTemplate as Oe } from "./helpers.js";
12
+ import { RelationCombobox as Pe } from "./RelationCombobox.js";
13
+ const ue = (a, l) => `${a ?? ""}\0${l ?? ""}`;
14
+ function Qe(a, l) {
15
+ const m = new Map(l.map((x) => [ue(x[0], x[1]), x])), d = /* @__PURE__ */ new Set(), o = [];
16
+ for (const x of a) {
17
+ const f = ue(x.value, x.value2);
18
+ m.has(f) && !d.has(f) ? d.add(f) : o.push(x.id);
19
19
  }
20
- const m = [], g = [];
21
- for (const [y, h] of u) {
22
- if (c.has(y)) continue;
20
+ const p = [], g = [];
21
+ for (const [x, f] of m) {
22
+ if (d.has(x)) continue;
23
23
  const i = o.shift();
24
- i !== void 0 ? m.push({ id: i, pair: h }) : g.push(h);
24
+ i !== void 0 ? p.push({ id: i, pair: f }) : g.push(f);
25
25
  }
26
- return { repoint: m, create: g, remove: o };
26
+ return { repoint: p, create: g, remove: o };
27
27
  }
28
- const je = (r, l) => {
29
- const u = r.size ? [...r] : [null], c = l.size ? [...l] : [null];
30
- return u.flatMap((o) => c.map((m) => [o, m]));
31
- }, Fe = 10;
32
- async function A(r, l, u) {
33
- const c = [];
28
+ const ze = (a, l) => {
29
+ const m = a.size ? [...a] : [null], d = l.size ? [...l] : [null];
30
+ return m.flatMap((o) => d.map((p) => [o, p]));
31
+ }, De = 10;
32
+ async function z(a, l, m) {
33
+ const d = [];
34
34
  for (let o = 1; o <= 50; o++) {
35
- const m = await r.request(ke(l, { ...u, limit: 1e3, page: o })).then((g) => g.data ?? []);
36
- if (c.push(...m), m.length < 1e3) break;
35
+ const p = await a.request(Ke(l, { ...m, limit: 1e3, page: o })).then((g) => g.data ?? []);
36
+ if (d.push(...p), p.length < 1e3) break;
37
37
  }
38
- return c;
38
+ return d;
39
39
  }
40
- const Re = (r) => [...(r ?? "").matchAll(/\{\{([\w.]+)\}\}/g)].map((l) => l[1]);
41
- function P(r, l) {
42
- const u = ie(), { data: c } = T({
43
- queryKey: ce.collectionDisplayMeta(r),
44
- queryFn: () => Se(u, r),
40
+ const Ee = (a) => [...(a ?? "").matchAll(/\{\{([\w.]+)\}\}/g)].map((l) => l[1]);
41
+ function Q(a, l) {
42
+ const m = pe(), { data: d } = M({
43
+ queryKey: be.collectionDisplayMeta(a),
44
+ queryFn: () => Me(m, a),
45
45
  select: (i) => (i == null ? void 0 : i.display_template) ?? null,
46
- enabled: !!r,
46
+ enabled: !!a,
47
47
  staleTime: 10 * 6e4
48
- }), o = c ?? null, m = l === "all" ? "all" : [...l].sort().join(","), { data: g = [], isLoading: y } = T({
49
- queryKey: ["membership-set-labels", r, o, m],
48
+ }), o = d ?? null, p = l === "all" ? "all" : [...l].sort().join(","), { data: g = [], isLoading: x } = M({
49
+ queryKey: ["membership-set-labels", a, o, p],
50
50
  queryFn: async () => {
51
- const i = Re(o), n = i.length ? { fields: ["id", ...i].join(",") } : {};
52
- if (l === "all") return A(u, `/items/${r}`, n);
53
- const f = [];
51
+ const i = Ee(o), n = i.length ? { fields: ["id", ...i].join(",") } : {};
52
+ if (l === "all") return z(m, `/items/${a}`, n);
53
+ const y = [];
54
54
  for (let w = 0; w < l.length; w += 150)
55
- f.push(
56
- ...await A(u, `/items/${r}`, {
55
+ y.push(
56
+ ...await z(m, `/items/${a}`, {
57
57
  ...n,
58
58
  filter: JSON.stringify({ id: { _in: l.slice(w, w + 150) } })
59
59
  })
60
60
  );
61
- return f;
61
+ return y;
62
62
  },
63
- enabled: !!r && c !== void 0 && (l === "all" || l.length > 0),
63
+ enabled: !!a && d !== void 0 && (l === "all" || l.length > 0),
64
64
  staleTime: 6e4
65
65
  });
66
- return { labels: S(() => {
66
+ return { labels: C(() => {
67
67
  const i = /* @__PURE__ */ new Map();
68
68
  for (const n of g) {
69
- const f = String(n.name ?? n.title ?? n.label ?? `#${n.id}`);
70
- i.set(String(n.id), (o ? Ke(o, n) : "").trim() || f);
69
+ const y = String(n.name ?? n.title ?? n.label ?? `#${n.id}`);
70
+ i.set(String(n.id), (o ? Oe(o, n) : "").trim() || y);
71
71
  }
72
72
  return i;
73
- }, [g, o]), isLoading: y };
73
+ }, [g, o]), isLoading: x };
74
74
  }
75
- function Xe({
76
- relatedCollection: r,
75
+ function tt({
76
+ relatedCollection: a,
77
77
  manyField: l,
78
- parentId: u,
79
- config: c,
78
+ parentId: m,
79
+ config: d,
80
80
  readOnly: o
81
81
  }) {
82
- const m = ie(), g = ye(), y = u === "new", { key_field: h, value_field: i } = c, n = c.value_field_2 || null, f = c.empty_label ?? "All", w = c.empty_label_2 ?? f, [_, p] = q(""), [k, Q] = q(null), [z, D] = q(null), { data: ue = [] } = T({
83
- queryKey: ce.collectionRelations(r),
84
- queryFn: () => Ce(m, r),
82
+ const p = pe(), g = Ne(), x = m === "new", { key_field: f, value_field: i } = d, n = d.value_field_2 || null, y = d.empty_label ?? "All", w = d.empty_label_2 ?? y, [q, u] = $(""), [k, D] = $(null), E = qe(null), [K, V] = $(null), [B, J] = $(null), { data: fe = [] } = M({
83
+ queryKey: be.collectionRelations(a),
84
+ queryFn: () => Le(p, a),
85
85
  staleTime: 10 * 6e4
86
- }), M = (e) => {
87
- var a;
88
- return ((a = ue.find((t) => t.many_collection === r && t.many_field === e)) == null ? void 0 : a.one_collection) ?? null;
89
- }, L = M(h), B = M(i), E = n ? M(n) : null, J = ["membership-set-rows", r, l, String(u)], { data: V = [], isLoading: me } = T({
90
- queryKey: J,
91
- queryFn: async () => (await A(m, `/items/${r}`, {
92
- fields: ["id", h, i, ...n ? [n] : []].join(","),
93
- filter: JSON.stringify({ [l]: { _eq: u } })
94
- })).filter((e) => e[h] != null).map((e) => ({
86
+ }), F = (e) => {
87
+ var r;
88
+ return ((r = fe.find((t) => t.many_collection === a && t.many_field === e)) == null ? void 0 : r.one_collection) ?? null;
89
+ }, T = F(f), H = F(i), U = n ? F(n) : null, X = ["membership-set-rows", a, l, String(m)], { data: G = [], isLoading: ye } = M({
90
+ queryKey: X,
91
+ queryFn: async () => (await z(p, `/items/${a}`, {
92
+ fields: ["id", f, i, ...n ? [n] : []].join(","),
93
+ filter: JSON.stringify({ [l]: { _eq: m } })
94
+ })).filter((e) => e[f] != null).map((e) => ({
95
95
  id: e.id,
96
- key: String(e[h]),
96
+ key: String(e[f]),
97
97
  value: e[i] == null ? null : String(e[i]),
98
98
  value2: !n || e[n] == null ? null : String(e[n])
99
99
  })),
100
- enabled: !y,
100
+ enabled: !x,
101
101
  staleTime: 15e3
102
- }), N = S(() => {
102
+ }), N = C(() => {
103
103
  const e = /* @__PURE__ */ new Map();
104
- for (const a of V) e.set(a.key, [...e.get(a.key) ?? [], a]);
104
+ for (const r of G) e.set(r.key, [...e.get(r.key) ?? [], r]);
105
105
  return e;
106
- }, [V]), v = S(() => [...N.keys()], [N]), { labels: H } = P(L, v), { labels: U } = P(B, "all"), { labels: X } = P(E, "all"), G = (e) => [...e.entries()].map(([a, t]) => ({ id: a, label: t })).sort((a, t) => a.label.localeCompare(t.label, void 0, { numeric: !0 })), pe = S(() => G(U), [U]), be = S(() => G(X), [X]), he = () => {
107
- g.invalidateQueries({ queryKey: J }), g.invalidateQueries({ queryKey: ["o2m-rows", r] });
108
- }, j = async (e, a) => {
109
- Q(e), D(null);
106
+ }, [G]), v = C(() => [...N.keys()], [N]), { labels: R } = Q(T, v), { labels: I } = Q(H, "all"), { labels: W } = Q(U, "all"), Y = (e) => [...e.entries()].map(([r, t]) => ({ id: r, label: t })).sort((r, t) => r.label.localeCompare(t.label, void 0, { numeric: !0 })), xe = C(() => Y(I), [I]), ge = C(() => Y(W), [W]), ve = () => {
107
+ g.invalidateQueries({ queryKey: X }), g.invalidateQueries({ queryKey: ["o2m-rows", a] });
108
+ }, j = async (e, r) => {
109
+ V(e), J(null);
110
110
  try {
111
- await a();
111
+ await r();
112
112
  } catch (t) {
113
- const x = t == null ? void 0 : t.response;
114
- D((x == null ? void 0 : x.error) ?? _e(t, "Could not save"));
113
+ const b = t == null ? void 0 : t.response;
114
+ J((b == null ? void 0 : b.error) ?? Fe(t, "Could not save"));
115
115
  } finally {
116
- Q(null), he();
116
+ V(null), ve();
117
117
  }
118
- }, W = (e) => {
119
- const a = N.get(e) ?? [];
118
+ }, Z = (e) => {
119
+ const r = N.get(e) ?? [];
120
120
  return {
121
- a: new Set(a.filter((t) => t.value !== null).map((t) => t.value)),
122
- b: new Set(a.filter((t) => t.value2 !== null).map((t) => t.value2))
121
+ a: new Set(r.filter((t) => t.value !== null).map((t) => t.value)),
122
+ b: new Set(r.filter((t) => t.value2 !== null).map((t) => t.value2))
123
123
  };
124
- }, F = ([e, a]) => ({
124
+ }, A = ([e, r]) => ({
125
125
  [i]: e,
126
- ...n ? { [n]: a } : {}
127
- }), K = (e, a, t) => j(e, async () => {
128
- const x = Me(N.get(e) ?? [], je(a, t));
129
- for (const d of x.repoint)
130
- await m.request(Ne(`/items/${r}/${d.id}`, F(d.pair)));
131
- for (const d of x.create)
132
- await m.request(
133
- le(`/items/${r}`, {
134
- [l]: u,
135
- [h]: e,
136
- ...F(d)
126
+ ...n ? { [n]: r } : {}
127
+ }), L = (e, r, t) => j(e, async () => {
128
+ const b = Qe(N.get(e) ?? [], ze(r, t));
129
+ for (const c of b.repoint)
130
+ await p.request(Te(`/items/${a}/${c.id}`, A(c.pair)));
131
+ for (const c of b.create)
132
+ await p.request(
133
+ ce(`/items/${a}`, {
134
+ [l]: m,
135
+ [f]: e,
136
+ ...A(c)
137
137
  })
138
138
  );
139
- for (const d of x.remove) await m.request(se(`/items/${r}/${d}`));
140
- }), Y = (e, a) => {
139
+ for (const c of b.remove) await p.request(de(`/items/${a}/${c}`));
140
+ }), ee = (e, r) => {
141
141
  const t = new Set(e);
142
- return t.has(a) ? t.delete(a) : t.add(a), t;
143
- }, Z = (e, a, t = 1) => {
144
- const { a: x, b: d } = W(e);
145
- return t === 1 ? K(e, Y(x, a), d) : K(e, x, Y(d, a));
146
- }, I = (e, a = 1) => {
147
- const { a: t, b: x } = W(e);
148
- if ((a === 1 ? t : x).size !== 0)
149
- return a === 1 ? K(e, /* @__PURE__ */ new Set(), x) : K(e, t, /* @__PURE__ */ new Set());
150
- }, fe = (e) => j(e, async () => {
151
- for (const a of N.get(e) ?? [])
152
- await m.request(se(`/items/${r}/${a.id}`));
153
- }), xe = (e) => {
142
+ return t.has(r) ? t.delete(r) : t.add(r), t;
143
+ }, te = (e, r, t = 1) => {
144
+ const { a: b, b: c } = Z(e);
145
+ return t === 1 ? L(e, ee(b, r), c) : L(e, b, ee(c, r));
146
+ }, re = (e, r = 1) => {
147
+ const { a: t, b } = Z(e);
148
+ if ((r === 1 ? t : b).size !== 0)
149
+ return r === 1 ? L(e, /* @__PURE__ */ new Set(), b) : L(e, t, /* @__PURE__ */ new Set());
150
+ }, we = (e) => j(e, async () => {
151
+ for (const r of N.get(e) ?? [])
152
+ await p.request(de(`/items/${a}/${r.id}`));
153
+ }), ke = (e) => {
154
154
  e == null || e === "" || N.has(String(e)) || j(
155
155
  String(e),
156
- () => m.request(
157
- le(`/items/${r}`, {
158
- [l]: u,
159
- [h]: e,
160
- ...F([null, null])
156
+ () => p.request(
157
+ ce(`/items/${a}`, {
158
+ [l]: m,
159
+ [f]: e,
160
+ ...A([null, null])
161
161
  })
162
162
  )
163
163
  );
164
- }, ee = S(() => {
165
- const e = v.map((t) => ({ key: t, label: H.get(t) ?? `#${t}` })).sort((t, x) => t.label.localeCompare(x.label, void 0, { numeric: !0 })), a = _.trim();
166
- return a ? e.filter((t) => de(t.label, a)) : e;
167
- }, [v, H, _]), $ = c.key_label ?? O(L ?? h), te = c.value_label ?? O(B ?? i), re = n ? c.value_label_2 ?? O(E ?? n) : "", ae = n ? "grid-cols-[minmax(140px,1fr)_minmax(0,1.5fr)_minmax(0,1.5fr)_28px]" : "grid-cols-[minmax(140px,1fr)_minmax(0,2fr)_28px]";
168
- 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: [
164
+ }, ae = C(() => {
165
+ const e = v.map((t) => ({ key: t, label: R.get(t) ?? `#${t}` })).sort((t, b) => t.label.localeCompare(b.label, void 0, { numeric: !0 })), r = q.trim();
166
+ return r ? e.filter((t) => he(t.label, r)) : e;
167
+ }, [v, R, q]);
168
+ _e(() => {
169
+ if (!k) return;
170
+ const e = requestAnimationFrame(() => {
171
+ var c, oe, ie;
172
+ const t = (c = E.current) == null ? void 0 : c.querySelector(
173
+ `[data-membership-key="${CSS.escape(k)}"]`
174
+ );
175
+ if (!t) return;
176
+ const b = (oe = window.matchMedia) == null ? void 0 : oe.call(window, "(prefers-reduced-motion: reduce)").matches;
177
+ t.scrollIntoView({ block: "nearest", behavior: b ? "auto" : "smooth" }), (ie = t.querySelector("button:not([disabled])")) == null || ie.focus({ preventScroll: !0 });
178
+ }), r = window.setTimeout(() => D(null), 2200);
179
+ return () => {
180
+ cancelAnimationFrame(e), window.clearTimeout(r);
181
+ };
182
+ }, [k]);
183
+ const _ = d.key_label ?? P(T ?? f), le = d.value_label ?? P(H ?? i), se = n ? d.value_label_2 ?? P(U ?? n) : "", ne = n ? "grid-cols-[minmax(140px,1fr)_minmax(0,1.5fr)_minmax(0,1.5fr)_28px]" : "grid-cols-[minmax(140px,1fr)_minmax(0,2fr)_28px]";
184
+ return x ? /* @__PURE__ */ h("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: [
169
185
  "Save this record first, then add ",
170
- $.toLowerCase(),
186
+ _.toLowerCase(),
171
187
  " here."
172
- ] }) : /* @__PURE__ */ b("div", { "data-membership-set": `${r}:${l}`, className: "space-y-2", children: [
173
- !o && L && /* @__PURE__ */ b("div", { className: "flex flex-wrap items-center gap-2", children: [
188
+ ] }) : /* @__PURE__ */ h("div", { "data-membership-set": `${a}:${l}`, className: "space-y-2", children: [
189
+ !o && T && /* @__PURE__ */ h("div", { className: "flex flex-wrap items-center gap-2", children: [
174
190
  /* @__PURE__ */ s("div", { className: "w-[320px] max-w-full", children: /* @__PURE__ */ s(
175
- Te,
191
+ Pe,
176
192
  {
177
- collection: L,
193
+ collection: T,
178
194
  value: null,
179
- onChange: xe,
180
- placeholder: `Add ${$.toLowerCase()}…`,
181
- extraFilter: v.length && v.length <= 400 ? { id: { _nin: v } } : void 0
195
+ onChange: ke,
196
+ placeholder: `Add ${_.toLowerCase()}…`,
197
+ extraFilter: v.length && v.length <= 400 ? { id: { _nin: v } } : void 0,
198
+ alreadyAdded: {
199
+ items: v.map((e) => ({ id: e, label: R.get(e) ?? `#${e}` })),
200
+ where: "in this table",
201
+ onShow: (e) => {
202
+ u(""), D(e);
203
+ }
204
+ }
182
205
  },
183
206
  v.length
184
207
  ) }),
185
- v.length > 8 && /* @__PURE__ */ b("label", { className: "relative ml-auto block w-[220px] max-w-full", children: [
186
- /* @__PURE__ */ s(ge, { className: "pointer-events-none absolute left-2 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-slate-400" }),
208
+ v.length > 8 && /* @__PURE__ */ h("label", { className: "relative ml-auto block w-[220px] max-w-full", children: [
209
+ /* @__PURE__ */ s(Se, { className: "pointer-events-none absolute left-2 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-slate-400" }),
187
210
  /* @__PURE__ */ s(
188
211
  "input",
189
212
  {
190
- value: _,
191
- onChange: (e) => p(e.target.value),
213
+ value: q,
214
+ onChange: (e) => u(e.target.value),
192
215
  placeholder: `Filter ${v.length}…`,
193
- "aria-label": `Filter ${$}`,
216
+ "aria-label": `Filter ${_}`,
194
217
  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"
195
218
  }
196
219
  )
197
220
  ] })
198
221
  ] }),
199
- /* @__PURE__ */ b("div", { className: "overflow-hidden rounded-lg border border-slate-200 dark:border-border", children: [
200
- /* @__PURE__ */ b(
222
+ /* @__PURE__ */ h("div", { className: "overflow-hidden rounded-lg border border-slate-200 dark:border-border", children: [
223
+ /* @__PURE__ */ h(
201
224
  "div",
202
225
  {
203
- className: C(
204
- ae,
226
+ className: S(
227
+ ne,
205
228
  "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"
206
229
  ),
207
230
  children: [
208
- /* @__PURE__ */ s("span", { children: $ }),
209
- /* @__PURE__ */ b("span", { children: [
210
- te,
231
+ /* @__PURE__ */ s("span", { children: _ }),
232
+ /* @__PURE__ */ h("span", { children: [
233
+ le,
211
234
  " ",
212
- /* @__PURE__ */ b("span", { className: "normal-case tracking-normal text-slate-400", children: [
235
+ /* @__PURE__ */ h("span", { className: "normal-case tracking-normal text-slate-400", children: [
213
236
  "· none picked = ",
214
- f.toLowerCase()
237
+ y.toLowerCase()
215
238
  ] })
216
239
  ] }),
217
- n && /* @__PURE__ */ b("span", { children: [
218
- re,
240
+ n && /* @__PURE__ */ h("span", { children: [
241
+ se,
219
242
  " ",
220
- /* @__PURE__ */ b("span", { className: "normal-case tracking-normal text-slate-400", children: [
243
+ /* @__PURE__ */ h("span", { className: "normal-case tracking-normal text-slate-400", children: [
221
244
  "· none picked = ",
222
245
  w.toLowerCase()
223
246
  ] })
@@ -226,187 +249,195 @@ function Xe({
226
249
  ]
227
250
  }
228
251
  ),
229
- me ? /* @__PURE__ */ s("div", { className: "space-y-2 p-3", children: [0, 1, 2].map((e) => /* @__PURE__ */ s("div", { className: "h-6 animate-pulse rounded bg-[hsl(var(--nvr-skeleton))]" }, e)) }) : ee.length === 0 ? /* @__PURE__ */ s("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 ${$.toLowerCase()} yet.` }) : /* @__PURE__ */ s("ul", { className: "max-h-[480px] divide-y divide-slate-100 overflow-y-auto dark:divide-border", children: ee.map((e) => {
230
- const a = N.get(e.key) ?? [], t = new Set(
231
- a.filter((d) => d.value !== null).map((d) => d.value)
232
- ), x = new Set(
233
- a.filter((d) => d.value2 !== null).map((d) => d.value2)
234
- );
235
- return /* @__PURE__ */ b(
236
- "li",
237
- {
238
- "data-membership-key": e.key,
239
- className: C(
240
- ae,
241
- "grid items-center gap-3 px-3 py-1.5 text-[12px]",
242
- k === e.key && "opacity-60"
243
- ),
244
- children: [
245
- /* @__PURE__ */ s(
246
- "span",
247
- {
248
- className: "truncate font-medium text-slate-800 dark:text-foreground",
249
- "data-tip": e.label,
250
- children: e.label
251
- }
252
- ),
253
- /* @__PURE__ */ s(
254
- oe,
255
- {
256
- options: pe,
257
- picked: t,
258
- emptyLabel: f,
259
- valueTitle: te,
260
- disabled: !!o || k === e.key,
261
- onToggle: (d) => Z(e.key, d),
262
- onClear: () => I(e.key)
263
- }
264
- ),
265
- n && /* @__PURE__ */ s(
266
- oe,
267
- {
268
- options: be,
269
- picked: x,
270
- emptyLabel: w,
271
- valueTitle: re,
272
- disabled: !!o || k === e.key,
273
- onToggle: (d) => Z(e.key, d, 2),
274
- onClear: () => I(e.key, 2)
275
- }
276
- ),
277
- o ? /* @__PURE__ */ s("span", {}) : /* @__PURE__ */ s(
278
- "button",
279
- {
280
- type: "button",
281
- onClick: () => fe(e.key),
282
- disabled: k === e.key,
283
- "aria-label": `Remove ${e.label}`,
284
- "data-tip": "Remove",
285
- 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",
286
- children: /* @__PURE__ */ s(ve, { className: "h-3.5 w-3.5" })
287
- }
288
- )
289
- ]
290
- },
291
- e.key
292
- );
293
- }) })
252
+ ye ? /* @__PURE__ */ s("div", { className: "space-y-2 p-3", children: [0, 1, 2].map((e) => /* @__PURE__ */ s("div", { className: "h-6 animate-pulse rounded bg-[hsl(var(--nvr-skeleton))]" }, e)) }) : ae.length === 0 ? /* @__PURE__ */ s("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 ${_.toLowerCase()} yet.` }) : /* @__PURE__ */ s(
253
+ "ul",
254
+ {
255
+ ref: E,
256
+ className: "max-h-[480px] divide-y divide-slate-100 overflow-y-auto dark:divide-border",
257
+ children: ae.map((e) => {
258
+ const r = N.get(e.key) ?? [], t = new Set(
259
+ r.filter((c) => c.value !== null).map((c) => c.value)
260
+ ), b = new Set(
261
+ r.filter((c) => c.value2 !== null).map((c) => c.value2)
262
+ );
263
+ return /* @__PURE__ */ h(
264
+ "li",
265
+ {
266
+ "data-membership-key": e.key,
267
+ className: S(
268
+ ne,
269
+ "grid items-center gap-3 px-3 py-1.5 text-[12px] transition-colors duration-700 ease-out",
270
+ K === e.key && "opacity-60",
271
+ k === e.key && "bg-nvr-cyan/10"
272
+ ),
273
+ children: [
274
+ /* @__PURE__ */ s(
275
+ "span",
276
+ {
277
+ className: "truncate font-medium text-slate-800 dark:text-foreground",
278
+ "data-tip": e.label,
279
+ children: e.label
280
+ }
281
+ ),
282
+ /* @__PURE__ */ s(
283
+ me,
284
+ {
285
+ options: xe,
286
+ picked: t,
287
+ emptyLabel: y,
288
+ valueTitle: le,
289
+ disabled: !!o || K === e.key,
290
+ onToggle: (c) => te(e.key, c),
291
+ onClear: () => re(e.key)
292
+ }
293
+ ),
294
+ n && /* @__PURE__ */ s(
295
+ me,
296
+ {
297
+ options: ge,
298
+ picked: b,
299
+ emptyLabel: w,
300
+ valueTitle: se,
301
+ disabled: !!o || K === e.key,
302
+ onToggle: (c) => te(e.key, c, 2),
303
+ onClear: () => re(e.key, 2)
304
+ }
305
+ ),
306
+ o ? /* @__PURE__ */ s("span", {}) : /* @__PURE__ */ s(
307
+ "button",
308
+ {
309
+ type: "button",
310
+ onClick: () => we(e.key),
311
+ disabled: K === e.key,
312
+ "aria-label": `Remove ${e.label}`,
313
+ "data-tip": "Remove",
314
+ 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",
315
+ children: /* @__PURE__ */ s(Ce, { className: "h-3.5 w-3.5" })
316
+ }
317
+ )
318
+ ]
319
+ },
320
+ e.key
321
+ );
322
+ })
323
+ }
324
+ )
294
325
  ] }),
295
- z && /* @__PURE__ */ s("p", { className: "text-[12px] text-red-600 dark:text-red-400", children: z })
326
+ B && /* @__PURE__ */ s("p", { className: "text-[12px] text-red-600 dark:text-red-400", children: B })
296
327
  ] });
297
328
  }
298
- function oe({
299
- options: r,
329
+ function me({
330
+ options: a,
300
331
  picked: l,
301
- emptyLabel: u,
302
- valueTitle: c,
332
+ emptyLabel: m,
333
+ valueTitle: d,
303
334
  disabled: o,
304
- onToggle: m,
335
+ onToggle: p,
305
336
  onClear: g
306
337
  }) {
307
- const [y, h] = q(!1), [i, n] = q(""), f = l.size === 0;
308
- if (r.length <= Fe)
309
- return /* @__PURE__ */ b("div", { className: "flex flex-wrap items-center gap-1", "data-membership-values": !0, children: [
338
+ const [x, f] = $(!1), [i, n] = $(""), y = l.size === 0;
339
+ if (a.length <= De)
340
+ return /* @__PURE__ */ h("div", { className: "flex flex-wrap items-center gap-1", "data-membership-values": !0, children: [
310
341
  /* @__PURE__ */ s(
311
342
  "button",
312
343
  {
313
344
  type: "button",
314
- disabled: o || f,
315
- "aria-pressed": f,
345
+ disabled: o || y,
346
+ "aria-pressed": y,
316
347
  onClick: g,
317
- className: C(
348
+ className: S(
318
349
  "h-6 rounded-full border px-2 text-[11px] transition-colors",
319
- 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"
350
+ 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"
320
351
  ),
321
- children: u
352
+ children: m
322
353
  }
323
354
  ),
324
- r.map((p) => {
325
- const k = l.has(p.id);
326
- return /* @__PURE__ */ b(
355
+ a.map((u) => {
356
+ const k = l.has(u.id);
357
+ return /* @__PURE__ */ h(
327
358
  "button",
328
359
  {
329
360
  type: "button",
330
361
  disabled: o,
331
362
  "aria-pressed": k,
332
- "data-membership-value": p.id,
333
- onClick: () => m(p.id),
334
- className: C(
363
+ "data-membership-value": u.id,
364
+ onClick: () => p(u.id),
365
+ className: S(
335
366
  "inline-flex h-6 items-center gap-1 rounded-full border px-2 text-[11px] transition-colors",
336
367
  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"
337
368
  ),
338
369
  children: [
339
- k && /* @__PURE__ */ s(R, { className: "h-3 w-3" }),
340
- p.label
370
+ k && /* @__PURE__ */ s(O, { className: "h-3 w-3" }),
371
+ u.label
341
372
  ]
342
373
  },
343
- p.id
374
+ u.id
344
375
  );
345
376
  })
346
377
  ] });
347
- const w = i.trim() ? r.filter((p) => de(p.label, i)) : r, _ = f ? u : r.filter((p) => l.has(p.id)).map((p) => p.label).join(", ");
348
- return /* @__PURE__ */ b($e, { open: y, onOpenChange: h, children: [
349
- /* @__PURE__ */ s(qe, { asChild: !0, children: /* @__PURE__ */ b(
378
+ const w = i.trim() ? a.filter((u) => he(u.label, i)) : a, q = y ? m : a.filter((u) => l.has(u.id)).map((u) => u.label).join(", ");
379
+ return /* @__PURE__ */ h(Re, { open: x, onOpenChange: f, children: [
380
+ /* @__PURE__ */ s(je, { asChild: !0, children: /* @__PURE__ */ h(
350
381
  "button",
351
382
  {
352
383
  type: "button",
353
384
  disabled: o,
354
385
  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",
355
386
  children: [
356
- /* @__PURE__ */ s("span", { className: C("truncate", f && "text-slate-500 dark:text-muted-foreground"), children: _ }),
357
- /* @__PURE__ */ s(we, { className: "h-3.5 w-3.5 shrink-0 text-slate-400" })
387
+ /* @__PURE__ */ s("span", { className: S("truncate", y && "text-slate-500 dark:text-muted-foreground"), children: q }),
388
+ /* @__PURE__ */ s($e, { className: "h-3.5 w-3.5 shrink-0 text-slate-400" })
358
389
  ]
359
390
  }
360
391
  ) }),
361
- /* @__PURE__ */ b(Le, { align: "start", className: "w-[260px] p-1", children: [
392
+ /* @__PURE__ */ h(Ae, { align: "start", className: "w-[260px] p-1", children: [
362
393
  /* @__PURE__ */ s(
363
394
  "input",
364
395
  {
365
396
  value: i,
366
- onChange: (p) => n(p.target.value),
367
- placeholder: `Search ${c.toLowerCase()}…`,
397
+ onChange: (u) => n(u.target.value),
398
+ placeholder: `Search ${d.toLowerCase()}…`,
368
399
  className: "mb-1 h-7 w-full rounded border border-slate-200 bg-background px-2 text-[12px] outline-none dark:border-border"
369
400
  }
370
401
  ),
371
- /* @__PURE__ */ b("ul", { className: "max-h-[240px] overflow-y-auto", children: [
372
- !i.trim() && /* @__PURE__ */ s("li", { className: "mb-1 border-b border-slate-100 pb-1 dark:border-border", children: /* @__PURE__ */ b(
402
+ /* @__PURE__ */ h("ul", { className: "max-h-[240px] overflow-y-auto", children: [
403
+ !i.trim() && /* @__PURE__ */ s("li", { className: "mb-1 border-b border-slate-100 pb-1 dark:border-border", children: /* @__PURE__ */ h(
373
404
  "button",
374
405
  {
375
406
  type: "button",
376
407
  onClick: () => {
377
- f || g();
408
+ y || g();
378
409
  },
379
- "aria-pressed": f,
410
+ "aria-pressed": y,
380
411
  "data-membership-clear": !0,
381
412
  className: "flex w-full items-center gap-2 rounded px-2 py-1 text-left text-[12px] font-medium hover:bg-muted",
382
413
  children: [
383
- /* @__PURE__ */ s(R, { className: C("h-3.5 w-3.5", f ? "opacity-100" : "opacity-0") }),
384
- u
414
+ /* @__PURE__ */ s(O, { className: S("h-3.5 w-3.5", y ? "opacity-100" : "opacity-0") }),
415
+ m
385
416
  ]
386
417
  }
387
418
  ) }),
388
- w.map((p) => /* @__PURE__ */ s("li", { children: /* @__PURE__ */ b(
419
+ w.map((u) => /* @__PURE__ */ s("li", { children: /* @__PURE__ */ h(
389
420
  "button",
390
421
  {
391
422
  type: "button",
392
- onClick: () => m(p.id),
423
+ onClick: () => p(u.id),
393
424
  className: "flex w-full items-center gap-2 rounded px-2 py-1 text-left text-[12px] hover:bg-muted",
394
425
  children: [
395
426
  /* @__PURE__ */ s(
396
- R,
427
+ O,
397
428
  {
398
- className: C("h-3.5 w-3.5", l.has(p.id) ? "opacity-100" : "opacity-0")
429
+ className: S("h-3.5 w-3.5", l.has(u.id) ? "opacity-100" : "opacity-0")
399
430
  }
400
431
  ),
401
- p.label
432
+ u.label
402
433
  ]
403
434
  }
404
- ) }, p.id))
435
+ ) }, u.id))
405
436
  ] })
406
437
  ] })
407
438
  ] });
408
439
  }
409
440
  export {
410
- Xe as MembershipSetField,
411
- Me as planMembershipRows
441
+ tt as MembershipSetField,
442
+ Qe as planMembershipRows
412
443
  };