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