@burdenoff/microfe-bigconsole 2026.1118.5 → 2026.1118.7

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.
@@ -9,37 +9,37 @@ import { Fragment as l, jsx as u, jsxs as d } from "react/jsx-runtime";
9
9
  import { createPortal as f } from "react-dom";
10
10
  // src/bigconsole/components/widgets/WidgetMenu.tsx
11
11
  var p = r(function({ widget: r, isEditMode: p, onRefresh: m, onExportCSV: h, onExportPNG: g, onSpotOutliers: _, onReconcile: v }) {
12
- let [y, b] = s(!1), [x, S] = s({
12
+ let [y, b] = s(!1), [x, S] = s(!1), [C, w] = s({
13
13
  top: 0,
14
14
  left: 0
15
- }), C = o(null), w = o(null), { hasPermission: T } = c(), E = T(n.WIDGET_UPDATE), D = T(n.WIDGET_CREATE), O = T(n.WIDGET_DELETE), k = e((e) => e.selectWidget), A = e((e) => e.copyWidget), j = e((e) => e.cutWidget), M = e((e) => e.removeWidget), N = e((e) => e.openConfigPanel), { duplicateWidget: P, deleteWidget: F, refreshWidgetData: I } = t(r.pageId, r.dashboardId, { skipFetch: !0 });
15
+ }), T = o(null), E = o(null), { hasPermission: D } = c(), O = D(n.WIDGET_UPDATE), k = D(n.WIDGET_CREATE), A = D(n.WIDGET_DELETE), j = e((e) => e.selectWidget), M = e((e) => e.copyWidget), N = e((e) => e.cutWidget), P = e((e) => e.removeWidget), F = e((e) => e.openConfigPanel), { duplicateWidget: I, deleteWidget: L, refreshWidgetData: R } = t(r.pageId, r.dashboardId, { skipFetch: !0 });
16
16
  a(() => {
17
17
  let e = (e) => {
18
- C.current && !C.current.contains(e.target) && w.current && !w.current.contains(e.target) && b(!1);
18
+ T.current && !T.current.contains(e.target) && E.current && !E.current.contains(e.target) && b(!1);
19
19
  };
20
20
  return y && document.addEventListener("mousedown", e), () => {
21
21
  document.removeEventListener("mousedown", e);
22
22
  };
23
23
  }, [y]), a(() => {
24
24
  let e = (e) => {
25
- e.key === "Escape" && (b(!1), w.current?.focus());
25
+ e.key === "Escape" && (b(!1), E.current?.focus());
26
26
  };
27
27
  return y && document.addEventListener("keydown", e), () => {
28
28
  document.removeEventListener("keydown", e);
29
29
  };
30
30
  }, [y]);
31
- let L = i((e) => {
31
+ let z = i((e) => {
32
32
  e.stopPropagation(), b((e) => {
33
- if (!e && w.current) {
34
- let e = w.current.getBoundingClientRect(), t = e.bottom + 4, n = e.right - 160;
35
- n + 160 > window.innerWidth - 10 && (n = window.innerWidth - 160 - 10), n < 10 && (n = 10), t + 320 > window.innerHeight - 10 && (t = e.top - 320 - 4, t < 10 && (t = 10)), S({
33
+ if (!e && E.current) {
34
+ let e = E.current.getBoundingClientRect(), t = e.bottom + 4, n = e.right - 160;
35
+ n + 160 > window.innerWidth - 10 && (n = window.innerWidth - 160 - 10), n < 10 && (n = 10), t + 320 > window.innerHeight - 10 && (t = e.top - 320 - 4, t < 10 && (t = 10)), w({
36
36
  top: t + window.scrollY,
37
37
  left: n + window.scrollX
38
38
  });
39
39
  }
40
40
  return !e;
41
41
  });
42
- }, []), R = [
42
+ }, []), B = [
43
43
  {
44
44
  id: "edit",
45
45
  label: "Edit Widget",
@@ -56,10 +56,10 @@ var p = r(function({ widget: r, isEditMode: p, onRefresh: m, onExportCSV: h, onE
56
56
  })
57
57
  }),
58
58
  action: () => {
59
- k(r.id), N(), b(!1);
59
+ j(r.id), F(), b(!1);
60
60
  },
61
61
  disabled: !p,
62
- permitted: E
62
+ permitted: O
63
63
  },
64
64
  {
65
65
  id: "refresh",
@@ -77,7 +77,7 @@ var p = r(function({ widget: r, isEditMode: p, onRefresh: m, onExportCSV: h, onE
77
77
  })
78
78
  }),
79
79
  action: async () => {
80
- b(!1), m ? m() : await I(r.id);
80
+ b(!1), m ? m() : await R(r.id);
81
81
  },
82
82
  disabled: !1
83
83
  },
@@ -183,10 +183,10 @@ var p = r(function({ widget: r, isEditMode: p, onRefresh: m, onExportCSV: h, onE
183
183
  })
184
184
  }),
185
185
  action: () => {
186
- A(r.id), b(!1);
186
+ M(r.id), b(!1);
187
187
  },
188
188
  disabled: !p,
189
- permitted: D
189
+ permitted: k
190
190
  },
191
191
  {
192
192
  id: "cut",
@@ -204,10 +204,10 @@ var p = r(function({ widget: r, isEditMode: p, onRefresh: m, onExportCSV: h, onE
204
204
  })
205
205
  }),
206
206
  action: () => {
207
- j(r.id), b(!1);
207
+ N(r.id), b(!1);
208
208
  },
209
209
  disabled: !p,
210
- permitted: D && E
210
+ permitted: k && O
211
211
  },
212
212
  {
213
213
  id: "duplicate",
@@ -232,10 +232,10 @@ var p = r(function({ widget: r, isEditMode: p, onRefresh: m, onExportCSV: h, onE
232
232
  width: r.positionWidth ?? 4,
233
233
  height: r.positionHeight ?? 4
234
234
  };
235
- await P(r.id, e, `${r.title} (Copy)`);
235
+ await I(r.id, e, `${r.title} (Copy)`);
236
236
  },
237
237
  disabled: !p,
238
- permitted: D
238
+ permitted: k
239
239
  },
240
240
  {
241
241
  id: "divider2",
@@ -260,24 +260,33 @@ var p = r(function({ widget: r, isEditMode: p, onRefresh: m, onExportCSV: h, onE
260
260
  })
261
261
  }),
262
262
  action: async () => {
263
- window.confirm("Are you sure you want to delete this widget?") ? (b(!1), await F(r.id) || M(r.id)) : b(!1);
263
+ if (window.confirm("Are you sure you want to delete this widget?")) {
264
+ b(!1);
265
+ let e = await L(r.id);
266
+ r.savedQueryId ? S(!e) : e || P(r.id);
267
+ } else b(!1);
264
268
  },
265
269
  disabled: !p,
266
270
  destructive: !0,
267
- permitted: O
271
+ permitted: A
268
272
  }
269
- ].filter((e) => e.permitted !== !1), z = R.filter((e, t) => {
273
+ ].filter((e) => e.permitted !== !1 && (!r.savedQueryId || p && e.id === "delete")), V = B.filter((e, t) => {
270
274
  if (!e.divider) return !0;
271
- let n = R[t - 1], r = R[t + 1];
275
+ let n = B[t - 1], r = B[t + 1];
272
276
  return n !== void 0 && r !== void 0 && !n.divider && !r.divider;
273
277
  });
274
- return /* @__PURE__ */ d("div", {
278
+ return V.length ? /* @__PURE__ */ d("div", {
275
279
  className: "relative",
276
- children: [/* @__PURE__ */ u("button", {
277
- ref: w,
278
- type: "button",
279
- onClick: L,
280
- className: `
280
+ children: [
281
+ x && /* @__PURE__ */ u("span", {
282
+ role: "alert",
283
+ children: "Could not delete this widget."
284
+ }),
285
+ /* @__PURE__ */ u("button", {
286
+ ref: E,
287
+ type: "button",
288
+ onClick: z,
289
+ className: `
281
290
  p-1.5 rounded-md
282
291
  text-text-secondary
283
292
  hover:text-text-primary
@@ -285,59 +294,61 @@ var p = r(function({ widget: r, isEditMode: p, onRefresh: m, onExportCSV: h, onE
285
294
  transition-colors
286
295
  ${y ? "bg-bg-sunken" : ""}
287
296
  `,
288
- title: "Widget options",
289
- "aria-haspopup": "menu",
290
- "aria-expanded": y,
291
- children: /* @__PURE__ */ d("svg", {
292
- className: "w-4 h-4",
293
- fill: "currentColor",
294
- viewBox: "0 0 24 24",
295
- children: [
296
- /* @__PURE__ */ u("circle", {
297
- cx: "12",
298
- cy: "5",
299
- r: "2"
300
- }),
301
- /* @__PURE__ */ u("circle", {
302
- cx: "12",
303
- cy: "12",
304
- r: "2"
305
- }),
306
- /* @__PURE__ */ u("circle", {
307
- cx: "12",
308
- cy: "19",
309
- r: "2"
310
- })
311
- ]
312
- })
313
- }), y && f(/* @__PURE__ */ u("div", {
314
- ref: C,
315
- style: {
316
- position: "fixed",
317
- top: x.top,
318
- left: x.left,
319
- zIndex: 99999
320
- },
321
- className: "\n min-w-[160px]\n py-1\n bg-bg-surface\n border border-border-default\n rounded-lg shadow-lg\n ",
322
- role: "menu",
323
- "aria-orientation": "vertical",
324
- children: z.map((e) => e.divider ? /* @__PURE__ */ u("div", { className: "my-1 border-t border-border-default" }, e.id) : /* @__PURE__ */ d("button", {
325
- type: "button",
326
- onClick: (t) => {
327
- t.stopPropagation(), e.action();
297
+ title: "Widget options",
298
+ "aria-haspopup": "menu",
299
+ "aria-expanded": y,
300
+ children: /* @__PURE__ */ d("svg", {
301
+ className: "w-4 h-4",
302
+ fill: "currentColor",
303
+ viewBox: "0 0 24 24",
304
+ children: [
305
+ /* @__PURE__ */ u("circle", {
306
+ cx: "12",
307
+ cy: "5",
308
+ r: "2"
309
+ }),
310
+ /* @__PURE__ */ u("circle", {
311
+ cx: "12",
312
+ cy: "12",
313
+ r: "2"
314
+ }),
315
+ /* @__PURE__ */ u("circle", {
316
+ cx: "12",
317
+ cy: "19",
318
+ r: "2"
319
+ })
320
+ ]
321
+ })
322
+ }),
323
+ y && f(/* @__PURE__ */ u("div", {
324
+ ref: T,
325
+ style: {
326
+ position: "fixed",
327
+ top: C.top,
328
+ left: C.left,
329
+ zIndex: 99999
328
330
  },
329
- disabled: e.disabled,
330
- className: `
331
+ className: "\n min-w-[160px]\n py-1\n bg-bg-surface\n border border-border-default\n rounded-lg shadow-lg\n ",
332
+ role: "menu",
333
+ "aria-orientation": "vertical",
334
+ children: V.map((e) => e.divider ? /* @__PURE__ */ u("div", { className: "my-1 border-t border-border-default" }, e.id) : /* @__PURE__ */ d("button", {
335
+ type: "button",
336
+ onClick: (t) => {
337
+ t.stopPropagation(), e.action();
338
+ },
339
+ disabled: e.disabled,
340
+ className: `
331
341
  w-full flex items-center gap-2
332
342
  px-3 py-2 text-left text-sm
333
343
  transition-colors
334
344
  ${e.disabled ? "opacity-50 cursor-not-allowed" : "hover:bg-bg-sunken"}
335
345
  ${e.destructive ? "text-status-error-text hover:text-status-error-text" : "text-text-primary"}
336
346
  `,
337
- role: "menuitem",
338
- children: [e.icon, /* @__PURE__ */ u("span", { children: e.label })]
339
- }, e.id))
340
- }), document.body)]
341
- });
347
+ role: "menuitem",
348
+ children: [e.icon, /* @__PURE__ */ u("span", { children: e.label })]
349
+ }, e.id))
350
+ }), document.body)
351
+ ]
352
+ }) : null;
342
353
  });
343
354
  export { p as WidgetMenu, p as default };