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