react-semaphor 0.1.164 → 0.1.166

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.
Files changed (33) hide show
  1. package/dist/chunks/dashboard-controls-B9UPzyO5.js +26 -0
  2. package/dist/chunks/{dashboard-controls-CWQ_gUsq.js → dashboard-controls-CixEPYYv.js} +260 -285
  3. package/dist/chunks/{dashboard-json-05FNu5_c.js → dashboard-json-BYNwk3YG.js} +1 -1
  4. package/dist/chunks/{dashboard-json-BnUM90on.js → dashboard-json-LXUW-x_7.js} +1 -1
  5. package/dist/chunks/{edit-dashboard-visual-BQyiGFIJ.js → edit-dashboard-visual-CyW3aGrM.js} +1 -1
  6. package/dist/chunks/{edit-dashboard-visual-DvcXroC3.js → edit-dashboard-visual-DtiYOHX5.js} +2 -2
  7. package/dist/chunks/{editor-action-buttons-0lhAtWvK.js → editor-action-buttons-C2VJa0cF.js} +2 -2
  8. package/dist/chunks/{editor-action-buttons-DChxrcx_.js → editor-action-buttons-CFZZpeDq.js} +1 -1
  9. package/dist/chunks/index-CQ7RRL9U.js +1108 -0
  10. package/dist/chunks/{index-Ba7cbkS0.js → index-DYeBGt71.js} +19247 -18898
  11. package/dist/chunks/{resource-management-panel-BDDrOqYt.js → resource-management-panel-DJOLQsLL.js} +141 -141
  12. package/dist/chunks/{resource-management-panel-Dw5GP_kj.js → resource-management-panel-qqHHN4xT.js} +1 -1
  13. package/dist/chunks/schedule-dashboard-B5cLQ2sk.js +6 -0
  14. package/dist/chunks/schedule-dashboard-B9Y23qK6.js +416 -0
  15. package/dist/chunks/{use-role-aware-display-preferences-C9ydHtPN.js → use-role-aware-display-preferences-8gWJAMO3.js} +1 -1
  16. package/dist/chunks/{use-role-aware-display-preferences-Dk-fULeQ.js → use-role-aware-display-preferences-BJCLNjn8.js} +1 -1
  17. package/dist/chunks/{use-visual-utils-BOMHKg6C.js → use-visual-utils-Bsvc2KNu.js} +1 -1
  18. package/dist/chunks/{use-visual-utils-DfO9gvaA.js → use-visual-utils-DA9bk0Rh.js} +20 -20
  19. package/dist/dashboard/index.cjs +1 -1
  20. package/dist/dashboard/index.js +1 -1
  21. package/dist/index.cjs +2 -2
  22. package/dist/index.js +111 -108
  23. package/dist/surfboard/index.cjs +1 -1
  24. package/dist/surfboard/index.js +1 -1
  25. package/dist/types/dashboard.d.ts +5 -0
  26. package/dist/types/main.d.ts +5 -0
  27. package/dist/types/surfboard.d.ts +5 -0
  28. package/dist/types/types.d.ts +5 -0
  29. package/package.json +1 -1
  30. package/dist/chunks/dashboard-controls-Czfs9TsO.js +0 -26
  31. package/dist/chunks/dashboard-export-dialog-DiJIOI6i.js +0 -602
  32. package/dist/chunks/dashboard-export-dialog-zge97BYd.js +0 -6
  33. package/dist/chunks/index-SZ7sy6nw.js +0 -1103
@@ -1,602 +0,0 @@
1
- import { jsx as e, jsxs as a, Fragment as F } from "react/jsx-runtime";
2
- import { l as X, aD as $, aE as H, aF as W, aG as _, aH as q, aI as A, aJ as Y, aK as Z, aL as V, aM as J, B as P, L as T, n as E, q as ee, u as b, az as ae, o as K, aN as se, aO as O, t as v, Q as te, aP as re, c as I, aQ as B, aR as L, aS as z, aT as U, aU as G, m as oe, aV as le, aW as ne, aX as de, aY as ie, aZ as ce, a_ as he, a$ as ue, b0 as me, b1 as pe, b2 as fe, b3 as ve, b4 as ge, a4 as be, J as Ce, b5 as we, b6 as xe, ay as De, b7 as ye, b8 as R, b9 as Ne, ba as Se, bb as Ae, bc as Pe, bd as Fe, be as ke, a6 as Ie } from "./index-Ba7cbkS0.js";
3
- import { E as Ee, V as Me, a as Ve, b as Te, S as j, c as Oe } from "./editor-action-buttons-0lhAtWvK.js";
4
- import Be, { useState as C, useContext as Le, useEffect as ze } from "react";
5
- import { a as Q } from "./use-visual-utils-DfO9gvaA.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 Ue = X("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 Ge({
18
- open: c,
19
- onOpenChange: i,
20
- isLibraryVisual: r,
21
- currentVisualName: o,
22
- isSaving: d = !1,
23
- onConfirm: m
24
- }) {
25
- const [s, l] = C(
26
- r && o ? `Copy of ${o}` : o || ""
27
- ), [n, f] = C(""), [g, w] = C(!r), [p, N] = C(!0);
28
- Be.useEffect(() => {
29
- c && (l(
30
- r && o ? `Copy of ${o}` : o || ""
31
- ), f(""), w(!r), N(!0));
32
- }, [c, r, o]);
33
- const x = () => {
34
- s.trim() && (!g && !p || m({
35
- name: s.trim(),
36
- description: n.trim() || void 0,
37
- saveToLibrary: g,
38
- saveToCurrentDashboard: p
39
- }));
40
- }, D = s.trim() && (g || p);
41
- return /* @__PURE__ */ e($, { open: c, onOpenChange: i, children: /* @__PURE__ */ a(H, { className: "sm:max-w-[425px]", children: [
42
- /* @__PURE__ */ a(W, { children: [
43
- /* @__PURE__ */ e(_, { children: "Save Visual As" }),
44
- /* @__PURE__ */ e(q, { children: r ? "Create a copy of this visual with a new name" : "Save this visual to make it reusable" })
45
- ] }),
46
- /* @__PURE__ */ a("div", { className: "grid gap-4 py-4", children: [
47
- /* @__PURE__ */ a("div", { className: "grid gap-2", children: [
48
- /* @__PURE__ */ e(A, { htmlFor: "name", children: "Name" }),
49
- /* @__PURE__ */ e(
50
- Y,
51
- {
52
- id: "name",
53
- value: s,
54
- onChange: (t) => l(t.target.value),
55
- placeholder: "Enter visual name",
56
- disabled: d
57
- }
58
- )
59
- ] }),
60
- /* @__PURE__ */ a("div", { className: "grid gap-2", children: [
61
- /* @__PURE__ */ e(A, { htmlFor: "description", children: "Description (optional)" }),
62
- /* @__PURE__ */ e(
63
- Z,
64
- {
65
- id: "description",
66
- value: n,
67
- onChange: (t) => f(t.target.value),
68
- placeholder: "Enter visual description",
69
- rows: 3,
70
- disabled: d
71
- }
72
- )
73
- ] }),
74
- /* @__PURE__ */ a("div", { className: "space-y-4", children: [
75
- /* @__PURE__ */ e(A, { children: "Save to:" }),
76
- /* @__PURE__ */ a("div", { className: "space-y-2", children: [
77
- /* @__PURE__ */ a("div", { className: "flex items-center space-x-2", children: [
78
- /* @__PURE__ */ e(
79
- V,
80
- {
81
- id: "save-to-dashboard",
82
- checked: p,
83
- onCheckedChange: (t) => N(!!t),
84
- disabled: d
85
- }
86
- ),
87
- /* @__PURE__ */ a(
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: r ? "(add copy to this dashboard)" : "(keep as local visual)" })
95
- ]
96
- }
97
- )
98
- ] }),
99
- /* @__PURE__ */ a("div", { className: "flex items-center space-x-2", children: [
100
- /* @__PURE__ */ e(
101
- V,
102
- {
103
- id: "save-to-library",
104
- checked: g,
105
- onCheckedChange: (t) => w(!!t),
106
- disabled: d
107
- }
108
- ),
109
- /* @__PURE__ */ a(
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: r ? "(save as new reusable visual)" : "(make available to all dashboards)" })
117
- ]
118
- }
119
- )
120
- ] })
121
- ] }),
122
- !g && !p && /* @__PURE__ */ e("p", { className: "text-sm text-destructive", children: "Please select at least one destination" })
123
- ] })
124
- ] }),
125
- /* @__PURE__ */ a(J, { children: [
126
- /* @__PURE__ */ e(
127
- P,
128
- {
129
- variant: "outline",
130
- onClick: () => i(!1),
131
- disabled: d,
132
- children: "Cancel"
133
- }
134
- ),
135
- /* @__PURE__ */ a(P, { onClick: x, disabled: !D || d, children: [
136
- d && /* @__PURE__ */ e(T, { className: "mr-2 h-4 w-4 animate-spin" }),
137
- d ? "Saving..." : "Save"
138
- ] })
139
- ] })
140
- ] }) });
141
- }
142
- function Re() {
143
- const [c, i] = C(!1), [r, o] = C(!1), [d, m] = C(null), s = E((u) => u.frame), l = E((u) => u.card), n = ee(), f = b((u) => u.selectedSheetId), g = b(
144
- (u) => u.actions.setIsDashboardPanelOpen
145
- ), { getUpdatedFrame: w } = Q(), { selectVisual: p } = ae(), { addFrame: N, setSelectedFrameId: x, setIsVisualEditing: D } = K(), t = !!(s != null && s.visualId), S = (() => {
146
- var u, y;
147
- return ((u = s == null ? void 0 : s.cards) == null ? void 0 : u.length) === 1 && ((y = s.cards[0]) != null && y.title) ? s.cards[0].title : n != null && n.title ? n.title : (l == null ? void 0 : l.title) || "Untitled Visual";
148
- })(), h = se((u) => {
149
- if (u != null && u.id) {
150
- if (p(u), r && d && f) {
151
- const y = {
152
- ...d,
153
- id: O(),
154
- visualId: u.id
155
- // Link to the newly created library visual
156
- };
157
- N(f, y, "end"), x(y.id), o(!1), m(null), D(!1);
158
- }
159
- g(!0), i(!1);
160
- }
161
- });
162
- return {
163
- saveAsDialogOpen: c,
164
- setSaveAsDialogOpen: i,
165
- handleSaveAs: async (u) => {
166
- if (!f) {
167
- v.error("No sheet selected");
168
- return;
169
- }
170
- const y = w(), M = y.cards.length === 1 ? {
171
- ...y,
172
- cards: y.cards.map((k) => ({
173
- ...k,
174
- title: u.name
175
- // Use visual name as card title
176
- }))
177
- } : y;
178
- if (u.saveToLibrary) {
179
- o(u.saveToCurrentDashboard), m(M);
180
- const k = {
181
- title: u.name,
182
- description: u.description,
183
- frameObject: M,
184
- // Card title synced for single-card frames
185
- isPrivate: !1
186
- };
187
- h.mutate(k);
188
- } else if (u.saveToCurrentDashboard) {
189
- const k = {
190
- ...M,
191
- // Card title already synced
192
- id: O(),
193
- visualId: void 0
194
- // Explicitly no visualId for local visuals
195
- };
196
- N(f, k, "end"), x(k.id), v.success("Visual saved to dashboard"), i(!1), D(!1);
197
- }
198
- },
199
- isLibraryVisual: t,
200
- currentVisualName: S,
201
- isSaving: h.isPending
202
- };
203
- }
204
- function Ke({
205
- className: c
206
- }) {
207
- const i = E((h) => h.frame), r = E((h) => h.card), o = te((h) => h.selectedVisual), d = b((h) => h.selectedFrameId), m = b((h) => h.selectedSheetId), { setIsVisualEditing: s } = K(), l = !!(i != null && i.visualId || o != null && o.id), n = !!(i != null && i.visualId && d), f = l && !n, {
208
- saveAsDialogOpen: g,
209
- setSaveAsDialogOpen: w,
210
- handleSaveAs: p,
211
- isLibraryVisual: N,
212
- currentVisualName: x,
213
- isSaving: D
214
- } = Re(), { handleAddLibraryVisual: t } = Q(), S = async () => {
215
- if (!m) {
216
- v.error("No dashboard sheet selected");
217
- return;
218
- }
219
- if (!o) {
220
- v.error("No visual selected");
221
- return;
222
- }
223
- const h = await t(o);
224
- h.success ? (v.success("Visual added to dashboard"), s(!1)) : v.error(h.error || "Failed to add visual to dashboard");
225
- };
226
- return /* @__PURE__ */ a(F, { children: [
227
- !l && /* @__PURE__ */ e(Ee, { className: c, variant: "default" }),
228
- l && /* @__PURE__ */ a(F, { children: [
229
- n && /* @__PURE__ */ e(Me, { className: c }),
230
- f && m && r && (r.sql || re(r.config)) && /* @__PURE__ */ a(
231
- P,
232
- {
233
- onClick: S,
234
- className: I(c),
235
- size: "sm",
236
- variant: "outline",
237
- children: [
238
- /* @__PURE__ */ e(Ue, { className: "mr-2 size-4 font-bold" }),
239
- "Add to Dashboard"
240
- ]
241
- }
242
- ),
243
- f && /* @__PURE__ */ e(Ve, { className: c, variant: "default" }),
244
- n && /* @__PURE__ */ e(Te, { className: c }),
245
- /* @__PURE__ */ a(B, { modal: !1, children: [
246
- /* @__PURE__ */ e(L, { asChild: !0, children: /* @__PURE__ */ e(
247
- P,
248
- {
249
- variant: "outline",
250
- size: "sm",
251
- className: I(c, "w-8 p-0"),
252
- children: /* @__PURE__ */ e(z, { className: "h-4 w-4" })
253
- }
254
- ) }),
255
- /* @__PURE__ */ e(U, { align: "end", children: /* @__PURE__ */ a(
256
- G,
257
- {
258
- onClick: (h) => {
259
- h.stopPropagation(), w(!0);
260
- },
261
- children: [
262
- /* @__PURE__ */ e(j, { className: "mr-2 h-4 w-4" }),
263
- "Save As..."
264
- ]
265
- }
266
- ) })
267
- ] })
268
- ] }),
269
- !l && /* @__PURE__ */ a(B, { modal: !1, children: [
270
- /* @__PURE__ */ e(L, { asChild: !0, children: /* @__PURE__ */ e(
271
- P,
272
- {
273
- variant: "outline",
274
- size: "sm",
275
- className: I(c, "w-8 p-0"),
276
- children: /* @__PURE__ */ e(z, { className: "h-4 w-4" })
277
- }
278
- ) }),
279
- /* @__PURE__ */ e(U, { align: "end", children: /* @__PURE__ */ a(G, { onClick: () => w(!0), children: [
280
- /* @__PURE__ */ e(j, { className: "mr-2 h-4 w-4" }),
281
- "Save As..."
282
- ] }) })
283
- ] }),
284
- /* @__PURE__ */ e(Oe, { className: c }),
285
- /* @__PURE__ */ e(
286
- Ge,
287
- {
288
- open: g,
289
- onOpenChange: (h) => {
290
- D || w(h);
291
- },
292
- isLibraryVisual: N,
293
- currentVisualName: x,
294
- isSaving: D,
295
- onConfirm: p
296
- }
297
- )
298
- ] });
299
- }
300
- function Qe({
301
- className: c,
302
- //labelClassName,
303
- switchClassName: i
304
- }) {
305
- const r = E((l) => l.isDevMode), o = b((l) => l.isVisualEditing), { setIsDevMode: d } = oe(), { config: m } = Le(le).tokenProps, s = (m == null ? void 0 : m.showAdvancedMode) !== !1;
306
- return !o || !s ? null : /* @__PURE__ */ a("div", { className: I("flex items-center space-x-2", c), children: [
307
- /* @__PURE__ */ e(
308
- ne,
309
- {
310
- className: I("", i),
311
- checked: r,
312
- onCheckedChange: () => d(!r),
313
- id: "advanced-mode",
314
- icon: /* @__PURE__ */ e(de, { className: "h-4 w-4" }),
315
- tooltip: r ? "Standard Mode" : "Advanced Mode"
316
- }
317
- ),
318
- /* @__PURE__ */ e("label", { htmlFor: "advanced-mode", className: "sr-only", children: "Advanced Mode" })
319
- ] });
320
- }
321
- function Xe({
322
- open: c,
323
- onOpenChange: i,
324
- onSave: r,
325
- onDiscard: o,
326
- isSaving: d
327
- }) {
328
- return /* @__PURE__ */ e(ie, { open: c, onOpenChange: (s) => {
329
- !s && d || i(s);
330
- }, children: /* @__PURE__ */ a(ce, { className: "max-w-md", children: [
331
- /* @__PURE__ */ a(he, { children: [
332
- /* @__PURE__ */ a("div", { className: "flex items-center gap-3", children: [
333
- /* @__PURE__ */ e("div", { className: "flex h-10 w-10 items-center justify-center rounded-full bg-amber-100", children: /* @__PURE__ */ e(ue, { className: "h-5 w-5 text-amber-600" }) }),
334
- /* @__PURE__ */ e(me, { className: "text-xl", children: "Unsaved Changes" })
335
- ] }),
336
- /* @__PURE__ */ e(pe, { className: "pt-2 text-base leading-relaxed", children: "You have unsaved changes to this dashboard. What would you like to do?" })
337
- ] }),
338
- /* @__PURE__ */ a(fe, { className: "flex-col gap-2 sm:flex-row sm:gap-2", children: [
339
- /* @__PURE__ */ e(
340
- ve,
341
- {
342
- disabled: d,
343
- className: "order-1 m-0 border-border/50 sm:order-1",
344
- children: "Cancel"
345
- }
346
- ),
347
- /* @__PURE__ */ e(
348
- "button",
349
- {
350
- onClick: o,
351
- disabled: d,
352
- className: "order-2 rounded-md border border-destructive/20 bg-destructive/10 px-4 py-2 text-sm font-medium text-destructive transition-colors hover:bg-destructive/20 disabled:pointer-events-none disabled:opacity-50 sm:order-2",
353
- children: "Discard"
354
- }
355
- ),
356
- /* @__PURE__ */ e(
357
- ge,
358
- {
359
- onClick: r,
360
- disabled: d,
361
- className: "order-3 m-0 bg-primary text-primary-foreground hover:bg-primary/90 sm:order-3",
362
- children: d ? /* @__PURE__ */ a(F, { children: [
363
- /* @__PURE__ */ e(T, { className: "mr-2 h-4 w-4 animate-spin" }),
364
- "Saving..."
365
- ] }) : "Save & Close"
366
- }
367
- )
368
- ] })
369
- ] }) });
370
- }
371
- function Ye(c, i, r, o) {
372
- ze(() => {
373
- c && !r && i && o(be(i));
374
- }, [c, r, i, o]);
375
- }
376
- function Ze({
377
- triggerButtonClassName: c
378
- }) {
379
- const [i, r] = C(!1), o = b((l) => {
380
- var n;
381
- return (n = l.dashboard) == null ? void 0 : n.id;
382
- }), d = b((l) => {
383
- var n;
384
- return (n = l.dashboard) == null ? void 0 : n.title;
385
- }), m = b((l) => {
386
- var n;
387
- return (n = l.dashboard) == null ? void 0 : n.sheets;
388
- }), s = b((l) => l.selectedSheetId);
389
- return m == null || m.find((l) => l.id === s), o ? /* @__PURE__ */ a(F, { children: [
390
- /* @__PURE__ */ e(
391
- Ce,
392
- {
393
- tooltip: "Schedule Dashboard",
394
- className: I("h-7 p-2", c),
395
- onClick: () => r(!0),
396
- children: /* @__PURE__ */ e(we, { className: "size-4" })
397
- }
398
- ),
399
- /* @__PURE__ */ e(
400
- xe,
401
- {
402
- open: i,
403
- onOpenChange: r,
404
- dashboardId: o,
405
- dashboardName: d
406
- }
407
- )
408
- ] }) : null;
409
- }
410
- function ea({
411
- open: c,
412
- onOpenChange: i
413
- }) {
414
- const [r, o] = C(!1), [d, m] = C(!1), [s, l] = C({
415
- sheetSelection: "current",
416
- protectPdf: !1,
417
- password: ""
418
- }), n = b((t) => {
419
- var S;
420
- return (S = t.dashboard) == null ? void 0 : S.sheets;
421
- }), f = b((t) => t.selectedSheetId), { authToken: g, tokenProps: w } = De(), p = n == null ? void 0 : n.find((t) => t.id === f), N = ((n == null ? void 0 : n.length) || 0) > 1, x = () => {
422
- l({
423
- sheetSelection: "current",
424
- protectPdf: !1,
425
- password: ""
426
- }), o(!1), i(!1);
427
- };
428
- async function D() {
429
- if (s.protectPdf && !s.password) {
430
- v.error("Please enter a password to protect the PDF");
431
- return;
432
- }
433
- m(!0);
434
- const t = s.sheetSelection === "all" ? "Generating PDF for all sheets... This may take a while." : s.protectPdf ? "Generating protected PDF... may take up to 60 seconds" : "Generating PDF... may take up to 60 seconds", S = v.loading(t);
435
- try {
436
- await Ie(
437
- w.apiServiceUrl,
438
- g,
439
- s.protectPdf ? s.password : void 0,
440
- s.sheetSelection
441
- ), v.dismiss(S);
442
- const h = s.sheetSelection === "all" ? "All sheets PDF downloaded successfully!" : s.protectPdf ? "Protected PDF downloaded successfully!" : "PDF downloaded successfully!";
443
- v.success(h, {
444
- duration: 2e3
445
- }), x();
446
- } catch (h) {
447
- v.dismiss(S), v.error("Failed to download PDF", {
448
- description: "Please try again or contact support.",
449
- richColors: !0
450
- }), console.error("PDF download error:", h);
451
- } finally {
452
- m(!1);
453
- }
454
- }
455
- return /* @__PURE__ */ e(
456
- $,
457
- {
458
- open: c,
459
- onOpenChange: (t) => {
460
- if (!t) {
461
- x();
462
- return;
463
- }
464
- i(!0);
465
- },
466
- children: /* @__PURE__ */ a(H, { className: "sm:max-w-[425px]", children: [
467
- /* @__PURE__ */ a(W, { children: [
468
- /* @__PURE__ */ e(_, { children: "Export Dashboard" }),
469
- /* @__PURE__ */ e(q, { children: "Export your dashboard as a PDF document." })
470
- ] }),
471
- /* @__PURE__ */ a("div", { className: "space-y-4 py-4", children: [
472
- N && /* @__PURE__ */ a(F, { children: [
473
- /* @__PURE__ */ a("div", { className: "space-y-3", children: [
474
- /* @__PURE__ */ e(A, { children: "Export Scope" }),
475
- /* @__PURE__ */ a(
476
- ye,
477
- {
478
- value: s.sheetSelection,
479
- onValueChange: (t) => l({
480
- ...s,
481
- sheetSelection: t
482
- }),
483
- children: [
484
- /* @__PURE__ */ a("div", { className: "flex items-center space-x-2", children: [
485
- /* @__PURE__ */ e(R, { value: "current", id: "scope-current" }),
486
- /* @__PURE__ */ a(
487
- A,
488
- {
489
- htmlFor: "scope-current",
490
- className: "cursor-pointer font-normal",
491
- children: [
492
- "This sheet (",
493
- (p == null ? void 0 : p.title) || "Current",
494
- ")"
495
- ]
496
- }
497
- )
498
- ] }),
499
- /* @__PURE__ */ a("div", { className: "flex items-center space-x-2", children: [
500
- /* @__PURE__ */ e(R, { value: "all", id: "scope-all" }),
501
- /* @__PURE__ */ a(
502
- A,
503
- {
504
- htmlFor: "scope-all",
505
- className: "cursor-pointer font-normal",
506
- children: [
507
- "All sheets (",
508
- n == null ? void 0 : n.length,
509
- " sheets)"
510
- ]
511
- }
512
- )
513
- ] })
514
- ]
515
- }
516
- )
517
- ] }),
518
- /* @__PURE__ */ e(Ne, {})
519
- ] }),
520
- /* @__PURE__ */ a("div", { className: "space-y-3", children: [
521
- /* @__PURE__ */ a("div", { className: "flex items-center space-x-2", children: [
522
- /* @__PURE__ */ e(
523
- V,
524
- {
525
- id: "protect-pdf",
526
- checked: s.protectPdf,
527
- onCheckedChange: (t) => {
528
- l({
529
- ...s,
530
- protectPdf: t,
531
- password: t ? s.password : ""
532
- }), t || o(!1);
533
- }
534
- }
535
- ),
536
- /* @__PURE__ */ a(
537
- A,
538
- {
539
- htmlFor: "protect-pdf",
540
- className: "flex cursor-pointer items-center text-sm font-normal",
541
- children: [
542
- /* @__PURE__ */ e(Se, { className: "mr-2 h-3.5 w-3.5" }),
543
- "Password protect PDF"
544
- ]
545
- }
546
- )
547
- ] }),
548
- s.protectPdf && /* @__PURE__ */ a("div", { className: "ml-6 space-y-2", children: [
549
- /* @__PURE__ */ e(A, { htmlFor: "pdf-password", className: "text-sm", children: "Password" }),
550
- /* @__PURE__ */ a("div", { className: "relative", children: [
551
- /* @__PURE__ */ e(
552
- Ae,
553
- {
554
- id: "pdf-password",
555
- type: r ? "text" : "password",
556
- value: s.password,
557
- onChange: (t) => l({ ...s, password: t.target.value }),
558
- placeholder: "Enter password",
559
- className: "pr-10",
560
- onKeyDown: (t) => {
561
- t.key === "Enter" && s.password && D();
562
- }
563
- }
564
- ),
565
- /* @__PURE__ */ e(
566
- P,
567
- {
568
- type: "button",
569
- variant: "ghost",
570
- size: "sm",
571
- className: "absolute right-0 top-0 h-full px-3 py-2 hover:bg-transparent",
572
- onClick: () => o(!r),
573
- children: r ? /* @__PURE__ */ e(Pe, { className: "h-4 w-4 text-muted-foreground" }) : /* @__PURE__ */ e(Fe, { className: "h-4 w-4 text-muted-foreground" })
574
- }
575
- )
576
- ] }),
577
- /* @__PURE__ */ e("p", { className: "text-xs text-muted-foreground", children: "Recipients will need this password to open the PDF" })
578
- ] })
579
- ] })
580
- ] }),
581
- /* @__PURE__ */ a(J, { children: [
582
- /* @__PURE__ */ e(P, { variant: "outline", onClick: x, disabled: d, children: "Cancel" }),
583
- /* @__PURE__ */ e(P, { onClick: D, disabled: d, children: d ? /* @__PURE__ */ a(F, { children: [
584
- /* @__PURE__ */ e(T, { className: "mr-2 h-4 w-4 animate-spin" }),
585
- "Exporting..."
586
- ] }) : /* @__PURE__ */ a(F, { children: [
587
- /* @__PURE__ */ e(ke, { className: "mr-2 h-4 w-4" }),
588
- "Export"
589
- ] }) })
590
- ] })
591
- ] })
592
- }
593
- );
594
- }
595
- export {
596
- Qe as A,
597
- ea as D,
598
- Ze as S,
599
- Xe as U,
600
- Ke as V,
601
- Ye as u
602
- };
@@ -1,6 +0,0 @@
1
- "use strict";const e=require("react/jsx-runtime"),s=require("./index-SZ7sy6nw.js"),w=require("./editor-action-buttons-DChxrcx_.js"),x=require("react"),F=require("./use-visual-utils-BOMHKg6C.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 A=s.createLucideIcon("CirclePlus",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M8 12h8",key:"1wcyev"}],["path",{d:"M12 8v8",key:"napkw2"}]]);function P({open:c,onOpenChange:i,isLibraryVisual:r,currentVisualName:o,isSaving:d=!1,onConfirm:m}){const[a,n]=x.useState(r&&o?`Copy of ${o}`:o||""),[l,g]=x.useState(""),[v,f]=x.useState(!r),[p,S]=x.useState(!0);x.useEffect(()=>{c&&(n(r&&o?`Copy of ${o}`:o||""),g(""),f(!r),S(!0))},[c,r,o]);const j=()=>{a.trim()&&(!v&&!p||m({name:a.trim(),description:l.trim()||void 0,saveToLibrary:v,saveToCurrentDashboard:p}))},b=a.trim()&&(v||p);return e.jsx(s.Dialog,{open:c,onOpenChange:i,children:e.jsxs(s.DialogContent,{className:"sm:max-w-[425px]",children:[e.jsxs(s.DialogHeader,{children:[e.jsx(s.DialogTitle,{children:"Save Visual As"}),e.jsx(s.DialogDescription,{children:r?"Create a copy of this visual with a new name":"Save this visual to make it reusable"})]}),e.jsxs("div",{className:"grid gap-4 py-4",children:[e.jsxs("div",{className:"grid gap-2",children:[e.jsx(s.Label,{htmlFor:"name",children:"Name"}),e.jsx(s.Input,{id:"name",value:a,onChange:t=>n(t.target.value),placeholder:"Enter visual name",disabled:d})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(s.Label,{htmlFor:"description",children:"Description (optional)"}),e.jsx(s.Textarea,{id:"description",value:l,onChange:t=>g(t.target.value),placeholder:"Enter visual description",rows:3,disabled:d})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsx(s.Label,{children:"Save to:"}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(s.Checkbox,{id:"save-to-dashboard",checked:p,onCheckedChange:t=>S(!!t),disabled:d}),e.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",e.jsx("span",{className:"ml-2 text-xs text-muted-foreground",children:r?"(add copy to this dashboard)":"(keep as local visual)"})]})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(s.Checkbox,{id:"save-to-library",checked:v,onCheckedChange:t=>f(!!t),disabled:d}),e.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",e.jsx("span",{className:"ml-2 text-xs text-muted-foreground",children:r?"(save as new reusable visual)":"(make available to all dashboards)"})]})]})]}),!v&&!p&&e.jsx("p",{className:"text-sm text-destructive",children:"Please select at least one destination"})]})]}),e.jsxs(s.DialogFooter,{children:[e.jsx(s.Button,{variant:"outline",onClick:()=>i(!1),disabled:d,children:"Cancel"}),e.jsxs(s.Button,{onClick:j,disabled:!b||d,children:[d&&e.jsx(s.LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin"}),d?"Saving...":"Save"]})]})]})})}function k(){const[c,i]=x.useState(!1),[r,o]=x.useState(!1),[d,m]=x.useState(null),a=s.useEditorStore(h=>h.frame),n=s.useEditorStore(h=>h.card),l=s.useSelectedVisual(),g=s.useDashboardStore(h=>h.selectedSheetId),v=s.useDashboardStore(h=>h.actions.setIsDashboardPanelOpen),{getUpdatedFrame:f}=F.useVisualUtils(),{selectVisual:p}=s.useManagementActions(),{addFrame:S,setSelectedFrameId:j,setIsVisualEditing:b}=s.useDashboardActions(),t=!!(a!=null&&a.visualId),C=(()=>{var h,D;return((h=a==null?void 0:a.cards)==null?void 0:h.length)===1&&((D=a.cards[0])!=null&&D.title)?a.cards[0].title:l!=null&&l.title?l.title:(n==null?void 0:n.title)||"Untitled Visual"})(),u=s.useCreateVisualWithFrame(h=>{if(h!=null&&h.id){if(p(h),r&&d&&g){const D={...d,id:s.v4(),visualId:h.id};S(g,D,"end"),j(D.id),o(!1),m(null),b(!1)}v(!0),i(!1)}});return{saveAsDialogOpen:c,setSaveAsDialogOpen:i,handleSaveAs:async h=>{if(!g){s.ue.error("No sheet selected");return}const D=f(),N=D.cards.length===1?{...D,cards:D.cards.map(y=>({...y,title:h.name}))}:D;if(h.saveToLibrary){o(h.saveToCurrentDashboard),m(N);const y={title:h.name,description:h.description,frameObject:N,isPrivate:!1};u.mutate(y)}else if(h.saveToCurrentDashboard){const y={...N,id:s.v4(),visualId:void 0};S(g,y,"end"),j(y.id),s.ue.success("Visual saved to dashboard"),i(!1),b(!1)}},isLibraryVisual:t,currentVisualName:C,isSaving:u.isPending}}function I({className:c}){const i=s.useEditorStore(u=>u.frame),r=s.useEditorStore(u=>u.card),o=s.useManagementStore(u=>u.selectedVisual),d=s.useDashboardStore(u=>u.selectedFrameId),m=s.useDashboardStore(u=>u.selectedSheetId),{setIsVisualEditing:a}=s.useDashboardActions(),n=!!(i!=null&&i.visualId||o!=null&&o.id),l=!!(i!=null&&i.visualId&&d),g=n&&!l,{saveAsDialogOpen:v,setSaveAsDialogOpen:f,handleSaveAs:p,isLibraryVisual:S,currentVisualName:j,isSaving:b}=k(),{handleAddLibraryVisual:t}=F.useVisualUtils(),C=async()=>{if(!m){s.ue.error("No dashboard sheet selected");return}if(!o){s.ue.error("No visual selected");return}const u=await t(o);u.success?(s.ue.success("Visual added to dashboard"),a(!1)):s.ue.error(u.error||"Failed to add visual to dashboard")};return e.jsxs(e.Fragment,{children:[!n&&e.jsx(w.EditorAcceptButton,{className:c,variant:"default"}),n&&e.jsxs(e.Fragment,{children:[l&&e.jsx(w.VisualApplyLocalButton,{className:c}),g&&m&&r&&(r.sql||s.hasValidCardConfig(r.config))&&e.jsxs(s.Button,{onClick:C,className:s.cn(c),size:"sm",variant:"outline",children:[e.jsx(A,{className:"mr-2 size-4 font-bold"}),"Add to Dashboard"]}),g&&e.jsx(w.VisualSaveButton,{className:c,variant:"default"}),l&&e.jsx(w.VisualSaveAndApplyButton,{className:c}),e.jsxs(s.DropdownMenu,{modal:!1,children:[e.jsx(s.DropdownMenuTrigger,{asChild:!0,children:e.jsx(s.Button,{variant:"outline",size:"sm",className:s.cn(c,"w-8 p-0"),children:e.jsx(s.EllipsisVertical,{className:"h-4 w-4"})})}),e.jsx(s.DropdownMenuContent,{align:"end",children:e.jsxs(s.DropdownMenuItem,{onClick:u=>{u.stopPropagation(),f(!0)},children:[e.jsx(w.Save,{className:"mr-2 h-4 w-4"}),"Save As..."]})})]})]}),!n&&e.jsxs(s.DropdownMenu,{modal:!1,children:[e.jsx(s.DropdownMenuTrigger,{asChild:!0,children:e.jsx(s.Button,{variant:"outline",size:"sm",className:s.cn(c,"w-8 p-0"),children:e.jsx(s.EllipsisVertical,{className:"h-4 w-4"})})}),e.jsx(s.DropdownMenuContent,{align:"end",children:e.jsxs(s.DropdownMenuItem,{onClick:()=>f(!0),children:[e.jsx(w.Save,{className:"mr-2 h-4 w-4"}),"Save As..."]})})]}),e.jsx(w.EditorCancelButton,{className:c}),e.jsx(P,{open:v,onOpenChange:u=>{b||f(u)},isLibraryVisual:S,currentVisualName:j,isSaving:b,onConfirm:p})]})}function E({className:c,switchClassName:i}){const r=s.useEditorStore(n=>n.isDevMode),o=s.useDashboardStore(n=>n.isVisualEditing),{setIsDevMode:d}=s.useEditorActions(),{config:m}=x.useContext(s.SemaphorContext).tokenProps,a=(m==null?void 0:m.showAdvancedMode)!==!1;return!o||!a?null:e.jsxs("div",{className:s.cn("flex items-center space-x-2",c),children:[e.jsx(s.DevModeSwitch,{className:s.cn("",i),checked:r,onCheckedChange:()=>d(!r),id:"advanced-mode",icon:e.jsx(s.CodeXml,{className:"h-4 w-4"}),tooltip:r?"Standard Mode":"Advanced Mode"}),e.jsx("label",{htmlFor:"advanced-mode",className:"sr-only",children:"Advanced Mode"})]})}function M({open:c,onOpenChange:i,onSave:r,onDiscard:o,isSaving:d}){const m=a=>{!a&&d||i(a)};return e.jsx(s.AlertDialog,{open:c,onOpenChange:m,children:e.jsxs(s.AlertDialogContent,{className:"max-w-md",children:[e.jsxs(s.AlertDialogHeader,{children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"flex h-10 w-10 items-center justify-center rounded-full bg-amber-100",children:e.jsx(s.TriangleAlert,{className:"h-5 w-5 text-amber-600"})}),e.jsx(s.AlertDialogTitle,{className:"text-xl",children:"Unsaved Changes"})]}),e.jsx(s.AlertDialogDescription,{className:"pt-2 text-base leading-relaxed",children:"You have unsaved changes to this dashboard. What would you like to do?"})]}),e.jsxs(s.AlertDialogFooter,{className:"flex-col gap-2 sm:flex-row sm:gap-2",children:[e.jsx(s.AlertDialogCancel,{disabled:d,className:"order-1 m-0 border-border/50 sm:order-1",children:"Cancel"}),e.jsx("button",{onClick:o,disabled:d,className:"order-2 rounded-md border border-destructive/20 bg-destructive/10 px-4 py-2 text-sm font-medium text-destructive transition-colors hover:bg-destructive/20 disabled:pointer-events-none disabled:opacity-50 sm:order-2",children:"Discard"}),e.jsx(s.AlertDialogAction,{onClick:r,disabled:d,className:"order-3 m-0 bg-primary text-primary-foreground hover:bg-primary/90 sm:order-3",children:d?e.jsxs(e.Fragment,{children:[e.jsx(s.LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin"}),"Saving..."]}):"Save & Close"})]})]})})}function T(c,i,r,o){x.useEffect(()=>{c&&!r&&i&&o(s.cloneDeep(i))},[c,r,i,o])}function V({triggerButtonClassName:c}){const[i,r]=x.useState(!1),o=s.useDashboardStore(n=>{var l;return(l=n.dashboard)==null?void 0:l.id}),d=s.useDashboardStore(n=>{var l;return(l=n.dashboard)==null?void 0:l.title}),m=s.useDashboardStore(n=>{var l;return(l=n.dashboard)==null?void 0:l.sheets}),a=s.useDashboardStore(n=>n.selectedSheetId);return m==null||m.find(n=>n.id===a),o?e.jsxs(e.Fragment,{children:[e.jsx(s.IconButton,{tooltip:"Schedule Dashboard",className:s.cn("h-7 p-2",c),onClick:()=>r(!0),children:e.jsx(s.Clock,{className:"size-4"})}),e.jsx(s.EmailScheduleDialog,{open:i,onOpenChange:r,dashboardId:o,dashboardName:d})]}):null}function B({open:c,onOpenChange:i}){const[r,o]=x.useState(!1),[d,m]=x.useState(!1),[a,n]=x.useState({sheetSelection:"current",protectPdf:!1,password:""}),l=s.useDashboardStore(t=>{var C;return(C=t.dashboard)==null?void 0:C.sheets}),g=s.useDashboardStore(t=>t.selectedSheetId),{authToken:v,tokenProps:f}=s.useSemaphorContext(),p=l==null?void 0:l.find(t=>t.id===g),S=((l==null?void 0:l.length)||0)>1,j=()=>{n({sheetSelection:"current",protectPdf:!1,password:""}),o(!1),i(!1)};async function b(){if(a.protectPdf&&!a.password){s.ue.error("Please enter a password to protect the PDF");return}m(!0);const t=a.sheetSelection==="all"?"Generating PDF for all sheets... This may take a while.":a.protectPdf?"Generating protected PDF... may take up to 60 seconds":"Generating PDF... may take up to 60 seconds",C=s.ue.loading(t);try{await s.downloadPdf(f.apiServiceUrl,v,a.protectPdf?a.password:void 0,a.sheetSelection),s.ue.dismiss(C);const u=a.sheetSelection==="all"?"All sheets PDF downloaded successfully!":a.protectPdf?"Protected PDF downloaded successfully!":"PDF downloaded successfully!";s.ue.success(u,{duration:2e3}),j()}catch(u){s.ue.dismiss(C),s.ue.error("Failed to download PDF",{description:"Please try again or contact support.",richColors:!0}),console.error("PDF download error:",u)}finally{m(!1)}}return e.jsx(s.Dialog,{open:c,onOpenChange:t=>{if(!t){j();return}i(!0)},children:e.jsxs(s.DialogContent,{className:"sm:max-w-[425px]",children:[e.jsxs(s.DialogHeader,{children:[e.jsx(s.DialogTitle,{children:"Export Dashboard"}),e.jsx(s.DialogDescription,{children:"Export your dashboard as a PDF document."})]}),e.jsxs("div",{className:"space-y-4 py-4",children:[S&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"space-y-3",children:[e.jsx(s.Label,{children:"Export Scope"}),e.jsxs(s.RadioGroup,{value:a.sheetSelection,onValueChange:t=>n({...a,sheetSelection:t}),children:[e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(s.RadioGroupItem,{value:"current",id:"scope-current"}),e.jsxs(s.Label,{htmlFor:"scope-current",className:"cursor-pointer font-normal",children:["This sheet (",(p==null?void 0:p.title)||"Current",")"]})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(s.RadioGroupItem,{value:"all",id:"scope-all"}),e.jsxs(s.Label,{htmlFor:"scope-all",className:"cursor-pointer font-normal",children:["All sheets (",l==null?void 0:l.length," sheets)"]})]})]})]}),e.jsx(s.Separator,{})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(s.Checkbox,{id:"protect-pdf",checked:a.protectPdf,onCheckedChange:t=>{n({...a,protectPdf:t,password:t?a.password:""}),t||o(!1)}}),e.jsxs(s.Label,{htmlFor:"protect-pdf",className:"flex cursor-pointer items-center text-sm font-normal",children:[e.jsx(s.Lock,{className:"mr-2 h-3.5 w-3.5"}),"Password protect PDF"]})]}),a.protectPdf&&e.jsxs("div",{className:"ml-6 space-y-2",children:[e.jsx(s.Label,{htmlFor:"pdf-password",className:"text-sm",children:"Password"}),e.jsxs("div",{className:"relative",children:[e.jsx(s.Input$1,{id:"pdf-password",type:r?"text":"password",value:a.password,onChange:t=>n({...a,password:t.target.value}),placeholder:"Enter password",className:"pr-10",onKeyDown:t=>{t.key==="Enter"&&a.password&&b()}}),e.jsx(s.Button,{type:"button",variant:"ghost",size:"sm",className:"absolute right-0 top-0 h-full px-3 py-2 hover:bg-transparent",onClick:()=>o(!r),children:r?e.jsx(s.EyeOff,{className:"h-4 w-4 text-muted-foreground"}):e.jsx(s.Eye,{className:"h-4 w-4 text-muted-foreground"})})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Recipients will need this password to open the PDF"})]})]})]}),e.jsxs(s.DialogFooter,{children:[e.jsx(s.Button,{variant:"outline",onClick:j,disabled:d,children:"Cancel"}),e.jsx(s.Button,{onClick:b,disabled:d,children:d?e.jsxs(e.Fragment,{children:[e.jsx(s.LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin"}),"Exporting..."]}):e.jsxs(e.Fragment,{children:[e.jsx(s.Download,{className:"mr-2 h-4 w-4"}),"Export"]})})]})]})})}exports.AdvancedModeToggle=E;exports.DashboardExportDialog=B;exports.ScheduleDashboard=V;exports.UnsavedChangesAlert=M;exports.VisualEditingControls=I;exports.usePristineSnapshotInitializer=T;