react-semaphor 0.1.125 → 0.1.127
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/chunks/dashboard-controls-BFo8ClGD.js +1473 -0
- package/dist/chunks/dashboard-controls-CpNsaWbB.js +26 -0
- package/dist/chunks/dashboard-export-dialog-CKGJIz95.js +6 -0
- package/dist/chunks/dashboard-export-dialog-CKr9o8DW.js +600 -0
- package/dist/chunks/{dashboard-json-BlEVRs4V.js → dashboard-json-Bqddgxcf.js} +1 -1
- package/dist/chunks/{dashboard-json-Cn2IxIvK.js → dashboard-json-CZrxKZBn.js} +1 -1
- package/dist/chunks/{edit-dashboard-visual-CHqS0-RO.js → edit-dashboard-visual-Du3rYBkf.js} +5966 -4980
- package/dist/chunks/edit-dashboard-visual-Kg8h34hs.js +195 -0
- package/dist/chunks/{editor-action-buttons-BjVPDqso.js → editor-action-buttons-BMeOcqc2.js} +2 -2
- package/dist/chunks/{editor-action-buttons-j0OdQL7Y.js → editor-action-buttons-DHk1Cdb6.js} +1 -1
- package/dist/chunks/{index-CZGIYFfM.js → index-DJmpV5Lg.js} +163 -158
- package/dist/chunks/{index-BQPGBZP4.js → index-DLxVadBx.js} +5788 -5769
- package/dist/chunks/{resource-management-panel-CaktfbhQ.js → resource-management-panel-D6gqCHWr.js} +1 -1
- package/dist/chunks/{resource-management-panel-BD6pGiUl.js → resource-management-panel-VT7LYPp8.js} +88 -88
- package/dist/chunks/{use-visual-utils-uElEhCM9.js → use-visual-utils-DpxMI5Pe.js} +1 -1
- package/dist/chunks/{use-visual-utils-Dhcu2Fn4.js → use-visual-utils-O1QcxL8l.js} +1 -1
- package/dist/dashboard/index.cjs +1 -1
- package/dist/dashboard/index.js +1 -1
- package/dist/index.cjs +2 -2
- package/dist/index.js +25 -24
- package/dist/style.css +1 -1
- package/dist/surfboard/index.cjs +1 -1
- package/dist/surfboard/index.js +1 -1
- package/dist/types/dashboard.d.ts +1 -1
- package/dist/types/main.d.ts +9 -2
- package/dist/types/surfboard.d.ts +1 -1
- package/dist/types/types.d.ts +1 -1
- package/package.json +1 -1
- package/dist/chunks/dashboard-controls-Bx-ySdim.js +0 -1561
- package/dist/chunks/dashboard-controls-CZkFeNrk.js +0 -26
- package/dist/chunks/edit-dashboard-visual-Cm5Mc4Um.js +0 -170
- package/dist/chunks/schedule-dashboard-BQ5u1NRe.js +0 -415
- package/dist/chunks/schedule-dashboard-Cul4sDBY.js +0 -6
|
@@ -1,415 +0,0 @@
|
|
|
1
|
-
import { jsx as e, jsxs as r, Fragment as E } from "react/jsx-runtime";
|
|
2
|
-
import { b as W, aq as _, ar as $, as as G, at as J, au as K, av as V, aw as R, ax as X, ay as T, az as Q, B as N, L as Y, f as k, i as Z, u as g, am as ee, g as q, aA as ae, aB as B, l as w, aC as se, aD as te, c as y, aE as O, aF as P, aG as L, aH as z, aI as j, e as ne, aJ as de, aK as le, aL as re, I as ie, aM as oe, aN as ce } from "./index-BQPGBZP4.js";
|
|
3
|
-
import { E as he, V as ue, a as me, b as ve, S as U, c as pe } from "./editor-action-buttons-BjVPDqso.js";
|
|
4
|
-
import fe, { useState as C, useContext as be } from "react";
|
|
5
|
-
import { a as H } from "./use-visual-utils-uElEhCM9.js";
|
|
6
|
-
/**
|
|
7
|
-
* @license lucide-react v0.453.0 - ISC
|
|
8
|
-
*
|
|
9
|
-
* This source code is licensed under the ISC license.
|
|
10
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
11
|
-
*/
|
|
12
|
-
const ge = W("CirclePlus", [
|
|
13
|
-
["circle", { cx: "12", cy: "12", r: "10", key: "1mglay" }],
|
|
14
|
-
["path", { d: "M8 12h8", key: "1wcyev" }],
|
|
15
|
-
["path", { d: "M12 8v8", key: "napkw2" }]
|
|
16
|
-
]);
|
|
17
|
-
function De({
|
|
18
|
-
open: a,
|
|
19
|
-
onOpenChange: d,
|
|
20
|
-
isLibraryVisual: s,
|
|
21
|
-
currentVisualName: t,
|
|
22
|
-
isSaving: o = !1,
|
|
23
|
-
onConfirm: u
|
|
24
|
-
}) {
|
|
25
|
-
const [i, n] = C(
|
|
26
|
-
s && t ? `Copy of ${t}` : t || ""
|
|
27
|
-
), [c, v] = C(""), [f, D] = C(!s), [b, S] = C(!0);
|
|
28
|
-
fe.useEffect(() => {
|
|
29
|
-
a && (n(
|
|
30
|
-
s && t ? `Copy of ${t}` : t || ""
|
|
31
|
-
), v(""), D(!s), S(!0));
|
|
32
|
-
}, [a, s, t]);
|
|
33
|
-
const I = () => {
|
|
34
|
-
i.trim() && (!f && !b || u({
|
|
35
|
-
name: i.trim(),
|
|
36
|
-
description: c.trim() || void 0,
|
|
37
|
-
saveToLibrary: f,
|
|
38
|
-
saveToCurrentDashboard: b
|
|
39
|
-
}));
|
|
40
|
-
}, A = i.trim() && (f || b);
|
|
41
|
-
return /* @__PURE__ */ e(_, { open: a, onOpenChange: d, children: /* @__PURE__ */ r($, { className: "sm:max-w-[425px]", children: [
|
|
42
|
-
/* @__PURE__ */ r(G, { children: [
|
|
43
|
-
/* @__PURE__ */ e(J, { children: "Save Visual As" }),
|
|
44
|
-
/* @__PURE__ */ e(K, { children: s ? "Create a copy of this visual with a new name" : "Save this visual to make it reusable" })
|
|
45
|
-
] }),
|
|
46
|
-
/* @__PURE__ */ r("div", { className: "grid gap-4 py-4", children: [
|
|
47
|
-
/* @__PURE__ */ r("div", { className: "grid gap-2", children: [
|
|
48
|
-
/* @__PURE__ */ e(V, { htmlFor: "name", children: "Name" }),
|
|
49
|
-
/* @__PURE__ */ e(
|
|
50
|
-
R,
|
|
51
|
-
{
|
|
52
|
-
id: "name",
|
|
53
|
-
value: i,
|
|
54
|
-
onChange: (m) => n(m.target.value),
|
|
55
|
-
placeholder: "Enter visual name",
|
|
56
|
-
disabled: o
|
|
57
|
-
}
|
|
58
|
-
)
|
|
59
|
-
] }),
|
|
60
|
-
/* @__PURE__ */ r("div", { className: "grid gap-2", children: [
|
|
61
|
-
/* @__PURE__ */ e(V, { htmlFor: "description", children: "Description (optional)" }),
|
|
62
|
-
/* @__PURE__ */ e(
|
|
63
|
-
X,
|
|
64
|
-
{
|
|
65
|
-
id: "description",
|
|
66
|
-
value: c,
|
|
67
|
-
onChange: (m) => v(m.target.value),
|
|
68
|
-
placeholder: "Enter visual description",
|
|
69
|
-
rows: 3,
|
|
70
|
-
disabled: o
|
|
71
|
-
}
|
|
72
|
-
)
|
|
73
|
-
] }),
|
|
74
|
-
/* @__PURE__ */ r("div", { className: "space-y-4", children: [
|
|
75
|
-
/* @__PURE__ */ e(V, { children: "Save to:" }),
|
|
76
|
-
/* @__PURE__ */ r("div", { className: "space-y-2", children: [
|
|
77
|
-
/* @__PURE__ */ r("div", { className: "flex items-center space-x-2", children: [
|
|
78
|
-
/* @__PURE__ */ e(
|
|
79
|
-
T,
|
|
80
|
-
{
|
|
81
|
-
id: "save-to-dashboard",
|
|
82
|
-
checked: b,
|
|
83
|
-
onCheckedChange: (m) => S(!!m),
|
|
84
|
-
disabled: o
|
|
85
|
-
}
|
|
86
|
-
),
|
|
87
|
-
/* @__PURE__ */ r(
|
|
88
|
-
"label",
|
|
89
|
-
{
|
|
90
|
-
htmlFor: "save-to-dashboard",
|
|
91
|
-
className: "text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70",
|
|
92
|
-
children: [
|
|
93
|
-
"Current Dashboard",
|
|
94
|
-
/* @__PURE__ */ e("span", { className: "ml-2 text-xs text-muted-foreground", children: s ? "(add copy to this dashboard)" : "(keep as local visual)" })
|
|
95
|
-
]
|
|
96
|
-
}
|
|
97
|
-
)
|
|
98
|
-
] }),
|
|
99
|
-
/* @__PURE__ */ r("div", { className: "flex items-center space-x-2", children: [
|
|
100
|
-
/* @__PURE__ */ e(
|
|
101
|
-
T,
|
|
102
|
-
{
|
|
103
|
-
id: "save-to-library",
|
|
104
|
-
checked: f,
|
|
105
|
-
onCheckedChange: (m) => D(!!m),
|
|
106
|
-
disabled: o
|
|
107
|
-
}
|
|
108
|
-
),
|
|
109
|
-
/* @__PURE__ */ r(
|
|
110
|
-
"label",
|
|
111
|
-
{
|
|
112
|
-
htmlFor: "save-to-library",
|
|
113
|
-
className: "text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70",
|
|
114
|
-
children: [
|
|
115
|
-
"Visual Library",
|
|
116
|
-
/* @__PURE__ */ e("span", { className: "ml-2 text-xs text-muted-foreground", children: s ? "(save as new reusable visual)" : "(make available to all dashboards)" })
|
|
117
|
-
]
|
|
118
|
-
}
|
|
119
|
-
)
|
|
120
|
-
] })
|
|
121
|
-
] }),
|
|
122
|
-
!f && !b && /* @__PURE__ */ e("p", { className: "text-sm text-destructive", children: "Please select at least one destination" })
|
|
123
|
-
] })
|
|
124
|
-
] }),
|
|
125
|
-
/* @__PURE__ */ r(Q, { children: [
|
|
126
|
-
/* @__PURE__ */ e(
|
|
127
|
-
N,
|
|
128
|
-
{
|
|
129
|
-
variant: "outline",
|
|
130
|
-
onClick: () => d(!1),
|
|
131
|
-
disabled: o,
|
|
132
|
-
children: "Cancel"
|
|
133
|
-
}
|
|
134
|
-
),
|
|
135
|
-
/* @__PURE__ */ r(N, { onClick: I, disabled: !A || o, children: [
|
|
136
|
-
o && /* @__PURE__ */ e(Y, { className: "mr-2 h-4 w-4 animate-spin" }),
|
|
137
|
-
o ? "Saving..." : "Save"
|
|
138
|
-
] })
|
|
139
|
-
] })
|
|
140
|
-
] }) });
|
|
141
|
-
}
|
|
142
|
-
function Ce() {
|
|
143
|
-
const [a, d] = C(!1), [s, t] = C(!1), [o, u] = C(null), i = k((l) => l.frame), n = k((l) => l.card), c = Z(), v = g((l) => l.selectedSheetId), f = g(
|
|
144
|
-
(l) => l.actions.setIsDashboardPanelOpen
|
|
145
|
-
), { getUpdatedFrame: D } = H(), { selectVisual: b } = ee(), { addFrame: S, setSelectedFrameId: I, setIsVisualEditing: A } = q(), m = !!(i != null && i.visualId), F = (() => {
|
|
146
|
-
var l, p;
|
|
147
|
-
return ((l = i == null ? void 0 : i.cards) == null ? void 0 : l.length) === 1 && ((p = i.cards[0]) != null && p.title) ? i.cards[0].title : c != null && c.title ? c.title : (n == null ? void 0 : n.title) || "Untitled Visual";
|
|
148
|
-
})(), h = ae((l) => {
|
|
149
|
-
if (l != null && l.id) {
|
|
150
|
-
if (b(l), s && o && v) {
|
|
151
|
-
const p = {
|
|
152
|
-
...o,
|
|
153
|
-
id: B(),
|
|
154
|
-
visualId: l.id
|
|
155
|
-
// Link to the newly created library visual
|
|
156
|
-
};
|
|
157
|
-
S(v, p, "end"), I(p.id), t(!1), u(null), A(!1);
|
|
158
|
-
}
|
|
159
|
-
f(!0), d(!1);
|
|
160
|
-
}
|
|
161
|
-
});
|
|
162
|
-
return {
|
|
163
|
-
saveAsDialogOpen: a,
|
|
164
|
-
setSaveAsDialogOpen: d,
|
|
165
|
-
handleSaveAs: async (l) => {
|
|
166
|
-
if (!v) {
|
|
167
|
-
w.error("No sheet selected");
|
|
168
|
-
return;
|
|
169
|
-
}
|
|
170
|
-
const p = D(), M = p.cards.length === 1 ? {
|
|
171
|
-
...p,
|
|
172
|
-
cards: p.cards.map((x) => ({
|
|
173
|
-
...x,
|
|
174
|
-
title: l.name
|
|
175
|
-
// Use visual name as card title
|
|
176
|
-
}))
|
|
177
|
-
} : p;
|
|
178
|
-
if (l.saveToLibrary) {
|
|
179
|
-
t(l.saveToCurrentDashboard), u(M);
|
|
180
|
-
const x = {
|
|
181
|
-
title: l.name,
|
|
182
|
-
description: l.description,
|
|
183
|
-
frameObject: M,
|
|
184
|
-
// Card title synced for single-card frames
|
|
185
|
-
isPrivate: !1
|
|
186
|
-
};
|
|
187
|
-
h.mutate(x);
|
|
188
|
-
} else if (l.saveToCurrentDashboard) {
|
|
189
|
-
const x = {
|
|
190
|
-
...M,
|
|
191
|
-
// Card title already synced
|
|
192
|
-
id: B(),
|
|
193
|
-
visualId: void 0
|
|
194
|
-
// Explicitly no visualId for local visuals
|
|
195
|
-
};
|
|
196
|
-
S(v, x, "end"), I(x.id), w.success("Visual saved to dashboard"), d(!1), A(!1);
|
|
197
|
-
}
|
|
198
|
-
},
|
|
199
|
-
isLibraryVisual: m,
|
|
200
|
-
currentVisualName: F,
|
|
201
|
-
isSaving: h.isPending
|
|
202
|
-
};
|
|
203
|
-
}
|
|
204
|
-
function Me({
|
|
205
|
-
className: a
|
|
206
|
-
}) {
|
|
207
|
-
const d = k((h) => h.frame), s = k((h) => h.card), t = se((h) => h.selectedVisual), o = g((h) => h.selectedFrameId), u = g((h) => h.selectedSheetId), { setIsVisualEditing: i } = q(), n = !!(d != null && d.visualId || t != null && t.id), c = !!(d != null && d.visualId && o), v = n && !c, {
|
|
208
|
-
saveAsDialogOpen: f,
|
|
209
|
-
setSaveAsDialogOpen: D,
|
|
210
|
-
handleSaveAs: b,
|
|
211
|
-
isLibraryVisual: S,
|
|
212
|
-
currentVisualName: I,
|
|
213
|
-
isSaving: A
|
|
214
|
-
} = Ce(), { handleAddLibraryVisual: m } = H(), F = async () => {
|
|
215
|
-
if (!u) {
|
|
216
|
-
w.error("No dashboard sheet selected");
|
|
217
|
-
return;
|
|
218
|
-
}
|
|
219
|
-
if (!t) {
|
|
220
|
-
w.error("No visual selected");
|
|
221
|
-
return;
|
|
222
|
-
}
|
|
223
|
-
const h = await m(t);
|
|
224
|
-
h.success ? (w.success("Visual added to dashboard"), i(!1)) : w.error(h.error || "Failed to add visual to dashboard");
|
|
225
|
-
};
|
|
226
|
-
return /* @__PURE__ */ r(E, { children: [
|
|
227
|
-
!n && /* @__PURE__ */ e(he, { className: a, variant: "default" }),
|
|
228
|
-
n && /* @__PURE__ */ r(E, { children: [
|
|
229
|
-
c && /* @__PURE__ */ e(ue, { className: a }),
|
|
230
|
-
v && u && s && (s.sql || te(s.config)) && /* @__PURE__ */ r(
|
|
231
|
-
N,
|
|
232
|
-
{
|
|
233
|
-
onClick: F,
|
|
234
|
-
className: y(a),
|
|
235
|
-
size: "sm",
|
|
236
|
-
variant: "outline",
|
|
237
|
-
children: [
|
|
238
|
-
/* @__PURE__ */ e(ge, { className: "mr-2 size-4 font-bold" }),
|
|
239
|
-
"Add to Dashboard"
|
|
240
|
-
]
|
|
241
|
-
}
|
|
242
|
-
),
|
|
243
|
-
v && /* @__PURE__ */ e(me, { className: a, variant: "default" }),
|
|
244
|
-
c && /* @__PURE__ */ e(ve, { className: a }),
|
|
245
|
-
/* @__PURE__ */ r(O, { modal: !1, children: [
|
|
246
|
-
/* @__PURE__ */ e(P, { asChild: !0, children: /* @__PURE__ */ e(
|
|
247
|
-
N,
|
|
248
|
-
{
|
|
249
|
-
variant: "outline",
|
|
250
|
-
size: "sm",
|
|
251
|
-
className: y(a, "w-8 p-0"),
|
|
252
|
-
children: /* @__PURE__ */ e(L, { className: "h-4 w-4" })
|
|
253
|
-
}
|
|
254
|
-
) }),
|
|
255
|
-
/* @__PURE__ */ e(z, { align: "end", children: /* @__PURE__ */ r(
|
|
256
|
-
j,
|
|
257
|
-
{
|
|
258
|
-
onClick: (h) => {
|
|
259
|
-
h.stopPropagation(), D(!0);
|
|
260
|
-
},
|
|
261
|
-
children: [
|
|
262
|
-
/* @__PURE__ */ e(U, { className: "mr-2 h-4 w-4" }),
|
|
263
|
-
"Save As..."
|
|
264
|
-
]
|
|
265
|
-
}
|
|
266
|
-
) })
|
|
267
|
-
] })
|
|
268
|
-
] }),
|
|
269
|
-
!n && /* @__PURE__ */ r(O, { modal: !1, children: [
|
|
270
|
-
/* @__PURE__ */ e(P, { asChild: !0, children: /* @__PURE__ */ e(
|
|
271
|
-
N,
|
|
272
|
-
{
|
|
273
|
-
variant: "outline",
|
|
274
|
-
size: "sm",
|
|
275
|
-
className: y(a, "w-8 p-0"),
|
|
276
|
-
children: /* @__PURE__ */ e(L, { className: "h-4 w-4" })
|
|
277
|
-
}
|
|
278
|
-
) }),
|
|
279
|
-
/* @__PURE__ */ e(z, { align: "end", children: /* @__PURE__ */ r(j, { onClick: () => D(!0), children: [
|
|
280
|
-
/* @__PURE__ */ e(U, { className: "mr-2 h-4 w-4" }),
|
|
281
|
-
"Save As..."
|
|
282
|
-
] }) })
|
|
283
|
-
] }),
|
|
284
|
-
/* @__PURE__ */ e(pe, { className: a }),
|
|
285
|
-
/* @__PURE__ */ e(
|
|
286
|
-
De,
|
|
287
|
-
{
|
|
288
|
-
open: f,
|
|
289
|
-
onOpenChange: (h) => {
|
|
290
|
-
A || D(h);
|
|
291
|
-
},
|
|
292
|
-
isLibraryVisual: S,
|
|
293
|
-
currentVisualName: I,
|
|
294
|
-
isSaving: A,
|
|
295
|
-
onConfirm: b
|
|
296
|
-
}
|
|
297
|
-
)
|
|
298
|
-
] });
|
|
299
|
-
}
|
|
300
|
-
function Ve({
|
|
301
|
-
className: a,
|
|
302
|
-
//labelClassName,
|
|
303
|
-
switchClassName: d
|
|
304
|
-
}) {
|
|
305
|
-
const s = k((n) => n.isDevMode), t = g((n) => n.isVisualEditing), { setIsDevMode: o } = ne(), { config: u } = be(de).tokenProps, i = (u == null ? void 0 : u.showAdvancedMode) !== !1;
|
|
306
|
-
return !t || !i ? null : /* @__PURE__ */ r("div", { className: y("flex items-center space-x-2", a), children: [
|
|
307
|
-
/* @__PURE__ */ e(
|
|
308
|
-
le,
|
|
309
|
-
{
|
|
310
|
-
className: y("", d),
|
|
311
|
-
checked: s,
|
|
312
|
-
onCheckedChange: () => o(!s),
|
|
313
|
-
id: "advanced-mode",
|
|
314
|
-
icon: /* @__PURE__ */ e(re, { className: "h-4 w-4" }),
|
|
315
|
-
tooltip: s ? "Standard Mode" : "Advanced Mode"
|
|
316
|
-
}
|
|
317
|
-
),
|
|
318
|
-
/* @__PURE__ */ e("label", { htmlFor: "advanced-mode", className: "sr-only", children: "Advanced Mode" })
|
|
319
|
-
] });
|
|
320
|
-
}
|
|
321
|
-
function Ee(a) {
|
|
322
|
-
var d;
|
|
323
|
-
return {
|
|
324
|
-
...a,
|
|
325
|
-
sheets: (d = a == null ? void 0 : a.sheets) == null ? void 0 : d.map((s) => {
|
|
326
|
-
var t;
|
|
327
|
-
return {
|
|
328
|
-
...s,
|
|
329
|
-
frames: (t = s.frames) == null ? void 0 : t.map((o) => {
|
|
330
|
-
var u;
|
|
331
|
-
return {
|
|
332
|
-
...o,
|
|
333
|
-
cards: (u = o.cards) == null ? void 0 : u.map((i) => Se(i))
|
|
334
|
-
};
|
|
335
|
-
})
|
|
336
|
-
};
|
|
337
|
-
})
|
|
338
|
-
};
|
|
339
|
-
}
|
|
340
|
-
function Se(a) {
|
|
341
|
-
return {
|
|
342
|
-
...a,
|
|
343
|
-
// cfg: {
|
|
344
|
-
// ...card.cfg,
|
|
345
|
-
// data: {
|
|
346
|
-
// ...card.cfg?.data,
|
|
347
|
-
// labels: [],
|
|
348
|
-
// datasets: card.cfg?.data?.datasets?.map((dataset: any) => {
|
|
349
|
-
// return {
|
|
350
|
-
// ...dataset,
|
|
351
|
-
// data: [],
|
|
352
|
-
// };
|
|
353
|
-
// }),
|
|
354
|
-
// },
|
|
355
|
-
// },
|
|
356
|
-
customCfg: Ae(a.customCfg),
|
|
357
|
-
// if customCfg is present, clean it, otherwise return null{
|
|
358
|
-
data: []
|
|
359
|
-
};
|
|
360
|
-
}
|
|
361
|
-
function Ae(a) {
|
|
362
|
-
var d, s;
|
|
363
|
-
return a ? {
|
|
364
|
-
...a,
|
|
365
|
-
data: {
|
|
366
|
-
...a == null ? void 0 : a.data,
|
|
367
|
-
labels: [],
|
|
368
|
-
datasets: (s = (d = a == null ? void 0 : a.data) == null ? void 0 : d.datasets) == null ? void 0 : s.map((t) => ({
|
|
369
|
-
...t,
|
|
370
|
-
data: []
|
|
371
|
-
}))
|
|
372
|
-
}
|
|
373
|
-
} : null;
|
|
374
|
-
}
|
|
375
|
-
function Te({
|
|
376
|
-
triggerButtonClassName: a
|
|
377
|
-
}) {
|
|
378
|
-
const [d, s] = C(!1), t = g((n) => {
|
|
379
|
-
var c;
|
|
380
|
-
return (c = n.dashboard) == null ? void 0 : c.id;
|
|
381
|
-
}), o = g((n) => {
|
|
382
|
-
var c;
|
|
383
|
-
return (c = n.dashboard) == null ? void 0 : c.title;
|
|
384
|
-
}), u = g((n) => {
|
|
385
|
-
var c;
|
|
386
|
-
return (c = n.dashboard) == null ? void 0 : c.sheets;
|
|
387
|
-
}), i = g((n) => n.selectedSheetId);
|
|
388
|
-
return u == null || u.find((n) => n.id === i), t ? /* @__PURE__ */ r(E, { children: [
|
|
389
|
-
/* @__PURE__ */ e(
|
|
390
|
-
ie,
|
|
391
|
-
{
|
|
392
|
-
tooltip: "Schedule Dashboard",
|
|
393
|
-
className: y("h-7 p-2", a),
|
|
394
|
-
onClick: () => s(!0),
|
|
395
|
-
children: /* @__PURE__ */ e(oe, { className: "size-4" })
|
|
396
|
-
}
|
|
397
|
-
),
|
|
398
|
-
/* @__PURE__ */ e(
|
|
399
|
-
ce,
|
|
400
|
-
{
|
|
401
|
-
open: d,
|
|
402
|
-
onOpenChange: s,
|
|
403
|
-
dashboardId: t,
|
|
404
|
-
dashboardName: o
|
|
405
|
-
}
|
|
406
|
-
)
|
|
407
|
-
] }) : null;
|
|
408
|
-
}
|
|
409
|
-
export {
|
|
410
|
-
Ve as A,
|
|
411
|
-
Te as S,
|
|
412
|
-
Me as V,
|
|
413
|
-
Se as c,
|
|
414
|
-
Ee as g
|
|
415
|
-
};
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
"use strict";const s=require("react/jsx-runtime"),e=require("./index-CZGIYFfM.js"),f=require("./editor-action-buttons-j0OdQL7Y.js"),p=require("react"),y=require("./use-visual-utils-Dhcu2Fn4.js");/**
|
|
2
|
-
* @license lucide-react v0.453.0 - ISC
|
|
3
|
-
*
|
|
4
|
-
* This source code is licensed under the ISC license.
|
|
5
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
6
|
-
*/const k=e.createLucideIcon("CirclePlus",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M8 12h8",key:"1wcyev"}],["path",{d:"M12 8v8",key:"napkw2"}]]);function F({open:a,onOpenChange:r,isLibraryVisual:t,currentVisualName:n,isSaving:l=!1,onConfirm:h}){const[i,d]=p.useState(t&&n?`Copy of ${n}`:n||""),[c,v]=p.useState(""),[b,D]=p.useState(!t),[j,S]=p.useState(!0);p.useEffect(()=>{a&&(d(t&&n?`Copy of ${n}`:n||""),v(""),D(!t),S(!0))},[a,t,n]);const C=()=>{i.trim()&&(!b&&!j||h({name:i.trim(),description:c.trim()||void 0,saveToLibrary:b,saveToCurrentDashboard:j}))},g=i.trim()&&(b||j);return s.jsx(e.Dialog,{open:a,onOpenChange:r,children:s.jsxs(e.DialogContent,{className:"sm:max-w-[425px]",children:[s.jsxs(e.DialogHeader,{children:[s.jsx(e.DialogTitle,{children:"Save Visual As"}),s.jsx(e.DialogDescription,{children:t?"Create a copy of this visual with a new name":"Save this visual to make it reusable"})]}),s.jsxs("div",{className:"grid gap-4 py-4",children:[s.jsxs("div",{className:"grid gap-2",children:[s.jsx(e.Label,{htmlFor:"name",children:"Name"}),s.jsx(e.Input,{id:"name",value:i,onChange:m=>d(m.target.value),placeholder:"Enter visual name",disabled:l})]}),s.jsxs("div",{className:"grid gap-2",children:[s.jsx(e.Label,{htmlFor:"description",children:"Description (optional)"}),s.jsx(e.Textarea,{id:"description",value:c,onChange:m=>v(m.target.value),placeholder:"Enter visual description",rows:3,disabled:l})]}),s.jsxs("div",{className:"space-y-4",children:[s.jsx(e.Label,{children:"Save to:"}),s.jsxs("div",{className:"space-y-2",children:[s.jsxs("div",{className:"flex items-center space-x-2",children:[s.jsx(e.Checkbox,{id:"save-to-dashboard",checked:j,onCheckedChange:m=>S(!!m),disabled:l}),s.jsxs("label",{htmlFor:"save-to-dashboard",className:"text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70",children:["Current Dashboard",s.jsx("span",{className:"ml-2 text-xs text-muted-foreground",children:t?"(add copy to this dashboard)":"(keep as local visual)"})]})]}),s.jsxs("div",{className:"flex items-center space-x-2",children:[s.jsx(e.Checkbox,{id:"save-to-library",checked:b,onCheckedChange:m=>D(!!m),disabled:l}),s.jsxs("label",{htmlFor:"save-to-library",className:"text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70",children:["Visual Library",s.jsx("span",{className:"ml-2 text-xs text-muted-foreground",children:t?"(save as new reusable visual)":"(make available to all dashboards)"})]})]})]}),!b&&!j&&s.jsx("p",{className:"text-sm text-destructive",children:"Please select at least one destination"})]})]}),s.jsxs(e.DialogFooter,{children:[s.jsx(e.Button,{variant:"outline",onClick:()=>r(!1),disabled:l,children:"Cancel"}),s.jsxs(e.Button,{onClick:C,disabled:!g||l,children:[l&&s.jsx(e.LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin"}),l?"Saving...":"Save"]})]})]})})}function N(){const[a,r]=p.useState(!1),[t,n]=p.useState(!1),[l,h]=p.useState(null),i=e.useEditorStore(o=>o.frame),d=e.useEditorStore(o=>o.card),c=e.useSelectedVisual(),v=e.useDashboardStore(o=>o.selectedSheetId),b=e.useDashboardStore(o=>o.actions.setIsDashboardPanelOpen),{getUpdatedFrame:D}=y.useVisualUtils(),{selectVisual:j}=e.useManagementActions(),{addFrame:S,setSelectedFrameId:C,setIsVisualEditing:g}=e.useDashboardActions(),m=!!(i!=null&&i.visualId),w=(()=>{var o,x;return((o=i==null?void 0:i.cards)==null?void 0:o.length)===1&&((x=i.cards[0])!=null&&x.title)?i.cards[0].title:c!=null&&c.title?c.title:(d==null?void 0:d.title)||"Untitled Visual"})(),u=e.useCreateVisualWithFrame(o=>{if(o!=null&&o.id){if(j(o),t&&l&&v){const x={...l,id:e.v4(),visualId:o.id};S(v,x,"end"),C(x.id),n(!1),h(null),g(!1)}b(!0),r(!1)}});return{saveAsDialogOpen:a,setSaveAsDialogOpen:r,handleSaveAs:async o=>{if(!v){e.ue.error("No sheet selected");return}const x=D(),I=x.cards.length===1?{...x,cards:x.cards.map(A=>({...A,title:o.name}))}:x;if(o.saveToLibrary){n(o.saveToCurrentDashboard),h(I);const A={title:o.name,description:o.description,frameObject:I,isPrivate:!1};u.mutate(A)}else if(o.saveToCurrentDashboard){const A={...I,id:e.v4(),visualId:void 0};S(v,A,"end"),C(A.id),e.ue.success("Visual saved to dashboard"),r(!1),g(!1)}},isLibraryVisual:m,currentVisualName:w,isSaving:u.isPending}}function V({className:a}){const r=e.useEditorStore(u=>u.frame),t=e.useEditorStore(u=>u.card),n=e.useManagementStore(u=>u.selectedVisual),l=e.useDashboardStore(u=>u.selectedFrameId),h=e.useDashboardStore(u=>u.selectedSheetId),{setIsVisualEditing:i}=e.useDashboardActions(),d=!!(r!=null&&r.visualId||n!=null&&n.id),c=!!(r!=null&&r.visualId&&l),v=d&&!c,{saveAsDialogOpen:b,setSaveAsDialogOpen:D,handleSaveAs:j,isLibraryVisual:S,currentVisualName:C,isSaving:g}=N(),{handleAddLibraryVisual:m}=y.useVisualUtils(),w=async()=>{if(!h){e.ue.error("No dashboard sheet selected");return}if(!n){e.ue.error("No visual selected");return}const u=await m(n);u.success?(e.ue.success("Visual added to dashboard"),i(!1)):e.ue.error(u.error||"Failed to add visual to dashboard")};return s.jsxs(s.Fragment,{children:[!d&&s.jsx(f.EditorAcceptButton,{className:a,variant:"default"}),d&&s.jsxs(s.Fragment,{children:[c&&s.jsx(f.VisualApplyLocalButton,{className:a}),v&&h&&t&&(t.sql||e.hasValidCardConfig(t.config))&&s.jsxs(e.Button,{onClick:w,className:e.cn(a),size:"sm",variant:"outline",children:[s.jsx(k,{className:"mr-2 size-4 font-bold"}),"Add to Dashboard"]}),v&&s.jsx(f.VisualSaveButton,{className:a,variant:"default"}),c&&s.jsx(f.VisualSaveAndApplyButton,{className:a}),s.jsxs(e.DropdownMenu,{modal:!1,children:[s.jsx(e.DropdownMenuTrigger,{asChild:!0,children:s.jsx(e.Button,{variant:"outline",size:"sm",className:e.cn(a,"w-8 p-0"),children:s.jsx(e.EllipsisVertical,{className:"h-4 w-4"})})}),s.jsx(e.DropdownMenuContent,{align:"end",children:s.jsxs(e.DropdownMenuItem,{onClick:u=>{u.stopPropagation(),D(!0)},children:[s.jsx(f.Save,{className:"mr-2 h-4 w-4"}),"Save As..."]})})]})]}),!d&&s.jsxs(e.DropdownMenu,{modal:!1,children:[s.jsx(e.DropdownMenuTrigger,{asChild:!0,children:s.jsx(e.Button,{variant:"outline",size:"sm",className:e.cn(a,"w-8 p-0"),children:s.jsx(e.EllipsisVertical,{className:"h-4 w-4"})})}),s.jsx(e.DropdownMenuContent,{align:"end",children:s.jsxs(e.DropdownMenuItem,{onClick:()=>D(!0),children:[s.jsx(f.Save,{className:"mr-2 h-4 w-4"}),"Save As..."]})})]}),s.jsx(f.EditorCancelButton,{className:a}),s.jsx(F,{open:b,onOpenChange:u=>{g||D(u)},isLibraryVisual:S,currentVisualName:C,isSaving:g,onConfirm:j})]})}function E({className:a,switchClassName:r}){const t=e.useEditorStore(d=>d.isDevMode),n=e.useDashboardStore(d=>d.isVisualEditing),{setIsDevMode:l}=e.useEditorActions(),{config:h}=p.useContext(e.SemaphorContext).tokenProps,i=(h==null?void 0:h.showAdvancedMode)!==!1;return!n||!i?null:s.jsxs("div",{className:e.cn("flex items-center space-x-2",a),children:[s.jsx(e.DevModeSwitch,{className:e.cn("",r),checked:t,onCheckedChange:()=>l(!t),id:"advanced-mode",icon:s.jsx(e.CodeXml,{className:"h-4 w-4"}),tooltip:t?"Standard Mode":"Advanced Mode"}),s.jsx("label",{htmlFor:"advanced-mode",className:"sr-only",children:"Advanced Mode"})]})}function T(a){var r;return{...a,sheets:(r=a==null?void 0:a.sheets)==null?void 0:r.map(t=>{var n;return{...t,frames:(n=t.frames)==null?void 0:n.map(l=>{var h;return{...l,cards:(h=l.cards)==null?void 0:h.map(i=>M(i))}})}})}}function M(a){return{...a,customCfg:B(a.customCfg),data:[]}}function B(a){var r,t;return a?{...a,data:{...a==null?void 0:a.data,labels:[],datasets:(t=(r=a==null?void 0:a.data)==null?void 0:r.datasets)==null?void 0:t.map(n=>({...n,data:[]}))}}:null}function O({triggerButtonClassName:a}){const[r,t]=p.useState(!1),n=e.useDashboardStore(d=>{var c;return(c=d.dashboard)==null?void 0:c.id}),l=e.useDashboardStore(d=>{var c;return(c=d.dashboard)==null?void 0:c.title}),h=e.useDashboardStore(d=>{var c;return(c=d.dashboard)==null?void 0:c.sheets}),i=e.useDashboardStore(d=>d.selectedSheetId);return h==null||h.find(d=>d.id===i),n?s.jsxs(s.Fragment,{children:[s.jsx(e.IconButton,{tooltip:"Schedule Dashboard",className:e.cn("h-7 p-2",a),onClick:()=>t(!0),children:s.jsx(e.Clock,{className:"size-4"})}),s.jsx(e.EmailScheduleDialog,{open:r,onOpenChange:t,dashboardId:n,dashboardName:l})]}):null}exports.AdvancedModeToggle=E;exports.ScheduleDashboard=O;exports.VisualEditingControls=V;exports.cleanCard=M;exports.getDashbaordStateWithoutData=T;
|