react-semaphor 0.1.208 → 0.1.209

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