react-semaphor 0.1.228 → 0.1.230

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 (32) hide show
  1. package/dist/chunks/dashboard-controls-CIGGC81u.js +47 -0
  2. package/dist/chunks/dashboard-controls-uZZf2_Ms.js +1837 -0
  3. package/dist/chunks/{dashboard-json-CIXKhNAd.js → dashboard-json-BPOoq2o2.js} +1 -1
  4. package/dist/chunks/{dashboard-json-BIuKyo5Q.js → dashboard-json-BSpSg-pF.js} +1 -1
  5. package/dist/chunks/{dashboard-summary-settings-dialog-BN1SlS2f.js → dashboard-summary-settings-dialog-BBOnX1vh.js} +1 -1
  6. package/dist/chunks/{dashboard-summary-settings-dialog-eHzsX-Qu.js → dashboard-summary-settings-dialog-Dd-wAZsI.js} +23 -23
  7. package/dist/chunks/{edit-dashboard-visual-q2sqCojJ.js → edit-dashboard-visual-CmKLavr8.js} +2115 -2091
  8. package/dist/chunks/{edit-dashboard-visual-DYgod5dM.js → edit-dashboard-visual-D0myN7lC.js} +18 -18
  9. package/dist/chunks/{editor-action-buttons-C7BPnMbF.js → editor-action-buttons-DicV0M4e.js} +1 -1
  10. package/dist/chunks/{editor-action-buttons-iNXXLdep.js → editor-action-buttons-ujerALSP.js} +42 -42
  11. package/dist/chunks/{index-DAK3Chqv.js → index-BKtY-D8Y.js} +161 -161
  12. package/dist/chunks/{index-CCPiaTlA.js → index-SLQXKi01.js} +5658 -5645
  13. package/dist/chunks/{notification-bell-C1ds6KBh.js → notification-bell-BlKABlIE.js} +1 -1
  14. package/dist/chunks/{notification-bell-jUNpjlLi.js → notification-bell-D83sUTTI.js} +60 -60
  15. package/dist/chunks/resource-management-panel-CJXZMjqO.js +920 -0
  16. package/dist/chunks/resource-management-panel-TqjX5FH0.js +6 -0
  17. package/dist/chunks/{use-visual-utils-D-Z7L3fG.js → use-visual-utils-CjUf9Xns.js} +1 -1
  18. package/dist/chunks/{use-visual-utils-CmNSBat8.js → use-visual-utils-DNfxkGiH.js} +33 -33
  19. package/dist/dashboard/index.cjs +1 -1
  20. package/dist/dashboard/index.js +1 -1
  21. package/dist/index.cjs +1 -1
  22. package/dist/index.js +44 -44
  23. package/dist/style.css +1 -1
  24. package/dist/surfboard/index.cjs +1 -1
  25. package/dist/surfboard/index.js +2 -2
  26. package/package.json +1 -1
  27. package/dist/chunks/dashboard-controls-DBYFd2CJ.js +0 -1764
  28. package/dist/chunks/dashboard-controls-nOlG4ZgU.js +0 -47
  29. package/dist/chunks/resource-management-panel-0zLiCZGO.js +0 -913
  30. package/dist/chunks/resource-management-panel-8lnUNPf1.js +0 -6
  31. package/dist/chunks/use-role-aware-display-preferences-CPLw3mxL.js +0 -1
  32. package/dist/chunks/use-role-aware-display-preferences-qy2jrDtd.js +0 -29
@@ -1,913 +0,0 @@
1
- import { jsx as e, jsxs as n, Fragment as ge } from "react/jsx-runtime";
2
- import { bS as _e, u as ie, a1 as Ge, W as le, c5 as qe, c6 as Ke, c as re, B as U, c7 as pe, c8 as We, c9 as Ye, ca as Ze, cb as $e, cc as Z, H as de, cd as Je, ce as Qe, cf as Xe, cg as ve, ch as De, ci as ke, cj as et, ck as ye, e as ce, cl as be, cm as Se, cn as tt, an as Ee, aj as Ve, co as Le, cp as Ae, cq as Oe, cr as Te, cs as Re, ct as Pe, cu as Ue, cv as je, cw as Fe, cx as st, cy as nt, ah as ae, l as at, cz as Ie, cA as it, m as rt, n as ot, o as lt, p as dt, q as ct, L as Ce, cB as fe, G as ut, cC as ht, cD as mt, cE as pt, bZ as ft, b_ as gt, b$ as Dt, c1 as xt, cF as Nt, cG as wt } from "./index-CCPiaTlA.js";
3
- import vt, { useRef as Ct, useEffect as oe, useState as N } from "react";
4
- import { a as Me } from "./use-visual-utils-CmNSBat8.js";
5
- import { u as yt } from "./use-role-aware-display-preferences-qy2jrDtd.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 bt = _e("FolderOpen", [
13
- [
14
- "path",
15
- {
16
- d: "m6 14 1.5-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.54 6a2 2 0 0 1-1.95 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2",
17
- key: "usdka0"
18
- }
19
- ]
20
- ]);
21
- function St(t, g = {}) {
22
- const { enabled: p = !0, eventType: o = "mousedown" } = g, r = Ct(null);
23
- return oe(() => {
24
- const c = (D) => {
25
- const i = D.target;
26
- r.current && r.current.contains(i) || i instanceof Element && (i.closest("[data-radix-popper-content-wrapper]") || i.closest("[data-radix-select-content]") || i.closest("[data-radix-popover-content]") || i.closest("[data-radix-dropdown-menu-content]") || i.closest("[data-radix-tooltip-content]") || i.closest('[role="listbox"]') || i.closest('[role="option"]') || i.closest('[role="combobox"]')) || i instanceof Element && i.hasAttribute("data-radix-") || t();
27
- };
28
- return p && document.addEventListener(o, c), () => {
29
- document.removeEventListener(o, c);
30
- };
31
- }, [t, p, o]), r;
32
- }
33
- function ze() {
34
- return /* @__PURE__ */ e("div", { className: "space-y-1 px-2 py-2", children: [...Array(5)].map((t, g) => /* @__PURE__ */ n(
35
- "div",
36
- {
37
- className: "flex animate-pulse items-start gap-3 rounded-md px-2 py-2",
38
- children: [
39
- /* @__PURE__ */ e("div", { className: "mt-0.5 h-4 w-4 flex-shrink-0 rounded bg-muted/60" }),
40
- /* @__PURE__ */ n("div", { className: "flex-1 space-y-1.5", children: [
41
- /* @__PURE__ */ e("div", { className: "h-4 w-3/5 rounded bg-muted/60" }),
42
- /* @__PURE__ */ e("div", { className: "h-3 w-4/5 rounded bg-muted/40" })
43
- ] })
44
- ]
45
- },
46
- g
47
- )) });
48
- }
49
- const Et = (t) => {
50
- const g = ie((r) => r.isVisualEditing), p = ie((r) => r.selectedFrameId), o = Ge((r) => r.frame);
51
- return !!(g && p && (o == null ? void 0 : o.visualId) === t);
52
- };
53
- function Vt({
54
- visual: t,
55
- isDeleting: g,
56
- isDuplicating: p,
57
- onAddVisual: o,
58
- onOpenVisual: r,
59
- onEditDetails: c,
60
- onDeleteClick: D,
61
- onDuplicateVisual: i,
62
- // onTogglePrivacy,
63
- onShareVisual: w,
64
- formatDate: y
65
- }) {
66
- var T, F, v, z;
67
- const { selectVisual: u } = le(), h = qe(t.id), d = Et(t.id), A = ie((f) => f.isVisualEditing), { isConsoleMode: O } = Ke(), x = vt.useRef(null), [V, b] = N(!1), [S, M] = N(!1);
68
- oe(() => {
69
- p ? (b(!0), M(!0)) : S && (b(!1), M(!1));
70
- }, [p, S]), oe(() => {
71
- d && x.current && x.current.scrollIntoView({
72
- behavior: "smooth",
73
- block: "center"
74
- });
75
- }, [d]);
76
- const j = () => {
77
- u(t), r == null || r(t);
78
- };
79
- return /* @__PURE__ */ e(
80
- "div",
81
- {
82
- ref: x,
83
- className: re(
84
- "group flex cursor-pointer items-start rounded-md px-2 py-2 transition-colors hover:bg-muted",
85
- d ? "bg-purple-500/10" : h && "bg-muted/80"
86
- ),
87
- onClick: j,
88
- children: /* @__PURE__ */ e("div", { className: "min-w-0 flex-1", children: /* @__PURE__ */ n("div", { className: "flex items-start justify-between gap-2", children: [
89
- /* @__PURE__ */ n("div", { className: "min-w-0 flex-1", children: [
90
- /* @__PURE__ */ e(
91
- "p",
92
- {
93
- className: "truncate text-sm font-medium text-foreground",
94
- title: t.title || "Untitled Visual",
95
- children: t.title || "Untitled Visual"
96
- }
97
- ),
98
- /* @__PURE__ */ e(
99
- "p",
100
- {
101
- className: "truncate text-xs text-muted-foreground",
102
- title: t.description || "No description",
103
- children: (T = t.description) != null && T.trim() ? t.description : "No description"
104
- }
105
- )
106
- ] }),
107
- /* @__PURE__ */ e(
108
- "div",
109
- {
110
- className: "flex flex-shrink-0 items-center gap-1",
111
- onClick: (f) => f.stopPropagation(),
112
- children: /* @__PURE__ */ n("div", { className: "inline-flex items-center overflow-hidden rounded-md border border-input", children: [
113
- /* @__PURE__ */ n(
114
- U,
115
- {
116
- size: "sm",
117
- variant: "outline",
118
- className: "h-7 gap-1 rounded-none border-0 px-2 text-xs shadow-none",
119
- disabled: A,
120
- onClick: (f) => {
121
- f.stopPropagation(), o(t);
122
- },
123
- children: [
124
- /* @__PURE__ */ e(pe, { className: "h-3.5 w-3.5" }),
125
- "Add"
126
- ]
127
- }
128
- ),
129
- /* @__PURE__ */ n(
130
- We,
131
- {
132
- modal: !1,
133
- open: V,
134
- onOpenChange: b,
135
- children: [
136
- /* @__PURE__ */ e(Ye, { asChild: !0, children: /* @__PURE__ */ e(
137
- U,
138
- {
139
- size: "sm",
140
- variant: "outline",
141
- className: "h-7 w-7 rounded-none border-0 border-l border-input p-0 shadow-none",
142
- "aria-label": "Open visual actions",
143
- children: /* @__PURE__ */ e(Ze, { className: "h-3 w-3" })
144
- }
145
- ) }),
146
- /* @__PURE__ */ n($e, { align: "end", className: "z-[51] w-40", children: [
147
- /* @__PURE__ */ n(
148
- Z,
149
- {
150
- onClick: (f) => {
151
- f.stopPropagation(), o(t);
152
- },
153
- disabled: A,
154
- children: [
155
- /* @__PURE__ */ e(pe, { className: "mr-2 h-3 w-3" }),
156
- "Add"
157
- ]
158
- }
159
- ),
160
- /* @__PURE__ */ n(
161
- Z,
162
- {
163
- onClick: (f) => {
164
- f.stopPropagation(), r == null || r(t);
165
- },
166
- children: [
167
- /* @__PURE__ */ e(bt, { className: "mr-2 h-3 w-3" }),
168
- "Open"
169
- ]
170
- }
171
- ),
172
- /* @__PURE__ */ n(
173
- Z,
174
- {
175
- onClick: (f) => {
176
- f.preventDefault(), f.stopPropagation(), i(t.id);
177
- },
178
- disabled: p,
179
- children: [
180
- p ? /* @__PURE__ */ e(de, { className: "mr-2 h-3 w-3 animate-spin" }) : /* @__PURE__ */ e(Je, { className: "mr-2 h-3 w-3" }),
181
- p ? "Duplicating..." : "Duplicate"
182
- ]
183
- }
184
- ),
185
- t.ownership.isOwner && /* @__PURE__ */ n(ge, { children: [
186
- /* @__PURE__ */ n(
187
- Z,
188
- {
189
- onClick: (f) => {
190
- f.stopPropagation(), c == null || c(t);
191
- },
192
- children: [
193
- /* @__PURE__ */ e(Qe, { className: "mr-2 h-3 w-3" }),
194
- "Edit details"
195
- ]
196
- }
197
- ),
198
- /* @__PURE__ */ n(
199
- Z,
200
- {
201
- onClick: (f) => {
202
- f.stopPropagation(), w(t);
203
- },
204
- children: [
205
- /* @__PURE__ */ e(Xe, { className: "mr-2 h-3 w-3" }),
206
- "Share"
207
- ]
208
- }
209
- ),
210
- /* @__PURE__ */ e(ve, {}),
211
- /* @__PURE__ */ n(
212
- Z,
213
- {
214
- onClick: (f) => {
215
- f.stopPropagation(), D(t);
216
- },
217
- className: "text-destructive",
218
- disabled: g,
219
- children: [
220
- /* @__PURE__ */ e(De, { className: "mr-2 h-3 w-3" }),
221
- g ? "Deleting..." : "Delete"
222
- ]
223
- }
224
- )
225
- ] }),
226
- /* @__PURE__ */ e(ve, {}),
227
- /* @__PURE__ */ n("div", { className: "space-y-1 px-2 py-2 text-xs text-slate-500 dark:text-slate-400", children: [
228
- (((F = t.ownership.createdBy) == null ? void 0 : F.type) === "tenant" || ((v = t.ownership.createdBy) == null ? void 0 : v.type) === "organization" && O) && /* @__PURE__ */ n("div", { className: "flex items-center gap-1", children: [
229
- /* @__PURE__ */ e(ke, { className: "h-3 w-3" }),
230
- /* @__PURE__ */ e("span", { children: ((z = t.ownership.createdBy) == null ? void 0 : z.name) || "Unknown" })
231
- ] }),
232
- /* @__PURE__ */ n("div", { className: "flex items-center gap-1", children: [
233
- /* @__PURE__ */ e(et, { className: "h-3 w-3" }),
234
- /* @__PURE__ */ e("span", { children: y(t.lastModified) })
235
- ] })
236
- ] })
237
- ] })
238
- ]
239
- }
240
- )
241
- ] })
242
- }
243
- )
244
- ] }) })
245
- },
246
- t.id
247
- );
248
- }
249
- function Lt({ searchQuery: t }) {
250
- const [g, p] = N(!1), [o, r] = N(
251
- null
252
- ), [c, D] = N(!1), [i, w] = N(null), [y, u] = N(null), [h, d] = N(
253
- null
254
- ), { selectVisual: A } = le(), { handleEditLibraryVisual: O, handleAddLibraryVisual: x } = Me(), {
255
- resources: V,
256
- isLoading: b,
257
- isError: S,
258
- isFetching: M,
259
- updateResource: j,
260
- deleteResource: T,
261
- duplicateResource: F,
262
- isDeleting: v,
263
- isDuplicating: z,
264
- isUpdating: f
265
- } = ye(() => {
266
- D(!1), w(null);
267
- });
268
- ce();
269
- const $ = V.filter(
270
- (a) => {
271
- var L, l;
272
- return ((L = a == null ? void 0 : a.title) == null ? void 0 : L.toLowerCase().includes(t.toLowerCase())) || ((l = a == null ? void 0 : a.description) == null ? void 0 : l.toLowerCase().includes(t.toLowerCase()));
273
- }
274
- ), q = (a) => new Date(a).toLocaleDateString("en-US", {
275
- month: "short",
276
- day: "numeric",
277
- year: "numeric"
278
- }), B = (a) => {
279
- w(a), D(!0);
280
- }, I = () => {
281
- i && T(i.id);
282
- }, {
283
- startUpdating: ue,
284
- stopUpdating: E,
285
- isUpdating: te
286
- } = be(), J = (a, L, l) => {
287
- var ne;
288
- const k = Object.fromEntries(
289
- Object.entries(L).filter(([, P]) => P !== void 0)
290
- );
291
- if (Object.keys(k).length === 0) {
292
- (ne = l == null ? void 0 : l.onSuccess) == null || ne.call(l);
293
- return;
294
- }
295
- const se = Object.keys(k), ee = se.length === 1 ? se[0] : void 0;
296
- ue(a, ee), j(
297
- {
298
- resourceId: a,
299
- data: k
300
- },
301
- {
302
- onSuccess: () => {
303
- var P;
304
- E(a, ee), (P = l == null ? void 0 : l.onSuccess) == null || P.call(l);
305
- },
306
- onError: () => {
307
- var P;
308
- E(a, ee), (P = l == null ? void 0 : l.onError) == null || P.call(l);
309
- }
310
- }
311
- );
312
- }, H = (a) => {
313
- u(a), F(a, {
314
- onSettled: () => u(null)
315
- });
316
- }, _ = (a) => {
317
- O(a);
318
- }, Q = (a) => {
319
- x(a);
320
- }, K = (a) => {
321
- const L = V.find((l) => l.id === a);
322
- L && j({
323
- resourceId: a,
324
- data: {
325
- isPrivate: !L.isPrivate
326
- }
327
- });
328
- }, X = (a) => {
329
- r(a), p(!0);
330
- }, W = (a) => {
331
- d(a);
332
- }, Y = () => {
333
- d(null);
334
- }, C = ({
335
- title: a,
336
- description: L
337
- }) => {
338
- if (!h)
339
- return;
340
- const l = {};
341
- a !== h.title && (l.title = a), (h.description || "") !== L && (l.description = L), J(h.id, l, {
342
- onSuccess: () => {
343
- d(null);
344
- }
345
- });
346
- };
347
- return b ? /* @__PURE__ */ e(ze, {}) : S ? /* @__PURE__ */ e(Se, { className: "w-full flex-1 pr-2", children: /* @__PURE__ */ n("div", { className: "py-8 text-center text-muted-foreground", children: [
348
- /* @__PURE__ */ e("p", { className: "text-sm text-destructive", children: "Failed to load visuals" }),
349
- /* @__PURE__ */ e(
350
- U,
351
- {
352
- variant: "outline",
353
- size: "sm",
354
- className: "mt-2",
355
- onClick: () => window.location.reload(),
356
- children: "Retry"
357
- }
358
- )
359
- ] }) }) : /* @__PURE__ */ n("div", { className: "flex h-full flex-1 flex-col", children: [
360
- /* @__PURE__ */ e("div", { className: "flex flex-1 basis-0 flex-col gap-3 overflow-y-auto", children: $.length === 0 ? /* @__PURE__ */ n("div", { className: "py-8 text-center", children: [
361
- /* @__PURE__ */ e("div", { className: "mb-3", children: /* @__PURE__ */ e(tt, { className: "mx-auto h-12 w-12 text-muted-foreground/50" }) }),
362
- /* @__PURE__ */ e("h3", { className: "mb-1 font-medium text-foreground", children: t ? "No visuals found" : "No visuals yet" }),
363
- /* @__PURE__ */ e("p", { className: "text-sm text-muted-foreground", children: t ? "Try adjusting your search" : 'Click "New" above to add your first visual' })
364
- ] }) : $.map((a) => /* @__PURE__ */ e(
365
- Vt,
366
- {
367
- visual: a,
368
- onAddVisual: Q,
369
- onOpenVisual: _,
370
- onEditDetails: W,
371
- onDeleteClick: B,
372
- onDuplicateVisual: H,
373
- onTogglePrivacy: K,
374
- onShareVisual: X,
375
- isDeleting: v,
376
- isDuplicating: y === a.id,
377
- formatDate: q
378
- },
379
- a.id
380
- )) }),
381
- g && o && /* @__PURE__ */ e(
382
- Ee,
383
- {
384
- resource: o,
385
- resourceType: Ve.VISUAL,
386
- onClose: () => {
387
- p(!1), r(null);
388
- }
389
- }
390
- ),
391
- h && /* @__PURE__ */ e(
392
- Le,
393
- {
394
- open: !!h,
395
- resourceLabel: "Visual",
396
- initialTitle: h.title || "",
397
- initialDescription: h.description || "",
398
- onClose: Y,
399
- onSave: C,
400
- isSaving: te(h.id)
401
- }
402
- ),
403
- /* @__PURE__ */ e(
404
- Ae,
405
- {
406
- open: c,
407
- onOpenChange: (a) => {
408
- !a && v || (D(a), a || w(null));
409
- },
410
- children: /* @__PURE__ */ n(Oe, { children: [
411
- /* @__PURE__ */ n(Te, { children: [
412
- /* @__PURE__ */ e(Re, { children: "Delete Visual" }),
413
- /* @__PURE__ */ n(Pe, { children: [
414
- 'Are you sure you want to delete "',
415
- i == null ? void 0 : i.title,
416
- '"? This action cannot be undone.'
417
- ] })
418
- ] }),
419
- /* @__PURE__ */ n(Ue, { children: [
420
- /* @__PURE__ */ e(je, { disabled: v, children: "Cancel" }),
421
- /* @__PURE__ */ n(
422
- Fe,
423
- {
424
- onClick: (a) => {
425
- a.preventDefault(), a.stopPropagation(), I();
426
- },
427
- className: "bg-destructive text-destructive-foreground hover:bg-destructive/90",
428
- disabled: v,
429
- children: [
430
- v ? /* @__PURE__ */ e(de, { className: "mr-2 h-3.5 w-3.5 animate-spin" }) : /* @__PURE__ */ e(De, { className: "mr-2 h-3.5 w-3.5" }),
431
- v ? "Deleting..." : "Delete"
432
- ]
433
- }
434
- )
435
- ] })
436
- ] })
437
- }
438
- )
439
- ] });
440
- }
441
- function At({
442
- dashboard: t,
443
- isDeleting: g,
444
- isDuplicating: p,
445
- onLoadDashboard: o,
446
- onEditDetails: r,
447
- onDeleteClick: c,
448
- onDuplicateDashboard: D,
449
- onShareDashboard: i,
450
- formatDate: w,
451
- onDashboardItemClick: y
452
- }) {
453
- var b, S;
454
- const { selectDashboard: u } = le(), h = st(t.id), { userContext: d, isLoading: A } = ce(), O = ((b = d == null ? void 0 : d.permissions) == null ? void 0 : b.canEdit) ?? !1, x = A || !O, V = () => {
455
- u(t), o(t.id), y == null || y(t.id);
456
- };
457
- return /* @__PURE__ */ e(
458
- "div",
459
- {
460
- className: re(
461
- "group flex cursor-pointer items-start rounded-md px-2 py-2 transition-colors hover:bg-muted",
462
- h && "bg-muted/80"
463
- ),
464
- onClick: V,
465
- children: /* @__PURE__ */ e("div", { className: "min-w-0 flex-1", children: /* @__PURE__ */ n("div", { className: "flex items-start justify-between gap-2", children: [
466
- /* @__PURE__ */ n("div", { className: "min-w-0 flex-1", children: [
467
- /* @__PURE__ */ e(
468
- "p",
469
- {
470
- className: "truncate text-sm font-medium text-foreground",
471
- title: t.title || "Untitled Dashboard",
472
- children: t.title || "Untitled Dashboard"
473
- }
474
- ),
475
- /* @__PURE__ */ e(
476
- "p",
477
- {
478
- className: "truncate text-xs text-muted-foreground",
479
- title: t.description || "No description",
480
- children: (S = t.description) != null && S.trim() ? t.description : "No description"
481
- }
482
- )
483
- ] }),
484
- /* @__PURE__ */ e("div", { className: "flex-shrink-0 opacity-0 transition-opacity group-hover:opacity-100", children: /* @__PURE__ */ e(
485
- nt,
486
- {
487
- dashboard: t,
488
- isDeleting: g,
489
- isDuplicating: p,
490
- shouldHideActions: x,
491
- onEditDetails: r,
492
- onDeleteClick: c,
493
- onDuplicateDashboard: D,
494
- onShareDashboard: i,
495
- formatDate: w
496
- }
497
- ) })
498
- ] }) })
499
- },
500
- t.id
501
- );
502
- }
503
- function Ot({ onRetry: t }) {
504
- return /* @__PURE__ */ e(Se, { className: "w-full flex-1 pr-2", children: /* @__PURE__ */ n("div", { className: "py-8 text-center text-muted-foreground", children: [
505
- /* @__PURE__ */ e("p", { className: "text-sm text-destructive", children: "Failed to load dashboards" }),
506
- /* @__PURE__ */ e(U, { variant: "outline", size: "sm", className: "mt-2", onClick: t, children: "Retry" })
507
- ] }) });
508
- }
509
- function Tt(t) {
510
- var xe;
511
- const { searchQuery: g, onLoadDashboard: p, onEditDashboard: o, onDashboardItemClick: r } = t, [c, D] = N(!1), [i, w] = N(
512
- null
513
- ), [y, u] = N(!1), [h, d] = N(null), [A, O] = N(null), [x, V] = N(null), b = ae(
514
- (s) => s.lastSelectedDashboard
515
- ), S = ae(
516
- (s) => s.selectedDashboard
517
- ), M = ae(
518
- (s) => s.actions.selectDashboard
519
- ), j = ae(
520
- (s) => s.actions.clearSelectedDashboard
521
- ), { tokenProps: T, id: F } = at();
522
- yt();
523
- const {
524
- resources: v,
525
- isLoading: z,
526
- isError: f,
527
- isFetching: $,
528
- updateResource: q,
529
- deleteResource: B,
530
- duplicateResource: I,
531
- isUpdating: ue,
532
- isDeleting: E,
533
- isDuplicating: te,
534
- refetch: J
535
- } = Ie(() => {
536
- u(!1);
537
- const s = h == null ? void 0 : h.id;
538
- d(null), (S == null ? void 0 : S.id) === s && (!(T != null && T.dashboard_id) && !F ? j() : b && b.id !== s && M(b));
539
- }), { currentUser: H, userContext: _ } = ce(), Q = ((xe = _ == null ? void 0 : _.permissions) == null ? void 0 : xe.canCreateDashboard) ?? !1, K = v.filter(
540
- (s) => {
541
- var R, m;
542
- return ((R = s == null ? void 0 : s.title) == null ? void 0 : R.toLowerCase().includes(g.toLowerCase())) || ((m = s == null ? void 0 : s.description) == null ? void 0 : m.toLowerCase().includes(g.toLowerCase()));
543
- }
544
- ), X = (s) => new Date(s).toLocaleDateString("en-US", {
545
- month: "short",
546
- day: "numeric",
547
- year: "numeric"
548
- }), W = (s) => {
549
- p == null || p(s);
550
- }, Y = (s) => {
551
- d(s), u(!0);
552
- }, C = () => {
553
- h && B(h.id);
554
- }, a = (s) => {
555
- O(s), I(s, {
556
- onSettled: () => O(null)
557
- });
558
- }, {
559
- startUpdating: L,
560
- stopUpdating: l,
561
- isUpdating: k
562
- } = be(), se = (s, R, m) => {
563
- var we;
564
- const he = Object.fromEntries(
565
- Object.entries(R).filter(([, G]) => G !== void 0)
566
- );
567
- if (Object.keys(he).length === 0) {
568
- (we = m == null ? void 0 : m.onSuccess) == null || we.call(m);
569
- return;
570
- }
571
- const Ne = Object.keys(he), me = Ne.length === 1 ? Ne[0] : void 0;
572
- L(s, me), q(
573
- {
574
- resourceId: s,
575
- data: he
576
- },
577
- {
578
- onSuccess: () => {
579
- var G;
580
- l(s, me), (G = m == null ? void 0 : m.onSuccess) == null || G.call(m);
581
- },
582
- onError: () => {
583
- var G;
584
- l(s, me), (G = m == null ? void 0 : m.onError) == null || G.call(m);
585
- }
586
- }
587
- );
588
- }, ee = (s) => {
589
- const R = v.find(
590
- (m) => m.id === s
591
- );
592
- R && q({
593
- resourceId: s,
594
- data: {
595
- isPrivate: !R.isPrivate
596
- }
597
- });
598
- }, ne = (s) => {
599
- w(s), H == null || H.type, D(!0);
600
- }, P = (s) => {
601
- o == null || o(s.id), V(s);
602
- }, Be = () => {
603
- V(null);
604
- }, He = ({
605
- title: s,
606
- description: R
607
- }) => {
608
- if (!x)
609
- return;
610
- const m = {};
611
- s !== x.title && (m.title = s), (x.description || "") !== R && (m.description = R), se(x.id, m, {
612
- onSuccess: () => {
613
- V(null);
614
- }
615
- });
616
- };
617
- return z ? /* @__PURE__ */ e(ze, {}) : f ? /* @__PURE__ */ e(Ot, { onRetry: () => window.location.reload() }) : /* @__PURE__ */ n("div", { className: "flex h-full flex-1 flex-col", children: [
618
- /* @__PURE__ */ e("div", { className: "flex flex-1 basis-0 flex-col gap-3 overflow-y-auto", children: K.length === 0 ? /* @__PURE__ */ n("div", { className: "py-8 text-center", children: [
619
- /* @__PURE__ */ e("div", { className: "mb-3", children: /* @__PURE__ */ e(it, { className: "mx-auto h-12 w-12 text-muted-foreground/50" }) }),
620
- /* @__PURE__ */ e("h3", { className: "mb-1 font-medium text-foreground", children: g ? "No dashboards found" : "No dashboards yet" }),
621
- /* @__PURE__ */ e("p", { className: "text-sm text-muted-foreground", children: g ? "Try adjusting your search" : Q ? 'Click "New" above to add your first dashboard' : "No dashboards have been shared with you yet" })
622
- ] }) : K.map((s) => /* @__PURE__ */ e(
623
- At,
624
- {
625
- dashboard: s,
626
- isDeleting: E,
627
- isDuplicating: A === s.id,
628
- onLoadDashboard: W,
629
- onEditDetails: P,
630
- onDeleteClick: Y,
631
- onDuplicateDashboard: a,
632
- onTogglePrivacy: ee,
633
- onShareDashboard: ne,
634
- formatDate: X,
635
- onDashboardItemClick: r
636
- },
637
- s.id
638
- )) }),
639
- c && i && /* @__PURE__ */ e(
640
- Ee,
641
- {
642
- resource: i,
643
- resourceType: Ve.DASHBOARD,
644
- onClose: () => {
645
- D(!1), w(null);
646
- }
647
- }
648
- ),
649
- /* @__PURE__ */ e(
650
- Ae,
651
- {
652
- open: y,
653
- onOpenChange: (s) => {
654
- !s && E || (u(s), s || d(null));
655
- },
656
- children: /* @__PURE__ */ n(Oe, { children: [
657
- /* @__PURE__ */ n(Te, { children: [
658
- /* @__PURE__ */ e(Re, { children: "Delete Dashboard" }),
659
- /* @__PURE__ */ n(Pe, { children: [
660
- 'Are you sure you want to delete "',
661
- h == null ? void 0 : h.title,
662
- '"? This action cannot be undone.'
663
- ] })
664
- ] }),
665
- /* @__PURE__ */ n(Ue, { children: [
666
- /* @__PURE__ */ e(je, { disabled: E, children: "Cancel" }),
667
- /* @__PURE__ */ n(
668
- Fe,
669
- {
670
- onClick: (s) => {
671
- s.preventDefault(), s.stopPropagation(), C();
672
- },
673
- className: "bg-destructive text-destructive-foreground hover:bg-destructive/90",
674
- disabled: E,
675
- children: [
676
- E ? /* @__PURE__ */ e(de, { className: "mr-2 h-3.5 w-3.5 animate-spin" }) : /* @__PURE__ */ e(De, { className: "mr-2 h-3.5 w-3.5" }),
677
- E ? "Deleting..." : "Delete"
678
- ]
679
- }
680
- )
681
- ] })
682
- ] })
683
- }
684
- ),
685
- x && /* @__PURE__ */ e(
686
- Le,
687
- {
688
- open: !!x,
689
- resourceLabel: "Dashboard",
690
- initialTitle: x.title || "",
691
- initialDescription: x.description || "",
692
- onClose: Be,
693
- onSave: He,
694
- isSaving: k(x.id)
695
- }
696
- )
697
- ] });
698
- }
699
- function Rt({
700
- open: t,
701
- onOpenChange: g,
702
- onSubmit: p,
703
- isCreating: o
704
- }) {
705
- const [r, c] = N(""), [D, i] = N("");
706
- oe(() => {
707
- t || (c(""), i(""));
708
- }, [t]);
709
- const w = () => {
710
- r.trim() && p({ title: r, description: D });
711
- }, y = (u) => {
712
- g(u);
713
- };
714
- return /* @__PURE__ */ e(rt, { open: t, onOpenChange: y, children: /* @__PURE__ */ n(ot, { children: [
715
- /* @__PURE__ */ n(lt, { children: [
716
- /* @__PURE__ */ e(dt, { children: "Create New Visual" }),
717
- /* @__PURE__ */ e(ct, { children: "Add a new visual to your library. You can configure it after creation." })
718
- ] }),
719
- /* @__PURE__ */ n("div", { className: "space-y-4 py-4", children: [
720
- /* @__PURE__ */ n("div", { className: "space-y-2", children: [
721
- /* @__PURE__ */ e(Ce, { htmlFor: "title", children: "Visual Title" }),
722
- /* @__PURE__ */ e(
723
- fe,
724
- {
725
- id: "title",
726
- placeholder: "Enter visual title...",
727
- value: r,
728
- onChange: (u) => c(u.target.value),
729
- disabled: o,
730
- onKeyDown: (u) => {
731
- u.key === "Enter" && !u.shiftKey && (u.preventDefault(), w());
732
- }
733
- }
734
- )
735
- ] }),
736
- /* @__PURE__ */ n("div", { className: "space-y-2", children: [
737
- /* @__PURE__ */ e(Ce, { htmlFor: "description", children: "Description (optional)" }),
738
- /* @__PURE__ */ e(
739
- fe,
740
- {
741
- id: "description",
742
- placeholder: "Enter visual description...",
743
- value: D,
744
- onChange: (u) => i(u.target.value),
745
- disabled: o
746
- }
747
- )
748
- ] })
749
- ] }),
750
- /* @__PURE__ */ n(ut, { children: [
751
- /* @__PURE__ */ e(
752
- U,
753
- {
754
- variant: "outline",
755
- onClick: () => y(!1),
756
- disabled: o,
757
- children: "Cancel"
758
- }
759
- ),
760
- /* @__PURE__ */ e(
761
- U,
762
- {
763
- onClick: w,
764
- disabled: !r.trim() || o,
765
- children: o ? /* @__PURE__ */ n(ge, { children: [
766
- /* @__PURE__ */ e(de, { className: "mr-2 h-4 w-4 animate-spin" }),
767
- "Creating..."
768
- ] }) : "Create Visual"
769
- }
770
- )
771
- ] })
772
- ] }) });
773
- }
774
- function Mt({
775
- isOpen: t,
776
- onClose: g,
777
- className: p,
778
- onDashboardItemClick: o,
779
- variant: r = "inline"
780
- }) {
781
- var W, Y;
782
- const c = ie(
783
- (C) => C.isDashboardEditing
784
- ), [D, i] = N(!1), [w, y] = N(""), [u, h] = N(!1), { currentUser: d, userContext: A } = ce(), O = ((W = A == null ? void 0 : A.permissions) == null ? void 0 : W.canCreateDashboard) ?? !1, { onCreateSuccess: x } = ht({
785
- onDashboardSelect: o
786
- }), { selectVisual: V } = le(), { handleEditLibraryVisual: b } = Me(), {
787
- createResource: S,
788
- isCreating: M,
789
- refetch: j
790
- } = Ie(), { createResource: T, isCreating: F } = ye(
791
- void 0,
792
- // onDeleteSuccess (not needed here)
793
- (C) => {
794
- i(!1), C && (V(C), b(C));
795
- }
796
- ), v = r === "overlay", z = c ? "New Visual" : "New", f = c ? "New Visual" : "New Dashboard", $ = c ? "Search visuals..." : "Search dashboards...", q = c ? "Collapse visuals panel" : "Collapse dashboard panel", B = ((d == null ? void 0 : d.name) ?? "").trim(), I = ((d == null ? void 0 : d.email) ?? "").trim(), E = B && B.toLowerCase() !== "undefined" ? B : I || "Current user", te = ((Y = E.charAt(0)) == null ? void 0 : Y.toUpperCase()) || "?", J = I && I.toLowerCase() !== "undefined" ? I : "", H = St(g, {
797
- enabled: t && v
798
- }), _ = re(
799
- "flex h-full flex-col border-r bg-background",
800
- v ? re(
801
- "absolute inset-y-0 left-0 z-[51] w-60 shadow-lg transition-transform duration-300 ease-in-out",
802
- t ? "translate-x-0" : "pointer-events-none -translate-x-full"
803
- ) : "w-full max-w-[17rem] min-w-[11rem] overflow-hidden shadow-sm",
804
- p
805
- ), Q = (C) => {
806
- }, K = (C) => {
807
- console.log("Editing dashboard:", C);
808
- }, X = (C) => {
809
- S(C, {
810
- onSuccess: (a) => {
811
- i(!1), x(a, j);
812
- }
813
- });
814
- };
815
- return /* @__PURE__ */ e(ge, { children: (!v || t) && /* @__PURE__ */ n("div", { ref: H, className: _, children: [
816
- /* @__PURE__ */ n("div", { className: "border-b border-border", children: [
817
- /* @__PURE__ */ n("div", { className: "flex items-center justify-between px-4 py-1.5", children: [
818
- /* @__PURE__ */ e("div", { className: "flex items-center gap-2", children: /* @__PURE__ */ e("h2", { className: "whitespace-nowrap text-sm font-semibold", children: c ? "Visuals" : "Dashboards" }) }),
819
- /* @__PURE__ */ n("div", { className: "flex items-center gap-1", children: [
820
- /* @__PURE__ */ e(
821
- U,
822
- {
823
- size: "sm",
824
- variant: "ghost",
825
- onClick: () => h(!u),
826
- className: "h-8 w-8 p-0",
827
- "aria-label": u ? "Hide search" : "Show search",
828
- children: /* @__PURE__ */ e(mt, { className: "h-3.5 w-3.5" })
829
- }
830
- ),
831
- (c || O) && /* @__PURE__ */ n(
832
- U,
833
- {
834
- size: "sm",
835
- variant: "ghost",
836
- className: "h-8 gap-1.5 whitespace-nowrap px-2 text-xs",
837
- onClick: () => i(!0),
838
- "aria-label": f,
839
- children: [
840
- /* @__PURE__ */ e(pe, { className: "h-3.5 w-3.5" }),
841
- z
842
- ]
843
- }
844
- ),
845
- /* @__PURE__ */ e(
846
- U,
847
- {
848
- size: "sm",
849
- variant: "secondary",
850
- className: "h-7 w-7 p-0.5",
851
- onClick: g,
852
- "aria-label": q,
853
- children: /* @__PURE__ */ e(pt, { className: "h-3.5 w-3.5" })
854
- }
855
- )
856
- ] })
857
- ] }),
858
- u && /* @__PURE__ */ e("div", { className: "bg-muted/30 px-4 pb-3", children: /* @__PURE__ */ e(
859
- fe,
860
- {
861
- placeholder: $,
862
- value: w,
863
- onChange: (C) => y(C.target.value),
864
- className: "h-8 border-muted-foreground/20 bg-background text-sm focus-visible:border-muted-foreground/40 focus-visible:ring-0 focus-visible:ring-offset-0",
865
- autoFocus: !0
866
- }
867
- ) })
868
- ] }),
869
- /* @__PURE__ */ e("div", { className: "flex flex-1 flex-col overflow-auto px-2 py-2", children: c ? /* @__PURE__ */ e(Lt, { searchQuery: w }) : /* @__PURE__ */ e(
870
- Tt,
871
- {
872
- searchQuery: w,
873
- onLoadDashboard: Q,
874
- onEditDashboard: K,
875
- onDashboardItemClick: o
876
- }
877
- ) }),
878
- d && /* @__PURE__ */ e(ft, { children: /* @__PURE__ */ e("div", { className: "border-t border-border px-4 py-2", children: /* @__PURE__ */ n("div", { className: "flex items-center gap-2", children: [
879
- /* @__PURE__ */ n(gt, { children: [
880
- /* @__PURE__ */ e(Dt, { asChild: !0, children: /* @__PURE__ */ e("div", { className: "flex h-6 w-6 cursor-default items-center justify-center rounded-full bg-primary/10", children: /* @__PURE__ */ e("span", { className: "text-xs font-medium text-primary", children: te }) }) }),
881
- /* @__PURE__ */ e(xt, { side: "top", className: "max-w-xs", children: /* @__PURE__ */ n("div", { className: "space-y-1", children: [
882
- /* @__PURE__ */ e("div", { className: "font-medium", children: E }),
883
- J && /* @__PURE__ */ e("div", { className: "text-xs text-muted-foreground", children: J }),
884
- d.role && /* @__PURE__ */ n("div", { className: "text-xs text-muted-foreground", children: [
885
- "Role: ",
886
- Nt(d.role.replace(/_/g, " "))
887
- ] })
888
- ] }) })
889
- ] }),
890
- /* @__PURE__ */ e("span", { className: "truncate text-xs text-muted-foreground", children: E })
891
- ] }) }) }),
892
- c ? /* @__PURE__ */ e(
893
- Rt,
894
- {
895
- open: D,
896
- onOpenChange: i,
897
- onSubmit: T,
898
- isCreating: F
899
- }
900
- ) : /* @__PURE__ */ e(
901
- wt,
902
- {
903
- open: D,
904
- onOpenChange: i,
905
- onSubmit: X,
906
- isCreating: M
907
- }
908
- )
909
- ] }) });
910
- }
911
- export {
912
- Mt as ResourceManagementPanel
913
- };