@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.
- package/dist/full.css +1 -1
- package/dist/hooks/useSessionRecorder.js +99 -98
- package/dist/index.d.ts +367 -2
- package/dist/index.js +645 -616
- package/dist/layout-editor.d.ts +4 -0
- package/dist/shared/components/BackgroundRunOffer.js +117 -0
- package/dist/shared/components/BroadcastView.js +214 -213
- package/dist/shared/components/CollectionBrowserView.js +2592 -2695
- package/dist/shared/components/ItemEditForm.js +4066 -3832
- package/dist/shared/components/JobsTray.js +100 -55
- package/dist/shared/components/MyWorkView.js +91 -89
- package/dist/shared/components/NotificationBell.js +80 -79
- package/dist/shared/components/ProfileView.js +568 -520
- package/dist/shared/components/RecordCompare.js +254 -0
- package/dist/shared/components/RecordReadView.js +599 -552
- package/dist/shared/components/ReportView.js +578 -543
- package/dist/shared/components/RowPresence.js +91 -0
- package/dist/shared/components/WidgetSlot.js +474 -458
- package/dist/shared/components/ai/AiAnalyticsView.js +16 -6
- package/dist/shared/components/ai/AskPanel.js +139 -119
- package/dist/shared/components/ai/FirstWeekCard.js +126 -0
- package/dist/shared/components/bulk/BulkFieldUpdate.js +289 -0
- package/dist/shared/components/bulk/bulk-field-options.js +45 -0
- package/dist/shared/components/charts/CumulativeFlowChart.js +176 -0
- package/dist/shared/components/chat/ChannelArchive.js +326 -0
- package/dist/shared/components/chat/ChannelExtras.js +141 -121
- package/dist/shared/components/chat/ChatAnalyticsView.js +112 -110
- package/dist/shared/components/chat/ChatPanel.js +1695 -1733
- package/dist/shared/components/chat/Composer.js +357 -303
- package/dist/shared/components/chat/MessageActions.js +92 -0
- package/dist/shared/components/chat/MessageFormat.js +290 -264
- package/dist/shared/components/chat/OutboxBubbles.js +146 -0
- package/dist/shared/components/chat/RequestIdCard.js +135 -0
- package/dist/shared/components/chat/RoomHeaderMenu.js +202 -0
- package/dist/shared/components/chat/RoomParts.js +213 -274
- package/dist/shared/components/chat/ScreenClip.js +184 -0
- package/dist/shared/components/chat/chat-core.js +402 -483
- package/dist/shared/components/chat/chat-drafts.js +59 -0
- package/dist/shared/components/chat/chat-emoji.js +348 -0
- package/dist/shared/components/chat/chat-local-time.js +41 -0
- package/dist/shared/components/chat/chat-outbox.js +303 -0
- package/dist/shared/components/chat/chat-window.js +163 -0
- package/dist/shared/components/chat/huddle/HuddleControls.js +143 -0
- package/dist/shared/components/chat/huddle/HuddleStage.js +164 -0
- package/dist/shared/components/chat/huddle/huddle-store.js +342 -0
- package/dist/shared/components/chat/huddle/useHuddle.js +58 -0
- package/dist/shared/components/help-videos/api.js +76 -73
- package/dist/shared/components/item-edit/CatalogPickerField.js +113 -112
- package/dist/shared/components/item-edit/ChangeReasonDialog.js +13 -13
- package/dist/shared/components/item-edit/FieldAffordances.js +2 -2
- package/dist/shared/components/item-edit/FieldRenderer.js +248 -245
- package/dist/shared/components/item-edit/FieldRow.js +292 -279
- package/dist/shared/components/item-edit/GroupSection.js +698 -574
- package/dist/shared/components/item-edit/InlineTableField.js +3 -1
- package/dist/shared/components/item-edit/RelationCombobox.js +186 -176
- package/dist/shared/components/item-edit/entry/EntryStrip.js +54 -0
- package/dist/shared/components/item-edit/entry/entry-keys.js +27 -0
- package/dist/shared/components/item-edit/entry/useEntryKeyboard.js +70 -0
- package/dist/shared/components/item-edit/entry/useEntryMode.js +59 -0
- package/dist/shared/components/item-edit/form-structure-ui.js +105 -0
- package/dist/shared/components/item-edit/lazy-sections.js +36 -0
- package/dist/shared/components/item-edit/lock-why.js +39 -32
- package/dist/shared/components/item-edit/picker-miss.js +26 -0
- package/dist/shared/components/item-edit/placement-behaviour.js +196 -0
- package/dist/shared/components/item-edit/useFormUsageBeacon.js +51 -45
- package/dist/shared/components/layout-editor/AddPanel.js +134 -117
- package/dist/shared/components/layout-editor/ChangeNote.js +25 -24
- package/dist/shared/components/layout-editor/CollabParts.js +80 -75
- package/dist/shared/components/layout-editor/DesignNode.js +126 -120
- package/dist/shared/components/layout-editor/EditorCanvas.js +30 -27
- package/dist/shared/components/layout-editor/EditorTopBar.js +203 -192
- package/dist/shared/components/layout-editor/HistoryPanel.js +120 -104
- package/dist/shared/components/layout-editor/LayoutEditor.js +768 -671
- package/dist/shared/components/layout-editor/RestorePiece.js +143 -0
- package/dist/shared/components/layout-editor/StagedChip.js +22 -0
- package/dist/shared/components/layout-editor/StructureMenu.js +237 -186
- package/dist/shared/components/layout-editor/collab/FormFollowShare.js +149 -103
- package/dist/shared/components/layout-editor/collab/collab-api.js +29 -26
- package/dist/shared/components/layout-editor/dnd/LayoutDndProvider.js +81 -80
- package/dist/shared/components/layout-editor/dnd/node.js +69 -57
- package/dist/shared/components/layout-editor/draft-recovery.js +113 -43
- package/dist/shared/components/layout-editor/entry/PlacementPresets.js +149 -0
- package/dist/shared/components/layout-editor/entry/entry-editor-context.js +10 -0
- package/dist/shared/components/layout-editor/entry/presets.js +71 -0
- package/dist/shared/components/layout-editor/entry/tab-order.js +110 -0
- package/dist/shared/components/layout-editor/entry/theme-preview.js +37 -0
- package/dist/shared/components/layout-editor/grid-guides.js +142 -0
- package/dist/shared/components/layout-editor/inspector/BehaviourSettings.js +402 -0
- package/dist/shared/components/layout-editor/inspector/BulkInspector.js +61 -57
- package/dist/shared/components/layout-editor/inspector/GroupInspector.js +247 -151
- package/dist/shared/components/layout-editor/inspector/Inspector.js +176 -155
- package/dist/shared/components/layout-editor/inspector/LookTab.js +167 -116
- package/dist/shared/components/layout-editor/inspector/PickerMisses.js +129 -0
- package/dist/shared/components/layout-editor/inspector/PickerTab.js +84 -82
- package/dist/shared/components/layout-editor/inspector/RulesTab.js +66 -62
- package/dist/shared/components/layout-editor/inspector/kit.js +69 -68
- package/dist/shared/components/layout-editor/outputs/OutputsButton.js +254 -0
- package/dist/shared/components/layout-editor/outputs/help-sheet.js +154 -0
- package/dist/shared/components/layout-editor/outputs/output-api.js +61 -0
- package/dist/shared/components/layout-editor/overview/describe-conditions.js +6 -0
- package/dist/shared/components/layout-editor/overview/purpose.js +15 -13
- package/dist/shared/components/layout-editor/parity-keys.json.js +1 -1
- package/dist/shared/components/layout-editor/restore-piece.js +192 -0
- package/dist/shared/components/layout-editor/section-structure.js +241 -0
- package/dist/shared/components/layout-editor/settings/EntrySection.js +296 -0
- package/dist/shared/components/layout-editor/settings/FormSettings.js +41 -39
- package/dist/shared/components/layout-editor/settings/ResolveSettings.js +255 -0
- package/dist/shared/components/layout-editor/settings/ToolsSection.js +147 -111
- package/dist/shared/components/layout-editor/settings/WhoSection.js +29 -26
- package/dist/shared/components/layout-editor/settings/settings-registry.js +114 -17
- package/dist/shared/components/layout-editor/staged-api.js +64 -0
- package/dist/shared/components/layout-editor/structure-ops.js +81 -77
- package/dist/shared/components/layout-editor/testing/TestingPanels.js +65 -60
- package/dist/shared/components/layout-editor/testing/testing-model.js +198 -185
- package/dist/shared/components/layout-editor/toolbar-kit.js +11 -11
- package/dist/shared/components/layout-editor/usage/AbTestSection.js +355 -0
- package/dist/shared/components/layout-editor/usage/UsagePanel.js +144 -70
- package/dist/shared/components/layout-editor/usage/ab-api.js +86 -0
- package/dist/shared/components/layout-editor/usage/suggest-collapse.js +32 -0
- package/dist/shared/components/layout-editor/useLayoutDraft.js +25 -24
- package/dist/shared/components/notifications/NotificationAnalyticsView.js +148 -77
- package/dist/shared/components/panels/ErpFailureBanner.js +18 -17
- package/dist/shared/components/panels/ExternalRequestsChip.js +63 -62
- package/dist/shared/components/pipeline/PipelineEditorView.js +106 -104
- package/dist/shared/components/profile/AgentsPanel.js +479 -0
- package/dist/shared/components/queue/QueueWorklist.js +1026 -1040
- package/dist/shared/components/support/SupportAnalytics.js +171 -0
- package/dist/shared/components/support/SupportView.js +75 -73
- package/dist/shared/lib/background-runs.js +150 -0
- package/dist/shared/lib/delivery-ack.js +9 -0
- package/dist/shared/lib/entry-badge-style.js +13 -0
- package/dist/shared/lib/entry-config.js +71 -0
- package/dist/shared/lib/form-sections.js +64 -0
- package/dist/shared/lib/form-structure.js +99 -0
- package/dist/shared/lib/form-usage-beacon.js +101 -52
- package/dist/shared/lib/jobs-tray.js +25 -23
- package/dist/shared/lib/keyset-pager.js +37 -0
- package/dist/shared/lib/layout-ops.js +84 -82
- package/dist/shared/lib/layout-resolve.js +113 -0
- package/dist/shared/lib/placement-behaviour.js +144 -0
- package/dist/shared/lib/prefetch.js +149 -0
- package/dist/shared/lib/presence-hooks.js +199 -0
- package/dist/shared/lib/record-outbox.js +82 -81
- package/dist/shared/lib/replay-socket.js +93 -0
- package/dist/shared/lib/request-gate.js +51 -50
- package/dist/shared/lib/room-gaps.js +96 -0
- package/dist/shared/lib/search-log.js +27 -0
- package/dist/shared/lib/socket-realtime.js +101 -80
- package/dist/shared/lib/stale-chunk.js +60 -0
- package/dist/shared/lib/worker-socket.js +200 -0
- 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
|
|
3
|
-
import { ChevronDown as
|
|
4
|
-
import { useState as
|
|
5
|
-
import { createPortal as
|
|
6
|
-
import { useNivaroClient as
|
|
7
|
-
import { get as
|
|
8
|
-
import { useRecordReader as
|
|
9
|
-
import { useOnlineUsers as
|
|
10
|
-
import { UserAvatar as
|
|
11
|
-
import { userOptionFilter as
|
|
12
|
-
import { applyDisplayTemplate as
|
|
13
|
-
|
|
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
|
|
17
|
-
const [t, d] =
|
|
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
|
-
},
|
|
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:
|
|
36
|
+
return { bind: h, tip: y };
|
|
36
37
|
}
|
|
37
|
-
function
|
|
38
|
+
function Me({
|
|
38
39
|
collection: s,
|
|
39
40
|
value: t,
|
|
40
41
|
onChange: d,
|
|
41
|
-
disabled:
|
|
42
|
-
placeholder:
|
|
42
|
+
disabled: h,
|
|
43
|
+
placeholder: y,
|
|
43
44
|
extraFilter: f,
|
|
44
45
|
autoSelectSingle: m,
|
|
45
46
|
optionSort: u,
|
|
46
|
-
requiredParent:
|
|
47
|
+
requiredParent: $,
|
|
47
48
|
facets: o,
|
|
48
|
-
fieldKey:
|
|
49
|
+
fieldKey: _,
|
|
49
50
|
narrowedBy: l,
|
|
50
|
-
pinned: p
|
|
51
|
+
pinned: p,
|
|
52
|
+
missPlacement: w
|
|
51
53
|
}) {
|
|
52
|
-
const
|
|
53
|
-
|
|
54
|
-
|
|
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 =
|
|
57
|
-
}, 30) : (
|
|
58
|
-
}, [
|
|
59
|
-
const e = setTimeout(() =>
|
|
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
|
-
}, [
|
|
62
|
-
if (!
|
|
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]") ||
|
|
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
|
-
}, [
|
|
70
|
-
const [
|
|
71
|
-
|
|
72
|
-
if (!
|
|
73
|
-
|
|
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 =
|
|
79
|
+
const i = I.current;
|
|
78
80
|
if (!i) return;
|
|
79
81
|
const n = i.getBoundingClientRect(), a = i.closest('[role="dialog"]') ?? document.body;
|
|
80
|
-
|
|
81
|
-
const
|
|
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
|
-
...
|
|
86
|
+
...fe ? { transform: "translateY(-100%)" } : {}
|
|
85
87
|
};
|
|
86
88
|
if (a === document.body)
|
|
87
|
-
|
|
89
|
+
Y({ position: "fixed", left: be, top: he, ...ge });
|
|
88
90
|
else {
|
|
89
|
-
const
|
|
90
|
-
|
|
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
|
-
}, [
|
|
97
|
-
const { data:
|
|
98
|
+
}, [g]);
|
|
99
|
+
const { data: W } = k({
|
|
98
100
|
queryKey: ["col-meta", s],
|
|
99
|
-
queryFn: () =>
|
|
101
|
+
queryFn: () => T.request(F(`/collections/${s}`)).then((e) => e.data),
|
|
100
102
|
staleTime: 3e5,
|
|
101
103
|
retry: !1
|
|
102
|
-
}), [
|
|
104
|
+
}), [X, Se] = S({}), { data: de = [] } = k({
|
|
103
105
|
queryKey: ["collection-meta", s],
|
|
104
|
-
queryFn: () =>
|
|
105
|
-
|
|
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
|
-
}),
|
|
116
|
+
}), _e = ee(() => {
|
|
115
117
|
const e = {};
|
|
116
118
|
for (const i of o ?? []) {
|
|
117
|
-
const n =
|
|
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,
|
|
125
|
+
}, [o, de, s]), O = s === "nivaro_users", qe = Ue(O), ce = Oe().isAdmin, G = ee(() => {
|
|
124
126
|
const e = [];
|
|
125
|
-
|
|
126
|
-
for (const [i, n] of Object.entries(
|
|
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,
|
|
131
|
-
if (!
|
|
132
|
-
const e = [...
|
|
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
|
-
}, [
|
|
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
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
141
|
+
R,
|
|
142
|
+
x,
|
|
143
|
+
q,
|
|
144
|
+
D ?? ""
|
|
143
145
|
],
|
|
144
|
-
queryFn: () =>
|
|
145
|
-
|
|
146
|
+
queryFn: () => T.request(
|
|
147
|
+
F(`/items/${s}`, {
|
|
146
148
|
limit: 200,
|
|
147
149
|
picker: "1",
|
|
148
|
-
...
|
|
149
|
-
...
|
|
150
|
-
...
|
|
151
|
-
...
|
|
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:
|
|
155
|
-
staleTime:
|
|
156
|
-
})
|
|
157
|
-
|
|
158
|
-
|
|
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
|
-
}),
|
|
162
|
-
queryKey: ["relation-single", s,
|
|
163
|
-
queryFn: () =>
|
|
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: !!
|
|
176
|
+
enabled: !!b && g,
|
|
167
177
|
staleTime: 6e4
|
|
168
|
-
}),
|
|
169
|
-
queryKey: ["relation-avail", s, String(t),
|
|
170
|
-
queryFn: () =>
|
|
171
|
-
|
|
172
|
-
filter:
|
|
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 && !!
|
|
191
|
+
enabled: !!t && !!z && String(t) !== b,
|
|
182
192
|
staleTime: 3e4
|
|
183
|
-
}),
|
|
184
|
-
|
|
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
|
-
|
|
187
|
-
Q || (
|
|
188
|
-
}, [Q]),
|
|
189
|
-
if (!m ||
|
|
190
|
-
const e =
|
|
191
|
-
|
|
192
|
-
|
|
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
|
-
...
|
|
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
|
-
|
|
213
|
+
M.current = null;
|
|
204
214
|
}));
|
|
205
|
-
}, [m,
|
|
206
|
-
const
|
|
207
|
-
return
|
|
208
|
-
!
|
|
209
|
-
}, [
|
|
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
|
-
|
|
228
|
+
$,
|
|
219
229
|
" first"
|
|
220
230
|
] }),
|
|
221
|
-
/* @__PURE__ */ r(
|
|
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:
|
|
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:
|
|
233
|
-
onClick: () =>
|
|
234
|
-
className:
|
|
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
|
-
|
|
246
|
+
K ? "border-amber-300 dark:border-amber-600" : "border-input"
|
|
237
247
|
),
|
|
238
248
|
children: [
|
|
239
|
-
|
|
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:
|
|
252
|
+
className: U(
|
|
243
253
|
"flex items-center gap-1.5 truncate min-w-0",
|
|
244
|
-
!
|
|
254
|
+
!me && "text-muted-foreground"
|
|
245
255
|
),
|
|
246
256
|
children: [
|
|
247
|
-
|
|
248
|
-
/* @__PURE__ */ r("span", { className: "truncate", children:
|
|
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(
|
|
262
|
+
/* @__PURE__ */ r(ye, { className: "h-4 w-4 shrink-0 opacity-50" })
|
|
253
263
|
]
|
|
254
264
|
}
|
|
255
265
|
),
|
|
256
|
-
|
|
257
|
-
|
|
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:
|
|
263
|
-
className:
|
|
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 =
|
|
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
|
-
|
|
283
|
+
Me,
|
|
274
284
|
{
|
|
275
285
|
collection: i,
|
|
276
|
-
value:
|
|
277
|
-
onChange: (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(
|
|
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:
|
|
291
|
-
value:
|
|
292
|
-
onChange: (e) =>
|
|
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 && !
|
|
309
|
+
!!t && !h && /* @__PURE__ */ c(
|
|
300
310
|
"button",
|
|
301
311
|
{
|
|
302
312
|
type: "button",
|
|
303
313
|
onClick: () => {
|
|
304
|
-
|
|
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(
|
|
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
|
-
|
|
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((
|
|
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:
|
|
336
|
+
className: U(
|
|
327
337
|
"flex h-4 w-4 shrink-0 items-center justify-center rounded-full border transition-colors",
|
|
328
|
-
String(t) ===
|
|
338
|
+
String(t) === b ? "border-nvr-cyan bg-nvr-cyan" : "border-slate-300"
|
|
329
339
|
),
|
|
330
|
-
children: String(t) ===
|
|
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:
|
|
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
|
-
|
|
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:
|
|
362
|
-
(e, i) => u === "-label" ?
|
|
363
|
-
)).filter((e) => !
|
|
364
|
-
const i =
|
|
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),
|
|
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:
|
|
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(
|
|
391
|
+
children: n && /* @__PURE__ */ r(we, { className: "h-2.5 w-2.5 text-white" })
|
|
382
392
|
}
|
|
383
393
|
),
|
|
384
|
-
|
|
385
|
-
|
|
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:
|
|
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
|
-
|
|
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
|
-
!
|
|
407
|
-
|
|
416
|
+
!V && /* @__PURE__ */ r(
|
|
417
|
+
Qe,
|
|
408
418
|
{
|
|
409
419
|
collection: s,
|
|
410
|
-
search:
|
|
411
|
-
filter:
|
|
420
|
+
search: R,
|
|
421
|
+
filter: G,
|
|
412
422
|
narrowedLabels: (l == null ? void 0 : l.labels) ?? [],
|
|
413
|
-
auto: (
|
|
423
|
+
auto: (v ?? []).length === 0 && !!R
|
|
414
424
|
}
|
|
415
425
|
)
|
|
416
426
|
]
|
|
417
427
|
}
|
|
418
428
|
),
|
|
419
|
-
|
|
429
|
+
ae
|
|
420
430
|
)
|
|
421
431
|
] })
|
|
422
432
|
);
|
|
423
433
|
}
|
|
424
|
-
function
|
|
434
|
+
function Qe({
|
|
425
435
|
collection: s,
|
|
426
436
|
search: t,
|
|
427
437
|
filter: d,
|
|
428
|
-
narrowedLabels:
|
|
429
|
-
auto:
|
|
438
|
+
narrowedLabels: h,
|
|
439
|
+
auto: y
|
|
430
440
|
}) {
|
|
431
|
-
const f =
|
|
432
|
-
queryKey: ["picker-narrowing", s, t,
|
|
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
|
-
|
|
435
|
-
).then((
|
|
436
|
-
enabled: m ||
|
|
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 && !
|
|
450
|
+
if (!m && !y)
|
|
441
451
|
return /* @__PURE__ */ r(
|
|
442
452
|
"button",
|
|
443
453
|
{
|
|
444
454
|
type: "button",
|
|
445
|
-
onClick: (
|
|
446
|
-
|
|
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 (
|
|
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 ${
|
|
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((
|
|
480
|
+
children: l.map((w) => /* @__PURE__ */ r("p", { children: w }, w))
|
|
471
481
|
}
|
|
472
482
|
);
|
|
473
483
|
}
|
|
474
|
-
function
|
|
484
|
+
function ot({
|
|
475
485
|
collection: s,
|
|
476
486
|
id: t,
|
|
477
487
|
displayTemplate: d
|
|
478
488
|
}) {
|
|
479
|
-
const
|
|
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((
|
|
491
|
+
const o = [...d.matchAll(/\{\{([^}]+)\}\}/g)].map((_) => _[1].trim());
|
|
482
492
|
return o.length > 0 ? ["id", ...o].join(",") : null;
|
|
483
|
-
})(), { data: u, isLoading:
|
|
493
|
+
})(), { data: u, isLoading: $ } = k({
|
|
484
494
|
queryKey: ["relation-single", s, String(t), m ?? ""],
|
|
485
|
-
queryFn: () => f ?
|
|
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 (
|
|
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:
|
|
505
|
+
return /* @__PURE__ */ r("span", { children: N(d, u) });
|
|
496
506
|
}
|
|
497
507
|
export {
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
508
|
+
ot as RelatedItemLabel,
|
|
509
|
+
Me as RelationCombobox,
|
|
510
|
+
Je as useStaleTip
|
|
501
511
|
};
|