react-semaphor 0.1.282 → 0.1.284
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chunks/{dashboard-controls-XX9__V-e.js → dashboard-controls-4pDdG3me.js} +1 -1
- package/dist/chunks/{dashboard-controls-B_F5f_BF.js → dashboard-controls-Dhry2k8x.js} +102 -102
- package/dist/chunks/{dashboard-filter-controls-button-DVLBLHga.js → dashboard-filter-controls-button-BZXrmJP2.js} +115 -103
- package/dist/chunks/{dashboard-filter-controls-button-DZpvfXwU.js → dashboard-filter-controls-button-DEUvxIWD.js} +2 -2
- package/dist/chunks/dashboard-json-CYnf5rdp.js +1 -0
- package/dist/chunks/dashboard-json-D-KsLEGl.js +61 -0
- package/dist/chunks/{dashboard-summary-settings-dialog-zdacBYZZ.js → dashboard-summary-settings-dialog-B4jsBFro.js} +15 -15
- package/dist/chunks/{dashboard-summary-settings-dialog-BjdrHb1l.js → dashboard-summary-settings-dialog-Cn4-fB2h.js} +1 -1
- package/dist/chunks/{edit-dashboard-visual-DQts3aun.js → edit-dashboard-visual-BDIt_S2F.js} +4978 -5049
- package/dist/chunks/edit-dashboard-visual-BQnApBvr.js +193 -0
- package/dist/chunks/{index-BY0YEY92.js → index-DBuN9Zf6.js} +281 -250
- package/dist/chunks/{index-Bgn4zTsp.js → index-y1uW2fuZ.js} +29740 -28419
- package/dist/chunks/{resource-management-panel--xIMLPdz.js → resource-management-panel-BC-cvjI9.js} +2 -2
- package/dist/chunks/{resource-management-panel-w7afzaPB.js → resource-management-panel-PSvKnmq5.js} +1 -1
- package/dist/chunks/use-create-flow-overlay-state-COe7Ekru.js +21 -0
- package/dist/chunks/use-create-flow-overlay-state-Cr9AFdXx.js +1597 -0
- package/dist/chunks/use-visual-utils-Ccmzx7-m.js +353 -0
- package/dist/chunks/use-visual-utils-DNp8XO6G.js +1 -0
- package/dist/dashboard/index.cjs +1 -1
- package/dist/dashboard/index.js +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.js +5 -5
- package/dist/style.css +1 -1
- package/dist/surfboard/index.cjs +1 -1
- package/dist/surfboard/index.js +2 -2
- package/package.json +3 -2
- package/dist/chunks/dashboard-json-CexNQg-E.js +0 -1
- package/dist/chunks/dashboard-json-Dd9Q2bZm.js +0 -66
- package/dist/chunks/edit-dashboard-visual-Bi9pQx6G.js +0 -193
- package/dist/chunks/use-create-flow-overlay-state-AsQy4tbh.js +0 -21
- package/dist/chunks/use-create-flow-overlay-state-COsIHnQp.js +0 -1523
- package/dist/chunks/use-visual-utils-BCWNcaWk.js +0 -347
- package/dist/chunks/use-visual-utils-CI-7TNJI.js +0 -1
|
@@ -0,0 +1,1597 @@
|
|
|
1
|
+
import { bM as le, U as L, bN as Ke, bO as pt, bP as mt, bQ as ft, bR as ht, bS as bt, u as De, af as gt, bT as yt, bU as xt, bV as vt, ac as Ct, c as A, bW as kt, bX as Nt, B as q, s as St, H as ne, N as Ye, J as He, bY as Xe, w as Pe, M as Ne, bZ as Ge, X as Je, x as O, b_ as Dt, b$ as wt, c0 as ae, c1 as Fe, c2 as ze, c3 as fe, c4 as he, c5 as Tt, c6 as Ae, c7 as Vt, c8 as It, c9 as re, ca as qt, cb as Me, cc as Et, a6 as Oe, cd as Be, ce as We, cf as Ze, cg as et, ch as _t, L as H, I as tt, y as be, z as ge, A as ye, E as xe, F as ve, ci as at, cj as Lt, ck as Ft, cl as rt, cm as st, cn as zt, co as At, cp as Mt, cq as Ot, cr as Bt, cs as Qt, ct as jt, cu as Qe, cv as Rt, cw as je, cx as Ut, cy as Ce, cz as $t } from "./index-y1uW2fuZ.js";
|
|
2
|
+
import { jsx as t, jsxs as d, Fragment as $ } from "react/jsx-runtime";
|
|
3
|
+
import { useMemo as z, useState as B, useRef as ke, useCallback as M, useEffect as Se, Fragment as Kt } from "react";
|
|
4
|
+
import { u as we } from "./use-visual-utils-Ccmzx7-m.js";
|
|
5
|
+
/**
|
|
6
|
+
* @license lucide-react v0.453.0 - ISC
|
|
7
|
+
*
|
|
8
|
+
* This source code is licensed under the ISC license.
|
|
9
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
10
|
+
*/
|
|
11
|
+
const ra = le("CircleX", [
|
|
12
|
+
["circle", { cx: "12", cy: "12", r: "10", key: "1mglay" }],
|
|
13
|
+
["path", { d: "m15 9-6 6", key: "1uzhvr" }],
|
|
14
|
+
["path", { d: "m9 9 6 6", key: "z0biqf" }]
|
|
15
|
+
]);
|
|
16
|
+
/**
|
|
17
|
+
* @license lucide-react v0.453.0 - ISC
|
|
18
|
+
*
|
|
19
|
+
* This source code is licensed under the ISC license.
|
|
20
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
21
|
+
*/
|
|
22
|
+
const Yt = le("Library", [
|
|
23
|
+
["path", { d: "m16 6 4 14", key: "ji33uf" }],
|
|
24
|
+
["path", { d: "M12 6v14", key: "1n7gus" }],
|
|
25
|
+
["path", { d: "M8 8v12", key: "1gg7y9" }],
|
|
26
|
+
["path", { d: "M4 4v16", key: "6qkkli" }]
|
|
27
|
+
]);
|
|
28
|
+
/**
|
|
29
|
+
* @license lucide-react v0.453.0 - ISC
|
|
30
|
+
*
|
|
31
|
+
* This source code is licensed under the ISC license.
|
|
32
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
33
|
+
*/
|
|
34
|
+
const Ht = le("Link2", [
|
|
35
|
+
["path", { d: "M9 17H7A5 5 0 0 1 7 7h2", key: "8i5ue5" }],
|
|
36
|
+
["path", { d: "M15 7h2a5 5 0 1 1 0 10h-2", key: "1b9ql8" }],
|
|
37
|
+
["line", { x1: "8", x2: "16", y1: "12", y2: "12", key: "1jonct" }]
|
|
38
|
+
]);
|
|
39
|
+
/**
|
|
40
|
+
* @license lucide-react v0.453.0 - ISC
|
|
41
|
+
*
|
|
42
|
+
* This source code is licensed under the ISC license.
|
|
43
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
44
|
+
*/
|
|
45
|
+
const lt = le("Save", [
|
|
46
|
+
[
|
|
47
|
+
"path",
|
|
48
|
+
{
|
|
49
|
+
d: "M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z",
|
|
50
|
+
key: "1c8476"
|
|
51
|
+
}
|
|
52
|
+
],
|
|
53
|
+
["path", { d: "M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7", key: "1ydtos" }],
|
|
54
|
+
["path", { d: "M7 3v4a1 1 0 0 0 1 1h7", key: "t51u73" }]
|
|
55
|
+
]);
|
|
56
|
+
function nt() {
|
|
57
|
+
var h, C;
|
|
58
|
+
const s = L((x) => x.card), r = L((x) => x.frame), o = z(
|
|
59
|
+
() => Ke(r, s),
|
|
60
|
+
[r, s]
|
|
61
|
+
), { manifest: i } = pt(
|
|
62
|
+
((h = o == null ? void 0 : o.customCardPreferences) == null ? void 0 : h.url) || ""
|
|
63
|
+
), f = z(
|
|
64
|
+
() => {
|
|
65
|
+
var x;
|
|
66
|
+
return (x = i == null ? void 0 : i.visuals) == null ? void 0 : x.find(
|
|
67
|
+
(m) => {
|
|
68
|
+
var g;
|
|
69
|
+
return m.name === ((g = o == null ? void 0 : o.customCardPreferences) == null ? void 0 : g.componentName);
|
|
70
|
+
}
|
|
71
|
+
);
|
|
72
|
+
},
|
|
73
|
+
[i, (C = o == null ? void 0 : o.customCardPreferences) == null ? void 0 : C.componentName]
|
|
74
|
+
), u = mt(o, f), b = z(
|
|
75
|
+
() => ft({
|
|
76
|
+
frame: r,
|
|
77
|
+
configCard: o,
|
|
78
|
+
isMultiInputVisual: u === "multiple"
|
|
79
|
+
}),
|
|
80
|
+
[r, o, u]
|
|
81
|
+
), v = z(() => {
|
|
82
|
+
const x = b.findIndex(
|
|
83
|
+
(m) => (m == null ? void 0 : m.id) === s.id
|
|
84
|
+
);
|
|
85
|
+
return x < 0 ? -1 : ht(s, x);
|
|
86
|
+
}, [b, s]);
|
|
87
|
+
return z(() => !o || u !== "multiple" || v < 0 ? s.type : bt(
|
|
88
|
+
s,
|
|
89
|
+
v,
|
|
90
|
+
f == null ? void 0 : f.slots
|
|
91
|
+
) ?? s.type, [o, u, v, s, f == null ? void 0 : f.slots]);
|
|
92
|
+
}
|
|
93
|
+
function sa({
|
|
94
|
+
type: s,
|
|
95
|
+
isLinked: r,
|
|
96
|
+
className: o,
|
|
97
|
+
showLabel: i = !1,
|
|
98
|
+
showLocal: f = !1
|
|
99
|
+
}) {
|
|
100
|
+
const u = De((I) => I.selectedFrameId), b = gt((I) => I.selectedVisual), v = L((I) => I.frame);
|
|
101
|
+
let h;
|
|
102
|
+
if (s)
|
|
103
|
+
h = s;
|
|
104
|
+
else if (r !== void 0)
|
|
105
|
+
h = r ? "linked" : "library";
|
|
106
|
+
else if (!!!(v != null && v.visualId || b != null && b.id) && u)
|
|
107
|
+
h = "local";
|
|
108
|
+
else if (b && !u)
|
|
109
|
+
h = "library";
|
|
110
|
+
else if (v != null && v.visualId && u)
|
|
111
|
+
h = "linked";
|
|
112
|
+
else if (b != null && b.id && u)
|
|
113
|
+
h = "library";
|
|
114
|
+
else
|
|
115
|
+
return null;
|
|
116
|
+
if (h === "local" && !f)
|
|
117
|
+
return null;
|
|
118
|
+
const C = {
|
|
119
|
+
local: "border-slate-200/70 bg-slate-50/80 text-slate-700 shadow-sm hover:bg-slate-100/80 dark:border-slate-700 dark:bg-slate-900/70 dark:text-slate-200 dark:hover:bg-slate-800/80",
|
|
120
|
+
linked: "border-purple-200/70 bg-gradient-to-r from-purple-50/50 to-purple-100/30 text-purple-900 shadow-sm hover:from-purple-100/60 hover:to-purple-100/50 hover:shadow-md dark:border-purple-800/50 dark:from-purple-950/40 dark:to-purple-900/30 dark:text-purple-100 dark:hover:from-purple-950/60 dark:hover:to-purple-900/50",
|
|
121
|
+
library: "border-blue-200/70 bg-gradient-to-r from-blue-50/50 to-blue-100/30 text-blue-900 shadow-sm hover:from-blue-100/60 hover:to-blue-100/50 hover:shadow-md dark:border-blue-800/50 dark:from-blue-950/40 dark:to-blue-900/30 dark:text-blue-100 dark:hover:from-blue-950/60 dark:hover:to-blue-900/50"
|
|
122
|
+
}, x = {
|
|
123
|
+
local: "Local to this dashboard: Changes made here only affect this dashboard copy.",
|
|
124
|
+
linked: "Linked to library: Changes made here update the library visual and all linked instances.",
|
|
125
|
+
library: "Library visual: Share and reuse this visual across multiple dashboards."
|
|
126
|
+
}, m = {
|
|
127
|
+
local: "border-slate-200 bg-slate-50 text-slate-900 dark:border-slate-700 dark:bg-slate-900 dark:text-slate-100",
|
|
128
|
+
linked: "border-purple-200 bg-purple-50 text-purple-900 dark:border-purple-800 dark:bg-purple-950 dark:text-purple-100",
|
|
129
|
+
library: "border-blue-200 bg-blue-50 text-blue-900 dark:border-blue-800 dark:bg-blue-950 dark:text-blue-100"
|
|
130
|
+
}, g = {
|
|
131
|
+
local: "fill-slate-50 dark:fill-slate-900",
|
|
132
|
+
linked: "fill-purple-50 dark:fill-purple-950",
|
|
133
|
+
library: "fill-blue-50 dark:fill-blue-950"
|
|
134
|
+
}, N = {
|
|
135
|
+
local: /* @__PURE__ */ t("span", { className: "h-2 w-2 rounded-full bg-current/70" }),
|
|
136
|
+
linked: /* @__PURE__ */ t(Ht, { className: "h-3.5 w-3.5" }),
|
|
137
|
+
library: /* @__PURE__ */ t(Yt, { className: "h-3.5 w-3.5" })
|
|
138
|
+
}, V = {
|
|
139
|
+
local: "Local",
|
|
140
|
+
linked: "Linked",
|
|
141
|
+
library: "Library"
|
|
142
|
+
};
|
|
143
|
+
return /* @__PURE__ */ t(yt, { children: /* @__PURE__ */ d(xt, { delayDuration: 300, children: [
|
|
144
|
+
/* @__PURE__ */ t(vt, { asChild: !0, children: /* @__PURE__ */ d(
|
|
145
|
+
Ct,
|
|
146
|
+
{
|
|
147
|
+
variant: "outline",
|
|
148
|
+
className: A(
|
|
149
|
+
"cursor-help select-none transition-all",
|
|
150
|
+
C[h],
|
|
151
|
+
o
|
|
152
|
+
),
|
|
153
|
+
children: [
|
|
154
|
+
N[h],
|
|
155
|
+
i && /* @__PURE__ */ t("span", { className: "ml-1 text-xs font-medium leading-none", children: V[h] })
|
|
156
|
+
]
|
|
157
|
+
}
|
|
158
|
+
) }),
|
|
159
|
+
/* @__PURE__ */ d(
|
|
160
|
+
kt,
|
|
161
|
+
{
|
|
162
|
+
side: "bottom",
|
|
163
|
+
className: A("max-w-xs", m[h]),
|
|
164
|
+
children: [
|
|
165
|
+
/* @__PURE__ */ t(Nt, { className: g[h] }),
|
|
166
|
+
/* @__PURE__ */ t("p", { children: x[h] })
|
|
167
|
+
]
|
|
168
|
+
}
|
|
169
|
+
)
|
|
170
|
+
] }) });
|
|
171
|
+
}
|
|
172
|
+
function Xt(s, r) {
|
|
173
|
+
return {
|
|
174
|
+
...s,
|
|
175
|
+
sql: "",
|
|
176
|
+
python: "",
|
|
177
|
+
config: void 0,
|
|
178
|
+
customCfg: "",
|
|
179
|
+
preferences: {},
|
|
180
|
+
interactionConfig: void 0,
|
|
181
|
+
linkedInteractionTargetOverrides: void 0,
|
|
182
|
+
dynamicCardPreferences: void 0,
|
|
183
|
+
customCardPreferences: r ? s.customCardPreferences : void 0,
|
|
184
|
+
visualizationMode: "builtin",
|
|
185
|
+
type: r ? s.type : "bar"
|
|
186
|
+
};
|
|
187
|
+
}
|
|
188
|
+
function Te(s) {
|
|
189
|
+
const r = Dt(s);
|
|
190
|
+
return r ? (O.error(r), !1) : !0;
|
|
191
|
+
}
|
|
192
|
+
function la({
|
|
193
|
+
className: s,
|
|
194
|
+
variant: r = "outline"
|
|
195
|
+
}) {
|
|
196
|
+
const o = L((u) => u.onSave), { getUpdatedFrame: i } = we();
|
|
197
|
+
function f() {
|
|
198
|
+
const u = i();
|
|
199
|
+
Te(u) && (o == null || o(u));
|
|
200
|
+
}
|
|
201
|
+
return /* @__PURE__ */ d(
|
|
202
|
+
q,
|
|
203
|
+
{
|
|
204
|
+
onClick: f,
|
|
205
|
+
className: A("h-8", s),
|
|
206
|
+
size: "sm",
|
|
207
|
+
variant: r,
|
|
208
|
+
children: [
|
|
209
|
+
/* @__PURE__ */ t(St, { className: "mr-2 size-4 font-bold" }),
|
|
210
|
+
"Accept"
|
|
211
|
+
]
|
|
212
|
+
}
|
|
213
|
+
);
|
|
214
|
+
}
|
|
215
|
+
function na({
|
|
216
|
+
className: s,
|
|
217
|
+
variant: r = "default"
|
|
218
|
+
}) {
|
|
219
|
+
const o = ne(), [i, f] = B(!1), u = De(
|
|
220
|
+
(g) => g.actions.setIsDashboardPanelOpen
|
|
221
|
+
), { setIsVisualEditing: b } = Ye(), { getUpdatedFrame: v } = we(), h = He(), C = L((g) => g.frame), x = Xe();
|
|
222
|
+
return /* @__PURE__ */ d(
|
|
223
|
+
q,
|
|
224
|
+
{
|
|
225
|
+
onClick: () => {
|
|
226
|
+
const g = v();
|
|
227
|
+
if (!Te(g))
|
|
228
|
+
return;
|
|
229
|
+
const N = (C == null ? void 0 : C.visualId) || (h == null ? void 0 : h.id);
|
|
230
|
+
if (!N) {
|
|
231
|
+
O.error("No visual to save");
|
|
232
|
+
return;
|
|
233
|
+
}
|
|
234
|
+
f(!0), x.mutate(
|
|
235
|
+
{
|
|
236
|
+
visualId: N,
|
|
237
|
+
data: {
|
|
238
|
+
frameObject: g
|
|
239
|
+
}
|
|
240
|
+
},
|
|
241
|
+
{
|
|
242
|
+
onSuccess: () => {
|
|
243
|
+
f(!1), u(!0), O.success("Visual updated successfully"), o.invalidateQueries({
|
|
244
|
+
queryKey: ["resource-by-id", "visual", N],
|
|
245
|
+
exact: !0
|
|
246
|
+
});
|
|
247
|
+
},
|
|
248
|
+
onError: () => {
|
|
249
|
+
f(!1), O.error("Failed to update visual");
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
);
|
|
253
|
+
},
|
|
254
|
+
className: A("h-8", s),
|
|
255
|
+
size: "sm",
|
|
256
|
+
variant: r,
|
|
257
|
+
children: [
|
|
258
|
+
i && /* @__PURE__ */ d($, { children: [
|
|
259
|
+
/* @__PURE__ */ t(Pe, { className: "mr-2 size-4 animate-spin font-bold" }),
|
|
260
|
+
" Saving"
|
|
261
|
+
] }),
|
|
262
|
+
!i && /* @__PURE__ */ d($, { children: [
|
|
263
|
+
/* @__PURE__ */ t(lt, { className: "mr-2 size-4 font-bold" }),
|
|
264
|
+
"Save to Library"
|
|
265
|
+
] })
|
|
266
|
+
]
|
|
267
|
+
}
|
|
268
|
+
);
|
|
269
|
+
}
|
|
270
|
+
function oa({
|
|
271
|
+
className: s
|
|
272
|
+
}) {
|
|
273
|
+
const r = ne(), [o, i] = B(!1), f = He(), u = L((g) => g.frame), b = De((g) => g.selectedSheetId), { updateFrame: v, setIsVisualEditing: h } = Ye(), { getUpdatedFrame: C } = we(), x = Xe();
|
|
274
|
+
return /* @__PURE__ */ t(
|
|
275
|
+
q,
|
|
276
|
+
{
|
|
277
|
+
onClick: async () => {
|
|
278
|
+
if (!b) {
|
|
279
|
+
O.error("No sheet selected");
|
|
280
|
+
return;
|
|
281
|
+
}
|
|
282
|
+
const g = (u == null ? void 0 : u.visualId) || (f == null ? void 0 : f.id);
|
|
283
|
+
if (!g) {
|
|
284
|
+
O.error("No visual to update");
|
|
285
|
+
return;
|
|
286
|
+
}
|
|
287
|
+
i(!0);
|
|
288
|
+
try {
|
|
289
|
+
const N = C();
|
|
290
|
+
if (!Te(N)) {
|
|
291
|
+
i(!1);
|
|
292
|
+
return;
|
|
293
|
+
}
|
|
294
|
+
await x.mutateAsync({
|
|
295
|
+
visualId: g,
|
|
296
|
+
data: {
|
|
297
|
+
frameObject: N
|
|
298
|
+
}
|
|
299
|
+
});
|
|
300
|
+
const V = {
|
|
301
|
+
...N,
|
|
302
|
+
visualId: g
|
|
303
|
+
// Keep the link to library visual
|
|
304
|
+
};
|
|
305
|
+
v(b, V), r.invalidateQueries({ queryKey: ["visuals"] }), r.invalidateQueries({ queryKey: ["visual", g] }), O.success("Saved to library and applied locally"), setTimeout(() => {
|
|
306
|
+
h(!1);
|
|
307
|
+
}, 300);
|
|
308
|
+
} catch (N) {
|
|
309
|
+
console.error("Failed to save and apply:", N), O.error("Failed to save and apply changes");
|
|
310
|
+
} finally {
|
|
311
|
+
i(!1);
|
|
312
|
+
}
|
|
313
|
+
},
|
|
314
|
+
className: A("h-8", s),
|
|
315
|
+
size: "sm",
|
|
316
|
+
variant: "default",
|
|
317
|
+
disabled: o,
|
|
318
|
+
children: o ? /* @__PURE__ */ d($, { children: [
|
|
319
|
+
/* @__PURE__ */ t(Pe, { className: "mr-2 size-4 animate-spin font-bold" }),
|
|
320
|
+
" Saving..."
|
|
321
|
+
] }) : /* @__PURE__ */ d($, { children: [
|
|
322
|
+
/* @__PURE__ */ t(lt, { className: "mr-2 size-4 font-bold" }),
|
|
323
|
+
"Save & Apply"
|
|
324
|
+
] })
|
|
325
|
+
}
|
|
326
|
+
);
|
|
327
|
+
}
|
|
328
|
+
function ia({ className: s }) {
|
|
329
|
+
const { setTempQueryData: r, setSqlGen: o } = Ne(), i = ne(), f = L((m) => m.tempQueryData), u = L((m) => m.onClose), b = L((m) => m.card), v = nt(), h = z(() => v !== b.type ? { ...b, type: v } : b, [b, v]), { queryKey: C } = Ge(h);
|
|
330
|
+
function x() {
|
|
331
|
+
if (f) {
|
|
332
|
+
const { queryKey: m, queryData: g } = f;
|
|
333
|
+
m && g && i.setQueryData(m, g);
|
|
334
|
+
}
|
|
335
|
+
o({}), u == null || u();
|
|
336
|
+
}
|
|
337
|
+
return /* @__PURE__ */ d(
|
|
338
|
+
q,
|
|
339
|
+
{
|
|
340
|
+
onClick: x,
|
|
341
|
+
className: A("h-8", s),
|
|
342
|
+
size: "sm",
|
|
343
|
+
variant: "outline",
|
|
344
|
+
children: [
|
|
345
|
+
/* @__PURE__ */ t(Je, { className: "mr-2 size-4" }),
|
|
346
|
+
"Close"
|
|
347
|
+
]
|
|
348
|
+
}
|
|
349
|
+
);
|
|
350
|
+
}
|
|
351
|
+
function da({
|
|
352
|
+
label: s = "Clear",
|
|
353
|
+
variant: r = "secondary",
|
|
354
|
+
className: o
|
|
355
|
+
} = {}) {
|
|
356
|
+
const { setTempQueryData: i } = Ne(), f = ne(), u = L((a) => a.tempQueryData), b = L((a) => a.card), v = nt(), h = z(() => v !== b.type ? { ...b, type: v } : b, [b, v]), { queryKey: C } = Ge(h), {
|
|
357
|
+
setCardSql: x,
|
|
358
|
+
setSqlGen: m,
|
|
359
|
+
setCardPython: g,
|
|
360
|
+
setCardCustomCfg: N,
|
|
361
|
+
setCardPreferences: V,
|
|
362
|
+
clearQueryConfig: I,
|
|
363
|
+
setCardConfig: oe,
|
|
364
|
+
setCardType: ie,
|
|
365
|
+
setFrame: ee,
|
|
366
|
+
setCard: X,
|
|
367
|
+
setActiveTabCardId: de
|
|
368
|
+
} = Ne();
|
|
369
|
+
function K() {
|
|
370
|
+
var E, G, R, te;
|
|
371
|
+
const a = f.getQueryData(C);
|
|
372
|
+
u != null && u.queryData || i({
|
|
373
|
+
queryKey: C,
|
|
374
|
+
queryData: a
|
|
375
|
+
}), f.setQueryData(C, null), f.removeQueries({ queryKey: C, exact: !0 }), x(""), m({}), I(), oe(void 0), g(""), N(""), V({});
|
|
376
|
+
const S = L.getState().frame, Q = L.getState().card, T = Ke(S, Q), P = ((E = T == null ? void 0 : T.customCardPreferences) == null ? void 0 : E.visualType) === "multiple" || !!((G = T == null ? void 0 : T.customCardPreferences) != null && G.dataInputCardIds) || (((R = T == null ? void 0 : T.customCardPreferences) == null ? void 0 : R.minInputs) || 0) > 1 || (((te = T == null ? void 0 : T.customCardPreferences) == null ? void 0 : te.maxInputs) || 0) > 1, j = Xt(Q, P);
|
|
377
|
+
ee({
|
|
378
|
+
...S,
|
|
379
|
+
cards: S.cards.map(
|
|
380
|
+
(J) => J.id === j.id ? j : J
|
|
381
|
+
)
|
|
382
|
+
}), de(j.id), X(j), P || ie("bar");
|
|
383
|
+
}
|
|
384
|
+
return /* @__PURE__ */ d(
|
|
385
|
+
q,
|
|
386
|
+
{
|
|
387
|
+
onClick: K,
|
|
388
|
+
className: A("h-8", o),
|
|
389
|
+
size: "sm",
|
|
390
|
+
variant: r,
|
|
391
|
+
children: [
|
|
392
|
+
/* @__PURE__ */ t(Je, { className: "mr-2 size-3.5" }),
|
|
393
|
+
s
|
|
394
|
+
]
|
|
395
|
+
}
|
|
396
|
+
);
|
|
397
|
+
}
|
|
398
|
+
function ot(s) {
|
|
399
|
+
const { control: r, onChange: o } = s;
|
|
400
|
+
return /* @__PURE__ */ d("div", { className: "flex flex-col gap-1.5", children: [
|
|
401
|
+
/* @__PURE__ */ t(H, { className: "text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground", children: "Label" }),
|
|
402
|
+
/* @__PURE__ */ t(
|
|
403
|
+
tt,
|
|
404
|
+
{
|
|
405
|
+
size: "xs",
|
|
406
|
+
value: r.label,
|
|
407
|
+
placeholder: "Control label",
|
|
408
|
+
onChange: (i) => o(i.target.value)
|
|
409
|
+
}
|
|
410
|
+
)
|
|
411
|
+
] });
|
|
412
|
+
}
|
|
413
|
+
function Pt(s) {
|
|
414
|
+
const { currentStep: r, labels: o } = s;
|
|
415
|
+
return /* @__PURE__ */ t("div", { className: "sticky top-0 z-10 -mx-1 border-b border-border/60 bg-background/95 px-1 pb-2.5 pt-1 backdrop-blur supports-[backdrop-filter]:bg-background/85", children: /* @__PURE__ */ t("div", { className: "flex flex-wrap items-center gap-2 sm:gap-2.5", children: o.map((i, f) => {
|
|
416
|
+
const u = f + 1, b = u === r, v = u < r;
|
|
417
|
+
return /* @__PURE__ */ d(Kt, { children: [
|
|
418
|
+
/* @__PURE__ */ d("div", { className: "flex items-center gap-1.5", children: [
|
|
419
|
+
/* @__PURE__ */ t(
|
|
420
|
+
"span",
|
|
421
|
+
{
|
|
422
|
+
className: A(
|
|
423
|
+
"flex h-5 w-5 items-center justify-center rounded-full border text-[10px] font-medium tabular-nums",
|
|
424
|
+
b ? "border-foreground bg-foreground text-background" : v ? "border-foreground/30 bg-foreground/10 text-foreground" : "border-border/60 bg-background text-muted-foreground"
|
|
425
|
+
),
|
|
426
|
+
children: u
|
|
427
|
+
}
|
|
428
|
+
),
|
|
429
|
+
/* @__PURE__ */ t(
|
|
430
|
+
"span",
|
|
431
|
+
{
|
|
432
|
+
className: A(
|
|
433
|
+
"text-[12px]",
|
|
434
|
+
b ? "font-medium text-foreground" : "text-muted-foreground"
|
|
435
|
+
),
|
|
436
|
+
children: i
|
|
437
|
+
}
|
|
438
|
+
)
|
|
439
|
+
] }),
|
|
440
|
+
f < o.length - 1 ? /* @__PURE__ */ t(
|
|
441
|
+
"span",
|
|
442
|
+
{
|
|
443
|
+
className: "h-px w-4 bg-border/60 sm:w-6",
|
|
444
|
+
"aria-hidden": "true"
|
|
445
|
+
}
|
|
446
|
+
) : null
|
|
447
|
+
] }, i);
|
|
448
|
+
}) }) });
|
|
449
|
+
}
|
|
450
|
+
function se(s) {
|
|
451
|
+
const { secondary: r, tertiary: o, primary: i } = s;
|
|
452
|
+
return /* @__PURE__ */ d("div", { className: "sticky bottom-0 z-10 -mx-1 flex justify-end gap-2 border-t bg-background/95 px-1 pb-1 pt-3 backdrop-blur supports-[backdrop-filter]:bg-background/85", children: [
|
|
453
|
+
r,
|
|
454
|
+
o,
|
|
455
|
+
i
|
|
456
|
+
] });
|
|
457
|
+
}
|
|
458
|
+
function Gt(s) {
|
|
459
|
+
const { control: r, scope: o, detail: i } = s;
|
|
460
|
+
return /* @__PURE__ */ d("div", { className: "flex items-start gap-2.5 rounded-[6px] border border-border/60 bg-muted/30 px-3 py-2.5", children: [
|
|
461
|
+
/* @__PURE__ */ t($t, { className: "mt-0.5 h-3.5 w-3.5 shrink-0 text-foreground" }),
|
|
462
|
+
/* @__PURE__ */ d("div", { className: "min-w-0 space-y-0.5", children: [
|
|
463
|
+
/* @__PURE__ */ t("div", { className: "text-[13px] font-medium text-foreground", children: r.label }),
|
|
464
|
+
/* @__PURE__ */ d("div", { className: "text-[12px] text-muted-foreground", children: [
|
|
465
|
+
We(r.type).label,
|
|
466
|
+
" ·",
|
|
467
|
+
" ",
|
|
468
|
+
et(r),
|
|
469
|
+
" ·",
|
|
470
|
+
" ",
|
|
471
|
+
Ze(o, r.placement)
|
|
472
|
+
] }),
|
|
473
|
+
i ? /* @__PURE__ */ t("div", { className: "text-[12px] text-muted-foreground", children: i }) : null
|
|
474
|
+
] })
|
|
475
|
+
] });
|
|
476
|
+
}
|
|
477
|
+
function Re(s) {
|
|
478
|
+
const {
|
|
479
|
+
control: r,
|
|
480
|
+
defaultValue: o,
|
|
481
|
+
availableFieldChoices: i,
|
|
482
|
+
availableMetricChoices: f,
|
|
483
|
+
previewControlDefinitions: u,
|
|
484
|
+
previewControlValues: b,
|
|
485
|
+
onControlChange: v,
|
|
486
|
+
onLabelChange: h,
|
|
487
|
+
onDefaultValueChange: C,
|
|
488
|
+
onBack: x,
|
|
489
|
+
onNext: m,
|
|
490
|
+
nextDisabled: g
|
|
491
|
+
} = s;
|
|
492
|
+
return /* @__PURE__ */ d("div", { className: "space-y-3", children: [
|
|
493
|
+
/* @__PURE__ */ t(ot, { control: r, onChange: h }),
|
|
494
|
+
/* @__PURE__ */ t(
|
|
495
|
+
rt,
|
|
496
|
+
{
|
|
497
|
+
control: r,
|
|
498
|
+
availableFieldChoices: i,
|
|
499
|
+
availableMetricChoices: f,
|
|
500
|
+
previewControlDefinitions: u,
|
|
501
|
+
previewControlValues: b,
|
|
502
|
+
controlLifecycle: "create",
|
|
503
|
+
onChange: v
|
|
504
|
+
}
|
|
505
|
+
),
|
|
506
|
+
/* @__PURE__ */ t(
|
|
507
|
+
st,
|
|
508
|
+
{
|
|
509
|
+
control: r,
|
|
510
|
+
value: o,
|
|
511
|
+
onChange: C,
|
|
512
|
+
allowNoDefault: !0,
|
|
513
|
+
allowCardDefault: !0,
|
|
514
|
+
hint: "This is the value viewers will see first.",
|
|
515
|
+
previewControlDefinitions: u,
|
|
516
|
+
previewControlValues: b
|
|
517
|
+
}
|
|
518
|
+
),
|
|
519
|
+
/* @__PURE__ */ t(
|
|
520
|
+
se,
|
|
521
|
+
{
|
|
522
|
+
secondary: /* @__PURE__ */ t(
|
|
523
|
+
q,
|
|
524
|
+
{
|
|
525
|
+
type: "button",
|
|
526
|
+
variant: "outline",
|
|
527
|
+
size: "xs",
|
|
528
|
+
onClick: x,
|
|
529
|
+
children: "Back"
|
|
530
|
+
}
|
|
531
|
+
),
|
|
532
|
+
primary: /* @__PURE__ */ t(
|
|
533
|
+
q,
|
|
534
|
+
{
|
|
535
|
+
type: "button",
|
|
536
|
+
size: "xs",
|
|
537
|
+
onClick: m,
|
|
538
|
+
disabled: g,
|
|
539
|
+
children: "Next"
|
|
540
|
+
}
|
|
541
|
+
)
|
|
542
|
+
}
|
|
543
|
+
)
|
|
544
|
+
] });
|
|
545
|
+
}
|
|
546
|
+
const Jt = /* @__PURE__ */ new Set([
|
|
547
|
+
"grain_selector",
|
|
548
|
+
"aggregation_selector",
|
|
549
|
+
"field_selector",
|
|
550
|
+
"metric_selector"
|
|
551
|
+
]);
|
|
552
|
+
function Ue(s) {
|
|
553
|
+
const { text: r, ariaLabel: o } = s, [i, f] = B(!1);
|
|
554
|
+
return /* @__PURE__ */ d(
|
|
555
|
+
"button",
|
|
556
|
+
{
|
|
557
|
+
type: "button",
|
|
558
|
+
"aria-label": o,
|
|
559
|
+
onClick: async () => {
|
|
560
|
+
try {
|
|
561
|
+
await navigator.clipboard.writeText(r), f(!0), setTimeout(() => f(!1), 1200);
|
|
562
|
+
} catch (u) {
|
|
563
|
+
console.error("Failed to copy", u);
|
|
564
|
+
}
|
|
565
|
+
},
|
|
566
|
+
className: "group flex w-full items-center justify-between gap-2 rounded-[4px] bg-muted/40 px-2 py-1 text-left transition-colors hover:bg-muted/60 focus-visible:bg-muted/60 focus-visible:outline-none",
|
|
567
|
+
children: [
|
|
568
|
+
/* @__PURE__ */ t("code", { className: "min-w-0 truncate font-mono text-[12px] text-foreground", children: r }),
|
|
569
|
+
/* @__PURE__ */ t("span", { className: "shrink-0 text-[11px] text-muted-foreground opacity-0 transition-opacity group-hover:opacity-100", children: i ? "Copied" : "Click to copy" })
|
|
570
|
+
]
|
|
571
|
+
}
|
|
572
|
+
);
|
|
573
|
+
}
|
|
574
|
+
function $e(s) {
|
|
575
|
+
const {
|
|
576
|
+
control: r,
|
|
577
|
+
scope: o,
|
|
578
|
+
createdReference: i,
|
|
579
|
+
explorerContent: f,
|
|
580
|
+
sqlDescription: u,
|
|
581
|
+
summaryDetail: b,
|
|
582
|
+
onBack: v,
|
|
583
|
+
onCancel: h,
|
|
584
|
+
onDone: C
|
|
585
|
+
} = s, x = Jt.has(r.type), m = i.match(/\[\[param\.(.+?)\]\]/), g = m ? `{{ param('${m[1]}') }}` : "";
|
|
586
|
+
return /* @__PURE__ */ d("div", { className: "space-y-4", children: [
|
|
587
|
+
/* @__PURE__ */ t(
|
|
588
|
+
Gt,
|
|
589
|
+
{
|
|
590
|
+
control: r,
|
|
591
|
+
scope: o,
|
|
592
|
+
detail: b
|
|
593
|
+
}
|
|
594
|
+
),
|
|
595
|
+
/* @__PURE__ */ d("div", { className: "space-y-2", children: [
|
|
596
|
+
/* @__PURE__ */ t("p", { className: "text-[13px] font-medium text-foreground", children: "How cards use this control" }),
|
|
597
|
+
/* @__PURE__ */ d("div", { className: "divide-y divide-border/60 overflow-hidden rounded-[6px] border border-border/60", children: [
|
|
598
|
+
x ? /* @__PURE__ */ d("div", { className: "space-y-1 px-3 py-2.5", children: [
|
|
599
|
+
/* @__PURE__ */ t("p", { className: "text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground", children: "Explorer cards" }),
|
|
600
|
+
/* @__PURE__ */ t("div", { className: "text-[12px] text-muted-foreground", children: f })
|
|
601
|
+
] }) : null,
|
|
602
|
+
/* @__PURE__ */ d("div", { className: "space-y-1.5 px-3 py-2.5", children: [
|
|
603
|
+
/* @__PURE__ */ t("p", { className: "text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground", children: "SQL cards" }),
|
|
604
|
+
/* @__PURE__ */ t(
|
|
605
|
+
Ue,
|
|
606
|
+
{
|
|
607
|
+
text: i,
|
|
608
|
+
ariaLabel: "Copy SQL control reference"
|
|
609
|
+
}
|
|
610
|
+
),
|
|
611
|
+
g ? /* @__PURE__ */ t(
|
|
612
|
+
Ue,
|
|
613
|
+
{
|
|
614
|
+
text: g,
|
|
615
|
+
ariaLabel: "Copy Jinja control reference"
|
|
616
|
+
}
|
|
617
|
+
) : null,
|
|
618
|
+
/* @__PURE__ */ d("p", { className: "text-[12px] text-muted-foreground", children: [
|
|
619
|
+
u,
|
|
620
|
+
" ",
|
|
621
|
+
/* @__PURE__ */ t(
|
|
622
|
+
"a",
|
|
623
|
+
{
|
|
624
|
+
href: "https://docs.semaphor.cloud/docs/concepts/template-expressions",
|
|
625
|
+
target: "_blank",
|
|
626
|
+
rel: "noreferrer",
|
|
627
|
+
className: "underline underline-offset-2 hover:text-foreground",
|
|
628
|
+
children: "Template expressions docs"
|
|
629
|
+
}
|
|
630
|
+
),
|
|
631
|
+
"."
|
|
632
|
+
] })
|
|
633
|
+
] })
|
|
634
|
+
] })
|
|
635
|
+
] }),
|
|
636
|
+
/* @__PURE__ */ t(
|
|
637
|
+
se,
|
|
638
|
+
{
|
|
639
|
+
secondary: /* @__PURE__ */ t(
|
|
640
|
+
q,
|
|
641
|
+
{
|
|
642
|
+
type: "button",
|
|
643
|
+
variant: "outline",
|
|
644
|
+
size: "xs",
|
|
645
|
+
onClick: v,
|
|
646
|
+
children: "Back"
|
|
647
|
+
}
|
|
648
|
+
),
|
|
649
|
+
tertiary: /* @__PURE__ */ t(
|
|
650
|
+
q,
|
|
651
|
+
{
|
|
652
|
+
type: "button",
|
|
653
|
+
variant: "outline",
|
|
654
|
+
size: "xs",
|
|
655
|
+
onClick: h,
|
|
656
|
+
children: "Cancel"
|
|
657
|
+
}
|
|
658
|
+
),
|
|
659
|
+
primary: /* @__PURE__ */ t(q, { type: "button", size: "xs", onClick: C, children: "Done" })
|
|
660
|
+
}
|
|
661
|
+
)
|
|
662
|
+
] });
|
|
663
|
+
}
|
|
664
|
+
function Wt(s) {
|
|
665
|
+
const r = ae(
|
|
666
|
+
s.scope,
|
|
667
|
+
s.existingControls,
|
|
668
|
+
s.reservedIds
|
|
669
|
+
), o = s.type === r.type ? {
|
|
670
|
+
...r,
|
|
671
|
+
label: Ce[s.type]
|
|
672
|
+
} : {
|
|
673
|
+
...at({
|
|
674
|
+
controls: [
|
|
675
|
+
{
|
|
676
|
+
...r,
|
|
677
|
+
label: Ce[s.type]
|
|
678
|
+
}
|
|
679
|
+
],
|
|
680
|
+
controlId: r.id,
|
|
681
|
+
nextType: s.type
|
|
682
|
+
}).controls[0],
|
|
683
|
+
label: Ce[s.type]
|
|
684
|
+
};
|
|
685
|
+
return {
|
|
686
|
+
step: 2,
|
|
687
|
+
control: o,
|
|
688
|
+
defaultValue: re(o, void 0)
|
|
689
|
+
};
|
|
690
|
+
}
|
|
691
|
+
function ca({
|
|
692
|
+
scope: s,
|
|
693
|
+
controls: r,
|
|
694
|
+
reservedControlIds: o,
|
|
695
|
+
defaultValues: i,
|
|
696
|
+
onChange: f,
|
|
697
|
+
emptyMessage: u,
|
|
698
|
+
initialCreateFlow: b = !1,
|
|
699
|
+
usageByControlId: v,
|
|
700
|
+
availableFieldChoices: h,
|
|
701
|
+
availableMetricChoices: C,
|
|
702
|
+
structuralParticipants: x,
|
|
703
|
+
structuralParticipantIdsByControlId: m,
|
|
704
|
+
card: g,
|
|
705
|
+
onCreateFlowActiveChange: N,
|
|
706
|
+
onCreateFlowComplete: V
|
|
707
|
+
}) {
|
|
708
|
+
const I = z(
|
|
709
|
+
() => new Set(o || []),
|
|
710
|
+
[o]
|
|
711
|
+
), oe = Lt(s), ie = wt(s), [ee, X] = B(
|
|
712
|
+
null
|
|
713
|
+
), [de, K] = B(
|
|
714
|
+
null
|
|
715
|
+
), [a, S] = B(
|
|
716
|
+
() => b ? {
|
|
717
|
+
step: 1,
|
|
718
|
+
control: ae(s, r, Array.from(I))
|
|
719
|
+
} : null
|
|
720
|
+
), Q = ke({}), T = ke(void 0), P = ke(b), j = z(
|
|
721
|
+
() => Fe({ scope: s, card: g }),
|
|
722
|
+
[g, s]
|
|
723
|
+
), E = M(
|
|
724
|
+
(e) => s === "dashboard" && (e === "field_selector" || e === "metric_selector"),
|
|
725
|
+
[s]
|
|
726
|
+
), G = z(
|
|
727
|
+
() => a ? ze(
|
|
728
|
+
x || [],
|
|
729
|
+
a.control.type
|
|
730
|
+
) : [],
|
|
731
|
+
[a, x]
|
|
732
|
+
), R = z(() => {
|
|
733
|
+
if (!a)
|
|
734
|
+
return {
|
|
735
|
+
fields: h || [],
|
|
736
|
+
metrics: C || []
|
|
737
|
+
};
|
|
738
|
+
if (!E(a.control.type))
|
|
739
|
+
return {
|
|
740
|
+
fields: h || [],
|
|
741
|
+
metrics: C || []
|
|
742
|
+
};
|
|
743
|
+
const e = a.selectedCardIds || [], n = fe({
|
|
744
|
+
controlType: a.control.type,
|
|
745
|
+
participants: x || [],
|
|
746
|
+
selectedCardIds: e
|
|
747
|
+
});
|
|
748
|
+
return {
|
|
749
|
+
fields: a.control.type === "field_selector" ? n.choices.map((l) => ({
|
|
750
|
+
option: l,
|
|
751
|
+
target: n.fieldTargetMap[l.value]
|
|
752
|
+
})) : [],
|
|
753
|
+
metrics: a.control.type === "metric_selector" ? n.choices.map((l) => ({
|
|
754
|
+
option: l,
|
|
755
|
+
target: n.metricTargetMap[l.value]
|
|
756
|
+
})) : []
|
|
757
|
+
};
|
|
758
|
+
}, [
|
|
759
|
+
h,
|
|
760
|
+
C,
|
|
761
|
+
a,
|
|
762
|
+
E,
|
|
763
|
+
x
|
|
764
|
+
]);
|
|
765
|
+
Se(() => {
|
|
766
|
+
N == null || N(!!a);
|
|
767
|
+
}, [a, N]), Se(() => {
|
|
768
|
+
const e = b && !P.current;
|
|
769
|
+
P.current = b, e && (S({
|
|
770
|
+
step: 1,
|
|
771
|
+
control: ae(s, r, Array.from(I))
|
|
772
|
+
}), K(null), X(null));
|
|
773
|
+
}, [r, b, I, s]);
|
|
774
|
+
const te = (e) => {
|
|
775
|
+
if (!E(e.type))
|
|
776
|
+
return {
|
|
777
|
+
fields: h || [],
|
|
778
|
+
metrics: C || []
|
|
779
|
+
};
|
|
780
|
+
const n = (m == null ? void 0 : m[e.id]) || [];
|
|
781
|
+
if (n.length === 0)
|
|
782
|
+
return {
|
|
783
|
+
fields: h || [],
|
|
784
|
+
metrics: C || []
|
|
785
|
+
};
|
|
786
|
+
const l = fe({
|
|
787
|
+
controlType: e.type,
|
|
788
|
+
participants: x || [],
|
|
789
|
+
selectedCardIds: n
|
|
790
|
+
});
|
|
791
|
+
return {
|
|
792
|
+
fields: e.type === "field_selector" ? l.choices.map((c) => ({
|
|
793
|
+
option: c,
|
|
794
|
+
target: l.fieldTargetMap[c.value]
|
|
795
|
+
})) : [],
|
|
796
|
+
metrics: e.type === "metric_selector" ? l.choices.map((c) => ({
|
|
797
|
+
option: c,
|
|
798
|
+
target: l.metricTargetMap[c.value]
|
|
799
|
+
})) : []
|
|
800
|
+
};
|
|
801
|
+
}, J = (e) => {
|
|
802
|
+
if (!E(e.control.type))
|
|
803
|
+
return {
|
|
804
|
+
nextControl: e.control,
|
|
805
|
+
cardBindingsById: void 0
|
|
806
|
+
};
|
|
807
|
+
const n = (m == null ? void 0 : m[e.control.id]) || [], l = fe({
|
|
808
|
+
controlType: e.control.type,
|
|
809
|
+
participants: x || [],
|
|
810
|
+
selectedCardIds: e.nextSelectedCardIds
|
|
811
|
+
}), c = Ut({
|
|
812
|
+
control: e.control,
|
|
813
|
+
choices: l.choices
|
|
814
|
+
}), y = Object.fromEntries(
|
|
815
|
+
n.filter((D) => !e.nextSelectedCardIds.includes(D)).map((D) => [D, void 0])
|
|
816
|
+
);
|
|
817
|
+
return e.nextSelectedCardIds.length > 0 && c.source.kind === "manual" && c.source.options.length > 0 && Object.assign(
|
|
818
|
+
y,
|
|
819
|
+
je({
|
|
820
|
+
control: c,
|
|
821
|
+
participants: x || [],
|
|
822
|
+
selectedCardIds: e.nextSelectedCardIds
|
|
823
|
+
})
|
|
824
|
+
), {
|
|
825
|
+
nextControl: c,
|
|
826
|
+
cardBindingsById: y
|
|
827
|
+
};
|
|
828
|
+
}, F = M((e, n = i, l = { type: "update" }) => {
|
|
829
|
+
const c = e.map((y) => (he({
|
|
830
|
+
control: y,
|
|
831
|
+
defaultValues: n
|
|
832
|
+
}), Tt(
|
|
833
|
+
y
|
|
834
|
+
)));
|
|
835
|
+
f(c, n, l);
|
|
836
|
+
}, [i, f]), W = (e, n) => {
|
|
837
|
+
const l = r.find(
|
|
838
|
+
(w) => w.id === e
|
|
839
|
+
);
|
|
840
|
+
let c = r.map((w) => w.id !== e ? w : n(w));
|
|
841
|
+
const y = c.find(
|
|
842
|
+
(w) => w.id === e
|
|
843
|
+
);
|
|
844
|
+
let D, p;
|
|
845
|
+
if (y && s === "dashboard" && (y.type === "field_selector" || y.type === "metric_selector")) {
|
|
846
|
+
const w = (m == null ? void 0 : m[y.id]) || [], Y = J({
|
|
847
|
+
control: y,
|
|
848
|
+
nextSelectedCardIds: w
|
|
849
|
+
});
|
|
850
|
+
c = c.map(
|
|
851
|
+
(U) => U.id === e ? Y.nextControl : U
|
|
852
|
+
), D = Y.cardBindingsById, p = [y.id];
|
|
853
|
+
} else if (l && s === "dashboard" && (l.type === "field_selector" || l.type === "metric_selector")) {
|
|
854
|
+
const w = (m == null ? void 0 : m[l.id]) || [];
|
|
855
|
+
D = Object.fromEntries(
|
|
856
|
+
w.map((Y) => [Y, void 0])
|
|
857
|
+
), p = [l.id];
|
|
858
|
+
}
|
|
859
|
+
const k = c.find(
|
|
860
|
+
(w) => w.id === e
|
|
861
|
+
);
|
|
862
|
+
let _ = i;
|
|
863
|
+
if (l && k) {
|
|
864
|
+
const w = he({
|
|
865
|
+
control: l,
|
|
866
|
+
defaultValues: i
|
|
867
|
+
});
|
|
868
|
+
l.source.kind === "manual" && k.source.kind === "sql_query" && (Q.current[e] = w);
|
|
869
|
+
const Y = w === void 0 && l.source.kind === "sql_query" && k.source.kind === "manual" ? Q.current[e] : w, U = Qe({
|
|
870
|
+
previousControl: l,
|
|
871
|
+
nextControl: k,
|
|
872
|
+
currentDefaultValue: Y
|
|
873
|
+
});
|
|
874
|
+
k.source.kind === "manual" && (Q.current[e] = U), i && (_ = { ...i }, U === void 0 ? delete _[e] : _[e] = U), c = c.map(
|
|
875
|
+
(Le) => Le.id === e ? { ...k, defaultValue: U } : Le
|
|
876
|
+
);
|
|
877
|
+
}
|
|
878
|
+
F(c, _, {
|
|
879
|
+
type: "update",
|
|
880
|
+
cardBindingsById: D,
|
|
881
|
+
affectedBindingControlIds: p
|
|
882
|
+
});
|
|
883
|
+
}, it = (e, n) => {
|
|
884
|
+
const l = n.trim();
|
|
885
|
+
if (l.length === 0 || l === e || I.has(l) || r.some(
|
|
886
|
+
(D) => D.id === l && D.id !== e
|
|
887
|
+
))
|
|
888
|
+
return;
|
|
889
|
+
const c = r.map(
|
|
890
|
+
(D) => D.id === e ? { ...D, id: l } : D
|
|
891
|
+
);
|
|
892
|
+
if (!i) {
|
|
893
|
+
F(c, void 0, {
|
|
894
|
+
type: "rename",
|
|
895
|
+
oldId: e,
|
|
896
|
+
newId: l
|
|
897
|
+
});
|
|
898
|
+
return;
|
|
899
|
+
}
|
|
900
|
+
const y = { ...i };
|
|
901
|
+
Object.prototype.hasOwnProperty.call(y, e) && (y[l] = y[e], delete y[e]), F(c, y, {
|
|
902
|
+
type: "rename",
|
|
903
|
+
oldId: e,
|
|
904
|
+
newId: l
|
|
905
|
+
});
|
|
906
|
+
}, dt = (e) => {
|
|
907
|
+
const n = r.filter((c) => c.id !== e);
|
|
908
|
+
if (!i) {
|
|
909
|
+
F(n, void 0, { type: "remove", controlId: e });
|
|
910
|
+
return;
|
|
911
|
+
}
|
|
912
|
+
const l = { ...i };
|
|
913
|
+
delete l[e], F(n, l, { type: "remove", controlId: e });
|
|
914
|
+
}, ct = M(() => {
|
|
915
|
+
T.current = void 0, S({
|
|
916
|
+
step: 1,
|
|
917
|
+
control: ae(s, r, Array.from(I))
|
|
918
|
+
}), K(null), X(null);
|
|
919
|
+
}, [r, I, s]), Z = (e) => {
|
|
920
|
+
S(
|
|
921
|
+
(n) => n && (() => {
|
|
922
|
+
const l = e(n.control);
|
|
923
|
+
n.control.source.kind === "manual" && l.source.kind === "sql_query" && (T.current = n.defaultValue);
|
|
924
|
+
const c = n.defaultValue === void 0 && n.control.source.kind === "sql_query" && l.source.kind === "manual" ? T.current : n.defaultValue, y = Qe({
|
|
925
|
+
previousControl: n.control,
|
|
926
|
+
nextControl: l,
|
|
927
|
+
currentDefaultValue: c
|
|
928
|
+
});
|
|
929
|
+
return l.source.kind === "manual" && (T.current = y), {
|
|
930
|
+
...n,
|
|
931
|
+
control: l,
|
|
932
|
+
defaultValue: y
|
|
933
|
+
};
|
|
934
|
+
})()
|
|
935
|
+
);
|
|
936
|
+
}, Ve = (e) => {
|
|
937
|
+
S(
|
|
938
|
+
(n) => n && (n.control.source.kind === "manual" && (T.current = e), {
|
|
939
|
+
...n,
|
|
940
|
+
defaultValue: e
|
|
941
|
+
})
|
|
942
|
+
);
|
|
943
|
+
}, ce = (() => {
|
|
944
|
+
if (!a)
|
|
945
|
+
return !1;
|
|
946
|
+
if (a.step === 2 && E(a.control.type))
|
|
947
|
+
return (a.selectedCardIds || []).length > 0;
|
|
948
|
+
if (a.step !== 2 && a.step !== 3 || !a.control.label.trim())
|
|
949
|
+
return !1;
|
|
950
|
+
const n = a.control.source.kind === "sql_query" ? a.control : Ae(a.control);
|
|
951
|
+
if (n.source.kind === "manual" && (Vt(n) && n.source.options.length === 0 || n.source.options.some(
|
|
952
|
+
(c) => c.label.trim().length === 0 || c.value.trim().length === 0
|
|
953
|
+
)))
|
|
954
|
+
return !1;
|
|
955
|
+
if (n.source.kind === "sql_query") {
|
|
956
|
+
const { connectionId: l, sql: c, valueColumn: y } = n.source;
|
|
957
|
+
return l.trim().length > 0 && c.trim().length > 0 && y.trim().length > 0;
|
|
958
|
+
}
|
|
959
|
+
return It(
|
|
960
|
+
re(n, a.defaultValue)
|
|
961
|
+
);
|
|
962
|
+
})(), Ie = () => {
|
|
963
|
+
var D;
|
|
964
|
+
if (!a)
|
|
965
|
+
return;
|
|
966
|
+
const e = Ae(a.control), n = Rt({
|
|
967
|
+
label: e.label,
|
|
968
|
+
fallbackId: e.id,
|
|
969
|
+
existingControls: r,
|
|
970
|
+
reservedIds: Array.from(I)
|
|
971
|
+
}), l = {
|
|
972
|
+
...e,
|
|
973
|
+
id: n
|
|
974
|
+
}, c = s === "dashboard" && (l.type === "field_selector" || l.type === "metric_selector") && ((D = a.selectedCardIds) != null && D.length) ? je({
|
|
975
|
+
control: l,
|
|
976
|
+
participants: x || [],
|
|
977
|
+
selectedCardIds: a.selectedCardIds
|
|
978
|
+
}) : void 0, y = re(
|
|
979
|
+
l,
|
|
980
|
+
a.defaultValue
|
|
981
|
+
);
|
|
982
|
+
S({
|
|
983
|
+
step: s === "dashboard" && (l.type === "field_selector" || l.type === "metric_selector") ? 4 : 3,
|
|
984
|
+
control: l,
|
|
985
|
+
defaultValue: y,
|
|
986
|
+
createdControlId: n,
|
|
987
|
+
selectedCardIds: a.selectedCardIds,
|
|
988
|
+
cardBindingsById: c
|
|
989
|
+
});
|
|
990
|
+
}, ue = M(() => {
|
|
991
|
+
S(null);
|
|
992
|
+
}, []), qe = M(() => {
|
|
993
|
+
if (!(a != null && a.createdControlId)) {
|
|
994
|
+
S(null);
|
|
995
|
+
return;
|
|
996
|
+
}
|
|
997
|
+
const e = a.control, n = a.createdControlId, l = re(
|
|
998
|
+
e,
|
|
999
|
+
a.defaultValue
|
|
1000
|
+
);
|
|
1001
|
+
if (i) {
|
|
1002
|
+
const c = { ...i };
|
|
1003
|
+
l === void 0 ? delete c[n] : c[n] = l, F(
|
|
1004
|
+
[
|
|
1005
|
+
...r,
|
|
1006
|
+
{
|
|
1007
|
+
...e,
|
|
1008
|
+
defaultValue: l
|
|
1009
|
+
}
|
|
1010
|
+
],
|
|
1011
|
+
c,
|
|
1012
|
+
{
|
|
1013
|
+
type: "add",
|
|
1014
|
+
cardBindingsById: a.cardBindingsById
|
|
1015
|
+
}
|
|
1016
|
+
);
|
|
1017
|
+
} else
|
|
1018
|
+
F(
|
|
1019
|
+
[
|
|
1020
|
+
...r,
|
|
1021
|
+
{
|
|
1022
|
+
...e,
|
|
1023
|
+
defaultValue: l
|
|
1024
|
+
}
|
|
1025
|
+
],
|
|
1026
|
+
void 0,
|
|
1027
|
+
{
|
|
1028
|
+
type: "add",
|
|
1029
|
+
cardBindingsById: a.cardBindingsById
|
|
1030
|
+
}
|
|
1031
|
+
);
|
|
1032
|
+
K(n), S(null), V == null || V();
|
|
1033
|
+
}, [r, a, i, F, V]), ut = a ? E(a.control.type) ? ["Choose type", "Select cards", "Configure", "Finish"] : ["Choose type", "Configure", "Finish"] : [], Ee = a != null && a.createdControlId ? `[[param.${a.createdControlId}]]` : a ? `[[param.${qt(a.control.label) || a.control.id}]]` : "", pe = Me({
|
|
1034
|
+
controls: r,
|
|
1035
|
+
defaultValues: i
|
|
1036
|
+
}), me = a ? [...r, a.control] : r, _e = a ? Me({
|
|
1037
|
+
controls: me,
|
|
1038
|
+
defaultValues: i,
|
|
1039
|
+
overrides: [
|
|
1040
|
+
{
|
|
1041
|
+
controlId: a.control.id,
|
|
1042
|
+
value: a.defaultValue
|
|
1043
|
+
}
|
|
1044
|
+
]
|
|
1045
|
+
}) : pe;
|
|
1046
|
+
return /* @__PURE__ */ d("div", { className: "space-y-4", children: [
|
|
1047
|
+
a ? /* @__PURE__ */ d("div", { className: "space-y-4 pb-1", children: [
|
|
1048
|
+
/* @__PURE__ */ t(
|
|
1049
|
+
Pt,
|
|
1050
|
+
{
|
|
1051
|
+
currentStep: a.step,
|
|
1052
|
+
labels: ut
|
|
1053
|
+
}
|
|
1054
|
+
),
|
|
1055
|
+
a.step === 1 && (() => {
|
|
1056
|
+
const e = /* @__PURE__ */ new Set([
|
|
1057
|
+
"grain_selector",
|
|
1058
|
+
"aggregation_selector",
|
|
1059
|
+
"field_selector",
|
|
1060
|
+
"metric_selector"
|
|
1061
|
+
]), n = j.filter(
|
|
1062
|
+
(y) => !e.has(y.value)
|
|
1063
|
+
), l = j.filter(
|
|
1064
|
+
(y) => e.has(y.value)
|
|
1065
|
+
), c = (y) => /* @__PURE__ */ d(
|
|
1066
|
+
"button",
|
|
1067
|
+
{
|
|
1068
|
+
type: "button",
|
|
1069
|
+
className: "rounded-[6px] border border-border/60 bg-background px-3 py-2.5 text-left transition-colors hover:bg-muted/40 focus-visible:bg-muted/40 focus-visible:outline-none",
|
|
1070
|
+
onClick: () => S(
|
|
1071
|
+
Wt({
|
|
1072
|
+
scope: s,
|
|
1073
|
+
existingControls: r,
|
|
1074
|
+
reservedIds: Array.from(I),
|
|
1075
|
+
type: y.value
|
|
1076
|
+
})
|
|
1077
|
+
),
|
|
1078
|
+
children: [
|
|
1079
|
+
/* @__PURE__ */ t("div", { className: "text-[13px] font-medium text-foreground", children: y.label }),
|
|
1080
|
+
/* @__PURE__ */ t("p", { className: "mt-0.5 text-[12px] text-muted-foreground", children: y.description })
|
|
1081
|
+
]
|
|
1082
|
+
},
|
|
1083
|
+
y.value
|
|
1084
|
+
);
|
|
1085
|
+
return /* @__PURE__ */ d("div", { className: "space-y-4", children: [
|
|
1086
|
+
s === "card" && (g == null ? void 0 : g.sql) == null ? /* @__PURE__ */ t("p", { className: "text-[12px] text-muted-foreground", children: "Explorer cards support displayed metric, group by field, aggregation, and time grain controls here." }) : null,
|
|
1087
|
+
n.length > 0 && /* @__PURE__ */ d("div", { className: "space-y-1.5", children: [
|
|
1088
|
+
/* @__PURE__ */ t("p", { className: "text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground", children: "Input controls" }),
|
|
1089
|
+
/* @__PURE__ */ t("div", { className: "grid gap-1.5 sm:grid-cols-2", children: n.map(c) })
|
|
1090
|
+
] }),
|
|
1091
|
+
l.length > 0 && /* @__PURE__ */ d("div", { className: "space-y-1.5", children: [
|
|
1092
|
+
/* @__PURE__ */ t("p", { className: "text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground", children: "Data-driven controls" }),
|
|
1093
|
+
/* @__PURE__ */ t("div", { className: "grid gap-1.5 sm:grid-cols-2", children: l.map(c) })
|
|
1094
|
+
] }),
|
|
1095
|
+
/* @__PURE__ */ t(
|
|
1096
|
+
se,
|
|
1097
|
+
{
|
|
1098
|
+
secondary: /* @__PURE__ */ t(
|
|
1099
|
+
q,
|
|
1100
|
+
{
|
|
1101
|
+
type: "button",
|
|
1102
|
+
variant: "outline",
|
|
1103
|
+
size: "xs",
|
|
1104
|
+
onClick: ue,
|
|
1105
|
+
children: "Back to controls"
|
|
1106
|
+
}
|
|
1107
|
+
)
|
|
1108
|
+
}
|
|
1109
|
+
)
|
|
1110
|
+
] });
|
|
1111
|
+
})(),
|
|
1112
|
+
a.step === 2 && E(a.control.type) && /* @__PURE__ */ d("div", { className: "space-y-3", children: [
|
|
1113
|
+
/* @__PURE__ */ d("div", { className: "space-y-3", children: [
|
|
1114
|
+
/* @__PURE__ */ t(
|
|
1115
|
+
ot,
|
|
1116
|
+
{
|
|
1117
|
+
control: a.control,
|
|
1118
|
+
onChange: (e) => Z((n) => ({
|
|
1119
|
+
...n,
|
|
1120
|
+
label: e
|
|
1121
|
+
}))
|
|
1122
|
+
}
|
|
1123
|
+
),
|
|
1124
|
+
/* @__PURE__ */ t("p", { className: "text-[12px] text-muted-foreground", children: "Choose which cards should respond to this shared control." })
|
|
1125
|
+
] }),
|
|
1126
|
+
G.length === 0 ? /* @__PURE__ */ t("div", { className: "rounded-[6px] border border-border/60 bg-muted/30 px-3 py-2.5 text-[12px] text-muted-foreground", children: "No eligible cards are available yet. Add compatible metrics or group-by fields to cards first." }) : /* @__PURE__ */ t("div", { className: "space-y-1 rounded-[6px] border border-border/60 bg-background p-2", children: G.map((e) => {
|
|
1127
|
+
const n = (a.selectedCardIds || []).includes(e.cardId);
|
|
1128
|
+
return /* @__PURE__ */ d(
|
|
1129
|
+
"label",
|
|
1130
|
+
{
|
|
1131
|
+
className: "flex items-start gap-2 rounded-[4px] px-1.5 py-1 text-[13px] hover:bg-muted/40",
|
|
1132
|
+
children: [
|
|
1133
|
+
/* @__PURE__ */ t(
|
|
1134
|
+
Et,
|
|
1135
|
+
{
|
|
1136
|
+
checked: n,
|
|
1137
|
+
onCheckedChange: (l) => S(
|
|
1138
|
+
(c) => c && {
|
|
1139
|
+
...c,
|
|
1140
|
+
selectedCardIds: l === !0 ? [
|
|
1141
|
+
...c.selectedCardIds || [],
|
|
1142
|
+
e.cardId
|
|
1143
|
+
] : (c.selectedCardIds || []).filter(
|
|
1144
|
+
(y) => y !== e.cardId
|
|
1145
|
+
)
|
|
1146
|
+
}
|
|
1147
|
+
)
|
|
1148
|
+
}
|
|
1149
|
+
),
|
|
1150
|
+
/* @__PURE__ */ d("div", { className: "min-w-0", children: [
|
|
1151
|
+
/* @__PURE__ */ t("div", { className: "font-medium text-foreground", children: e.title }),
|
|
1152
|
+
/* @__PURE__ */ t("div", { className: "text-[12px] text-muted-foreground", children: a.control.type === "field_selector" ? `${e.fieldChoices.length} compatible group-by fields` : `${e.metricChoices.length} compatible metrics` })
|
|
1153
|
+
] })
|
|
1154
|
+
]
|
|
1155
|
+
},
|
|
1156
|
+
e.cardId
|
|
1157
|
+
);
|
|
1158
|
+
}) }),
|
|
1159
|
+
/* @__PURE__ */ t(
|
|
1160
|
+
se,
|
|
1161
|
+
{
|
|
1162
|
+
secondary: /* @__PURE__ */ t(
|
|
1163
|
+
q,
|
|
1164
|
+
{
|
|
1165
|
+
type: "button",
|
|
1166
|
+
variant: "outline",
|
|
1167
|
+
size: "xs",
|
|
1168
|
+
onClick: () => S(
|
|
1169
|
+
(e) => e && {
|
|
1170
|
+
...e,
|
|
1171
|
+
step: 1,
|
|
1172
|
+
selectedCardIds: []
|
|
1173
|
+
}
|
|
1174
|
+
),
|
|
1175
|
+
children: "Back"
|
|
1176
|
+
}
|
|
1177
|
+
),
|
|
1178
|
+
primary: /* @__PURE__ */ t(
|
|
1179
|
+
q,
|
|
1180
|
+
{
|
|
1181
|
+
type: "button",
|
|
1182
|
+
size: "xs",
|
|
1183
|
+
onClick: () => S(
|
|
1184
|
+
(e) => e && {
|
|
1185
|
+
...e,
|
|
1186
|
+
step: 3
|
|
1187
|
+
}
|
|
1188
|
+
),
|
|
1189
|
+
disabled: !ce,
|
|
1190
|
+
children: "Next"
|
|
1191
|
+
}
|
|
1192
|
+
)
|
|
1193
|
+
}
|
|
1194
|
+
)
|
|
1195
|
+
] }),
|
|
1196
|
+
a.step === 2 && !E(a.control.type) && /* @__PURE__ */ t(
|
|
1197
|
+
Re,
|
|
1198
|
+
{
|
|
1199
|
+
control: a.control,
|
|
1200
|
+
defaultValue: a.defaultValue,
|
|
1201
|
+
availableFieldChoices: R.fields,
|
|
1202
|
+
availableMetricChoices: R.metrics,
|
|
1203
|
+
previewControlDefinitions: me,
|
|
1204
|
+
previewControlValues: _e,
|
|
1205
|
+
onControlChange: (e) => Z(() => e),
|
|
1206
|
+
onLabelChange: (e) => Z((n) => ({
|
|
1207
|
+
...n,
|
|
1208
|
+
label: e
|
|
1209
|
+
})),
|
|
1210
|
+
onDefaultValueChange: Ve,
|
|
1211
|
+
onBack: () => S(
|
|
1212
|
+
(e) => e && {
|
|
1213
|
+
...e,
|
|
1214
|
+
step: 1
|
|
1215
|
+
}
|
|
1216
|
+
),
|
|
1217
|
+
onNext: Ie,
|
|
1218
|
+
nextDisabled: !ce
|
|
1219
|
+
}
|
|
1220
|
+
),
|
|
1221
|
+
a.step === 3 && E(a.control.type) && /* @__PURE__ */ t(
|
|
1222
|
+
Re,
|
|
1223
|
+
{
|
|
1224
|
+
control: a.control,
|
|
1225
|
+
defaultValue: a.defaultValue,
|
|
1226
|
+
availableFieldChoices: R.fields,
|
|
1227
|
+
availableMetricChoices: R.metrics,
|
|
1228
|
+
previewControlDefinitions: me,
|
|
1229
|
+
previewControlValues: _e,
|
|
1230
|
+
onControlChange: (e) => Z(() => e),
|
|
1231
|
+
onLabelChange: (e) => Z((n) => ({
|
|
1232
|
+
...n,
|
|
1233
|
+
label: e
|
|
1234
|
+
})),
|
|
1235
|
+
onDefaultValueChange: Ve,
|
|
1236
|
+
onBack: () => S(
|
|
1237
|
+
(e) => e && {
|
|
1238
|
+
...e,
|
|
1239
|
+
step: 2
|
|
1240
|
+
}
|
|
1241
|
+
),
|
|
1242
|
+
onNext: Ie,
|
|
1243
|
+
nextDisabled: !ce
|
|
1244
|
+
}
|
|
1245
|
+
),
|
|
1246
|
+
a.step === 3 && !E(a.control.type) && /* @__PURE__ */ t(
|
|
1247
|
+
$e,
|
|
1248
|
+
{
|
|
1249
|
+
control: a.control,
|
|
1250
|
+
scope: s,
|
|
1251
|
+
createdReference: Ee,
|
|
1252
|
+
explorerContent: /* @__PURE__ */ d($, { children: [
|
|
1253
|
+
"Open the card and use",
|
|
1254
|
+
" ",
|
|
1255
|
+
/* @__PURE__ */ t("span", { className: "font-medium text-foreground", children: "Settings → Controls" }),
|
|
1256
|
+
" ",
|
|
1257
|
+
"to choose what this control changes."
|
|
1258
|
+
] }),
|
|
1259
|
+
sqlDescription: "Reference this control directly in the SQL editor.",
|
|
1260
|
+
onBack: () => S(
|
|
1261
|
+
(e) => e && {
|
|
1262
|
+
...e,
|
|
1263
|
+
step: 2
|
|
1264
|
+
}
|
|
1265
|
+
),
|
|
1266
|
+
onCancel: ue,
|
|
1267
|
+
onDone: qe
|
|
1268
|
+
}
|
|
1269
|
+
),
|
|
1270
|
+
a.step === 4 && E(a.control.type) && /* @__PURE__ */ t(
|
|
1271
|
+
$e,
|
|
1272
|
+
{
|
|
1273
|
+
control: a.control,
|
|
1274
|
+
scope: s,
|
|
1275
|
+
createdReference: Ee,
|
|
1276
|
+
summaryDetail: /* @__PURE__ */ d($, { children: [
|
|
1277
|
+
"Used by ",
|
|
1278
|
+
(a.selectedCardIds || []).length,
|
|
1279
|
+
" ",
|
|
1280
|
+
"selected card",
|
|
1281
|
+
(a.selectedCardIds || []).length === 1 ? "" : "s"
|
|
1282
|
+
] }),
|
|
1283
|
+
explorerContent: /* @__PURE__ */ t($, { children: "Selected cards have been set up to respond to this control automatically." }),
|
|
1284
|
+
sqlDescription: "SQL cards can still reference this control directly in the SQL editor.",
|
|
1285
|
+
onBack: () => S(
|
|
1286
|
+
(e) => e && {
|
|
1287
|
+
...e,
|
|
1288
|
+
step: 3
|
|
1289
|
+
}
|
|
1290
|
+
),
|
|
1291
|
+
onCancel: ue,
|
|
1292
|
+
onDone: qe
|
|
1293
|
+
}
|
|
1294
|
+
)
|
|
1295
|
+
] }) : null,
|
|
1296
|
+
!a && r.length === 0 ? /* @__PURE__ */ t("div", { className: "rounded-md border border-dashed p-3 text-sm text-muted-foreground", children: u }) : null,
|
|
1297
|
+
!a && r.map((e) => {
|
|
1298
|
+
const n = te(e), l = v == null ? void 0 : v[e.id], c = he({
|
|
1299
|
+
control: e,
|
|
1300
|
+
defaultValues: i
|
|
1301
|
+
}), y = de === e.id, D = "inline-flex shrink-0 items-center rounded-[4px] border border-border/60 bg-muted/40 px-1.5 py-0.5 text-[11px] font-medium text-muted-foreground";
|
|
1302
|
+
return /* @__PURE__ */ d("div", { className: "rounded-[6px] border border-border/60", children: [
|
|
1303
|
+
/* @__PURE__ */ d("div", { className: "flex items-center gap-2 px-3 py-2.5", children: [
|
|
1304
|
+
/* @__PURE__ */ d(
|
|
1305
|
+
"button",
|
|
1306
|
+
{
|
|
1307
|
+
type: "button",
|
|
1308
|
+
className: "flex min-w-0 flex-1 items-start gap-2 rounded-[4px] text-left focus:outline-none focus-visible:bg-muted/40",
|
|
1309
|
+
onClick: () => K(
|
|
1310
|
+
(p) => p === e.id ? null : e.id
|
|
1311
|
+
),
|
|
1312
|
+
children: [
|
|
1313
|
+
y ? /* @__PURE__ */ t(Oe, { className: "mt-0.5 h-3.5 w-3.5 shrink-0 text-muted-foreground" }) : /* @__PURE__ */ t(Be, { className: "mt-0.5 h-3.5 w-3.5 shrink-0 text-muted-foreground" }),
|
|
1314
|
+
/* @__PURE__ */ d("div", { className: "min-w-0", children: [
|
|
1315
|
+
/* @__PURE__ */ d("div", { className: "flex flex-wrap items-center gap-1.5", children: [
|
|
1316
|
+
/* @__PURE__ */ t("span", { className: "truncate text-[13px] font-medium text-foreground", children: e.label || "Untitled control" }),
|
|
1317
|
+
/* @__PURE__ */ t("span", { className: D, children: We(e.type).label }),
|
|
1318
|
+
/* @__PURE__ */ t("span", { className: D, children: Ze(s, e.placement) })
|
|
1319
|
+
] }),
|
|
1320
|
+
/* @__PURE__ */ d("div", { className: "mt-0.5 text-[12px] text-muted-foreground", children: [
|
|
1321
|
+
et(e),
|
|
1322
|
+
l != null && l.status ? ` · ${l.status}` : ""
|
|
1323
|
+
] })
|
|
1324
|
+
] })
|
|
1325
|
+
]
|
|
1326
|
+
}
|
|
1327
|
+
),
|
|
1328
|
+
/* @__PURE__ */ t(
|
|
1329
|
+
q,
|
|
1330
|
+
{
|
|
1331
|
+
type: "button",
|
|
1332
|
+
size: "xs",
|
|
1333
|
+
variant: "ghost",
|
|
1334
|
+
className: "h-7 w-7 shrink-0 p-0 text-muted-foreground",
|
|
1335
|
+
onClick: () => dt(e.id),
|
|
1336
|
+
"aria-label": `Remove ${e.label}`,
|
|
1337
|
+
children: /* @__PURE__ */ t(_t, { className: "h-3.5 w-3.5" })
|
|
1338
|
+
}
|
|
1339
|
+
)
|
|
1340
|
+
] }),
|
|
1341
|
+
y && /* @__PURE__ */ d("div", { className: "space-y-4 border-t border-border/60 px-3 py-3", children: [
|
|
1342
|
+
/* @__PURE__ */ d("div", { className: "grid gap-3 md:grid-cols-3", children: [
|
|
1343
|
+
/* @__PURE__ */ d("div", { className: "flex flex-col gap-1.5", children: [
|
|
1344
|
+
/* @__PURE__ */ t(H, { className: "text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground", children: "Label" }),
|
|
1345
|
+
/* @__PURE__ */ t(
|
|
1346
|
+
tt,
|
|
1347
|
+
{
|
|
1348
|
+
size: "xs",
|
|
1349
|
+
value: e.label,
|
|
1350
|
+
placeholder: "Control label",
|
|
1351
|
+
onChange: (p) => W(e.id, (k) => ({
|
|
1352
|
+
...k,
|
|
1353
|
+
label: p.target.value
|
|
1354
|
+
}))
|
|
1355
|
+
}
|
|
1356
|
+
)
|
|
1357
|
+
] }),
|
|
1358
|
+
/* @__PURE__ */ d("div", { className: "flex flex-col gap-1.5", children: [
|
|
1359
|
+
/* @__PURE__ */ t(H, { className: "text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground", children: "Type" }),
|
|
1360
|
+
/* @__PURE__ */ d(
|
|
1361
|
+
be,
|
|
1362
|
+
{
|
|
1363
|
+
value: e.type,
|
|
1364
|
+
onValueChange: (p) => {
|
|
1365
|
+
const k = at({
|
|
1366
|
+
controls: r,
|
|
1367
|
+
controlId: e.id,
|
|
1368
|
+
nextType: p,
|
|
1369
|
+
defaultValues: i
|
|
1370
|
+
});
|
|
1371
|
+
F(k.controls, k.defaultValues);
|
|
1372
|
+
},
|
|
1373
|
+
children: [
|
|
1374
|
+
/* @__PURE__ */ t(ge, { size: "xs", children: /* @__PURE__ */ t(ye, {}) }),
|
|
1375
|
+
/* @__PURE__ */ t(xe, { children: Fe({
|
|
1376
|
+
scope: s,
|
|
1377
|
+
card: g,
|
|
1378
|
+
includeType: e.type
|
|
1379
|
+
}).map((p) => /* @__PURE__ */ t(ve, { value: p.value, children: p.label }, p.value)) })
|
|
1380
|
+
]
|
|
1381
|
+
}
|
|
1382
|
+
)
|
|
1383
|
+
] }),
|
|
1384
|
+
/* @__PURE__ */ d("div", { className: "flex flex-col gap-1.5", children: [
|
|
1385
|
+
/* @__PURE__ */ t(H, { className: "text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground", children: "Show in" }),
|
|
1386
|
+
/* @__PURE__ */ d(
|
|
1387
|
+
be,
|
|
1388
|
+
{
|
|
1389
|
+
value: e.placement || ie,
|
|
1390
|
+
onValueChange: (p) => W(e.id, (k) => ({
|
|
1391
|
+
...k,
|
|
1392
|
+
placement: p
|
|
1393
|
+
})),
|
|
1394
|
+
children: [
|
|
1395
|
+
/* @__PURE__ */ t(ge, { size: "xs", children: /* @__PURE__ */ t(ye, {}) }),
|
|
1396
|
+
/* @__PURE__ */ t(xe, { children: oe.map((p) => /* @__PURE__ */ t(ve, { value: p.value, children: p.label }, p.value)) })
|
|
1397
|
+
]
|
|
1398
|
+
}
|
|
1399
|
+
)
|
|
1400
|
+
] })
|
|
1401
|
+
] }),
|
|
1402
|
+
E(e.type) ? /* @__PURE__ */ t(
|
|
1403
|
+
Ft,
|
|
1404
|
+
{
|
|
1405
|
+
type: e.type,
|
|
1406
|
+
participants: ze(
|
|
1407
|
+
x || [],
|
|
1408
|
+
e.type
|
|
1409
|
+
).map((p) => ({
|
|
1410
|
+
cardId: p.cardId,
|
|
1411
|
+
title: p.title,
|
|
1412
|
+
choiceCount: e.type === "field_selector" ? p.fieldChoices.length : p.metricChoices.length
|
|
1413
|
+
})),
|
|
1414
|
+
selectedCardIds: (m == null ? void 0 : m[e.id]) || [],
|
|
1415
|
+
onChange: (p) => {
|
|
1416
|
+
const k = J({
|
|
1417
|
+
control: e,
|
|
1418
|
+
nextSelectedCardIds: p
|
|
1419
|
+
}), _ = r.map(
|
|
1420
|
+
(w) => w.id === e.id ? k.nextControl : w
|
|
1421
|
+
);
|
|
1422
|
+
F(_, i, {
|
|
1423
|
+
type: "update",
|
|
1424
|
+
cardBindingsById: k.cardBindingsById
|
|
1425
|
+
});
|
|
1426
|
+
}
|
|
1427
|
+
}
|
|
1428
|
+
) : null,
|
|
1429
|
+
/* @__PURE__ */ t(
|
|
1430
|
+
rt,
|
|
1431
|
+
{
|
|
1432
|
+
control: e,
|
|
1433
|
+
availableFieldChoices: n.fields,
|
|
1434
|
+
availableMetricChoices: n.metrics,
|
|
1435
|
+
previewControlDefinitions: r,
|
|
1436
|
+
previewControlValues: pe,
|
|
1437
|
+
controlLifecycle: "edit",
|
|
1438
|
+
onChange: (p) => W(e.id, () => p)
|
|
1439
|
+
}
|
|
1440
|
+
),
|
|
1441
|
+
e.initialValueStrategy === "saved_default" && /* @__PURE__ */ t(
|
|
1442
|
+
st,
|
|
1443
|
+
{
|
|
1444
|
+
control: e,
|
|
1445
|
+
value: c,
|
|
1446
|
+
allowNoDefault: !0,
|
|
1447
|
+
allowCardDefault: !0,
|
|
1448
|
+
previewControlDefinitions: r,
|
|
1449
|
+
previewControlValues: pe,
|
|
1450
|
+
onChange: (p) => {
|
|
1451
|
+
const k = r.map(
|
|
1452
|
+
(_) => _.id === e.id ? { ..._, defaultValue: p } : _
|
|
1453
|
+
);
|
|
1454
|
+
if (e.source.kind === "manual" && (Q.current[e.id] = p), i) {
|
|
1455
|
+
const _ = { ...i };
|
|
1456
|
+
p === void 0 ? delete _[e.id] : _[e.id] = p, F(k, _);
|
|
1457
|
+
return;
|
|
1458
|
+
}
|
|
1459
|
+
F(k, void 0);
|
|
1460
|
+
}
|
|
1461
|
+
}
|
|
1462
|
+
),
|
|
1463
|
+
/* @__PURE__ */ d(
|
|
1464
|
+
zt,
|
|
1465
|
+
{
|
|
1466
|
+
open: ee === e.id,
|
|
1467
|
+
onOpenChange: (p) => X(p ? e.id : null),
|
|
1468
|
+
children: [
|
|
1469
|
+
/* @__PURE__ */ t(At, { asChild: !0, children: /* @__PURE__ */ d(
|
|
1470
|
+
q,
|
|
1471
|
+
{
|
|
1472
|
+
type: "button",
|
|
1473
|
+
variant: "ghost",
|
|
1474
|
+
size: "xs",
|
|
1475
|
+
className: "-ml-2 gap-1 text-muted-foreground hover:text-foreground",
|
|
1476
|
+
children: [
|
|
1477
|
+
ee === e.id ? /* @__PURE__ */ t(Oe, { className: "h-3.5 w-3.5" }) : /* @__PURE__ */ t(Be, { className: "h-3.5 w-3.5" }),
|
|
1478
|
+
"Advanced"
|
|
1479
|
+
]
|
|
1480
|
+
}
|
|
1481
|
+
) }),
|
|
1482
|
+
/* @__PURE__ */ d(Mt, { className: "space-y-3 pt-2", children: [
|
|
1483
|
+
/* @__PURE__ */ d("div", { className: "grid gap-3 md:grid-cols-2", children: [
|
|
1484
|
+
/* @__PURE__ */ d("div", { className: "flex flex-col gap-1.5", children: [
|
|
1485
|
+
/* @__PURE__ */ t(H, { className: "text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground", children: "Control ID" }),
|
|
1486
|
+
/* @__PURE__ */ t(
|
|
1487
|
+
Ot,
|
|
1488
|
+
{
|
|
1489
|
+
controlId: e.id,
|
|
1490
|
+
onCommit: (p) => it(e.id, p)
|
|
1491
|
+
},
|
|
1492
|
+
e.id
|
|
1493
|
+
)
|
|
1494
|
+
] }),
|
|
1495
|
+
/* @__PURE__ */ d("div", { className: "flex flex-col gap-1.5", children: [
|
|
1496
|
+
/* @__PURE__ */ t(H, { className: "text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground", children: "Initial value" }),
|
|
1497
|
+
/* @__PURE__ */ d(
|
|
1498
|
+
be,
|
|
1499
|
+
{
|
|
1500
|
+
value: e.initialValueStrategy,
|
|
1501
|
+
onValueChange: (p) => W(e.id, (k) => ({
|
|
1502
|
+
...k,
|
|
1503
|
+
initialValueStrategy: p
|
|
1504
|
+
})),
|
|
1505
|
+
children: [
|
|
1506
|
+
/* @__PURE__ */ t(ge, { size: "xs", children: /* @__PURE__ */ t(ye, {}) }),
|
|
1507
|
+
/* @__PURE__ */ t(xe, { children: Bt.map((p) => /* @__PURE__ */ t(
|
|
1508
|
+
ve,
|
|
1509
|
+
{
|
|
1510
|
+
value: p.value,
|
|
1511
|
+
children: p.label
|
|
1512
|
+
},
|
|
1513
|
+
p.value
|
|
1514
|
+
)) })
|
|
1515
|
+
]
|
|
1516
|
+
}
|
|
1517
|
+
)
|
|
1518
|
+
] })
|
|
1519
|
+
] }),
|
|
1520
|
+
/* @__PURE__ */ t(
|
|
1521
|
+
Qt,
|
|
1522
|
+
{
|
|
1523
|
+
control: e,
|
|
1524
|
+
onChange: (p) => W(e.id, () => p)
|
|
1525
|
+
}
|
|
1526
|
+
)
|
|
1527
|
+
] })
|
|
1528
|
+
]
|
|
1529
|
+
}
|
|
1530
|
+
)
|
|
1531
|
+
] })
|
|
1532
|
+
] }, e.id);
|
|
1533
|
+
}),
|
|
1534
|
+
!a && /* @__PURE__ */ d(
|
|
1535
|
+
q,
|
|
1536
|
+
{
|
|
1537
|
+
type: "button",
|
|
1538
|
+
variant: "outline",
|
|
1539
|
+
size: "xs",
|
|
1540
|
+
onClick: ct,
|
|
1541
|
+
children: [
|
|
1542
|
+
/* @__PURE__ */ t(jt, { className: "h-3.5 w-3.5" }),
|
|
1543
|
+
"Add control"
|
|
1544
|
+
]
|
|
1545
|
+
}
|
|
1546
|
+
)
|
|
1547
|
+
] });
|
|
1548
|
+
}
|
|
1549
|
+
function ua(s) {
|
|
1550
|
+
const {
|
|
1551
|
+
open: r,
|
|
1552
|
+
onOpenChange: o,
|
|
1553
|
+
initialCreateFlowActive: i = !1,
|
|
1554
|
+
dismissMode: f = "passive"
|
|
1555
|
+
} = s, u = r !== void 0, [b, v] = B(!1), [h, C] = B(
|
|
1556
|
+
i
|
|
1557
|
+
), x = u ? r : b, m = M(
|
|
1558
|
+
(V) => {
|
|
1559
|
+
!V && h && f === "passive" || (u || v(V), V || C(!1), o == null || o(V));
|
|
1560
|
+
},
|
|
1561
|
+
[u, h, f, o]
|
|
1562
|
+
), g = M(() => {
|
|
1563
|
+
u || v(!1), C(!1), o == null || o(!1);
|
|
1564
|
+
}, [u, o]);
|
|
1565
|
+
Se(() => {
|
|
1566
|
+
x || C(!1);
|
|
1567
|
+
}, [x]);
|
|
1568
|
+
const N = M(
|
|
1569
|
+
(V) => {
|
|
1570
|
+
h && V.preventDefault();
|
|
1571
|
+
},
|
|
1572
|
+
[h]
|
|
1573
|
+
);
|
|
1574
|
+
return {
|
|
1575
|
+
forceClose: g,
|
|
1576
|
+
handleOpenChange: m,
|
|
1577
|
+
isCreateFlowActive: h,
|
|
1578
|
+
preventPassiveDismissDuringCreate: N,
|
|
1579
|
+
resolvedOpen: x,
|
|
1580
|
+
setIsCreateFlowActive: C
|
|
1581
|
+
};
|
|
1582
|
+
}
|
|
1583
|
+
export {
|
|
1584
|
+
ra as C,
|
|
1585
|
+
la as E,
|
|
1586
|
+
Yt as L,
|
|
1587
|
+
lt as S,
|
|
1588
|
+
sa as V,
|
|
1589
|
+
na as a,
|
|
1590
|
+
oa as b,
|
|
1591
|
+
Ht as c,
|
|
1592
|
+
ia as d,
|
|
1593
|
+
ca as e,
|
|
1594
|
+
nt as f,
|
|
1595
|
+
da as g,
|
|
1596
|
+
ua as u
|
|
1597
|
+
};
|