react-semaphor 0.1.208 → 0.1.209
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chunks/{dashboard-controls-yOzrvYwI.js → dashboard-controls-BNTI4r0_.js} +30 -30
- package/dist/chunks/{dashboard-controls-K5zNLdtH.js → dashboard-controls-Dcpx9_an.js} +1 -1
- package/dist/chunks/{dashboard-json-DqChvVCF.js → dashboard-json-BjOqpGbW.js} +1 -1
- package/dist/chunks/{dashboard-json-BuLoVNV4.js → dashboard-json-kIoBtmBF.js} +1 -1
- package/dist/chunks/{dashboard-summary-settings-dialog-tJueBNph.js → dashboard-summary-settings-dialog-BoX18wiA.js} +1 -1
- package/dist/chunks/{dashboard-summary-settings-dialog-DmccX33N.js → dashboard-summary-settings-dialog-CO1SwHHD.js} +1 -1
- package/dist/chunks/{edit-dashboard-visual-CKNlwaCO.js → edit-dashboard-visual-B9HuGExj.js} +1 -1
- package/dist/chunks/{edit-dashboard-visual-CV4JsCTg.js → edit-dashboard-visual-DG4VLoJF.js} +2 -2
- package/dist/chunks/editor-action-buttons-CDTIx_Jc.js +11 -0
- package/dist/chunks/editor-action-buttons-CszdZ4Fw.js +345 -0
- package/dist/chunks/{index-CBcPi9pm.js → index-D0TdW88i.js} +24289 -23875
- package/dist/chunks/index-DSA80lEg.js +1104 -0
- package/dist/chunks/{notification-bell-DyzIftQU.js → notification-bell-D2V1-ARa.js} +1 -1
- package/dist/chunks/{notification-bell-B-OVf20Q.js → notification-bell-DFiRaeJQ.js} +52 -52
- package/dist/chunks/resource-management-panel-BhiWNPcw.js +6 -0
- package/dist/chunks/resource-management-panel-DS_WEv1x.js +902 -0
- package/dist/chunks/{use-role-aware-display-preferences-B4QJkliF.js → use-role-aware-display-preferences-D8j5_cnK.js} +1 -1
- package/dist/chunks/{use-role-aware-display-preferences-DTSpe_ZT.js → use-role-aware-display-preferences-DfihB5pN.js} +1 -1
- package/dist/chunks/{use-visual-utils-CCT3ABI5.js → use-visual-utils-BfLXO_vi.js} +34 -34
- package/dist/chunks/{use-visual-utils-ChR-Jti8.js → use-visual-utils-CzcVz3zB.js} +1 -1
- 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/surfboard/index.cjs +1 -1
- package/dist/surfboard/index.js +2 -2
- package/dist/types/dashboard.d.ts +12 -1
- package/dist/types/main.d.ts +13 -1
- package/dist/types/surfboard.d.ts +12 -1
- package/dist/types/types.d.ts +12 -1
- package/package.json +1 -1
- package/dist/chunks/editor-action-buttons-CAjqJiT_.js +0 -340
- package/dist/chunks/editor-action-buttons-DQVh7L5i.js +0 -11
- package/dist/chunks/index-DQOwJyRp.js +0 -1104
- package/dist/chunks/resource-management-panel-D_mSi7Cm.js +0 -914
- package/dist/chunks/resource-management-panel-NqaNfAq3.js +0 -6
|
@@ -1,340 +0,0 @@
|
|
|
1
|
-
import { bI as O, bA as r, bJ as j, bK as se, bL as ae, bM as te, bN as re, bO as ne, by as F, B as N, E as w, c as q, u as T, bs as k, H as E, bP as V, bQ as H, bR as X, bS as G, X as R, I as C } from "./index-CBcPi9pm.js";
|
|
2
|
-
import { jsxs as f, jsx as h, Fragment as I } from "react/jsx-runtime";
|
|
3
|
-
import { u as ce, a as D } from "./use-visual-utils-CCT3ABI5.js";
|
|
4
|
-
import { useMemo as S, useState as M } from "react";
|
|
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 de = O("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 J = O("Save", [
|
|
23
|
-
[
|
|
24
|
-
"path",
|
|
25
|
-
{
|
|
26
|
-
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",
|
|
27
|
-
key: "1c8476"
|
|
28
|
-
}
|
|
29
|
-
],
|
|
30
|
-
["path", { d: "M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7", key: "1ydtos" }],
|
|
31
|
-
["path", { d: "M7 3v4a1 1 0 0 0 1 1h7", key: "t51u73" }]
|
|
32
|
-
]);
|
|
33
|
-
function W() {
|
|
34
|
-
var e, p;
|
|
35
|
-
const n = r((m) => m.card), i = r((m) => m.frame), s = S(
|
|
36
|
-
() => j(i, n),
|
|
37
|
-
[i, n]
|
|
38
|
-
), { manifest: t } = se(
|
|
39
|
-
((e = s == null ? void 0 : s.customCardPreferences) == null ? void 0 : e.url) || ""
|
|
40
|
-
), a = S(
|
|
41
|
-
() => {
|
|
42
|
-
var m;
|
|
43
|
-
return (m = t == null ? void 0 : t.visuals) == null ? void 0 : m.find(
|
|
44
|
-
(u) => {
|
|
45
|
-
var l;
|
|
46
|
-
return u.name === ((l = s == null ? void 0 : s.customCardPreferences) == null ? void 0 : l.componentName);
|
|
47
|
-
}
|
|
48
|
-
);
|
|
49
|
-
},
|
|
50
|
-
[t, (p = s == null ? void 0 : s.customCardPreferences) == null ? void 0 : p.componentName]
|
|
51
|
-
), c = ae(s, a), o = S(
|
|
52
|
-
() => te({
|
|
53
|
-
frame: i,
|
|
54
|
-
configCard: s,
|
|
55
|
-
isMultiInputVisual: c === "multiple"
|
|
56
|
-
}),
|
|
57
|
-
[i, s, c]
|
|
58
|
-
), d = S(() => {
|
|
59
|
-
const m = o.findIndex(
|
|
60
|
-
(u) => (u == null ? void 0 : u.id) === n.id
|
|
61
|
-
);
|
|
62
|
-
return m < 0 ? -1 : re(n, m);
|
|
63
|
-
}, [o, n]);
|
|
64
|
-
return S(() => !s || c !== "multiple" || d < 0 ? n.type : ne(
|
|
65
|
-
n,
|
|
66
|
-
d,
|
|
67
|
-
a == null ? void 0 : a.slots
|
|
68
|
-
) ?? n.type, [s, c, d, n, a == null ? void 0 : a.slots]);
|
|
69
|
-
}
|
|
70
|
-
function me({
|
|
71
|
-
className: n,
|
|
72
|
-
variant: i = "outline"
|
|
73
|
-
}) {
|
|
74
|
-
var d;
|
|
75
|
-
const { setCardSql: s } = F();
|
|
76
|
-
r((e) => e.frame);
|
|
77
|
-
const t = r((e) => e.card);
|
|
78
|
-
ce(
|
|
79
|
-
((d = t.customCardPreferences) == null ? void 0 : d.url) || ""
|
|
80
|
-
), r(
|
|
81
|
-
(e) => e.selectedSchemaName
|
|
82
|
-
), r(
|
|
83
|
-
(e) => e.selectedDatamodelId
|
|
84
|
-
), r(
|
|
85
|
-
(e) => e.selectedDatabaseName
|
|
86
|
-
), r((e) => e.selectedTableName), r(
|
|
87
|
-
(e) => e.selectedConnectionId
|
|
88
|
-
), r((e) => e.isShowingVisual), t.sql;
|
|
89
|
-
const a = r((e) => e.onSave), { getUpdatedFrame: c } = D();
|
|
90
|
-
function o() {
|
|
91
|
-
const e = c();
|
|
92
|
-
a == null || a(e);
|
|
93
|
-
}
|
|
94
|
-
return /* @__PURE__ */ f(
|
|
95
|
-
N,
|
|
96
|
-
{
|
|
97
|
-
onClick: o,
|
|
98
|
-
className: q("h-8", n),
|
|
99
|
-
size: "sm",
|
|
100
|
-
variant: i,
|
|
101
|
-
children: [
|
|
102
|
-
/* @__PURE__ */ h(w, { className: "mr-2 size-4 font-bold" }),
|
|
103
|
-
"Accept"
|
|
104
|
-
]
|
|
105
|
-
}
|
|
106
|
-
);
|
|
107
|
-
}
|
|
108
|
-
function pe({
|
|
109
|
-
className: n,
|
|
110
|
-
variant: i = "default"
|
|
111
|
-
}) {
|
|
112
|
-
const s = V(), [t, a] = M(!1), c = T(
|
|
113
|
-
(l) => l.actions.setIsDashboardPanelOpen
|
|
114
|
-
), { setIsVisualEditing: o } = k(), { getUpdatedFrame: d } = D(), e = H(), p = r((l) => l.frame), m = X();
|
|
115
|
-
return /* @__PURE__ */ f(
|
|
116
|
-
N,
|
|
117
|
-
{
|
|
118
|
-
onClick: () => {
|
|
119
|
-
const l = d(), v = (p == null ? void 0 : p.visualId) || (e == null ? void 0 : e.id);
|
|
120
|
-
if (!v) {
|
|
121
|
-
C.error("No visual to save");
|
|
122
|
-
return;
|
|
123
|
-
}
|
|
124
|
-
a(!0), m.mutate(
|
|
125
|
-
{
|
|
126
|
-
visualId: v,
|
|
127
|
-
data: {
|
|
128
|
-
frameObject: l
|
|
129
|
-
}
|
|
130
|
-
},
|
|
131
|
-
{
|
|
132
|
-
onSuccess: () => {
|
|
133
|
-
a(!1), c(!0), C.success("Visual updated successfully"), s.invalidateQueries({
|
|
134
|
-
queryKey: ["resource-by-id", "visual", v],
|
|
135
|
-
exact: !0
|
|
136
|
-
});
|
|
137
|
-
},
|
|
138
|
-
onError: () => {
|
|
139
|
-
a(!1), C.error("Failed to update visual");
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
);
|
|
143
|
-
},
|
|
144
|
-
className: q("h-8", n),
|
|
145
|
-
size: "sm",
|
|
146
|
-
variant: i,
|
|
147
|
-
children: [
|
|
148
|
-
t && /* @__PURE__ */ f(I, { children: [
|
|
149
|
-
/* @__PURE__ */ h(E, { className: "mr-2 size-4 animate-spin font-bold" }),
|
|
150
|
-
" Saving"
|
|
151
|
-
] }),
|
|
152
|
-
!t && /* @__PURE__ */ f(I, { children: [
|
|
153
|
-
/* @__PURE__ */ h(J, { className: "mr-2 size-4 font-bold" }),
|
|
154
|
-
"Save to Library"
|
|
155
|
-
] })
|
|
156
|
-
]
|
|
157
|
-
}
|
|
158
|
-
);
|
|
159
|
-
}
|
|
160
|
-
function ye({
|
|
161
|
-
className: n
|
|
162
|
-
}) {
|
|
163
|
-
const i = V(), [s, t] = M(!1), a = H(), c = r((l) => l.frame), o = T((l) => l.selectedSheetId), { updateFrame: d, setIsVisualEditing: e } = k(), { getUpdatedFrame: p } = D(), m = X();
|
|
164
|
-
return /* @__PURE__ */ h(
|
|
165
|
-
N,
|
|
166
|
-
{
|
|
167
|
-
onClick: async () => {
|
|
168
|
-
if (!o) {
|
|
169
|
-
C.error("No sheet selected");
|
|
170
|
-
return;
|
|
171
|
-
}
|
|
172
|
-
const l = (c == null ? void 0 : c.visualId) || (a == null ? void 0 : a.id);
|
|
173
|
-
if (!l) {
|
|
174
|
-
C.error("No visual to update");
|
|
175
|
-
return;
|
|
176
|
-
}
|
|
177
|
-
t(!0);
|
|
178
|
-
try {
|
|
179
|
-
const v = p();
|
|
180
|
-
await m.mutateAsync({
|
|
181
|
-
visualId: l,
|
|
182
|
-
data: {
|
|
183
|
-
frameObject: v
|
|
184
|
-
}
|
|
185
|
-
});
|
|
186
|
-
const z = {
|
|
187
|
-
...v,
|
|
188
|
-
visualId: l
|
|
189
|
-
// Keep the link to library visual
|
|
190
|
-
};
|
|
191
|
-
d(o, z), i.invalidateQueries({ queryKey: ["visuals"] }), i.invalidateQueries({ queryKey: ["visual", l] }), C.success("Saved to library and applied locally"), setTimeout(() => {
|
|
192
|
-
e(!1);
|
|
193
|
-
}, 300);
|
|
194
|
-
} catch (v) {
|
|
195
|
-
console.error("Failed to save and apply:", v), C.error("Failed to save and apply changes");
|
|
196
|
-
} finally {
|
|
197
|
-
t(!1);
|
|
198
|
-
}
|
|
199
|
-
},
|
|
200
|
-
className: q("h-8", n),
|
|
201
|
-
size: "sm",
|
|
202
|
-
variant: "default",
|
|
203
|
-
disabled: s,
|
|
204
|
-
children: s ? /* @__PURE__ */ f(I, { children: [
|
|
205
|
-
/* @__PURE__ */ h(E, { className: "mr-2 size-4 animate-spin font-bold" }),
|
|
206
|
-
" Saving..."
|
|
207
|
-
] }) : /* @__PURE__ */ f(I, { children: [
|
|
208
|
-
/* @__PURE__ */ h(J, { className: "mr-2 size-4 font-bold" }),
|
|
209
|
-
"Save & Apply"
|
|
210
|
-
] })
|
|
211
|
-
}
|
|
212
|
-
);
|
|
213
|
-
}
|
|
214
|
-
function fe({ className: n }) {
|
|
215
|
-
const { getUpdatedFrame: i } = D();
|
|
216
|
-
r((e) => e.frame);
|
|
217
|
-
const s = T((e) => e.selectedSheetId), { updateFrame: t, setIsVisualEditing: a } = k(), [c, o] = M(!1);
|
|
218
|
-
return /* @__PURE__ */ f(
|
|
219
|
-
N,
|
|
220
|
-
{
|
|
221
|
-
onClick: () => {
|
|
222
|
-
if (!s) {
|
|
223
|
-
C.error("No sheet selected");
|
|
224
|
-
return;
|
|
225
|
-
}
|
|
226
|
-
o(!0);
|
|
227
|
-
const p = {
|
|
228
|
-
...i(),
|
|
229
|
-
visualId: void 0
|
|
230
|
-
// Remove the link to library visual
|
|
231
|
-
};
|
|
232
|
-
t(s, p), setTimeout(() => {
|
|
233
|
-
o(!1), C.success("Changes applied. Visual is now local to this dashboard"), a(!1);
|
|
234
|
-
}, 300);
|
|
235
|
-
},
|
|
236
|
-
className: q("h-8", n),
|
|
237
|
-
size: "sm",
|
|
238
|
-
variant: "outline",
|
|
239
|
-
children: [
|
|
240
|
-
c && /* @__PURE__ */ f(I, { children: [
|
|
241
|
-
/* @__PURE__ */ h(E, { className: "mr-2 size-4 animate-spin font-bold" }),
|
|
242
|
-
" Applying"
|
|
243
|
-
] }),
|
|
244
|
-
!c && /* @__PURE__ */ f(I, { children: [
|
|
245
|
-
/* @__PURE__ */ h(w, { className: "mr-2 size-4 font-bold" }),
|
|
246
|
-
"Apply Locally"
|
|
247
|
-
] })
|
|
248
|
-
]
|
|
249
|
-
}
|
|
250
|
-
);
|
|
251
|
-
}
|
|
252
|
-
function ve({ className: n }) {
|
|
253
|
-
const { setTempQueryData: i, setSqlGen: s } = F(), t = V(), a = r((u) => u.tempQueryData), c = r((u) => u.onClose), o = r((u) => u.card), d = W(), e = S(() => d !== o.type ? { ...o, type: d } : o, [o, d]), { queryKey: p } = G(e);
|
|
254
|
-
function m() {
|
|
255
|
-
if (a) {
|
|
256
|
-
const { queryKey: u, queryData: l } = a;
|
|
257
|
-
u && l && t.setQueryData(u, l);
|
|
258
|
-
}
|
|
259
|
-
s({}), c == null || c();
|
|
260
|
-
}
|
|
261
|
-
return /* @__PURE__ */ f(
|
|
262
|
-
N,
|
|
263
|
-
{
|
|
264
|
-
onClick: m,
|
|
265
|
-
className: q("h-8", n),
|
|
266
|
-
size: "sm",
|
|
267
|
-
variant: "outline",
|
|
268
|
-
children: [
|
|
269
|
-
/* @__PURE__ */ h(R, { className: "mr-2 size-4" }),
|
|
270
|
-
"Close"
|
|
271
|
-
]
|
|
272
|
-
}
|
|
273
|
-
);
|
|
274
|
-
}
|
|
275
|
-
function he() {
|
|
276
|
-
const { setTempQueryData: n } = F(), i = V();
|
|
277
|
-
r((b) => b.isDevMode);
|
|
278
|
-
const s = r((b) => b.tempQueryData), t = r((b) => b.card), a = W(), c = S(() => a !== t.type ? { ...t, type: a } : t, [t, a]), { queryKey: o } = G(c), {
|
|
279
|
-
setCardSql: d,
|
|
280
|
-
setSqlGen: e,
|
|
281
|
-
setCardPython: p,
|
|
282
|
-
setCardCustomCfg: m,
|
|
283
|
-
setCardPreferences: u,
|
|
284
|
-
updateDataSource: l,
|
|
285
|
-
clearQueryConfig: v,
|
|
286
|
-
setCardConfig: z,
|
|
287
|
-
setCardType: Y,
|
|
288
|
-
setFrame: Z,
|
|
289
|
-
setCard: _,
|
|
290
|
-
setActiveTabCardId: $
|
|
291
|
-
} = F();
|
|
292
|
-
function ee() {
|
|
293
|
-
var x, B, K, L;
|
|
294
|
-
const b = i.getQueryData(o);
|
|
295
|
-
s != null && s.queryData || n({
|
|
296
|
-
queryKey: o,
|
|
297
|
-
queryData: b
|
|
298
|
-
}), i.setQueryData(o, null), i.removeQueries({ queryKey: o, exact: !0 }), d(""), e({}), v(), z(void 0), p(""), m(""), u({});
|
|
299
|
-
const P = r.getState().frame, g = r.getState().card, y = j(P, g), Q = ((x = y == null ? void 0 : y.customCardPreferences) == null ? void 0 : x.visualType) === "multiple" || !!((B = y == null ? void 0 : y.customCardPreferences) != null && B.dataInputCardIds) || (((K = y == null ? void 0 : y.customCardPreferences) == null ? void 0 : K.minInputs) || 0) > 1 || (((L = y == null ? void 0 : y.customCardPreferences) == null ? void 0 : L.maxInputs) || 0) > 1, A = {
|
|
300
|
-
...g,
|
|
301
|
-
sql: "",
|
|
302
|
-
python: "",
|
|
303
|
-
config: void 0,
|
|
304
|
-
customCfg: "",
|
|
305
|
-
preferences: {},
|
|
306
|
-
customCardPreferences: Q ? g.customCardPreferences : void 0,
|
|
307
|
-
type: Q ? g.type : "bar"
|
|
308
|
-
};
|
|
309
|
-
Z({
|
|
310
|
-
...P,
|
|
311
|
-
cards: P.cards.map(
|
|
312
|
-
(U) => U.id === A.id ? A : U
|
|
313
|
-
)
|
|
314
|
-
}), $(A.id), _(A), Q || Y("bar");
|
|
315
|
-
}
|
|
316
|
-
return /* @__PURE__ */ f(
|
|
317
|
-
N,
|
|
318
|
-
{
|
|
319
|
-
onClick: ee,
|
|
320
|
-
className: "h-8",
|
|
321
|
-
size: "sm",
|
|
322
|
-
variant: "secondary",
|
|
323
|
-
children: [
|
|
324
|
-
/* @__PURE__ */ h(R, { className: "mr-2 size-3.5" }),
|
|
325
|
-
"Clear"
|
|
326
|
-
]
|
|
327
|
-
}
|
|
328
|
-
);
|
|
329
|
-
}
|
|
330
|
-
export {
|
|
331
|
-
de as C,
|
|
332
|
-
me as E,
|
|
333
|
-
J as S,
|
|
334
|
-
fe as V,
|
|
335
|
-
pe as a,
|
|
336
|
-
ye as b,
|
|
337
|
-
ve as c,
|
|
338
|
-
he as d,
|
|
339
|
-
W as u
|
|
340
|
-
};
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
"use strict";const e=require("./index-DQOwJyRp.js"),r=require("react/jsx-runtime"),h=require("./use-visual-utils-ChR-Jti8.js"),v=require("react");/**
|
|
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 k=e.createLucideIcon("CircleX",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"m9 9 6 6",key:"z0biqf"}]]);/**
|
|
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 g=e.createLucideIcon("Save",[["path",{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",key:"1c8476"}],["path",{d:"M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7",key:"1ydtos"}],["path",{d:"M7 3v4a1 1 0 0 0 1 1h7",key:"t51u73"}]]);function q(){var t,y;const u=e.useEditorStore(p=>p.card),l=e.useEditorStore(p=>p.frame),s=v.useMemo(()=>e.findCustomVisualConfigCard(l,u),[l,u]),{manifest:o}=e.useCustomVisual(((t=s==null?void 0:s.customCardPreferences)==null?void 0:t.url)||""),a=v.useMemo(()=>{var p;return(p=o==null?void 0:o.visuals)==null?void 0:p.find(d=>{var c;return d.name===((c=s==null?void 0:s.customCardPreferences)==null?void 0:c.componentName)})},[o,(y=s==null?void 0:s.customCardPreferences)==null?void 0:y.componentName]),n=e.resolveMultiInputType(s,a),i=v.useMemo(()=>e.getCustomVisualInputCards({frame:l,configCard:s,isMultiInputVisual:n==="multiple"}),[l,s,n]),m=v.useMemo(()=>{const p=i.findIndex(d=>(d==null?void 0:d.id)===u.id);return p<0?-1:e.getSlotIndexForCard(u,p)},[i,u]);return v.useMemo(()=>!s||n!=="multiple"||m<0?u.type:e.getEffectiveCardTypeForSlot(u,m,a==null?void 0:a.slots)??u.type,[s,n,m,u,a==null?void 0:a.slots])}function P({className:u,variant:l="outline"}){var m;const{setCardSql:s}=e.useEditorActions();e.useEditorStore(t=>t.frame);const o=e.useEditorStore(t=>t.card);h.useRemoteChartStore(((m=o.customCardPreferences)==null?void 0:m.url)||""),e.useEditorStore(t=>t.selectedSchemaName),e.useEditorStore(t=>t.selectedDatamodelId),e.useEditorStore(t=>t.selectedDatabaseName),e.useEditorStore(t=>t.selectedTableName),e.useEditorStore(t=>t.selectedConnectionId),e.useEditorStore(t=>t.isShowingVisual),o.sql;const a=e.useEditorStore(t=>t.onSave),{getUpdatedFrame:n}=h.useVisualUtils();function i(){const t=n();a==null||a(t)}return r.jsxs(e.Button,{onClick:i,className:e.cn("h-8",u),size:"sm",variant:l,children:[r.jsx(e.Check,{className:"mr-2 size-4 font-bold"}),"Accept"]})}function U({className:u,variant:l="default"}){const s=e.useQueryClient(),[o,a]=v.useState(!1),n=e.useDashboardStore(c=>c.actions.setIsDashboardPanelOpen),{setIsVisualEditing:i}=e.useDashboardActions(),{getUpdatedFrame:m}=h.useVisualUtils(),t=e.useSelectedVisual(),y=e.useEditorStore(c=>c.frame),p=e.useUpdateVisualMutation(),d=()=>{const c=m(),S=(y==null?void 0:y.visualId)||(t==null?void 0:t.id);if(!S){e.ue.error("No visual to save");return}a(!0),p.mutate({visualId:S,data:{frameObject:c}},{onSuccess:()=>{a(!1),n(!0),e.ue.success("Visual updated successfully"),s.invalidateQueries({queryKey:["resource-by-id","visual",S],exact:!0})},onError:()=>{a(!1),e.ue.error("Failed to update visual")}})};return r.jsxs(e.Button,{onClick:d,className:e.cn("h-8",u),size:"sm",variant:l,children:[o&&r.jsxs(r.Fragment,{children:[r.jsx(e.LoaderCircle,{className:"mr-2 size-4 animate-spin font-bold"})," Saving"]}),!o&&r.jsxs(r.Fragment,{children:[r.jsx(g,{className:"mr-2 size-4 font-bold"}),"Save to Library"]})]})}function L({className:u}){const l=e.useQueryClient(),[s,o]=v.useState(!1),a=e.useSelectedVisual(),n=e.useEditorStore(c=>c.frame),i=e.useDashboardStore(c=>c.selectedSheetId),{updateFrame:m,setIsVisualEditing:t}=e.useDashboardActions(),{getUpdatedFrame:y}=h.useVisualUtils(),p=e.useUpdateVisualMutation(),d=async()=>{if(!i){e.ue.error("No sheet selected");return}const c=(n==null?void 0:n.visualId)||(a==null?void 0:a.id);if(!c){e.ue.error("No visual to update");return}o(!0);try{const S=y();await p.mutateAsync({visualId:c,data:{frameObject:S}});const b={...S,visualId:c};m(i,b),l.invalidateQueries({queryKey:["visuals"]}),l.invalidateQueries({queryKey:["visual",c]}),e.ue.success("Saved to library and applied locally"),setTimeout(()=>{t(!1)},300)}catch(S){console.error("Failed to save and apply:",S),e.ue.error("Failed to save and apply changes")}finally{o(!1)}};return r.jsx(e.Button,{onClick:d,className:e.cn("h-8",u),size:"sm",variant:"default",disabled:s,children:s?r.jsxs(r.Fragment,{children:[r.jsx(e.LoaderCircle,{className:"mr-2 size-4 animate-spin font-bold"})," Saving..."]}):r.jsxs(r.Fragment,{children:[r.jsx(g,{className:"mr-2 size-4 font-bold"}),"Save & Apply"]})})}function K({className:u}){const{getUpdatedFrame:l}=h.useVisualUtils();e.useEditorStore(t=>t.frame);const s=e.useDashboardStore(t=>t.selectedSheetId),{updateFrame:o,setIsVisualEditing:a}=e.useDashboardActions(),[n,i]=v.useState(!1),m=()=>{if(!s){e.ue.error("No sheet selected");return}i(!0);const y={...l(),visualId:void 0};o(s,y),setTimeout(()=>{i(!1),e.ue.success("Changes applied. Visual is now local to this dashboard"),a(!1)},300)};return r.jsxs(e.Button,{onClick:m,className:e.cn("h-8",u),size:"sm",variant:"outline",children:[n&&r.jsxs(r.Fragment,{children:[r.jsx(e.LoaderCircle,{className:"mr-2 size-4 animate-spin font-bold"})," Applying"]}),!n&&r.jsxs(r.Fragment,{children:[r.jsx(e.Check,{className:"mr-2 size-4 font-bold"}),"Apply Locally"]})]})}function X({className:u}){const{setTempQueryData:l,setSqlGen:s}=e.useEditorActions(),o=e.useQueryClient(),a=e.useEditorStore(d=>d.tempQueryData),n=e.useEditorStore(d=>d.onClose),i=e.useEditorStore(d=>d.card),m=q(),t=v.useMemo(()=>m!==i.type?{...i,type:m}:i,[i,m]),{queryKey:y}=e.useDashboardCardQuery(t);function p(){if(a){const{queryKey:d,queryData:c}=a;d&&c&&o.setQueryData(d,c)}s({}),n==null||n()}return r.jsxs(e.Button,{onClick:p,className:e.cn("h-8",u),size:"sm",variant:"outline",children:[r.jsx(e.X,{className:"mr-2 size-4"}),"Close"]})}function O(){const{setTempQueryData:u}=e.useEditorActions(),l=e.useQueryClient();e.useEditorStore(C=>C.isDevMode);const s=e.useEditorStore(C=>C.tempQueryData),o=e.useEditorStore(C=>C.card),a=q(),n=v.useMemo(()=>a!==o.type?{...o,type:a}:o,[o,a]),{queryKey:i}=e.useDashboardCardQuery(n),{setCardSql:m,setSqlGen:t,setCardPython:y,setCardCustomCfg:p,setCardPreferences:d,updateDataSource:c,clearQueryConfig:S,setCardConfig:b,setCardType:z,setFrame:B,setCard:M,setActiveTabCardId:Q}=e.useEditorActions();function T(){var A,F,j,D;const C=l.getQueryData(i);s!=null&&s.queryData||u({queryKey:i,queryData:C}),l.setQueryData(i,null),l.removeQueries({queryKey:i,exact:!0}),m(""),t({}),S(),b(void 0),y(""),p(""),d({});const x=e.useEditorStore.getState().frame,E=e.useEditorStore.getState().card,f=e.findCustomVisualConfigCard(x,E),V=((A=f==null?void 0:f.customCardPreferences)==null?void 0:A.visualType)==="multiple"||!!((F=f==null?void 0:f.customCardPreferences)!=null&&F.dataInputCardIds)||(((j=f==null?void 0:f.customCardPreferences)==null?void 0:j.minInputs)||0)>1||(((D=f==null?void 0:f.customCardPreferences)==null?void 0:D.maxInputs)||0)>1,I={...E,sql:"",python:"",config:void 0,customCfg:"",preferences:{},customCardPreferences:V?E.customCardPreferences:void 0,type:V?E.type:"bar"};B({...x,cards:x.cards.map(N=>N.id===I.id?I:N)}),Q(I.id),M(I),V||z("bar")}return r.jsxs(e.Button,{onClick:T,className:"h-8",size:"sm",variant:"secondary",children:[r.jsx(e.X,{className:"mr-2 size-3.5"}),"Clear"]})}exports.CircleX=k;exports.EditorAcceptButton=P;exports.EditorCancelButton=X;exports.EditorClearButton=O;exports.Save=g;exports.VisualApplyLocalButton=K;exports.VisualSaveAndApplyButton=L;exports.VisualSaveButton=U;exports.useEffectiveEditorCardType=q;
|