react-semaphor 0.1.100 → 0.1.102

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (32) hide show
  1. package/dist/chunks/dashboard-controls-B69rp7Eg.js +26 -0
  2. package/dist/chunks/{dashboard-controls-DW1JJWP7.js → dashboard-controls-BcI9OPvx.js} +599 -599
  3. package/dist/chunks/{dashboard-json-C0CKQW3d.js → dashboard-json-BJ1c04y3.js} +1 -1
  4. package/dist/chunks/{dashboard-json-BDAEIUep.js → dashboard-json-DsxHtR1h.js} +1 -1
  5. package/dist/chunks/{edit-dashboard-visual-DQzy1fUR.js → edit-dashboard-visual-C2PPgPSf.js} +30 -21
  6. package/dist/chunks/{edit-dashboard-visual-BtV3RWgf.js → edit-dashboard-visual-CRvSRhC4.js} +31 -31
  7. package/dist/chunks/{editor-action-buttons-CReBF7FV.js → editor-action-buttons-18dPoIIF.js} +1 -1
  8. package/dist/chunks/{editor-action-buttons-BJRrkj_n.js → editor-action-buttons-D74G-fOO.js} +2 -2
  9. package/dist/chunks/{index-BDtdPUUE.js → index-BYjv54tY.js} +160 -160
  10. package/dist/chunks/{index-f2IZ7tlh.js → index-DLEb3N-R.js} +7985 -7967
  11. package/dist/chunks/resource-management-panel-DToljP14.js +11 -0
  12. package/dist/chunks/resource-management-panel-k_ZQIBfh.js +924 -0
  13. package/dist/chunks/{schedule-dashboard-CfeYnMXp.js → schedule-dashboard-fjtSpUVj.js} +4 -4
  14. package/dist/chunks/schedule-dashboard-vZXqGP-q.js +6 -0
  15. package/dist/chunks/use-click-outside-B9T3lmcw.js +1 -0
  16. package/dist/chunks/use-click-outside-CMeO_QFI.js +16 -0
  17. package/dist/chunks/{use-visual-utils-CRA2-3Z2.js → use-visual-utils-Btxew3Er.js} +1 -1
  18. package/dist/chunks/{use-visual-utils-BN4h1-xa.js → use-visual-utils-CMaqO2nT.js} +1 -1
  19. package/dist/dashboard/index.cjs +1 -1
  20. package/dist/dashboard/index.js +1 -1
  21. package/dist/index.cjs +1 -1
  22. package/dist/index.js +4 -4
  23. package/dist/style.css +1 -1
  24. package/dist/surfboard/index.cjs +1 -1
  25. package/dist/surfboard/index.js +1 -1
  26. package/package.json +1 -1
  27. package/dist/chunks/dashboard-controls-DKci3my0.js +0 -26
  28. package/dist/chunks/resource-management-panel-BQVERuRi.js +0 -11
  29. package/dist/chunks/resource-management-panel-DNpbhYNu.js +0 -982
  30. package/dist/chunks/schedule-dashboard-D8ctQToc.js +0 -6
  31. package/dist/chunks/use-local-storage-state-CWjTT77L.js +0 -26
  32. package/dist/chunks/use-local-storage-state-DXYWw213.js +0 -1
@@ -1,8 +1,8 @@
1
1
  import { jsx as e, jsxs as r, Fragment as E } from "react/jsx-runtime";
2
- import { b as W, ao as _, ap as $, aq as G, ar as J, as as K, at as M, au as R, av as X, aw as T, ax as Q, B as k, ac as Y, aa as N, ae as Z, u as g, ak as ee, a8 as q, ay as ae, az as B, ah as w, aA as se, aB as te, c as y, aC as O, aD as P, aE as L, aF as z, aG as j, ab as ne, aH as de, aI as le, aJ as re, I as ie, aK as oe, aL as ce } from "./index-f2IZ7tlh.js";
3
- import { E as he, V as ue, a as me, b as ve, S as U, c as pe } from "./editor-action-buttons-BJRrkj_n.js";
2
+ import { b as W, ao as _, ap as $, aq as G, ar as J, as as K, at as M, au as R, av as X, aw as T, ax as Q, B as k, ac as Y, aa as N, ae as Z, u as g, ak as ee, a8 as q, ay as ae, az as B, ah as w, aA as se, aB as te, c as y, aC as O, aD as P, aE as L, aF as z, aG as j, ab as ne, aH as de, aI as le, aJ as re, I as ie, aK as oe, aL as ce } from "./index-DLEb3N-R.js";
3
+ import { E as he, V as ue, a as me, b as ve, S as U, c as pe } from "./editor-action-buttons-D74G-fOO.js";
4
4
  import fe, { useState as C, useContext as be } from "react";
5
- import { a as H } from "./use-visual-utils-CRA2-3Z2.js";
5
+ import { a as H } from "./use-visual-utils-Btxew3Er.js";
6
6
  /**
7
7
  * @license lucide-react v0.453.0 - ISC
8
8
  *
@@ -144,7 +144,7 @@ function Ce() {
144
144
  (l) => l.actions.setIsDashboardPanelOpen
145
145
  ), { getUpdatedFrame: D } = H(), { selectVisual: b } = ee(), { addFrame: S, setSelectedFrameId: I, setIsVisualEditing: A } = q(), m = !!(i != null && i.visualId), F = (() => {
146
146
  var l, p;
147
- return c != null && c.title ? c.title : ((l = i == null ? void 0 : i.cards) == null ? void 0 : l.length) === 1 && ((p = i.cards[0]) != null && p.title) ? i.cards[0].title : (n == null ? void 0 : n.title) || "Untitled Visual";
147
+ return ((l = i == null ? void 0 : i.cards) == null ? void 0 : l.length) === 1 && ((p = i.cards[0]) != null && p.title) ? i.cards[0].title : c != null && c.title ? c.title : (n == null ? void 0 : n.title) || "Untitled Visual";
148
148
  })(), h = ae((l) => {
149
149
  if (l != null && l.id) {
150
150
  if (b(l), s && o && v) {
@@ -0,0 +1,6 @@
1
+ "use strict";const s=require("react/jsx-runtime"),e=require("./index-BYjv54tY.js"),f=require("./editor-action-buttons-18dPoIIF.js"),p=require("react"),y=require("./use-visual-utils-CMaqO2nT.js");/**
2
+ * @license lucide-react v0.453.0 - ISC
3
+ *
4
+ * This source code is licensed under the ISC license.
5
+ * See the LICENSE file in the root directory of this source tree.
6
+ */const k=e.createLucideIcon("CirclePlus",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M8 12h8",key:"1wcyev"}],["path",{d:"M12 8v8",key:"napkw2"}]]);function F({open:a,onOpenChange:r,isLibraryVisual:t,currentVisualName:n,isSaving:l=!1,onConfirm:h}){const[i,d]=p.useState(t&&n?`Copy of ${n}`:n||""),[c,v]=p.useState(""),[b,D]=p.useState(!t),[j,S]=p.useState(!0);p.useEffect(()=>{a&&(d(t&&n?`Copy of ${n}`:n||""),v(""),D(!t),S(!0))},[a,t,n]);const C=()=>{i.trim()&&(!b&&!j||h({name:i.trim(),description:c.trim()||void 0,saveToLibrary:b,saveToCurrentDashboard:j}))},g=i.trim()&&(b||j);return s.jsx(e.Dialog,{open:a,onOpenChange:r,children:s.jsxs(e.DialogContent,{className:"sm:max-w-[425px]",children:[s.jsxs(e.DialogHeader,{children:[s.jsx(e.DialogTitle,{children:"Save Visual As"}),s.jsx(e.DialogDescription,{children:t?"Create a copy of this visual with a new name":"Save this visual to make it reusable"})]}),s.jsxs("div",{className:"grid gap-4 py-4",children:[s.jsxs("div",{className:"grid gap-2",children:[s.jsx(e.Label,{htmlFor:"name",children:"Name"}),s.jsx(e.Input,{id:"name",value:i,onChange:m=>d(m.target.value),placeholder:"Enter visual name",disabled:l})]}),s.jsxs("div",{className:"grid gap-2",children:[s.jsx(e.Label,{htmlFor:"description",children:"Description (optional)"}),s.jsx(e.Textarea,{id:"description",value:c,onChange:m=>v(m.target.value),placeholder:"Enter visual description",rows:3,disabled:l})]}),s.jsxs("div",{className:"space-y-4",children:[s.jsx(e.Label,{children:"Save to:"}),s.jsxs("div",{className:"space-y-2",children:[s.jsxs("div",{className:"flex items-center space-x-2",children:[s.jsx(e.Checkbox,{id:"save-to-dashboard",checked:j,onCheckedChange:m=>S(!!m),disabled:l}),s.jsxs("label",{htmlFor:"save-to-dashboard",className:"text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70",children:["Current Dashboard",s.jsx("span",{className:"ml-2 text-xs text-muted-foreground",children:t?"(add copy to this dashboard)":"(keep as local visual)"})]})]}),s.jsxs("div",{className:"flex items-center space-x-2",children:[s.jsx(e.Checkbox,{id:"save-to-library",checked:b,onCheckedChange:m=>D(!!m),disabled:l}),s.jsxs("label",{htmlFor:"save-to-library",className:"text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70",children:["Visual Library",s.jsx("span",{className:"ml-2 text-xs text-muted-foreground",children:t?"(save as new reusable visual)":"(make available to all dashboards)"})]})]})]}),!b&&!j&&s.jsx("p",{className:"text-sm text-destructive",children:"Please select at least one destination"})]})]}),s.jsxs(e.DialogFooter,{children:[s.jsx(e.Button,{variant:"outline",onClick:()=>r(!1),disabled:l,children:"Cancel"}),s.jsxs(e.Button,{onClick:C,disabled:!g||l,children:[l&&s.jsx(e.LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin"}),l?"Saving...":"Save"]})]})]})})}function N(){const[a,r]=p.useState(!1),[t,n]=p.useState(!1),[l,h]=p.useState(null),i=e.useEditorStore(o=>o.frame),d=e.useEditorStore(o=>o.card),c=e.useSelectedVisual(),v=e.useDashboardStore(o=>o.selectedSheetId),b=e.useDashboardStore(o=>o.actions.setIsDashboardPanelOpen),{getUpdatedFrame:D}=y.useVisualUtils(),{selectVisual:j}=e.useManagementActions(),{addFrame:S,setSelectedFrameId:C,setIsVisualEditing:g}=e.useDashboardActions(),m=!!(i!=null&&i.visualId),w=(()=>{var o,x;return((o=i==null?void 0:i.cards)==null?void 0:o.length)===1&&((x=i.cards[0])!=null&&x.title)?i.cards[0].title:c!=null&&c.title?c.title:(d==null?void 0:d.title)||"Untitled Visual"})(),u=e.useCreateVisualWithFrame(o=>{if(o!=null&&o.id){if(j(o),t&&l&&v){const x={...l,id:e.v4(),visualId:o.id};S(v,x,"end"),C(x.id),n(!1),h(null),g(!1)}b(!0),r(!1)}});return{saveAsDialogOpen:a,setSaveAsDialogOpen:r,handleSaveAs:async o=>{if(!v){e.ue.error("No sheet selected");return}const x=D(),I=x.cards.length===1?{...x,cards:x.cards.map(A=>({...A,title:o.name}))}:x;if(o.saveToLibrary){n(o.saveToCurrentDashboard),h(I);const A={title:o.name,description:o.description,frameObject:I,isPrivate:!1};u.mutate(A)}else if(o.saveToCurrentDashboard){const A={...I,id:e.v4(),visualId:void 0};S(v,A,"end"),C(A.id),e.ue.success("Visual saved to dashboard"),r(!1),g(!1)}},isLibraryVisual:m,currentVisualName:w,isSaving:u.isPending}}function V({className:a}){const r=e.useEditorStore(u=>u.frame),t=e.useEditorStore(u=>u.card),n=e.useManagementStore(u=>u.selectedVisual),l=e.useDashboardStore(u=>u.selectedFrameId),h=e.useDashboardStore(u=>u.selectedSheetId),{setIsVisualEditing:i}=e.useDashboardActions(),d=!!(r!=null&&r.visualId||n!=null&&n.id),c=!!(r!=null&&r.visualId&&l),v=d&&!c,{saveAsDialogOpen:b,setSaveAsDialogOpen:D,handleSaveAs:j,isLibraryVisual:S,currentVisualName:C,isSaving:g}=N(),{handleAddLibraryVisual:m}=y.useVisualUtils(),w=async()=>{if(!h){e.ue.error("No dashboard sheet selected");return}if(!n){e.ue.error("No visual selected");return}const u=await m(n);u.success?(e.ue.success("Visual added to dashboard"),i(!1)):e.ue.error(u.error||"Failed to add visual to dashboard")};return s.jsxs(s.Fragment,{children:[!d&&s.jsx(f.EditorAcceptButton,{className:a,variant:"default"}),d&&s.jsxs(s.Fragment,{children:[c&&s.jsx(f.VisualApplyLocalButton,{className:a}),v&&h&&t&&(t.sql||e.hasValidCardConfig(t.config))&&s.jsxs(e.Button,{onClick:w,className:e.cn(a),size:"sm",variant:"outline",children:[s.jsx(k,{className:"mr-2 size-4 font-bold"}),"Add to Dashboard"]}),v&&s.jsx(f.VisualSaveButton,{className:a,variant:"default"}),c&&s.jsx(f.VisualSaveAndApplyButton,{className:a}),s.jsxs(e.DropdownMenu,{modal:!1,children:[s.jsx(e.DropdownMenuTrigger,{asChild:!0,children:s.jsx(e.Button,{variant:"outline",size:"sm",className:e.cn(a,"w-8 p-0"),children:s.jsx(e.EllipsisVertical,{className:"h-4 w-4"})})}),s.jsx(e.DropdownMenuContent,{align:"end",children:s.jsxs(e.DropdownMenuItem,{onClick:u=>{u.stopPropagation(),D(!0)},children:[s.jsx(f.Save,{className:"mr-2 h-4 w-4"}),"Save As..."]})})]})]}),!d&&s.jsxs(e.DropdownMenu,{modal:!1,children:[s.jsx(e.DropdownMenuTrigger,{asChild:!0,children:s.jsx(e.Button,{variant:"outline",size:"sm",className:e.cn(a,"w-8 p-0"),children:s.jsx(e.EllipsisVertical,{className:"h-4 w-4"})})}),s.jsx(e.DropdownMenuContent,{align:"end",children:s.jsxs(e.DropdownMenuItem,{onClick:()=>D(!0),children:[s.jsx(f.Save,{className:"mr-2 h-4 w-4"}),"Save As..."]})})]}),s.jsx(f.EditorCancelButton,{className:a}),s.jsx(F,{open:b,onOpenChange:u=>{g||D(u)},isLibraryVisual:S,currentVisualName:C,isSaving:g,onConfirm:j})]})}function E({className:a,switchClassName:r}){const t=e.useEditorStore(d=>d.isDevMode),n=e.useDashboardStore(d=>d.isVisualEditing),{setIsDevMode:l}=e.useEditorActions(),{config:h}=p.useContext(e.SemaphorContext).tokenProps,i=(h==null?void 0:h.showAdvancedMode)!==!1;return!n||!i?null:s.jsxs("div",{className:e.cn("flex items-center space-x-2",a),children:[s.jsx(e.DevModeSwitch,{className:e.cn("",r),checked:t,onCheckedChange:()=>l(!t),id:"advanced-mode",icon:s.jsx(e.CodeXml,{className:"h-4 w-4"}),tooltip:t?"Standard Mode":"Advanced Mode"}),s.jsx("label",{htmlFor:"advanced-mode",className:"sr-only",children:"Advanced Mode"})]})}function T(a){var r;return{...a,sheets:(r=a==null?void 0:a.sheets)==null?void 0:r.map(t=>{var n;return{...t,frames:(n=t.frames)==null?void 0:n.map(l=>{var h;return{...l,cards:(h=l.cards)==null?void 0:h.map(i=>M(i))}})}})}}function M(a){return{...a,customCfg:B(a.customCfg),data:[]}}function B(a){var r,t;return a?{...a,data:{...a==null?void 0:a.data,labels:[],datasets:(t=(r=a==null?void 0:a.data)==null?void 0:r.datasets)==null?void 0:t.map(n=>({...n,data:[]}))}}:null}function O({triggerButtonClassName:a}){const[r,t]=p.useState(!1),n=e.useDashboardStore(d=>{var c;return(c=d.dashboard)==null?void 0:c.id}),l=e.useDashboardStore(d=>{var c;return(c=d.dashboard)==null?void 0:c.title}),h=e.useDashboardStore(d=>{var c;return(c=d.dashboard)==null?void 0:c.sheets}),i=e.useDashboardStore(d=>d.selectedSheetId);return h==null||h.find(d=>d.id===i),n?s.jsxs(s.Fragment,{children:[s.jsx(e.IconButton,{tooltip:"Schedule Dashboard",className:e.cn("h-7 p-2",a),onClick:()=>t(!0),children:s.jsx(e.Clock,{className:"size-4"})}),s.jsx(e.EmailScheduleDialog,{open:r,onOpenChange:t,dashboardId:n,dashboardName:l})]}):null}exports.AdvancedModeToggle=E;exports.ScheduleDashboard=O;exports.VisualEditingControls=V;exports.cleanCard=M;exports.getDashbaordStateWithoutData=T;
@@ -0,0 +1 @@
1
+ "use strict";const i=require("react");function d(o,c={}){const{enabled:s=!0,eventType:e="mousedown"}=c,n=i.useRef(null);return i.useEffect(()=>{const r=a=>{const t=a.target;n.current&&n.current.contains(t)||t instanceof Element&&(t.closest("[data-radix-popper-content-wrapper]")||t.closest("[data-radix-select-content]")||t.closest("[data-radix-popover-content]")||t.closest("[data-radix-dropdown-menu-content]")||t.closest("[data-radix-tooltip-content]")||t.closest('[role="listbox"]')||t.closest('[role="option"]')||t.closest('[role="combobox"]'))||t instanceof Element&&t.hasAttribute("data-radix-")||o()};return s&&document.addEventListener(e,r),()=>{document.removeEventListener(e,r)}},[o,s,e]),n}exports.useClickOutside=d;
@@ -0,0 +1,16 @@
1
+ import { useRef as c, useEffect as d } from "react";
2
+ function x(n, a = {}) {
3
+ const { enabled: r = !0, eventType: e = "mousedown" } = a, o = c(null);
4
+ return d(() => {
5
+ const s = (i) => {
6
+ const t = i.target;
7
+ o.current && o.current.contains(t) || t instanceof Element && (t.closest("[data-radix-popper-content-wrapper]") || t.closest("[data-radix-select-content]") || t.closest("[data-radix-popover-content]") || t.closest("[data-radix-dropdown-menu-content]") || t.closest("[data-radix-tooltip-content]") || t.closest('[role="listbox"]') || t.closest('[role="option"]') || t.closest('[role="combobox"]')) || t instanceof Element && t.hasAttribute("data-radix-") || n();
8
+ };
9
+ return r && document.addEventListener(e, s), () => {
10
+ document.removeEventListener(e, s);
11
+ };
12
+ }, [n, r, e]), o;
13
+ }
14
+ export {
15
+ x as u
16
+ };
@@ -1,4 +1,4 @@
1
- import { ai as G, aj as z, ad as Y, ae as J, ak as K, ab as _, a8 as X, u as U, al as Z, am as q, ah as v, an as ee, aa as h } from "./index-f2IZ7tlh.js";
1
+ import { ai as G, aj as z, ad as Y, ae as J, ak as K, ab as _, a8 as X, u as U, al as Z, am as q, ah as v, an as ee, aa as h } from "./index-DLEb3N-R.js";
2
2
  import { useState as T, useEffect as te, useCallback as V } from "react";
3
3
  function re(e) {
4
4
  const a = e.toUpperCase().indexOf("WHERE"), r = e.toUpperCase().indexOf("GROUP BY"), t = e.toUpperCase().indexOf("LIMIT"), i = e.toUpperCase().indexOf("ORDER BY");
@@ -1 +1 @@
1
- "use strict";const o=require("./index-BDtdPUUE.js"),b=require("react");function _(e){const a=e.toUpperCase().indexOf("WHERE"),r=e.toUpperCase().indexOf("GROUP BY"),t=e.toUpperCase().indexOf("LIMIT"),d=e.toUpperCase().indexOf("ORDER BY");let c=e.length;if(d!==-1&&(c=d),t!==-1&&t<c&&(c=t),a!==-1){const n=e.substring(0,a),s=e.substring(a);return`${n} {{ filters | where }} AND ${s.substring(6)}`}else if(r!==-1){const n=e.substring(0,r),s=e.substring(r);return`${n} {{ filters | where }} ${s}`}else{const n=e.substring(0,c),s=e.substring(c);return console.log("beforeClause",n),console.log("afterClause",s),s?`${n} {{ filters | where }} ${s}`:`${n.replace(/;$/,"")} {{ filters | where }}`}}function B(e){const[a,r]=b.useState(null),[t,d]=b.useState(null),c=o.useEnsureReactGlobals();return b.useEffect(()=>{if(!e||e.trim()===""){r(null),d(null);return}if(!c)return;(async()=>{try{if(!e.startsWith("http://")&&!e.startsWith("https://"))throw new Error(`Invalid URL format: ${e}`);try{new URL(e)}catch{throw new Error(`Invalid URL: ${e}`)}const l=`${e.endsWith("/")?e:`${e}/`}index.js`;try{if(!(await fetch(l,{method:"HEAD"})).ok)throw new Error(`Module not found at ${l}`)}catch{}const m=await import(l);if(typeof m.useChartStore!="function")throw new Error("useChartStore is not a function");r(()=>m.useChartStore),d(null)}catch(s){const l=s instanceof Error?s.message:"Unknown error";console.error("Failed to load remote chart store:",l),d(l),r(null)}})()},[e,c]),a}function H(e,a){if(e.length===0)return"";if(a){const r=e.find(t=>t.id===a);if(r){const t=r.tabTitle;if(t=="All__Header")return e[0].id;if(t&&t.endsWith("__Header")){const c=t.split("__")[0],n=e.find(s=>s.tabTitle===c);return n?n.id:e[0].id}return a}}return e[0].id}async function j(e,a,r,t){if(!a||!r)throw new Error("Missing auth token or visual ID");const d=["resource-by-id","visual",r],c=t.getQueryData(d);if(c)return console.log("Using cached visual data for:",r),{data:c,fromCache:!0};console.log("Fetching visual data from network for:",r);const n=o.ue.loading("Loading visual...",{position:"top-center"});try{const s=await fetch(`${e}/management/v1/visuals/${r}`,{headers:{Authorization:`Bearer ${a}`}});if(!s.ok)throw new Error("Failed to load visual");const l=await s.json();return t.setQueryData(d,l),o.ue.dismiss(n),{data:l,fromCache:!1}}catch(s){throw o.ue.dismiss(n),s}}function T(e){if(typeof e=="string")return JSON.parse(e);if(typeof e=="object")return e;throw new Error("Invalid frame object format")}function Q(e,a){var c,n;const r=(e==null?void 0:e.frameObject)??((c=e==null?void 0:e.visual)==null?void 0:c.frameObject);if(!r)return!1;const t=T(r);if(!(t!=null&&t.cards)||t.cards.length===0)return!1;const d=(n=t.cards)==null?void 0:n.find(s=>s.id===t.activeCardId);return d?(o.setupEditorWithCard({...a,frame:t,card:d,visualId:(e==null?void 0:e.id)||t.visualId}),!0):!1}function G(){var g;const{setCardSql:e}=o.useEditorActions(),a=o.useEditorStore(i=>i.frame),r=o.useEditorStore(i=>i.card),t=B(((g=r.customCardPreferences)==null?void 0:g.url)||""),d=o.useEditorStore(i=>i.selectedSchemaName),c=o.useEditorStore(i=>i.selectedDatamodelId),n=o.useEditorStore(i=>i.selectedDatabaseName),s=o.useEditorStore(i=>i.selectedTableName),l=o.useEditorStore(i=>i.selectedConnectionId),m=o.useEditorStore(i=>i.isShowingVisual),f=r.sql;return{getUpdatedFrame:b.useCallback(()=>{var E;let i=f;f&&!f.includes("{{")&&(i=_(f),e(i));const C=(E=t==null?void 0:t.getState())==null?void 0:E.settings,U={...r,dataSource:r.dataSource||{mode:"directSource"},lastSelectedSchema:d,lastSelectedDatamodelId:c,lastSelectedDatabase:n,lastSelectedTable:s,connectionId:l,sql:i,customCfg:m?r.customCfg:null,preferences:r.preferences,...C&&{customCardPreferences:{...r.customCardPreferences,settings:C}}},w=a.cards.map(S=>S.id===r.id?U:S);return{...a,cards:w,activeCardId:H(w,a.activeCardId)}},[r,a,m,d,c,n,s,l,e,t,f])}}function z(){const{authToken:e,tokenProps:a}=o.useSemaphorContext(),r=o.useQueryClient(),t=o.useSelectedVisual(),{selectVisual:d}=o.useManagementActions(),{setFrame:c,setCard:n,setIsDevMode:s,setActiveTabCardId:l,updateDataSource:m,setQueryResultColumns:f,setSelectedConnectionId:V,setSelectedDatabaseName:g,setSelectedSchemaName:i,setSelectedTableName:C,setSelectedDatamodelId:U,setFilterValues:w,setApplyFilters:E}=o.useEditorActions(),{setIsDashboardEditing:S,setIsVisualEditing:$,setSelectedFrameId:v,clearSelectedFrameId:A,addFrame:N,setIsDashboardPanelOpen:R}=o.useDashboardActions(),I=o.useDashboardStore(u=>u.selectedSheetId),D=o.useDashboardStore(u=>u.selectedFrameId),O=o.useDashboardStore(u=>u.dashboard),x=o.useDashboardStore(u=>u.filterValues),y=o.useVisualById((t==null?void 0:t.id)||"",{enabled:!!(t!=null&&t.id)&&!!(e!=null&&e.accessToken)}),M=b.useCallback(async u=>{try{d(u),A();const{data:p,fromCache:h}=await j(a.apiServiceUrl,(e==null?void 0:e.accessToken)||"",u.id,r);if(!Q(p,{setFrame:c,setCard:n,setIsDevMode:s,setActiveTabCardId:l,updateDataSource:m,setQueryResultColumns:f,setSelectedConnectionId:V,setSelectedDatabaseName:g,setSelectedSchemaName:i,setSelectedTableName:C,setSelectedDatamodelId:U,setFilterValues:w,setApplyFilters:E,setIsDashboardEditing:S,setIsVisualEditing:$,dashboard:O,selectedSheetId:I,selectedFrameId:D,filterValues:x}))throw new Error("Failed to setup editor with visual data");return{success:!0,fromCache:h}}catch(p){return console.error("Error editing visual:",p),{success:!1,error:"Failed to load visual for editing"}}},[e==null?void 0:e.accessToken,a.apiServiceUrl,r,d,c,n,S,$,s,l,m,f,V,g,i,C,U,w,E,A,O,I,D,x]),k=b.useCallback(async u=>{var p;try{if(d(u),!I)return{success:!1,error:"No sheet selected. Please select a sheet first."};const{data:h,fromCache:W}=await j(a.apiServiceUrl,(e==null?void 0:e.accessToken)||"",u.id,r),L=(h==null?void 0:h.frameObject)??((p=h==null?void 0:h.visual)==null?void 0:p.frameObject);if(!L)return{success:!1,error:"Visual has no frame data"};const F=T(L);if(!(F!=null&&F.cards)||F.cards.length===0)return{success:!1,error:"Visual frame is malformed"};const P={...o.cloneFrameWithNewIds(F),visualId:u.id};return N(I,P,"end"),S(!0),v(P.id),R(!1),{success:!0,fromCache:W}}catch(h){return console.error("Error adding visual:",h),{success:!1,error:"Failed to add visual to dashboard"}}},[e==null?void 0:e.accessToken,a.apiServiceUrl,r,d,I,N,S,v,R]);return{visual:y.data,isLoading:y.isLoading,isError:y.isError,error:y.error,handleEditLibraryVisual:M,handleAddLibraryVisual:k,getUpdatedFrame:G().getUpdatedFrame,refetch:y.refetch}}exports.useRemoteChartStore=B;exports.useVisualUtils=z;
1
+ "use strict";const o=require("./index-BYjv54tY.js"),b=require("react");function _(e){const a=e.toUpperCase().indexOf("WHERE"),r=e.toUpperCase().indexOf("GROUP BY"),t=e.toUpperCase().indexOf("LIMIT"),d=e.toUpperCase().indexOf("ORDER BY");let c=e.length;if(d!==-1&&(c=d),t!==-1&&t<c&&(c=t),a!==-1){const n=e.substring(0,a),s=e.substring(a);return`${n} {{ filters | where }} AND ${s.substring(6)}`}else if(r!==-1){const n=e.substring(0,r),s=e.substring(r);return`${n} {{ filters | where }} ${s}`}else{const n=e.substring(0,c),s=e.substring(c);return console.log("beforeClause",n),console.log("afterClause",s),s?`${n} {{ filters | where }} ${s}`:`${n.replace(/;$/,"")} {{ filters | where }}`}}function B(e){const[a,r]=b.useState(null),[t,d]=b.useState(null),c=o.useEnsureReactGlobals();return b.useEffect(()=>{if(!e||e.trim()===""){r(null),d(null);return}if(!c)return;(async()=>{try{if(!e.startsWith("http://")&&!e.startsWith("https://"))throw new Error(`Invalid URL format: ${e}`);try{new URL(e)}catch{throw new Error(`Invalid URL: ${e}`)}const l=`${e.endsWith("/")?e:`${e}/`}index.js`;try{if(!(await fetch(l,{method:"HEAD"})).ok)throw new Error(`Module not found at ${l}`)}catch{}const m=await import(l);if(typeof m.useChartStore!="function")throw new Error("useChartStore is not a function");r(()=>m.useChartStore),d(null)}catch(s){const l=s instanceof Error?s.message:"Unknown error";console.error("Failed to load remote chart store:",l),d(l),r(null)}})()},[e,c]),a}function H(e,a){if(e.length===0)return"";if(a){const r=e.find(t=>t.id===a);if(r){const t=r.tabTitle;if(t=="All__Header")return e[0].id;if(t&&t.endsWith("__Header")){const c=t.split("__")[0],n=e.find(s=>s.tabTitle===c);return n?n.id:e[0].id}return a}}return e[0].id}async function j(e,a,r,t){if(!a||!r)throw new Error("Missing auth token or visual ID");const d=["resource-by-id","visual",r],c=t.getQueryData(d);if(c)return console.log("Using cached visual data for:",r),{data:c,fromCache:!0};console.log("Fetching visual data from network for:",r);const n=o.ue.loading("Loading visual...",{position:"top-center"});try{const s=await fetch(`${e}/management/v1/visuals/${r}`,{headers:{Authorization:`Bearer ${a}`}});if(!s.ok)throw new Error("Failed to load visual");const l=await s.json();return t.setQueryData(d,l),o.ue.dismiss(n),{data:l,fromCache:!1}}catch(s){throw o.ue.dismiss(n),s}}function T(e){if(typeof e=="string")return JSON.parse(e);if(typeof e=="object")return e;throw new Error("Invalid frame object format")}function Q(e,a){var c,n;const r=(e==null?void 0:e.frameObject)??((c=e==null?void 0:e.visual)==null?void 0:c.frameObject);if(!r)return!1;const t=T(r);if(!(t!=null&&t.cards)||t.cards.length===0)return!1;const d=(n=t.cards)==null?void 0:n.find(s=>s.id===t.activeCardId);return d?(o.setupEditorWithCard({...a,frame:t,card:d,visualId:(e==null?void 0:e.id)||t.visualId}),!0):!1}function G(){var g;const{setCardSql:e}=o.useEditorActions(),a=o.useEditorStore(i=>i.frame),r=o.useEditorStore(i=>i.card),t=B(((g=r.customCardPreferences)==null?void 0:g.url)||""),d=o.useEditorStore(i=>i.selectedSchemaName),c=o.useEditorStore(i=>i.selectedDatamodelId),n=o.useEditorStore(i=>i.selectedDatabaseName),s=o.useEditorStore(i=>i.selectedTableName),l=o.useEditorStore(i=>i.selectedConnectionId),m=o.useEditorStore(i=>i.isShowingVisual),f=r.sql;return{getUpdatedFrame:b.useCallback(()=>{var E;let i=f;f&&!f.includes("{{")&&(i=_(f),e(i));const C=(E=t==null?void 0:t.getState())==null?void 0:E.settings,U={...r,dataSource:r.dataSource||{mode:"directSource"},lastSelectedSchema:d,lastSelectedDatamodelId:c,lastSelectedDatabase:n,lastSelectedTable:s,connectionId:l,sql:i,customCfg:m?r.customCfg:null,preferences:r.preferences,...C&&{customCardPreferences:{...r.customCardPreferences,settings:C}}},w=a.cards.map(S=>S.id===r.id?U:S);return{...a,cards:w,activeCardId:H(w,a.activeCardId)}},[r,a,m,d,c,n,s,l,e,t,f])}}function z(){const{authToken:e,tokenProps:a}=o.useSemaphorContext(),r=o.useQueryClient(),t=o.useSelectedVisual(),{selectVisual:d}=o.useManagementActions(),{setFrame:c,setCard:n,setIsDevMode:s,setActiveTabCardId:l,updateDataSource:m,setQueryResultColumns:f,setSelectedConnectionId:V,setSelectedDatabaseName:g,setSelectedSchemaName:i,setSelectedTableName:C,setSelectedDatamodelId:U,setFilterValues:w,setApplyFilters:E}=o.useEditorActions(),{setIsDashboardEditing:S,setIsVisualEditing:$,setSelectedFrameId:v,clearSelectedFrameId:A,addFrame:N,setIsDashboardPanelOpen:R}=o.useDashboardActions(),I=o.useDashboardStore(u=>u.selectedSheetId),D=o.useDashboardStore(u=>u.selectedFrameId),O=o.useDashboardStore(u=>u.dashboard),x=o.useDashboardStore(u=>u.filterValues),y=o.useVisualById((t==null?void 0:t.id)||"",{enabled:!!(t!=null&&t.id)&&!!(e!=null&&e.accessToken)}),M=b.useCallback(async u=>{try{d(u),A();const{data:p,fromCache:h}=await j(a.apiServiceUrl,(e==null?void 0:e.accessToken)||"",u.id,r);if(!Q(p,{setFrame:c,setCard:n,setIsDevMode:s,setActiveTabCardId:l,updateDataSource:m,setQueryResultColumns:f,setSelectedConnectionId:V,setSelectedDatabaseName:g,setSelectedSchemaName:i,setSelectedTableName:C,setSelectedDatamodelId:U,setFilterValues:w,setApplyFilters:E,setIsDashboardEditing:S,setIsVisualEditing:$,dashboard:O,selectedSheetId:I,selectedFrameId:D,filterValues:x}))throw new Error("Failed to setup editor with visual data");return{success:!0,fromCache:h}}catch(p){return console.error("Error editing visual:",p),{success:!1,error:"Failed to load visual for editing"}}},[e==null?void 0:e.accessToken,a.apiServiceUrl,r,d,c,n,S,$,s,l,m,f,V,g,i,C,U,w,E,A,O,I,D,x]),k=b.useCallback(async u=>{var p;try{if(d(u),!I)return{success:!1,error:"No sheet selected. Please select a sheet first."};const{data:h,fromCache:W}=await j(a.apiServiceUrl,(e==null?void 0:e.accessToken)||"",u.id,r),L=(h==null?void 0:h.frameObject)??((p=h==null?void 0:h.visual)==null?void 0:p.frameObject);if(!L)return{success:!1,error:"Visual has no frame data"};const F=T(L);if(!(F!=null&&F.cards)||F.cards.length===0)return{success:!1,error:"Visual frame is malformed"};const P={...o.cloneFrameWithNewIds(F),visualId:u.id};return N(I,P,"end"),S(!0),v(P.id),R(!1),{success:!0,fromCache:W}}catch(h){return console.error("Error adding visual:",h),{success:!1,error:"Failed to add visual to dashboard"}}},[e==null?void 0:e.accessToken,a.apiServiceUrl,r,d,I,N,S,v,R]);return{visual:y.data,isLoading:y.isLoading,isError:y.isError,error:y.error,handleEditLibraryVisual:M,handleAddLibraryVisual:k,getUpdatedFrame:G().getUpdatedFrame,refetch:y.refetch}}exports.useRemoteChartStore=B;exports.useVisualUtils=z;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("../chunks/index-BDtdPUUE.js"),r=require("../types/index.cjs");exports.Dashboard=e.Dashboard;exports.EMPTY_SELECTION=r.EMPTY_SELECTION;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("../chunks/index-BYjv54tY.js"),r=require("../types/index.cjs");exports.Dashboard=e.Dashboard;exports.EMPTY_SELECTION=r.EMPTY_SELECTION;
@@ -1,4 +1,4 @@
1
- import { D as a } from "../chunks/index-f2IZ7tlh.js";
1
+ import { D as a } from "../chunks/index-DLEb3N-R.js";
2
2
  import { EMPTY_SELECTION as e } from "../types/index.js";
3
3
  export {
4
4
  a as Dashboard,
package/dist/index.cjs CHANGED
@@ -1,4 +1,4 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./chunks/index-BDtdPUUE.js"),j=require("./types/index.cjs"),a=require("react/jsx-runtime"),g=require("react"),E=require("./chunks/resource-management-panel-BQVERuRi.js"),h=require("./chunks/schedule-dashboard-D8ctQToc.js");require("react-dom");function N(t){const r=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const n in t)if(n!=="default"){const i=Object.getOwnPropertyDescriptor(t,n);Object.defineProperty(r,n,i.get?i:{enumerable:!0,get:()=>t[n]})}}return r.default=t,Object.freeze(r)}const p=N(g);/**
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./chunks/index-BYjv54tY.js"),j=require("./types/index.cjs"),a=require("react/jsx-runtime"),g=require("react"),E=require("./chunks/resource-management-panel-DToljP14.js"),h=require("./chunks/schedule-dashboard-vZXqGP-q.js");require("react-dom");function N(t){const r=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const n in t)if(n!=="default"){const i=Object.getOwnPropertyDescriptor(t,n);Object.defineProperty(r,n,i.get?i:{enumerable:!0,get:()=>t[n]})}}return r.default=t,Object.freeze(r)}const p=N(g);/**
2
2
  * @license lucide-react v0.453.0 - ISC
3
3
  *
4
4
  * This source code is licensed under the ISC license.
package/dist/index.js CHANGED
@@ -1,11 +1,11 @@
1
- import { b as S, E as D, F as w, S as P, U as M, e as k, C as A, u as F, f as g, g as L, P as R, h as I, B as V, c as v, i as _, j as W, k as B, l as j, I as q, m as O, n as z, o as G, p as H, q as Q } from "./chunks/index-f2IZ7tlh.js";
2
- import { G as oa, H as ta, D as na, x as ia, M as la, R as da, t as ca, t as ua, v as ha, a as pa, a9 as fa, Y as ma, z as Ca, N as va, _ as ya, Z as ba, a1 as ga, a2 as Da, W as xa, y as Ea, V as Na, K as Ta, L as Sa, J as wa, $ as Pa, T as Ma, Q as ka, O as Aa, a3 as Fa, a0 as La, w as Ra, a5 as Ia, a7 as Va, a6 as _a, a8 as Wa, A as Ba, r as ja, ab as qa, a4 as Oa, aa as za, s as Ga } from "./chunks/index-f2IZ7tlh.js";
1
+ import { b as S, E as D, F as w, S as P, U as M, e as k, C as A, u as F, f as g, g as L, P as R, h as I, B as V, c as v, i as _, j as W, k as B, l as j, I as q, m as O, n as z, o as G, p as H, q as Q } from "./chunks/index-DLEb3N-R.js";
2
+ import { G as oa, H as ta, D as na, x as ia, M as la, R as da, t as ca, t as ua, v as ha, a as pa, a9 as fa, Y as ma, z as Ca, N as va, _ as ya, Z as ba, a1 as ga, a2 as Da, W as xa, y as Ea, V as Na, K as Ta, L as Sa, J as wa, $ as Pa, T as Ma, Q as ka, O as Aa, a3 as Fa, a0 as La, w as Ra, a5 as Ia, a7 as Va, a6 as _a, a8 as Wa, A as Ba, r as ja, ab as qa, a4 as Oa, aa as za, s as Ga } from "./chunks/index-DLEb3N-R.js";
3
3
  import { EMPTY_SELECTION as Qa } from "./types/index.js";
4
4
  import { jsx as a, jsxs as l } from "react/jsx-runtime";
5
5
  import * as p from "react";
6
6
  import { useMemo as U } from "react";
7
- import { ResourceManagementPanel as Ka } from "./chunks/resource-management-panel-DNpbhYNu.js";
8
- import { A as $a, S as Ja, V as Xa, c as Za, g as ae } from "./chunks/schedule-dashboard-CfeYnMXp.js";
7
+ import { ResourceManagementPanel as Ka } from "./chunks/resource-management-panel-k_ZQIBfh.js";
8
+ import { A as $a, S as Ja, V as Xa, c as Za, g as ae } from "./chunks/schedule-dashboard-fjtSpUVj.js";
9
9
  import "react-dom";
10
10
  /**
11
11
  * @license lucide-react v0.453.0 - ISC