react-semaphor 0.1.291 → 0.1.292
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chunks/braces-0bzwctGp.js +23 -0
- package/dist/chunks/braces-hczcJsV8.js +6 -0
- package/dist/chunks/dashboard-controls-Db0F38eK.js +47 -0
- package/dist/chunks/dashboard-controls-DeUHM4uL.js +1970 -0
- package/dist/chunks/{dashboard-filter-controls-button-C4AMu723.js → dashboard-filter-controls-button-DDqEus_E.js} +54 -52
- package/dist/chunks/dashboard-filter-controls-button-DSQHVjjX.js +11 -0
- package/dist/chunks/{dashboard-json-C13EJaTK.js → dashboard-json-BDyKcoGT.js} +1 -1
- package/dist/chunks/{dashboard-json-BKs1UTLL.js → dashboard-json-COXiPm3N.js} +6 -6
- package/dist/chunks/{dashboard-summary-settings-dialog-fL9l0wUO.js → dashboard-summary-settings-dialog-CryMC_4x.js} +1 -1
- package/dist/chunks/{dashboard-summary-settings-dialog-T6aUgPAf.js → dashboard-summary-settings-dialog-DbcWMZsr.js} +1 -1
- package/dist/chunks/{edit-dashboard-visual-CKB34ird.js → edit-dashboard-visual-BqfzqW4i.js} +4 -9
- package/dist/chunks/{edit-dashboard-visual-CnVx0Xi7.js → edit-dashboard-visual-DLyimx6x.js} +11 -29
- package/dist/chunks/{index-Cr9Smn6Q.js → index-72yod5pb.js} +523 -516
- package/dist/chunks/{index-Cwg2SRSi.js → index-BQ6qu8FI.js} +93 -93
- package/dist/chunks/resource-management-panel-CSLGSJjC.js +6 -0
- package/dist/chunks/{resource-management-panel-DJgYduN9.js → resource-management-panel-DwPION_M.js} +22 -22
- package/dist/chunks/{use-create-flow-overlay-state-NGb4c5Ye.js → use-create-flow-overlay-state-UruHbtfS.js} +53 -53
- package/dist/chunks/{use-create-flow-overlay-state-DnI1SSKD.js → use-create-flow-overlay-state-zz9TYhdC.js} +1 -1
- package/dist/chunks/{use-visual-utils-ivCDI1cO.js → use-visual-utils-Bm-ZnkON.js} +1 -1
- package/dist/chunks/{use-visual-utils-BbxYtbzK.js → use-visual-utils-DPBqTRUC.js} +11 -11
- package/dist/dashboard/index.cjs +1 -1
- package/dist/dashboard/index.js +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.js +21 -21
- package/dist/style.css +1 -1
- package/dist/surfboard/index.cjs +1 -1
- package/dist/surfboard/index.js +2 -2
- package/package.json +1 -1
- package/dist/chunks/dashboard-controls-BSbG43wo.js +0 -42
- package/dist/chunks/dashboard-controls-LtQ98rvL.js +0 -1938
- package/dist/chunks/dashboard-filter-controls-button-CgoIPOZZ.js +0 -11
- package/dist/chunks/resource-management-panel-Dv18tosO.js +0 -6
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import ge, { useState as L, useRef as O, useCallback as M, useEffect as
|
|
2
|
-
import {
|
|
1
|
+
import ge, { useState as L, useRef as O, useCallback as M, useEffect as T, useContext as be } from "react";
|
|
2
|
+
import { c as ee, d as _, aD as k, bK as $, bG as te, bH as H, aE as ae, bF as xe, e as se, f as re, g as oe, h as ne, i as ie, L as K, I as Ce, d8 as we, w as ye, B as S, x as j, V as R, K as Ne, u as z, M as De, O as X, d9 as Ae, da as W, y as P, b_ as le, ag as Se, cC as de, cD as ce, a7 as ue, cF as he, cG as U, t as Ee, cK as Ie, ct as Le, N as Te, db as Fe, b as V, dc as G, dd as ke, cS as Ue, cT as Ve, cU as Me, cV as Pe, cW as ze, cX as Be, cY as Oe, at as Re, bM as _e, X as $e, de as He, df as je, cz as Xe, bI as q, a9 as Ge, aG as Ke, P as me, k as pe, dg as We, m as fe, dh as qe, di as Qe, dj as Ye, dk as Ze, dl as Je, dm as Q, dn as et } from "./index-72yod5pb.js";
|
|
3
3
|
import { jsx as t, jsxs as s, Fragment as B } from "react/jsx-runtime";
|
|
4
|
-
import { V as tt, E as at, a as st, b as rt, L as ot, c as nt, d as it, C as lt, u as dt, e as ct } from "./use-create-flow-overlay-state-
|
|
5
|
-
import { u as ve } from "./use-visual-utils-
|
|
6
|
-
import { k as
|
|
4
|
+
import { V as tt, E as at, a as st, b as rt, L as ot, c as nt, d as it, C as lt, u as dt, e as ct } from "./use-create-flow-overlay-state-UruHbtfS.js";
|
|
5
|
+
import { u as ve } from "./use-visual-utils-DPBqTRUC.js";
|
|
6
|
+
import { k as Y } from "./date-formatter-vkCj9Ct-.js";
|
|
7
7
|
/**
|
|
8
8
|
* @license lucide-react v0.453.0 - ISC
|
|
9
9
|
*
|
|
10
10
|
* This source code is licensed under the ISC license.
|
|
11
11
|
* See the LICENSE file in the root directory of this source tree.
|
|
12
12
|
*/
|
|
13
|
-
const
|
|
13
|
+
const Z = ee("FileDown", [
|
|
14
14
|
["path", { d: "M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z", key: "1rqfz7" }],
|
|
15
15
|
["path", { d: "M14 2v4a2 2 0 0 0 2 2h4", key: "tnqrlb" }],
|
|
16
16
|
["path", { d: "M12 18v-6", key: "17g6i2" }],
|
|
@@ -26,12 +26,12 @@ const ut = ee("FilterX", [
|
|
|
26
26
|
["path", { d: "M13.013 3H2l8 9.46V19l4 2v-8.54l.9-1.055", key: "1fi1da" }],
|
|
27
27
|
["path", { d: "m22 3-5 5", key: "12jva0" }],
|
|
28
28
|
["path", { d: "m17 3 5 5", key: "k36vhe" }]
|
|
29
|
-
]), ht = 1e4, mt = 15e3, pt = 3e4, ft = 3e4, vt = 12e4,
|
|
29
|
+
]), ht = 1e4, mt = 15e3, pt = 3e4, ft = 3e4, vt = 12e4, J = 2 * 60 * 60 * 1e3;
|
|
30
30
|
function gt(e) {
|
|
31
31
|
const a = Date.now() - e.getTime();
|
|
32
32
|
return a < ft ? ht : a < vt ? mt : pt;
|
|
33
33
|
}
|
|
34
|
-
function
|
|
34
|
+
function Tt() {
|
|
35
35
|
const { authToken: e, tokenProps: a } = _(), p = k((m) => m.activeExports), [d, l] = L(
|
|
36
36
|
typeof document < "u" ? !document.hidden : !0
|
|
37
37
|
), h = O(null), o = O(!1), c = O(void 0), u = a == null ? void 0 : a.apiServiceUrl, n = e == null ? void 0 : e.accessToken, v = M(() => {
|
|
@@ -40,7 +40,7 @@ function Ft() {
|
|
|
40
40
|
(x) => $(x.status)
|
|
41
41
|
);
|
|
42
42
|
}, []);
|
|
43
|
-
|
|
43
|
+
T(() => {
|
|
44
44
|
if (typeof document > "u") return;
|
|
45
45
|
const m = () => {
|
|
46
46
|
l(!document.hidden);
|
|
@@ -60,7 +60,7 @@ function Ft() {
|
|
|
60
60
|
return;
|
|
61
61
|
}
|
|
62
62
|
const x = Date.now(), N = m.filter(
|
|
63
|
-
(r) => x - r.startedAt.getTime() >
|
|
63
|
+
(r) => x - r.startedAt.getTime() > J
|
|
64
64
|
);
|
|
65
65
|
if (N.length > 0) {
|
|
66
66
|
const { updateExport: r } = k.getState().actions;
|
|
@@ -72,7 +72,7 @@ function Ft() {
|
|
|
72
72
|
});
|
|
73
73
|
}
|
|
74
74
|
const f = m.filter(
|
|
75
|
-
(r) => x - r.startedAt.getTime() <=
|
|
75
|
+
(r) => x - r.startedAt.getTime() <= J
|
|
76
76
|
);
|
|
77
77
|
if (f.length === 0) {
|
|
78
78
|
o.current = !1;
|
|
@@ -85,7 +85,7 @@ function Ft() {
|
|
|
85
85
|
let g;
|
|
86
86
|
if (i.status === "completed")
|
|
87
87
|
try {
|
|
88
|
-
g = await
|
|
88
|
+
g = await H(u, n, r.id);
|
|
89
89
|
} catch (I) {
|
|
90
90
|
console.error(
|
|
91
91
|
`[useExportPolling] Failed to get download URL for ${r.id}:`,
|
|
@@ -126,18 +126,18 @@ function Ft() {
|
|
|
126
126
|
} else
|
|
127
127
|
o.current = !1;
|
|
128
128
|
}, [u, n, v]);
|
|
129
|
-
return
|
|
129
|
+
return T(() => {
|
|
130
130
|
c.current = b;
|
|
131
|
-
}, [b]),
|
|
131
|
+
}, [b]), T(() => {
|
|
132
132
|
var x;
|
|
133
133
|
v().length > 0 && d && !o.current && (o.current = !0, (x = c.current) == null || x.call(c));
|
|
134
|
-
}, [p, d, v]),
|
|
134
|
+
}, [p, d, v]), T(() => {
|
|
135
135
|
var x;
|
|
136
136
|
const m = v();
|
|
137
137
|
d && m.length > 0 && !o.current && (o.current = !0, (x = c.current) == null || x.call(c));
|
|
138
|
-
}, [d, v]),
|
|
138
|
+
}, [d, v]), T(() => {
|
|
139
139
|
!d && h.current && (clearTimeout(h.current), h.current = null, o.current = !1);
|
|
140
|
-
}, [d]),
|
|
140
|
+
}, [d]), T(() => () => {
|
|
141
141
|
h.current && (clearTimeout(h.current), h.current = null);
|
|
142
142
|
}, []), {
|
|
143
143
|
isPolling: o.current,
|
|
@@ -145,9 +145,9 @@ function Ft() {
|
|
|
145
145
|
inProgressCount: v().length
|
|
146
146
|
};
|
|
147
147
|
}
|
|
148
|
-
function
|
|
148
|
+
function Ft() {
|
|
149
149
|
const { authToken: e, tokenProps: a } = _(), p = k((c) => c.activeExports), { addExport: d } = ae(), l = O(!1), h = a == null ? void 0 : a.apiServiceUrl, o = e == null ? void 0 : e.accessToken;
|
|
150
|
-
|
|
150
|
+
T(() => {
|
|
151
151
|
if (l.current || !h || !o) return;
|
|
152
152
|
(async () => {
|
|
153
153
|
try {
|
|
@@ -162,7 +162,7 @@ function Tt() {
|
|
|
162
162
|
let b;
|
|
163
163
|
if (n.status === "completed")
|
|
164
164
|
try {
|
|
165
|
-
b = await
|
|
165
|
+
b = await H(h, o, n.id);
|
|
166
166
|
} catch (x) {
|
|
167
167
|
console.error(
|
|
168
168
|
`[useExportRecovery] Failed to get download URL for ${n.id}:`,
|
|
@@ -297,7 +297,7 @@ function xt({
|
|
|
297
297
|
}
|
|
298
298
|
),
|
|
299
299
|
/* @__PURE__ */ s(S, { onClick: x, disabled: !b || l, children: [
|
|
300
|
-
l && /* @__PURE__ */ t(
|
|
300
|
+
l && /* @__PURE__ */ t(j, { className: "mr-2 h-4 w-4 animate-spin" }),
|
|
301
301
|
m.actionLabel
|
|
302
302
|
] })
|
|
303
303
|
] })
|
|
@@ -505,17 +505,17 @@ function kt(e = {}) {
|
|
|
505
505
|
] });
|
|
506
506
|
}
|
|
507
507
|
function Ut({ className: e }) {
|
|
508
|
-
const a = R((u) => u.isDevMode), p = z((u) => u.isVisualEditing), { setIsDevMode: d } =
|
|
508
|
+
const a = R((u) => u.isDevMode), p = z((u) => u.isVisualEditing), { setIsDevMode: d } = Te(), { config: l } = be(Fe).tokenProps, h = (l == null ? void 0 : l.showAdvancedMode) !== !1;
|
|
509
509
|
if (!p || !h)
|
|
510
510
|
return null;
|
|
511
|
-
const o = "h-
|
|
511
|
+
const o = "h-full rounded-none border-0 bg-transparent px-2.5 shadow-none text-muted-foreground hover:bg-accent/50 hover:text-foreground", c = "bg-muted text-foreground hover:bg-muted";
|
|
512
512
|
return /* @__PURE__ */ s(
|
|
513
513
|
"div",
|
|
514
514
|
{
|
|
515
515
|
role: "radiogroup",
|
|
516
516
|
"aria-label": "Editor mode",
|
|
517
517
|
className: V(
|
|
518
|
-
"inline-flex items-stretch overflow-hidden rounded-[5px] border border-input bg-background",
|
|
518
|
+
"inline-flex h-7 items-stretch overflow-hidden rounded-[5px] border border-input bg-background",
|
|
519
519
|
e
|
|
520
520
|
),
|
|
521
521
|
children: [
|
|
@@ -593,14 +593,14 @@ function Vt({
|
|
|
593
593
|
),
|
|
594
594
|
/* @__PURE__ */ t(Oe, { disabled: l, children: c }),
|
|
595
595
|
/* @__PURE__ */ t(S, { type: "button", size: "xs", onClick: p, disabled: l, children: l ? /* @__PURE__ */ s(B, { children: [
|
|
596
|
-
/* @__PURE__ */ t(
|
|
596
|
+
/* @__PURE__ */ t(j, { className: "mr-2 h-3.5 w-3.5 animate-spin" }),
|
|
597
597
|
"Saving..."
|
|
598
598
|
] }) : n })
|
|
599
599
|
] })
|
|
600
600
|
] }) });
|
|
601
601
|
}
|
|
602
602
|
function Mt(e, a, p, d) {
|
|
603
|
-
|
|
603
|
+
T(() => {
|
|
604
604
|
e && !p && a && d(Re(a));
|
|
605
605
|
}, [e, p, a, d]);
|
|
606
606
|
}
|
|
@@ -619,7 +619,7 @@ function wt({
|
|
|
619
619
|
case "failed":
|
|
620
620
|
return /* @__PURE__ */ t(lt, { className: "mt-0.5 h-5 w-5 shrink-0 text-destructive" });
|
|
621
621
|
default:
|
|
622
|
-
return /* @__PURE__ */ t(
|
|
622
|
+
return /* @__PURE__ */ t(j, { className: "text-foreground-muted mt-0.5 h-5 w-5 shrink-0 animate-spin" });
|
|
623
623
|
}
|
|
624
624
|
}, h = $(e.status), o = (() => {
|
|
625
625
|
switch (e.status) {
|
|
@@ -669,7 +669,7 @@ function wt({
|
|
|
669
669
|
] }),
|
|
670
670
|
/* @__PURE__ */ s("div", { className: "ml-8", children: [
|
|
671
671
|
e.status === "completed" && /* @__PURE__ */ s("div", { className: "flex items-center justify-between", children: [
|
|
672
|
-
/* @__PURE__ */ t("span", { className: "text-xs text-muted-foreground", children:
|
|
672
|
+
/* @__PURE__ */ t("span", { className: "text-xs text-muted-foreground", children: Y(e.startedAt, { addSuffix: !0 }) }),
|
|
673
673
|
e.downloadUrl && /* @__PURE__ */ s(
|
|
674
674
|
S,
|
|
675
675
|
{
|
|
@@ -678,20 +678,20 @@ function wt({
|
|
|
678
678
|
className: "h-8 bg-transparent",
|
|
679
679
|
onClick: p,
|
|
680
680
|
children: [
|
|
681
|
-
/* @__PURE__ */ t(
|
|
681
|
+
/* @__PURE__ */ t(He, { className: "mr-1.5 h-3.5 w-3.5" }),
|
|
682
682
|
"Download"
|
|
683
683
|
]
|
|
684
684
|
}
|
|
685
685
|
)
|
|
686
686
|
] }),
|
|
687
687
|
h && /* @__PURE__ */ s("div", { children: [
|
|
688
|
-
/* @__PURE__ */ t(
|
|
688
|
+
/* @__PURE__ */ t(je, { value: e.progress, className: "h-1.5" }),
|
|
689
689
|
/* @__PURE__ */ s("span", { className: "mt-1 block text-xs text-muted-foreground", children: [
|
|
690
690
|
e.progress,
|
|
691
691
|
"% complete"
|
|
692
692
|
] })
|
|
693
693
|
] }),
|
|
694
|
-
e.status === "failed" && /* @__PURE__ */ t("span", { className: "text-xs text-muted-foreground", children:
|
|
694
|
+
e.status === "failed" && /* @__PURE__ */ t("span", { className: "text-xs text-muted-foreground", children: Y(e.startedAt, { addSuffix: !0 }) })
|
|
695
695
|
] })
|
|
696
696
|
] });
|
|
697
697
|
}
|
|
@@ -713,7 +713,7 @@ function yt() {
|
|
|
713
713
|
let i;
|
|
714
714
|
if (r.status === "completed")
|
|
715
715
|
try {
|
|
716
|
-
i = await
|
|
716
|
+
i = await H(
|
|
717
717
|
f,
|
|
718
718
|
w,
|
|
719
719
|
C.id
|
|
@@ -784,13 +784,13 @@ function yt() {
|
|
|
784
784
|
[a == null ? void 0 : a.apiServiceUrl, e == null ? void 0 : e.accessToken, l]
|
|
785
785
|
);
|
|
786
786
|
return v.length === 0 ? /* @__PURE__ */ s("div", { className: "p-6 text-center", children: [
|
|
787
|
-
/* @__PURE__ */ t(
|
|
787
|
+
/* @__PURE__ */ t(Z, { className: "mx-auto mb-2 h-8 w-8 text-muted-foreground" }),
|
|
788
788
|
/* @__PURE__ */ t("p", { className: "text-sm text-muted-foreground", children: "No active exports" }),
|
|
789
789
|
/* @__PURE__ */ t("p", { className: "mt-1 text-xs text-muted-foreground", children: "Large exports will appear here" })
|
|
790
790
|
] }) : /* @__PURE__ */ s("div", { className: "flex flex-col", children: [
|
|
791
791
|
/* @__PURE__ */ s("div", { className: "flex items-center justify-between border-b px-4 py-3", children: [
|
|
792
792
|
/* @__PURE__ */ s("div", { className: "flex items-center gap-2", children: [
|
|
793
|
-
/* @__PURE__ */ t(
|
|
793
|
+
/* @__PURE__ */ t(Z, { className: "h-5 w-5 text-muted-foreground" }),
|
|
794
794
|
/* @__PURE__ */ t("h4", { className: "font-semibold", children: "Exports" })
|
|
795
795
|
] }),
|
|
796
796
|
/* @__PURE__ */ s("div", { className: "flex items-center gap-1", children: [
|
|
@@ -897,16 +897,16 @@ function zt({
|
|
|
897
897
|
// create and make consumers use `forceClose()` from a dedicated
|
|
898
898
|
// button.
|
|
899
899
|
dismissMode: d ? "passive" : "explicit-only"
|
|
900
|
-
}), m = z((A) => A.dashboard), { setDashboardControlsModel: x } = X(), { participants: N } = qe(
|
|
900
|
+
}), m = z((A) => A.dashboard), { setDashboardControlsModel: x } = X(), { participants: N } = qe(Qe(m)), f = Array.from(
|
|
901
901
|
new Map(
|
|
902
902
|
N.flatMap(
|
|
903
903
|
(A) => A.fieldChoices.map((y) => {
|
|
904
|
-
var
|
|
904
|
+
var F;
|
|
905
905
|
return [
|
|
906
906
|
y.value,
|
|
907
907
|
{
|
|
908
908
|
option: y,
|
|
909
|
-
target: (
|
|
909
|
+
target: (F = A.fieldTargetMap) == null ? void 0 : F[y.value]
|
|
910
910
|
}
|
|
911
911
|
];
|
|
912
912
|
})
|
|
@@ -916,25 +916,25 @@ function zt({
|
|
|
916
916
|
new Map(
|
|
917
917
|
N.flatMap(
|
|
918
918
|
(A) => A.metricChoices.map((y) => {
|
|
919
|
-
var
|
|
919
|
+
var F;
|
|
920
920
|
return [
|
|
921
921
|
y.value,
|
|
922
922
|
{
|
|
923
923
|
option: y,
|
|
924
|
-
target: (
|
|
924
|
+
target: (F = A.metricTargetMap) == null ? void 0 : F[y.value]
|
|
925
925
|
}
|
|
926
926
|
];
|
|
927
927
|
})
|
|
928
928
|
)
|
|
929
929
|
).values()
|
|
930
|
-
), E =
|
|
930
|
+
), E = Ye({
|
|
931
931
|
...m || {},
|
|
932
932
|
controls: []
|
|
933
|
-
}), C =
|
|
933
|
+
}), C = Ze(m), r = (A, y, F) => {
|
|
934
934
|
x(
|
|
935
935
|
A,
|
|
936
936
|
y,
|
|
937
|
-
Nt(
|
|
937
|
+
Nt(F)
|
|
938
938
|
);
|
|
939
939
|
}, i = M(() => {
|
|
940
940
|
if (h) {
|
|
@@ -949,7 +949,7 @@ function zt({
|
|
|
949
949
|
controls: m.controls || [],
|
|
950
950
|
reservedControlIds: E,
|
|
951
951
|
defaultValues: m.defaultControlValues || {},
|
|
952
|
-
usageByControlId:
|
|
952
|
+
usageByControlId: Je(m),
|
|
953
953
|
availableFieldChoices: f,
|
|
954
954
|
availableMetricChoices: w,
|
|
955
955
|
structuralParticipants: N,
|
|
@@ -1022,12 +1022,16 @@ function Bt({
|
|
|
1022
1022
|
secondaryButtonClassName: u,
|
|
1023
1023
|
dropdownContentClassName: n
|
|
1024
1024
|
}) {
|
|
1025
|
-
const v = h === "toolbar";
|
|
1026
1025
|
return /* @__PURE__ */ s(
|
|
1027
1026
|
"div",
|
|
1028
1027
|
{
|
|
1029
1028
|
className: V(
|
|
1029
|
+
// Height lives on the shell so the outer border is part of the
|
|
1030
|
+
// h-7 box (matches regular `size="xs"` buttons). Inner buttons
|
|
1031
|
+
// stretch to fill via `h-full`, avoiding the 2px stack-up that
|
|
1032
|
+
// makes the combo taller than a sibling `<Button size="xs">`.
|
|
1030
1033
|
"relative inline-flex items-stretch overflow-hidden rounded-[5px] border border-input bg-background",
|
|
1034
|
+
h === "toolbar" ? "h-8" : "h-7",
|
|
1031
1035
|
o
|
|
1032
1036
|
),
|
|
1033
1037
|
children: [
|
|
@@ -1037,13 +1041,12 @@ function Bt({
|
|
|
1037
1041
|
variant: "ghost",
|
|
1038
1042
|
size: "xs",
|
|
1039
1043
|
className: V(
|
|
1040
|
-
|
|
1041
|
-
"rounded-none border-0 bg-transparent pl-2.5 pr-2 shadow-none hover:bg-accent/50",
|
|
1044
|
+
"h-full rounded-none border-0 bg-transparent pl-2.5 pr-2 shadow-none hover:bg-accent/50",
|
|
1042
1045
|
c
|
|
1043
1046
|
),
|
|
1044
1047
|
onClick: a,
|
|
1045
1048
|
children: [
|
|
1046
|
-
e ? /* @__PURE__ */ t(ut, { className: "h-3.5 w-3.5" }) : /* @__PURE__ */ t(
|
|
1049
|
+
e ? /* @__PURE__ */ t(ut, { className: "h-3.5 w-3.5" }) : /* @__PURE__ */ t(Q, { className: "h-3.5 w-3.5" }),
|
|
1047
1050
|
"Filter"
|
|
1048
1051
|
]
|
|
1049
1052
|
}
|
|
@@ -1055,8 +1058,7 @@ function Bt({
|
|
|
1055
1058
|
variant: "ghost",
|
|
1056
1059
|
size: "xs",
|
|
1057
1060
|
className: V(
|
|
1058
|
-
|
|
1059
|
-
"rounded-none border-0 border-l border-border/60 bg-transparent px-0 shadow-none hover:bg-accent/50",
|
|
1061
|
+
"h-full w-7 rounded-none border-0 border-l border-border/60 bg-transparent px-0 shadow-none hover:bg-accent/50",
|
|
1060
1062
|
u
|
|
1061
1063
|
),
|
|
1062
1064
|
"aria-label": "Filter and control actions",
|
|
@@ -1073,7 +1075,7 @@ function Bt({
|
|
|
1073
1075
|
),
|
|
1074
1076
|
children: [
|
|
1075
1077
|
/* @__PURE__ */ s(U, { onSelect: p, children: [
|
|
1076
|
-
/* @__PURE__ */ t(
|
|
1078
|
+
/* @__PURE__ */ t(Q, { className: "h-3.5 w-3.5" }),
|
|
1077
1079
|
"Add filter"
|
|
1078
1080
|
] }),
|
|
1079
1081
|
/* @__PURE__ */ s(U, { onSelect: d, children: [
|
|
@@ -1100,8 +1102,8 @@ export {
|
|
|
1100
1102
|
Vt as U,
|
|
1101
1103
|
kt as V,
|
|
1102
1104
|
wt as a,
|
|
1103
|
-
|
|
1105
|
+
Ft as b,
|
|
1104
1106
|
Bt as c,
|
|
1105
1107
|
Mt as d,
|
|
1106
|
-
|
|
1108
|
+
Tt as u
|
|
1107
1109
|
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";const g=require("react"),e=require("./index-BQ6qu8FI.js"),t=require("react/jsx-runtime"),I=require("./use-create-flow-overlay-state-zz9TYhdC.js"),M=require("./use-visual-utils-Bm-ZnkON.js"),L=require("./date-formatter-CqXdM6JO.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 T=e.createLucideIcon("FileDown",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M12 18v-6",key:"17g6i2"}],["path",{d:"m9 15 3 3 3-3",key:"1npd3o"}]]);/**
|
|
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
|
+
*/const P=e.createLucideIcon("FilterX",[["path",{d:"M13.013 3H2l8 9.46V19l4 2v-8.54l.9-1.055",key:"1fi1da"}],["path",{d:"m22 3-5 5",key:"12jva0"}],["path",{d:"m17 3 5 5",key:"k36vhe"}]]),V=1e4,z=15e3,O=3e4,R=3e4,H=12e4,k=2*60*60*1e3;function $(s){const r=Date.now()-s.getTime();return r<R?V:r<H?z:O}function _(){const{authToken:s,tokenProps:r}=e.useSemaphorContext(),m=e.useExportStore(p=>p.activeExports),[d,l]=g.useState(typeof document<"u"?!document.hidden:!0),h=g.useRef(null),o=g.useRef(!1),c=g.useRef(void 0),u=r==null?void 0:r.apiServiceUrl,n=s==null?void 0:s.accessToken,f=g.useCallback(()=>{const p=e.useExportStore.getState().activeExports;return Array.from(p.values()).filter(C=>e.isExportInProgress(C.status))},[]);g.useEffect(()=>{if(typeof document>"u")return;const p=()=>{l(!document.hidden)};return document.addEventListener("visibilitychange",p),()=>{document.removeEventListener("visibilitychange",p)}},[]);const b=g.useCallback(async()=>{if(!u||!n){o.current=!1;return}const p=f();if(p.length===0){o.current=!1;return}const C=Date.now(),D=p.filter(a=>C-a.startedAt.getTime()>k);if(D.length>0){const{updateExport:a}=e.useExportStore.getState().actions;for(const i of D)a(i.id,{status:"failed",error:"Export timed out. Please try again or contact support.",lastUpdatedAt:new Date})}const x=p.filter(a=>C-a.startedAt.getTime()<=k);if(x.length===0){o.current=!1;return}const j=await Promise.allSettled(x.map(async a=>{try{const i=await e.getExportStatus(u,n,a.id);let v;if(i.status==="completed")try{v=await e.getDownloadUrl(u,n,a.id)}catch(A){console.error(`[useExportPolling] Failed to get download URL for ${a.id}:`,A)}return{id:a.id,status:i.status,progress:i.progress,completedChunks:i.completedChunks,completedAt:i.completedAt?new Date(i.completedAt):void 0,lastUpdatedAt:new Date,fileSize:i.fileSize,error:i.error,downloadUrl:v}}catch(i){return console.error(`[useExportPolling] Failed to poll export ${a.id}:`,i),null}})),{updateExport:E}=e.useExportStore.getState().actions;for(const a of j)a.status==="fulfilled"&&a.value&&E(a.value.id,a.value);const w=f();if(w.length>0&&!document.hidden){const a=w.reduce((v,A)=>A.startedAt<v?A.startedAt:v,w[0].startedAt),i=$(a);h.current&&clearTimeout(h.current),h.current=setTimeout(()=>{var v;(v=c.current)==null||v.call(c)},i)}else o.current=!1},[u,n,f]);return g.useEffect(()=>{c.current=b},[b]),g.useEffect(()=>{var C;f().length>0&&d&&!o.current&&(o.current=!0,(C=c.current)==null||C.call(c))},[m,d,f]),g.useEffect(()=>{var C;const p=f();d&&p.length>0&&!o.current&&(o.current=!0,(C=c.current)==null||C.call(c))},[d,f]),g.useEffect(()=>{!d&&h.current&&(clearTimeout(h.current),h.current=null,o.current=!1)},[d]),g.useEffect(()=>()=>{h.current&&(clearTimeout(h.current),h.current=null)},[]),{isPolling:o.current,isTabVisible:d,inProgressCount:f().length}}function q(){const{authToken:s,tokenProps:r}=e.useSemaphorContext(),m=e.useExportStore(c=>c.activeExports),{addExport:d}=e.useExportActions(),l=g.useRef(!1),h=r==null?void 0:r.apiServiceUrl,o=s==null?void 0:s.accessToken;g.useEffect(()=>{if(l.current||!h||!o)return;(async()=>{try{const{exports:u}=await e.getExports(h,o,{status:["pending","processing","chunking","compacting","completed","failed"],limit:20});for(const n of u){if(m.has(n.id))continue;const f=n.totalChunks?Math.round(n.completedChunks/n.totalChunks*100):0;let b;if(n.status==="completed")try{b=await e.getDownloadUrl(h,o,n.id)}catch(C){console.error(`[useExportRecovery] Failed to get download URL for ${n.id}:`,C)}const p={id:n.id,status:n.status,progress:f,title:X(n),totalRows:n.totalRows,totalChunks:n.totalChunks,completedChunks:n.completedChunks,startedAt:new Date(n.createdAt),lastUpdatedAt:new Date,completedAt:n.completedAt?new Date(n.completedAt):void 0,fileSize:n.fileSize,error:n.error,expiresAt:new Date(n.expiresAt),downloadUrl:b};d(p)}l.current=!0}catch(u){console.error("[useExportRecovery] Failed to recover exports:",u),l.current=!0}})()},[h,o,d,m])}function X(s){return s.title?s.title:e.isExportInProgress(s.status)?"Export in progress...":s.status==="completed"?"Export completed":s.status==="failed"?"Export failed":"Export"}function G({open:s,onOpenChange:r,isLibraryVisual:m,currentVisualName:d,isSaving:l=!1,destinationMode:h="both",onConfirm:o}){const[c,u]=g.useState(m&&d?`Copy of ${d}`:d||""),[n,f]=g.useState("");g.useEffect(()=>{s&&(u(m&&d?`Copy of ${d}`:d||""),f(""))},[s,m,d]);const b=!!c.trim(),p=h==="local"?{saveToLibrary:!1,saveToCurrentDashboard:!0,badgeType:"local",description:"Creates a local copy on the current dashboard.",actionLabel:"Add to Dashboard (Local)"}:h==="library"?{saveToLibrary:!0,saveToCurrentDashboard:!1,badgeType:"library",description:"Creates a reusable visual in Visual Library.",actionLabel:"Save as Library Visual"}:{saveToLibrary:!0,saveToCurrentDashboard:!0,badgeType:"linked",description:"Creates a new library visual and adds a linked copy to this dashboard.",actionLabel:"Save Copy as Linked Visual"},C=()=>{!b||l||o({name:c.trim(),description:n.trim()||void 0,saveToLibrary:p.saveToLibrary,saveToCurrentDashboard:p.saveToCurrentDashboard})};return t.jsx(e.Dialog,{open:s,onOpenChange:r,children:t.jsxs(e.DialogContent,{className:"sm:max-w-[500px]",children:[t.jsxs(e.DialogHeader,{children:[t.jsxs(e.DialogTitle,{className:"flex items-center gap-2",children:[t.jsx("span",{children:"Save Visual As"}),p.badgeType!=="local"&&t.jsx(I.VisualBadge,{type:p.badgeType,showLabel:!0,className:"px-2 py-0.5"})]}),t.jsx(e.DialogDescription,{children:p.description})]}),t.jsxs("div",{className:"grid gap-4 py-4",children:[t.jsxs("div",{className:"grid gap-2",children:[t.jsx(e.Label,{htmlFor:"name",children:"Name"}),t.jsx(e.Input,{id:"name",value:c,onChange:D=>u(D.target.value),placeholder:"Enter visual name",disabled:l})]}),t.jsxs("div",{className:"grid gap-2",children:[t.jsx(e.Label,{htmlFor:"description",children:"Description (optional)"}),t.jsx(e.Textarea,{id:"description",value:n,onChange:D=>f(D.target.value),placeholder:"Enter visual description",rows:3,disabled:l})]})]}),t.jsxs(e.DialogFooter,{children:[t.jsx(e.Button,{variant:"outline",onClick:()=>r(!1),disabled:l,children:"Cancel"}),t.jsxs(e.Button,{onClick:C,disabled:!b||l,children:[l&&t.jsx(e.LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin"}),p.actionLabel]})]})]})})}function K(){const[s,r]=g.useState(!1),[m,d]=g.useState(!1),[l,h]=g.useState(null),o=e.useEditorStore(i=>i.frame),c=e.useEditorStore(i=>i.card),u=e.useSelectedVisual(),n=e.useDashboardStore(i=>i.selectedSheetId),f=e.useDashboardStore(i=>i.actions.setIsDashboardPanelOpen),{getUpdatedFrame:b}=M.useVisualUtils(),{selectVisual:p}=e.useManagementActions(),{addFrame:C,setSelectedFrameId:D,setIsVisualEditing:x}=e.useDashboardActions(),j=!!(o!=null&&o.visualId),E=(()=>{var i,v;return((i=o==null?void 0:o.cards)==null?void 0:i.length)===1&&((v=o.cards[0])!=null&&v.title)?o.cards[0].title:u!=null&&u.title?u.title:(c==null?void 0:c.title)||"Untitled Visual"})(),w=e.useCreateVisualWithFrame(i=>{if(i!=null&&i.id){if(p(i),m&&l&&n){const v={...l,id:e.v4(),visualId:i.id};C(n,v,"end"),D(v.id),d(!1),h(null),x(!1)}f(!0),r(!1)}});return{saveAsDialogOpen:s,setSaveAsDialogOpen:r,handleSaveAs:async i=>{if(!n){e.ue.error("No sheet selected");return}const v=b(),A=e.getDynamicFrameSaveIssue(v);if(A){e.ue.error(A);return}const N=v.cards.length===1?{...v,cards:v.cards.map(y=>({...y,title:i.name}))}:v;if(i.saveToLibrary){d(i.saveToCurrentDashboard),h(N);const y={title:i.name,description:i.description,frameObject:N,isPrivate:!1};w.mutate(y)}else if(i.saveToCurrentDashboard){const y={...N,id:e.v4(),visualId:void 0};C(n,y,"end"),D(y.id),e.ue.success("Visual saved to dashboard"),r(!1),x(!1)}},isLibraryVisual:j,currentVisualName:E,isSaving:w.isPending}}function Q(s={}){const r=e.useEditorStore(S=>S.frame),m=e.useManagementStore(S=>S.selectedVisual),d=e.useDashboardStore(S=>S.selectedFrameId),l=e.useDashboardStore(S=>S.selectedSheetId),{setIsVisualEditing:h,updateFrame:o}=e.useDashboardActions(),[c,u]=g.useState(!1),[n,f]=g.useState("both"),b=!!(r!=null&&r.visualId||m!=null&&m.id),p=!!(r!=null&&r.visualId&&d),C=b&&!p,{saveAsDialogOpen:D,setSaveAsDialogOpen:x,handleSaveAs:j,isLibraryVisual:E,currentVisualName:w,isSaving:a}=K(),{getUpdatedFrame:i}=M.useVisualUtils(),v=()=>{if(!l){e.ue.error("No sheet selected");return}if(c)return;u(!0);const S=i(),N=e.getDynamicFrameSaveIssue(S);if(N){u(!1),e.ue.error(N);return}const y={...S,visualId:void 0};o(l,y),setTimeout(()=>{u(!1),e.ue.success("Changes applied. Visual is now local to this dashboard"),h(!1)},300)},A=S=>{f(S),x(!0)};return t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"inline-flex items-center overflow-hidden rounded-[5px]",children:[!b&&t.jsx(I.EditorAcceptButton,{className:"rounded-none",variant:"default"}),b&&C&&t.jsx(I.VisualSaveButton,{className:"rounded-none",variant:"default"}),b&&p&&t.jsx(I.VisualSaveAndApplyButton,{className:"rounded-none"}),t.jsxs(e.DropdownMenu,{modal:!1,children:[t.jsx(e.DropdownMenuTrigger,{asChild:!0,children:t.jsx(e.Button,{variant:"default",size:"xs",className:"w-7 rounded-none border-l border-primary-foreground/20 px-0","aria-label":"Open visual save options",disabled:a||c,children:t.jsx(e.ChevronDown,{className:"h-3.5 w-3.5"})})}),t.jsxs(e.DropdownMenuContent,{align:"end",className:"min-w-[220px] rounded-[6px] border border-border/60 p-1 shadow-sm",children:[p&&t.jsxs(t.Fragment,{children:[t.jsxs(e.DropdownMenuItem,{onClick:v,disabled:c,children:[t.jsx(e.Check,{className:"h-3.5 w-3.5"}),c?"Applying...":"Apply Locally"]}),t.jsx(e.DropdownMenuSeparator,{})]}),t.jsxs(e.DropdownMenuItem,{onClick:()=>A("local"),disabled:a,children:[t.jsx(e.Plus,{className:"h-3.5 w-3.5"}),"Add to Dashboard (Local)"]}),t.jsxs(e.DropdownMenuItem,{onClick:()=>A("library"),disabled:a,children:[t.jsx(I.Library,{className:"h-3.5 w-3.5"}),"Save as Library Visual"]}),t.jsxs(e.DropdownMenuItem,{onClick:()=>A("both"),disabled:a,children:[t.jsx(I.Link2,{className:"h-3.5 w-3.5"}),"Save Copy as Linked Visual"]})]})]})]}),t.jsx(I.EditorCancelButton,{}),t.jsx(G,{open:D,onOpenChange:S=>{a||x(S)},isLibraryVisual:E,currentVisualName:w,isSaving:a,destinationMode:n,onConfirm:j})]})}function W({className:s}){const r=e.useEditorStore(u=>u.isDevMode),m=e.useDashboardStore(u=>u.isVisualEditing),{setIsDevMode:d}=e.useEditorActions(),{config:l}=g.useContext(e.SemaphorContext).tokenProps,h=(l==null?void 0:l.showAdvancedMode)!==!1;if(!m||!h)return null;const o="h-full rounded-none border-0 bg-transparent px-2.5 shadow-none text-muted-foreground hover:bg-accent/50 hover:text-foreground",c="bg-muted text-foreground hover:bg-muted";return t.jsxs("div",{role:"radiogroup","aria-label":"Editor mode",className:e.cn("inline-flex h-7 items-stretch overflow-hidden rounded-[5px] border border-input bg-background",s),children:[t.jsxs(e.Button,{type:"button",variant:"ghost",size:"xs",role:"radio","aria-checked":!r,className:e.cn(o,!r&&c),onClick:()=>d(!1),children:[t.jsx(e.SlidersHorizontal,{className:"h-3.5 w-3.5"}),"Drag & drop"]}),t.jsxs(e.Button,{type:"button",variant:"ghost",size:"xs",role:"radio","aria-checked":r,className:e.cn(o,"border-l border-border/60",r&&c),onClick:()=>d(!0),children:[t.jsx(e.CodeXml,{className:"h-3.5 w-3.5"}),"SQL"]})]})}function Y({open:s,onOpenChange:r,onSave:m,onDiscard:d,isSaving:l,title:h="Unsaved changes",description:o="You have unsaved changes to this dashboard. What would you like to do?",cancelLabel:c="Cancel",discardLabel:u="Discard",saveLabel:n="Save"}){const f=b=>{!b&&l||r(b)};return t.jsx(e.AlertDialog,{open:s,onOpenChange:f,children:t.jsxs(e.AlertDialogContent,{children:[t.jsxs(e.AlertDialogHeader,{children:[t.jsx(e.AlertDialogTitle,{children:h}),t.jsx(e.AlertDialogDescription,{children:o})]}),t.jsxs(e.AlertDialogFooter,{children:[t.jsx(e.Button,{type:"button",size:"xs",onClick:d,disabled:l,variant:"ghost",className:"mr-auto text-muted-foreground hover:bg-destructive/10 hover:text-destructive focus-visible:bg-destructive/10 focus-visible:text-destructive",children:u}),t.jsx(e.AlertDialogCancel,{disabled:l,children:c}),t.jsx(e.Button,{type:"button",size:"xs",onClick:m,disabled:l,children:l?t.jsxs(t.Fragment,{children:[t.jsx(e.LoaderCircle,{className:"mr-2 h-3.5 w-3.5 animate-spin"}),"Saving..."]}):n})]})]})})}function Z(s,r,m,d){g.useEffect(()=>{s&&!m&&r&&d(e.cloneDeep(r))},[s,m,r,d])}function B({export:s,onRemove:r}){const m=()=>{s.downloadUrl&&window.open(s.downloadUrl,"_blank")},d=c=>{c.stopPropagation(),r==null||r(s.id)},l=()=>{switch(s.status){case"completed":return t.jsx(e.CircleCheck,{className:"mt-0.5 h-5 w-5 shrink-0 text-green-600"});case"failed":return t.jsx(I.CircleX,{className:"mt-0.5 h-5 w-5 shrink-0 text-destructive"});default:return t.jsx(e.LoaderCircle,{className:"text-foreground-muted mt-0.5 h-5 w-5 shrink-0 animate-spin"})}},h=e.isExportInProgress(s.status),o=(()=>{switch(s.status){case"pending":return"Queued...";case"processing":return"Processing...";case"chunking":return"Processing...";case"compacting":return"Finalizing...";default:return"Processing..."}})();return t.jsxs("div",{className:"group p-4 transition-colors hover:bg-muted/50",children:[t.jsxs("div",{className:"mb-2 flex items-start justify-between gap-3",children:[t.jsxs("div",{className:"flex min-w-0 flex-1 items-start gap-3",children:[l(),t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsx("h4",{className:"mb-1 truncate text-sm font-medium",children:s.title}),s.status==="completed"&&t.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[t.jsxs("span",{children:[s.totalRows.toLocaleString()," rows"]}),s.fileSize&&t.jsxs(t.Fragment,{children:[t.jsx("span",{children:"•"}),t.jsx("span",{children:e.formatFileSize(s.fileSize)})]})]}),h&&t.jsx("div",{className:"text-xs text-muted-foreground",children:o}),s.status==="failed"&&t.jsx("div",{className:"line-clamp-2 text-xs text-destructive",children:s.error||"Export failed"})]})]}),t.jsx(e.Button,{variant:"ghost",size:"icon",className:"h-6 w-6 shrink-0 opacity-0 transition-opacity group-hover:opacity-100",onClick:d,"aria-label":"Remove notification",children:t.jsx(e.X,{className:"h-4 w-4"})})]}),t.jsxs("div",{className:"ml-8",children:[s.status==="completed"&&t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsx("span",{className:"text-xs text-muted-foreground",children:L.formatDistanceToNow(s.startedAt,{addSuffix:!0})}),s.downloadUrl&&t.jsxs(e.Button,{size:"sm",variant:"outline",className:"h-8 bg-transparent",onClick:m,children:[t.jsx(e.Download,{className:"mr-1.5 h-3.5 w-3.5"}),"Download"]})]}),h&&t.jsxs("div",{children:[t.jsx(e.Progress,{value:s.progress,className:"h-1.5"}),t.jsxs("span",{className:"mt-1 block text-xs text-muted-foreground",children:[s.progress,"% complete"]})]}),s.status==="failed"&&t.jsx("span",{className:"text-xs text-muted-foreground",children:L.formatDistanceToNow(s.startedAt,{addSuffix:!0})})]})]})}function U(){const{authToken:s,tokenProps:r}=e.useSemaphorContext(),m=e.useExportStore(x=>x.activeExports),{clearCompleted:d,removeExport:l,updateExport:h}=e.useExportActions(),[o,c]=g.useState(!1),[u,n]=g.useState(!1),f=Array.from(m.values()).sort((x,j)=>j.startedAt.getTime()-x.startedAt.getTime()),b=f.some(x=>x.status==="completed"||x.status==="failed"),p=g.useCallback(async()=>{const x=r==null?void 0:r.apiServiceUrl,j=s==null?void 0:s.accessToken;if(!(!x||!j)){c(!0);try{const E=Array.from(m.values());await Promise.all(E.map(async w=>{try{const a=await e.getExportStatus(x,j,w.id);let i;if(a.status==="completed")try{i=await e.getDownloadUrl(x,j,w.id)}catch(v){console.error(`Failed to get download URL for ${w.id}:`,v)}h(w.id,{status:a.status,progress:a.progress,completedChunks:a.completedChunks,completedAt:a.completedAt?new Date(a.completedAt):void 0,lastUpdatedAt:new Date,fileSize:a.fileSize,error:a.error,downloadUrl:i})}catch(a){console.error(`Failed to refresh export ${w.id}:`,a)}}))}finally{c(!1)}}},[m,s==null?void 0:s.accessToken,r==null?void 0:r.apiServiceUrl,h]),C=g.useCallback(async()=>{const x=r==null?void 0:r.apiServiceUrl,j=s==null?void 0:s.accessToken;if(!x||!j){d();return}n(!0);try{const E=f.filter(a=>a.status==="completed"||a.status==="failed"),w=await Promise.allSettled(E.map(async a=>(await e.cancelExport(x,j,a.id),a.id)));for(const a of w)a.status==="fulfilled"?l(a.value):console.error("Failed to delete export:",a.reason)}finally{n(!1)}},[f,r==null?void 0:r.apiServiceUrl,s==null?void 0:s.accessToken,d,l]),D=g.useCallback(async x=>{const j=r==null?void 0:r.apiServiceUrl,E=s==null?void 0:s.accessToken;if(j&&E)try{await e.cancelExport(j,E,x),l(x);return}catch(w){console.error(`Failed to cancel export ${x}:`,w)}l(x)},[r==null?void 0:r.apiServiceUrl,s==null?void 0:s.accessToken,l]);return f.length===0?t.jsxs("div",{className:"p-6 text-center",children:[t.jsx(T,{className:"mx-auto mb-2 h-8 w-8 text-muted-foreground"}),t.jsx("p",{className:"text-sm text-muted-foreground",children:"No active exports"}),t.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:"Large exports will appear here"})]}):t.jsxs("div",{className:"flex flex-col",children:[t.jsxs("div",{className:"flex items-center justify-between border-b px-4 py-3",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(T,{className:"h-5 w-5 text-muted-foreground"}),t.jsx("h4",{className:"font-semibold",children:"Exports"})]}),t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx(e.Button,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0",onClick:p,disabled:o,title:"Refresh status",children:t.jsx(e.RefreshCw,{className:`h-4 w-4 ${o?"animate-spin":""}`})}),b&&t.jsx(e.Button,{variant:"ghost",size:"sm",className:"h-7 px-2 text-sm",onClick:C,disabled:u,children:u?"Clearing...":"Clear all"})]})]}),t.jsx("div",{className:"max-h-[350px] overflow-y-auto",children:t.jsx("div",{className:"divide-y",children:f.map(x=>t.jsx(B,{export:x,onRemove:D},x.id))})})]})}function J({variant:s}){const r=e.useExportStore(u=>u.activeExports),m=e.useInProgressExportsCount(),d=r.size>0,l=Array.from(r.values()).some(u=>u.status==="completed"||u.status==="failed"),o=m>0?m>9?"9+":String(m):null,c=d;return t.jsxs(e.Popover,{children:[t.jsx(e.PopoverTrigger,{asChild:!0,children:t.jsxs(e.Button,{variant:s??"ghost",size:"xs",className:"relative w-7 px-0 text-muted-foreground hover:text-foreground","aria-label":"Export notifications",children:[t.jsx(e.Bell,{className:"h-3.5 w-3.5"}),c&&t.jsx("span",{className:`absolute flex items-center justify-center rounded-full bg-primary text-primary-foreground ${o?"-right-0.5 -top-0.5 h-3.5 min-w-3.5 px-0.5 text-[9px] font-semibold":"right-1 top-1 h-1.5 w-1.5"}`,children:o})]})}),t.jsx(e.PopoverContent,{className:"w-80 p-0",align:"end",sideOffset:8,children:t.jsx(U,{})})]})}function ee(s){if(s)return{renamed:s.type==="rename"?{oldId:s.oldId,newId:s.newId}:void 0,removedControlId:s.type==="remove"?s.controlId:void 0,cardBindingsById:s.type==="add"||s.type==="update"?s.cardBindingsById:void 0,affectedBindingControlIds:s.type==="add"||s.type==="update"?s.affectedBindingControlIds:void 0}}function te({open:s,onOpenChange:r,trigger:m,showTrigger:d=!0,initialMode:l="manage"}){const h=l==="create",{forceClose:o,handleOpenChange:c,isCreateFlowActive:u,preventPassiveDismissDuringCreate:n,resolvedOpen:f,setIsCreateFlowActive:b}=I.useCreateFlowOverlayState({open:s,onOpenChange:r,initialCreateFlowActive:l==="create",dismissMode:d?"passive":"explicit-only"}),p=e.useDashboardStore(N=>N.dashboard),{setDashboardControlsModel:C}=e.useDashboardActions(),{participants:D}=e.useDashboardStructuralParticipants(e.getDashboardCards(p)),x=Array.from(new Map(D.flatMap(N=>N.fieldChoices.map(y=>{var F;return[y.value,{option:y,target:(F=N.fieldTargetMap)==null?void 0:F[y.value]}]}))).values()),j=Array.from(new Map(D.flatMap(N=>N.metricChoices.map(y=>{var F;return[y.value,{option:y,target:(F=N.metricTargetMap)==null?void 0:F[y.value]}]}))).values()),E=e.collectDashboardControlIds({...p||{},controls:[]}),w=e.buildDashboardStructuralParticipantIdsByControlId(p),a=(N,y,F)=>{C(N,y,ee(F))},i=g.useCallback(()=>{if(h){o();return}b(!1)},[h,o,b]),v=t.jsx(I.ControlDefinitionListEditor,{scope:"dashboard",controls:p.controls||[],reservedControlIds:E,defaultValues:p.defaultControlValues||{},usageByControlId:e.buildDashboardControlUsageById(p),availableFieldChoices:x,availableMetricChoices:j,structuralParticipants:D,structuralParticipantIdsByControlId:w,initialCreateFlow:l==="create",onCreateFlowActiveChange:b,onCreateFlowComplete:i,onChange:a,emptyMessage:"No dashboard controls yet."}),A=u?"Add dashboard control":"Dashboard Controls",S=t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"space-y-1",children:[t.jsx("h4",{className:"text-sm font-medium",children:"Dashboard Controls"}),t.jsx("p",{className:"text-xs text-muted-foreground",children:"Add shared controls viewers can use across the dashboard. Each card can decide how to respond to the same control."})]}),v]});return d?t.jsxs(e.Popover,{open:f,onOpenChange:c,children:[t.jsx(e.PopoverTrigger,{asChild:!0,children:m||t.jsxs(e.Button,{variant:"outline",className:"h-7 px-2",size:"sm",children:[t.jsx(e.SlidersHorizontal,{className:"mr-2 h-4 w-4"}),"Controls"]})}),t.jsx(e.PopoverContent,{className:"w-[620px] max-w-[95vw] space-y-4",align:"end",onEscapeKeyDown:n,onPointerDownOutside:n,children:S})]}):t.jsx(e.Dialog,{open:f,onOpenChange:c,children:t.jsxs(e.DialogContent,{className:"flex max-h-[88vh] flex-col overflow-hidden sm:max-w-[600px]",onEscapeKeyDown:n,onPointerDownOutside:n,children:[t.jsxs(e.DialogHeader,{className:u?"space-y-0":void 0,children:[t.jsx(e.DialogTitle,{className:"text-[15px]",children:A}),t.jsx(e.DialogDescription,{className:u?"sr-only":"text-[13px]",children:u?"Configure and add a shared dashboard control.":"Add shared controls viewers can use across the dashboard. Each card can decide how to respond to the same control."})]}),t.jsx("div",{className:"min-h-0 overflow-y-auto pr-1",children:v})]})})}function se({showFilters:s,onToggleFilters:r,onAddFilter:m,onAddControl:d,onManageControls:l,size:h="default",className:o,primaryButtonClassName:c,secondaryButtonClassName:u,dropdownContentClassName:n}){const f=h==="toolbar";return t.jsxs("div",{className:e.cn("relative inline-flex items-stretch overflow-hidden rounded-[5px] border border-input bg-background",f?"h-8":"h-7",o),children:[t.jsxs(e.Button,{variant:"ghost",size:"xs",className:e.cn("h-full rounded-none border-0 bg-transparent pl-2.5 pr-2 shadow-none hover:bg-accent/50",c),onClick:r,children:[s?t.jsx(P,{className:"h-3.5 w-3.5"}):t.jsx(e.Filter,{className:"h-3.5 w-3.5"}),"Filter"]}),t.jsxs(e.DropdownMenu,{children:[t.jsx(e.DropdownMenuTrigger,{asChild:!0,children:t.jsx(e.Button,{variant:"ghost",size:"xs",className:e.cn("h-full w-7 rounded-none border-0 border-l border-border/60 bg-transparent px-0 shadow-none hover:bg-accent/50",u),"aria-label":"Filter and control actions",children:t.jsx(e.ChevronDown,{className:"h-3.5 w-3.5"})})}),t.jsxs(e.DropdownMenuContent,{align:"start",className:e.cn("min-w-[180px] rounded-[6px] border border-border/60 p-1 shadow-sm",n),children:[t.jsxs(e.DropdownMenuItem,{onSelect:m,children:[t.jsx(e.Filter,{className:"h-3.5 w-3.5"}),"Add filter"]}),t.jsxs(e.DropdownMenuItem,{onSelect:d,children:[t.jsx(e.SlidersHorizontal,{className:"h-3.5 w-3.5"}),"Add control"]}),t.jsxs(e.DropdownMenuItem,{onSelect:l,children:[t.jsx(e.Pencil,{className:"h-3.5 w-3.5"}),"Manage controls"]})]})]})]})}exports.AdvancedModeToggle=W;exports.DashboardControlsSettings=te;exports.DashboardFilterControlsButton=se;exports.ExportNotificationItem=B;exports.ExportNotificationList=U;exports.NotificationBell=J;exports.UnsavedChangesAlert=Y;exports.VisualEditingControls=Q;exports.useExportPolling=_;exports.useExportRecovery=q;exports.usePristineSnapshotInitializer=Z;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("react/jsx-runtime"),r=require("react"),s=require("./index-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("react/jsx-runtime"),r=require("react"),s=require("./index-BQ6qu8FI.js");require("react-dom");function b(){const t=s.useDashboardStore(e=>e.dashboard),i=s.useDashboardStore(e=>e.actions.setDashboard),h=s.useDashboardStore(e=>e.showDashboardJSON),u=s.useDashboardStore(e=>e.actions.setShowDashboardJSON),a=r.useMemo(()=>t?JSON.stringify(t,null,2):"",[t]),[l,d]=r.useState(a),n=r.useRef(a);return r.useEffect(()=>{a!==n.current&&(d(a),n.current=a)},[a]),o.jsxs("div",{className:s.cn("relative p-2",{hidden:!h}),children:[o.jsxs(s.Button,{variant:"secondary",size:"sm",className:"absolute right-2 top-2 z-10 h-8",onClick:()=>u(!1),children:[o.jsx(s.X,{className:"mr-2 h-4 w-4"}),"Close"]}),o.jsx("div",{className:"h-[550px] overflow-hidden",children:o.jsx(s.CodeEditor,{value:l,onValueChange:e=>{d(e);try{const c=JSON.parse(e);n.current=JSON.stringify(c,null,2),i(c)}catch{}},language:"json"})})]})}exports.default=b;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { jsxs as
|
|
1
|
+
import { jsxs as i, jsx as t } from "react/jsx-runtime";
|
|
2
2
|
import { useMemo as b, useState as f, useRef as m, useEffect as S } from "react";
|
|
3
|
-
import { u as e,
|
|
3
|
+
import { u as e, b as N, B as D, X as p, C as J } from "./index-72yod5pb.js";
|
|
4
4
|
import "react-dom";
|
|
5
5
|
function x() {
|
|
6
|
-
const o = e((s) => s.dashboard),
|
|
6
|
+
const o = e((s) => s.dashboard), c = e((s) => s.actions.setDashboard), h = e(
|
|
7
7
|
(s) => s.showDashboardJSON
|
|
8
8
|
), l = e(
|
|
9
9
|
(s) => s.actions.setShowDashboardJSON
|
|
@@ -13,14 +13,14 @@ function x() {
|
|
|
13
13
|
), [u, n] = f(a), r = m(a);
|
|
14
14
|
return S(() => {
|
|
15
15
|
a !== r.current && (n(a), r.current = a);
|
|
16
|
-
}, [a]), /* @__PURE__ */
|
|
16
|
+
}, [a]), /* @__PURE__ */ i(
|
|
17
17
|
"div",
|
|
18
18
|
{
|
|
19
19
|
className: N("relative p-2", {
|
|
20
20
|
hidden: !h
|
|
21
21
|
}),
|
|
22
22
|
children: [
|
|
23
|
-
/* @__PURE__ */
|
|
23
|
+
/* @__PURE__ */ i(
|
|
24
24
|
D,
|
|
25
25
|
{
|
|
26
26
|
variant: "secondary",
|
|
@@ -45,7 +45,7 @@ function x() {
|
|
|
45
45
|
d,
|
|
46
46
|
null,
|
|
47
47
|
2
|
|
48
|
-
),
|
|
48
|
+
), c(d);
|
|
49
49
|
} catch {
|
|
50
50
|
}
|
|
51
51
|
},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const e=require("react/jsx-runtime"),l=require("react"),a=require("./index-Cwg2SRSi.js");function W(r={}){var C,I,P,D;const{authToken:o,tokenProps:s}=a.useSemaphorContext(),v=r.enabled??!0,d=(o==null?void 0:o.accessToken)??null,f=(s==null?void 0:s.apiServiceUrl)??null,[y,g]=l.useState(!1),[S,p]=l.useState(!1),[m,n]=l.useState(!1),[j,c]=l.useState(null),[x,w]=l.useState(null),k=x||{tz:((I=(C=s==null?void 0:s.params)==null?void 0:C.calendarContext)==null?void 0:I.tz)||null,weekStart:((D=(P=s==null?void 0:s.params)==null?void 0:P.calendarContext)==null?void 0:D.weekStart)??null},b=l.useCallback(async()=>{if(!(!v||!d||!f)){g(!0),c(null);try{const u=await fetch(`${f}/v1/user-preferences/calendar`,{method:"GET",headers:{Authorization:`Bearer ${d}`}});if(!u.ok){const h=await u.json().catch(()=>({}));throw new Error(h.error||"Failed to fetch preferences")}const i=await u.json();w({tz:i.tz,weekStart:i.weekStart,source:i.source,isInherited:i.isInherited,userHasPrefs:i.userHasPrefs,inherited:i.inherited})}catch(u){const i=u instanceof Error?u.message:"Unknown error";c(i)}finally{g(!1)}}},[d,f,v]);l.useEffect(()=>{v&&b()},[v,b]);const T=l.useCallback(async u=>{if(!d||!f)return c("Not authenticated"),!1;p(!0),c(null);try{const i=await fetch(`${f}/v1/user-preferences/calendar`,{method:"PATCH",headers:{"Content-Type":"application/json",Authorization:`Bearer ${d}`},body:JSON.stringify(u)});if(!i.ok){const h=await i.json().catch(()=>({}));throw new Error(h.error||"Failed to update preferences")}return await b(),!0}catch(i){const h=i instanceof Error?i.message:"Unknown error";return c(h),!1}finally{p(!1)}},[d,f,b]),N=l.useCallback(async()=>{if(!d||!f)return c("Not authenticated"),!1;n(!0),c(null);try{const u=await fetch(`${f}/v1/user-preferences/calendar`,{method:"DELETE",headers:{Authorization:`Bearer ${d}`}});if(!u.ok){const h=await u.json().catch(()=>({}));throw new Error(h.error||"Failed to clear preferences")}const i=await u.text();if(i)try{const h=JSON.parse(i);return w({tz:h.tz,weekStart:h.weekStart,source:h.source,isInherited:h.isInherited??!0,userHasPrefs:!1,inherited:h.inherited}),!0}catch{}return await b(),!0}catch(u){const i=u instanceof Error?u.message:"Unknown error";return c(i),!1}finally{n(!1)}},[d,f,b]);return{preferences:k,isLoading:y,isSaving:S,isClearing:m,error:j,updatePreferences:T,clearPreferences:N,refetch:b}}const A=[{value:"America/New_York",label:"Eastern Time (US & Canada)"},{value:"America/Chicago",label:"Central Time (US & Canada)"},{value:"America/Denver",label:"Mountain Time (US & Canada)"},{value:"America/Los_Angeles",label:"Pacific Time (US & Canada)"},{value:"America/Phoenix",label:"Arizona"},{value:"America/Anchorage",label:"Alaska"},{value:"Pacific/Honolulu",label:"Hawaii"},{value:"Europe/London",label:"London"},{value:"Europe/Paris",label:"Paris, Berlin, Rome"},{value:"Asia/Tokyo",label:"Tokyo"},{value:"Asia/Shanghai",label:"Beijing, Shanghai"},{value:"Asia/Kolkata",label:"Mumbai, New Delhi"},{value:"Australia/Sydney",label:"Sydney"},{value:"UTC",label:"UTC"}],H=[{value:0,label:"Sunday"},{value:1,label:"Monday"},{value:6,label:"Saturday"}];function G(){try{const r=Intl;if(r.supportedValuesOf)return r.supportedValuesOf("timeZone")}catch{}return A.map(r=>r.value)}function V(r){switch(r){case"tenant":return"tenant";case"organization":return"organization";case"system":return"system";default:return"default"}}function U(r){const o=A.find(s=>s.value===r);return o?o.label:r}function X(r){const o=H.find(s=>s.value===r);return o?o.label:String(r)}function q({open:r,onOpenChange:o}){var M,z,F;const{preferences:s,isLoading:v,isSaving:d,isClearing:f,updatePreferences:y,clearPreferences:g}=W({enabled:r}),S=s.tz||((M=s.inherited)==null?void 0:M.tz)||Intl.DateTimeFormat().resolvedOptions().timeZone,p=s.weekStart??((z=s.inherited)==null?void 0:z.weekStart)??1,[m,n]=l.useState(!s.userHasPrefs),[j,c]=l.useState(!1),[x,w]=l.useState(S),[k,b]=l.useState(p),[T,N]=l.useState(!1),C=l.useMemo(()=>G(),[]),I=l.useMemo(()=>C.filter(t=>!A.some(R=>R.value===t)),[C]),P=l.useMemo(()=>U(x),[x]),D=s.inherited?U(s.inherited.tz):"UTC",u=s.inherited?X(s.inherited.weekStart):"Monday",i=V((F=s.inherited)==null?void 0:F.source);l.useEffect(()=>{if(!r){c(!1);return}j||(s.userHasPrefs!==void 0&&n(!s.userHasPrefs),w(S),b(p))},[r,j,s.userHasPrefs,S,p]);const h=async()=>{if(v){a.ue.error("Preferences are still loading. Please try again.");return}m?await g()?(a.ue.success("Now using default settings. Please refresh the page to apply changes.",{duration:5e3}),o(!1)):a.ue.error("Failed to save preferences. Please try again."):await y({tz:x,weekStart:k})?(a.ue.success("Preferences saved. Please refresh the page to apply changes.",{duration:5e3}),o(!1)):a.ue.error("Failed to save preferences. Please try again.")},$=()=>{o(!1)},L=d||f,O=L||v;return e.jsx(a.Dialog,{open:r,onOpenChange:o,children:e.jsxs(a.DialogContent,{className:"sm:max-w-[425px]",children:[e.jsxs(a.DialogHeader,{children:[e.jsx(a.DialogTitle,{children:"Calendar Preferences"}),e.jsx(a.DialogDescription,{children:"Set your timezone and week start preferences for date calculations and displays."})]}),e.jsxs("div",{className:"space-y-6 py-4",children:[e.jsxs(a.RadioGroup,{value:m?"defaults":"custom",onValueChange:t=>{c(!0),n(t==="defaults")},className:"space-y-3",children:[e.jsxs("div",{className:a.cn("flex items-start space-x-3 rounded-lg border p-4 cursor-pointer transition-colors",m?"border-primary bg-primary/5":"border-border hover:border-muted-foreground/50"),onClick:()=>{c(!0),n(!0)},children:[e.jsx(a.RadioGroupItem,{value:"defaults",id:"mode-defaults"}),e.jsxs("div",{className:"flex-1 space-y-1",children:[e.jsxs(a.Label,{htmlFor:"mode-defaults",className:"cursor-pointer font-medium",children:["Use ",i," defaults"]}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:[D,", Week starts ",u]})]})]}),e.jsxs("div",{className:a.cn("flex items-start space-x-3 rounded-lg border p-4 cursor-pointer transition-colors",m?"border-border hover:border-muted-foreground/50":"border-primary bg-primary/5"),onClick:()=>{c(!0),n(!1)},children:[e.jsx(a.RadioGroupItem,{value:"custom",id:"mode-custom"}),e.jsx(a.Label,{htmlFor:"mode-custom",className:"cursor-pointer font-medium",children:"Use custom settings"})]})]}),e.jsxs("div",{className:a.cn("space-y-6 transition-opacity",m&&"opacity-50 pointer-events-none"),children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(a.Label,{children:"Timezone"}),e.jsxs(a.Popover,{open:T,onOpenChange:N,modal:!0,children:[e.jsx(a.PopoverTrigger,{asChild:!0,children:e.jsxs(a.Button,{variant:"outline",role:"combobox","aria-expanded":T,className:"w-full justify-between",disabled:m,children:[P,e.jsx(a.ChevronsUpDown,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]})}),e.jsx(a.PopoverContent,{className:"z-50 w-[--radix-popover-trigger-width] p-0",align:"start",children:e.jsxs(a.Command,{className:"overflow-visible",children:[e.jsx(a.CommandInput,{placeholder:"Search timezones..."}),e.jsxs(a.CommandList,{children:[e.jsx(a.CommandEmpty,{children:"No timezone found."}),e.jsx(a.CommandGroup,{heading:"Common",children:A.map(t=>e.jsxs(a.CommandItem,{value:`${t.value} ${t.label}`,onSelect:()=>{c(!0),w(t.value),N(!1)},children:[e.jsx(a.Check,{className:a.cn("mr-2 h-4 w-4",x===t.value?"opacity-100":"opacity-0")}),e.jsx("span",{className:"flex-1",children:t.label}),e.jsx("span",{className:"text-xs text-muted-foreground",children:t.value})]},t.value))}),e.jsx(a.CommandSeparator,{}),e.jsx(a.CommandGroup,{heading:"All Timezones",children:I.map(t=>e.jsxs(a.CommandItem,{value:t,onSelect:()=>{c(!0),w(t),N(!1)},children:[e.jsx(a.Check,{className:a.cn("mr-2 h-4 w-4",x===t?"opacity-100":"opacity-0")}),t]},t))})]})]})})]})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx(a.Label,{children:"Week Starts On"}),e.jsx(a.RadioGroup,{value:String(k),onValueChange:t=>{c(!0),b(Number(t))},className:"flex gap-4",disabled:m,children:H.map(t=>e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(a.RadioGroupItem,{value:String(t.value),id:`week-start-${t.value}`,disabled:m}),e.jsx(a.Label,{htmlFor:`week-start-${t.value}`,className:a.cn("cursor-pointer font-normal",m&&"cursor-not-allowed"),children:t.label})]},t.value))})]})]})]}),e.jsxs(a.DialogFooter,{children:[e.jsx(a.Button,{variant:"outline",onClick:$,disabled:L,children:"Cancel"}),e.jsx(a.Button,{onClick:h,disabled:O,children:L?e.jsxs(e.Fragment,{children:[e.jsx(a.LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin"}),"Saving..."]}):"Save"})]})]})})}const E=6,B=1,_=20;function Z(r){return Number.isNaN(r)?E:Math.min(_,Math.max(B,r))}function J({open:r,onOpenChange:o,dashboard:s,onApply:v,disabled:d=!1}){const[f,y]=l.useState(!1),[g,S]=l.useState("top"),[p,m]=l.useState(String(E)),n=s.summary;l.useEffect(()=>{r&&(y((n==null?void 0:n.enabled)===!0),S((n==null?void 0:n.position)==="bottom"?"bottom":"top"),m(String((n==null?void 0:n.maxItems)??E)))},[r,n==null?void 0:n.enabled,n==null?void 0:n.position,n==null?void 0:n.maxItems]);const j=l.useMemo(()=>Z(Number.parseInt(p||`${E}`,10)),[p]),c=()=>{v({enabled:f,position:g,maxItems:j}),o(!1)};return e.jsx(a.Dialog,{open:r,onOpenChange:o,children:e.jsxs(a.DialogContent,{className:"sm:max-w-[420px]",children:[e.jsxs(a.DialogHeader,{children:[e.jsx(a.DialogTitle,{children:"Summary Settings"}),e.jsx(a.DialogDescription,{children:"Configure dashboard-level summary display. Card-level summary settings still control which cards contribute."})]}),e.jsxs("div",{className:"space-y-4 py-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(a.Label,{htmlFor:"dashboard-summary-enabled",children:"Enable Dashboard Summary"}),e.jsx(a.Switch,{size:"sm",id:"dashboard-summary-enabled",checked:f,disabled:d,onCheckedChange:y})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(a.Label,{htmlFor:"dashboard-summary-position",children:"Position"}),e.jsxs(a.Select,{value:g,disabled:d,onValueChange:x=>S(x),children:[e.jsx(a.SelectTrigger,{id:"dashboard-summary-position",children:e.jsx(a.SelectValue,{placeholder:"Select position"})}),e.jsxs(a.SelectContent,{children:[e.jsx(a.SelectItem,{value:"top",children:"Top"}),e.jsx(a.SelectItem,{value:"bottom",children:"Bottom"})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(a.Label,{htmlFor:"dashboard-summary-max-items",children:"Max Items"}),e.jsx(a.Input,{id:"dashboard-summary-max-items",type:"number",min:B,max:_,disabled:d,value:p,onChange:x=>m(x.target.value),onBlur:()=>m(String(j))}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Display limit only. Computation is unchanged."})]}),d&&e.jsx("p",{className:"text-xs text-amber-700",children:"Enter dashboard edit mode to modify summary settings."})]}),e.jsxs(a.DialogFooter,{children:[e.jsx(a.Button,{variant:"outline",onClick:()=>o(!1),children:"Cancel"}),e.jsx(a.Button,{onClick:c,disabled:d,children:"Apply"})]})]})})}exports.CalendarPreferencesDialog=q;exports.DashboardSummarySettingsDialog=J;
|
|
1
|
+
"use strict";const e=require("react/jsx-runtime"),l=require("react"),a=require("./index-BQ6qu8FI.js");function W(r={}){var C,I,P,D;const{authToken:o,tokenProps:s}=a.useSemaphorContext(),v=r.enabled??!0,d=(o==null?void 0:o.accessToken)??null,f=(s==null?void 0:s.apiServiceUrl)??null,[y,g]=l.useState(!1),[S,p]=l.useState(!1),[m,n]=l.useState(!1),[j,c]=l.useState(null),[x,w]=l.useState(null),k=x||{tz:((I=(C=s==null?void 0:s.params)==null?void 0:C.calendarContext)==null?void 0:I.tz)||null,weekStart:((D=(P=s==null?void 0:s.params)==null?void 0:P.calendarContext)==null?void 0:D.weekStart)??null},b=l.useCallback(async()=>{if(!(!v||!d||!f)){g(!0),c(null);try{const u=await fetch(`${f}/v1/user-preferences/calendar`,{method:"GET",headers:{Authorization:`Bearer ${d}`}});if(!u.ok){const h=await u.json().catch(()=>({}));throw new Error(h.error||"Failed to fetch preferences")}const i=await u.json();w({tz:i.tz,weekStart:i.weekStart,source:i.source,isInherited:i.isInherited,userHasPrefs:i.userHasPrefs,inherited:i.inherited})}catch(u){const i=u instanceof Error?u.message:"Unknown error";c(i)}finally{g(!1)}}},[d,f,v]);l.useEffect(()=>{v&&b()},[v,b]);const T=l.useCallback(async u=>{if(!d||!f)return c("Not authenticated"),!1;p(!0),c(null);try{const i=await fetch(`${f}/v1/user-preferences/calendar`,{method:"PATCH",headers:{"Content-Type":"application/json",Authorization:`Bearer ${d}`},body:JSON.stringify(u)});if(!i.ok){const h=await i.json().catch(()=>({}));throw new Error(h.error||"Failed to update preferences")}return await b(),!0}catch(i){const h=i instanceof Error?i.message:"Unknown error";return c(h),!1}finally{p(!1)}},[d,f,b]),N=l.useCallback(async()=>{if(!d||!f)return c("Not authenticated"),!1;n(!0),c(null);try{const u=await fetch(`${f}/v1/user-preferences/calendar`,{method:"DELETE",headers:{Authorization:`Bearer ${d}`}});if(!u.ok){const h=await u.json().catch(()=>({}));throw new Error(h.error||"Failed to clear preferences")}const i=await u.text();if(i)try{const h=JSON.parse(i);return w({tz:h.tz,weekStart:h.weekStart,source:h.source,isInherited:h.isInherited??!0,userHasPrefs:!1,inherited:h.inherited}),!0}catch{}return await b(),!0}catch(u){const i=u instanceof Error?u.message:"Unknown error";return c(i),!1}finally{n(!1)}},[d,f,b]);return{preferences:k,isLoading:y,isSaving:S,isClearing:m,error:j,updatePreferences:T,clearPreferences:N,refetch:b}}const A=[{value:"America/New_York",label:"Eastern Time (US & Canada)"},{value:"America/Chicago",label:"Central Time (US & Canada)"},{value:"America/Denver",label:"Mountain Time (US & Canada)"},{value:"America/Los_Angeles",label:"Pacific Time (US & Canada)"},{value:"America/Phoenix",label:"Arizona"},{value:"America/Anchorage",label:"Alaska"},{value:"Pacific/Honolulu",label:"Hawaii"},{value:"Europe/London",label:"London"},{value:"Europe/Paris",label:"Paris, Berlin, Rome"},{value:"Asia/Tokyo",label:"Tokyo"},{value:"Asia/Shanghai",label:"Beijing, Shanghai"},{value:"Asia/Kolkata",label:"Mumbai, New Delhi"},{value:"Australia/Sydney",label:"Sydney"},{value:"UTC",label:"UTC"}],H=[{value:0,label:"Sunday"},{value:1,label:"Monday"},{value:6,label:"Saturday"}];function G(){try{const r=Intl;if(r.supportedValuesOf)return r.supportedValuesOf("timeZone")}catch{}return A.map(r=>r.value)}function V(r){switch(r){case"tenant":return"tenant";case"organization":return"organization";case"system":return"system";default:return"default"}}function U(r){const o=A.find(s=>s.value===r);return o?o.label:r}function X(r){const o=H.find(s=>s.value===r);return o?o.label:String(r)}function q({open:r,onOpenChange:o}){var M,z,F;const{preferences:s,isLoading:v,isSaving:d,isClearing:f,updatePreferences:y,clearPreferences:g}=W({enabled:r}),S=s.tz||((M=s.inherited)==null?void 0:M.tz)||Intl.DateTimeFormat().resolvedOptions().timeZone,p=s.weekStart??((z=s.inherited)==null?void 0:z.weekStart)??1,[m,n]=l.useState(!s.userHasPrefs),[j,c]=l.useState(!1),[x,w]=l.useState(S),[k,b]=l.useState(p),[T,N]=l.useState(!1),C=l.useMemo(()=>G(),[]),I=l.useMemo(()=>C.filter(t=>!A.some(R=>R.value===t)),[C]),P=l.useMemo(()=>U(x),[x]),D=s.inherited?U(s.inherited.tz):"UTC",u=s.inherited?X(s.inherited.weekStart):"Monday",i=V((F=s.inherited)==null?void 0:F.source);l.useEffect(()=>{if(!r){c(!1);return}j||(s.userHasPrefs!==void 0&&n(!s.userHasPrefs),w(S),b(p))},[r,j,s.userHasPrefs,S,p]);const h=async()=>{if(v){a.ue.error("Preferences are still loading. Please try again.");return}m?await g()?(a.ue.success("Now using default settings. Please refresh the page to apply changes.",{duration:5e3}),o(!1)):a.ue.error("Failed to save preferences. Please try again."):await y({tz:x,weekStart:k})?(a.ue.success("Preferences saved. Please refresh the page to apply changes.",{duration:5e3}),o(!1)):a.ue.error("Failed to save preferences. Please try again.")},$=()=>{o(!1)},L=d||f,O=L||v;return e.jsx(a.Dialog,{open:r,onOpenChange:o,children:e.jsxs(a.DialogContent,{className:"sm:max-w-[425px]",children:[e.jsxs(a.DialogHeader,{children:[e.jsx(a.DialogTitle,{children:"Calendar Preferences"}),e.jsx(a.DialogDescription,{children:"Set your timezone and week start preferences for date calculations and displays."})]}),e.jsxs("div",{className:"space-y-6 py-4",children:[e.jsxs(a.RadioGroup,{value:m?"defaults":"custom",onValueChange:t=>{c(!0),n(t==="defaults")},className:"space-y-3",children:[e.jsxs("div",{className:a.cn("flex items-start space-x-3 rounded-lg border p-4 cursor-pointer transition-colors",m?"border-primary bg-primary/5":"border-border hover:border-muted-foreground/50"),onClick:()=>{c(!0),n(!0)},children:[e.jsx(a.RadioGroupItem,{value:"defaults",id:"mode-defaults"}),e.jsxs("div",{className:"flex-1 space-y-1",children:[e.jsxs(a.Label,{htmlFor:"mode-defaults",className:"cursor-pointer font-medium",children:["Use ",i," defaults"]}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:[D,", Week starts ",u]})]})]}),e.jsxs("div",{className:a.cn("flex items-start space-x-3 rounded-lg border p-4 cursor-pointer transition-colors",m?"border-border hover:border-muted-foreground/50":"border-primary bg-primary/5"),onClick:()=>{c(!0),n(!1)},children:[e.jsx(a.RadioGroupItem,{value:"custom",id:"mode-custom"}),e.jsx(a.Label,{htmlFor:"mode-custom",className:"cursor-pointer font-medium",children:"Use custom settings"})]})]}),e.jsxs("div",{className:a.cn("space-y-6 transition-opacity",m&&"opacity-50 pointer-events-none"),children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(a.Label,{children:"Timezone"}),e.jsxs(a.Popover,{open:T,onOpenChange:N,modal:!0,children:[e.jsx(a.PopoverTrigger,{asChild:!0,children:e.jsxs(a.Button,{variant:"outline",role:"combobox","aria-expanded":T,className:"w-full justify-between",disabled:m,children:[P,e.jsx(a.ChevronsUpDown,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]})}),e.jsx(a.PopoverContent,{className:"z-50 w-[--radix-popover-trigger-width] p-0",align:"start",children:e.jsxs(a.Command,{className:"overflow-visible",children:[e.jsx(a.CommandInput,{placeholder:"Search timezones..."}),e.jsxs(a.CommandList,{children:[e.jsx(a.CommandEmpty,{children:"No timezone found."}),e.jsx(a.CommandGroup,{heading:"Common",children:A.map(t=>e.jsxs(a.CommandItem,{value:`${t.value} ${t.label}`,onSelect:()=>{c(!0),w(t.value),N(!1)},children:[e.jsx(a.Check,{className:a.cn("mr-2 h-4 w-4",x===t.value?"opacity-100":"opacity-0")}),e.jsx("span",{className:"flex-1",children:t.label}),e.jsx("span",{className:"text-xs text-muted-foreground",children:t.value})]},t.value))}),e.jsx(a.CommandSeparator,{}),e.jsx(a.CommandGroup,{heading:"All Timezones",children:I.map(t=>e.jsxs(a.CommandItem,{value:t,onSelect:()=>{c(!0),w(t),N(!1)},children:[e.jsx(a.Check,{className:a.cn("mr-2 h-4 w-4",x===t?"opacity-100":"opacity-0")}),t]},t))})]})]})})]})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx(a.Label,{children:"Week Starts On"}),e.jsx(a.RadioGroup,{value:String(k),onValueChange:t=>{c(!0),b(Number(t))},className:"flex gap-4",disabled:m,children:H.map(t=>e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(a.RadioGroupItem,{value:String(t.value),id:`week-start-${t.value}`,disabled:m}),e.jsx(a.Label,{htmlFor:`week-start-${t.value}`,className:a.cn("cursor-pointer font-normal",m&&"cursor-not-allowed"),children:t.label})]},t.value))})]})]})]}),e.jsxs(a.DialogFooter,{children:[e.jsx(a.Button,{variant:"outline",onClick:$,disabled:L,children:"Cancel"}),e.jsx(a.Button,{onClick:h,disabled:O,children:L?e.jsxs(e.Fragment,{children:[e.jsx(a.LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin"}),"Saving..."]}):"Save"})]})]})})}const E=6,B=1,_=20;function Z(r){return Number.isNaN(r)?E:Math.min(_,Math.max(B,r))}function J({open:r,onOpenChange:o,dashboard:s,onApply:v,disabled:d=!1}){const[f,y]=l.useState(!1),[g,S]=l.useState("top"),[p,m]=l.useState(String(E)),n=s.summary;l.useEffect(()=>{r&&(y((n==null?void 0:n.enabled)===!0),S((n==null?void 0:n.position)==="bottom"?"bottom":"top"),m(String((n==null?void 0:n.maxItems)??E)))},[r,n==null?void 0:n.enabled,n==null?void 0:n.position,n==null?void 0:n.maxItems]);const j=l.useMemo(()=>Z(Number.parseInt(p||`${E}`,10)),[p]),c=()=>{v({enabled:f,position:g,maxItems:j}),o(!1)};return e.jsx(a.Dialog,{open:r,onOpenChange:o,children:e.jsxs(a.DialogContent,{className:"sm:max-w-[420px]",children:[e.jsxs(a.DialogHeader,{children:[e.jsx(a.DialogTitle,{children:"Summary Settings"}),e.jsx(a.DialogDescription,{children:"Configure dashboard-level summary display. Card-level summary settings still control which cards contribute."})]}),e.jsxs("div",{className:"space-y-4 py-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(a.Label,{htmlFor:"dashboard-summary-enabled",children:"Enable Dashboard Summary"}),e.jsx(a.Switch,{size:"sm",id:"dashboard-summary-enabled",checked:f,disabled:d,onCheckedChange:y})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(a.Label,{htmlFor:"dashboard-summary-position",children:"Position"}),e.jsxs(a.Select,{value:g,disabled:d,onValueChange:x=>S(x),children:[e.jsx(a.SelectTrigger,{id:"dashboard-summary-position",children:e.jsx(a.SelectValue,{placeholder:"Select position"})}),e.jsxs(a.SelectContent,{children:[e.jsx(a.SelectItem,{value:"top",children:"Top"}),e.jsx(a.SelectItem,{value:"bottom",children:"Bottom"})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(a.Label,{htmlFor:"dashboard-summary-max-items",children:"Max Items"}),e.jsx(a.Input,{id:"dashboard-summary-max-items",type:"number",min:B,max:_,disabled:d,value:p,onChange:x=>m(x.target.value),onBlur:()=>m(String(j))}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Display limit only. Computation is unchanged."})]}),d&&e.jsx("p",{className:"text-xs text-amber-700",children:"Enter dashboard edit mode to modify summary settings."})]}),e.jsxs(a.DialogFooter,{children:[e.jsx(a.Button,{variant:"outline",onClick:()=>o(!1),children:"Cancel"}),e.jsx(a.Button,{onClick:c,disabled:d,children:"Apply"})]})]})})}exports.CalendarPreferencesDialog=q;exports.DashboardSummarySettingsDialog=J;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx as e, jsxs as a, Fragment as ce } from "react/jsx-runtime";
|
|
2
2
|
import de, { useState as f, useCallback as j, useEffect as K, useMemo as F } from "react";
|
|
3
|
-
import {
|
|
3
|
+
import { d as ue, e as q, f as Y, g as Q, h as ee, i as ae, R, b as C, j as $, L as y, P as me, k as he, B as E, l as fe, m as pe, n as ve, o as be, p as Se, q as ge, r as V, s as G, t as X, v as ye, w as re, x as we, y as P, S as xe, z as Ne, A as ke, E as Ce, F as Te, G as Z, I as Ie } from "./index-72yod5pb.js";
|
|
4
4
|
function Pe(s = {}) {
|
|
5
5
|
var I, D, M, L;
|
|
6
6
|
const { authToken: i, tokenProps: r } = ue(), S = s.enabled ?? !0, o = (i == null ? void 0 : i.accessToken) ?? null, h = (r == null ? void 0 : r.apiServiceUrl) ?? null, [N, w] = f(!1), [g, v] = f(!1), [u, n] = f(!1), [x, c] = f(null), [p, k] = f(null), A = p || {
|