@nivaro/react 0.2.54 → 0.2.56

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 (151) hide show
  1. package/dist/full.css +1 -1
  2. package/dist/hooks/useSessionRecorder.js +99 -98
  3. package/dist/index.d.ts +367 -2
  4. package/dist/index.js +645 -616
  5. package/dist/layout-editor.d.ts +4 -0
  6. package/dist/shared/components/BackgroundRunOffer.js +117 -0
  7. package/dist/shared/components/BroadcastView.js +214 -213
  8. package/dist/shared/components/CollectionBrowserView.js +2592 -2695
  9. package/dist/shared/components/ItemEditForm.js +4066 -3832
  10. package/dist/shared/components/JobsTray.js +100 -55
  11. package/dist/shared/components/MyWorkView.js +91 -89
  12. package/dist/shared/components/NotificationBell.js +80 -79
  13. package/dist/shared/components/ProfileView.js +568 -520
  14. package/dist/shared/components/RecordCompare.js +254 -0
  15. package/dist/shared/components/RecordReadView.js +599 -552
  16. package/dist/shared/components/ReportView.js +578 -543
  17. package/dist/shared/components/RowPresence.js +91 -0
  18. package/dist/shared/components/WidgetSlot.js +474 -458
  19. package/dist/shared/components/ai/AiAnalyticsView.js +16 -6
  20. package/dist/shared/components/ai/AskPanel.js +139 -119
  21. package/dist/shared/components/ai/FirstWeekCard.js +126 -0
  22. package/dist/shared/components/bulk/BulkFieldUpdate.js +289 -0
  23. package/dist/shared/components/bulk/bulk-field-options.js +45 -0
  24. package/dist/shared/components/charts/CumulativeFlowChart.js +176 -0
  25. package/dist/shared/components/chat/ChannelArchive.js +326 -0
  26. package/dist/shared/components/chat/ChannelExtras.js +141 -121
  27. package/dist/shared/components/chat/ChatAnalyticsView.js +112 -110
  28. package/dist/shared/components/chat/ChatPanel.js +1695 -1733
  29. package/dist/shared/components/chat/Composer.js +357 -303
  30. package/dist/shared/components/chat/MessageActions.js +92 -0
  31. package/dist/shared/components/chat/MessageFormat.js +290 -264
  32. package/dist/shared/components/chat/OutboxBubbles.js +146 -0
  33. package/dist/shared/components/chat/RequestIdCard.js +135 -0
  34. package/dist/shared/components/chat/RoomHeaderMenu.js +202 -0
  35. package/dist/shared/components/chat/RoomParts.js +213 -274
  36. package/dist/shared/components/chat/ScreenClip.js +184 -0
  37. package/dist/shared/components/chat/chat-core.js +402 -483
  38. package/dist/shared/components/chat/chat-drafts.js +59 -0
  39. package/dist/shared/components/chat/chat-emoji.js +348 -0
  40. package/dist/shared/components/chat/chat-local-time.js +41 -0
  41. package/dist/shared/components/chat/chat-outbox.js +303 -0
  42. package/dist/shared/components/chat/chat-window.js +163 -0
  43. package/dist/shared/components/chat/huddle/HuddleControls.js +143 -0
  44. package/dist/shared/components/chat/huddle/HuddleStage.js +164 -0
  45. package/dist/shared/components/chat/huddle/huddle-store.js +342 -0
  46. package/dist/shared/components/chat/huddle/useHuddle.js +58 -0
  47. package/dist/shared/components/help-videos/api.js +76 -73
  48. package/dist/shared/components/item-edit/CatalogPickerField.js +113 -112
  49. package/dist/shared/components/item-edit/ChangeReasonDialog.js +13 -13
  50. package/dist/shared/components/item-edit/FieldAffordances.js +2 -2
  51. package/dist/shared/components/item-edit/FieldRenderer.js +248 -245
  52. package/dist/shared/components/item-edit/FieldRow.js +292 -279
  53. package/dist/shared/components/item-edit/GroupSection.js +698 -574
  54. package/dist/shared/components/item-edit/InlineTableField.js +3 -1
  55. package/dist/shared/components/item-edit/RelationCombobox.js +186 -176
  56. package/dist/shared/components/item-edit/entry/EntryStrip.js +54 -0
  57. package/dist/shared/components/item-edit/entry/entry-keys.js +27 -0
  58. package/dist/shared/components/item-edit/entry/useEntryKeyboard.js +70 -0
  59. package/dist/shared/components/item-edit/entry/useEntryMode.js +59 -0
  60. package/dist/shared/components/item-edit/form-structure-ui.js +105 -0
  61. package/dist/shared/components/item-edit/lazy-sections.js +36 -0
  62. package/dist/shared/components/item-edit/lock-why.js +39 -32
  63. package/dist/shared/components/item-edit/picker-miss.js +26 -0
  64. package/dist/shared/components/item-edit/placement-behaviour.js +196 -0
  65. package/dist/shared/components/item-edit/useFormUsageBeacon.js +51 -45
  66. package/dist/shared/components/layout-editor/AddPanel.js +134 -117
  67. package/dist/shared/components/layout-editor/ChangeNote.js +25 -24
  68. package/dist/shared/components/layout-editor/CollabParts.js +80 -75
  69. package/dist/shared/components/layout-editor/DesignNode.js +126 -120
  70. package/dist/shared/components/layout-editor/EditorCanvas.js +30 -27
  71. package/dist/shared/components/layout-editor/EditorTopBar.js +203 -192
  72. package/dist/shared/components/layout-editor/HistoryPanel.js +120 -104
  73. package/dist/shared/components/layout-editor/LayoutEditor.js +768 -671
  74. package/dist/shared/components/layout-editor/RestorePiece.js +143 -0
  75. package/dist/shared/components/layout-editor/StagedChip.js +22 -0
  76. package/dist/shared/components/layout-editor/StructureMenu.js +237 -186
  77. package/dist/shared/components/layout-editor/collab/FormFollowShare.js +149 -103
  78. package/dist/shared/components/layout-editor/collab/collab-api.js +29 -26
  79. package/dist/shared/components/layout-editor/dnd/LayoutDndProvider.js +81 -80
  80. package/dist/shared/components/layout-editor/dnd/node.js +69 -57
  81. package/dist/shared/components/layout-editor/draft-recovery.js +113 -43
  82. package/dist/shared/components/layout-editor/entry/PlacementPresets.js +149 -0
  83. package/dist/shared/components/layout-editor/entry/entry-editor-context.js +10 -0
  84. package/dist/shared/components/layout-editor/entry/presets.js +71 -0
  85. package/dist/shared/components/layout-editor/entry/tab-order.js +110 -0
  86. package/dist/shared/components/layout-editor/entry/theme-preview.js +37 -0
  87. package/dist/shared/components/layout-editor/grid-guides.js +142 -0
  88. package/dist/shared/components/layout-editor/inspector/BehaviourSettings.js +402 -0
  89. package/dist/shared/components/layout-editor/inspector/BulkInspector.js +61 -57
  90. package/dist/shared/components/layout-editor/inspector/GroupInspector.js +247 -151
  91. package/dist/shared/components/layout-editor/inspector/Inspector.js +176 -155
  92. package/dist/shared/components/layout-editor/inspector/LookTab.js +167 -116
  93. package/dist/shared/components/layout-editor/inspector/PickerMisses.js +129 -0
  94. package/dist/shared/components/layout-editor/inspector/PickerTab.js +84 -82
  95. package/dist/shared/components/layout-editor/inspector/RulesTab.js +66 -62
  96. package/dist/shared/components/layout-editor/inspector/kit.js +69 -68
  97. package/dist/shared/components/layout-editor/outputs/OutputsButton.js +254 -0
  98. package/dist/shared/components/layout-editor/outputs/help-sheet.js +154 -0
  99. package/dist/shared/components/layout-editor/outputs/output-api.js +61 -0
  100. package/dist/shared/components/layout-editor/overview/describe-conditions.js +6 -0
  101. package/dist/shared/components/layout-editor/overview/purpose.js +15 -13
  102. package/dist/shared/components/layout-editor/parity-keys.json.js +1 -1
  103. package/dist/shared/components/layout-editor/restore-piece.js +192 -0
  104. package/dist/shared/components/layout-editor/section-structure.js +241 -0
  105. package/dist/shared/components/layout-editor/settings/EntrySection.js +296 -0
  106. package/dist/shared/components/layout-editor/settings/FormSettings.js +41 -39
  107. package/dist/shared/components/layout-editor/settings/ResolveSettings.js +255 -0
  108. package/dist/shared/components/layout-editor/settings/ToolsSection.js +147 -111
  109. package/dist/shared/components/layout-editor/settings/WhoSection.js +29 -26
  110. package/dist/shared/components/layout-editor/settings/settings-registry.js +114 -17
  111. package/dist/shared/components/layout-editor/staged-api.js +64 -0
  112. package/dist/shared/components/layout-editor/structure-ops.js +81 -77
  113. package/dist/shared/components/layout-editor/testing/TestingPanels.js +65 -60
  114. package/dist/shared/components/layout-editor/testing/testing-model.js +198 -185
  115. package/dist/shared/components/layout-editor/toolbar-kit.js +11 -11
  116. package/dist/shared/components/layout-editor/usage/AbTestSection.js +355 -0
  117. package/dist/shared/components/layout-editor/usage/UsagePanel.js +144 -70
  118. package/dist/shared/components/layout-editor/usage/ab-api.js +86 -0
  119. package/dist/shared/components/layout-editor/usage/suggest-collapse.js +32 -0
  120. package/dist/shared/components/layout-editor/useLayoutDraft.js +25 -24
  121. package/dist/shared/components/notifications/NotificationAnalyticsView.js +148 -77
  122. package/dist/shared/components/panels/ErpFailureBanner.js +18 -17
  123. package/dist/shared/components/panels/ExternalRequestsChip.js +63 -62
  124. package/dist/shared/components/pipeline/PipelineEditorView.js +106 -104
  125. package/dist/shared/components/profile/AgentsPanel.js +479 -0
  126. package/dist/shared/components/queue/QueueWorklist.js +1026 -1040
  127. package/dist/shared/components/support/SupportAnalytics.js +171 -0
  128. package/dist/shared/components/support/SupportView.js +75 -73
  129. package/dist/shared/lib/background-runs.js +150 -0
  130. package/dist/shared/lib/delivery-ack.js +9 -0
  131. package/dist/shared/lib/entry-badge-style.js +13 -0
  132. package/dist/shared/lib/entry-config.js +71 -0
  133. package/dist/shared/lib/form-sections.js +64 -0
  134. package/dist/shared/lib/form-structure.js +99 -0
  135. package/dist/shared/lib/form-usage-beacon.js +101 -52
  136. package/dist/shared/lib/jobs-tray.js +25 -23
  137. package/dist/shared/lib/keyset-pager.js +37 -0
  138. package/dist/shared/lib/layout-ops.js +84 -82
  139. package/dist/shared/lib/layout-resolve.js +113 -0
  140. package/dist/shared/lib/placement-behaviour.js +144 -0
  141. package/dist/shared/lib/prefetch.js +149 -0
  142. package/dist/shared/lib/presence-hooks.js +199 -0
  143. package/dist/shared/lib/record-outbox.js +82 -81
  144. package/dist/shared/lib/replay-socket.js +93 -0
  145. package/dist/shared/lib/request-gate.js +51 -50
  146. package/dist/shared/lib/room-gaps.js +96 -0
  147. package/dist/shared/lib/search-log.js +27 -0
  148. package/dist/shared/lib/socket-realtime.js +101 -80
  149. package/dist/shared/lib/stale-chunk.js +60 -0
  150. package/dist/shared/lib/worker-socket.js +200 -0
  151. package/package.json +1 -1
@@ -1,27 +1,28 @@
1
1
  import { jsxs as c, jsx as r } from "react/jsx-runtime";
2
- import { useQuery as N } from "@tanstack/react-query";
3
- import { ChevronDown as xe, Loader2 as B, AlertTriangle as je, Search as Re, X as Fe, Check as ye } from "lucide-react";
4
- import { useState as k, useRef as H, useEffect as L, useLayoutEffect as Te, useMemo as Z } from "react";
5
- import { createPortal as we } from "react-dom";
6
- import { useNivaroClient as ee, useItemEditAuth as Ee, useStaleFieldReporter as Oe } from "../../context.js";
7
- import { get as j, post as Ae } from "../../lib/commands.js";
8
- import { useRecordReader as ve } from "../../lib/record-loader.js";
9
- import { useOnlineUsers as Ke } from "../../lib/use-online-users.js";
10
- import { UserAvatar as Ue } from "../UserAvatar.js";
11
- import { userOptionFilter as Ie, cn as A } from "../../lib/utils.js";
12
- import { applyDisplayTemplate as v } from "./helpers.js";
13
- function Pe(s) {
2
+ import { useQuery as k } from "@tanstack/react-query";
3
+ import { ChevronDown as ye, Loader2 as te, AlertTriangle as je, Search as Fe, X as Te, Check as we } from "lucide-react";
4
+ import { useState as S, useRef as H, useEffect as j, useLayoutEffect as Ee, useMemo as ee } from "react";
5
+ import { createPortal as ve } from "react-dom";
6
+ import { useNivaroClient as re, useItemEditAuth as Oe, useStaleFieldReporter as Ae } from "../../context.js";
7
+ import { get as F, post as Ke } from "../../lib/commands.js";
8
+ import { useRecordReader as Ne } from "../../lib/record-loader.js";
9
+ import { useOnlineUsers as Ue } from "../../lib/use-online-users.js";
10
+ import { UserAvatar as Ie } from "../UserAvatar.js";
11
+ import { userOptionFilter as Pe, cn as U } from "../../lib/utils.js";
12
+ import { applyDisplayTemplate as N } from "./helpers.js";
13
+ import { usePickerMissReport as De } from "./picker-miss.js";
14
+ function ze(s) {
14
15
  return s.replace(/\(.*$/, "").trim().split(/\s+/).map((t) => t[0]).filter(Boolean).slice(0, 2).join("").toUpperCase() || "?";
15
16
  }
16
- function De(s) {
17
- const [t, d] = k(null), g = {
17
+ function Je(s) {
18
+ const [t, d] = S(null), h = {
18
19
  onMouseEnter: (f) => {
19
20
  if (!s) return;
20
21
  const m = f.currentTarget.getBoundingClientRect(), u = window.innerHeight - m.bottom < 80;
21
22
  d({ x: m.left, y: u ? m.top - 58 : m.bottom + 4 });
22
23
  },
23
24
  onMouseLeave: () => d(null)
24
- }, w = s && t ? we(
25
+ }, y = s && t ? ve(
25
26
  /* @__PURE__ */ r(
26
27
  "div",
27
28
  {
@@ -32,77 +33,78 @@ function De(s) {
32
33
  ),
33
34
  document.body
34
35
  ) : null;
35
- return { bind: g, tip: w };
36
+ return { bind: h, tip: y };
36
37
  }
37
- function ze({
38
+ function Me({
38
39
  collection: s,
39
40
  value: t,
40
41
  onChange: d,
41
- disabled: g,
42
- placeholder: w,
42
+ disabled: h,
43
+ placeholder: y,
43
44
  extraFilter: f,
44
45
  autoSelectSingle: m,
45
46
  optionSort: u,
46
- requiredParent: C,
47
+ requiredParent: $,
47
48
  facets: o,
48
- fieldKey: S,
49
+ fieldKey: _,
49
50
  narrowedBy: l,
50
- pinned: p
51
+ pinned: p,
52
+ missPlacement: w
51
53
  }) {
52
- const b = ee(), te = ve(), [x, R] = k(!1), [$, re] = k(""), [F, ne] = k(""), se = H(null), K = H(null);
53
- L(() => {
54
- x ? setTimeout(() => {
54
+ const T = re(), ne = Ne(), [g, E] = S(!1), [L, se] = S(""), [R, oe] = S(""), ie = H(null), I = H(null);
55
+ j(() => {
56
+ g ? setTimeout(() => {
55
57
  var e;
56
- return (e = se.current) == null ? void 0 : e.focus();
57
- }, 30) : (re(""), ne(""));
58
- }, [x]), L(() => {
59
- const e = setTimeout(() => ne($), 300);
58
+ return (e = ie.current) == null ? void 0 : e.focus();
59
+ }, 30) : (se(""), oe(""));
60
+ }, [g]), j(() => {
61
+ const e = setTimeout(() => oe(L), 300);
60
62
  return () => clearTimeout(e);
61
- }, [$]), L(() => {
62
- if (!x) return;
63
+ }, [L]), j(() => {
64
+ if (!g) return;
63
65
  const e = (i) => {
64
66
  var a;
65
67
  const n = i.target;
66
- (a = n == null ? void 0 : n.closest) != null && a.call(n, "[data-nvr-combobox-panel]") || K.current && !K.current.contains(i.target) && R(!1);
68
+ (a = n == null ? void 0 : n.closest) != null && a.call(n, "[data-nvr-combobox-panel]") || I.current && !I.current.contains(i.target) && E(!1);
67
69
  };
68
70
  return document.addEventListener("mousedown", e), () => document.removeEventListener("mousedown", e);
69
- }, [x]);
70
- const [oe, M] = k(null), [ie, Ne] = k(null);
71
- Te(() => {
72
- if (!x) {
73
- M(null);
71
+ }, [g]);
72
+ const [le, Y] = S(null), [ae, ke] = S(null);
73
+ Ee(() => {
74
+ if (!g) {
75
+ Y(null);
74
76
  return;
75
77
  }
76
78
  const e = () => {
77
- const i = K.current;
79
+ const i = I.current;
78
80
  if (!i) return;
79
81
  const n = i.getBoundingClientRect(), a = i.closest('[role="dialog"]') ?? document.body;
80
- Ne(a);
81
- const pe = window.innerHeight - n.bottom < 340 && n.top > window.innerHeight - n.bottom, fe = n.left, be = pe ? n.top - 4 : n.bottom + 4, he = {
82
+ ke(a);
83
+ const fe = window.innerHeight - n.bottom < 340 && n.top > window.innerHeight - n.bottom, be = n.left, he = fe ? n.top - 4 : n.bottom + 4, ge = {
82
84
  minWidth: n.width,
83
85
  zIndex: 120,
84
- ...pe ? { transform: "translateY(-100%)" } : {}
86
+ ...fe ? { transform: "translateY(-100%)" } : {}
85
87
  };
86
88
  if (a === document.body)
87
- M({ position: "fixed", left: fe, top: be, ...he });
89
+ Y({ position: "fixed", left: be, top: he, ...ge });
88
90
  else {
89
- const ge = a.getBoundingClientRect();
90
- M({ position: "absolute", left: fe - ge.left, top: be - ge.top, ...he });
91
+ const xe = a.getBoundingClientRect();
92
+ Y({ position: "absolute", left: be - xe.left, top: he - xe.top, ...ge });
91
93
  }
92
94
  };
93
95
  return e(), window.addEventListener("scroll", e, !0), window.addEventListener("resize", e), () => {
94
96
  window.removeEventListener("scroll", e, !0), window.removeEventListener("resize", e);
95
97
  };
96
- }, [x]);
97
- const { data: Y } = N({
98
+ }, [g]);
99
+ const { data: W } = k({
98
100
  queryKey: ["col-meta", s],
99
- queryFn: () => b.request(j(`/collections/${s}`)).then((e) => e.data),
101
+ queryFn: () => T.request(F(`/collections/${s}`)).then((e) => e.data),
100
102
  staleTime: 3e5,
101
103
  retry: !1
102
- }), [W, ke] = k({}), { data: le = [] } = N({
104
+ }), [X, Se] = S({}), { data: de = [] } = k({
103
105
  queryKey: ["collection-meta", s],
104
- queryFn: () => b.request(
105
- j(`/collections/${s}`)
106
+ queryFn: () => T.request(
107
+ F(`/collections/${s}`)
106
108
  ).then(
107
109
  (e) => {
108
110
  var i;
@@ -111,65 +113,73 @@ function ze({
111
113
  ),
112
114
  enabled: !!(o != null && o.length),
113
115
  staleTime: 10 * 6e4
114
- }), Se = Z(() => {
116
+ }), _e = ee(() => {
115
117
  const e = {};
116
118
  for (const i of o ?? []) {
117
- const n = le.find(
119
+ const n = de.find(
118
120
  (a) => a.many_collection === s && a.many_field === i.field && !a.junction_field
119
121
  );
120
122
  n != null && n.one_collection && (e[i.field] = n.one_collection);
121
123
  }
122
124
  return e;
123
- }, [o, le, s]), T = s === "nivaro_users", _e = Ke(T), ae = Ee().isAdmin, X = Z(() => {
125
+ }, [o, de, s]), O = s === "nivaro_users", qe = Ue(O), ce = Oe().isAdmin, G = ee(() => {
124
126
  const e = [];
125
- T && e.push(Ie(ae)), f && e.push(f);
126
- for (const [i, n] of Object.entries(W))
127
+ O && e.push(Pe(ce)), f && e.push(f);
128
+ for (const [i, n] of Object.entries(X))
127
129
  n != null && n !== "" && e.push({ [i]: { _eq: n } });
128
130
  if (e.length !== 0)
129
131
  return e.length === 1 ? e[0] : { _and: e };
130
- }, [f, W, ae]), U = (Y == null ? void 0 : Y.display_template) ?? (T ? "{{first_name}} {{last_name}} ({{email}})" : null), _ = Z(() => {
131
- if (!U) return;
132
- const e = [...U.matchAll(/\{\{([\w.]+)\}\}/g)].map((i) => i[1]);
132
+ }, [f, X, ce]), P = (W == null ? void 0 : W.display_template) ?? (O ? "{{first_name}} {{last_name}} ({{email}})" : null), q = ee(() => {
133
+ if (!P) return;
134
+ const e = [...P.matchAll(/\{\{([\w.]+)\}\}/g)].map((i) => i[1]);
133
135
  if (e.length)
134
136
  return ["id", ...e].join(",");
135
- }, [U]), y = X ? JSON.stringify(X) : void 0, I = u && !/^-?label$/.test(u) ? u : void 0, { data: P, isFetching: de } = N({
137
+ }, [P]), x = G ? JSON.stringify(G) : void 0, D = u && !/^-?label$/.test(u) ? u : void 0, { data: v, isFetching: V } = k({
136
138
  queryKey: [
137
139
  "relation-opts",
138
140
  s,
139
- F,
140
- y,
141
- _,
142
- I ?? ""
141
+ R,
142
+ x,
143
+ q,
144
+ D ?? ""
143
145
  ],
144
- queryFn: () => b.request(
145
- j(`/items/${s}`, {
146
+ queryFn: () => T.request(
147
+ F(`/items/${s}`, {
146
148
  limit: 200,
147
149
  picker: "1",
148
- ...F ? { search: F } : {},
149
- ...y ? { filter: y } : {},
150
- ..._ ? { fields: _ } : {},
151
- ...I ? { sort: I } : {}
150
+ ...R ? { search: R } : {},
151
+ ...x ? { filter: x } : {},
152
+ ...q ? { fields: q } : {},
153
+ ...D ? { sort: D } : {}
152
154
  })
153
155
  ).then((e) => e.data ?? []),
154
- enabled: x,
155
- staleTime: y ? 0 : 3e4
156
- }), { data: D, isLoading: qe } = N({
157
- queryKey: ["relation-single", s, String(t), _],
158
- queryFn: () => te(s, t, _),
156
+ enabled: g,
157
+ staleTime: x ? 0 : 3e4
158
+ });
159
+ De({
160
+ placement: w,
161
+ open: g,
162
+ search: R,
163
+ settled: !V && v !== void 0,
164
+ count: (v == null ? void 0 : v.length) ?? 0
165
+ });
166
+ const { data: z, isLoading: Ce } = k({
167
+ queryKey: ["relation-single", s, String(t), q],
168
+ queryFn: () => ne(s, t, q),
159
169
  enabled: !!t,
160
170
  staleTime: 6e4
161
- }), h = (p == null ? void 0 : p.id) != null && p.id !== "" ? String(p.id) : null, { data: E } = N({
162
- queryKey: ["relation-single", s, h ?? "", _],
163
- queryFn: () => te(s, h, _).catch(
171
+ }), b = (p == null ? void 0 : p.id) != null && p.id !== "" ? String(p.id) : null, { data: A } = k({
172
+ queryKey: ["relation-single", s, b ?? "", q],
173
+ queryFn: () => ne(s, b, q).catch(
164
174
  () => null
165
175
  ),
166
- enabled: !!h && x,
176
+ enabled: !!b && g,
167
177
  staleTime: 6e4
168
- }), Ce = JSON.stringify(f ? { _and: [{ id: { _eq: t } }, f] } : { id: { _eq: t } }), { data: z } = N({
169
- queryKey: ["relation-avail", s, String(t), y],
170
- queryFn: () => b.request(
171
- j(`/items/${s}`, {
172
- filter: Ce,
178
+ }), $e = JSON.stringify(f ? { _and: [{ id: { _eq: t } }, f] } : { id: { _eq: t } }), { data: J } = k({
179
+ queryKey: ["relation-avail", s, String(t), x],
180
+ queryFn: () => T.request(
181
+ F(`/items/${s}`, {
182
+ filter: $e,
173
183
  picker: "1",
174
184
  limit: 1,
175
185
  fields: "id"
@@ -178,35 +188,35 @@ function ze({
178
188
  // The pinned option is offered OUTSIDE the option filter (a type's generic
179
189
  // item is excluded from the general list on purpose), so a value that IS
180
190
  // the pin is available by construction — never probe it, never flag it.
181
- enabled: !!t && !!D && String(t) !== h,
191
+ enabled: !!t && !!z && String(t) !== b,
182
192
  staleTime: 3e4
183
- }), O = !!t && String(t) !== h && z !== void 0 && z.length === 0, J = H(null), G = H(!1), ce = `${s}|${y ?? ""}`, $e = () => {
184
- G.current = !0, J.current = ce, d(null);
193
+ }), K = !!t && String(t) !== b && J !== void 0 && J.length === 0, M = H(null), Z = H(!1), ue = `${s}|${x ?? ""}`, Le = () => {
194
+ Z.current = !0, M.current = ue, d(null);
185
195
  }, Q = t == null || t === "";
186
- L(() => {
187
- Q || (G.current = !1);
188
- }, [Q]), L(() => {
189
- if (!m || g || !Q || G.current) return;
190
- const e = ce;
191
- J.current !== e && (J.current = e, b.request(
192
- j(`/items/${s}`, {
196
+ j(() => {
197
+ Q || (Z.current = !1);
198
+ }, [Q]), j(() => {
199
+ if (!m || h || !Q || Z.current) return;
200
+ const e = ue;
201
+ M.current !== e && (M.current = e, T.request(
202
+ F(`/items/${s}`, {
193
203
  limit: 2,
194
204
  picker: "1",
195
205
  fields: "id",
196
- ...y ? { filter: y } : {}
206
+ ...x ? { filter: x } : {}
197
207
  })
198
208
  ).then((i) => {
199
209
  var a;
200
210
  const n = i.data ?? [];
201
211
  n.length === 1 && ((a = n[0]) == null ? void 0 : a.id) != null && d(n[0].id);
202
212
  }).catch(() => {
203
- J.current = null;
213
+ M.current = null;
204
214
  }));
205
- }, [m, g, Q, s, y]);
206
- const q = U, ue = t && D ? v(q, D) : null, Le = !!t && qe && !D, me = De(O), V = Oe();
207
- return L(() => {
208
- !V || !S || z === void 0 || V(S, O);
209
- }, [V, S, O, z]), C ? /* @__PURE__ */ c(
215
+ }, [m, h, Q, s, x]);
216
+ const C = P, me = t && z ? N(C, z) : null, Re = !!t && Ce && !z, pe = Je(K), B = Ae();
217
+ return j(() => {
218
+ !B || !_ || J === void 0 || B(_, K);
219
+ }, [B, _, K, J]), $ ? /* @__PURE__ */ c(
210
220
  "button",
211
221
  {
212
222
  type: "button",
@@ -215,66 +225,66 @@ function ze({
215
225
  children: [
216
226
  /* @__PURE__ */ c("span", { className: "truncate text-muted-foreground", children: [
217
227
  "Select ",
218
- C,
228
+ $,
219
229
  " first"
220
230
  ] }),
221
- /* @__PURE__ */ r(xe, { className: "h-4 w-4 shrink-0 opacity-50" })
231
+ /* @__PURE__ */ r(ye, { className: "h-4 w-4 shrink-0 opacity-50" })
222
232
  ]
223
233
  }
224
234
  ) : (
225
235
  // Stale tooltip binds on the WRAPPER: a disabled trigger button swallows
226
236
  // mouse events, so a locked-but-stale field would never show the hint.
227
- /* @__PURE__ */ c("div", { ref: K, className: "relative", ...me.bind, children: [
237
+ /* @__PURE__ */ c("div", { ref: I, className: "relative", ...pe.bind, children: [
228
238
  /* @__PURE__ */ c(
229
239
  "button",
230
240
  {
231
241
  type: "button",
232
- disabled: g,
233
- onClick: () => R((e) => !e),
234
- className: A(
242
+ disabled: h,
243
+ onClick: () => E((e) => !e),
244
+ className: U(
235
245
  "flex h-9 w-full items-center justify-between gap-2 rounded-md border bg-background px-3 text-sm text-left hover:bg-muted disabled:pointer-events-none disabled:opacity-50",
236
- O ? "border-amber-300 dark:border-amber-600" : "border-input"
246
+ K ? "border-amber-300 dark:border-amber-600" : "border-input"
237
247
  ),
238
248
  children: [
239
- Le ? /* @__PURE__ */ r(B, { className: "h-3.5 w-3.5 animate-spin text-muted-foreground" }) : /* @__PURE__ */ c(
249
+ Re ? /* @__PURE__ */ r(te, { className: "h-3.5 w-3.5 animate-spin text-muted-foreground" }) : /* @__PURE__ */ c(
240
250
  "span",
241
251
  {
242
- className: A(
252
+ className: U(
243
253
  "flex items-center gap-1.5 truncate min-w-0",
244
- !ue && "text-muted-foreground"
254
+ !me && "text-muted-foreground"
245
255
  ),
246
256
  children: [
247
- O && /* @__PURE__ */ r(je, { className: "h-3.5 w-3.5 shrink-0 text-amber-500" }),
248
- /* @__PURE__ */ r("span", { className: "truncate", children: ue ?? w ?? "Select…" })
257
+ K && /* @__PURE__ */ r(je, { className: "h-3.5 w-3.5 shrink-0 text-amber-500" }),
258
+ /* @__PURE__ */ r("span", { className: "truncate", children: me ?? y ?? "Select…" })
249
259
  ]
250
260
  }
251
261
  ),
252
- /* @__PURE__ */ r(xe, { className: "h-4 w-4 shrink-0 opacity-50" })
262
+ /* @__PURE__ */ r(ye, { className: "h-4 w-4 shrink-0 opacity-50" })
253
263
  ]
254
264
  }
255
265
  ),
256
- me.tip,
257
- x && oe && ie && we(
266
+ pe.tip,
267
+ g && le && ae && ve(
258
268
  /* @__PURE__ */ c(
259
269
  "div",
260
270
  {
261
271
  "data-nvr-combobox-panel": "",
262
- style: oe,
263
- className: A(
272
+ style: le,
273
+ className: U(
264
274
  "nvr-pop-in rounded-md border border-border bg-popover shadow-md",
265
275
  o != null && o.length ? "w-[560px] max-w-[92vw]" : "min-w-[240px] w-max max-w-[360px]"
266
276
  ),
267
277
  children: [
268
278
  !!(o != null && o.length) && /* @__PURE__ */ r("div", { className: "grid grid-cols-2 gap-2 border-b border-border bg-slate-50/60 p-2 dark:bg-muted/40", children: o.map((e) => {
269
- const i = Se[e.field];
279
+ const i = _e[e.field];
270
280
  return i ? /* @__PURE__ */ c("div", { children: [
271
281
  /* @__PURE__ */ r("p", { className: "mb-0.5 text-[10px] font-medium uppercase tracking-wide text-slate-400", children: e.label ?? e.field }),
272
282
  /* @__PURE__ */ r(
273
- ze,
283
+ Me,
274
284
  {
275
285
  collection: i,
276
- value: W[e.field] ?? null,
277
- onChange: (n) => ke((a) => ({ ...a, [e.field]: n })),
286
+ value: X[e.field] ?? null,
287
+ onChange: (n) => Se((a) => ({ ...a, [e.field]: n })),
278
288
  placeholder: "Any",
279
289
  optionSort: e.sort,
280
290
  extraFilter: e.filter
@@ -283,59 +293,59 @@ function ze({
283
293
  ] }, e.field) : null;
284
294
  }) }),
285
295
  /* @__PURE__ */ c("div", { className: "flex items-center border-b px-3", children: [
286
- /* @__PURE__ */ r(Re, { className: "mr-2 h-4 w-4 shrink-0 opacity-50" }),
296
+ /* @__PURE__ */ r(Fe, { className: "mr-2 h-4 w-4 shrink-0 opacity-50" }),
287
297
  /* @__PURE__ */ r(
288
298
  "input",
289
299
  {
290
- ref: se,
291
- value: $,
292
- onChange: (e) => re(e.target.value),
300
+ ref: ie,
301
+ value: L,
302
+ onChange: (e) => se(e.target.value),
293
303
  placeholder: "Search…",
294
304
  className: "flex h-9 w-full bg-transparent py-3 text-[13px] outline-none placeholder:text-muted-foreground"
295
305
  }
296
306
  )
297
307
  ] }),
298
308
  /* @__PURE__ */ c("div", { className: "max-h-52 overflow-y-auto py-1", children: [
299
- !!t && !g && /* @__PURE__ */ c(
309
+ !!t && !h && /* @__PURE__ */ c(
300
310
  "button",
301
311
  {
302
312
  type: "button",
303
313
  onClick: () => {
304
- $e(), R(!1);
314
+ Le(), E(!1);
305
315
  },
306
316
  className: "flex w-full items-center gap-2 px-3 py-1.5 text-[13px] text-slate-500 hover:bg-muted border-b border-slate-100 dark:text-slate-400 dark:border-border",
307
317
  children: [
308
- /* @__PURE__ */ r(Fe, { className: "h-3.5 w-3.5 text-slate-400" }),
318
+ /* @__PURE__ */ r(Te, { className: "h-3.5 w-3.5 text-slate-400" }),
309
319
  "Clear selection"
310
320
  ]
311
321
  }
312
322
  ),
313
- h && /* @__PURE__ */ c(
323
+ b && /* @__PURE__ */ c(
314
324
  "button",
315
325
  {
316
326
  type: "button",
317
327
  "data-nvr-pinned-option": !0,
318
328
  onClick: () => {
319
- d((E == null ? void 0 : E.id) ?? (p == null ? void 0 : p.id)), R(!1);
329
+ d((A == null ? void 0 : A.id) ?? (p == null ? void 0 : p.id)), E(!1);
320
330
  },
321
331
  className: "flex w-full items-center gap-2 border-b border-slate-100 bg-nvr-cyan/5 px-3 py-1.5 text-left text-[13px] hover:bg-nvr-cyan/10 dark:border-border",
322
332
  children: [
323
333
  /* @__PURE__ */ r(
324
334
  "div",
325
335
  {
326
- className: A(
336
+ className: U(
327
337
  "flex h-4 w-4 shrink-0 items-center justify-center rounded-full border transition-colors",
328
- String(t) === h ? "border-nvr-cyan bg-nvr-cyan" : "border-slate-300"
338
+ String(t) === b ? "border-nvr-cyan bg-nvr-cyan" : "border-slate-300"
329
339
  ),
330
- children: String(t) === h && /* @__PURE__ */ r(ye, { className: "h-2.5 w-2.5 text-white" })
340
+ children: String(t) === b && /* @__PURE__ */ r(we, { className: "h-2.5 w-2.5 text-white" })
331
341
  }
332
342
  ),
333
- /* @__PURE__ */ r("span", { className: "min-w-0 flex-1 truncate", children: E ? v(q, E) || `#${h}` : `#${h}` }),
343
+ /* @__PURE__ */ r("span", { className: "min-w-0 flex-1 truncate", children: A ? N(C, A) || `#${b}` : `#${b}` }),
334
344
  /* @__PURE__ */ r("span", { className: "shrink-0 rounded bg-nvr-cyan/15 px-1.5 py-0.5 text-[10px] font-semibold uppercase tracking-wide text-slate-700 dark:text-foreground", children: (p == null ? void 0 : p.tag) ?? "Default" })
335
345
  ]
336
346
  }
337
347
  ),
338
- de ? /* @__PURE__ */ r("div", { className: "flex items-center justify-center py-4", children: /* @__PURE__ */ r(B, { className: "h-4 w-4 animate-spin text-muted-foreground" }) }) : (P ?? []).length === 0 ? l && l.labels.length > 0 && !$.trim() ? /* @__PURE__ */ c("div", { className: "px-3 py-2 text-[12px] leading-5 text-muted-foreground", children: [
348
+ V ? /* @__PURE__ */ r("div", { className: "flex items-center justify-center py-4", children: /* @__PURE__ */ r(te, { className: "h-4 w-4 animate-spin text-muted-foreground" }) }) : (v ?? []).length === 0 ? l && l.labels.length > 0 && !L.trim() ? /* @__PURE__ */ c("div", { className: "px-3 py-2 text-[12px] leading-5 text-muted-foreground", children: [
339
349
  /* @__PURE__ */ c("p", { children: [
340
350
  "No options for",
341
351
  " ",
@@ -358,38 +368,38 @@ function ze({
358
368
  },
359
369
  e
360
370
  )) })
361
- ] }) : /* @__PURE__ */ r("p", { className: "px-3 py-2 text-[13px] text-muted-foreground", children: $.trim() ? `No results for “${$.trim()}”` : "No results" }) : (I ? [...P ?? []] : [...P ?? []].sort(
362
- (e, i) => u === "-label" ? v(q, i).localeCompare(v(q, e)) : v(q, e).localeCompare(v(q, i))
363
- )).filter((e) => !h || String(e.id) !== h).map((e) => {
364
- const i = v(q, e) || `#${e.id}`, n = String(e.id) === String(t);
371
+ ] }) : /* @__PURE__ */ r("p", { className: "px-3 py-2 text-[13px] text-muted-foreground", children: L.trim() ? `No results for “${L.trim()}”` : "No results" }) : (D ? [...v ?? []] : [...v ?? []].sort(
372
+ (e, i) => u === "-label" ? N(C, i).localeCompare(N(C, e)) : N(C, e).localeCompare(N(C, i))
373
+ )).filter((e) => !b || String(e.id) !== b).map((e) => {
374
+ const i = N(C, e) || `#${e.id}`, n = String(e.id) === String(t);
365
375
  return /* @__PURE__ */ c(
366
376
  "button",
367
377
  {
368
378
  type: "button",
369
379
  onClick: () => {
370
- d(e.id), R(!1);
380
+ d(e.id), E(!1);
371
381
  },
372
382
  className: "flex w-full items-center gap-2 px-3 py-1.5 text-[13px] text-left hover:bg-muted",
373
383
  children: [
374
384
  /* @__PURE__ */ r(
375
385
  "div",
376
386
  {
377
- className: A(
387
+ className: U(
378
388
  "flex h-4 w-4 shrink-0 items-center justify-center rounded-full border transition-colors",
379
389
  n ? "border-nvr-cyan bg-nvr-cyan" : "border-slate-300"
380
390
  ),
381
- children: n && /* @__PURE__ */ r(ye, { className: "h-2.5 w-2.5 text-white" })
391
+ children: n && /* @__PURE__ */ r(we, { className: "h-2.5 w-2.5 text-white" })
382
392
  }
383
393
  ),
384
- T && /* @__PURE__ */ r(
385
- Ue,
394
+ O && /* @__PURE__ */ r(
395
+ Ie,
386
396
  {
387
397
  userId: e.id,
388
398
  className: "h-4 w-4",
389
- fallback: /* @__PURE__ */ r("span", { className: "flex h-4 w-4 shrink-0 items-center justify-center rounded-full bg-nvr-cyan/20 text-[8px] font-bold text-nvr-navy dark:text-nvr-cyan", children: Pe(i) })
399
+ fallback: /* @__PURE__ */ r("span", { className: "flex h-4 w-4 shrink-0 items-center justify-center rounded-full bg-nvr-cyan/20 text-[8px] font-bold text-nvr-navy dark:text-nvr-cyan", children: ze(i) })
390
400
  }
391
401
  ),
392
- T && _e.has(String(e.id).toUpperCase()) && /* @__PURE__ */ r(
402
+ O && qe.has(String(e.id).toUpperCase()) && /* @__PURE__ */ r(
393
403
  "span",
394
404
  {
395
405
  className: "h-1.5 w-1.5 shrink-0 rounded-full bg-emerald-500",
@@ -403,59 +413,59 @@ function ze({
403
413
  );
404
414
  })
405
415
  ] }),
406
- !de && /* @__PURE__ */ r(
407
- Je,
416
+ !V && /* @__PURE__ */ r(
417
+ Qe,
408
418
  {
409
419
  collection: s,
410
- search: F,
411
- filter: X,
420
+ search: R,
421
+ filter: G,
412
422
  narrowedLabels: (l == null ? void 0 : l.labels) ?? [],
413
- auto: (P ?? []).length === 0 && !!F
423
+ auto: (v ?? []).length === 0 && !!R
414
424
  }
415
425
  )
416
426
  ]
417
427
  }
418
428
  ),
419
- ie
429
+ ae
420
430
  )
421
431
  ] })
422
432
  );
423
433
  }
424
- function Je({
434
+ function Qe({
425
435
  collection: s,
426
436
  search: t,
427
437
  filter: d,
428
- narrowedLabels: g,
429
- auto: w
438
+ narrowedLabels: h,
439
+ auto: y
430
440
  }) {
431
- const f = ee(), [m, u] = k(!1), C = d ? JSON.stringify(d) : "", { data: o, isFetching: S } = N({
432
- queryKey: ["picker-narrowing", s, t, C],
441
+ const f = re(), [m, u] = S(!1), $ = d ? JSON.stringify(d) : "", { data: o, isFetching: _ } = k({
442
+ queryKey: ["picker-narrowing", s, t, $],
433
443
  queryFn: () => f.request(
434
- Ae("/picker-narrowing", { collection: s, search: t, filter: d ?? null })
435
- ).then((b) => b.data),
436
- enabled: m || w,
444
+ Ke("/picker-narrowing", { collection: s, search: t, filter: d ?? null })
445
+ ).then((w) => w.data),
446
+ enabled: m || y,
437
447
  staleTime: 3e4,
438
448
  retry: !1
439
449
  });
440
- if (!m && !w)
450
+ if (!m && !y)
441
451
  return /* @__PURE__ */ r(
442
452
  "button",
443
453
  {
444
454
  type: "button",
445
- onClick: (b) => {
446
- b.stopPropagation(), u(!0);
455
+ onClick: (w) => {
456
+ w.stopPropagation(), u(!0);
447
457
  },
448
458
  className: "w-full border-t border-border px-3 py-1.5 text-left text-[11px] text-muted-foreground hover:text-foreground",
449
459
  "data-picker-narrowing-ask": !0,
450
460
  children: "Missing something?"
451
461
  }
452
462
  );
453
- if (S && !o)
463
+ if (_ && !o)
454
464
  return /* @__PURE__ */ r("p", { className: "border-t border-border px-3 py-1.5 text-[11px] text-muted-foreground", children: "Checking what narrows this list…" });
455
465
  if (!o) return null;
456
466
  const l = [], p = t ? `match “${t}”` : "exist";
457
467
  return o.by_field_filter > 0 && l.push(
458
- `${o.by_field_filter.toLocaleString()} more ${p} but this field only offers ${g.length ? `records that fit ${g.join(" · ")}` : "records its filter allows"}.`
468
+ `${o.by_field_filter.toLocaleString()} more ${p} but this field only offers ${h.length ? `records that fit ${h.join(" · ")}` : "records its filter allows"}.`
459
469
  ), o.by_exclusions > 0 && l.push(
460
470
  `${o.by_exclusions.toLocaleString()} ${o.by_exclusions === 1 ? "is" : "are"} hidden from pickers by an admin.`
461
471
  ), o.scopes.length > 0 && l.push(`Your ${o.scopes.join(", ")} access narrows what you can pick here.`), o.row_filter && l.push("Your role only sees some of these records."), l.length === 0 && l.push(
@@ -467,35 +477,35 @@ function Je({
467
477
  "data-picker-narrowing": !0,
468
478
  "data-picker-narrowing-field": o.by_field_filter,
469
479
  "data-picker-narrowing-excluded": o.by_exclusions,
470
- children: l.map((b) => /* @__PURE__ */ r("p", { children: b }, b))
480
+ children: l.map((w) => /* @__PURE__ */ r("p", { children: w }, w))
471
481
  }
472
482
  );
473
483
  }
474
- function rt({
484
+ function ot({
475
485
  collection: s,
476
486
  id: t,
477
487
  displayTemplate: d
478
488
  }) {
479
- const g = ee(), w = ve(), f = s === "nivaro_files" || s === "directus_files", m = (() => {
489
+ const h = re(), y = Ne(), f = s === "nivaro_files" || s === "directus_files", m = (() => {
480
490
  if (!d || !d.includes(".")) return null;
481
- const o = [...d.matchAll(/\{\{([^}]+)\}\}/g)].map((S) => S[1].trim());
491
+ const o = [...d.matchAll(/\{\{([^}]+)\}\}/g)].map((_) => _[1].trim());
482
492
  return o.length > 0 ? ["id", ...o].join(",") : null;
483
- })(), { data: u, isLoading: C } = N({
493
+ })(), { data: u, isLoading: $ } = k({
484
494
  queryKey: ["relation-single", s, String(t), m ?? ""],
485
- queryFn: () => f ? g.request(j(`/files/${t}`)).then((o) => o.data) : w(s, t, m),
495
+ queryFn: () => f ? h.request(F(`/files/${t}`)).then((o) => o.data) : y(s, t, m),
486
496
  enabled: !!t && !!s,
487
497
  staleTime: 6e4
488
498
  });
489
- if (C) return /* @__PURE__ */ r(B, { className: "h-3 w-3 animate-spin text-slate-400" });
499
+ if ($) return /* @__PURE__ */ r(te, { className: "h-3 w-3 animate-spin text-slate-400" });
490
500
  if (!u) return /* @__PURE__ */ r("span", { children: String(t ?? "") });
491
501
  if (f) {
492
502
  const o = u.title || u.filename_download || u.filename_disk || String(t);
493
503
  return /* @__PURE__ */ r("span", { children: o });
494
504
  }
495
- return /* @__PURE__ */ r("span", { children: v(d, u) });
505
+ return /* @__PURE__ */ r("span", { children: N(d, u) });
496
506
  }
497
507
  export {
498
- rt as RelatedItemLabel,
499
- ze as RelationCombobox,
500
- De as useStaleTip
508
+ ot as RelatedItemLabel,
509
+ Me as RelationCombobox,
510
+ Je as useStaleTip
501
511
  };