@nivaro/react 0.3.85 → 0.3.87
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/CollectionBrowserView.js +639 -632
- package/dist/shared/components/WidgetSlot.js +539 -530
- package/dist/shared/components/item-edit/UserChip.js +67 -67
- package/dist/shared/components/profile/PersonAdminTools.js +29 -29
- package/dist/shared/components/profile/session-actions.js +6 -4
- package/package.json +1 -1
|
@@ -1,91 +1,91 @@
|
|
|
1
|
-
import { jsx as t, jsxs as
|
|
2
|
-
import { useQueryClient as
|
|
3
|
-
import { AlertTriangle as
|
|
4
|
-
import { useState as
|
|
5
|
-
import { useApiFetchConfig as
|
|
6
|
-
import { useDebounced as
|
|
7
|
-
import { PRETEND_DOWN_EVENT as
|
|
8
|
-
import { get as
|
|
9
|
-
import { HEADER_CELL_DENSE as
|
|
10
|
-
import { loadErrorText as
|
|
11
|
-
import { affixesFor as
|
|
12
|
-
import { BackgroundRunOffer as
|
|
13
|
-
import { cacheStampTip as
|
|
14
|
-
import { useStagedRelations as
|
|
15
|
-
import { LoadErrorNote as
|
|
16
|
-
import { QueryTable as
|
|
17
|
-
import { CardSkeleton as
|
|
18
|
-
import { Button as
|
|
19
|
-
import { DropdownMenu as
|
|
20
|
-
import { reportSlotScalar as
|
|
21
|
-
import { ReviewListWidget as
|
|
22
|
-
import { RollupWidget as
|
|
23
|
-
const
|
|
24
|
-
ArrowRight:
|
|
25
|
-
ArrowLeft:
|
|
26
|
-
ArrowUp:
|
|
27
|
-
ArrowDown:
|
|
28
|
-
ArrowUpRight:
|
|
29
|
-
ExternalLink:
|
|
30
|
-
Link:
|
|
31
|
-
Share2:
|
|
32
|
-
Check:
|
|
33
|
-
CheckCircle:
|
|
34
|
-
X:
|
|
35
|
-
XCircle:
|
|
36
|
-
Plus:
|
|
37
|
-
Minus:
|
|
38
|
-
Edit:
|
|
39
|
-
Edit2:
|
|
40
|
-
Trash2:
|
|
41
|
-
Save:
|
|
42
|
-
Download:
|
|
43
|
-
Upload:
|
|
44
|
-
Send:
|
|
45
|
-
Eye:
|
|
46
|
-
EyeOff:
|
|
47
|
-
Lock:
|
|
48
|
-
Unlock:
|
|
49
|
-
Star:
|
|
50
|
-
Heart:
|
|
51
|
-
Bookmark:
|
|
52
|
-
Flag:
|
|
53
|
-
AlertCircle:
|
|
54
|
-
AlertTriangle:
|
|
55
|
-
Info:
|
|
56
|
-
HelpCircle:
|
|
57
|
-
Play:
|
|
58
|
-
Pause:
|
|
59
|
-
RefreshCw:
|
|
60
|
-
RotateCcw:
|
|
61
|
-
Settings:
|
|
62
|
-
Sliders:
|
|
63
|
-
Filter:
|
|
64
|
-
Search:
|
|
65
|
-
Power:
|
|
66
|
-
Zap:
|
|
67
|
-
Activity:
|
|
68
|
-
User:
|
|
69
|
-
Users:
|
|
70
|
-
UserPlus:
|
|
71
|
-
UserCheck:
|
|
72
|
-
Mail:
|
|
73
|
-
MessageSquare:
|
|
74
|
-
Phone:
|
|
75
|
-
Bell:
|
|
76
|
-
FileText:
|
|
77
|
-
File:
|
|
78
|
-
Folder:
|
|
79
|
-
Paperclip:
|
|
80
|
-
Calendar:
|
|
81
|
-
Clock:
|
|
82
|
-
Copy:
|
|
83
|
-
Clipboard:
|
|
84
|
-
MoreHorizontal:
|
|
85
|
-
MoreVertical:
|
|
1
|
+
import { jsx as t, jsxs as w, Fragment as ke } from "react/jsx-runtime";
|
|
2
|
+
import { useQueryClient as rt, useQuery as nt } from "@tanstack/react-query";
|
|
3
|
+
import { AlertTriangle as Xe, RefreshCw as Ye, MoreVertical as lt, MoreHorizontal as st, Clipboard as it, Copy as at, Clock as ot, Calendar as ct, Paperclip as dt, Folder as ut, File as ft, FileText as pt, Bell as mt, Phone as ht, MessageSquare as gt, Mail as yt, UserCheck as xt, UserPlus as wt, Users as bt, User as vt, Activity as _t, Zap as Nt, Power as kt, Search as St, Filter as Rt, Sliders as Lt, Settings as Ct, RotateCcw as $t, Pause as Et, Play as Tt, HelpCircle as qt, Info as jt, AlertCircle as Ot, Flag as It, Bookmark as Dt, Heart as At, Star as Wt, Unlock as Ut, Lock as Pt, EyeOff as Mt, Eye as Bt, Send as Ht, Upload as Vt, Download as Ft, Save as Jt, Trash2 as Kt, Edit2 as Qt, Edit as zt, Minus as Gt, Plus as Xt, XCircle as Yt, X as Zt, CheckCircle as er, Check as tr, Share2 as rr, Link as nr, ExternalLink as lr, ArrowUpRight as sr, ArrowDown as ir, ArrowUp as ar, ArrowLeft as or, ArrowRight as cr } from "lucide-react";
|
|
4
|
+
import { useState as M, useRef as re, useCallback as Ue, useEffect as te, useMemo as Pe } from "react";
|
|
5
|
+
import { useApiFetchConfig as Se, useDrilldown as dr, useOptionalNivaroClient as ur } from "../context.js";
|
|
6
|
+
import { useDebounced as fr } from "../hooks/useDebounced.js";
|
|
7
|
+
import { PRETEND_DOWN_EVENT as Me } from "../lib/client-chaos.js";
|
|
8
|
+
import { get as pr, post as mr } from "../lib/commands.js";
|
|
9
|
+
import { HEADER_CELL_DENSE as hr, HEADER_CELL_LIST as gr, HEADER_LABEL as yr, HEADER_VALUE_LINE as xr, HEADER_VALUE_HERO as wr, HEADER_VALUE as br } from "../lib/header-strip.js";
|
|
10
|
+
import { loadErrorText as Be } from "../lib/load-error.js";
|
|
11
|
+
import { affixesFor as de, formatWidgetValue as ue } from "../lib/widget-value-format.js";
|
|
12
|
+
import { BackgroundRunOffer as vr } from "./BackgroundRunOffer.js";
|
|
13
|
+
import { cacheStampTip as _r, CacheStamp as Nr } from "./CacheStamp.js";
|
|
14
|
+
import { useStagedRelations as kr } from "./item-edit/O2MStagingContext.js";
|
|
15
|
+
import { LoadErrorNote as He } from "./LoadErrorNote.js";
|
|
16
|
+
import { QueryTable as Sr } from "./QueryTable.js";
|
|
17
|
+
import { CardSkeleton as we } from "./Skeletons.js";
|
|
18
|
+
import { Button as ce } from "./ui/button.js";
|
|
19
|
+
import { DropdownMenu as Ve, DropdownMenuTrigger as Fe, DropdownMenuContent as Je, DropdownMenuItem as Ke } from "./ui/dropdown-menu.js";
|
|
20
|
+
import { reportSlotScalar as Rr, ReportSlotWidget as Lr } from "./widgets/ReportSlotWidget.js";
|
|
21
|
+
import { ReviewListWidget as Cr } from "./widgets/ReviewListWidget.js";
|
|
22
|
+
import { RollupWidget as $r } from "./widgets/RollupWidget.js";
|
|
23
|
+
const Y = {
|
|
24
|
+
ArrowRight: cr,
|
|
25
|
+
ArrowLeft: or,
|
|
26
|
+
ArrowUp: ar,
|
|
27
|
+
ArrowDown: ir,
|
|
28
|
+
ArrowUpRight: sr,
|
|
29
|
+
ExternalLink: lr,
|
|
30
|
+
Link: nr,
|
|
31
|
+
Share2: rr,
|
|
32
|
+
Check: tr,
|
|
33
|
+
CheckCircle: er,
|
|
34
|
+
X: Zt,
|
|
35
|
+
XCircle: Yt,
|
|
36
|
+
Plus: Xt,
|
|
37
|
+
Minus: Gt,
|
|
38
|
+
Edit: zt,
|
|
39
|
+
Edit2: Qt,
|
|
40
|
+
Trash2: Kt,
|
|
41
|
+
Save: Jt,
|
|
42
|
+
Download: Ft,
|
|
43
|
+
Upload: Vt,
|
|
44
|
+
Send: Ht,
|
|
45
|
+
Eye: Bt,
|
|
46
|
+
EyeOff: Mt,
|
|
47
|
+
Lock: Pt,
|
|
48
|
+
Unlock: Ut,
|
|
49
|
+
Star: Wt,
|
|
50
|
+
Heart: At,
|
|
51
|
+
Bookmark: Dt,
|
|
52
|
+
Flag: It,
|
|
53
|
+
AlertCircle: Ot,
|
|
54
|
+
AlertTriangle: Xe,
|
|
55
|
+
Info: jt,
|
|
56
|
+
HelpCircle: qt,
|
|
57
|
+
Play: Tt,
|
|
58
|
+
Pause: Et,
|
|
59
|
+
RefreshCw: Ye,
|
|
60
|
+
RotateCcw: $t,
|
|
61
|
+
Settings: Ct,
|
|
62
|
+
Sliders: Lt,
|
|
63
|
+
Filter: Rt,
|
|
64
|
+
Search: St,
|
|
65
|
+
Power: kt,
|
|
66
|
+
Zap: Nt,
|
|
67
|
+
Activity: _t,
|
|
68
|
+
User: vt,
|
|
69
|
+
Users: bt,
|
|
70
|
+
UserPlus: wt,
|
|
71
|
+
UserCheck: xt,
|
|
72
|
+
Mail: yt,
|
|
73
|
+
MessageSquare: gt,
|
|
74
|
+
Phone: ht,
|
|
75
|
+
Bell: mt,
|
|
76
|
+
FileText: pt,
|
|
77
|
+
File: ft,
|
|
78
|
+
Folder: ut,
|
|
79
|
+
Paperclip: dt,
|
|
80
|
+
Calendar: ct,
|
|
81
|
+
Clock: ot,
|
|
82
|
+
Copy: at,
|
|
83
|
+
Clipboard: it,
|
|
84
|
+
MoreHorizontal: st,
|
|
85
|
+
MoreVertical: lt
|
|
86
86
|
};
|
|
87
|
-
function
|
|
88
|
-
return /* @__PURE__ */
|
|
87
|
+
function Re({ awaiting: n, dark: a }) {
|
|
88
|
+
return /* @__PURE__ */ w(
|
|
89
89
|
"span",
|
|
90
90
|
{
|
|
91
91
|
className: `text-[12px] font-normal italic ${a ? "text-slate-400" : "text-slate-400 dark:text-slate-500"}`,
|
|
@@ -98,36 +98,36 @@ function ke({ awaiting: n, dark: a }) {
|
|
|
98
98
|
}
|
|
99
99
|
);
|
|
100
100
|
}
|
|
101
|
-
function
|
|
101
|
+
function be({
|
|
102
102
|
label: n,
|
|
103
103
|
value: a,
|
|
104
104
|
display: o,
|
|
105
|
-
loading:
|
|
105
|
+
loading: s,
|
|
106
106
|
awaiting: d
|
|
107
107
|
}) {
|
|
108
|
-
const { prefix:
|
|
108
|
+
const { prefix: g, suffix: v } = de(a, o), b = s ? null : ue(a, o.format ?? "");
|
|
109
109
|
return (
|
|
110
110
|
// Same label / value vocabulary as a field tile in the record sub-header
|
|
111
111
|
// (lib/header-strip.ts) — the two kinds of cell read as one row.
|
|
112
|
-
/* @__PURE__ */
|
|
112
|
+
/* @__PURE__ */ w(
|
|
113
113
|
"div",
|
|
114
114
|
{
|
|
115
|
-
className: `flex h-full min-w-0 flex-col justify-start gap-1 px-4 pt-[9px] pb-2 ${
|
|
115
|
+
className: `flex h-full min-w-0 flex-col justify-start gap-1 px-4 pt-[9px] pb-2 ${hr} ${gr}`,
|
|
116
116
|
children: [
|
|
117
|
-
/* @__PURE__ */ t("span", { className:
|
|
117
|
+
/* @__PURE__ */ t("span", { className: yr, "data-header-label": !0, children: n }),
|
|
118
118
|
/* @__PURE__ */ t(
|
|
119
119
|
"span",
|
|
120
120
|
{
|
|
121
121
|
"data-header-value": !0,
|
|
122
|
-
className: `${
|
|
123
|
-
children:
|
|
122
|
+
className: `${xr} max-w-[232px] items-baseline truncate leading-tight`,
|
|
123
|
+
children: s ? /* @__PURE__ */ t("span", { className: "animate-pulse inline-block h-3.5 w-16 rounded bg-slate-200 dark:bg-[hsl(var(--nvr-skeleton))]" }) : d && a == null ? /* @__PURE__ */ t(Re, { awaiting: d }) : /* @__PURE__ */ w(
|
|
124
124
|
"span",
|
|
125
125
|
{
|
|
126
|
-
className: String(o.format ?? "").startsWith("currency") || /^[$€£¥]/.test(
|
|
126
|
+
className: String(o.format ?? "").startsWith("currency") || /^[$€£¥]/.test(g) ? wr : br,
|
|
127
127
|
children: [
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
128
|
+
g,
|
|
129
|
+
b,
|
|
130
|
+
v
|
|
131
131
|
]
|
|
132
132
|
}
|
|
133
133
|
)
|
|
@@ -138,22 +138,22 @@ function xe({
|
|
|
138
138
|
)
|
|
139
139
|
);
|
|
140
140
|
}
|
|
141
|
-
function
|
|
141
|
+
function Er({
|
|
142
142
|
data: n,
|
|
143
143
|
label: a,
|
|
144
144
|
loading: o,
|
|
145
|
-
widgetConfig:
|
|
145
|
+
widgetConfig: s,
|
|
146
146
|
awaiting: d
|
|
147
147
|
}) {
|
|
148
|
-
const
|
|
148
|
+
const g = "h-full flex items-stretch divide-x divide-slate-200 dark:divide-border [[data-header-list]_&]:w-full [[data-header-list]_&]:flex-col [[data-header-list]_&]:divide-x-0";
|
|
149
149
|
if (n && "values" in n) {
|
|
150
|
-
const
|
|
151
|
-
return
|
|
152
|
-
|
|
150
|
+
const b = n.values ?? [];
|
|
151
|
+
return b.length === 0 ? null : /* @__PURE__ */ t("div", { className: g, children: b.map((_, R) => /* @__PURE__ */ t(
|
|
152
|
+
be,
|
|
153
153
|
{
|
|
154
|
-
label:
|
|
155
|
-
value:
|
|
156
|
-
display:
|
|
154
|
+
label: _.label,
|
|
155
|
+
value: _.value,
|
|
156
|
+
display: _.display ?? {},
|
|
157
157
|
loading: !1,
|
|
158
158
|
awaiting: d
|
|
159
159
|
},
|
|
@@ -161,9 +161,9 @@ function Cr({
|
|
|
161
161
|
)) });
|
|
162
162
|
}
|
|
163
163
|
if (o) {
|
|
164
|
-
const
|
|
165
|
-
return /* @__PURE__ */ t("div", { className:
|
|
166
|
-
|
|
164
|
+
const b = (s == null ? void 0 : s.value_fields) ?? [], _ = b.length > 0 ? b : [{ label: a }];
|
|
165
|
+
return /* @__PURE__ */ t("div", { className: g, children: _.map((R, C) => /* @__PURE__ */ t(
|
|
166
|
+
be,
|
|
167
167
|
{
|
|
168
168
|
label: R.label ?? a,
|
|
169
169
|
display: { prefix: R.prefix ?? "", suffix: R.suffix ?? "", format: R.format ?? "" },
|
|
@@ -173,237 +173,237 @@ function Cr({
|
|
|
173
173
|
)) });
|
|
174
174
|
}
|
|
175
175
|
if (!n) return null;
|
|
176
|
-
const
|
|
177
|
-
return /* @__PURE__ */ t("div", { className:
|
|
178
|
-
|
|
176
|
+
const v = n.display ?? {};
|
|
177
|
+
return /* @__PURE__ */ t("div", { className: g, children: /* @__PURE__ */ t(
|
|
178
|
+
be,
|
|
179
179
|
{
|
|
180
180
|
label: a,
|
|
181
181
|
value: n.value,
|
|
182
|
-
display:
|
|
182
|
+
display: v,
|
|
183
183
|
loading: !1,
|
|
184
184
|
awaiting: d
|
|
185
185
|
}
|
|
186
186
|
) });
|
|
187
187
|
}
|
|
188
|
-
function
|
|
188
|
+
function Tr(n, a) {
|
|
189
189
|
if (Object.hasOwn(n, a)) return n[a] ?? null;
|
|
190
190
|
const o = a.split(".");
|
|
191
|
-
let
|
|
191
|
+
let s = n;
|
|
192
192
|
for (const d of o) {
|
|
193
|
-
if (
|
|
194
|
-
|
|
193
|
+
if (s == null || typeof s != "object") return s ?? null;
|
|
194
|
+
s = s[d];
|
|
195
195
|
}
|
|
196
|
-
return
|
|
196
|
+
return s ?? null;
|
|
197
197
|
}
|
|
198
|
-
function
|
|
198
|
+
function qr(n, a) {
|
|
199
199
|
const o = {};
|
|
200
|
-
for (const
|
|
201
|
-
if (
|
|
202
|
-
o[
|
|
203
|
-
else if (
|
|
204
|
-
o[
|
|
205
|
-
else if (
|
|
200
|
+
for (const s of n)
|
|
201
|
+
if (s.binding_type === "item_field")
|
|
202
|
+
o[s.key] = Tr(a, s.binding_value);
|
|
203
|
+
else if (s.binding_type === "static")
|
|
204
|
+
o[s.key] = s.binding_value;
|
|
205
|
+
else if (s.binding_type === "url_param" && typeof window < "u") {
|
|
206
206
|
const d = new URLSearchParams(window.location.search);
|
|
207
|
-
o[
|
|
207
|
+
o[s.key] = d.get(s.binding_value) ?? null;
|
|
208
208
|
}
|
|
209
209
|
return o;
|
|
210
210
|
}
|
|
211
|
-
function
|
|
211
|
+
function ve({
|
|
212
212
|
data: n,
|
|
213
213
|
awaiting: a
|
|
214
214
|
}) {
|
|
215
|
-
if (a && n.value == null) return /* @__PURE__ */ t(
|
|
216
|
-
const o = n.display ?? {}, { prefix:
|
|
217
|
-
return /* @__PURE__ */
|
|
218
|
-
|
|
219
|
-
/* @__PURE__ */ t("span", { className: "text-2xl font-semibold text-slate-900 dark:text-slate-100", children:
|
|
215
|
+
if (a && n.value == null) return /* @__PURE__ */ t(Re, { awaiting: a });
|
|
216
|
+
const o = n.display ?? {}, { prefix: s, suffix: d } = de(n.value, o), g = ue(n.value, o.format ?? "");
|
|
217
|
+
return /* @__PURE__ */ w("div", { className: "flex items-baseline gap-1", children: [
|
|
218
|
+
s && /* @__PURE__ */ t("span", { className: "text-[13px] text-slate-500", children: s }),
|
|
219
|
+
/* @__PURE__ */ t("span", { className: "text-2xl font-semibold text-slate-900 dark:text-slate-100", children: g }),
|
|
220
220
|
d && /* @__PURE__ */ t("span", { className: "text-[13px] text-slate-500", children: d })
|
|
221
221
|
] });
|
|
222
222
|
}
|
|
223
|
-
function
|
|
223
|
+
function _e({
|
|
224
224
|
label: n,
|
|
225
225
|
value: a,
|
|
226
226
|
display: o,
|
|
227
|
-
dark:
|
|
227
|
+
dark: s,
|
|
228
228
|
loading: d,
|
|
229
|
-
awaiting:
|
|
229
|
+
awaiting: g
|
|
230
230
|
}) {
|
|
231
|
-
const { prefix:
|
|
232
|
-
return /* @__PURE__ */
|
|
231
|
+
const { prefix: v, suffix: b } = de(a, o), _ = d ? null : ue(a, o.format ?? "");
|
|
232
|
+
return /* @__PURE__ */ w("div", { className: "flex flex-col justify-center px-2.5 py-1 min-w-0 gap-0.5", children: [
|
|
233
233
|
/* @__PURE__ */ t(
|
|
234
234
|
"span",
|
|
235
235
|
{
|
|
236
|
-
className: `text-[9px] font-medium uppercase tracking-wider leading-none truncate ${
|
|
236
|
+
className: `text-[9px] font-medium uppercase tracking-wider leading-none truncate ${s ? "text-slate-500" : "text-slate-400"}`,
|
|
237
237
|
children: n
|
|
238
238
|
}
|
|
239
239
|
),
|
|
240
240
|
/* @__PURE__ */ t(
|
|
241
241
|
"span",
|
|
242
242
|
{
|
|
243
|
-
className: `flex items-baseline gap-0.5 text-[13px] font-semibold tabular-nums leading-none ${
|
|
243
|
+
className: `flex items-baseline gap-0.5 text-[13px] font-semibold tabular-nums leading-none ${s ? "text-slate-100" : "text-slate-900"}`,
|
|
244
244
|
children: d ? /* @__PURE__ */ t(
|
|
245
245
|
"span",
|
|
246
246
|
{
|
|
247
|
-
className: `animate-pulse inline-block h-3 w-14 rounded ${
|
|
247
|
+
className: `animate-pulse inline-block h-3 w-14 rounded ${s ? "bg-slate-600" : "bg-slate-200 dark:bg-[hsl(var(--nvr-skeleton))]"}`
|
|
248
248
|
}
|
|
249
|
-
) :
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
249
|
+
) : g && a == null ? /* @__PURE__ */ t(Re, { awaiting: g, dark: s }) : /* @__PURE__ */ w(ke, { children: [
|
|
250
|
+
v && /* @__PURE__ */ t("span", { className: `text-[10px] ${s ? "text-slate-400" : "text-slate-500"}`, children: v }),
|
|
251
|
+
_,
|
|
252
|
+
b && /* @__PURE__ */ t("span", { className: `text-[10px] ${s ? "text-slate-400" : "text-slate-500"}`, children: b })
|
|
253
253
|
] })
|
|
254
254
|
}
|
|
255
255
|
)
|
|
256
256
|
] });
|
|
257
257
|
}
|
|
258
|
-
function
|
|
258
|
+
function jr({
|
|
259
259
|
data: n,
|
|
260
260
|
label: a,
|
|
261
261
|
style: o,
|
|
262
|
-
loading:
|
|
262
|
+
loading: s,
|
|
263
263
|
widgetConfig: d,
|
|
264
|
-
awaiting:
|
|
264
|
+
awaiting: g
|
|
265
265
|
}) {
|
|
266
|
-
const
|
|
266
|
+
const v = o === "pill-dark", b = v ? "flex items-stretch divide-x divide-slate-700 rounded-md bg-slate-800/90 border border-slate-700 overflow-hidden" : "flex items-stretch divide-x divide-slate-200 rounded-md bg-white border border-slate-200 overflow-hidden dark:bg-card dark:border-border dark:divide-border";
|
|
267
267
|
if (n && "values" in n) {
|
|
268
268
|
const R = n.values ?? [];
|
|
269
|
-
return R.length === 0 ? null : /* @__PURE__ */ t("div", { className:
|
|
270
|
-
|
|
269
|
+
return R.length === 0 ? null : /* @__PURE__ */ t("div", { className: b, children: R.map((C, S) => /* @__PURE__ */ t(
|
|
270
|
+
_e,
|
|
271
271
|
{
|
|
272
272
|
label: C.label,
|
|
273
273
|
value: C.value,
|
|
274
274
|
display: C.display ?? {},
|
|
275
|
-
dark:
|
|
275
|
+
dark: v,
|
|
276
276
|
loading: !1,
|
|
277
|
-
awaiting:
|
|
277
|
+
awaiting: g
|
|
278
278
|
},
|
|
279
279
|
S
|
|
280
280
|
)) });
|
|
281
281
|
}
|
|
282
|
-
if (
|
|
282
|
+
if (s) {
|
|
283
283
|
const R = (d == null ? void 0 : d.value_fields) ?? [], C = R.length > 0 ? R : [{ label: a }];
|
|
284
|
-
return /* @__PURE__ */ t("div", { className:
|
|
285
|
-
|
|
284
|
+
return /* @__PURE__ */ t("div", { className: b, children: C.map((S, U) => /* @__PURE__ */ t(
|
|
285
|
+
_e,
|
|
286
286
|
{
|
|
287
287
|
label: S.label ?? a,
|
|
288
288
|
display: { prefix: S.prefix ?? "", suffix: S.suffix ?? "", format: S.format ?? "" },
|
|
289
|
-
dark:
|
|
289
|
+
dark: v,
|
|
290
290
|
loading: !0
|
|
291
291
|
},
|
|
292
|
-
|
|
292
|
+
U
|
|
293
293
|
)) });
|
|
294
294
|
}
|
|
295
295
|
if (!n) return null;
|
|
296
|
-
const
|
|
297
|
-
return /* @__PURE__ */ t("div", { className:
|
|
298
|
-
|
|
296
|
+
const _ = n.display ?? {};
|
|
297
|
+
return /* @__PURE__ */ t("div", { className: b, children: /* @__PURE__ */ t(
|
|
298
|
+
_e,
|
|
299
299
|
{
|
|
300
300
|
label: a,
|
|
301
301
|
value: n.value,
|
|
302
|
-
display:
|
|
303
|
-
dark:
|
|
302
|
+
display: _,
|
|
303
|
+
dark: v,
|
|
304
304
|
loading: !1,
|
|
305
|
-
awaiting:
|
|
305
|
+
awaiting: g
|
|
306
306
|
}
|
|
307
307
|
) });
|
|
308
308
|
}
|
|
309
|
-
function
|
|
309
|
+
function Qe({ data: n }) {
|
|
310
310
|
const a = n.values ?? [];
|
|
311
311
|
return a.length === 0 ? /* @__PURE__ */ t("p", { className: "text-[12px] text-slate-400", children: "No values" }) : /* @__PURE__ */ t(
|
|
312
312
|
"div",
|
|
313
313
|
{
|
|
314
314
|
className: "grid gap-3",
|
|
315
315
|
style: { gridTemplateColumns: `repeat(${Math.min(a.length, 3)}, minmax(0, 1fr))` },
|
|
316
|
-
children: a.map((o,
|
|
317
|
-
var
|
|
318
|
-
const { prefix: d, suffix:
|
|
319
|
-
return /* @__PURE__ */
|
|
316
|
+
children: a.map((o, s) => {
|
|
317
|
+
var b;
|
|
318
|
+
const { prefix: d, suffix: g } = de(o.value, o.display), v = ((b = o.display) == null ? void 0 : b.format) ?? "";
|
|
319
|
+
return /* @__PURE__ */ w("div", { className: "flex flex-col gap-0.5", children: [
|
|
320
320
|
o.label && /* @__PURE__ */ t("span", { className: "text-[11px] text-slate-400 dark:text-slate-500", children: o.label }),
|
|
321
|
-
/* @__PURE__ */
|
|
321
|
+
/* @__PURE__ */ w("div", { className: "flex items-baseline gap-0.5", children: [
|
|
322
322
|
d && /* @__PURE__ */ t("span", { className: "text-[12px] text-slate-500", children: d }),
|
|
323
|
-
/* @__PURE__ */ t("span", { className: "text-xl font-semibold text-slate-900 dark:text-slate-100", children:
|
|
324
|
-
|
|
323
|
+
/* @__PURE__ */ t("span", { className: "text-xl font-semibold text-slate-900 dark:text-slate-100", children: ue(o.value, v) }),
|
|
324
|
+
g && /* @__PURE__ */ t("span", { className: "text-[12px] text-slate-500", children: g })
|
|
325
325
|
] })
|
|
326
|
-
] },
|
|
326
|
+
] }, s);
|
|
327
327
|
})
|
|
328
328
|
}
|
|
329
329
|
);
|
|
330
330
|
}
|
|
331
|
-
function
|
|
331
|
+
function Or({ data: n }) {
|
|
332
332
|
const a = n.rows ?? [], o = n.fields ?? [];
|
|
333
|
-
return a.length === 0 ? /* @__PURE__ */ t("p", { className: "text-[12px] text-slate-400", children: "No items" }) : /* @__PURE__ */ t("div", { className: "overflow-x-auto", children: /* @__PURE__ */
|
|
334
|
-
/* @__PURE__ */ t("thead", { children: /* @__PURE__ */ t("tr", { className: "border-b border-slate-100", children: o.map((
|
|
335
|
-
/* @__PURE__ */ t("tbody", { children: a.map((
|
|
333
|
+
return a.length === 0 ? /* @__PURE__ */ t("p", { className: "text-[12px] text-slate-400", children: "No items" }) : /* @__PURE__ */ t("div", { className: "overflow-x-auto", children: /* @__PURE__ */ w("table", { className: "w-full text-[12px]", children: [
|
|
334
|
+
/* @__PURE__ */ t("thead", { children: /* @__PURE__ */ t("tr", { className: "border-b border-slate-100", children: o.map((s) => /* @__PURE__ */ t("th", { className: "py-1 pr-3 text-left font-medium text-slate-500", children: s }, s)) }) }),
|
|
335
|
+
/* @__PURE__ */ t("tbody", { children: a.map((s, d) => /* @__PURE__ */ t("tr", { className: "border-b border-slate-50", children: o.map((g) => /* @__PURE__ */ t("td", { className: "py-1 pr-3 text-slate-700", children: String(s[g] ?? "") }, g)) }, d)) })
|
|
336
336
|
] }) });
|
|
337
337
|
}
|
|
338
|
-
function
|
|
338
|
+
function ze({
|
|
339
339
|
data: n,
|
|
340
340
|
widgetId: a,
|
|
341
341
|
inputs: o,
|
|
342
|
-
apiBase:
|
|
342
|
+
apiBase: s,
|
|
343
343
|
onAction: d
|
|
344
344
|
}) {
|
|
345
|
-
const
|
|
346
|
-
|
|
345
|
+
const g = n.buttons ?? [], [v, b] = M(null), _ = Se(), R = async (C) => {
|
|
346
|
+
b(C);
|
|
347
347
|
try {
|
|
348
|
-
const S = typeof window < "u" ? localStorage.getItem("nivaro_workspace") ?? "" : "",
|
|
348
|
+
const S = typeof window < "u" ? localStorage.getItem("nivaro_workspace") ?? "" : "", $ = (await (await fetch(`${s}/widgets-internal/${a}/action`, {
|
|
349
349
|
method: "POST",
|
|
350
350
|
headers: {
|
|
351
351
|
"Content-Type": "application/json",
|
|
352
|
-
...
|
|
352
|
+
..._.authHeaders,
|
|
353
353
|
...S ? { "x-workspace": S } : {}
|
|
354
354
|
},
|
|
355
|
-
credentials:
|
|
355
|
+
credentials: _.credentials,
|
|
356
356
|
body: JSON.stringify({ button_index: C, inputs: o })
|
|
357
357
|
})).json()).data;
|
|
358
|
-
if (
|
|
358
|
+
if ($ != null && $.redirect_url)
|
|
359
359
|
try {
|
|
360
|
-
const
|
|
361
|
-
|
|
360
|
+
const E = new URL($.redirect_url, window.location.origin);
|
|
361
|
+
E.origin === window.location.origin && (window.location.href = E.toString());
|
|
362
362
|
} catch {
|
|
363
363
|
}
|
|
364
|
-
d == null || d(
|
|
364
|
+
d == null || d($);
|
|
365
365
|
} finally {
|
|
366
|
-
|
|
366
|
+
b(null);
|
|
367
367
|
}
|
|
368
368
|
};
|
|
369
|
-
return /* @__PURE__ */ t("div", { className: "flex flex-wrap gap-2", children:
|
|
370
|
-
const
|
|
369
|
+
return /* @__PURE__ */ t("div", { className: "flex flex-wrap gap-2", children: g.map((C, S) => {
|
|
370
|
+
const U = C.style ?? "secondary", A = "inline-flex items-center gap-1.5 rounded px-3 py-1.5 text-[12px] font-medium transition-colors disabled:opacity-50", $ = U === "primary" ? `${A} bg-nvr-cyan text-white hover:bg-nvr-cyan/90` : U === "danger" ? `${A} bg-red-500 text-white hover:bg-red-600` : `${A} border border-slate-200 bg-white text-slate-700 hover:bg-slate-50`;
|
|
371
371
|
return /* @__PURE__ */ t(
|
|
372
372
|
"button",
|
|
373
373
|
{
|
|
374
374
|
type: "button",
|
|
375
|
-
className:
|
|
376
|
-
disabled:
|
|
375
|
+
className: $,
|
|
376
|
+
disabled: v !== null,
|
|
377
377
|
onClick: () => R(S),
|
|
378
|
-
children:
|
|
378
|
+
children: v === S ? "…" : String(C.label ?? `Action ${S + 1}`)
|
|
379
379
|
},
|
|
380
380
|
S
|
|
381
381
|
);
|
|
382
382
|
}) });
|
|
383
383
|
}
|
|
384
|
-
const
|
|
385
|
-
function
|
|
384
|
+
const Ir = /* @__PURE__ */ new Set(["navigate", "field-update", "flow", "toggle"]);
|
|
385
|
+
function Ne({
|
|
386
386
|
buttons: n,
|
|
387
387
|
layout: a,
|
|
388
388
|
widgetId: o,
|
|
389
|
-
inputs:
|
|
389
|
+
inputs: s,
|
|
390
390
|
apiBase: d,
|
|
391
|
-
onClientAction:
|
|
391
|
+
onClientAction: g
|
|
392
392
|
}) {
|
|
393
|
-
const [
|
|
394
|
-
function
|
|
393
|
+
const [v, b] = M(null), [_, R] = M(null), [C, S] = M({}), U = re(null), A = Se();
|
|
394
|
+
function $(e) {
|
|
395
395
|
return e === !0 || e === 1 ? "1" : e === !1 || e === 0 ? "0" : String(e ?? "");
|
|
396
396
|
}
|
|
397
|
-
function
|
|
397
|
+
function E(e, f) {
|
|
398
398
|
const u = e.id ?? String(f);
|
|
399
|
-
return C[u] !== void 0 ? C[u] : e.is_on !== void 0 ? e.is_on :
|
|
399
|
+
return C[u] !== void 0 ? C[u] : e.is_on !== void 0 ? e.is_on : $(s[e.toggle_input ?? ""]) === $(e.toggle_on_value ?? "1");
|
|
400
400
|
}
|
|
401
|
-
function
|
|
401
|
+
function Z(e, f) {
|
|
402
402
|
if (e.action !== "toggle") return e.label ?? `Action ${f + 1}`;
|
|
403
|
-
const u = e.action_config, p = e.toggle_input || (u == null ? void 0 : u.toggle_input) || (u == null ? void 0 : u.field) || "",
|
|
404
|
-
return T
|
|
403
|
+
const u = e.action_config, p = e.toggle_input || (u == null ? void 0 : u.toggle_input) || (u == null ? void 0 : u.field) || "", T = p && p !== e.toggle_input ? { ...e, toggle_input: p } : e;
|
|
404
|
+
return E(T, f) ? e.label_on || e.label || `Action ${f + 1}` : e.label_off || e.label || `Action ${f + 1}`;
|
|
405
405
|
}
|
|
406
|
-
function
|
|
406
|
+
function fe(e) {
|
|
407
407
|
try {
|
|
408
408
|
if (e.startsWith("/") && !e.startsWith("//")) return e;
|
|
409
409
|
const f = new URL(e, window.location.origin);
|
|
@@ -416,38 +416,38 @@ function ve({
|
|
|
416
416
|
const u = e.id ?? String(f);
|
|
417
417
|
R(u);
|
|
418
418
|
try {
|
|
419
|
-
const p = typeof window < "u" ? localStorage.getItem("nivaro_workspace") ?? "" : "",
|
|
419
|
+
const p = typeof window < "u" ? localStorage.getItem("nivaro_workspace") ?? "" : "", x = (await (await fetch(`${d}/widgets-internal/${o}/action`, {
|
|
420
420
|
method: "POST",
|
|
421
421
|
headers: {
|
|
422
422
|
"Content-Type": "application/json",
|
|
423
|
-
...
|
|
423
|
+
...A.authHeaders,
|
|
424
424
|
...p ? { "x-workspace": p } : {}
|
|
425
425
|
},
|
|
426
|
-
credentials:
|
|
427
|
-
body: JSON.stringify({ button_index: f, inputs:
|
|
426
|
+
credentials: A.credentials,
|
|
427
|
+
body: JSON.stringify({ button_index: f, inputs: s })
|
|
428
428
|
})).json()).data;
|
|
429
|
-
if (
|
|
429
|
+
if (x != null && x.redirect_url)
|
|
430
430
|
try {
|
|
431
|
-
const
|
|
432
|
-
|
|
431
|
+
const N = new URL(x.redirect_url, window.location.origin);
|
|
432
|
+
N.origin === window.location.origin && (window.location.href = N.toString());
|
|
433
433
|
} catch {
|
|
434
434
|
}
|
|
435
435
|
} finally {
|
|
436
436
|
R(null);
|
|
437
437
|
}
|
|
438
438
|
}
|
|
439
|
-
function
|
|
439
|
+
function G(e, f) {
|
|
440
440
|
const u = e.action ?? "open-url";
|
|
441
|
-
if (
|
|
441
|
+
if (Ir.has(u)) {
|
|
442
442
|
if (u === "toggle") {
|
|
443
443
|
const p = e.id ?? String(f);
|
|
444
|
-
S((
|
|
444
|
+
S((T) => ({ ...T, [p]: !E(e, f) }));
|
|
445
445
|
}
|
|
446
446
|
r(e, f);
|
|
447
447
|
return;
|
|
448
448
|
}
|
|
449
449
|
if (u === "open-url" && e.url) {
|
|
450
|
-
const p =
|
|
450
|
+
const p = fe(e.url);
|
|
451
451
|
if (!p) return;
|
|
452
452
|
e.new_tab ? window.open(p, "_blank", "noopener,noreferrer") : window.location.href = p;
|
|
453
453
|
} else if (u === "email") {
|
|
@@ -456,46 +456,46 @@ function ve({
|
|
|
456
456
|
} else if (u === "copy") {
|
|
457
457
|
const p = e.copy_value ?? "";
|
|
458
458
|
navigator.clipboard.writeText(p).then(() => {
|
|
459
|
-
|
|
459
|
+
b(e.id ?? String(f)), U.current && clearTimeout(U.current), U.current = setTimeout(() => b(null), 1800);
|
|
460
460
|
});
|
|
461
|
-
} else u === "open-sidebar" && e.sidebar_collection && e.sidebar_id && (
|
|
461
|
+
} else u === "open-sidebar" && e.sidebar_collection && e.sidebar_id && (g == null || g({
|
|
462
462
|
type: "open-sidebar",
|
|
463
463
|
collection: e.sidebar_collection,
|
|
464
464
|
itemId: e.sidebar_id
|
|
465
465
|
}));
|
|
466
466
|
}
|
|
467
|
-
function
|
|
467
|
+
function i(e) {
|
|
468
468
|
const f = e.replace("#", "");
|
|
469
469
|
if (f.length < 6) return !0;
|
|
470
|
-
const u = parseInt(f.slice(0, 2), 16), p = parseInt(f.slice(2, 4), 16),
|
|
471
|
-
return (u * 299 + p * 587 +
|
|
470
|
+
const u = parseInt(f.slice(0, 2), 16), p = parseInt(f.slice(2, 4), 16), T = parseInt(f.slice(4, 6), 16);
|
|
471
|
+
return (u * 299 + p * 587 + T * 114) / 1e3 > 128;
|
|
472
472
|
}
|
|
473
|
-
function
|
|
474
|
-
const p = e.id ?? String(f),
|
|
475
|
-
let
|
|
476
|
-
const
|
|
473
|
+
function ne(e, f, u) {
|
|
474
|
+
const p = e.id ?? String(f), T = v === p, P = _ === p;
|
|
475
|
+
let x = e.label ?? "Button", N = e.variant ?? "secondary";
|
|
476
|
+
const B = e.action_config, I = e.toggle_input || (B == null ? void 0 : B.toggle_input) || (B == null ? void 0 : B.field) || "";
|
|
477
477
|
if (e.action === "toggle") {
|
|
478
|
-
const
|
|
479
|
-
|
|
478
|
+
const q = I && I !== e.toggle_input ? { ...e, toggle_input: I } : e, J = E(q, f);
|
|
479
|
+
x = J ? e.label_on || x : e.label_off || x, N = J ? e.variant_on ?? N : e.variant_off ?? N;
|
|
480
480
|
}
|
|
481
|
-
const
|
|
481
|
+
const F = e.icon ? Y[e.icon] : null, L = e.color ? {
|
|
482
482
|
backgroundColor: e.color,
|
|
483
483
|
borderColor: e.color,
|
|
484
|
-
color:
|
|
484
|
+
color: i(e.color) ? "#1e293b" : "#ffffff"
|
|
485
485
|
} : void 0;
|
|
486
|
-
return /* @__PURE__ */
|
|
487
|
-
|
|
486
|
+
return /* @__PURE__ */ w(
|
|
487
|
+
ce,
|
|
488
488
|
{
|
|
489
489
|
type: "button",
|
|
490
|
-
variant:
|
|
490
|
+
variant: N,
|
|
491
491
|
size: "sm",
|
|
492
492
|
className: "h-7 gap-1.5 text-[12px]",
|
|
493
493
|
style: L,
|
|
494
|
-
disabled:
|
|
495
|
-
onClick: () =>
|
|
494
|
+
disabled: _ !== null,
|
|
495
|
+
onClick: () => G(e, f),
|
|
496
496
|
children: [
|
|
497
|
-
|
|
498
|
-
|
|
497
|
+
F && /* @__PURE__ */ t(F, { className: "h-3.5 w-3.5 shrink-0" }),
|
|
498
|
+
P ? "…" : T ? "✓ Copied" : x
|
|
499
499
|
]
|
|
500
500
|
},
|
|
501
501
|
p
|
|
@@ -503,31 +503,31 @@ function ve({
|
|
|
503
503
|
}
|
|
504
504
|
if (n.length === 0) return null;
|
|
505
505
|
if (a === "split" && n.length > 1) {
|
|
506
|
-
const [e, ...f] = n, u = e.id ?? "0", p =
|
|
507
|
-
let
|
|
508
|
-
const
|
|
509
|
-
if (e.action === "toggle" &&
|
|
510
|
-
const L =
|
|
511
|
-
|
|
506
|
+
const [e, ...f] = n, u = e.id ?? "0", p = _ === u, T = e.action === "none" || !e.action;
|
|
507
|
+
let P = e.label ?? "Button", x = e.variant ?? "default";
|
|
508
|
+
const N = e.action_config, B = e.toggle_input || (N == null ? void 0 : N.toggle_input) || (N == null ? void 0 : N.field) || "";
|
|
509
|
+
if (e.action === "toggle" && B) {
|
|
510
|
+
const L = B !== e.toggle_input ? { ...e, toggle_input: B } : e, q = E(L, 0);
|
|
511
|
+
P = q ? e.label_on || P : e.label_off || P, x = q ? e.variant_on ?? x : e.variant_off ?? x;
|
|
512
512
|
}
|
|
513
|
-
const I = e.icon ?
|
|
513
|
+
const I = e.icon ? Y[e.icon] : null, F = e.color ? {
|
|
514
514
|
backgroundColor: e.color,
|
|
515
515
|
borderColor: e.color,
|
|
516
|
-
color:
|
|
516
|
+
color: i(e.color) ? "#1e293b" : "#ffffff"
|
|
517
517
|
} : void 0;
|
|
518
|
-
return
|
|
519
|
-
/* @__PURE__ */ t(
|
|
520
|
-
|
|
518
|
+
return T ? /* @__PURE__ */ t("div", { className: "flex items-center", children: /* @__PURE__ */ w(Ve, { children: [
|
|
519
|
+
/* @__PURE__ */ t(Fe, { asChild: !0, children: /* @__PURE__ */ w(
|
|
520
|
+
ce,
|
|
521
521
|
{
|
|
522
522
|
type: "button",
|
|
523
|
-
variant:
|
|
523
|
+
variant: x,
|
|
524
524
|
size: "sm",
|
|
525
525
|
className: "h-7 gap-1.5 text-[12px]",
|
|
526
|
-
style:
|
|
527
|
-
disabled:
|
|
526
|
+
style: F,
|
|
527
|
+
disabled: _ !== null,
|
|
528
528
|
children: [
|
|
529
529
|
I && /* @__PURE__ */ t(I, { className: "h-3.5 w-3.5 shrink-0" }),
|
|
530
|
-
|
|
530
|
+
P,
|
|
531
531
|
/* @__PURE__ */ t("svg", { width: "12", height: "12", viewBox: "0 0 12 12", fill: "none", "aria-hidden": "true", children: /* @__PURE__ */ t(
|
|
532
532
|
"path",
|
|
533
533
|
{
|
|
@@ -541,48 +541,48 @@ function ve({
|
|
|
541
541
|
]
|
|
542
542
|
}
|
|
543
543
|
) }),
|
|
544
|
-
/* @__PURE__ */ t(
|
|
545
|
-
|
|
544
|
+
/* @__PURE__ */ t(Je, { align: "end", className: "min-w-[140px]", children: f.map((L, q) => /* @__PURE__ */ w(
|
|
545
|
+
Ke,
|
|
546
546
|
{
|
|
547
547
|
className: "cursor-pointer text-[12px]",
|
|
548
|
-
onSelect: () =>
|
|
548
|
+
onSelect: () => G(L, q + 1),
|
|
549
549
|
children: [
|
|
550
|
-
L.icon &&
|
|
551
|
-
const
|
|
552
|
-
return /* @__PURE__ */ t(
|
|
550
|
+
L.icon && Y[L.icon] && (() => {
|
|
551
|
+
const J = Y[L.icon];
|
|
552
|
+
return /* @__PURE__ */ t(J, { className: "mr-1.5 h-3.5 w-3.5 shrink-0" });
|
|
553
553
|
})(),
|
|
554
|
-
|
|
554
|
+
Z(L, q + 1)
|
|
555
555
|
]
|
|
556
556
|
},
|
|
557
|
-
L.id ??
|
|
557
|
+
L.id ?? q
|
|
558
558
|
)) })
|
|
559
|
-
] }) }) : /* @__PURE__ */
|
|
560
|
-
/* @__PURE__ */
|
|
561
|
-
|
|
559
|
+
] }) }) : /* @__PURE__ */ w("div", { className: "flex items-center", children: [
|
|
560
|
+
/* @__PURE__ */ w(
|
|
561
|
+
ce,
|
|
562
562
|
{
|
|
563
563
|
type: "button",
|
|
564
|
-
variant:
|
|
564
|
+
variant: x,
|
|
565
565
|
size: "sm",
|
|
566
566
|
className: "h-7 rounded-r-none text-[12px] gap-1.5 border-r-0",
|
|
567
|
-
style:
|
|
568
|
-
disabled:
|
|
569
|
-
onClick: () =>
|
|
567
|
+
style: F,
|
|
568
|
+
disabled: _ !== null,
|
|
569
|
+
onClick: () => G(e, 0),
|
|
570
570
|
children: [
|
|
571
571
|
I && /* @__PURE__ */ t(I, { className: "h-3.5 w-3.5 shrink-0" }),
|
|
572
|
-
p ? "…" :
|
|
572
|
+
p ? "…" : v === u ? "✓ Copied" : P
|
|
573
573
|
]
|
|
574
574
|
}
|
|
575
575
|
),
|
|
576
|
-
/* @__PURE__ */
|
|
577
|
-
/* @__PURE__ */ t(
|
|
578
|
-
|
|
576
|
+
/* @__PURE__ */ w(Ve, { children: [
|
|
577
|
+
/* @__PURE__ */ t(Fe, { asChild: !0, children: /* @__PURE__ */ t(
|
|
578
|
+
ce,
|
|
579
579
|
{
|
|
580
580
|
type: "button",
|
|
581
|
-
variant:
|
|
581
|
+
variant: x,
|
|
582
582
|
size: "sm",
|
|
583
583
|
className: "h-7 rounded-l-none px-1.5 text-[12px]",
|
|
584
|
-
style:
|
|
585
|
-
disabled:
|
|
584
|
+
style: F,
|
|
585
|
+
disabled: _ !== null,
|
|
586
586
|
"aria-label": "More actions",
|
|
587
587
|
children: /* @__PURE__ */ t("svg", { width: "12", height: "12", viewBox: "0 0 12 12", fill: "none", "aria-hidden": "true", children: /* @__PURE__ */ t(
|
|
588
588
|
"path",
|
|
@@ -596,320 +596,329 @@ function ve({
|
|
|
596
596
|
) })
|
|
597
597
|
}
|
|
598
598
|
) }),
|
|
599
|
-
/* @__PURE__ */ t(
|
|
600
|
-
|
|
599
|
+
/* @__PURE__ */ t(Je, { align: "end", className: "min-w-[140px]", children: f.map((L, q) => /* @__PURE__ */ w(
|
|
600
|
+
Ke,
|
|
601
601
|
{
|
|
602
602
|
className: "text-[12px]",
|
|
603
|
-
onSelect: () =>
|
|
603
|
+
onSelect: () => G(L, q + 1),
|
|
604
604
|
children: [
|
|
605
|
-
L.icon &&
|
|
606
|
-
const
|
|
607
|
-
return /* @__PURE__ */ t(
|
|
605
|
+
L.icon && Y[L.icon] && (() => {
|
|
606
|
+
const J = Y[L.icon];
|
|
607
|
+
return /* @__PURE__ */ t(J, { className: "mr-1.5 h-3.5 w-3.5 shrink-0" });
|
|
608
608
|
})(),
|
|
609
|
-
|
|
609
|
+
Z(L, q + 1)
|
|
610
610
|
]
|
|
611
611
|
},
|
|
612
|
-
L.id ??
|
|
612
|
+
L.id ?? q
|
|
613
613
|
)) })
|
|
614
614
|
] })
|
|
615
615
|
] });
|
|
616
616
|
}
|
|
617
|
-
return /* @__PURE__ */ t("div", { className: "flex flex-wrap items-center gap-1.5", children: n.map((e, f) =>
|
|
617
|
+
return /* @__PURE__ */ t("div", { className: "flex flex-wrap items-center gap-1.5", children: n.map((e, f) => ne(e, f)) });
|
|
618
618
|
}
|
|
619
|
-
function
|
|
620
|
-
var
|
|
619
|
+
function Ge(n, a) {
|
|
620
|
+
var s;
|
|
621
621
|
if (a == null) return { next: n, moved: !1 };
|
|
622
|
-
const o = ((
|
|
622
|
+
const o = ((s = a == null ? void 0 : a.instance) == null ? void 0 : s.current_state) ?? null;
|
|
623
623
|
return { next: o, moved: n !== void 0 && n !== o };
|
|
624
624
|
}
|
|
625
|
-
function
|
|
625
|
+
function sn({
|
|
626
626
|
widgetId: n,
|
|
627
627
|
inputBindings: a = [],
|
|
628
628
|
itemDraft: o = {},
|
|
629
|
-
itemCollection:
|
|
629
|
+
itemCollection: s,
|
|
630
630
|
ready: d = !0,
|
|
631
|
-
label:
|
|
632
|
-
defaultExpanded:
|
|
633
|
-
frameless:
|
|
634
|
-
apiBase:
|
|
631
|
+
label: g,
|
|
632
|
+
defaultExpanded: v = !0,
|
|
633
|
+
frameless: b = !1,
|
|
634
|
+
apiBase: _,
|
|
635
635
|
compact: R = !1,
|
|
636
636
|
strip: C = !1,
|
|
637
637
|
onClientAction: S,
|
|
638
|
-
onWidgetType:
|
|
639
|
-
onContentChange:
|
|
638
|
+
onWidgetType: U,
|
|
639
|
+
onContentChange: A
|
|
640
640
|
}) {
|
|
641
|
-
var
|
|
642
|
-
const
|
|
643
|
-
|
|
644
|
-
}, []),
|
|
645
|
-
|
|
641
|
+
var De, Ae;
|
|
642
|
+
const $ = Se(), E = _ ?? $.apiBase, [Z, fe] = M(v), [r, G] = M(null), [i, ne] = M(null), [e, f] = M(!0), [u, p] = M(!0), [T, P] = M(!0), [x, N] = M(null), [B, I] = M(0), [F, L] = M(null), q = re(!1), J = Ue(() => {
|
|
643
|
+
q.current = !0, I((l) => l + 1);
|
|
644
|
+
}, []), K = re(null), le = re(void 0), pe = re(!1), se = rt();
|
|
645
|
+
te(() => {
|
|
646
|
+
var k;
|
|
646
647
|
const l = r == null ? void 0 : r.widget_type;
|
|
647
648
|
if (l !== "rollup" && l !== "review_list" && l !== "custom-query") return;
|
|
648
649
|
let c = null;
|
|
649
|
-
if (
|
|
650
|
-
const
|
|
651
|
-
(
|
|
650
|
+
if (le.current === void 0 && K.current != null) {
|
|
651
|
+
const h = se.getQueryCache().findAll({ queryKey: ["pipeline-instance-lock"] }).find((O) => String(O.queryKey[2]) === String(K.current));
|
|
652
|
+
(h == null ? void 0 : h.state.status) === "success" && (le.current = Ge(void 0, h.state.data).next);
|
|
653
|
+
}
|
|
654
|
+
const m = /* @__PURE__ */ new WeakMap();
|
|
655
|
+
for (const h of se.getQueryCache().getAll()) {
|
|
656
|
+
const O = (k = h.queryKey) == null ? void 0 : k[0];
|
|
657
|
+
typeof O != "string" || h.state.status !== "success" || (O.startsWith("o2m-rows") || O.startsWith("nested") || O === "match-agg" || O === "m2m-items") && m.set(h, h.state.data);
|
|
652
658
|
}
|
|
653
|
-
const
|
|
654
|
-
var
|
|
655
|
-
if (
|
|
656
|
-
const
|
|
657
|
-
if (typeof
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
O.current = !0, I((Ze) => Ze + 1);
|
|
665
|
-
}, 400);
|
|
659
|
+
const j = se.getQueryCache().subscribe((h) => {
|
|
660
|
+
var We;
|
|
661
|
+
if (h.type !== "updated" || ((We = h.action) == null ? void 0 : We.type) !== "success") return;
|
|
662
|
+
const O = h.query.queryKey, W = O == null ? void 0 : O[0];
|
|
663
|
+
if (typeof W != "string") return;
|
|
664
|
+
if (W.startsWith("o2m-rows") || W.startsWith("nested") || W === "match-agg" || W === "m2m-items") {
|
|
665
|
+
const X = m.has(h.query), xe = m.get(h.query);
|
|
666
|
+
if (m.set(h.query, h.query.state.data), X && xe === h.query.state.data) return;
|
|
667
|
+
}
|
|
668
|
+
if (W === "pipeline-instance-lock") {
|
|
669
|
+
if (K.current == null || String(O[2]) !== String(K.current))
|
|
666
670
|
return;
|
|
667
|
-
|
|
668
|
-
|
|
671
|
+
const X = Ge(le.current, h.query.state.data);
|
|
672
|
+
if (le.current = X.next, !X.moved) return;
|
|
673
|
+
c && clearTimeout(c), c = setTimeout(() => {
|
|
674
|
+
q.current = !0, I((xe) => xe + 1);
|
|
675
|
+
}, 400);
|
|
676
|
+
return;
|
|
669
677
|
}
|
|
678
|
+
!W.startsWith("o2m-rows") && !W.startsWith("nested") && W !== "match-agg" && W !== "m2m-items" || h.query.state.dataUpdateCount <= 1 || W.startsWith("o2m-rows") && K.current != null && String(O[3]) !== String(K.current) || (c && clearTimeout(c), c = setTimeout(() => I((X) => X + 1), 400));
|
|
670
679
|
});
|
|
671
680
|
return () => {
|
|
672
|
-
c && clearTimeout(c),
|
|
681
|
+
c && clearTimeout(c), j();
|
|
673
682
|
};
|
|
674
|
-
}, [
|
|
675
|
-
const
|
|
683
|
+
}, [se, r == null ? void 0 : r.widget_type]);
|
|
684
|
+
const Le = {};
|
|
676
685
|
for (const [l, c] of Object.entries(o))
|
|
677
|
-
l.includes(".") || (c == null || typeof c != "object") && (
|
|
678
|
-
const
|
|
679
|
-
if ((r == null ? void 0 : r.widget_type) !== "rollup" || !
|
|
686
|
+
l.includes(".") || (c == null || typeof c != "object") && (Le[l] = c);
|
|
687
|
+
const D = { ...Le, ...qr(a, o) }, me = kr(), Q = Pe(() => {
|
|
688
|
+
if ((r == null ? void 0 : r.widget_type) !== "rollup" || !me) return null;
|
|
680
689
|
const l = r.config, c = l == null ? void 0 : l.collection;
|
|
681
690
|
if (!c) return null;
|
|
682
|
-
const
|
|
691
|
+
const m = {
|
|
683
692
|
created: [],
|
|
684
693
|
updated: [],
|
|
685
694
|
deleted: []
|
|
686
695
|
};
|
|
687
|
-
for (const
|
|
688
|
-
const
|
|
689
|
-
|
|
696
|
+
for (const j of me.byGrid.values()) {
|
|
697
|
+
const k = j[c];
|
|
698
|
+
k && (m.created.push(...k.created), m.updated.push(...k.updated), m.deleted.push(...k.deleted));
|
|
690
699
|
}
|
|
691
|
-
return !
|
|
692
|
-
}, [r,
|
|
693
|
-
() =>
|
|
694
|
-
[
|
|
695
|
-
),
|
|
696
|
-
var
|
|
697
|
-
if (!
|
|
698
|
-
const l = String(
|
|
700
|
+
return !m.created.length && !m.updated.length && !m.deleted.length ? null : m;
|
|
701
|
+
}, [r, me]), Ze = Pe(
|
|
702
|
+
() => Q ? JSON.stringify(Q) : "",
|
|
703
|
+
[Q]
|
|
704
|
+
), y = (De = r == null ? void 0 : r.config) == null ? void 0 : De.drilldown, ie = dr(), he = y != null && y.id_input ? D[y.id_input] : null, ge = !!ie && !!(y != null && y.collection) && he != null && he !== "", Ce = async () => {
|
|
705
|
+
var j, k;
|
|
706
|
+
if (!ge || !(y != null && y.collection)) return;
|
|
707
|
+
const l = String(he);
|
|
699
708
|
let c = null;
|
|
700
|
-
const
|
|
701
|
-
credentials:
|
|
702
|
-
headers:
|
|
709
|
+
const m = (h) => fetch(`${E}${h}`, {
|
|
710
|
+
credentials: $.credentials,
|
|
711
|
+
headers: $.authHeaders
|
|
703
712
|
});
|
|
704
713
|
try {
|
|
705
|
-
if (
|
|
706
|
-
const
|
|
707
|
-
`/items/${
|
|
708
|
-
JSON.stringify({ [
|
|
714
|
+
if (y.match_field) {
|
|
715
|
+
const h = await m(
|
|
716
|
+
`/items/${y.collection}?filter=${encodeURIComponent(
|
|
717
|
+
JSON.stringify({ [y.match_field]: { _eq: l } })
|
|
709
718
|
)}&fields=id&limit=1`
|
|
710
719
|
);
|
|
711
|
-
if (
|
|
712
|
-
const
|
|
713
|
-
|
|
720
|
+
if (h.ok) {
|
|
721
|
+
const O = await h.json(), W = (k = (j = O == null ? void 0 : O.data) == null ? void 0 : j[0]) == null ? void 0 : k.id;
|
|
722
|
+
W != null && (c = String(W));
|
|
714
723
|
}
|
|
715
724
|
}
|
|
716
|
-
c == null && (await
|
|
725
|
+
c == null && (await m(`/items/${y.collection}/${encodeURIComponent(l)}?fields=id`)).ok && (c = l);
|
|
717
726
|
} catch {
|
|
718
727
|
return;
|
|
719
728
|
}
|
|
720
|
-
c != null && (
|
|
721
|
-
collection:
|
|
729
|
+
c != null && (ie == null || ie.open({
|
|
730
|
+
collection: y.collection,
|
|
722
731
|
itemId: c,
|
|
723
|
-
layoutId:
|
|
724
|
-
width:
|
|
725
|
-
title:
|
|
732
|
+
layoutId: y.layout_id ?? null,
|
|
733
|
+
width: y.width ?? "75%",
|
|
734
|
+
title: y.title
|
|
726
735
|
}));
|
|
727
736
|
};
|
|
728
|
-
if (
|
|
737
|
+
if (D.record_id == null || D.record_id === "") {
|
|
729
738
|
const l = o.id;
|
|
730
|
-
l != null && l !== "" && (
|
|
739
|
+
l != null && l !== "" && (D.record_id = l);
|
|
731
740
|
}
|
|
732
|
-
|
|
733
|
-
const
|
|
734
|
-
function
|
|
741
|
+
K.current = o.id ?? null;
|
|
742
|
+
const et = JSON.stringify(D) + (s ?? "") + Ze, tt = fr(et, 400);
|
|
743
|
+
function $e() {
|
|
735
744
|
const l = typeof window < "u" ? localStorage.getItem("nivaro_workspace") ?? "" : "";
|
|
736
745
|
return {
|
|
737
746
|
"Content-Type": "application/json",
|
|
738
|
-
|
|
747
|
+
...$.authHeaders,
|
|
739
748
|
...l ? { "x-workspace": l } : {}
|
|
740
749
|
};
|
|
741
750
|
}
|
|
742
|
-
const
|
|
751
|
+
const ee = ur(), V = nt({
|
|
743
752
|
queryKey: ["nvr-widget-def", n],
|
|
744
753
|
enabled: d,
|
|
745
754
|
staleTime: 6e4,
|
|
746
755
|
retry: !1,
|
|
747
756
|
queryFn: async () => {
|
|
748
|
-
if (
|
|
749
|
-
return (await
|
|
750
|
-
const l = await fetch(`${
|
|
751
|
-
credentials:
|
|
752
|
-
headers:
|
|
757
|
+
if (ee)
|
|
758
|
+
return (await ee.request(pr(`/widgets-internal/${n}`))).data;
|
|
759
|
+
const l = await fetch(`${E}/widgets-internal/${n}`, {
|
|
760
|
+
credentials: $.credentials,
|
|
761
|
+
headers: $e()
|
|
753
762
|
});
|
|
754
763
|
if (!l.ok) throw Object.assign(new Error("Widget not found"), { status: l.status });
|
|
755
764
|
return (await l.json()).data;
|
|
756
765
|
}
|
|
757
|
-
}),
|
|
758
|
-
|
|
759
|
-
}, [
|
|
760
|
-
|
|
766
|
+
}), Ee = V.refetch, ye = Ue(() => {
|
|
767
|
+
N(null), V.error ? Ee() : I((l) => l + 1);
|
|
768
|
+
}, [V.error, Ee]);
|
|
769
|
+
te(() => {
|
|
761
770
|
const l = () => I((c) => c + 1);
|
|
762
|
-
return window.addEventListener(
|
|
763
|
-
}, []),
|
|
764
|
-
d && (
|
|
765
|
-
}, [d,
|
|
771
|
+
return window.addEventListener(Me, l), () => window.removeEventListener(Me, l);
|
|
772
|
+
}, []), te(() => {
|
|
773
|
+
d && (V.data ? (G(V.data), f(!1), N(null), U == null || U(V.data.widget_type)) : V.error && N(Be(V.error, "this widget")));
|
|
774
|
+
}, [d, V.data, V.error]), te(() => {
|
|
766
775
|
if (!d || !r) return;
|
|
767
|
-
const l =
|
|
768
|
-
if (r.widget_type === "review_list" && l || r.widget_type === "rollup" && l && !
|
|
776
|
+
const l = D.record_id == null || D.record_id === "";
|
|
777
|
+
if (r.widget_type === "review_list" && l || r.widget_type === "rollup" && l && !Q) return;
|
|
769
778
|
let c = !1;
|
|
770
|
-
return
|
|
779
|
+
return pe.current || (p(!0), P(!0)), (async () => {
|
|
771
780
|
try {
|
|
772
|
-
const
|
|
773
|
-
inputs:
|
|
781
|
+
const m = {
|
|
782
|
+
inputs: Q ? { ...D, staged: Q } : D,
|
|
774
783
|
draft: o,
|
|
775
784
|
bindings: a,
|
|
776
|
-
item_collection:
|
|
785
|
+
item_collection: s
|
|
777
786
|
};
|
|
778
|
-
|
|
779
|
-
let
|
|
780
|
-
if (
|
|
781
|
-
|
|
782
|
-
|
|
787
|
+
q.current && (m.refresh = !0, q.current = !1), L(m);
|
|
788
|
+
let j;
|
|
789
|
+
if (ee)
|
|
790
|
+
j = await ee.request(
|
|
791
|
+
mr(`/widgets-internal/${n}/render`, m)
|
|
783
792
|
);
|
|
784
793
|
else {
|
|
785
|
-
const
|
|
794
|
+
const k = await fetch(`${E}/widgets-internal/${n}/render`, {
|
|
786
795
|
method: "POST",
|
|
787
|
-
credentials:
|
|
788
|
-
headers:
|
|
789
|
-
body: JSON.stringify(
|
|
796
|
+
credentials: $.credentials,
|
|
797
|
+
headers: $e(),
|
|
798
|
+
body: JSON.stringify(m)
|
|
790
799
|
});
|
|
791
|
-
if (!
|
|
792
|
-
throw Object.assign(new Error("Render failed"), { status:
|
|
793
|
-
|
|
800
|
+
if (!k.ok)
|
|
801
|
+
throw Object.assign(new Error("Render failed"), { status: k.status });
|
|
802
|
+
j = await k.json();
|
|
794
803
|
}
|
|
795
804
|
if (c) return;
|
|
796
|
-
c || (
|
|
797
|
-
} catch (
|
|
798
|
-
c ||
|
|
805
|
+
c || (pe.current = !0, ne(j.data), p(!1), N(null));
|
|
806
|
+
} catch (m) {
|
|
807
|
+
c || N(Be(m, "this widget"));
|
|
799
808
|
} finally {
|
|
800
|
-
c ||
|
|
809
|
+
c || P(!1);
|
|
801
810
|
}
|
|
802
811
|
})(), () => {
|
|
803
812
|
c = !0;
|
|
804
813
|
};
|
|
805
|
-
}, [n,
|
|
806
|
-
if (
|
|
807
|
-
if (
|
|
808
|
-
|
|
814
|
+
}, [n, E, tt, d, B, r == null ? void 0 : r.widget_type]), te(() => {
|
|
815
|
+
if (A) {
|
|
816
|
+
if (x) {
|
|
817
|
+
A(!0);
|
|
809
818
|
return;
|
|
810
819
|
}
|
|
811
|
-
if (
|
|
820
|
+
if (i) {
|
|
812
821
|
if ((r == null ? void 0 : r.widget_type) === "review_list" || (r == null ? void 0 : r.widget_type) === "rollup") {
|
|
813
|
-
const l =
|
|
814
|
-
|
|
822
|
+
const l = i.rows;
|
|
823
|
+
A(Array.isArray(l) && l.length > 0);
|
|
815
824
|
return;
|
|
816
825
|
}
|
|
817
|
-
if ((r == null ? void 0 : r.widget_type) === "custom-query" && "rows" in
|
|
818
|
-
const l =
|
|
819
|
-
|
|
826
|
+
if ((r == null ? void 0 : r.widget_type) === "custom-query" && "rows" in i) {
|
|
827
|
+
const l = i.rows;
|
|
828
|
+
A(Array.isArray(l) && l.length > 0);
|
|
820
829
|
return;
|
|
821
830
|
}
|
|
822
|
-
|
|
831
|
+
A(!0);
|
|
823
832
|
}
|
|
824
833
|
}
|
|
825
|
-
}, [
|
|
826
|
-
const
|
|
827
|
-
const l =
|
|
834
|
+
}, [i, x, r == null ? void 0 : r.widget_type, A]);
|
|
835
|
+
const z = g || (r == null ? void 0 : r.name) || "", ae = (r == null ? void 0 : r.widget_type) === "report_widget" && i ? Rr(i) : i, H = (() => {
|
|
836
|
+
const l = i == null ? void 0 : i.awaiting;
|
|
828
837
|
if (!Array.isArray(l) || l.length === 0) return null;
|
|
829
|
-
const c = l.map((
|
|
830
|
-
const
|
|
831
|
-
return String((
|
|
838
|
+
const c = l.map((m) => {
|
|
839
|
+
const j = a.find((h) => h.key === m && h.binding_type === "item_field");
|
|
840
|
+
return String((j == null ? void 0 : j.binding_value) ?? m).split(".")[0].replace(/_id$/, "").replace(/_/g, " ").replace(/^\w/, (h) => h.toUpperCase());
|
|
832
841
|
});
|
|
833
842
|
return [...new Set(c)].join(", ");
|
|
834
|
-
})(),
|
|
835
|
-
if ((r == null ? void 0 : r.widget_type) === "review_list" &&
|
|
843
|
+
})(), Te = D.record_id, qe = Te == null || Te === "";
|
|
844
|
+
if ((r == null ? void 0 : r.widget_type) === "review_list" && qe || (r == null ? void 0 : r.widget_type) === "rollup" && qe && !Q) return null;
|
|
836
845
|
if (R) {
|
|
837
|
-
const l = ((
|
|
838
|
-
if (
|
|
846
|
+
const l = ((Ae = r == null ? void 0 : r.config) == null ? void 0 : Ae.compact_style) ?? "default", c = l === "pill-dark" || l === "pill-light";
|
|
847
|
+
if (x)
|
|
839
848
|
return /* @__PURE__ */ t(
|
|
840
849
|
"button",
|
|
841
850
|
{
|
|
842
851
|
type: "button",
|
|
843
|
-
onClick:
|
|
852
|
+
onClick: ye,
|
|
844
853
|
"data-load-error": "",
|
|
845
|
-
"data-tip": `${
|
|
846
|
-
"aria-label": `${
|
|
854
|
+
"data-tip": `${x} Click to try again.`,
|
|
855
|
+
"aria-label": `${x} Try again`,
|
|
847
856
|
className: "inline-flex h-5 w-5 items-center justify-center rounded text-amber-500 hover:bg-amber-50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-nvr-cyan/50 dark:text-amber-400 dark:hover:bg-amber-400/10",
|
|
848
|
-
children: /* @__PURE__ */ t(
|
|
857
|
+
children: /* @__PURE__ */ t(Xe, { className: "h-3.5 w-3.5", "aria-hidden": !0 })
|
|
849
858
|
}
|
|
850
859
|
);
|
|
851
860
|
if (C) {
|
|
852
861
|
if (e)
|
|
853
|
-
return /* @__PURE__ */
|
|
862
|
+
return /* @__PURE__ */ w("div", { className: "flex h-full w-36 flex-col justify-center px-4 py-2.5", children: [
|
|
854
863
|
/* @__PURE__ */ t("span", { className: "animate-pulse h-2 w-10 rounded bg-slate-200 dark:bg-[hsl(var(--nvr-skeleton))] mb-1" }),
|
|
855
864
|
/* @__PURE__ */ t("span", { className: "animate-pulse h-3.5 w-20 rounded bg-slate-200 dark:bg-[hsl(var(--nvr-skeleton))]" })
|
|
856
865
|
] });
|
|
857
866
|
if (r.widget_type === "button-group")
|
|
858
|
-
return /* @__PURE__ */ t("div", { className: "h-full flex items-center px-3", children: u ? /* @__PURE__ */ t("div", { className: "animate-pulse h-7 w-24 rounded bg-slate-200 dark:bg-[hsl(var(--nvr-skeleton))]" }) :
|
|
859
|
-
|
|
867
|
+
return /* @__PURE__ */ t("div", { className: "h-full flex items-center px-3", children: u ? /* @__PURE__ */ t("div", { className: "animate-pulse h-7 w-24 rounded bg-slate-200 dark:bg-[hsl(var(--nvr-skeleton))]" }) : i && /* @__PURE__ */ t(
|
|
868
|
+
Ne,
|
|
860
869
|
{
|
|
861
|
-
buttons:
|
|
862
|
-
layout:
|
|
870
|
+
buttons: i.buttons ?? [],
|
|
871
|
+
layout: i.layout ?? "flat",
|
|
863
872
|
widgetId: n,
|
|
864
|
-
inputs:
|
|
865
|
-
apiBase:
|
|
873
|
+
inputs: D,
|
|
874
|
+
apiBase: E,
|
|
866
875
|
onClientAction: S
|
|
867
876
|
}
|
|
868
877
|
) });
|
|
869
878
|
{
|
|
870
|
-
const
|
|
871
|
-
|
|
879
|
+
const m = /* @__PURE__ */ t(
|
|
880
|
+
Er,
|
|
872
881
|
{
|
|
873
|
-
data: u ? null :
|
|
874
|
-
label:
|
|
882
|
+
data: u ? null : ae ?? null,
|
|
883
|
+
label: g || r.name,
|
|
875
884
|
loading: u,
|
|
876
885
|
widgetConfig: r.config,
|
|
877
|
-
awaiting:
|
|
886
|
+
awaiting: H
|
|
878
887
|
}
|
|
879
|
-
),
|
|
888
|
+
), j = ge ? /* @__PURE__ */ t(
|
|
880
889
|
"button",
|
|
881
890
|
{
|
|
882
891
|
type: "button",
|
|
883
|
-
onClick: () => void
|
|
884
|
-
title: (
|
|
892
|
+
onClick: () => void Ce(),
|
|
893
|
+
title: (y == null ? void 0 : y.title) ?? "Open details",
|
|
885
894
|
className: "h-full w-full cursor-pointer text-left transition-colors hover:bg-nvr-cyan/5",
|
|
886
|
-
"data-nvr-widget-drill":
|
|
887
|
-
children:
|
|
895
|
+
"data-nvr-widget-drill": y == null ? void 0 : y.collection,
|
|
896
|
+
children: m
|
|
888
897
|
}
|
|
889
|
-
) :
|
|
890
|
-
return
|
|
898
|
+
) : m, k = i == null ? void 0 : i.cache;
|
|
899
|
+
return k != null && k.cache_ttl ? /* @__PURE__ */ w(
|
|
891
900
|
"div",
|
|
892
901
|
{
|
|
893
902
|
className: "group/cache relative h-full w-full",
|
|
894
|
-
"data-cache-stamp":
|
|
903
|
+
"data-cache-stamp": k.cached ? "cached" : "fresh",
|
|
895
904
|
children: [
|
|
896
|
-
|
|
905
|
+
j,
|
|
897
906
|
/* @__PURE__ */ t(
|
|
898
907
|
"button",
|
|
899
908
|
{
|
|
900
909
|
type: "button",
|
|
901
|
-
onClick:
|
|
910
|
+
onClick: J,
|
|
902
911
|
disabled: u,
|
|
903
912
|
"data-cache-refresh": !0,
|
|
904
913
|
"aria-label": "Refresh this figure",
|
|
905
|
-
"data-tip":
|
|
914
|
+
"data-tip": _r(k),
|
|
906
915
|
className: "absolute bottom-1 right-1 rounded p-0.5 text-muted-foreground opacity-0 transition-opacity hover:bg-muted group-hover/cache:opacity-100 focus-visible:opacity-100 disabled:opacity-50",
|
|
907
|
-
children: /* @__PURE__ */ t(
|
|
916
|
+
children: /* @__PURE__ */ t(Ye, { className: `h-3 w-3 ${u ? "animate-spin" : ""}` })
|
|
908
917
|
}
|
|
909
918
|
)
|
|
910
919
|
]
|
|
911
920
|
}
|
|
912
|
-
) :
|
|
921
|
+
) : j;
|
|
913
922
|
}
|
|
914
923
|
}
|
|
915
924
|
if (c) {
|
|
@@ -921,174 +930,174 @@ function rn({
|
|
|
921
930
|
}
|
|
922
931
|
);
|
|
923
932
|
{
|
|
924
|
-
const
|
|
925
|
-
|
|
933
|
+
const m = /* @__PURE__ */ t(
|
|
934
|
+
jr,
|
|
926
935
|
{
|
|
927
|
-
data: u ? null :
|
|
928
|
-
label:
|
|
936
|
+
data: u ? null : ae ?? null,
|
|
937
|
+
label: g || r.name,
|
|
929
938
|
style: l,
|
|
930
939
|
loading: u,
|
|
931
940
|
widgetConfig: r.config,
|
|
932
|
-
awaiting:
|
|
941
|
+
awaiting: H
|
|
933
942
|
}
|
|
934
943
|
);
|
|
935
|
-
return
|
|
944
|
+
return ge ? /* @__PURE__ */ t(
|
|
936
945
|
"button",
|
|
937
946
|
{
|
|
938
947
|
type: "button",
|
|
939
|
-
onClick: () => void
|
|
940
|
-
title: (
|
|
948
|
+
onClick: () => void Ce(),
|
|
949
|
+
title: (y == null ? void 0 : y.title) ?? "Open details",
|
|
941
950
|
className: "cursor-pointer text-left",
|
|
942
|
-
"data-nvr-widget-drill":
|
|
943
|
-
children:
|
|
951
|
+
"data-nvr-widget-drill": y == null ? void 0 : y.collection,
|
|
952
|
+
children: m
|
|
944
953
|
}
|
|
945
|
-
) :
|
|
954
|
+
) : m;
|
|
946
955
|
}
|
|
947
956
|
}
|
|
948
|
-
return e ? /* @__PURE__ */ t("div", { className: "animate-pulse h-4 w-20 rounded bg-slate-200 dark:bg-[hsl(var(--nvr-skeleton))]" }) : /* @__PURE__ */ t("div", { className: "flex items-center gap-1.5", children: u ? /* @__PURE__ */ t("div", { className: "flex items-baseline gap-1", children: /* @__PURE__ */ t("div", { className: "animate-pulse h-5 w-20 rounded bg-slate-200 dark:bg-[hsl(var(--nvr-skeleton))]" }) }) :
|
|
949
|
-
(r.widget_type === "stat" || r.widget_type === "custom-query" && "value" in
|
|
950
|
-
r.widget_type === "report_widget" &&
|
|
951
|
-
r.widget_type === "custom-query" && "values" in
|
|
957
|
+
return e ? /* @__PURE__ */ t("div", { className: "animate-pulse h-4 w-20 rounded bg-slate-200 dark:bg-[hsl(var(--nvr-skeleton))]" }) : /* @__PURE__ */ t("div", { className: "flex items-center gap-1.5", children: u ? /* @__PURE__ */ t("div", { className: "flex items-baseline gap-1", children: /* @__PURE__ */ t("div", { className: "animate-pulse h-5 w-20 rounded bg-slate-200 dark:bg-[hsl(var(--nvr-skeleton))]" }) }) : i && r && /* @__PURE__ */ w(ke, { children: [
|
|
958
|
+
(r.widget_type === "stat" || r.widget_type === "custom-query" && "value" in i) && /* @__PURE__ */ t(ve, { data: i, awaiting: H }),
|
|
959
|
+
r.widget_type === "report_widget" && ae && /* @__PURE__ */ t(ve, { data: ae, awaiting: H }),
|
|
960
|
+
r.widget_type === "custom-query" && "values" in i && /* @__PURE__ */ t(Qe, { data: i }),
|
|
952
961
|
r.widget_type === "action-buttons" && /* @__PURE__ */ t(
|
|
953
|
-
|
|
962
|
+
ze,
|
|
954
963
|
{
|
|
955
|
-
data:
|
|
964
|
+
data: i,
|
|
956
965
|
widgetId: n,
|
|
957
|
-
inputs:
|
|
958
|
-
apiBase:
|
|
966
|
+
inputs: D,
|
|
967
|
+
apiBase: E
|
|
959
968
|
}
|
|
960
969
|
),
|
|
961
970
|
r.widget_type === "button-group" && /* @__PURE__ */ t(
|
|
962
|
-
|
|
971
|
+
Ne,
|
|
963
972
|
{
|
|
964
|
-
buttons:
|
|
965
|
-
layout:
|
|
973
|
+
buttons: i.buttons ?? [],
|
|
974
|
+
layout: i.layout ?? "flat",
|
|
966
975
|
widgetId: n,
|
|
967
|
-
inputs:
|
|
968
|
-
apiBase:
|
|
976
|
+
inputs: D,
|
|
977
|
+
apiBase: E,
|
|
969
978
|
onClientAction: S
|
|
970
979
|
}
|
|
971
980
|
)
|
|
972
981
|
] }) });
|
|
973
982
|
}
|
|
974
|
-
const
|
|
975
|
-
|
|
983
|
+
const oe = r == null ? void 0 : r.widget_type, je = oe === "stat" ? /* @__PURE__ */ t(we, { framed: !1, title: !1, kpi: !0, className: "py-0.5" }) : oe === "list" || oe === "review_list" || oe === "custom-query" ? /* @__PURE__ */ t(we, { framed: !1, title: !1, lines: 4, className: "py-0.5" }) : /* @__PURE__ */ t(we, { framed: !1, title: !1, lines: 3, className: "py-0.5" }), Oe = ee ? /* @__PURE__ */ t(
|
|
984
|
+
vr,
|
|
976
985
|
{
|
|
977
986
|
className: "mt-2",
|
|
978
987
|
pending: u && !!r,
|
|
979
|
-
request:
|
|
980
|
-
label:
|
|
988
|
+
request: F ? { method: "POST", url: `/widgets-internal/${n}/render`, body: F } : null,
|
|
989
|
+
label: z || "Widget",
|
|
981
990
|
onResult: (l) => {
|
|
982
991
|
const c = l == null ? void 0 : l.data;
|
|
983
|
-
c && (
|
|
992
|
+
c && (pe.current = !0, ne(c), p(!1), P(!1), N(null));
|
|
984
993
|
},
|
|
985
994
|
onGone: () => I((l) => l + 1)
|
|
986
995
|
}
|
|
987
996
|
) : null;
|
|
988
|
-
if (
|
|
989
|
-
return /* @__PURE__ */
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
!
|
|
997
|
+
if (b)
|
|
998
|
+
return /* @__PURE__ */ w("div", { children: [
|
|
999
|
+
T && je,
|
|
1000
|
+
T && Oe,
|
|
1001
|
+
x && /* @__PURE__ */ t(He, { message: x, onRetry: ye }),
|
|
1002
|
+
!T && !x && i && r && Ie()
|
|
994
1003
|
] });
|
|
995
|
-
return /* @__PURE__ */
|
|
996
|
-
/* @__PURE__ */
|
|
1004
|
+
return /* @__PURE__ */ w("div", { className: "rounded-lg border border-slate-200 bg-white dark:border-border dark:bg-card", children: [
|
|
1005
|
+
/* @__PURE__ */ w(
|
|
997
1006
|
"button",
|
|
998
1007
|
{
|
|
999
1008
|
type: "button",
|
|
1000
1009
|
className: "flex w-full items-center justify-between px-4 py-3 text-left",
|
|
1001
|
-
onClick: () =>
|
|
1010
|
+
onClick: () => fe((l) => !l),
|
|
1002
1011
|
children: [
|
|
1003
|
-
/* @__PURE__ */ t("span", { className: "text-[13px] font-medium text-slate-800 dark:text-slate-200", children:
|
|
1004
|
-
/* @__PURE__ */ t("span", { className: `text-slate-400 transition-transform ${
|
|
1012
|
+
/* @__PURE__ */ t("span", { className: "text-[13px] font-medium text-slate-800 dark:text-slate-200", children: z || /* @__PURE__ */ t("span", { className: "inline-block h-3 w-28 animate-pulse rounded bg-[hsl(var(--nvr-skeleton))] align-middle" }) }),
|
|
1013
|
+
/* @__PURE__ */ t("span", { className: `text-slate-400 transition-transform ${Z ? "rotate-90" : ""}`, children: "›" })
|
|
1005
1014
|
]
|
|
1006
1015
|
}
|
|
1007
1016
|
),
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
!
|
|
1017
|
+
Z && /* @__PURE__ */ w("div", { className: "border-t border-slate-100 px-4 py-3 dark:border-border", children: [
|
|
1018
|
+
T && je,
|
|
1019
|
+
T && Oe,
|
|
1020
|
+
x && /* @__PURE__ */ t(He, { message: x, onRetry: ye }),
|
|
1021
|
+
!T && !x && i && r && Ie()
|
|
1013
1022
|
] })
|
|
1014
1023
|
] });
|
|
1015
|
-
function
|
|
1024
|
+
function Ie() {
|
|
1016
1025
|
var l;
|
|
1017
|
-
return !
|
|
1018
|
-
(r.widget_type === "stat" || r.widget_type === "custom-query" && "value" in
|
|
1019
|
-
r.widget_type === "custom-query" && "values" in
|
|
1026
|
+
return !i || !r ? null : /* @__PURE__ */ w(ke, { children: [
|
|
1027
|
+
(r.widget_type === "stat" || r.widget_type === "custom-query" && "value" in i) && /* @__PURE__ */ t(ve, { data: i, awaiting: H }),
|
|
1028
|
+
r.widget_type === "custom-query" && "values" in i && (H ? /* @__PURE__ */ w(
|
|
1020
1029
|
"p",
|
|
1021
1030
|
{
|
|
1022
1031
|
className: "text-[12px] text-slate-500 dark:text-slate-400",
|
|
1023
|
-
"data-widget-awaiting":
|
|
1032
|
+
"data-widget-awaiting": H,
|
|
1024
1033
|
children: [
|
|
1025
1034
|
"Set ",
|
|
1026
|
-
|
|
1035
|
+
H,
|
|
1027
1036
|
" on this record to see ",
|
|
1028
|
-
|
|
1037
|
+
z || "this",
|
|
1029
1038
|
"."
|
|
1030
1039
|
]
|
|
1031
1040
|
}
|
|
1032
|
-
) : /* @__PURE__ */ t(
|
|
1033
|
-
r.widget_type === "list" && /* @__PURE__ */ t(
|
|
1034
|
-
|
|
1041
|
+
) : /* @__PURE__ */ t(Qe, { data: i })),
|
|
1042
|
+
r.widget_type === "list" && /* @__PURE__ */ t(Or, { data: i }),
|
|
1043
|
+
H && r.widget_type === "custom-query" && "rows" in i && /* @__PURE__ */ w(
|
|
1035
1044
|
"p",
|
|
1036
1045
|
{
|
|
1037
1046
|
className: "text-[12px] text-slate-500 dark:text-slate-400",
|
|
1038
|
-
"data-widget-awaiting":
|
|
1047
|
+
"data-widget-awaiting": H,
|
|
1039
1048
|
children: [
|
|
1040
1049
|
"Set ",
|
|
1041
|
-
|
|
1050
|
+
H,
|
|
1042
1051
|
" on this record to see ",
|
|
1043
|
-
|
|
1052
|
+
z || "this",
|
|
1044
1053
|
"."
|
|
1045
1054
|
]
|
|
1046
1055
|
}
|
|
1047
1056
|
),
|
|
1048
|
-
!
|
|
1049
|
-
|
|
1057
|
+
!H && r.widget_type === "custom-query" && "rows" in i && /* @__PURE__ */ t(
|
|
1058
|
+
Sr,
|
|
1050
1059
|
{
|
|
1051
|
-
rows:
|
|
1060
|
+
rows: i.rows ?? [],
|
|
1052
1061
|
config: (l = r.config) == null ? void 0 : l.table,
|
|
1053
|
-
emptyLabel:
|
|
1062
|
+
emptyLabel: z
|
|
1054
1063
|
}
|
|
1055
1064
|
),
|
|
1056
1065
|
r.widget_type === "review_list" && /* @__PURE__ */ t(
|
|
1057
|
-
|
|
1066
|
+
Cr,
|
|
1058
1067
|
{
|
|
1059
|
-
data:
|
|
1068
|
+
data: i,
|
|
1060
1069
|
config: r.config ?? {},
|
|
1061
1070
|
onRefetch: () => I((c) => c + 1),
|
|
1062
|
-
hostRecordId:
|
|
1063
|
-
emptyLabel:
|
|
1071
|
+
hostRecordId: D.record_id,
|
|
1072
|
+
emptyLabel: z
|
|
1064
1073
|
}
|
|
1065
1074
|
),
|
|
1066
1075
|
r.widget_type === "rollup" && /* @__PURE__ */ t(
|
|
1067
|
-
|
|
1076
|
+
$r,
|
|
1068
1077
|
{
|
|
1069
|
-
data:
|
|
1078
|
+
data: i,
|
|
1070
1079
|
config: r.config ?? {},
|
|
1071
|
-
emptyLabel:
|
|
1080
|
+
emptyLabel: z
|
|
1072
1081
|
}
|
|
1073
1082
|
),
|
|
1074
|
-
r.widget_type === "report_widget" && /* @__PURE__ */ t(
|
|
1083
|
+
r.widget_type === "report_widget" && /* @__PURE__ */ t(Lr, { payload: i }),
|
|
1075
1084
|
r.widget_type === "action-buttons" && /* @__PURE__ */ t(
|
|
1076
|
-
|
|
1085
|
+
ze,
|
|
1077
1086
|
{
|
|
1078
|
-
data:
|
|
1087
|
+
data: i,
|
|
1079
1088
|
widgetId: n,
|
|
1080
|
-
inputs:
|
|
1081
|
-
apiBase:
|
|
1089
|
+
inputs: D,
|
|
1090
|
+
apiBase: E
|
|
1082
1091
|
}
|
|
1083
1092
|
),
|
|
1084
1093
|
r.widget_type === "button-group" && /* @__PURE__ */ t(
|
|
1085
|
-
|
|
1094
|
+
Ne,
|
|
1086
1095
|
{
|
|
1087
|
-
buttons:
|
|
1088
|
-
layout:
|
|
1096
|
+
buttons: i.buttons ?? [],
|
|
1097
|
+
layout: i.layout ?? "flat",
|
|
1089
1098
|
widgetId: n,
|
|
1090
|
-
inputs:
|
|
1091
|
-
apiBase:
|
|
1099
|
+
inputs: D,
|
|
1100
|
+
apiBase: E,
|
|
1092
1101
|
onClientAction: S
|
|
1093
1102
|
}
|
|
1094
1103
|
),
|
|
@@ -1101,12 +1110,12 @@ function rn({
|
|
|
1101
1110
|
"review_list",
|
|
1102
1111
|
"rollup",
|
|
1103
1112
|
"report_widget"
|
|
1104
|
-
].includes(r.widget_type) && /* @__PURE__ */ t("pre", { className: "whitespace-pre-wrap text-[11px] text-slate-500", children: JSON.stringify(
|
|
1105
|
-
|
|
1106
|
-
|
|
1113
|
+
].includes(r.widget_type) && /* @__PURE__ */ t("pre", { className: "whitespace-pre-wrap text-[11px] text-slate-500", children: JSON.stringify(i, null, 2) }),
|
|
1114
|
+
i.cache ? /* @__PURE__ */ t(
|
|
1115
|
+
Nr,
|
|
1107
1116
|
{
|
|
1108
|
-
envelope:
|
|
1109
|
-
onRefresh:
|
|
1117
|
+
envelope: i.cache,
|
|
1118
|
+
onRefresh: J,
|
|
1110
1119
|
refreshing: u,
|
|
1111
1120
|
className: "mt-2 justify-end"
|
|
1112
1121
|
}
|
|
@@ -1115,6 +1124,6 @@ function rn({
|
|
|
1115
1124
|
}
|
|
1116
1125
|
}
|
|
1117
1126
|
export {
|
|
1118
|
-
|
|
1119
|
-
|
|
1127
|
+
sn as WidgetSlot,
|
|
1128
|
+
Ge as hostStepChange
|
|
1120
1129
|
};
|