@nivaro/react 0.3.110 → 0.3.112
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 +1 -1
- package/dist/index.d.ts +170 -2
- package/dist/index.js +745 -728
- package/dist/shared/components/CollectionBrowserView.js +3097 -2972
- package/dist/shared/components/CollectionImportBanner.js +135 -0
- package/dist/shared/components/ItemEditForm.js +2235 -2218
- package/dist/shared/components/JobsTray.js +54 -47
- package/dist/shared/components/TipLayer.js +61 -54
- package/dist/shared/components/ViewAsPersonButton.js +109 -0
- package/dist/shared/components/bulk/BulkFieldUpdate.js +228 -150
- package/dist/shared/components/bulk/BulkFieldUpdateButton.js +35 -41
- package/dist/shared/components/bulk/BulkLinksValue.js +91 -0
- package/dist/shared/components/bulk/bulk-field-options.js +20 -19
- package/dist/shared/components/bulk/bulk-update-preview.js +39 -0
- package/dist/shared/components/cbv/ColumnHeaderMenu.js +113 -0
- package/dist/shared/components/cbv/column-totals.js +66 -0
- package/dist/shared/components/collections-directory/CollectionHoverCard.js +108 -81
- package/dist/shared/components/collections-directory/CollectionRow.js +164 -148
- package/dist/shared/components/collections-directory/CollectionsDirectory.js +167 -166
- package/dist/shared/components/collections-directory/directory-data.js +70 -58
- package/dist/shared/components/imports/CollectionImportPanel.js +120 -118
- package/dist/shared/components/imports/DefinitionsPanel.js +24 -24
- package/dist/shared/components/imports/ImportDuplicatesNotice.js +65 -0
- package/dist/shared/components/item-edit/CatalogPickerField.js +631 -639
- package/dist/shared/components/item-edit/DuplicateNotice.js +168 -0
- package/dist/shared/components/item-edit/FieldRow.js +248 -246
- package/dist/shared/components/item-edit/InlineGridField.js +34 -33
- package/dist/shared/components/item-edit/InlineTableField.js +3064 -2882
- package/dist/shared/components/item-edit/MembershipSetField.js +165 -169
- package/dist/shared/components/item-edit/NestedRelationEditor.js +184 -189
- package/dist/shared/components/item-edit/PlanGrid.js +2 -1
- package/dist/shared/components/item-edit/QuickPickerDialog.js +35 -34
- package/dist/shared/components/item-edit/RecordLiveSync.js +32 -30
- package/dist/shared/components/item-edit/RelationCombobox.js +101 -100
- package/dist/shared/components/item-edit/RowHistorySheet.js +28 -27
- package/dist/shared/components/item-edit/SummaryPanel.js +133 -135
- package/dist/shared/components/item-edit/ViewAsRole.js +129 -52
- package/dist/shared/components/item-edit/grid-search.js +345 -0
- package/dist/shared/components/item-edit/render-stability.js +61 -54
- package/dist/shared/components/notifications/NotificationRulesEditor.js +25 -20
- package/dist/shared/components/ops-report/DigestSections.js +163 -144
- package/dist/shared/components/ops-report/drill.js +97 -97
- package/dist/shared/components/panels/AddendumLinesDiff.js +52 -51
- package/dist/shared/components/panels/AddendumPanel.js +92 -91
- package/dist/shared/components/panels/AsyncUserPicker.js +108 -0
- package/dist/shared/components/panels/BlockedMove.js +73 -0
- package/dist/shared/components/panels/CommentPanel.js +265 -252
- package/dist/shared/components/panels/OwnersSlot.js +47 -35
- package/dist/shared/components/panels/PipelineInsight.js +186 -0
- package/dist/shared/components/panels/PipelinePanel.js +1573 -1475
- package/dist/shared/components/panels/RecordIntegrityBanner.js +39 -38
- package/dist/shared/components/panels/RevisionsPanel.js +261 -260
- package/dist/shared/components/pipeline/FieldPicker.js +41 -40
- package/dist/shared/components/pipeline/OwnerMatrix.js +829 -700
- package/dist/shared/components/pipeline/OwnerRecordTrial.js +362 -0
- package/dist/shared/components/pipeline/PipelineEditorView.js +483 -467
- package/dist/shared/components/pipeline/PipelineStateOwners.js +65 -64
- package/dist/shared/components/pipeline/owner-matrix-draft.js +178 -0
- package/dist/shared/components/profile/MyDefaultsCard.js +36 -35
- package/dist/shared/components/profile/PersonHeader.js +29 -29
- package/dist/shared/components/profile/PersonProfile.js +30 -28
- package/dist/shared/components/profile/SlowScreensCard.js +286 -0
- package/dist/shared/components/queue/QueueWorklist.js +1090 -1071
- package/dist/shared/components/quick-filters/useQuickFilterEditing.js +45 -44
- package/dist/shared/components/support/TicketDetailSheet.js +25 -16
- package/dist/shared/components/support/TicketSlowScreens.js +32 -0
- package/dist/shared/lib/activity-sentence.js +224 -178
- package/dist/shared/lib/collection-import-banner.js +27 -0
- package/dist/shared/lib/crash-report.js +112 -0
- package/dist/shared/lib/export-runs.js +99 -0
- package/dist/shared/lib/jobs-tray.js +89 -67
- package/dist/shared/lib/list-link.js +76 -69
- package/dist/shared/lib/nav-trail.js +180 -76
- package/dist/shared/lib/query-keys.js +26 -0
- package/dist/shared/lib/view-as.js +16 -11
- package/package.json +1 -1
|
@@ -1,79 +1,155 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import { useQuery as
|
|
3
|
-
import { Eye as
|
|
4
|
-
import { useState as
|
|
5
|
-
import { useNivaroClient as
|
|
6
|
-
import { get as
|
|
7
|
-
import {
|
|
8
|
-
|
|
9
|
-
|
|
1
|
+
import { jsxs as N, jsx as r } from "react/jsx-runtime";
|
|
2
|
+
import { useQuery as y } from "@tanstack/react-query";
|
|
3
|
+
import { Eye as S, X as w } from "lucide-react";
|
|
4
|
+
import { useState as x, useMemo as _ } from "react";
|
|
5
|
+
import { useNivaroClient as R } from "../../context.js";
|
|
6
|
+
import { get as k } from "../../lib/commands.js";
|
|
7
|
+
import { cn as $ } from "../../lib/utils.js";
|
|
8
|
+
import { AsyncUserPicker as q } from "../panels/AsyncUserPicker.js";
|
|
9
|
+
import { SimpleSelectXs as j } from "../ui/SimpleSelect.js";
|
|
10
|
+
import { ViewAsPersonButton as I } from "../ViewAsPersonButton.js";
|
|
11
|
+
function F(s) {
|
|
12
|
+
return s ? [s.first_name, s.last_name].filter(Boolean).join(" ").trim() || s.email || "This person" : "";
|
|
13
|
+
}
|
|
14
|
+
function E(s, c) {
|
|
15
|
+
const m = R(), [t, f] = x(null), [i, a] = x(null), { data: u } = y({
|
|
10
16
|
queryKey: ["nvr-roles-lite"],
|
|
11
|
-
queryFn: () =>
|
|
12
|
-
enabled:
|
|
17
|
+
queryFn: () => m.request(k("/roles")).then((e) => (e.data ?? []).map((d) => ({ id: String(d.id), name: String(d.name) }))),
|
|
18
|
+
enabled: c,
|
|
13
19
|
staleTime: 5 * 6e4
|
|
14
|
-
}), { data:
|
|
15
|
-
queryKey: ["nvr-
|
|
16
|
-
queryFn: () =>
|
|
17
|
-
|
|
18
|
-
|
|
20
|
+
}), { data: l, isFetching: v } = y({
|
|
21
|
+
queryKey: ["nvr-view-as-person", i],
|
|
22
|
+
queryFn: () => m.request(
|
|
23
|
+
k(`/users/${encodeURIComponent(i ?? "")}`)
|
|
24
|
+
).then((e) => {
|
|
25
|
+
const d = e.data;
|
|
26
|
+
if (!d) return null;
|
|
27
|
+
const h = d.role;
|
|
28
|
+
return {
|
|
29
|
+
id: String(d.id),
|
|
30
|
+
first_name: d.first_name ?? null,
|
|
31
|
+
last_name: d.last_name ?? null,
|
|
32
|
+
email: d.email ?? null,
|
|
33
|
+
role: h && typeof h == "object" ? String(h.id ?? "") || null : h ? String(h) : null
|
|
34
|
+
};
|
|
35
|
+
}),
|
|
36
|
+
enabled: c && !!i,
|
|
37
|
+
staleTime: 6e4
|
|
38
|
+
}), o = i ? (l == null ? void 0 : l.role) ?? null : t, { data: n, isFetching: g } = y({
|
|
39
|
+
queryKey: ["nvr-role-preview", s, o],
|
|
40
|
+
queryFn: () => m.request(
|
|
41
|
+
k(
|
|
42
|
+
`/collection-layouts/preview-as-role?collection=${encodeURIComponent(s)}&role_id=${encodeURIComponent(o ?? "")}`
|
|
19
43
|
)
|
|
20
|
-
).then((
|
|
21
|
-
enabled:
|
|
44
|
+
).then((e) => e.data ?? null),
|
|
45
|
+
enabled: c && !!o,
|
|
22
46
|
staleTime: 6e4
|
|
23
|
-
}),
|
|
47
|
+
}), b = _(() => new Set((n == null ? void 0 : n.hidden_fields) ?? []), [n]), p = _(() => new Set((n == null ? void 0 : n.readonly_fields) ?? []), [n]);
|
|
24
48
|
return {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
49
|
+
/** The role the form is previewed as (the person's role in person mode). */
|
|
50
|
+
roleId: o,
|
|
51
|
+
setRoleId: (e) => {
|
|
52
|
+
a(null), f(e);
|
|
53
|
+
},
|
|
54
|
+
/** The person the pipeline is judged as (`?as_user=`), null in role mode. */
|
|
55
|
+
personId: i,
|
|
56
|
+
setPersonId: (e) => {
|
|
57
|
+
f(null), a(e);
|
|
58
|
+
},
|
|
59
|
+
person: i ? l ?? null : null,
|
|
60
|
+
roles: u ?? [],
|
|
61
|
+
preview: o ? n ?? null : null,
|
|
62
|
+
loading: !!i && v && !l || !!o && g && !n,
|
|
63
|
+
hidden: b,
|
|
31
64
|
readonly: p,
|
|
32
|
-
active: !!
|
|
65
|
+
active: !!o || !!i
|
|
33
66
|
};
|
|
34
67
|
}
|
|
35
|
-
function
|
|
36
|
-
roles:
|
|
37
|
-
roleId:
|
|
38
|
-
onChange:
|
|
39
|
-
preview:
|
|
40
|
-
loading:
|
|
68
|
+
function Q({
|
|
69
|
+
roles: s,
|
|
70
|
+
roleId: c,
|
|
71
|
+
onChange: m,
|
|
72
|
+
preview: t,
|
|
73
|
+
loading: f,
|
|
74
|
+
personId: i,
|
|
75
|
+
person: a,
|
|
76
|
+
onPersonChange: u
|
|
41
77
|
}) {
|
|
42
|
-
const l = [];
|
|
43
|
-
|
|
44
|
-
`${
|
|
45
|
-
),
|
|
78
|
+
const [l, v] = x(i ? "person" : "role"), o = [];
|
|
79
|
+
t && (t.can_read ? (t.hidden_fields.length && o.push(
|
|
80
|
+
`${t.hidden_fields.length} field${t.hidden_fields.length === 1 ? "" : "s"} hidden`
|
|
81
|
+
), t.readonly_fields.length && o.push(`${t.readonly_fields.length} read-only`), t.can_update || o.push("no edit permission"), t.layout && o.push(`layout “${t.layout.name}”`)) : o.push("cannot open this collection at all"));
|
|
82
|
+
const n = F(a), g = () => m(null), b = l === "person" ? "Pick a person: their moves and owner checks are judged as them. Nothing is saved or moved." : "Nothing is saved as the role; Save is disabled while previewing.", p = `${f ? l === "person" ? `Resolving what ${n || "this person"} sees…` : "Resolving what this role sees…" : l === "person" && a ? [`Moves and owner checks judged as ${n}`, ...a.role ? o : ["no role"]].join(
|
|
83
|
+
" · "
|
|
84
|
+
) : o.length ? o.join(" · ") : c ? "Same as you — no differences" : b}${t != null && t.note ? ` ${t.note}` : ""}`;
|
|
85
|
+
return /* @__PURE__ */ N(
|
|
46
86
|
"div",
|
|
47
87
|
{
|
|
48
88
|
"data-view-as-role": !0,
|
|
89
|
+
"data-view-as-mode": l,
|
|
49
90
|
className: "mb-2 flex flex-wrap items-center gap-2 rounded-md border border-violet-300 bg-violet-50 px-3 py-1.5 text-[12px] text-violet-900 dark:border-violet-500/40 dark:bg-violet-500/10 dark:text-violet-100",
|
|
50
91
|
children: [
|
|
51
|
-
/* @__PURE__ */
|
|
52
|
-
/* @__PURE__ */
|
|
53
|
-
/* @__PURE__ */
|
|
54
|
-
|
|
92
|
+
/* @__PURE__ */ r(S, { className: "h-3.5 w-3.5 shrink-0 text-violet-600 dark:text-violet-300" }),
|
|
93
|
+
/* @__PURE__ */ r("span", { className: "font-semibold", children: "Viewing as" }),
|
|
94
|
+
u && /* @__PURE__ */ r(
|
|
95
|
+
"fieldset",
|
|
96
|
+
{
|
|
97
|
+
"aria-label": "Preview as",
|
|
98
|
+
className: "m-0 flex min-w-0 shrink-0 overflow-hidden rounded border border-violet-300 p-0 dark:border-violet-500/40",
|
|
99
|
+
children: ["role", "person"].map((e) => /* @__PURE__ */ r(
|
|
100
|
+
"button",
|
|
101
|
+
{
|
|
102
|
+
type: "button",
|
|
103
|
+
"aria-pressed": l === e,
|
|
104
|
+
"data-view-as-mode-pick": e,
|
|
105
|
+
onClick: () => {
|
|
106
|
+
l !== e && (v(e), u == null || u(null));
|
|
107
|
+
},
|
|
108
|
+
className: $(
|
|
109
|
+
"h-6 px-2 text-[11px] font-medium transition-colors",
|
|
110
|
+
l === e ? "bg-violet-600 text-white dark:bg-violet-500" : "text-violet-800 hover:bg-violet-100 dark:text-violet-200 dark:hover:bg-violet-500/20"
|
|
111
|
+
),
|
|
112
|
+
children: e === "role" ? "Role" : "Person"
|
|
113
|
+
},
|
|
114
|
+
e
|
|
115
|
+
))
|
|
116
|
+
}
|
|
117
|
+
),
|
|
118
|
+
l === "person" && u ? /* @__PURE__ */ r("div", { className: "w-56 shrink-0", "data-view-as-person-picker": !0, children: /* @__PURE__ */ r(q, { value: i ?? "", onChange: (e) => u(e || null) }) }) : /* @__PURE__ */ r(
|
|
119
|
+
j,
|
|
55
120
|
{
|
|
56
|
-
value:
|
|
57
|
-
onChange: (
|
|
121
|
+
value: c ?? "",
|
|
122
|
+
onChange: (e) => m(e || null),
|
|
58
123
|
ariaLabel: "Role to preview",
|
|
59
124
|
options: [
|
|
60
125
|
{ value: "", label: "Pick a role…" },
|
|
61
|
-
...
|
|
126
|
+
...s.map((e) => ({ value: e.id, label: e.name }))
|
|
62
127
|
]
|
|
63
128
|
}
|
|
64
129
|
),
|
|
65
|
-
/* @__PURE__ */
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
130
|
+
/* @__PURE__ */ r(
|
|
131
|
+
"span",
|
|
132
|
+
{
|
|
133
|
+
className: "min-w-0 flex-1 truncate text-violet-800/80 dark:text-violet-200/80",
|
|
134
|
+
"data-tip": p,
|
|
135
|
+
children: p
|
|
136
|
+
}
|
|
137
|
+
),
|
|
138
|
+
l === "person" && a && /* @__PURE__ */ r(
|
|
139
|
+
I,
|
|
140
|
+
{
|
|
141
|
+
variant: "text",
|
|
142
|
+
person: { id: a.id, name: n, firstName: a.first_name }
|
|
143
|
+
}
|
|
144
|
+
),
|
|
145
|
+
/* @__PURE__ */ r(
|
|
70
146
|
"button",
|
|
71
147
|
{
|
|
72
148
|
type: "button",
|
|
73
|
-
onClick:
|
|
149
|
+
onClick: g,
|
|
74
150
|
"aria-label": "Stop previewing",
|
|
75
151
|
className: "shrink-0 rounded p-0.5 text-violet-500 hover:bg-violet-100 hover:text-violet-900 dark:hover:bg-violet-500/20",
|
|
76
|
-
children: /* @__PURE__ */
|
|
152
|
+
children: /* @__PURE__ */ r(w, { className: "h-3.5 w-3.5" })
|
|
77
153
|
}
|
|
78
154
|
)
|
|
79
155
|
]
|
|
@@ -81,6 +157,7 @@ function F({
|
|
|
81
157
|
);
|
|
82
158
|
}
|
|
83
159
|
export {
|
|
84
|
-
|
|
85
|
-
|
|
160
|
+
Q as ViewAsRoleBar,
|
|
161
|
+
F as personName,
|
|
162
|
+
E as useViewAsRole
|
|
86
163
|
};
|
|
@@ -0,0 +1,345 @@
|
|
|
1
|
+
import { jsxs as d, jsx as h, Fragment as T } from "react/jsx-runtime";
|
|
2
|
+
import { useQuery as C } from "@tanstack/react-query";
|
|
3
|
+
import { Search as _, X as D, Loader2 as L } from "lucide-react";
|
|
4
|
+
import { useState as v, useEffect as S } from "react";
|
|
5
|
+
import { get as R } from "../../lib/commands.js";
|
|
6
|
+
import { describeError as H } from "../../lib/error-message.js";
|
|
7
|
+
import { numericIntlOptions as k } from "../../lib/format-value.js";
|
|
8
|
+
import { cn as E, toLocalDateString as G, choiceLabel as F } from "../../lib/utils.js";
|
|
9
|
+
const X = 200, K = 10, O = 200;
|
|
10
|
+
function z(e) {
|
|
11
|
+
return [
|
|
12
|
+
...new Set(
|
|
13
|
+
e.toLowerCase().split(/\s+/).map((t) => t.trim()).filter(Boolean)
|
|
14
|
+
)
|
|
15
|
+
];
|
|
16
|
+
}
|
|
17
|
+
function q(e) {
|
|
18
|
+
if (!e.options) return {};
|
|
19
|
+
if (typeof e.options == "string")
|
|
20
|
+
try {
|
|
21
|
+
return JSON.parse(e.options) ?? {};
|
|
22
|
+
} catch {
|
|
23
|
+
return {};
|
|
24
|
+
}
|
|
25
|
+
return e.options;
|
|
26
|
+
}
|
|
27
|
+
const A = /* @__PURE__ */ new Set([
|
|
28
|
+
"integer",
|
|
29
|
+
"bigInteger",
|
|
30
|
+
"decimal",
|
|
31
|
+
"float",
|
|
32
|
+
"money",
|
|
33
|
+
"smallmoney",
|
|
34
|
+
"tinyint",
|
|
35
|
+
"smallint",
|
|
36
|
+
"bigint",
|
|
37
|
+
"int",
|
|
38
|
+
"numeric",
|
|
39
|
+
"real",
|
|
40
|
+
"double",
|
|
41
|
+
"number"
|
|
42
|
+
]);
|
|
43
|
+
function Z(e, t, a = {}) {
|
|
44
|
+
const r = q(e);
|
|
45
|
+
if (e.interface === "relation-path" && r.display === "presence")
|
|
46
|
+
return [t != null && String(t).trim() !== "" ? "Yes" : "No"];
|
|
47
|
+
if (t == null || t === "") return [];
|
|
48
|
+
if (typeof t == "object") return [];
|
|
49
|
+
const n = [String(t)];
|
|
50
|
+
if (a.m2oLabel && n.push(a.m2oLabel), e.type === "boolean" && n.push(t ? "Yes" : "No"), e.type === "date" || e.type === "datetime")
|
|
51
|
+
try {
|
|
52
|
+
n.push(G(t));
|
|
53
|
+
} catch {
|
|
54
|
+
}
|
|
55
|
+
const l = Array.isArray(r.choices) ? r.choices : [];
|
|
56
|
+
for (const o of l)
|
|
57
|
+
o && String(o.value) === String(t) && o.text != null && n.push(F(String(o.text)));
|
|
58
|
+
const i = Number(t);
|
|
59
|
+
if ((A.has(e.type ?? "") || r.format === "currency") && String(t).trim() !== "" && Number.isFinite(i)) {
|
|
60
|
+
n.push(new Intl.NumberFormat("en-US", { maximumFractionDigits: 20 }).format(i));
|
|
61
|
+
const o = r.format;
|
|
62
|
+
try {
|
|
63
|
+
o === "currency" ? n.push(
|
|
64
|
+
i.toLocaleString("en-US", {
|
|
65
|
+
...k(r, "currency"),
|
|
66
|
+
currency: r.currency || "USD"
|
|
67
|
+
})
|
|
68
|
+
) : o === "int" ? n.push(new Intl.NumberFormat("en-US", { maximumFractionDigits: 0 }).format(i)) : (o === "decimal" || o === "number") && n.push(i.toLocaleString("en-US", k(r, "number")));
|
|
69
|
+
} catch {
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
return n;
|
|
73
|
+
}
|
|
74
|
+
function Q(e, t) {
|
|
75
|
+
if (t.length === 0) return !0;
|
|
76
|
+
const a = e.toLowerCase();
|
|
77
|
+
return t.every((r) => a.includes(r));
|
|
78
|
+
}
|
|
79
|
+
function ee(e, t) {
|
|
80
|
+
return t.matches || t.editing ? "show" : e.__prefilled ? "hide" : "dim";
|
|
81
|
+
}
|
|
82
|
+
function te(e, t, a = []) {
|
|
83
|
+
const r = new Set(e.map((l) => String(l.id))), n = [];
|
|
84
|
+
for (const l of [...t ?? [], ...a]) {
|
|
85
|
+
const i = String(l.id);
|
|
86
|
+
l.id == null || r.has(i) || (r.add(i), n.push(l));
|
|
87
|
+
}
|
|
88
|
+
return n;
|
|
89
|
+
}
|
|
90
|
+
function re(e, t) {
|
|
91
|
+
const [a, r] = v(e);
|
|
92
|
+
return S(() => {
|
|
93
|
+
const n = setTimeout(() => r(e), t);
|
|
94
|
+
return () => clearTimeout(n);
|
|
95
|
+
}, [e, t]), a;
|
|
96
|
+
}
|
|
97
|
+
function ne(e) {
|
|
98
|
+
var n, l;
|
|
99
|
+
const t = e.query.trim(), a = JSON.stringify(e.filter), r = C({
|
|
100
|
+
queryKey: ["o2m-grid-search", e.collection, a, t, e.version],
|
|
101
|
+
queryFn: () => e.client.request(
|
|
102
|
+
R(`/items/${e.collection}`, {
|
|
103
|
+
filter: a,
|
|
104
|
+
search: t,
|
|
105
|
+
limit: O
|
|
106
|
+
})
|
|
107
|
+
).then((i) => ({
|
|
108
|
+
rows: i.data ?? [],
|
|
109
|
+
total: typeof i.total == "number" ? i.total : null
|
|
110
|
+
})),
|
|
111
|
+
enabled: e.enabled && t.length > 0,
|
|
112
|
+
staleTime: 3e4,
|
|
113
|
+
// The grid re-reading its rows (an edit, a live update) re-asks the same
|
|
114
|
+
// search: keep showing what was found meanwhile, never a blink. A NEW
|
|
115
|
+
// search starts empty.
|
|
116
|
+
placeholderData: (i, s) => (s == null ? void 0 : s.queryKey[3]) === t ? i : void 0,
|
|
117
|
+
retry: !1
|
|
118
|
+
});
|
|
119
|
+
return {
|
|
120
|
+
rows: e.enabled && t ? (n = r.data) == null ? void 0 : n.rows : void 0,
|
|
121
|
+
total: e.enabled && t ? ((l = r.data) == null ? void 0 : l.total) ?? null : null,
|
|
122
|
+
loading: e.enabled && t.length > 0 && r.isFetching,
|
|
123
|
+
error: e.enabled && t ? r.error : null,
|
|
124
|
+
retry: () => void r.refetch()
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
function ie(e) {
|
|
128
|
+
const t = JSON.stringify(e.filter), a = C({
|
|
129
|
+
queryKey: ["o2m-grid-total", e.collection, t, e.version],
|
|
130
|
+
queryFn: () => e.client.request(
|
|
131
|
+
R(`/items/${e.collection}`, { filter: t, fields: "id", limit: 1 })
|
|
132
|
+
).then((r) => typeof r.total == "number" ? r.total : null),
|
|
133
|
+
enabled: e.enabled,
|
|
134
|
+
staleTime: 6e4,
|
|
135
|
+
placeholderData: (r) => r,
|
|
136
|
+
retry: !1
|
|
137
|
+
});
|
|
138
|
+
return e.enabled ? a.data ?? null : null;
|
|
139
|
+
}
|
|
140
|
+
const b = "nvr-grid-search", ae = `::highlight(${b}){background-color:#fde68a;color:#422006}.dark ::highlight(${b}){background-color:rgba(245,158,11,0.45);color:#fffbeb}`, p = /* @__PURE__ */ new Map();
|
|
141
|
+
function U() {
|
|
142
|
+
if (typeof window > "u") return null;
|
|
143
|
+
const e = window.CSS, t = window.Highlight;
|
|
144
|
+
return !(e != null && e.highlights) || !t ? null : { registry: e.highlights, Ctor: t };
|
|
145
|
+
}
|
|
146
|
+
function y() {
|
|
147
|
+
const e = U();
|
|
148
|
+
if (!e) return;
|
|
149
|
+
const t = [...p.values()].flat();
|
|
150
|
+
t.length === 0 ? e.registry.delete(b) : e.registry.set(b, new e.Ctor(...t));
|
|
151
|
+
}
|
|
152
|
+
function M(e, t, a = 2e3) {
|
|
153
|
+
const r = [];
|
|
154
|
+
if (t.length === 0 || typeof document > "u") return r;
|
|
155
|
+
for (const n of e) {
|
|
156
|
+
const l = document.createTreeWalker(n, NodeFilter.SHOW_TEXT);
|
|
157
|
+
let i = l.nextNode();
|
|
158
|
+
for (; i; ) {
|
|
159
|
+
const s = i.data.toLowerCase();
|
|
160
|
+
for (const o of t) {
|
|
161
|
+
let c = s.indexOf(o);
|
|
162
|
+
for (; c >= 0; ) {
|
|
163
|
+
const m = document.createRange();
|
|
164
|
+
if (m.setStart(i, c), m.setEnd(i, c + o.length), r.push(m), r.length >= a) return r;
|
|
165
|
+
c = s.indexOf(o, c + o.length);
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
i = l.nextNode();
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
return r;
|
|
172
|
+
}
|
|
173
|
+
function oe(e, t, a, r) {
|
|
174
|
+
S(() => {
|
|
175
|
+
const n = t.current;
|
|
176
|
+
if (!n || a.length === 0) {
|
|
177
|
+
p.delete(e) && y();
|
|
178
|
+
return;
|
|
179
|
+
}
|
|
180
|
+
p.set(e, M(n.querySelectorAll(r), a)), y();
|
|
181
|
+
}), S(
|
|
182
|
+
() => () => {
|
|
183
|
+
p.delete(e) && y();
|
|
184
|
+
},
|
|
185
|
+
[e]
|
|
186
|
+
);
|
|
187
|
+
}
|
|
188
|
+
const f = (e) => e.toLocaleString("en-US");
|
|
189
|
+
function le(e) {
|
|
190
|
+
const {
|
|
191
|
+
value: t,
|
|
192
|
+
onChange: a,
|
|
193
|
+
inputRef: r,
|
|
194
|
+
shown: n,
|
|
195
|
+
total: l,
|
|
196
|
+
loaded: i,
|
|
197
|
+
loadedOf: s,
|
|
198
|
+
searching: o,
|
|
199
|
+
loading: c,
|
|
200
|
+
error: m,
|
|
201
|
+
onRetry: x,
|
|
202
|
+
moreMatches: g,
|
|
203
|
+
keptUnsaved: N,
|
|
204
|
+
className: I
|
|
205
|
+
} = e, w = m ? H(m, "Could not search the rest of the rows") : null;
|
|
206
|
+
return /* @__PURE__ */ d(
|
|
207
|
+
"div",
|
|
208
|
+
{
|
|
209
|
+
className: E("flex min-w-0 items-center gap-1.5 text-[11px]", I),
|
|
210
|
+
"data-grid-search": "",
|
|
211
|
+
children: [
|
|
212
|
+
/* @__PURE__ */ d("div", { className: "relative flex items-center", children: [
|
|
213
|
+
/* @__PURE__ */ h(
|
|
214
|
+
_,
|
|
215
|
+
{
|
|
216
|
+
className: "pointer-events-none absolute left-1.5 h-3 w-3 text-slate-400 dark:text-slate-500",
|
|
217
|
+
"aria-hidden": "true"
|
|
218
|
+
}
|
|
219
|
+
),
|
|
220
|
+
/* @__PURE__ */ h(
|
|
221
|
+
"input",
|
|
222
|
+
{
|
|
223
|
+
ref: r,
|
|
224
|
+
type: "search",
|
|
225
|
+
value: t,
|
|
226
|
+
onChange: (u) => a(u.target.value),
|
|
227
|
+
onKeyDown: (u) => {
|
|
228
|
+
u.key === "Escape" && (u.stopPropagation(), u.preventDefault(), t ? a("") : u.currentTarget.blur());
|
|
229
|
+
},
|
|
230
|
+
"aria-label": "Search these rows",
|
|
231
|
+
placeholder: `Search ${f(l)} rows`,
|
|
232
|
+
"data-tip": "Find rows by any column’s text — press / in the table to jump here, Esc to clear",
|
|
233
|
+
className: "h-6 w-[190px] rounded border border-slate-200 bg-white pl-5 pr-5 text-[11px] text-slate-700 placeholder:text-slate-400 focus:outline-none focus:ring-1 focus:ring-nvr-cyan dark:border-border dark:bg-background dark:text-slate-200 dark:placeholder:text-slate-500 [&::-webkit-search-cancel-button]:hidden"
|
|
234
|
+
}
|
|
235
|
+
),
|
|
236
|
+
t && /* @__PURE__ */ h(
|
|
237
|
+
"button",
|
|
238
|
+
{
|
|
239
|
+
type: "button",
|
|
240
|
+
"aria-label": "Clear search",
|
|
241
|
+
onClick: () => {
|
|
242
|
+
var u;
|
|
243
|
+
a(""), (u = r.current) == null || u.focus();
|
|
244
|
+
},
|
|
245
|
+
className: "absolute right-1 rounded p-px text-slate-400 hover:text-slate-700 dark:hover:text-slate-200",
|
|
246
|
+
children: /* @__PURE__ */ h(D, { className: "h-3 w-3", "aria-hidden": "true" })
|
|
247
|
+
}
|
|
248
|
+
)
|
|
249
|
+
] }),
|
|
250
|
+
/* @__PURE__ */ h(
|
|
251
|
+
"span",
|
|
252
|
+
{
|
|
253
|
+
className: "whitespace-nowrap tabular-nums text-slate-500 dark:text-slate-400",
|
|
254
|
+
"aria-live": "polite",
|
|
255
|
+
"data-grid-search-count": o ? n : void 0,
|
|
256
|
+
children: o ? /* @__PURE__ */ d(T, { children: [
|
|
257
|
+
f(n),
|
|
258
|
+
" of ",
|
|
259
|
+
f(l),
|
|
260
|
+
" rows",
|
|
261
|
+
N ? /* @__PURE__ */ d(
|
|
262
|
+
"span",
|
|
263
|
+
{
|
|
264
|
+
className: "ml-1 text-slate-400 dark:text-slate-500",
|
|
265
|
+
"data-tip": "Unsaved rows stay in view while you search",
|
|
266
|
+
children: [
|
|
267
|
+
"· ",
|
|
268
|
+
N,
|
|
269
|
+
" unsaved kept"
|
|
270
|
+
]
|
|
271
|
+
}
|
|
272
|
+
) : null
|
|
273
|
+
] }) : i != null && s != null && i < s ? /* @__PURE__ */ d(
|
|
274
|
+
"span",
|
|
275
|
+
{
|
|
276
|
+
"data-tip": `This table loads the first ${f(i)} rows — search finds the rest`,
|
|
277
|
+
children: [
|
|
278
|
+
f(i),
|
|
279
|
+
" of ",
|
|
280
|
+
f(s),
|
|
281
|
+
" loaded"
|
|
282
|
+
]
|
|
283
|
+
}
|
|
284
|
+
) : null
|
|
285
|
+
}
|
|
286
|
+
),
|
|
287
|
+
o && c && /* @__PURE__ */ d("span", { className: "inline-flex items-center gap-1 whitespace-nowrap text-slate-400 dark:text-slate-500", children: [
|
|
288
|
+
/* @__PURE__ */ h(L, { className: "h-3 w-3 animate-spin", "aria-hidden": "true" }),
|
|
289
|
+
"Searching all rows…"
|
|
290
|
+
] }),
|
|
291
|
+
o && !c && g != null && g > 0 && /* @__PURE__ */ d(
|
|
292
|
+
"span",
|
|
293
|
+
{
|
|
294
|
+
className: "whitespace-nowrap text-amber-700 dark:text-amber-300",
|
|
295
|
+
"data-tip": "Only the first matches are shown — add a word to narrow the search",
|
|
296
|
+
children: [
|
|
297
|
+
f(g),
|
|
298
|
+
" more ",
|
|
299
|
+
g === 1 ? "match" : "matches",
|
|
300
|
+
" — narrow it"
|
|
301
|
+
]
|
|
302
|
+
}
|
|
303
|
+
),
|
|
304
|
+
o && !c && w && /* @__PURE__ */ d(
|
|
305
|
+
"span",
|
|
306
|
+
{
|
|
307
|
+
className: "inline-flex items-center gap-1 whitespace-nowrap text-amber-700 dark:text-amber-300",
|
|
308
|
+
"data-tip": w.hint,
|
|
309
|
+
role: "status",
|
|
310
|
+
children: [
|
|
311
|
+
w.title,
|
|
312
|
+
x && /* @__PURE__ */ h(
|
|
313
|
+
"button",
|
|
314
|
+
{
|
|
315
|
+
type: "button",
|
|
316
|
+
onClick: x,
|
|
317
|
+
className: "rounded px-1 font-medium underline decoration-dotted underline-offset-2 hover:text-amber-900 dark:hover:text-amber-100",
|
|
318
|
+
children: "Retry"
|
|
319
|
+
}
|
|
320
|
+
)
|
|
321
|
+
]
|
|
322
|
+
}
|
|
323
|
+
)
|
|
324
|
+
]
|
|
325
|
+
}
|
|
326
|
+
);
|
|
327
|
+
}
|
|
328
|
+
export {
|
|
329
|
+
X as GRID_READ_LIMIT,
|
|
330
|
+
b as GRID_SEARCH_HIGHLIGHT,
|
|
331
|
+
ae as GRID_SEARCH_HIGHLIGHT_CSS,
|
|
332
|
+
O as GRID_SEARCH_LIMIT,
|
|
333
|
+
K as GRID_SEARCH_MIN_ROWS,
|
|
334
|
+
le as GridSearchBox,
|
|
335
|
+
Z as cellSearchTexts,
|
|
336
|
+
te as extraSearchRows,
|
|
337
|
+
M as matchRanges,
|
|
338
|
+
ee as pendingRowVisibility,
|
|
339
|
+
z as searchWords,
|
|
340
|
+
Q as textMatchesWords,
|
|
341
|
+
re as useDebouncedValue,
|
|
342
|
+
ie as useGridChildTotal,
|
|
343
|
+
oe as useGridSearchHighlight,
|
|
344
|
+
ne as useGridServerSearch
|
|
345
|
+
};
|