@nivaro/react 0.3.53 → 0.3.55
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/hooks/useSessionRecorder.js +1 -1
- package/dist/shared/components/ItemEditForm.js +3350 -3347
- package/dist/shared/components/PageRenderer.js +397 -396
- package/dist/shared/components/item-edit/DraftRecoveryBanner.js +52 -54
- package/dist/shared/components/item-edit/PersonalDefaultControl.js +12 -11
- package/dist/shared/components/item-edit/RelationCombobox.js +23 -20
- package/dist/shared/components/item-edit/SummaryPanel.js +358 -318
- package/dist/shared/components/item-edit/save-outcome.js +48 -0
- package/dist/shared/components/item-edit/stale-banner.js +13 -0
- package/dist/shared/components/item-edit/usePersonalDefaults.js +116 -114
- package/dist/shared/lib/draft-store.js +35 -29
- package/dist/shared/lib/error-hints.js +1 -0
- package/dist/shared/lib/page-widget-access.js +11 -0
- package/package.json +1 -1
|
@@ -1,28 +1,29 @@
|
|
|
1
|
-
import { jsx as t, jsxs as x, Fragment as
|
|
1
|
+
import { jsx as t, jsxs as x, Fragment as B } from "react/jsx-runtime";
|
|
2
2
|
import { useQuery as z, useQueryClient as He } from "@tanstack/react-query";
|
|
3
|
-
import { useState as q, useEffect as
|
|
3
|
+
import { useState as q, useEffect as X, useRef as D, useMemo as Re, useCallback as Ye } from "react";
|
|
4
4
|
import { createPortal as Xe } from "react-dom";
|
|
5
|
-
import { useNivaroClient as K, useDrilldown as
|
|
6
|
-
import { useDebounced as
|
|
7
|
-
import { get as Fe, post as
|
|
8
|
-
import { describeError as
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
18
|
-
import {
|
|
19
|
-
import {
|
|
20
|
-
import {
|
|
21
|
-
import {
|
|
22
|
-
import {
|
|
23
|
-
import {
|
|
5
|
+
import { useNivaroClient as K, useItemEditAuth as Ze, useDrilldown as Ae, useOverlayState as et, DrilldownContext as tt, useItemNavigation as rt } from "../context.js";
|
|
6
|
+
import { useDebounced as nt } from "../hooks/useDebounced.js";
|
|
7
|
+
import { get as Fe, post as Z } from "../lib/commands.js";
|
|
8
|
+
import { describeError as at } from "../lib/error-message.js";
|
|
9
|
+
import { visiblePageWidgets as lt } from "../lib/page-widget-access.js";
|
|
10
|
+
import { explicitAllUrlParams as st, initialFilterSelection as it, filterSelectionToSearch as ot } from "../lib/query-filter-seed.js";
|
|
11
|
+
import { userErrorMessage as Ee } from "../lib/safe-error.js";
|
|
12
|
+
import { safeLinkKind as dt } from "../lib/safe-href.js";
|
|
13
|
+
import { resolveSheetDef as ct } from "../lib/sheet-def.js";
|
|
14
|
+
import { uniqueByValue as ut } from "../lib/unique-options.js";
|
|
15
|
+
import { useMyScopes as mt, matchScopeDimension as Te, effectiveScopeSeedIds as pt, translateScopeValues as ht } from "../lib/use-my-scopes.js";
|
|
16
|
+
import { titleCase as F, formatRelative as xt, formatNumber as ft } from "../lib/utils.js";
|
|
17
|
+
import { CacheStamp as bt } from "./CacheStamp.js";
|
|
18
|
+
import { RelationCombobox as gt } from "./item-edit/RelationCombobox.js";
|
|
19
|
+
import { MatrixEditor as ce } from "./MatrixEditor.js";
|
|
20
|
+
import { QueryStatStrip as yt } from "./QueryStatStrip.js";
|
|
21
|
+
import { QueryTable as vt } from "./QueryTable.js";
|
|
22
|
+
import { RecordDrilldownSheet as kt } from "./RecordDrilldownSheet.js";
|
|
23
|
+
import { RecordGridEditor as We } from "./RecordGridEditor.js";
|
|
24
|
+
import { SheetHeaderBody as wt } from "./SheetHeaderBody.js";
|
|
24
25
|
const oe = 76;
|
|
25
|
-
function
|
|
26
|
+
function ee() {
|
|
26
27
|
return /* @__PURE__ */ t("div", { className: "space-y-1.5 p-3", children: [1, 2, 3].map((e) => /* @__PURE__ */ t(
|
|
27
28
|
"div",
|
|
28
29
|
{
|
|
@@ -31,17 +32,17 @@ function Z() {
|
|
|
31
32
|
e
|
|
32
33
|
)) });
|
|
33
34
|
}
|
|
34
|
-
function
|
|
35
|
-
const n =
|
|
35
|
+
function te({ error: e, unresolved: r }) {
|
|
36
|
+
const n = Mt(e, r) ?? Ee(e, "Failed to load widget data");
|
|
36
37
|
return /* @__PURE__ */ t("div", { className: "flex h-full items-center justify-center p-3 text-[12px] text-amber-600 dark:text-amber-500", children: n });
|
|
37
38
|
}
|
|
38
|
-
function
|
|
39
|
+
function Nt(e) {
|
|
39
40
|
if (e == null) return "—";
|
|
40
41
|
if (typeof e == "boolean") return e ? "true" : "false";
|
|
41
42
|
const r = String(e);
|
|
42
43
|
return r.length > 80 ? `${r.slice(0, 80)}…` : r;
|
|
43
44
|
}
|
|
44
|
-
function
|
|
45
|
+
function de(e, r) {
|
|
45
46
|
const n = [], a = /(\*\*[^*]+\*\*|\*[^*]+\*|`[^`]+`|\[[^\]]+\]\([^)]+\))/g;
|
|
46
47
|
return e.split(a).forEach((l, u) => {
|
|
47
48
|
const c = `${r}-${u}`;
|
|
@@ -62,104 +63,104 @@ function ie(e, r) {
|
|
|
62
63
|
)
|
|
63
64
|
);
|
|
64
65
|
else {
|
|
65
|
-
const
|
|
66
|
-
|
|
67
|
-
/* @__PURE__ */ t("a", { href:
|
|
66
|
+
const i = l.match(/^\[([^\]]+)\]\(([^)]+)\)$/);
|
|
67
|
+
i && dt(i[2]) !== null ? n.push(
|
|
68
|
+
/* @__PURE__ */ t("a", { href: i[2], className: "text-nvr-cyan underline-offset-2 hover:underline", children: i[1] }, c)
|
|
68
69
|
) : n.push(l);
|
|
69
70
|
}
|
|
70
71
|
}), n;
|
|
71
72
|
}
|
|
72
|
-
function
|
|
73
|
+
function St({ content: e }) {
|
|
73
74
|
const r = [];
|
|
74
75
|
let n = [], a = [], l = !1;
|
|
75
|
-
const u = (
|
|
76
|
+
const u = (i) => {
|
|
76
77
|
n.length && (r.push(
|
|
77
|
-
/* @__PURE__ */ t("p", { className: "leading-relaxed", children:
|
|
78
|
+
/* @__PURE__ */ t("p", { className: "leading-relaxed", children: de(n.join(" "), i) }, i)
|
|
78
79
|
), n = []);
|
|
79
|
-
}, c = (
|
|
80
|
+
}, c = (i) => {
|
|
80
81
|
if (!a.length) return;
|
|
81
|
-
const s = a.map((m,
|
|
82
|
+
const s = a.map((m, h) => /* @__PURE__ */ t("li", { children: de(m, `${i}-${h}`) }, `${i}-${h}`));
|
|
82
83
|
r.push(
|
|
83
|
-
l ? /* @__PURE__ */ t("ol", { className: "list-decimal space-y-0.5 pl-5", children: s },
|
|
84
|
+
l ? /* @__PURE__ */ t("ol", { className: "list-decimal space-y-0.5 pl-5", children: s }, i) : /* @__PURE__ */ t("ul", { className: "list-disc space-y-0.5 pl-5", children: s }, i)
|
|
84
85
|
), a = [];
|
|
85
86
|
};
|
|
86
87
|
return e.split(`
|
|
87
|
-
`).forEach((
|
|
88
|
-
const m = `md-${s}`,
|
|
89
|
-
if (
|
|
88
|
+
`).forEach((i, s) => {
|
|
89
|
+
const m = `md-${s}`, h = i.match(/^(#{1,3})\s+(.*)$/), v = i.match(/^[-*]\s+(.*)$/), $ = i.match(/^\d+\.\s+(.*)$/);
|
|
90
|
+
if (h) {
|
|
90
91
|
c(`${m}-fl`), u(`${m}-fp`);
|
|
91
|
-
const N =
|
|
92
|
+
const N = h[1].length, j = N === 1 ? "text-[17px] font-semibold" : N === 2 ? "text-[15px] font-semibold" : "text-[13.5px] font-semibold";
|
|
92
93
|
r.push(
|
|
93
|
-
/* @__PURE__ */ t("div", { className: `${
|
|
94
|
+
/* @__PURE__ */ t("div", { className: `${j} text-slate-900 dark:text-slate-100`, children: de(h[2], `${m}-h`) }, m)
|
|
94
95
|
);
|
|
95
96
|
} else if (v || $) {
|
|
96
97
|
u(`${m}-fp`);
|
|
97
98
|
const N = !!$;
|
|
98
99
|
a.length && l !== N && c(`${m}-fl`), l = N, a.push((v == null ? void 0 : v[1]) ?? ($ == null ? void 0 : $[1]));
|
|
99
|
-
} else
|
|
100
|
+
} else i.trim() === "" ? (c(`${m}-fl`), u(`${m}-fp`)) : (c(`${m}-fl`), n.push(i.trim()));
|
|
100
101
|
}), c("md-end-l"), u("md-end-p"), /* @__PURE__ */ t("div", { className: "space-y-2 p-4 text-[13px] text-slate-700 dark:text-slate-300", children: r });
|
|
101
102
|
}
|
|
102
|
-
function
|
|
103
|
+
function ue(e, r, n) {
|
|
103
104
|
const a = K();
|
|
104
105
|
return z({
|
|
105
106
|
queryKey: ["page-renderer-widget-data", e, r.id],
|
|
106
|
-
queryFn: () => a.request(
|
|
107
|
+
queryFn: () => a.request(Z(`/pages/${e}/widget-data`, { widget_id: r.id })).then((l) => l.data),
|
|
107
108
|
enabled: n,
|
|
108
109
|
retry: !1,
|
|
109
110
|
staleTime: 3e4
|
|
110
111
|
});
|
|
111
112
|
}
|
|
112
|
-
function
|
|
113
|
+
function $t({ slug: e, widget: r }) {
|
|
113
114
|
var m;
|
|
114
|
-
const n = r.config ?? {}, { data: a, isLoading: l, error: u } =
|
|
115
|
+
const n = r.config ?? {}, { data: a, isLoading: l, error: u } = ue(e, r, !!n.collection), c = rt();
|
|
115
116
|
if (!n.collection)
|
|
116
117
|
return /* @__PURE__ */ t("div", { className: "p-3 text-[12px] text-slate-400", children: "Select a collection" });
|
|
117
|
-
if (l) return /* @__PURE__ */ t(
|
|
118
|
-
if (u) return /* @__PURE__ */ t(
|
|
119
|
-
const
|
|
120
|
-
if (!
|
|
121
|
-
const s = (m = n.columns) != null && m.length ? n.columns : Object.keys(
|
|
122
|
-
const v =
|
|
118
|
+
if (l) return /* @__PURE__ */ t(ee, {});
|
|
119
|
+
if (u) return /* @__PURE__ */ t(te, { error: u });
|
|
120
|
+
const i = (a == null ? void 0 : a.rows) ?? [];
|
|
121
|
+
if (!i.length) return /* @__PURE__ */ t("div", { className: "p-3 text-[12px] text-slate-400", children: "No records" });
|
|
122
|
+
const s = (m = n.columns) != null && m.length ? n.columns : Object.keys(i[0]).filter((h) => {
|
|
123
|
+
const v = i[0][h];
|
|
123
124
|
return v === null || ["string", "number", "boolean"].includes(typeof v);
|
|
124
125
|
}).slice(0, 5);
|
|
125
126
|
return /* @__PURE__ */ t("div", { className: "h-full overflow-auto", children: /* @__PURE__ */ x("table", { className: "w-full text-[12px]", children: [
|
|
126
|
-
/* @__PURE__ */ t("thead", { children: /* @__PURE__ */ t("tr", { className: "border-b border-slate-100 dark:border-border", children: s.map((
|
|
127
|
+
/* @__PURE__ */ t("thead", { children: /* @__PURE__ */ t("tr", { className: "border-b border-slate-100 dark:border-border", children: s.map((h) => /* @__PURE__ */ t(
|
|
127
128
|
"th",
|
|
128
129
|
{
|
|
129
130
|
className: "whitespace-nowrap px-3 py-1.5 text-left font-medium text-slate-400",
|
|
130
|
-
children:
|
|
131
|
+
children: F(h)
|
|
131
132
|
},
|
|
132
|
-
|
|
133
|
+
h
|
|
133
134
|
)) }) }),
|
|
134
|
-
/* @__PURE__ */ t("tbody", { children:
|
|
135
|
+
/* @__PURE__ */ t("tbody", { children: i.map((h, v) => /* @__PURE__ */ t(
|
|
135
136
|
"tr",
|
|
136
137
|
{
|
|
137
|
-
onClick:
|
|
138
|
-
className: `border-b border-slate-50 last:border-0 dark:border-border/50 ${
|
|
138
|
+
onClick: h.id != null ? () => c.open({ collection: n.collection, itemId: String(h.id) }) : void 0,
|
|
139
|
+
className: `border-b border-slate-50 last:border-0 dark:border-border/50 ${h.id != null ? "cursor-pointer hover:bg-slate-50 dark:hover:bg-muted/40" : ""}`,
|
|
139
140
|
children: s.map(($) => /* @__PURE__ */ t(
|
|
140
141
|
"td",
|
|
141
142
|
{
|
|
142
143
|
className: "whitespace-nowrap px-3 py-1.5 text-slate-700 dark:text-slate-300",
|
|
143
|
-
children:
|
|
144
|
+
children: Nt(h[$])
|
|
144
145
|
},
|
|
145
146
|
$
|
|
146
147
|
))
|
|
147
148
|
},
|
|
148
|
-
|
|
149
|
+
h.id != null ? `${h.id}-${v}` : v
|
|
149
150
|
)) })
|
|
150
151
|
] }) });
|
|
151
152
|
}
|
|
152
|
-
function
|
|
153
|
-
const n = r.config ?? {}, { data: a, isLoading: l, error: u } =
|
|
154
|
-
return n.collection ? u ? /* @__PURE__ */ t(
|
|
155
|
-
l ? /* @__PURE__ */ t("div", { className: "h-9 w-24 animate-pulse rounded bg-slate-100 dark:bg-[hsl(var(--nvr-skeleton))]" }) : /* @__PURE__ */ t("span", { className: "text-[32px] font-semibold leading-none tracking-tight text-slate-900 dark:text-slate-100", children: (a == null ? void 0 : a.value) != null ?
|
|
153
|
+
function _t({ slug: e, widget: r }) {
|
|
154
|
+
const n = r.config ?? {}, { data: a, isLoading: l, error: u } = ue(e, r, !!n.collection);
|
|
155
|
+
return n.collection ? u ? /* @__PURE__ */ t(te, { error: u }) : /* @__PURE__ */ x("div", { className: "flex h-full flex-col items-start justify-center px-4", children: [
|
|
156
|
+
l ? /* @__PURE__ */ t("div", { className: "h-9 w-24 animate-pulse rounded bg-slate-100 dark:bg-[hsl(var(--nvr-skeleton))]" }) : /* @__PURE__ */ t("span", { className: "text-[32px] font-semibold leading-none tracking-tight text-slate-900 dark:text-slate-100", children: (a == null ? void 0 : a.value) != null ? ft(Number(a.value)) : "—" }),
|
|
156
157
|
/* @__PURE__ */ t("span", { className: "mt-1.5 text-[12px] text-slate-400", children: n.label || `${n.aggregate ?? "count"} of ${n.collection}` })
|
|
157
158
|
] }) : /* @__PURE__ */ t("div", { className: "p-3 text-[12px] text-slate-400", children: "Select a collection" });
|
|
158
159
|
}
|
|
159
|
-
function
|
|
160
|
-
const { data: n, isLoading: a, error: l } =
|
|
161
|
-
if (a) return /* @__PURE__ */ t(
|
|
162
|
-
if (l) return /* @__PURE__ */ t(
|
|
160
|
+
function Ct({ slug: e, widget: r }) {
|
|
161
|
+
const { data: n, isLoading: a, error: l } = ue(e, r, !0);
|
|
162
|
+
if (a) return /* @__PURE__ */ t(ee, {});
|
|
163
|
+
if (l) return /* @__PURE__ */ t(te, { error: l });
|
|
163
164
|
const u = (n == null ? void 0 : n.rows) ?? [];
|
|
164
165
|
return u.length ? /* @__PURE__ */ t("div", { className: "h-full overflow-auto px-3 py-1.5", children: u.map((c) => /* @__PURE__ */ x(
|
|
165
166
|
"div",
|
|
@@ -171,13 +172,13 @@ function $t({ slug: e, widget: r }) {
|
|
|
171
172
|
c.collection,
|
|
172
173
|
c.item ? ` · ${c.item}` : ""
|
|
173
174
|
] }),
|
|
174
|
-
/* @__PURE__ */ t("span", { className: "ml-auto shrink-0 text-[11px] text-slate-400", children:
|
|
175
|
+
/* @__PURE__ */ t("span", { className: "ml-auto shrink-0 text-[11px] text-slate-400", children: xt(c.timestamp) })
|
|
175
176
|
]
|
|
176
177
|
},
|
|
177
178
|
c.id
|
|
178
179
|
)) }) : /* @__PURE__ */ t("div", { className: "p-3 text-[12px] text-slate-400", children: "No activity" });
|
|
179
180
|
}
|
|
180
|
-
function
|
|
181
|
+
function qt({ widget: e }) {
|
|
181
182
|
var n;
|
|
182
183
|
const r = String(((n = e.config) == null ? void 0 : n.url) ?? "");
|
|
183
184
|
return r ? /^https?:\/\//i.test(r) ? /* @__PURE__ */ t(
|
|
@@ -190,7 +191,7 @@ function _t({ widget: e }) {
|
|
|
190
191
|
}
|
|
191
192
|
) : /* @__PURE__ */ t("div", { className: "p-3 text-[12px] text-amber-600", children: "URL must start with http(s)://" }) : /* @__PURE__ */ t("div", { className: "p-3 text-[12px] text-slate-400", children: "Set an iframe URL" });
|
|
192
193
|
}
|
|
193
|
-
function
|
|
194
|
+
function Le({
|
|
194
195
|
config: e,
|
|
195
196
|
initialScope: r,
|
|
196
197
|
width: n,
|
|
@@ -217,12 +218,12 @@ function Ee({
|
|
|
217
218
|
}
|
|
218
219
|
)
|
|
219
220
|
] }),
|
|
220
|
-
/* @__PURE__ */ t("div", { className: "min-h-0 flex-1 overflow-auto", children: /* @__PURE__ */ t(
|
|
221
|
+
/* @__PURE__ */ t("div", { className: "min-h-0 flex-1 overflow-auto", children: /* @__PURE__ */ t(ce, { config: e, initialScope: r }) })
|
|
221
222
|
]
|
|
222
223
|
}
|
|
223
224
|
) });
|
|
224
225
|
}
|
|
225
|
-
function
|
|
226
|
+
function jt({ widget: e }) {
|
|
226
227
|
const r = e.config ?? {}, [n, a] = q(!1);
|
|
227
228
|
return !r.target_collection || !r.option_collection || !r.key_field || !r.value_field ? /* @__PURE__ */ t("div", { className: "p-3 text-[12px] text-slate-400", children: "Matrix editor not configured" }) : r.display === "drawer" ? /* @__PURE__ */ x("div", { className: "flex h-full items-center", children: [
|
|
228
229
|
/* @__PURE__ */ t(
|
|
@@ -235,48 +236,48 @@ function Ct({ widget: e }) {
|
|
|
235
236
|
}
|
|
236
237
|
),
|
|
237
238
|
n && /* @__PURE__ */ t(
|
|
238
|
-
|
|
239
|
+
Le,
|
|
239
240
|
{
|
|
240
241
|
config: r,
|
|
241
242
|
width: r.sheet_width,
|
|
242
243
|
onClose: () => a(!1)
|
|
243
244
|
}
|
|
244
245
|
)
|
|
245
|
-
] }) : /* @__PURE__ */ t(
|
|
246
|
+
] }) : /* @__PURE__ */ t(ce, { config: r });
|
|
246
247
|
}
|
|
247
|
-
function
|
|
248
|
-
return
|
|
248
|
+
function Rt(e) {
|
|
249
|
+
return it(
|
|
249
250
|
e,
|
|
250
251
|
typeof window > "u" ? "" : window.location.search
|
|
251
252
|
);
|
|
252
253
|
}
|
|
253
|
-
function
|
|
254
|
+
function Me(e, r) {
|
|
254
255
|
const n = [...new Set(e.map((a) => a[r]).filter((a) => a != null && a !== ""))];
|
|
255
256
|
return n.length ? n.map(String).join(",") : void 0;
|
|
256
257
|
}
|
|
257
|
-
function
|
|
258
|
+
function Be(e, r, n, a, l, u, c) {
|
|
258
259
|
if (typeof e != "string") return e;
|
|
259
260
|
if (e.startsWith("$row.")) {
|
|
260
|
-
const
|
|
261
|
-
return !r && c ?
|
|
261
|
+
const i = e.slice(5);
|
|
262
|
+
return !r && c ? Me(c, i) : r == null ? void 0 : r[i];
|
|
262
263
|
}
|
|
263
|
-
if (e.startsWith("$rows.")) return
|
|
264
|
+
if (e.startsWith("$rows.")) return Me(n, e.slice(6));
|
|
264
265
|
if (e.startsWith("$param.")) return a[e.slice(7)];
|
|
265
266
|
if (e.startsWith("$filters.")) {
|
|
266
|
-
const
|
|
267
|
-
return m.length ? m.map((
|
|
267
|
+
const i = e.slice(9), s = u == null ? void 0 : u.find((h) => h.param === i), m = l[i] ?? [];
|
|
268
|
+
return m.length ? m.map((h) => String(h[(s == null ? void 0 : s.value_field) ?? "id"] ?? "")).join(",") : void 0;
|
|
268
269
|
}
|
|
269
270
|
return e;
|
|
270
271
|
}
|
|
271
|
-
function
|
|
272
|
-
const
|
|
273
|
-
for (const [m,
|
|
274
|
-
const v =
|
|
275
|
-
v !== void 0 ?
|
|
272
|
+
function Tt(e, r, n, a, l, u, c) {
|
|
273
|
+
const i = {}, s = [];
|
|
274
|
+
for (const [m, h] of Object.entries(e.params ?? {})) {
|
|
275
|
+
const v = Be(h, r, n, a, l, u, c);
|
|
276
|
+
v !== void 0 ? i[m] = v : typeof h == "string" && (h.startsWith("$row.") || h.startsWith("$rows.")) && s.push(m);
|
|
276
277
|
}
|
|
277
|
-
return { ...e, params:
|
|
278
|
+
return { ...e, params: i, ...s.length ? { unresolved_params: s } : {} };
|
|
278
279
|
}
|
|
279
|
-
function
|
|
280
|
+
function Wt(e, r) {
|
|
280
281
|
var l, u;
|
|
281
282
|
let n = (l = e.row_noun) == null ? void 0 : l.trim();
|
|
282
283
|
if (!n) {
|
|
@@ -286,22 +287,22 @@ function Rt(e, r) {
|
|
|
286
287
|
const a = r === 1 && n.endsWith("s") ? n.slice(0, -1) : n;
|
|
287
288
|
return `Total of ${r.toLocaleString("en-US")} ${a}`;
|
|
288
289
|
}
|
|
289
|
-
function
|
|
290
|
-
const n =
|
|
290
|
+
function Mt(e, r) {
|
|
291
|
+
const n = at(e), a = [n.title, n.technical ?? ""].join(" "), l = /Missing required parameter:\s*([\w]+)/i.exec(a);
|
|
291
292
|
if (!l) return null;
|
|
292
|
-
const u =
|
|
293
|
+
const u = F(l[1]).toLowerCase();
|
|
293
294
|
return r != null && r.includes(l[1]) ? `Nothing to show: the row you opened has no ${u}.` : `Choose ${u} to see this view.`;
|
|
294
295
|
}
|
|
295
|
-
function
|
|
296
|
+
function Ot({
|
|
296
297
|
config: e,
|
|
297
298
|
stats: r,
|
|
298
299
|
asOf: n,
|
|
299
300
|
note: a
|
|
300
301
|
}) {
|
|
301
|
-
const l = K(), u = e.params ?? {}, { data: c, isPending:
|
|
302
|
+
const l = K(), u = e.params ?? {}, { data: c, isPending: i, isError: s } = z({
|
|
302
303
|
queryKey: ["page-renderer-query", e.query_slug, JSON.stringify(u)],
|
|
303
304
|
queryFn: () => l.request(
|
|
304
|
-
|
|
305
|
+
Z(`/custom-queries/${e.query_slug}/execute`, { params: u })
|
|
305
306
|
),
|
|
306
307
|
enabled: !!e.query_slug,
|
|
307
308
|
staleTime: 6e4
|
|
@@ -312,12 +313,12 @@ function Wt({
|
|
|
312
313
|
className: "shrink-0 border-b border-slate-200 bg-white px-4 py-3 dark:border-border dark:bg-card",
|
|
313
314
|
"data-sheet-header": !0,
|
|
314
315
|
children: /* @__PURE__ */ t(
|
|
315
|
-
|
|
316
|
+
wt,
|
|
316
317
|
{
|
|
317
318
|
stats: r,
|
|
318
319
|
rows: (c == null ? void 0 : c.data) ?? [],
|
|
319
320
|
params: u,
|
|
320
|
-
loading:
|
|
321
|
+
loading: i && !s,
|
|
321
322
|
error: s,
|
|
322
323
|
asOf: n,
|
|
323
324
|
note: a
|
|
@@ -326,32 +327,32 @@ function Wt({
|
|
|
326
327
|
}
|
|
327
328
|
);
|
|
328
329
|
}
|
|
329
|
-
function
|
|
330
|
+
function Pt({
|
|
330
331
|
def: e,
|
|
331
332
|
row: r,
|
|
332
333
|
totalCount: n,
|
|
333
334
|
onClose: a
|
|
334
335
|
}) {
|
|
335
|
-
const [l, u] = q(e.initialTab ?? 0), c = !r && n != null ?
|
|
336
|
-
const v = r == null ? void 0 : r[
|
|
336
|
+
const [l, u] = q(e.initialTab ?? 0), c = !r && n != null ? Wt(e, n) : e.title ? e.title.replace(/\{\{\s*([\w.]+)\s*\}\}/g, (m, h) => {
|
|
337
|
+
const v = r == null ? void 0 : r[h];
|
|
337
338
|
return v == null ? "" : String(v);
|
|
338
|
-
}) : "Details",
|
|
339
|
+
}) : "Details", i = typeof e.width == "number" ? `${e.width}px` : e.width ?? "90%", s = e.resolvedTabs[l];
|
|
339
340
|
return /* @__PURE__ */ t("div", { className: "fixed inset-0 z-50 flex justify-end bg-black/30", onClick: a, children: /* @__PURE__ */ x(
|
|
340
341
|
"div",
|
|
341
342
|
{
|
|
342
343
|
className: "flex h-full flex-col border-l border-slate-200 bg-slate-50 shadow-2xl dark:border-border dark:bg-background",
|
|
343
|
-
style: { width:
|
|
344
|
+
style: { width: i, maxWidth: "96%" },
|
|
344
345
|
onClick: (m) => m.stopPropagation(),
|
|
345
346
|
children: [
|
|
346
347
|
/* @__PURE__ */ x("div", { className: "flex shrink-0 items-center justify-between border-b border-slate-200 bg-white px-4 py-2.5 dark:border-border dark:bg-card", children: [
|
|
347
348
|
/* @__PURE__ */ x("div", { className: "flex items-center gap-3", children: [
|
|
348
349
|
/* @__PURE__ */ t("p", { className: "text-[13px] font-semibold text-slate-700 dark:text-slate-200", children: c }),
|
|
349
|
-
e.resolvedTabs.length > 1 && /* @__PURE__ */ t("div", { className: "flex gap-1", children: e.resolvedTabs.map((m,
|
|
350
|
+
e.resolvedTabs.length > 1 && /* @__PURE__ */ t("div", { className: "flex gap-1", children: e.resolvedTabs.map((m, h) => /* @__PURE__ */ t(
|
|
350
351
|
"button",
|
|
351
352
|
{
|
|
352
353
|
type: "button",
|
|
353
|
-
onClick: () => u(
|
|
354
|
-
className: `rounded-md px-2.5 py-1 text-[12px] font-medium transition-colors ${
|
|
354
|
+
onClick: () => u(h),
|
|
355
|
+
className: `rounded-md px-2.5 py-1 text-[12px] font-medium transition-colors ${h === l ? "bg-nvr-cyan/10 text-slate-800 dark:text-slate-100" : "text-slate-500 hover:text-slate-700 dark:hover:text-slate-300"}`,
|
|
355
356
|
children: m.label
|
|
356
357
|
},
|
|
357
358
|
m.label
|
|
@@ -368,7 +369,7 @@ function Mt({
|
|
|
368
369
|
)
|
|
369
370
|
] }),
|
|
370
371
|
e.header && /* @__PURE__ */ t(
|
|
371
|
-
|
|
372
|
+
Ot,
|
|
372
373
|
{
|
|
373
374
|
config: e.header.config,
|
|
374
375
|
stats: e.header.stats,
|
|
@@ -377,14 +378,14 @@ function Mt({
|
|
|
377
378
|
}
|
|
378
379
|
),
|
|
379
380
|
/* @__PURE__ */ t("div", { className: "min-h-0 flex-1 overflow-auto", children: s != null && s.matrix ? /* @__PURE__ */ t(
|
|
380
|
-
|
|
381
|
+
ce,
|
|
381
382
|
{
|
|
382
383
|
config: s.matrix.config,
|
|
383
384
|
initialScope: s.matrix.initialScope,
|
|
384
385
|
lockScope: !0
|
|
385
386
|
},
|
|
386
387
|
l
|
|
387
|
-
) : s != null && s.config ? /* @__PURE__ */ x(
|
|
388
|
+
) : s != null && s.config ? /* @__PURE__ */ x(B, { children: [
|
|
388
389
|
s.note && /* @__PURE__ */ t(
|
|
389
390
|
"p",
|
|
390
391
|
{
|
|
@@ -393,31 +394,31 @@ function Mt({
|
|
|
393
394
|
children: s.note
|
|
394
395
|
}
|
|
395
396
|
),
|
|
396
|
-
/* @__PURE__ */ t(
|
|
397
|
+
/* @__PURE__ */ t(Ie, { config: s.config }, l)
|
|
397
398
|
] }) : /* @__PURE__ */ t("p", { className: "p-4 text-[12px] text-slate-400", children: "Sheet not configured" }) })
|
|
398
399
|
]
|
|
399
400
|
}
|
|
400
401
|
) });
|
|
401
402
|
}
|
|
402
|
-
function
|
|
403
|
+
function At(e, r, n, a) {
|
|
403
404
|
if (!e) return;
|
|
404
405
|
const l = (s) => {
|
|
405
406
|
const m = /^\$filters\.(\w+)(?:\.(\w+))?$/.exec(s);
|
|
406
407
|
if (!m) return;
|
|
407
|
-
const
|
|
408
|
+
const h = a == null ? void 0 : a.find((N) => N.param === m[1]), v = (n == null ? void 0 : n[m[1]]) ?? [];
|
|
408
409
|
if (v.length === 0) return;
|
|
409
|
-
const $ = m[2] ?? (
|
|
410
|
+
const $ = m[2] ?? (h == null ? void 0 : h.value_field) ?? "id";
|
|
410
411
|
return v.map((N) => N[$]);
|
|
411
412
|
}, u = (s) => typeof s == "string" && s.startsWith("$row.") ? r[s.slice(5)] : typeof s == "string" && s.startsWith("$filters.") ? l(s) : Array.isArray(s) ? s.map(u) : s && typeof s == "object" ? Object.fromEntries(
|
|
412
|
-
Object.entries(s).map(([m,
|
|
413
|
-
) : s, c = (s) => s === void 0 ? !0 : Array.isArray(s) ? s.some(c) : s && typeof s == "object" ? Object.values(s).some(c) : !1,
|
|
414
|
-
return Array.isArray(
|
|
413
|
+
Object.entries(s).map(([m, h]) => [m, u(h)])
|
|
414
|
+
) : s, c = (s) => s === void 0 ? !0 : Array.isArray(s) ? s.some(c) : s && typeof s == "object" ? Object.values(s).some(c) : !1, i = u(e);
|
|
415
|
+
return Array.isArray(i._and) && (i._and = i._and.filter((s) => !c(s))), c(i) ? void 0 : i;
|
|
415
416
|
}
|
|
416
|
-
const
|
|
417
|
-
function
|
|
417
|
+
const Ft = 400, Et = 2500;
|
|
418
|
+
function Oe(e, r) {
|
|
418
419
|
return e.map((n) => String(n[r] ?? "")).sort().join("\0");
|
|
419
420
|
}
|
|
420
|
-
function
|
|
421
|
+
function Lt({
|
|
421
422
|
filter: e,
|
|
422
423
|
selected: r,
|
|
423
424
|
onChange: n,
|
|
@@ -425,42 +426,42 @@ function At({
|
|
|
425
426
|
scopeDefault: l,
|
|
426
427
|
onOpenChange: u
|
|
427
428
|
}) {
|
|
428
|
-
const c = K(), [
|
|
429
|
-
m.current = u,
|
|
429
|
+
const c = K(), [i, s] = q(!1), m = D(u);
|
|
430
|
+
m.current = u, X(() => {
|
|
430
431
|
var k;
|
|
431
|
-
(k = m.current) == null || k.call(m,
|
|
432
|
-
}, [
|
|
433
|
-
const [
|
|
434
|
-
queryKey: ["page-renderer-filter", e.collection, N,
|
|
432
|
+
(k = m.current) == null || k.call(m, i);
|
|
433
|
+
}, [i]);
|
|
434
|
+
const [h, v] = q(""), $ = D(null), N = e.value_field ?? "id", j = e.label_field ?? N, { data: _ = [] } = z({
|
|
435
|
+
queryKey: ["page-renderer-filter", e.collection, N, j, e.sort],
|
|
435
436
|
queryFn: () => c.request(
|
|
436
437
|
Fe(`/items/${e.collection}`, {
|
|
437
|
-
fields: [.../* @__PURE__ */ new Set(["id", N,
|
|
438
|
+
fields: [.../* @__PURE__ */ new Set(["id", N, j])].join(","),
|
|
438
439
|
limit: e.limit ?? 500,
|
|
439
440
|
...e.sort ? { sort: e.sort } : {}
|
|
440
441
|
})
|
|
441
442
|
).then((k) => k.data ?? []),
|
|
442
443
|
staleTime: 6e4
|
|
443
444
|
});
|
|
444
|
-
|
|
445
|
-
if (!
|
|
446
|
-
const k = (
|
|
447
|
-
$.current && !$.current.contains(
|
|
445
|
+
X(() => {
|
|
446
|
+
if (!i) return;
|
|
447
|
+
const k = (T) => {
|
|
448
|
+
$.current && !$.current.contains(T.target) && s(!1);
|
|
448
449
|
};
|
|
449
450
|
return window.addEventListener("mousedown", k), () => window.removeEventListener("mousedown", k);
|
|
450
|
-
}, [
|
|
451
|
-
const
|
|
452
|
-
a != null && a.length ? _.filter((k) => a.some((
|
|
451
|
+
}, [i]);
|
|
452
|
+
const W = e.label ?? F(e.param), M = ut(
|
|
453
|
+
a != null && a.length ? _.filter((k) => a.some((T) => String(T) === String(k.id))) : _,
|
|
453
454
|
(k) => String(k[N] ?? "")
|
|
454
455
|
).filter(
|
|
455
|
-
(k) =>
|
|
456
|
+
(k) => h ? String(k[j] ?? "").toLowerCase().includes(h.toLowerCase()) : !0
|
|
456
457
|
), C = a != null && a.length ? {
|
|
457
458
|
label: "restricted",
|
|
458
459
|
cls: "bg-amber-500/15 text-amber-700 dark:text-amber-300",
|
|
459
|
-
title: `Options limited to your restricted ${
|
|
460
|
+
title: `Options limited to your restricted ${W} scope${l ? "; selection seeded from your defaults" : ""}`
|
|
460
461
|
} : l && r.length > 0 ? {
|
|
461
462
|
label: "your default",
|
|
462
463
|
cls: "bg-nvr-cyan/[0.12] text-[#0284a8] dark:text-nvr-cyan",
|
|
463
|
-
title: `Pre-selected from your default ${
|
|
464
|
+
title: `Pre-selected from your default ${W} scope — adjust freely`
|
|
464
465
|
} : null;
|
|
465
466
|
return /* @__PURE__ */ x("div", { ref: $, className: "relative", children: [
|
|
466
467
|
/* @__PURE__ */ x(
|
|
@@ -470,7 +471,7 @@ function At({
|
|
|
470
471
|
onClick: () => s((k) => !k),
|
|
471
472
|
className: `inline-flex h-8 items-center gap-1.5 rounded-md border px-2.5 text-[12px] transition-colors ${r.length > 0 ? "border-nvr-cyan bg-nvr-cyan/10 text-slate-700 dark:text-slate-200" : "border-slate-200 bg-white text-slate-600 hover:border-slate-400 dark:border-border dark:bg-card dark:text-slate-300"}`,
|
|
472
473
|
children: [
|
|
473
|
-
/* @__PURE__ */ t("span", { className: "font-medium", children:
|
|
474
|
+
/* @__PURE__ */ t("span", { className: "font-medium", children: W }),
|
|
474
475
|
C && /* @__PURE__ */ t(
|
|
475
476
|
"span",
|
|
476
477
|
{
|
|
@@ -479,16 +480,16 @@ function At({
|
|
|
479
480
|
children: C.label
|
|
480
481
|
}
|
|
481
482
|
),
|
|
482
|
-
/* @__PURE__ */ t("span", { className: "text-slate-400", children: r.length === 0 ? "All" : r.length === 1 ? String(r[0][
|
|
483
|
+
/* @__PURE__ */ t("span", { className: "text-slate-400", children: r.length === 0 ? "All" : r.length === 1 ? String(r[0][j] ?? r[0][N] ?? "") : `${r.length} selected` }),
|
|
483
484
|
/* @__PURE__ */ t("span", { className: "text-slate-400", children: "⌃" })
|
|
484
485
|
]
|
|
485
486
|
}
|
|
486
487
|
),
|
|
487
|
-
|
|
488
|
+
i && /* @__PURE__ */ x("div", { className: "absolute left-0 top-9 z-40 w-56 rounded-md border border-slate-200 bg-white p-1 shadow-md dark:border-border dark:bg-popover", children: [
|
|
488
489
|
/* @__PURE__ */ t(
|
|
489
490
|
"input",
|
|
490
491
|
{
|
|
491
|
-
value:
|
|
492
|
+
value: h,
|
|
492
493
|
onChange: (k) => v(k.target.value),
|
|
493
494
|
placeholder: "Search…",
|
|
494
495
|
className: "mb-1 h-7 w-full rounded border border-slate-200 bg-white px-2 text-[12px] outline-none dark:border-border dark:bg-background"
|
|
@@ -504,39 +505,39 @@ function At({
|
|
|
504
505
|
children: "Clear selection"
|
|
505
506
|
}
|
|
506
507
|
),
|
|
507
|
-
|
|
508
|
-
const
|
|
508
|
+
M.map((k) => {
|
|
509
|
+
const T = String(k[N] ?? ""), d = r.some((g) => String(g[N] ?? "") === T);
|
|
509
510
|
return /* @__PURE__ */ x(
|
|
510
511
|
"button",
|
|
511
512
|
{
|
|
512
513
|
type: "button",
|
|
513
514
|
onClick: () => {
|
|
514
515
|
if (e.single) {
|
|
515
|
-
n(
|
|
516
|
+
n(d ? [] : [k]), s(!1);
|
|
516
517
|
return;
|
|
517
518
|
}
|
|
518
519
|
n(
|
|
519
|
-
|
|
520
|
+
d ? r.filter((g) => String(g[N] ?? "") !== T) : [...r, k]
|
|
520
521
|
);
|
|
521
522
|
},
|
|
522
523
|
className: "flex w-full items-center gap-2 rounded px-2 py-1 text-left text-[12px] text-slate-700 hover:bg-slate-100 dark:text-slate-200 dark:hover:bg-muted",
|
|
523
524
|
children: [
|
|
524
|
-
/* @__PURE__ */ t("span", { className: `w-3.5 shrink-0 text-nvr-cyan ${
|
|
525
|
-
/* @__PURE__ */ t("span", { className: "truncate", children: String(k[
|
|
525
|
+
/* @__PURE__ */ t("span", { className: `w-3.5 shrink-0 text-nvr-cyan ${d ? "" : "invisible"}`, children: "✓" }),
|
|
526
|
+
/* @__PURE__ */ t("span", { className: "truncate", children: String(k[j] ?? T) })
|
|
526
527
|
]
|
|
527
528
|
},
|
|
528
|
-
|
|
529
|
+
T
|
|
529
530
|
);
|
|
530
531
|
}),
|
|
531
|
-
|
|
532
|
+
M.length === 0 && /* @__PURE__ */ t("p", { className: "px-2 py-1.5 text-[12px] text-slate-400", children: "No options" })
|
|
532
533
|
] })
|
|
533
534
|
] })
|
|
534
535
|
] });
|
|
535
536
|
}
|
|
536
|
-
function
|
|
537
|
-
return /* @__PURE__ */ t(
|
|
537
|
+
function Bt({ widget: e }) {
|
|
538
|
+
return /* @__PURE__ */ t(Ie, { config: e.config ?? {} });
|
|
538
539
|
}
|
|
539
|
-
function
|
|
540
|
+
function It({ widget: e }) {
|
|
540
541
|
const r = e.config ?? {}, [n, a] = q(!1);
|
|
541
542
|
return r.collection ? r.display === "drawer" ? /* @__PURE__ */ x("div", { className: "flex h-full items-center", children: [
|
|
542
543
|
/* @__PURE__ */ t(
|
|
@@ -575,15 +576,15 @@ function Lt({ widget: e }) {
|
|
|
575
576
|
}
|
|
576
577
|
)
|
|
577
578
|
] }),
|
|
578
|
-
/* @__PURE__ */ t("div", { className: "min-h-0 flex-1 overflow-auto", children: /* @__PURE__ */ t(
|
|
579
|
+
/* @__PURE__ */ t("div", { className: "min-h-0 flex-1 overflow-auto", children: /* @__PURE__ */ t(We, { config: r }) })
|
|
579
580
|
]
|
|
580
581
|
}
|
|
581
582
|
)
|
|
582
583
|
}
|
|
583
584
|
)
|
|
584
|
-
] }) : /* @__PURE__ */ t(
|
|
585
|
+
] }) : /* @__PURE__ */ t(We, { config: r }) : /* @__PURE__ */ t("div", { className: "p-3 text-[12px] text-slate-400", children: "Configure the record grid (collection)" });
|
|
585
586
|
}
|
|
586
|
-
function
|
|
587
|
+
function Dt({
|
|
587
588
|
cfg: e
|
|
588
589
|
}) {
|
|
589
590
|
const [r, n] = q(!1), a = { ...e };
|
|
@@ -632,257 +633,257 @@ function Bt({
|
|
|
632
633
|
)
|
|
633
634
|
] });
|
|
634
635
|
}
|
|
635
|
-
function
|
|
636
|
-
return e.display === "drawer" ? /* @__PURE__ */ t(
|
|
636
|
+
function Ie({ config: e }) {
|
|
637
|
+
return e.display === "drawer" ? /* @__PURE__ */ t(Dt, { cfg: e }) : /* @__PURE__ */ t(De, { config: e });
|
|
637
638
|
}
|
|
638
639
|
function De({ config: e }) {
|
|
639
|
-
var
|
|
640
|
-
const r = K(), n =
|
|
641
|
-
() =>
|
|
640
|
+
var ke, we, Ne, Se, $e, _e, Ce, qe, je;
|
|
641
|
+
const r = K(), n = Ae(), [a, l] = q(null), [u, c] = q(null), [i, s] = q(null), [m, h] = q(
|
|
642
|
+
() => Rt(e.filters)
|
|
642
643
|
), [v] = q(
|
|
643
|
-
() =>
|
|
644
|
-
), $ = (
|
|
645
|
-
const f = { ...m, [
|
|
646
|
-
if (
|
|
647
|
-
const b =
|
|
644
|
+
() => st(e.filters, typeof window > "u" ? "" : window.location.search)
|
|
645
|
+
), $ = (o, p) => {
|
|
646
|
+
const f = { ...m, [o]: p };
|
|
647
|
+
if (h(f), typeof window > "u" || !(e.filters ?? []).some((y) => y.url_param)) return;
|
|
648
|
+
const b = ot(e.filters, f, window.location.search);
|
|
648
649
|
b !== window.location.search && window.history.replaceState(
|
|
649
650
|
window.history.state,
|
|
650
651
|
"",
|
|
651
652
|
`${window.location.pathname}${b}${window.location.hash}`
|
|
652
653
|
);
|
|
653
|
-
}, [N,
|
|
654
|
-
|
|
654
|
+
}, [N, j] = q(null), [_, W] = q(null), P = (_ == null ? void 0 : _.phase) === "running", M = He();
|
|
655
|
+
X(() => {
|
|
655
656
|
if ((_ == null ? void 0 : _.phase) !== "running") return;
|
|
656
|
-
const
|
|
657
|
-
|
|
658
|
-
(
|
|
657
|
+
const o = window.setInterval(() => {
|
|
658
|
+
W(
|
|
659
|
+
(p) => (p == null ? void 0 : p.phase) === "running" ? { ...p, elapsedMs: Date.now() - p.startedAt } : p
|
|
659
660
|
);
|
|
660
661
|
}, 250);
|
|
661
|
-
return () => window.clearInterval(
|
|
662
|
+
return () => window.clearInterval(o);
|
|
662
663
|
}, [_ == null ? void 0 : _.phase]);
|
|
663
|
-
const { scopes: C, ready: k } =
|
|
664
|
-
|
|
665
|
-
if (
|
|
666
|
-
|
|
667
|
-
const
|
|
668
|
-
(
|
|
664
|
+
const { scopes: C, ready: k } = mt(), T = D(!1), [d, g] = q(!1), [E, Q] = q(/* @__PURE__ */ new Map());
|
|
665
|
+
X(() => {
|
|
666
|
+
if (T.current || !k) return;
|
|
667
|
+
T.current = !0;
|
|
668
|
+
const o = (e.filters ?? []).filter(
|
|
669
|
+
(p) => !(m[p.param] ?? []).length && !v.has(p.param)
|
|
669
670
|
);
|
|
670
|
-
if (!C || !
|
|
671
|
-
|
|
671
|
+
if (!C || !o.length) {
|
|
672
|
+
g(!0);
|
|
672
673
|
return;
|
|
673
674
|
}
|
|
674
675
|
(async () => {
|
|
675
676
|
try {
|
|
676
|
-
const
|
|
677
|
-
for (const f of
|
|
678
|
-
const b =
|
|
677
|
+
const p = {};
|
|
678
|
+
for (const f of o) {
|
|
679
|
+
const b = Te(C, { key: f.param, collection: f.collection });
|
|
679
680
|
if (!b) continue;
|
|
680
|
-
const y =
|
|
681
|
+
const y = pt(C, b.name);
|
|
681
682
|
if (!y.length) continue;
|
|
682
|
-
const S = f.value_field ?? "id", O = await
|
|
683
|
+
const S = f.value_field ?? "id", O = await ht(
|
|
683
684
|
r,
|
|
684
685
|
b,
|
|
685
686
|
y,
|
|
686
687
|
S
|
|
687
688
|
);
|
|
688
689
|
if (O.length) {
|
|
689
|
-
const R = O.map((
|
|
690
|
-
|
|
690
|
+
const R = O.map((H, se) => ({ [S]: H, id: y[se] }));
|
|
691
|
+
p[f.param] = f.single ? R.slice(0, 1) : R;
|
|
691
692
|
}
|
|
692
693
|
}
|
|
693
|
-
Object.keys(
|
|
694
|
+
Object.keys(p).length && (h((f) => {
|
|
694
695
|
const b = { ...f };
|
|
695
|
-
for (const [y, S] of Object.entries(
|
|
696
|
+
for (const [y, S] of Object.entries(p))
|
|
696
697
|
(b[y] ?? []).length || (b[y] = S);
|
|
697
698
|
return b;
|
|
698
699
|
}), Q(
|
|
699
700
|
new Map(
|
|
700
|
-
Object.entries(
|
|
701
|
+
Object.entries(p).map(([f, b]) => {
|
|
701
702
|
var S;
|
|
702
703
|
const y = ((S = (e.filters ?? []).find((O) => O.param === f)) == null ? void 0 : S.value_field) ?? "id";
|
|
703
|
-
return [f,
|
|
704
|
+
return [f, Oe(b, y)];
|
|
704
705
|
})
|
|
705
706
|
)
|
|
706
707
|
));
|
|
707
708
|
} finally {
|
|
708
|
-
|
|
709
|
+
g(!0);
|
|
709
710
|
}
|
|
710
711
|
})();
|
|
711
712
|
}, [k, C, e.filters, m, r, v]);
|
|
712
|
-
const J =
|
|
713
|
-
const
|
|
714
|
-
for (const
|
|
715
|
-
const f = m[
|
|
716
|
-
f.length > 0 && (
|
|
713
|
+
const J = Re(() => {
|
|
714
|
+
const o = { ...e.params ?? {} };
|
|
715
|
+
for (const p of e.filters ?? []) {
|
|
716
|
+
const f = m[p.param] ?? [];
|
|
717
|
+
f.length > 0 && (o[p.param] = f.map((b) => String(b[p.value_field ?? "id"] ?? "")).join(","));
|
|
717
718
|
}
|
|
718
|
-
return
|
|
719
|
-
}, [e.params, e.filters, m]), [U,
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
),
|
|
723
|
-
() => JSON.parse(
|
|
724
|
-
[
|
|
725
|
-
),
|
|
726
|
-
data:
|
|
727
|
-
isPending:
|
|
728
|
-
error:
|
|
729
|
-
refetch:
|
|
730
|
-
isFetching:
|
|
719
|
+
return o;
|
|
720
|
+
}, [e.params, e.filters, m]), [U, V] = q(/* @__PURE__ */ new Set()), re = D(!1), me = JSON.stringify(J), ze = nt(
|
|
721
|
+
me,
|
|
722
|
+
re.current ? U.size > 0 ? Et : Ft : 0
|
|
723
|
+
), ne = re.current ? ze : me, L = Re(
|
|
724
|
+
() => JSON.parse(ne),
|
|
725
|
+
[ne]
|
|
726
|
+
), ae = D(!1), {
|
|
727
|
+
data: A,
|
|
728
|
+
isPending: pe,
|
|
729
|
+
error: he,
|
|
730
|
+
refetch: xe,
|
|
731
|
+
isFetching: fe,
|
|
731
732
|
isPlaceholderData: Ke
|
|
732
733
|
} = z({
|
|
733
|
-
queryKey: ["page-renderer-query", e.query_slug,
|
|
734
|
+
queryKey: ["page-renderer-query", e.query_slug, ne],
|
|
734
735
|
queryFn: () => {
|
|
735
|
-
const
|
|
736
|
-
return
|
|
737
|
-
|
|
738
|
-
params:
|
|
739
|
-
...
|
|
736
|
+
const o = ae.current;
|
|
737
|
+
return ae.current = !1, r.request(
|
|
738
|
+
Z(`/custom-queries/${e.query_slug}/execute`, {
|
|
739
|
+
params: L,
|
|
740
|
+
...o ? { refresh: !0 } : {}
|
|
740
741
|
})
|
|
741
742
|
);
|
|
742
743
|
},
|
|
743
|
-
enabled: !!e.query_slug &&
|
|
744
|
+
enabled: !!e.query_slug && d,
|
|
744
745
|
staleTime: 6e4,
|
|
745
746
|
// A filter change (FY, zone) keeps the table on screen, dimmed, until the
|
|
746
747
|
// new answer lands: swapping it for the loader unmounted QueryTable and
|
|
747
748
|
// reset its view state — "Hide empty rows" switched itself off (L13).
|
|
748
749
|
// Only the same query's answer stands in; another slug starts fresh.
|
|
749
|
-
placeholderData: (
|
|
750
|
-
}),
|
|
751
|
-
|
|
752
|
-
}, [
|
|
750
|
+
placeholderData: (o, p) => (p == null ? void 0 : p.queryKey[1]) === e.query_slug ? o : void 0
|
|
751
|
+
}), I = A == null ? void 0 : A.data, G = Ke && fe, Qe = Ye(() => {
|
|
752
|
+
ae.current = !0, xe();
|
|
753
|
+
}, [xe]), be = pe;
|
|
753
754
|
if (!e.query_slug) return /* @__PURE__ */ t("div", { className: "p-3 text-[12px] text-slate-400", children: "Set a query slug" });
|
|
754
|
-
const Je = (
|
|
755
|
+
const Je = (o) => {
|
|
755
756
|
var y;
|
|
756
|
-
const
|
|
757
|
-
for (const [S, O] of Object.entries(
|
|
758
|
-
const R =
|
|
757
|
+
const p = {};
|
|
758
|
+
for (const [S, O] of Object.entries(o.params ?? {})) {
|
|
759
|
+
const R = Be(O, null, I ?? [], L, m, e.filters);
|
|
759
760
|
if (R === void 0) {
|
|
760
|
-
|
|
761
|
+
j(`Select a value for "${S}" first`);
|
|
761
762
|
return;
|
|
762
763
|
}
|
|
763
|
-
|
|
764
|
+
p[S] = R;
|
|
764
765
|
}
|
|
765
|
-
const f = (y =
|
|
766
|
-
action:
|
|
767
|
-
params:
|
|
766
|
+
const f = (y = o.confirm) == null ? void 0 : y.replace(/\{(\w+)\}/g, (S, O) => String(p[O] ?? "")), b = {
|
|
767
|
+
action: o,
|
|
768
|
+
params: p,
|
|
768
769
|
phase: f ? "confirm" : "running",
|
|
769
770
|
confirmText: f ?? null,
|
|
770
771
|
startedAt: Date.now(),
|
|
771
772
|
elapsedMs: 0
|
|
772
773
|
};
|
|
773
|
-
|
|
774
|
-
},
|
|
775
|
-
const
|
|
776
|
-
|
|
774
|
+
W(b), f || ge(b);
|
|
775
|
+
}, ge = async (o) => {
|
|
776
|
+
const p = Date.now();
|
|
777
|
+
W({ ...o, phase: "running", startedAt: p, elapsedMs: 0 });
|
|
777
778
|
try {
|
|
778
779
|
const f = await r.request(
|
|
779
|
-
|
|
780
|
+
Z(`/custom-queries/${o.action.query_slug}/execute`, { params: o.params })
|
|
780
781
|
), b = Array.isArray(f == null ? void 0 : f.data) ? f.data : [];
|
|
781
|
-
|
|
782
|
-
(y) => y && y.action ===
|
|
782
|
+
W(
|
|
783
|
+
(y) => y && y.action === o.action ? {
|
|
783
784
|
...y,
|
|
784
785
|
phase: "done",
|
|
785
|
-
elapsedMs: Date.now() -
|
|
786
|
+
elapsedMs: Date.now() - p,
|
|
786
787
|
resultRows: b.length,
|
|
787
788
|
resultSample: b[0] ?? null
|
|
788
789
|
} : y
|
|
789
|
-
),
|
|
790
|
-
`${
|
|
791
|
-
),
|
|
790
|
+
), j(
|
|
791
|
+
`${o.action.success_message ?? `${o.action.label} completed`} · ${Y(Date.now() - p)}`
|
|
792
|
+
), M.invalidateQueries({ queryKey: ["page-renderer-query", e.query_slug] });
|
|
792
793
|
} catch (f) {
|
|
793
|
-
const b =
|
|
794
|
-
|
|
795
|
-
(y) => y && y.action ===
|
|
796
|
-
),
|
|
794
|
+
const b = Ee(f, "unknown error");
|
|
795
|
+
W(
|
|
796
|
+
(y) => y && y.action === o.action ? { ...y, phase: "error", elapsedMs: Date.now() - p, error: b } : y
|
|
797
|
+
), j(`${o.action.label} failed: ${b}`);
|
|
797
798
|
}
|
|
798
799
|
}, Ue = /* @__PURE__ */ t(
|
|
799
|
-
|
|
800
|
+
bt,
|
|
800
801
|
{
|
|
801
|
-
envelope:
|
|
802
|
+
envelope: A,
|
|
802
803
|
onRefresh: Qe,
|
|
803
|
-
refreshing:
|
|
804
|
+
refreshing: fe && !pe,
|
|
804
805
|
className: "ml-auto"
|
|
805
806
|
}
|
|
806
|
-
),
|
|
807
|
-
(e.filters ?? []).map((
|
|
808
|
-
const
|
|
807
|
+
), le = e.filters && e.filters.length > 0 || (ke = e.actions) != null && ke.length || A != null && A.cache_ttl ? /* @__PURE__ */ x("div", { className: "flex flex-wrap items-center gap-2 pb-2", children: [
|
|
808
|
+
(e.filters ?? []).map((o) => {
|
|
809
|
+
const p = Te(C, { key: o.param, collection: o.collection }), f = p ? (C == null ? void 0 : C.restricted[p.name]) ?? [] : [];
|
|
809
810
|
return /* @__PURE__ */ t(
|
|
810
|
-
|
|
811
|
+
Lt,
|
|
811
812
|
{
|
|
812
|
-
filter:
|
|
813
|
-
selected: m[
|
|
813
|
+
filter: o,
|
|
814
|
+
selected: m[o.param] ?? [],
|
|
814
815
|
allowedIds: f.length > 0 ? f : void 0,
|
|
815
|
-
scopeDefault:
|
|
816
|
+
scopeDefault: E.has(o.param) && E.get(o.param) === Oe(m[o.param] ?? [], o.value_field ?? "id"),
|
|
816
817
|
onChange: (b) => {
|
|
817
|
-
|
|
818
|
+
re.current = !0, $(o.param, b);
|
|
818
819
|
},
|
|
819
|
-
onOpenChange: (b) =>
|
|
820
|
-
if (y.has(
|
|
820
|
+
onOpenChange: (b) => V((y) => {
|
|
821
|
+
if (y.has(o.param) === b) return y;
|
|
821
822
|
const S = new Set(y);
|
|
822
|
-
return b ? S.add(
|
|
823
|
+
return b ? S.add(o.param) : S.delete(o.param), S;
|
|
823
824
|
})
|
|
824
825
|
},
|
|
825
|
-
|
|
826
|
+
o.param
|
|
826
827
|
);
|
|
827
828
|
}),
|
|
828
|
-
(e.actions ?? []).map((
|
|
829
|
+
(e.actions ?? []).map((o) => /* @__PURE__ */ t(
|
|
829
830
|
"button",
|
|
830
831
|
{
|
|
831
832
|
type: "button",
|
|
832
|
-
disabled:
|
|
833
|
-
onClick: () => void Je(
|
|
833
|
+
disabled: P,
|
|
834
|
+
onClick: () => void Je(o),
|
|
834
835
|
className: "ml-auto inline-flex h-8 items-center rounded-md bg-nvr-cyan px-3 text-[12px] font-semibold text-white hover:opacity-90 disabled:opacity-50",
|
|
835
|
-
children:
|
|
836
|
+
children: P ? "Running…" : o.label
|
|
836
837
|
},
|
|
837
|
-
|
|
838
|
+
o.label
|
|
838
839
|
)),
|
|
839
840
|
N && /* @__PURE__ */ t("span", { className: "text-[12px] text-slate-500", children: N }),
|
|
840
841
|
Ue
|
|
841
|
-
] }) : null,
|
|
842
|
-
|
|
842
|
+
] }) : null, ye = (we = e.stats) != null && we.length ? /* @__PURE__ */ t(
|
|
843
|
+
yt,
|
|
843
844
|
{
|
|
844
845
|
stats: e.stats,
|
|
845
|
-
rows:
|
|
846
|
-
effectiveParams:
|
|
847
|
-
loading:
|
|
848
|
-
zeroDash: !!((
|
|
846
|
+
rows: I ?? [],
|
|
847
|
+
effectiveParams: L,
|
|
848
|
+
loading: be || G,
|
|
849
|
+
zeroDash: !!((Ne = e.table) != null && Ne.zero_dash)
|
|
849
850
|
}
|
|
850
851
|
) : null;
|
|
851
|
-
if (
|
|
852
|
+
if (be)
|
|
852
853
|
return /* @__PURE__ */ x("div", { className: "p-3", children: [
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
/* @__PURE__ */ t(
|
|
854
|
+
le,
|
|
855
|
+
ye,
|
|
856
|
+
/* @__PURE__ */ t(ee, {})
|
|
856
857
|
] });
|
|
857
|
-
if (
|
|
858
|
+
if (he)
|
|
858
859
|
return /* @__PURE__ */ x("div", { className: "p-3", children: [
|
|
859
|
-
|
|
860
|
-
/* @__PURE__ */ t(
|
|
860
|
+
le,
|
|
861
|
+
/* @__PURE__ */ t(te, { error: he, unresolved: e.unresolved_params })
|
|
861
862
|
] });
|
|
862
|
-
const w = e.row_click,
|
|
863
|
-
const b =
|
|
863
|
+
const w = e.row_click, ve = (o, p, f) => {
|
|
864
|
+
const b = p ? null : f ?? I ?? [], S = ct(o, (R) => Tt(
|
|
864
865
|
R,
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
866
|
+
p,
|
|
867
|
+
I ?? [],
|
|
868
|
+
L,
|
|
868
869
|
m,
|
|
869
870
|
e.filters,
|
|
870
871
|
b
|
|
871
872
|
)), O = S.resolvedTabs.map((R) => {
|
|
872
873
|
if ("matrix" in R) {
|
|
873
|
-
const
|
|
874
|
-
for (const [
|
|
875
|
-
|
|
874
|
+
const H = {};
|
|
875
|
+
for (const [se, ie] of Object.entries(R.matrix.scope))
|
|
876
|
+
H[se] = ie.startsWith("$row.") ? p == null ? void 0 : p[ie.slice(5)] : ie;
|
|
876
877
|
return {
|
|
877
878
|
label: R.label,
|
|
878
|
-
matrix: { config: R.matrix.config, initialScope:
|
|
879
|
+
matrix: { config: R.matrix.config, initialScope: H }
|
|
879
880
|
};
|
|
880
881
|
}
|
|
881
882
|
return { label: R.label, note: R.note, config: R.config };
|
|
882
883
|
});
|
|
883
884
|
s({
|
|
884
885
|
def: {
|
|
885
|
-
...
|
|
886
|
+
...o,
|
|
886
887
|
resolvedTabs: O,
|
|
887
888
|
header: S.header ? {
|
|
888
889
|
config: S.header.config,
|
|
@@ -892,52 +893,52 @@ function De({ config: e }) {
|
|
|
892
893
|
} : null,
|
|
893
894
|
initialTab: S.initialTab
|
|
894
895
|
},
|
|
895
|
-
row:
|
|
896
|
+
row: p,
|
|
896
897
|
totalCount: b ? b.length : null
|
|
897
898
|
});
|
|
898
|
-
}, Ve = w ? (
|
|
899
|
-
w.picker ? l(
|
|
899
|
+
}, Ve = w ? (o) => {
|
|
900
|
+
w.picker ? l(o) : w.sheet ? ve(w.sheet, o) : w.matrix && o.id != null ? c(o.id) : w.drill && o.id != null && (n == null || n.open({
|
|
900
901
|
collection: w.drill.collection ?? "",
|
|
901
|
-
itemId: String(
|
|
902
|
+
itemId: String(o.id),
|
|
902
903
|
layoutId: w.drill.layout_id,
|
|
903
904
|
width: w.drill.width
|
|
904
905
|
}));
|
|
905
|
-
} : void 0, Ge = (
|
|
906
|
-
label:
|
|
907
|
-
onClick: (
|
|
906
|
+
} : void 0, Ge = (Se = e.row_actions) != null && Se.length ? e.row_actions.map((o) => ({
|
|
907
|
+
label: o.label,
|
|
908
|
+
onClick: (p, f) => ve(o.sheet, p, f)
|
|
908
909
|
})) : void 0;
|
|
909
910
|
return /* @__PURE__ */ x(
|
|
910
911
|
"div",
|
|
911
912
|
{
|
|
912
|
-
className: (
|
|
913
|
+
className: ($e = e.table) != null && $e.sticky ? (
|
|
913
914
|
// Sticky grids own their scroll: filters/stats stay pinned above a
|
|
914
915
|
// scrolling table region (header/first-column/totals pin inside it).
|
|
915
916
|
"flex h-full min-h-0 flex-col overflow-hidden p-3"
|
|
916
917
|
) : "h-full overflow-auto p-3",
|
|
917
918
|
children: [
|
|
918
|
-
|
|
919
|
-
|
|
919
|
+
le,
|
|
920
|
+
ye,
|
|
920
921
|
/* @__PURE__ */ t(
|
|
921
922
|
"div",
|
|
922
923
|
{
|
|
923
|
-
"data-qt-refetching":
|
|
924
|
-
"aria-busy":
|
|
925
|
-
className: `transition-opacity ${
|
|
924
|
+
"data-qt-refetching": G ? "" : void 0,
|
|
925
|
+
"aria-busy": G || void 0,
|
|
926
|
+
className: `transition-opacity ${G ? "opacity-60" : ""} ${(_e = e.table) != null && _e.sticky ? "flex min-h-0 flex-1 flex-col" : ""}`.trim(),
|
|
926
927
|
children: /* @__PURE__ */ t(
|
|
927
|
-
|
|
928
|
+
vt,
|
|
928
929
|
{
|
|
929
|
-
rows:
|
|
930
|
+
rows: I ?? [],
|
|
930
931
|
config: (
|
|
931
932
|
// Current-month highlight only applies when the selected year param
|
|
932
933
|
// IS the current year — otherwise strip it.
|
|
933
|
-
(
|
|
934
|
-
String(
|
|
934
|
+
(Ce = e.table) != null && Ce.highlight_group && e.table.highlight_year_param ? Number(
|
|
935
|
+
String(L[e.table.highlight_year_param] ?? "").split(",")[0]
|
|
935
936
|
) === (/* @__PURE__ */ new Date()).getFullYear() ? e.table : { ...e.table, highlight_group: void 0 } : e.table
|
|
936
937
|
),
|
|
937
938
|
onRowClick: Ve,
|
|
938
939
|
rowActions: Ge,
|
|
939
940
|
emptyText: e.empty_label,
|
|
940
|
-
pivotYear: (
|
|
941
|
+
pivotYear: (je = (qe = e.table) == null ? void 0 : qe.pivot) != null && je.year_param && Number(String(L[e.table.pivot.year_param] ?? "").split(",")[0]) || void 0
|
|
941
942
|
}
|
|
942
943
|
)
|
|
943
944
|
}
|
|
@@ -951,30 +952,30 @@ function De({ config: e }) {
|
|
|
951
952
|
"div",
|
|
952
953
|
{
|
|
953
954
|
className: "w-[420px] rounded-lg border border-slate-200 bg-white p-4 shadow-xl dark:border-border dark:bg-background",
|
|
954
|
-
onClick: (
|
|
955
|
+
onClick: (o) => o.stopPropagation(),
|
|
955
956
|
children: [
|
|
956
957
|
/* @__PURE__ */ t("p", { className: "mb-2 text-[13px] font-semibold text-slate-700 dark:text-slate-200", children: w.picker.title ?? "Choose a record" }),
|
|
957
958
|
/* @__PURE__ */ t(
|
|
958
|
-
|
|
959
|
+
gt,
|
|
959
960
|
{
|
|
960
961
|
collection: w.picker.collection,
|
|
961
962
|
value: null,
|
|
962
|
-
onChange: (
|
|
963
|
-
var
|
|
964
|
-
if (l(null),
|
|
963
|
+
onChange: (o) => {
|
|
964
|
+
var p, f, b, y;
|
|
965
|
+
if (l(null), o != null) {
|
|
965
966
|
if (w.matrix) {
|
|
966
|
-
c(
|
|
967
|
+
c(o);
|
|
967
968
|
return;
|
|
968
969
|
}
|
|
969
970
|
n == null || n.open({
|
|
970
|
-
collection: ((
|
|
971
|
-
itemId: String(
|
|
971
|
+
collection: ((p = w.drill) == null ? void 0 : p.collection) ?? ((f = w.picker) == null ? void 0 : f.collection) ?? "",
|
|
972
|
+
itemId: String(o),
|
|
972
973
|
layoutId: (b = w.drill) == null ? void 0 : b.layout_id,
|
|
973
974
|
width: (y = w.drill) == null ? void 0 : y.width
|
|
974
975
|
});
|
|
975
976
|
}
|
|
976
977
|
},
|
|
977
|
-
extraFilter:
|
|
978
|
+
extraFilter: At(w.picker.filter, a, m, e.filters),
|
|
978
979
|
placeholder: "Search…"
|
|
979
980
|
}
|
|
980
981
|
),
|
|
@@ -993,7 +994,7 @@ function De({ config: e }) {
|
|
|
993
994
|
}
|
|
994
995
|
),
|
|
995
996
|
(w == null ? void 0 : w.matrix) && u != null && /* @__PURE__ */ t(
|
|
996
|
-
|
|
997
|
+
Le,
|
|
997
998
|
{
|
|
998
999
|
config: w.matrix.config,
|
|
999
1000
|
initialScope: { [w.matrix.scope_field]: u },
|
|
@@ -1002,22 +1003,22 @@ function De({ config: e }) {
|
|
|
1002
1003
|
onClose: () => c(null)
|
|
1003
1004
|
}
|
|
1004
1005
|
),
|
|
1005
|
-
|
|
1006
|
-
|
|
1006
|
+
i && /* @__PURE__ */ t(
|
|
1007
|
+
Pt,
|
|
1007
1008
|
{
|
|
1008
|
-
def:
|
|
1009
|
-
row:
|
|
1010
|
-
totalCount:
|
|
1009
|
+
def: i.def,
|
|
1010
|
+
row: i.row,
|
|
1011
|
+
totalCount: i.totalCount,
|
|
1011
1012
|
onClose: () => s(null)
|
|
1012
1013
|
}
|
|
1013
1014
|
),
|
|
1014
1015
|
_ && /* @__PURE__ */ t(
|
|
1015
|
-
|
|
1016
|
+
zt,
|
|
1016
1017
|
{
|
|
1017
1018
|
run: _,
|
|
1018
|
-
onConfirm: () => void
|
|
1019
|
+
onConfirm: () => void ge(_),
|
|
1019
1020
|
onClose: () => {
|
|
1020
|
-
|
|
1021
|
+
W(null);
|
|
1021
1022
|
}
|
|
1022
1023
|
}
|
|
1023
1024
|
)
|
|
@@ -1025,15 +1026,15 @@ function De({ config: e }) {
|
|
|
1025
1026
|
}
|
|
1026
1027
|
);
|
|
1027
1028
|
}
|
|
1028
|
-
const
|
|
1029
|
-
function
|
|
1029
|
+
const Y = (e) => e < 6e4 ? `${(e / 1e3).toFixed(e < 1e4 ? 1 : 0)}s` : `${Math.floor(e / 6e4)}m ${Math.round(e % 6e4 / 1e3)}s`;
|
|
1030
|
+
function zt({
|
|
1030
1031
|
run: e,
|
|
1031
1032
|
onConfirm: r,
|
|
1032
1033
|
onClose: n
|
|
1033
1034
|
}) {
|
|
1034
1035
|
const a = Object.entries(e.params);
|
|
1035
1036
|
return Xe(
|
|
1036
|
-
/* @__PURE__ */ x(
|
|
1037
|
+
/* @__PURE__ */ x(B, { children: [
|
|
1037
1038
|
/* @__PURE__ */ t(
|
|
1038
1039
|
"div",
|
|
1039
1040
|
{
|
|
@@ -1052,10 +1053,10 @@ function Dt({
|
|
|
1052
1053
|
children: [
|
|
1053
1054
|
/* @__PURE__ */ t("p", { className: "text-[13.5px] font-semibold text-slate-900 dark:text-foreground", children: e.action.label }),
|
|
1054
1055
|
a.length > 0 && /* @__PURE__ */ t("dl", { className: "mt-2 space-y-0.5 rounded-lg bg-slate-50 px-2.5 py-1.5 text-[11.5px] dark:bg-muted", children: a.map(([l, u]) => /* @__PURE__ */ x("div", { className: "flex gap-2", children: [
|
|
1055
|
-
/* @__PURE__ */ t("dt", { className: "text-slate-500 dark:text-slate-400", children:
|
|
1056
|
+
/* @__PURE__ */ t("dt", { className: "text-slate-500 dark:text-slate-400", children: F(l) }),
|
|
1056
1057
|
/* @__PURE__ */ t("dd", { className: "ml-auto font-medium tabular-nums text-slate-800 dark:text-slate-100", children: String(u) })
|
|
1057
1058
|
] }, l)) }),
|
|
1058
|
-
e.phase === "confirm" && /* @__PURE__ */ x(
|
|
1059
|
+
e.phase === "confirm" && /* @__PURE__ */ x(B, { children: [
|
|
1059
1060
|
/* @__PURE__ */ t("p", { className: "mt-2 text-[12.5px] text-slate-600 dark:text-slate-300", children: e.confirmText }),
|
|
1060
1061
|
/* @__PURE__ */ x("div", { className: "mt-3 flex gap-2", children: [
|
|
1061
1062
|
/* @__PURE__ */ t(
|
|
@@ -1081,17 +1082,17 @@ function Dt({
|
|
|
1081
1082
|
e.phase === "running" && /* @__PURE__ */ x("div", { className: "mt-3 flex items-center gap-2.5 text-[12.5px] text-slate-600 dark:text-slate-300", children: [
|
|
1082
1083
|
/* @__PURE__ */ t("span", { className: "h-4 w-4 shrink-0 animate-spin rounded-full border-2 border-nvr-cyan border-t-transparent" }),
|
|
1083
1084
|
"Running… ",
|
|
1084
|
-
/* @__PURE__ */ t("span", { className: "tabular-nums", children:
|
|
1085
|
+
/* @__PURE__ */ t("span", { className: "tabular-nums", children: Y(e.elapsedMs) })
|
|
1085
1086
|
] }),
|
|
1086
|
-
e.phase === "done" && /* @__PURE__ */ x(
|
|
1087
|
+
e.phase === "done" && /* @__PURE__ */ x(B, { children: [
|
|
1087
1088
|
/* @__PURE__ */ x("p", { className: "mt-2 text-[12.5px] font-medium text-emerald-600 dark:text-emerald-400", children: [
|
|
1088
1089
|
e.action.success_message ?? "Completed",
|
|
1089
1090
|
" · ",
|
|
1090
|
-
|
|
1091
|
+
Y(e.elapsedMs)
|
|
1091
1092
|
] }),
|
|
1092
1093
|
e.resultRows != null && e.resultRows > 0 && e.resultSample && /* @__PURE__ */ x("dl", { className: "mt-2 max-h-40 space-y-0.5 overflow-y-auto rounded-lg bg-slate-50 px-2.5 py-1.5 text-[11.5px] dark:bg-muted", children: [
|
|
1093
1094
|
Object.entries(e.resultSample).slice(0, 8).map(([l, u]) => /* @__PURE__ */ x("div", { className: "flex gap-2", children: [
|
|
1094
|
-
/* @__PURE__ */ t("dt", { className: "text-slate-500 dark:text-slate-400", children:
|
|
1095
|
+
/* @__PURE__ */ t("dt", { className: "text-slate-500 dark:text-slate-400", children: F(l) }),
|
|
1095
1096
|
/* @__PURE__ */ t("dd", { className: "ml-auto font-medium tabular-nums text-slate-800 dark:text-slate-100", children: String(u ?? "—") })
|
|
1096
1097
|
] }, l)),
|
|
1097
1098
|
e.resultRows > 1 && /* @__PURE__ */ x("p", { className: "pt-0.5 text-slate-400", children: [
|
|
@@ -1110,10 +1111,10 @@ function Dt({
|
|
|
1110
1111
|
}
|
|
1111
1112
|
)
|
|
1112
1113
|
] }),
|
|
1113
|
-
e.phase === "error" && /* @__PURE__ */ x(
|
|
1114
|
+
e.phase === "error" && /* @__PURE__ */ x(B, { children: [
|
|
1114
1115
|
/* @__PURE__ */ x("p", { className: "mt-2 text-[12.5px] font-medium text-red-600 dark:text-red-400", children: [
|
|
1115
1116
|
"Failed after ",
|
|
1116
|
-
|
|
1117
|
+
Y(e.elapsedMs),
|
|
1117
1118
|
": ",
|
|
1118
1119
|
e.error
|
|
1119
1120
|
] }),
|
|
@@ -1145,44 +1146,44 @@ function Dt({
|
|
|
1145
1146
|
document.body
|
|
1146
1147
|
);
|
|
1147
1148
|
}
|
|
1148
|
-
function
|
|
1149
|
+
function Pe({ slug: e, widget: r }) {
|
|
1149
1150
|
var n;
|
|
1150
1151
|
switch (r.type) {
|
|
1151
1152
|
case "table":
|
|
1152
|
-
return /* @__PURE__ */ t(
|
|
1153
|
+
return /* @__PURE__ */ t($t, { slug: e, widget: r });
|
|
1153
1154
|
case "kpi":
|
|
1154
|
-
return /* @__PURE__ */ t(
|
|
1155
|
+
return /* @__PURE__ */ t(_t, { slug: e, widget: r });
|
|
1155
1156
|
case "markdown":
|
|
1156
|
-
return /* @__PURE__ */ t(
|
|
1157
|
+
return /* @__PURE__ */ t(St, { content: String(((n = r.config) == null ? void 0 : n.content) ?? "") });
|
|
1157
1158
|
case "iframe":
|
|
1158
|
-
return /* @__PURE__ */ t(
|
|
1159
|
+
return /* @__PURE__ */ t(qt, { widget: r });
|
|
1159
1160
|
case "query":
|
|
1160
|
-
return /* @__PURE__ */ t(
|
|
1161
|
+
return /* @__PURE__ */ t(Bt, { widget: r });
|
|
1161
1162
|
case "matrix":
|
|
1162
|
-
return /* @__PURE__ */ t(
|
|
1163
|
+
return /* @__PURE__ */ t(jt, { widget: r });
|
|
1163
1164
|
case "record-grid":
|
|
1164
|
-
return /* @__PURE__ */ t(
|
|
1165
|
+
return /* @__PURE__ */ t(It, { widget: r });
|
|
1165
1166
|
case "recent-activity":
|
|
1166
|
-
return /* @__PURE__ */ t(
|
|
1167
|
+
return /* @__PURE__ */ t(Ct, { slug: e, widget: r });
|
|
1167
1168
|
default:
|
|
1168
1169
|
return /* @__PURE__ */ t("div", { className: "p-3 text-[12px] text-slate-400", children: "Unknown widget" });
|
|
1169
1170
|
}
|
|
1170
1171
|
}
|
|
1171
|
-
function
|
|
1172
|
-
var
|
|
1173
|
-
const a = K(), l =
|
|
1174
|
-
data:
|
|
1175
|
-
isLoading:
|
|
1176
|
-
error:
|
|
1172
|
+
function hr({ slug: e, hideHeader: r, className: n }) {
|
|
1173
|
+
var k, T;
|
|
1174
|
+
const a = K(), { isAdmin: l } = Ze(), u = Ae(), c = et("drill.page"), i = c.value, {
|
|
1175
|
+
data: s,
|
|
1176
|
+
isLoading: m,
|
|
1177
|
+
error: h
|
|
1177
1178
|
} = z({
|
|
1178
1179
|
queryKey: ["page-renderer", e],
|
|
1179
|
-
queryFn: () => a.request(Fe(`/pages/${e}`)).then((
|
|
1180
|
+
queryFn: () => a.request(Fe(`/pages/${e}`)).then((d) => d.data),
|
|
1180
1181
|
enabled: !!e,
|
|
1181
1182
|
retry: !1
|
|
1182
1183
|
});
|
|
1183
|
-
if (
|
|
1184
|
-
return /* @__PURE__ */ t("div", { className: n ?? "p-6", children: /* @__PURE__ */ t(
|
|
1185
|
-
if (
|
|
1184
|
+
if (m)
|
|
1185
|
+
return /* @__PURE__ */ t("div", { className: n ?? "p-6", children: /* @__PURE__ */ t(ee, {}) });
|
|
1186
|
+
if (h || !s)
|
|
1186
1187
|
return /* @__PURE__ */ x(
|
|
1187
1188
|
"div",
|
|
1188
1189
|
{
|
|
@@ -1193,81 +1194,81 @@ function ur({ slug: e, hideHeader: r, className: n }) {
|
|
|
1193
1194
|
]
|
|
1194
1195
|
}
|
|
1195
1196
|
);
|
|
1196
|
-
const
|
|
1197
|
+
const v = ((k = s.layout) == null ? void 0 : k.columns) ?? 12, $ = lt(((T = s.layout) == null ? void 0 : T.widgets) ?? [], l), N = (d) => {
|
|
1197
1198
|
var g;
|
|
1198
|
-
return (
|
|
1199
|
-
},
|
|
1200
|
-
y:
|
|
1201
|
-
items:
|
|
1202
|
-
})),
|
|
1199
|
+
return (d.type === "matrix" || d.type === "query" || d.type === "record-grid") && ((g = d.config) == null ? void 0 : g.display) === "drawer";
|
|
1200
|
+
}, j = [...new Set($.filter(N).map((d) => d.y))].filter((d) => $.every((g) => N(g) || d < g.y || d >= g.y + Math.max(g.h, 1))).sort((d, g) => d - g), _ = j.map((d) => ({
|
|
1201
|
+
y: d,
|
|
1202
|
+
items: $.filter((g) => g.y === d && N(g)).sort((g, E) => g.x - E.x)
|
|
1203
|
+
})), W = $.filter((d) => !(N(d) && j.includes(d.y))), P = (d) => d - j.filter((g) => g < d).length, M = W.find((d) => {
|
|
1203
1204
|
var g;
|
|
1204
|
-
return (g =
|
|
1205
|
-
}),
|
|
1206
|
-
!r && /* @__PURE__ */ t("div", { className: "shrink-0 pb-4", children: /* @__PURE__ */ t("h1", { className: "text-lg font-semibold text-slate-900 dark:text-slate-100", children:
|
|
1207
|
-
/* @__PURE__ */ t("div", { className: `min-h-0 flex-1 overflow-y-auto ${
|
|
1208
|
-
|
|
1205
|
+
return (g = d.config) == null ? void 0 : g.full_height;
|
|
1206
|
+
}), C = /* @__PURE__ */ x("div", { className: `flex h-full min-h-0 flex-col ${n ?? ""}`, children: [
|
|
1207
|
+
!r && /* @__PURE__ */ t("div", { className: "shrink-0 pb-4", children: /* @__PURE__ */ t("h1", { className: "text-lg font-semibold text-slate-900 dark:text-slate-100", children: s.name }) }),
|
|
1208
|
+
/* @__PURE__ */ t("div", { className: `min-h-0 flex-1 overflow-y-auto ${M ? "flex flex-col" : ""}`, children: $.length === 0 ? /* @__PURE__ */ t("p", { className: "p-6 text-center text-[13px] text-slate-400", children: "This page has no widgets yet." }) : /* @__PURE__ */ x(B, { children: [
|
|
1209
|
+
_.map((d) => /* @__PURE__ */ t("div", { className: "mb-3 flex shrink-0 flex-wrap items-center gap-2", children: d.items.map((g) => /* @__PURE__ */ t(Pe, { slug: s.slug, widget: g }, g.id)) }, d.y)),
|
|
1209
1210
|
/* @__PURE__ */ t(
|
|
1210
1211
|
"div",
|
|
1211
1212
|
{
|
|
1212
|
-
className:
|
|
1213
|
+
className: M ? "grid min-h-0 flex-1 gap-4" : "grid gap-4",
|
|
1213
1214
|
style: {
|
|
1214
|
-
gridTemplateColumns: `repeat(${
|
|
1215
|
+
gridTemplateColumns: `repeat(${v}, minmax(0, 1fr))`,
|
|
1215
1216
|
// repeat(0, …) is INVALID CSS (count must be ≥1) and drops the
|
|
1216
1217
|
// whole declaration — a fill widget in the first row band emits
|
|
1217
1218
|
// just the stretching track.
|
|
1218
|
-
...
|
|
1219
|
-
gridTemplateRows: `${
|
|
1219
|
+
...M ? {
|
|
1220
|
+
gridTemplateRows: `${P(M.y) > 0 ? `repeat(${P(M.y)}, ${oe}px) ` : ""}minmax(${oe * 3}px, 1fr)`
|
|
1220
1221
|
} : {},
|
|
1221
1222
|
gridAutoRows: `${oe}px`
|
|
1222
1223
|
},
|
|
1223
|
-
children:
|
|
1224
|
-
var
|
|
1225
|
-
const g = (
|
|
1224
|
+
children: W.map((d) => {
|
|
1225
|
+
var Q, J, U, V;
|
|
1226
|
+
const g = (d.type === "matrix" || d.type === "query" || d.type === "record-grid") && ((Q = d.config) == null ? void 0 : Q.display) === "drawer", E = d === M;
|
|
1226
1227
|
return /* @__PURE__ */ x(
|
|
1227
1228
|
"div",
|
|
1228
1229
|
{
|
|
1229
1230
|
className: g ? "flex min-h-0 flex-col" : "flex min-h-0 flex-col overflow-hidden rounded-xl border border-slate-200 bg-white shadow-sm dark:border-border dark:bg-card",
|
|
1230
1231
|
style: {
|
|
1231
|
-
gridColumn: `${Math.min(
|
|
1232
|
-
gridRow:
|
|
1232
|
+
gridColumn: `${Math.min(d.x, v - 1) + 1} / span ${Math.min(d.w, v)}`,
|
|
1233
|
+
gridRow: E ? `${P(d.y) + 1} / -1` : `${P(d.y) + 1} / span ${Math.max(d.h, 1)}`
|
|
1233
1234
|
},
|
|
1234
1235
|
children: [
|
|
1235
|
-
!g &&
|
|
1236
|
-
/* @__PURE__ */ t("div", { className: "min-h-0 flex-1", children: /* @__PURE__ */ t(
|
|
1236
|
+
!g && d.type !== "kpi" && d.type !== "markdown" && ((J = d.config) == null ? void 0 : J.hide_label) !== !0 && /* @__PURE__ */ t("div", { className: "shrink-0 border-b border-slate-100 px-3 py-1.5 text-[11px] font-medium uppercase tracking-wide text-slate-400 dark:border-border", children: String(((U = d.config) == null ? void 0 : U.label) ?? "") || (typeof ((V = d.config) == null ? void 0 : V.collection) == "string" ? F(String(d.config.collection)) : F(d.type)) }),
|
|
1237
|
+
/* @__PURE__ */ t("div", { className: "min-h-0 flex-1", children: /* @__PURE__ */ t(Pe, { slug: s.slug, widget: d }) })
|
|
1237
1238
|
]
|
|
1238
1239
|
},
|
|
1239
|
-
|
|
1240
|
+
d.id
|
|
1240
1241
|
);
|
|
1241
1242
|
})
|
|
1242
1243
|
}
|
|
1243
1244
|
)
|
|
1244
1245
|
] }) })
|
|
1245
1246
|
] });
|
|
1246
|
-
return
|
|
1247
|
-
|
|
1248
|
-
|
|
1247
|
+
return u ? C : /* @__PURE__ */ x(tt.Provider, { value: { open: (d) => c.push([d]) }, children: [
|
|
1248
|
+
i != null && i.length ? /* @__PURE__ */ t(
|
|
1249
|
+
kt,
|
|
1249
1250
|
{
|
|
1250
|
-
collection:
|
|
1251
|
-
itemId:
|
|
1252
|
-
layoutId:
|
|
1253
|
-
width:
|
|
1254
|
-
title:
|
|
1255
|
-
stack:
|
|
1256
|
-
onPush: (
|
|
1257
|
-
onPop: () =>
|
|
1258
|
-
onClose: () =>
|
|
1251
|
+
collection: i[0].collection,
|
|
1252
|
+
itemId: i[0].itemId,
|
|
1253
|
+
layoutId: i[0].layoutId,
|
|
1254
|
+
width: i[0].width,
|
|
1255
|
+
title: i[0].title,
|
|
1256
|
+
stack: i,
|
|
1257
|
+
onPush: (d) => c.push([...i, d]),
|
|
1258
|
+
onPop: () => c.back(),
|
|
1259
|
+
onClose: () => c.back(i.length)
|
|
1259
1260
|
}
|
|
1260
1261
|
) : null,
|
|
1261
|
-
|
|
1262
|
+
C
|
|
1262
1263
|
] });
|
|
1263
1264
|
}
|
|
1264
1265
|
export {
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1266
|
+
hr as PageRenderer,
|
|
1267
|
+
Ie as QueryWidgetView,
|
|
1268
|
+
It as RecordGridWidgetBody,
|
|
1269
|
+
Mt as missingRowParamMessage,
|
|
1270
|
+
Tt as resolveSheetConfig,
|
|
1271
|
+
Be as resolveSheetValue,
|
|
1272
|
+
Oe as selectionSignature,
|
|
1273
|
+
Wt as totalSheetTitle
|
|
1273
1274
|
};
|