semaphor 0.0.129 → 0.0.130

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 (33) hide show
  1. package/dist/chunks/dashboard-controls-BMLlOkS9.js +1539 -0
  2. package/dist/chunks/dashboard-controls-BdQcYRkf.js +26 -0
  3. package/dist/chunks/dashboard-export-dialog-BpNaUA5x.js +6 -0
  4. package/dist/chunks/dashboard-export-dialog-CbMcLZvW.js +602 -0
  5. package/dist/chunks/dashboard-json-DD-d9gYu.js +66 -0
  6. package/dist/chunks/dashboard-json-DgQozDAv.js +1 -0
  7. package/dist/chunks/edit-dashboard-visual-CR3NqJ7m.js +200 -0
  8. package/dist/chunks/edit-dashboard-visual-CRMhXxdG.js +15517 -0
  9. package/dist/chunks/editor-action-buttons-CNQtSzD5.js +270 -0
  10. package/dist/chunks/editor-action-buttons-DYrSZQhJ.js +6 -0
  11. package/dist/chunks/index-CReqnEJI.js +1081 -0
  12. package/dist/chunks/{index-CE57mw6l.js → index-QdSI9E0a.js} +82751 -68873
  13. package/dist/chunks/resource-management-panel-CBXn6QHi.js +895 -0
  14. package/dist/chunks/resource-management-panel-CXSx9QhW.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-BDuNB0Iz.js +1 -0
  18. package/dist/chunks/use-visual-utils-BnCl386t.js +331 -0
  19. package/dist/dashboard/index.cjs +1 -1
  20. package/dist/dashboard/index.js +1 -1
  21. package/dist/index.cjs +2 -2
  22. package/dist/index.js +138 -161
  23. package/dist/style.css +1 -1
  24. package/dist/surfboard/index.cjs +1 -1
  25. package/dist/surfboard/index.js +4 -4
  26. package/dist/types/dashboard.d.ts +500 -16
  27. package/dist/types/main.d.ts +882 -82
  28. package/dist/types/surfboard.d.ts +500 -16
  29. package/dist/types/types.d.ts +500 -16
  30. package/package.json +11 -7
  31. package/dist/chunks/dashboard-plus-BZ8k_sGe.js +0 -280
  32. package/dist/chunks/dashboard-plus-qMRXHdYf.js +0 -20761
  33. package/dist/chunks/index-Bo0bvCRT.js +0 -975
@@ -0,0 +1,6 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),s=require("./index-CReqnEJI.js"),m=require("react"),re=require("./use-visual-utils-BDuNB0Iz.js"),ue=require("./use-click-outside-B9T3lmcw.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 he=s.createLucideIcon("FolderOpen",[["path",{d:"m6 14 1.5-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.54 6a2 2 0 0 1-1.95 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2",key:"usdka0"}]]);function oe(){return e.jsx("div",{className:"space-y-1 px-2 py-2",children:[...Array(5)].map((t,g)=>e.jsxs("div",{className:"flex animate-pulse items-start gap-3 rounded-md px-2 py-2",children:[e.jsx("div",{className:"mt-0.5 h-4 w-4 flex-shrink-0 rounded bg-muted/60"}),e.jsxs("div",{className:"flex-1 space-y-1.5",children:[e.jsx("div",{className:"h-4 w-3/5 rounded bg-muted/60"}),e.jsx("div",{className:"h-3 w-4/5 rounded bg-muted/40"})]})]},g))})}const me=t=>{const g=s.useDashboardStore(r=>r.isVisualEditing),p=s.useDashboardStore(r=>r.selectedFrameId),a=s.useEditorStore(r=>r.frame);return!!(g&&p&&(a==null?void 0:a.visualId)===t)};function xe({visual:t,isDeleting:g,isDuplicating:p,onAddVisual:a,onOpenVisual:r,onEditDetails:f,onDeleteClick:j,onDuplicateVisual:x,onShareVisual:D,formatDate:S}){var M,v,w,T;const{selectVisual:l}=s.useManagementActions(),d=s.useIsVisualSelected(t.id),h=me(t.id),{isConsoleMode:b}=s.useDashboardPreferences(),V=m.useRef(null),[N,y]=m.useState(!1),[A,E]=m.useState(!1);m.useEffect(()=>{p?(y(!0),E(!0)):A&&(y(!1),E(!1))},[p,A]),m.useEffect(()=>{h&&V.current&&V.current.scrollIntoView({behavior:"smooth",block:"center"})},[h]);const I=()=>{l(t),r==null||r(t)};return e.jsxs("div",{ref:V,className:s.cn("group flex cursor-pointer items-start gap-3 rounded-md px-2 py-2 transition-colors hover:bg-muted",h?"bg-purple-500/10":d&&"bg-muted/80"),onClick:I,children:[e.jsx(s.ChartLine,{className:"mt-0.5 h-4 w-4 flex-shrink-0 text-muted-foreground/50"}),e.jsx("div",{className:"min-w-0 flex-1",children:e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("p",{className:"truncate text-sm font-medium text-foreground",title:t.title||"Untitled Visual",children:t.title||"Untitled Visual"}),e.jsx("p",{className:"truncate text-xs text-muted-foreground",title:t.description||"No description",children:(M=t.description)!=null&&M.trim()?t.description:"No description"})]}),e.jsxs("div",{className:"flex flex-shrink-0 items-center gap-1",onClick:c=>c.stopPropagation(),children:[e.jsx("div",{className:"opacity-0 transition-opacity group-hover:opacity-100",children:e.jsxs(s.DropdownMenu,{modal:!1,open:N,onOpenChange:y,children:[e.jsx(s.DropdownMenuTrigger,{asChild:!0,children:e.jsx(s.Button,{size:"sm",variant:"ghost",className:"h-6 w-6 p-0",children:e.jsx(s.EllipsisVertical,{className:"h-3 w-3"})})}),e.jsxs(s.DropdownMenuContent,{align:"end",className:"z-[51] w-40",children:[e.jsxs(s.DropdownMenuItem,{onClick:c=>{c.stopPropagation(),a(t)},children:[e.jsx(s.Plus,{className:"mr-2 h-3 w-3"}),"Add"]}),e.jsxs(s.DropdownMenuItem,{onClick:c=>{c.stopPropagation(),r==null||r(t)},children:[e.jsx(he,{className:"mr-2 h-3 w-3"}),"Open"]}),e.jsxs(s.DropdownMenuItem,{onClick:c=>{c.preventDefault(),c.stopPropagation(),x(t.id)},disabled:p,children:[p?e.jsx(s.LoaderCircle,{className:"mr-2 h-3 w-3 animate-spin"}):e.jsx(s.Copy,{className:"mr-2 h-3 w-3"}),p?"Duplicating...":"Duplicate"]}),t.ownership.isOwner&&e.jsxs(e.Fragment,{children:[e.jsxs(s.DropdownMenuItem,{onClick:c=>{c.stopPropagation(),f==null||f(t)},children:[e.jsx(s.PenLine,{className:"mr-2 h-3 w-3"}),"Edit details"]}),e.jsxs(s.DropdownMenuItem,{onClick:c=>{c.stopPropagation(),D(t)},children:[e.jsx(s.Users,{className:"mr-2 h-3 w-3"}),"Share"]}),e.jsx(s.DropdownMenuSeparator,{}),e.jsxs(s.DropdownMenuItem,{onClick:c=>{c.stopPropagation(),j(t)},className:"text-destructive",disabled:g,children:[e.jsx(s.Trash2,{className:"mr-2 h-3 w-3"}),g?"Deleting...":"Delete"]})]}),e.jsx(s.DropdownMenuSeparator,{}),e.jsxs("div",{className:"space-y-1 px-2 py-2 text-xs text-slate-500 dark:text-slate-400",children:[(((v=t.ownership.createdBy)==null?void 0:v.type)==="tenant"||((w=t.ownership.createdBy)==null?void 0:w.type)==="organization"&&b)&&e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(s.User,{className:"h-3 w-3"}),e.jsx("span",{children:((T=t.ownership.createdBy)==null?void 0:T.name)||"Unknown"})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(s.Calendar,{className:"h-3 w-3"}),e.jsx("span",{children:S(t.lastModified)})]})]})]})]})}),e.jsx(s.IconButton,{tooltip:"Add to dashboard",buttonProps:{variant:"ghost",size:"sm",onClick:c=>{c.stopPropagation(),a(t)}},className:"h-6 w-6 p-0",children:e.jsx(s.Plus,{className:"h-3.5 w-3.5"})})]})]})})]},t.id)}function pe({searchQuery:t}){const[g,p]=m.useState(!1),[a,r]=m.useState(null),[f,j]=m.useState(!1),[x,D]=m.useState(null),[S,l]=m.useState(null),[d,h]=m.useState(null),{selectVisual:b}=s.useManagementActions(),{handleEditLibraryVisual:V,handleAddLibraryVisual:N}=re.useVisualUtils(),{resources:y,isLoading:A,isError:E,updateResource:I,deleteResource:M,duplicateResource:v,isDeleting:w}=s.useVisualManagement(()=>{j(!1),D(null)});s.useCurrentUserInfo();const T=y.filter(i=>{var L,o;return((L=i==null?void 0:i.title)==null?void 0:L.toLowerCase().includes(t.toLowerCase()))||((o=i==null?void 0:i.description)==null?void 0:o.toLowerCase().includes(t.toLowerCase()))}),c=i=>new Date(i).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"}),U=i=>{D(i),j(!0)},Y=()=>{x&&M(x.id)},{startUpdating:F,stopUpdating:K,isUpdating:P}=s.useResourceUpdateState(),B=(i,L,o)=>{var k;const W=Object.fromEntries(Object.entries(L).filter(([,R])=>R!==void 0));if(Object.keys(W).length===0){(k=o==null?void 0:o.onSuccess)==null||k.call(o);return}const $=Object.keys(W),Z=$.length===1?$[0]:void 0;F(i,Z),I({resourceId:i,data:W},{onSuccess:()=>{var R;K(i,Z),(R=o==null?void 0:o.onSuccess)==null||R.call(o)},onError:()=>{var R;K(i,Z),(R=o==null?void 0:o.onError)==null||R.call(o)}})},z=i=>{l(i),v(i,{onSettled:()=>l(null)})},J=i=>{V(i)},H=i=>{N(i)},Q=i=>{const L=y.find(o=>o.id===i);L&&I({resourceId:i,data:{isPrivate:!L.isPrivate}})},q=i=>{r(i),p(!0)},G=i=>{h(i)},C=()=>{h(null)},X=({title:i,description:L})=>{if(!d)return;const o={};i!==d.title&&(o.title=i),(d.description||"")!==L&&(o.description=L),B(d.id,o,{onSuccess:()=>{h(null)}})};return A?e.jsx(oe,{}):E?e.jsx(s.ScrollArea,{className:"w-full flex-1 pr-2",children:e.jsxs("div",{className:"py-8 text-center text-muted-foreground",children:[e.jsx("p",{className:"text-sm text-destructive",children:"Failed to load visuals"}),e.jsx(s.Button,{variant:"outline",size:"sm",className:"mt-2",onClick:()=>window.location.reload(),children:"Retry"})]})}):e.jsxs("div",{className:"flex h-full flex-1 flex-col",children:[e.jsx("div",{className:"flex flex-1 basis-0 flex-col gap-3 overflow-y-auto",children:T.length===0?e.jsxs("div",{className:"py-8 text-center",children:[e.jsx("div",{className:"mb-3",children:e.jsx(s.Grid3x3,{className:"mx-auto h-12 w-12 text-muted-foreground/50"})}),e.jsx("h3",{className:"mb-1 font-medium text-foreground",children:t?"No visuals found":"No visuals yet"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:t?"Try adjusting your search":'Click "Create" above to add your first visual'})]}):T.map(i=>e.jsx(xe,{visual:i,onAddVisual:H,onOpenVisual:J,onEditDetails:G,onDeleteClick:U,onDuplicateVisual:z,onTogglePrivacy:Q,onShareVisual:q,isDeleting:w,isDuplicating:S===i.id,formatDate:c},i.id))}),g&&a&&e.jsx(s.ShareDialog,{resource:a,resourceType:s.ResourceType.VISUAL,onClose:()=>{p(!1),r(null)}}),d&&e.jsx(s.ResourceEditDialog,{open:!!d,resourceLabel:"Visual",initialTitle:d.title||"",initialDescription:d.description||"",onClose:C,onSave:X,isSaving:P(d.id)}),e.jsx(s.AlertDialog,{open:f,onOpenChange:i=>{!i&&w||(j(i),i||D(null))},children:e.jsxs(s.AlertDialogContent,{children:[e.jsxs(s.AlertDialogHeader,{children:[e.jsx(s.AlertDialogTitle,{children:"Delete Visual"}),e.jsxs(s.AlertDialogDescription,{children:['Are you sure you want to delete "',x==null?void 0:x.title,'"? This action cannot be undone.']})]}),e.jsxs(s.AlertDialogFooter,{children:[e.jsx(s.AlertDialogCancel,{disabled:w,children:"Cancel"}),e.jsxs(s.AlertDialogAction,{onClick:i=>{i.preventDefault(),i.stopPropagation(),Y()},className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",disabled:w,children:[w?e.jsx(s.LoaderCircle,{className:"mr-2 h-3.5 w-3.5 animate-spin"}):e.jsx(s.Trash2,{className:"mr-2 h-3.5 w-3.5"}),w?"Deleting...":"Delete"]})]})]})})]})}function ge({dashboard:t,isDeleting:g,isDuplicating:p,isDefault:a,onLoadDashboard:r,onEditDetails:f,onDeleteClick:j,onDuplicateDashboard:x,onShareDashboard:D,formatDate:S,onDashboardItemClick:l}){var M,v;const{selectDashboard:d}=s.useManagementActions(),h=s.useIsDashboardSelected(t.id),{userContext:b,isLoading:V}=s.useCurrentUserInfo(),{mutate:N}=s.useDefaultDashboardMutation(),y=((M=b==null?void 0:b.permissions)==null?void 0:M.canEdit)??!1,A=V||!y,E=()=>{d(t),r(t.id),l==null||l(t.id)},I=w=>{w.stopPropagation(),N({dashboardId:a?null:t.id})};return e.jsx(s.TooltipProvider,{children:e.jsxs("div",{className:s.cn("group flex cursor-pointer items-start gap-3 rounded-md px-2 py-2 transition-colors hover:bg-muted",h&&"bg-muted/80"),onClick:E,children:[e.jsxs(s.Tooltip,{children:[e.jsx(s.TooltipTrigger,{asChild:!0,children:e.jsx("button",{onClick:I,className:"mt-0.5 flex-shrink-0 rounded p-0.5 hover:bg-muted",children:e.jsx(s.Star,{className:s.cn("h-4 w-4 transition-colors",a?"fill-yellow-400 text-yellow-400":"text-muted-foreground/40 hover:text-yellow-400")})})}),e.jsx(s.TooltipContent,{side:"right",className:"text-xs",children:a?"Remove as default":"Set as default"})]}),e.jsx("div",{className:"min-w-0 flex-1",children:e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("p",{className:"truncate text-sm font-medium text-foreground",title:t.title||"Untitled Dashboard",children:t.title||"Untitled Dashboard"}),e.jsx("p",{className:"truncate text-xs text-muted-foreground",title:t.description||"No description",children:(v=t.description)!=null&&v.trim()?t.description:"No description"})]}),e.jsx("div",{className:"flex-shrink-0 opacity-0 transition-opacity group-hover:opacity-100",children:e.jsx(s.DashboardActionsMenu,{dashboard:t,isDeleting:g,isDuplicating:p,shouldHideActions:A,onEditDetails:f,onDeleteClick:j,onDuplicateDashboard:x,onShareDashboard:D,formatDate:S})})]})})]},t.id)})}function fe({onRetry:t}){return e.jsx(s.ScrollArea,{className:"w-full flex-1 pr-2",children:e.jsxs("div",{className:"py-8 text-center text-muted-foreground",children:[e.jsx("p",{className:"text-sm text-destructive",children:"Failed to load dashboards"}),e.jsx(s.Button,{variant:"outline",size:"sm",className:"mt-2",onClick:t,children:"Retry"})]})})}function je(t){var te,ne;const{searchQuery:g,onLoadDashboard:p,onEditDashboard:a,onDashboardItemClick:r}=t,[f,j]=m.useState(!1),[x,D]=m.useState(null),[S,l]=m.useState(!1),[d,h]=m.useState(null),[b,V]=m.useState(null),[N,y]=m.useState(null),A=s.useManagementStore(n=>n.lastSelectedDashboard),E=s.useManagementStore(n=>n.selectedDashboard),I=s.useManagementStore(n=>n.actions.selectDashboard),M=s.useManagementStore(n=>n.actions.clearSelectedDashboard),{tokenProps:v,id:w}=s.useSemaphorContext();s.useRoleAwareDisplayPreferences();const{resources:T,isLoading:c,isError:U,updateResource:Y,deleteResource:F,duplicateResource:K,isDeleting:P}=s.useDashboardManagement(()=>{l(!1);const n=d==null?void 0:d.id;h(null),(E==null?void 0:E.id)===n&&(!(v!=null&&v.dashboard_id)&&!w?M():A&&A.id!==n&&I(A))}),{currentUser:B,userContext:z}=s.useCurrentUserInfo(),J=((te=z==null?void 0:z.permissions)==null?void 0:te.canCreateDashboard)??!1,{data:H}=s.useUserPreferences(),Q=((ne=H==null?void 0:H.preference)==null?void 0:ne.defaultDashboardId)||null,q=T.filter(n=>{var O,u;return((O=n==null?void 0:n.title)==null?void 0:O.toLowerCase().includes(g.toLowerCase()))||((u=n==null?void 0:n.description)==null?void 0:u.toLowerCase().includes(g.toLowerCase()))}),G=n=>new Date(n).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"}),C=n=>{p==null||p(n)},X=n=>{h(n),l(!0)},i=()=>{d&&F(d.id)},L=n=>{V(n),K(n,{onSettled:()=>V(null)})},{startUpdating:o,stopUpdating:W,isUpdating:$}=s.useResourceUpdateState(),Z=(n,O,u)=>{var ae;const ee=Object.fromEntries(Object.entries(O).filter(([,_])=>_!==void 0));if(Object.keys(ee).length===0){(ae=u==null?void 0:u.onSuccess)==null||ae.call(u);return}const ie=Object.keys(ee),se=ie.length===1?ie[0]:void 0;o(n,se),Y({resourceId:n,data:ee},{onSuccess:()=>{var _;W(n,se),(_=u==null?void 0:u.onSuccess)==null||_.call(u)},onError:()=>{var _;W(n,se),(_=u==null?void 0:u.onError)==null||_.call(u)}})},k=n=>{const O=T.find(u=>u.id===n);O&&Y({resourceId:n,data:{isPrivate:!O.isPrivate}})},R=n=>{D(n),B==null||B.type,j(!0)},le=n=>{a==null||a(n.id),y(n)},de=()=>{y(null)},ce=({title:n,description:O})=>{if(!N)return;const u={};n!==N.title&&(u.title=n),(N.description||"")!==O&&(u.description=O),Z(N.id,u,{onSuccess:()=>{y(null)}})};return c?e.jsx(oe,{}):U?e.jsx(fe,{onRetry:()=>window.location.reload()}):e.jsxs("div",{className:"flex h-full flex-1 flex-col",children:[e.jsx("div",{className:"flex flex-1 basis-0 flex-col gap-3 overflow-y-auto",children:q.length===0?e.jsxs("div",{className:"py-8 text-center",children:[e.jsx("div",{className:"mb-3",children:e.jsx(s.ChartColumn,{className:"mx-auto h-12 w-12 text-muted-foreground/50"})}),e.jsx("h3",{className:"mb-1 font-medium text-foreground",children:g?"No dashboards found":"No dashboards yet"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:g?"Try adjusting your search":J?'Click "Create" above to add your first dashboard':"No dashboards have been shared with you yet"})]}):q.map(n=>e.jsx(ge,{dashboard:n,isDeleting:P,isDuplicating:b===n.id,isDefault:n.id===Q,onLoadDashboard:C,onEditDetails:le,onDeleteClick:X,onDuplicateDashboard:L,onTogglePrivacy:k,onShareDashboard:R,formatDate:G,onDashboardItemClick:r},n.id))}),f&&x&&e.jsx(s.ShareDialog,{resource:x,resourceType:s.ResourceType.DASHBOARD,onClose:()=>{j(!1),D(null)}}),e.jsx(s.AlertDialog,{open:S,onOpenChange:n=>{!n&&P||(l(n),n||h(null))},children:e.jsxs(s.AlertDialogContent,{children:[e.jsxs(s.AlertDialogHeader,{children:[e.jsx(s.AlertDialogTitle,{children:"Delete Dashboard"}),e.jsxs(s.AlertDialogDescription,{children:['Are you sure you want to delete "',d==null?void 0:d.title,'"? This action cannot be undone.']})]}),e.jsxs(s.AlertDialogFooter,{children:[e.jsx(s.AlertDialogCancel,{disabled:P,children:"Cancel"}),e.jsxs(s.AlertDialogAction,{onClick:n=>{n.preventDefault(),n.stopPropagation(),i()},className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",disabled:P,children:[P?e.jsx(s.LoaderCircle,{className:"mr-2 h-3.5 w-3.5 animate-spin"}):e.jsx(s.Trash2,{className:"mr-2 h-3.5 w-3.5"}),P?"Deleting...":"Delete"]})]})]})}),N&&e.jsx(s.ResourceEditDialog,{open:!!N,resourceLabel:"Dashboard",initialTitle:N.title||"",initialDescription:N.description||"",onClose:de,onSave:ce,isSaving:$(N.id)})]})}function De({open:t,onOpenChange:g,onSubmit:p,isCreating:a}){const[r,f]=m.useState(""),[j,x]=m.useState("");m.useEffect(()=>{t||(f(""),x(""))},[t]);const D=()=>{r.trim()&&p({title:r,description:j})},S=l=>{g(l)};return e.jsx(s.Dialog,{open:t,onOpenChange:S,children:e.jsxs(s.DialogContent,{children:[e.jsxs(s.DialogHeader,{children:[e.jsx(s.DialogTitle,{children:"Create New Visual"}),e.jsx(s.DialogDescription,{children:"Add a new visual to your library. You can configure it after creation."})]}),e.jsxs("div",{className:"space-y-4 py-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(s.Label,{htmlFor:"title",children:"Visual Title"}),e.jsx(s.Input,{id:"title",placeholder:"Enter visual title...",value:r,onChange:l=>f(l.target.value),disabled:a,onKeyDown:l=>{l.key==="Enter"&&!l.shiftKey&&(l.preventDefault(),D())}})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(s.Label,{htmlFor:"description",children:"Description (optional)"}),e.jsx(s.Input,{id:"description",placeholder:"Enter visual description...",value:j,onChange:l=>x(l.target.value),disabled:a})]})]}),e.jsxs(s.DialogFooter,{children:[e.jsx(s.Button,{variant:"outline",onClick:()=>S(!1),disabled:a,children:"Cancel"}),e.jsx(s.Button,{onClick:D,disabled:!r.trim()||a,children:a?e.jsxs(e.Fragment,{children:[e.jsx(s.LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin"}),"Creating..."]}):"Create Visual"})]})]})})}function Ne({isOpen:t,onClose:g,className:p,onDashboardItemClick:a,variant:r="inline"}){var q,G;const f=s.useDashboardStore(C=>C.isDashboardEditing),[j,x]=m.useState(!1),[D,S]=m.useState(""),[l,d]=m.useState(!1),{currentUser:h,userContext:b}=s.useCurrentUserInfo(),V=((q=b==null?void 0:b.permissions)==null?void 0:q.canCreateDashboard)??!1,{onCreateSuccess:N}=s.useDashboardCreation({onDashboardSelect:a}),{selectVisual:y}=s.useManagementActions(),{handleEditLibraryVisual:A}=re.useVisualUtils(),{createResource:E,isCreating:I,refetch:M}=s.useDashboardManagement(),{createResource:v,isCreating:w}=s.useVisualManagement(void 0,C=>{x(!1),C&&(y(C),A(C))}),T=r==="overlay",c=((h==null?void 0:h.name)??"").trim(),U=((h==null?void 0:h.email)??"").trim(),F=c&&c.toLowerCase()!=="undefined"?c:U||"Current user",K=((G=F.charAt(0))==null?void 0:G.toUpperCase())||"?",P=U&&U.toLowerCase()!=="undefined"?U:"",B=ue.useClickOutside(g,{enabled:t&&T}),z=s.cn("flex h-full flex-col border-r bg-background",T?s.cn("absolute inset-y-0 left-0 z-[51] w-60 shadow-lg transition-transform duration-300 ease-in-out",t?"translate-x-0":"pointer-events-none -translate-x-full"):"w-full max-w-[17rem] min-w-[11rem] overflow-hidden shadow-sm",p),J=C=>{},H=C=>{console.log("Editing dashboard:",C)},Q=C=>{E(C,{onSuccess:X=>{x(!1),N(X,M)}})};return e.jsx(e.Fragment,{children:(!T||t)&&e.jsxs("div",{ref:B,className:z,children:[e.jsxs("div",{className:"border-b border-border",children:[e.jsxs("div",{className:"flex items-center justify-between px-4 py-1.5",children:[e.jsx("div",{className:"flex items-center gap-2",children:e.jsx("h2",{className:"whitespace-nowrap text-sm font-semibold",children:f?"Visuals":"Dashboards"})}),e.jsxs("div",{className:"flex items-center gap-0",children:[e.jsx(s.Button,{size:"sm",variant:"ghost",onClick:()=>d(!l),className:"h-8 w-8 p-0",children:e.jsx(s.Search,{className:"h-3.5 w-3.5"})}),(f||V)&&e.jsx(s.Button,{size:"sm",variant:"ghost",className:"h-8 w-8 whitespace-nowrap p-0",onClick:()=>x(!0),children:e.jsx(s.Plus,{className:"h-3.5 w-3.5"})})]})]}),l&&e.jsx("div",{className:"bg-muted/30 px-4 pb-3",children:e.jsx(s.Input,{placeholder:"Search...",value:D,onChange:C=>S(C.target.value),className:"h-8 border-muted-foreground/20 bg-background text-sm focus-visible:border-muted-foreground/40 focus-visible:ring-0 focus-visible:ring-offset-0",autoFocus:!0})})]}),e.jsx("div",{className:"flex flex-1 flex-col overflow-auto px-2 py-2",children:f?e.jsx(pe,{searchQuery:D}):e.jsx(je,{searchQuery:D,onLoadDashboard:J,onEditDashboard:H,onDashboardItemClick:a})}),h&&e.jsx(s.TooltipProvider,{children:e.jsx("div",{className:"border-t border-border px-4 py-2",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(s.Tooltip,{children:[e.jsx(s.TooltipTrigger,{asChild:!0,children:e.jsx("div",{className:"flex h-6 w-6 cursor-default items-center justify-center rounded-full bg-primary/10",children:e.jsx("span",{className:"text-xs font-medium text-primary",children:K})})}),e.jsx(s.TooltipContent,{side:"top",className:"max-w-xs",children:e.jsxs("div",{className:"space-y-1",children:[e.jsx("div",{className:"font-medium",children:F}),P&&e.jsx("div",{className:"text-xs text-muted-foreground",children:P}),h.role&&e.jsxs("div",{className:"text-xs text-muted-foreground",children:["Role: ",s.toTitleCase(h.role.replace(/_/g," "))]})]})})]}),e.jsx("span",{className:"truncate text-xs text-muted-foreground",children:F})]})})}),f?e.jsx(De,{open:j,onOpenChange:x,onSubmit:v,isCreating:w}):e.jsx(s.CreateDashboardDialog,{open:j,onOpenChange:x,onSubmit:Q,isCreating:I})]})})}exports.ResourceManagementPanel=Ne;
@@ -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
+ };
@@ -0,0 +1 @@
1
+ "use strict";const o=require("./index-CReqnEJI.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;
@@ -0,0 +1,331 @@
1
+ import { am as G, an as z, h as Y, i as J, ao as K, e as _, g as X, u as U, ap as Z, aq as q, l as v, ar as ee, f as h } from "./index-QdSI9E0a.js";
2
+ import { useState as T, useEffect as te, useCallback as V } from "react";
3
+ function re(e) {
4
+ const o = e.toUpperCase().indexOf("WHERE"), r = e.toUpperCase().indexOf("GROUP BY"), t = e.toUpperCase().indexOf("LIMIT"), i = e.toUpperCase().indexOf("ORDER BY");
5
+ let n = e.length;
6
+ if (i !== -1 && (n = i), t !== -1 && t < n && (n = t), o !== -1) {
7
+ const a = e.substring(0, o), s = e.substring(o);
8
+ return `${a} {{ filters | where }} AND ${s.substring(
9
+ 6
10
+ )}`;
11
+ } else if (r !== -1) {
12
+ const a = e.substring(0, r), s = e.substring(r);
13
+ return `${a} {{ filters | where }} ${s}`;
14
+ } else {
15
+ const a = e.substring(0, n), s = e.substring(n);
16
+ return console.log("beforeClause", a), console.log("afterClause", s), s ? `${a} {{ filters | where }} ${s}` : `${a.replace(/;$/, "")} {{ filters | where }}`;
17
+ }
18
+ }
19
+ function se(e) {
20
+ const [o, r] = T(null), [t, i] = T(null), n = G();
21
+ return te(() => {
22
+ if (!e || e.trim() === "") {
23
+ r(null), i(null);
24
+ return;
25
+ }
26
+ if (!n)
27
+ return;
28
+ (async () => {
29
+ try {
30
+ if (!e.startsWith("http://") && !e.startsWith("https://"))
31
+ throw new Error(`Invalid URL format: ${e}`);
32
+ try {
33
+ new URL(e);
34
+ } catch {
35
+ throw new Error(`Invalid URL: ${e}`);
36
+ }
37
+ const d = `${e.endsWith("/") ? e : `${e}/`}index.js`;
38
+ try {
39
+ if (!(await fetch(d, { method: "HEAD" })).ok)
40
+ throw new Error(`Module not found at ${d}`);
41
+ } catch {
42
+ }
43
+ const m = await import(
44
+ /* @vite-ignore */
45
+ /* webpackIgnore: true */
46
+ d
47
+ );
48
+ if (typeof m.useChartStore != "function")
49
+ throw new Error("useChartStore is not a function");
50
+ r(() => m.useChartStore), i(null);
51
+ } catch (s) {
52
+ const d = s instanceof Error ? s.message : "Unknown error";
53
+ console.error("Failed to load remote chart store:", d), i(d), r(null);
54
+ }
55
+ })();
56
+ }, [e, n]), o;
57
+ }
58
+ function oe(e, o) {
59
+ if (e.length === 0)
60
+ return "";
61
+ if (o) {
62
+ const r = e.find((t) => t.id === o);
63
+ if (r) {
64
+ const t = r.tabTitle;
65
+ if (t == "All__Header")
66
+ return e[0].id;
67
+ if (t && t.endsWith("__Header")) {
68
+ const n = t.split("__")[0], a = e.find(
69
+ (s) => s.tabTitle === n
70
+ );
71
+ return a ? a.id : e[0].id;
72
+ }
73
+ return o;
74
+ }
75
+ }
76
+ return e[0].id;
77
+ }
78
+ async function M(e, o, r, t) {
79
+ if (!o || !r)
80
+ throw new Error("Missing auth token or visual ID");
81
+ const i = ["resource-by-id", "visual", r], n = t.getQueryData(i);
82
+ if (n)
83
+ return console.log("Using cached visual data for:", r), { data: n, fromCache: !0 };
84
+ console.log("Fetching visual data from network for:", r);
85
+ const a = v.loading("Loading visual...", {
86
+ position: "top-center"
87
+ });
88
+ try {
89
+ const s = await fetch(
90
+ `${e}/management/v1/visuals/${r}`,
91
+ {
92
+ headers: {
93
+ Authorization: `Bearer ${o}`
94
+ }
95
+ }
96
+ );
97
+ if (!s.ok)
98
+ throw new Error("Failed to load visual");
99
+ const d = await s.json();
100
+ return t.setQueryData(i, d), v.dismiss(a), { data: d, fromCache: !1 };
101
+ } catch (s) {
102
+ throw v.dismiss(a), s;
103
+ }
104
+ }
105
+ function H(e) {
106
+ if (typeof e == "string")
107
+ return JSON.parse(e);
108
+ if (typeof e == "object")
109
+ return e;
110
+ throw new Error("Invalid frame object format");
111
+ }
112
+ function ae(e, o) {
113
+ var n, a;
114
+ const r = (e == null ? void 0 : e.frameObject) ?? ((n = e == null ? void 0 : e.visual) == null ? void 0 : n.frameObject);
115
+ if (!r)
116
+ return !1;
117
+ const t = H(r);
118
+ if (!(t != null && t.cards) || t.cards.length === 0)
119
+ return !1;
120
+ const i = (a = t.cards) == null ? void 0 : a.find(
121
+ (s) => s.id === t.activeCardId
122
+ );
123
+ return i ? (ee({
124
+ ...o,
125
+ frame: t,
126
+ card: i,
127
+ visualId: (e == null ? void 0 : e.id) || t.visualId
128
+ }), !0) : !1;
129
+ }
130
+ function ne() {
131
+ var b;
132
+ const { setCardSql: e } = _(), o = h((c) => c.frame), r = h((c) => c.card), t = se(
133
+ ((b = r.customCardPreferences) == null ? void 0 : b.url) || ""
134
+ ), i = h(
135
+ (c) => c.selectedSchemaName
136
+ ), n = h(
137
+ (c) => c.selectedDatamodelId
138
+ ), a = h(
139
+ (c) => c.selectedDatabaseName
140
+ ), s = h((c) => c.selectedTableName), d = h(
141
+ (c) => c.selectedConnectionId
142
+ ), m = h((c) => c.isShowingVisual), u = r.sql;
143
+ return { getUpdatedFrame: V(() => {
144
+ var C;
145
+ let c = u;
146
+ u && !u.includes("{{") && (c = re(u), e(c));
147
+ const S = (C = t == null ? void 0 : t.getState()) == null ? void 0 : C.settings, F = {
148
+ ...r,
149
+ dataSource: r.dataSource || { mode: "directSource" },
150
+ lastSelectedSchema: i,
151
+ lastSelectedDatamodelId: n,
152
+ lastSelectedDatabase: a,
153
+ lastSelectedTable: s,
154
+ connectionId: d,
155
+ // type: isShowingVisual ? card.type : 'table', /// CHECK THIS!!!!
156
+ sql: c,
157
+ customCfg: m ? r.customCfg : null,
158
+ preferences: r.preferences,
159
+ // Preserve all preferences including column sizing
160
+ ...S && {
161
+ customCardPreferences: {
162
+ ...r.customCardPreferences,
163
+ settings: S
164
+ }
165
+ }
166
+ }, w = o.cards.map(
167
+ (p) => p.id === r.id ? F : p
168
+ );
169
+ return {
170
+ ...o,
171
+ cards: w,
172
+ activeCardId: oe(w, o.activeCardId)
173
+ };
174
+ }, [
175
+ r,
176
+ o,
177
+ m,
178
+ i,
179
+ n,
180
+ a,
181
+ s,
182
+ d,
183
+ e,
184
+ t,
185
+ u
186
+ ]) };
187
+ }
188
+ function de() {
189
+ const { authToken: e, tokenProps: o } = z(), r = Y(), t = J(), { selectVisual: i } = K(), {
190
+ setFrame: n,
191
+ setCard: a,
192
+ setIsDevMode: s,
193
+ setActiveTabCardId: d,
194
+ updateDataSource: m,
195
+ setQueryResultColumns: u,
196
+ setSelectedConnectionId: $,
197
+ setSelectedDatabaseName: b,
198
+ setSelectedSchemaName: c,
199
+ setSelectedTableName: S,
200
+ setSelectedDatamodelId: F,
201
+ setFilterValues: w,
202
+ setApplyFilters: C
203
+ } = _(), {
204
+ setIsDashboardEditing: p,
205
+ setIsVisualEditing: N,
206
+ setSelectedFrameId: A,
207
+ clearSelectedFrameId: O,
208
+ addFrame: x,
209
+ setIsDashboardPanelOpen: R
210
+ } = X(), I = U((l) => l.selectedSheetId), W = U((l) => l.selectedFrameId), D = U((l) => l.dashboard), L = U((l) => l.filterValues), y = Z((t == null ? void 0 : t.id) || "", {
211
+ enabled: !!(t != null && t.id) && !!(e != null && e.accessToken)
212
+ }), Q = V(
213
+ async (l) => {
214
+ try {
215
+ i(l), O();
216
+ const { data: g, fromCache: f } = await M(
217
+ o.apiServiceUrl,
218
+ (e == null ? void 0 : e.accessToken) || "",
219
+ l.id,
220
+ r
221
+ );
222
+ if (!ae(g, {
223
+ setFrame: n,
224
+ setCard: a,
225
+ setIsDevMode: s,
226
+ setActiveTabCardId: d,
227
+ updateDataSource: m,
228
+ setQueryResultColumns: u,
229
+ setSelectedConnectionId: $,
230
+ setSelectedDatabaseName: b,
231
+ setSelectedSchemaName: c,
232
+ setSelectedTableName: S,
233
+ setSelectedDatamodelId: F,
234
+ setFilterValues: w,
235
+ setApplyFilters: C,
236
+ setIsDashboardEditing: p,
237
+ setIsVisualEditing: N,
238
+ dashboard: D,
239
+ selectedSheetId: I,
240
+ selectedFrameId: W,
241
+ filterValues: L
242
+ }))
243
+ throw new Error("Failed to setup editor with visual data");
244
+ return { success: !0, fromCache: f };
245
+ } catch (g) {
246
+ return console.error("Error editing visual:", g), { success: !1, error: "Failed to load visual for editing" };
247
+ }
248
+ },
249
+ [
250
+ e == null ? void 0 : e.accessToken,
251
+ o.apiServiceUrl,
252
+ r,
253
+ i,
254
+ n,
255
+ a,
256
+ p,
257
+ N,
258
+ s,
259
+ d,
260
+ m,
261
+ u,
262
+ $,
263
+ b,
264
+ c,
265
+ S,
266
+ F,
267
+ w,
268
+ C,
269
+ O,
270
+ D,
271
+ I,
272
+ W,
273
+ L
274
+ ]
275
+ ), k = V(
276
+ async (l) => {
277
+ var g;
278
+ try {
279
+ if (i(l), !I)
280
+ return {
281
+ success: !1,
282
+ error: "No sheet selected. Please select a sheet first."
283
+ };
284
+ const { data: f, fromCache: P } = await M(
285
+ o.apiServiceUrl,
286
+ (e == null ? void 0 : e.accessToken) || "",
287
+ l.id,
288
+ r
289
+ ), j = (f == null ? void 0 : f.frameObject) ?? ((g = f == null ? void 0 : f.visual) == null ? void 0 : g.frameObject);
290
+ if (!j)
291
+ return { success: !1, error: "Visual has no frame data" };
292
+ const E = H(j);
293
+ if (!(E != null && E.cards) || E.cards.length === 0)
294
+ return { success: !1, error: "Visual frame is malformed" };
295
+ const B = {
296
+ ...q(E),
297
+ visualId: l.id
298
+ // Link this frame to the library visual
299
+ };
300
+ return x(I, B, "end"), p(!0), A(B.id), R(!1), { success: !0, fromCache: P };
301
+ } catch (f) {
302
+ return console.error("Error adding visual:", f), { success: !1, error: "Failed to add visual to dashboard" };
303
+ }
304
+ },
305
+ [
306
+ e == null ? void 0 : e.accessToken,
307
+ o.apiServiceUrl,
308
+ r,
309
+ i,
310
+ I,
311
+ x,
312
+ p,
313
+ A,
314
+ R
315
+ ]
316
+ );
317
+ return {
318
+ visual: y.data,
319
+ isLoading: y.isLoading,
320
+ isError: y.isError,
321
+ error: y.error,
322
+ handleEditLibraryVisual: Q,
323
+ handleAddLibraryVisual: k,
324
+ getUpdatedFrame: ne().getUpdatedFrame,
325
+ refetch: y.refetch
326
+ };
327
+ }
328
+ export {
329
+ de as a,
330
+ se as u
331
+ };
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("../chunks/index-Bo0bvCRT.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-CReqnEJI.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-CE57mw6l.js";
1
+ import { D as a } from "../chunks/index-QdSI9E0a.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,6 +1,6 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./chunks/index-Bo0bvCRT.js"),v=require("./types/index.cjs"),u=require("./chunks/dashboard-plus-BZ8k_sGe.js"),a=require("react/jsx-runtime"),x=require("react");require("react-dom");function j(r){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(r){for(const s in r)if(s!=="default"){const i=Object.getOwnPropertyDescriptor(r,s);Object.defineProperty(t,s,i.get?i:{enumerable:!0,get:()=>r[s]})}}return t.default=r,Object.freeze(t)}const p=j(x);/**
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./chunks/index-CReqnEJI.js"),S=require("./types/index.cjs"),a=require("react/jsx-runtime"),g=require("react"),j=require("./chunks/resource-management-panel-CXSx9QhW.js"),c=require("./chunks/dashboard-export-dialog-BpNaUA5x.js");require("react-dom");function P(r){const o=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(r){for(const s in r)if(s!=="default"){const i=Object.getOwnPropertyDescriptor(r,s);Object.defineProperty(o,s,i.get?i:{enumerable:!0,get:()=>r[s]})}}return o.default=r,Object.freeze(o)}const C=P(g);/**
2
2
  * @license lucide-react v0.453.0 - ISC
3
3
  *
4
4
  * This source code is licensed under the ISC license.
5
5
  * See the LICENSE file in the root directory of this source tree.
6
- */const E=e.createLucideIcon("RefreshCw",[["path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8",key:"v9h5vc"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}],["path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16",key:"3uifl3"}],["path",{d:"M8 16H3v5",key:"1cv678"}]]);function N(r){const{displayPreferences:t,...s}=r,i={...s,id:r.dashboardId};return a.jsx(e.ErrorBoundary,{FallbackComponent:e.Fallback,children:a.jsx(e.SemaphorContextProvider,{dashboardProps:i,children:a.jsx(e.UXProvider,{children:a.jsx(e.DisplayPreferencesProvider,{displayPreferences:t,children:a.jsx(e.Container,{type:"visual",...i,children:a.jsx(P,{cardId:r.cardId})})})})})})}function P({cardId:r}){const t=e.useDashboardStore(n=>{var l;return(l=n.dashboard)==null?void 0:l.sheets}),{card:s,frame:i}=x.useMemo(()=>{const n=t==null?void 0:t.flatMap(o=>o.frames),l=n==null?void 0:n.flatMap(o=>o==null?void 0:o.cards),f=l==null?void 0:l.find(o=>(o==null?void 0:o.id)===r),C=n==null?void 0:n.find(o=>{var h;return(h=o==null?void 0:o.cards)==null?void 0:h.find(c=>(c==null?void 0:c.id)===r)});return{card:f,frame:C}},[t,r]);return!s||!i?a.jsx(e.FallbackVisual,{error:new Error("Card not found"),resetErrorBoundary:()=>{},customerFacingMessage:`Card not found with ID: ${r}`}):a.jsx("main",{className:"flex h-full grow flex-col",children:a.jsx(e.ErrorBoundary,{FallbackComponent:({error:n,resetErrorBoundary:l})=>a.jsx(e.FallbackVisual,{error:n,resetErrorBoundary:l,customerFacingMessage:"Error creating visual. Please try again."}),children:a.jsx(e.DashboardCard,{card:s,frame:i})})})}const A=["MM-DD-YYYY","YYYY-MM-DD","MM/DD/YYYY","DD/MM/YYYY","MMMM DD, YYYY","MMM DD, YYYY","DD MMM YYYY","Week of MMM DD, YYYY","Week of MMMM DD, YYYY","YYYY-WW","MMM YYYY","MMMM YYYY","YYYY-MM","MM/YYYY","YYYY MMM","Q1 YYYY","YYYY Q1","1st Quarter YYYY","YYYY-Q1","Quarter 1, YYYY","YYYY","YY","custom"];var b=(r=>(r.SUBTOTAL="__SUBTOTAL__",r.TOTAL="__TOTAL__",r.ALL="__ALL__",r))(b||{});function _({name:r,items:t,value:s,onChange:i,isLoading:n,isError:l,refetch:f,className:C,icon:o,showNone:h=!1}){const c=p.useRef(null),[m,M]=p.useState(!1),[g,y]=p.useState("100%"),D=h?[...t||[],{id:"none",name:"None"}]:t;p.useLayoutEffect(()=>{c.current&&y(c.current.offsetWidth)},[]);function T(){var d;return n?"Loading...":l?"Error":s?(d=t==null?void 0:t.find(Y=>Y.id===s))==null?void 0:d.name:`Select ${r}`}function S(d,Y){i(Y),M(!1)}return a.jsxs(e.Popover,{open:m,onOpenChange:M,children:[a.jsx(e.PopoverTrigger,{asChild:!0,children:a.jsxs(e.Button,{ref:c,variant:"outline",role:"combobox","aria-expanded":m,className:e.cn("flex h-9 w-full justify-between",C),children:[a.jsxs("div",{className:"flex items-center gap-2",children:[o&&a.jsx("div",{className:"mr-2",children:o}),a.jsx("span",{className:"max-w-[150px] overflow-hidden truncate text-ellipsis whitespace-nowrap",children:T()})]}),a.jsx(e.ChevronDown,{className:"size-4 opacity-50"})]})}),a.jsx(e.PopoverContent,{className:"w-full p-0",style:{minWidth:g},children:a.jsxs(e.Command,{children:[a.jsxs("div",{className:"flex h-9 items-center justify-between border-b pr-1",children:[a.jsx(e.CommandInput,{className:"h-9",placeholder:"Search..."}),a.jsx(e.IconButton,{className:"h-7",onClick:f,children:a.jsx(E,{className:e.cn("size-3.5 opacity-50",n&&"animate-spin")})})]}),a.jsxs(e.CommandList,{children:[a.jsxs(e.CommandEmpty,{children:["No ",r==null?void 0:r.toLowerCase()," found."]}),a.jsx(e.CommandGroup,{children:D==null?void 0:D.map(d=>a.jsx(e.CommandItem,{className:"overflow-x-auto",value:d.name,onSelect:Y=>S(Y,d.id),children:a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(e.Check,{className:e.cn("size-4",s===d.id?"opacity-100":"opacity-0")}),a.jsx("div",{title:d.name,children:d.name})]})},d.id))})]})]})})]})}exports.Dashboard=e.Dashboard;exports.DashboardWC=e.DashboardWC;exports.ResourceType=e.ResourceType;exports.SemaphorContextProvider=e.SemaphorContextProvider;exports.SemaphorDataProvider=e.SemaphorQueryClient;exports.SemaphorQueryClient=e.SemaphorQueryClient;exports.createEmptyKpiConfig=e.createEmptyKpiConfig;exports.createSqlGenConfig=e.createSqlGenConfig;exports.downloadPdf=e.downloadPdf;exports.fmt=e.fmt;exports.getColumnDataType=e.getColumnDataType;exports.getFilterValueType=e.getFilterValueType;exports.getFormattedTableNameForQuery=e.getFormattedTableNameForQuery;exports.getQualifiedTableName=e.getQualifiedTableName;exports.getSql=e.getSql;exports.invalidateToken=e.invalidateToken;exports.isBooleanDataType=e.isBooleanDataType;exports.isColumnInSqlGen=e.isColumnInSqlGen;exports.isDateDataType=e.isDateDataType;exports.isNumberDataType=e.isNumberDataType;exports.isTextDataType=e.isTextDataType;exports.resolveDataType=e.resolveDataType;exports.resolveDatamodelName=e.resolveDatamodelName;exports.useCard=e.useCard;exports.useCurrentActiveCard=e.useCurrentActiveCard;exports.useCurrentCardConfig=e.useCurrentCardConfig;exports.useCurrentSheetActiveCards=e.useCurrentSheetActiveCards;exports.useDashboardActions=e.useDashboardActions;exports.useDashboardStore=e.useDashboardStore;exports.useDataColumns=e.useDataColumns;exports.useDateFilterHook=e.useDateFilterHook;exports.useEditorActions=e.useEditorActions;exports.useEditorAside=e.useEditorAside;exports.useEditorStore=e.useEditorStore;exports.useTextFilterHook=e.useTextFilterHook;exports.EMPTY_SELECTION=v.EMPTY_SELECTION;exports.AdvancedModeToggle=u.AdvancedModeToggle;exports.ResourceManagementPanel=u.ResourceManagementPanel;exports.ScheduleDashboard=u.ScheduleDashboard;exports.ShareDialog=u.ShareDialog;exports.Surfboard=u.DashboardPlus;exports.VisualBadge=u.VisualBadge;exports.VisualEditingControls=u.VisualEditingControls;exports.cleanCard=u.cleanCard;exports.getDashbaordStateWithoutData=u.getDashbaordStateWithoutData;exports.Combobox=_;exports.DATE_FORMAT_VALUES=A;exports.PivotMarkerEnum=b;exports.Visual=N;
6
+ */const N=e.createLucideIcon("RefreshCw",[["path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8",key:"v9h5vc"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}],["path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16",key:"3uifl3"}],["path",{d:"M8 16H3v5",key:"1cv678"}]]);function M(r){const{displayPreferences:o,...s}=r,i={...s,id:r.dashboardId};return a.jsx(e.ErrorBoundary,{FallbackComponent:e.Fallback,children:a.jsx(e.SemaphorContextProvider,{dashboardProps:i,children:a.jsx(e.UXProvider,{children:a.jsx(e.DisplayPreferencesProvider,{displayPreferences:o,children:a.jsx(e.Container,{type:"visual",...i,children:a.jsx(A,{cardId:r.cardId})})})})})})}function A({cardId:r}){const o=e.useDashboardStore(n=>{var l;return(l=n.dashboard)==null?void 0:l.sheets}),{card:s,frame:i}=g.useMemo(()=>{const n=o==null?void 0:o.flatMap(t=>t.frames),l=n==null?void 0:n.flatMap(t=>t==null?void 0:t.cards),m=l==null?void 0:l.find(t=>(t==null?void 0:t.id)===r),f=n==null?void 0:n.find(t=>{var p;return(p=t==null?void 0:t.cards)==null?void 0:p.find(u=>(u==null?void 0:u.id)===r)});return{card:m,frame:f}},[o,r]);return!s||!i?a.jsx(e.FallbackVisual,{error:new Error("Card not found"),resetErrorBoundary:()=>{},customerFacingMessage:`Card not found with ID: ${r}`}):a.jsx("main",{className:"flex h-full grow flex-col",children:a.jsx(e.ErrorBoundary,{FallbackComponent:({error:n,resetErrorBoundary:l})=>a.jsx(e.FallbackVisual,{error:n,resetErrorBoundary:l,customerFacingMessage:"Error creating visual. Please try again."}),children:a.jsx(e.DashboardCard,{card:s,frame:i})})})}function k({name:r,items:o,value:s,onChange:i,isLoading:n,isError:l,refetch:m,className:f,icon:t,showNone:p=!1}){const u=C.useRef(null),[b,x]=C.useState(!1),[y,v]=C.useState("100%"),D=p?[...o||[],{id:"none",name:"None"}]:o;C.useLayoutEffect(()=>{u.current&&v(u.current.offsetWidth)},[]);function T(){var d;return n?"Loading...":l?"Error":s?(d=o==null?void 0:o.find(h=>h.id===s))==null?void 0:d.name:`Select ${r}`}function E(d,h){i(h),x(!1)}return a.jsxs(e.Popover,{open:b,onOpenChange:x,children:[a.jsx(e.PopoverTrigger,{asChild:!0,children:a.jsxs(e.Button,{ref:u,variant:"outline",role:"combobox","aria-expanded":b,className:e.cn("flex h-9 w-full justify-between",f),children:[a.jsxs("div",{className:"flex items-center gap-2",children:[t&&a.jsx("div",{className:"mr-2",children:t}),a.jsx("span",{className:"max-w-[150px] overflow-hidden truncate text-ellipsis whitespace-nowrap",children:T()})]}),a.jsx(e.ChevronDown,{className:"size-4 opacity-50"})]})}),a.jsx(e.PopoverContent,{className:"w-full p-0",style:{minWidth:y},children:a.jsxs(e.Command,{children:[a.jsxs("div",{className:"flex h-9 items-center justify-between border-b pr-1",children:[a.jsx(e.CommandInput,{className:"h-9",placeholder:"Search..."}),a.jsx(e.IconButton,{className:"h-7",onClick:m,children:a.jsx(N,{className:e.cn("size-3.5 opacity-50",n&&"animate-spin")})})]}),a.jsxs(e.CommandList,{children:[a.jsxs(e.CommandEmpty,{children:["No ",r==null?void 0:r.toLowerCase()," found."]}),a.jsx(e.CommandGroup,{children:D==null?void 0:D.map(d=>a.jsx(e.CommandItem,{className:"overflow-x-auto",value:d.name,onSelect:h=>E(h,d.id),children:a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(e.Check,{className:e.cn("size-4",s===d.id?"opacity-100":"opacity-0")}),a.jsx("div",{title:d.name,children:d.name})]})},d.id))})]})]})})]})}exports.CALCULATED_FIELD_ENTITY_MARKER=e.CALCULATED_FIELD_ENTITY_MARKER;exports.DATE_FORMAT_VALUES=e.DATE_FORMAT_VALUES;exports.Dashboard=e.Dashboard;exports.DashboardWC=e.DashboardWC;exports.PivotMarkerEnum=e.PivotMarkerEnum;exports.ResourceType=e.ResourceType;exports.SemaphorContextProvider=e.SemaphorContextProvider;exports.SemaphorDataProvider=e.SemaphorQueryClient;exports.SemaphorQueryClient=e.SemaphorQueryClient;exports.ShareDialog=e.ShareDialog;exports.Surfboard=e.DashboardPlus;exports.cloneDeep=e.cloneDeep;exports.createEmptyKpiConfig=e.createEmptyKpiConfig;exports.createSqlGenConfig=e.createSqlGenConfig;exports.downloadPdf=e.downloadPdf;exports.emitDashboardLoad=e.emitDashboardLoad;exports.emitDashboardUnload=e.emitDashboardUnload;exports.fmt=e.fmt;exports.getColumnDataType=e.getColumnDataType;exports.getFilterValueType=e.getFilterValueType;exports.getFormattedTableNameForQuery=e.getFormattedTableNameForQuery;exports.getQualifiedTableName=e.getQualifiedTableName;exports.getSql=e.getSql;exports.invalidateToken=e.invalidateToken;exports.isBooleanDataType=e.isBooleanDataType;exports.isCalculatedDimension=e.isCalculatedDimension;exports.isCalculatedField=e.isCalculatedField;exports.isCalculatedMetric=e.isCalculatedMetric;exports.isColumnInSqlGen=e.isColumnInSqlGen;exports.isDateDataType=e.isDateDataType;exports.isNumberDataType=e.isNumberDataType;exports.isTextDataType=e.isTextDataType;exports.resolveDataType=e.resolveDataType;exports.resolveDatamodelName=e.resolveDatamodelName;exports.useCard=e.useCard;exports.useCurrentActiveCard=e.useCurrentActiveCard;exports.useCurrentCardConfig=e.useCurrentCardConfig;exports.useCurrentSheetActiveCards=e.useCurrentSheetActiveCards;exports.useDashboardActions=e.useDashboardActions;exports.useDashboardQuery=e.useDashboardQuery;exports.useDashboardStore=e.useDashboardStore;exports.useDataColumns=e.useDataColumns;exports.useDateFilterHook=e.useDateFilterHook;exports.useEditorActions=e.useEditorActions;exports.useEditorAside=e.useEditorAside;exports.useEditorStore=e.useEditorStore;exports.useTextFilterHook=e.useTextFilterHook;exports.EMPTY_SELECTION=S.EMPTY_SELECTION;exports.ResourceManagementPanel=j.ResourceManagementPanel;exports.AdvancedModeToggle=c.AdvancedModeToggle;exports.DashboardExportDialog=c.DashboardExportDialog;exports.ScheduleDashboard=c.ScheduleDashboard;exports.UnsavedChangesAlert=c.UnsavedChangesAlert;exports.VisualEditingControls=c.VisualEditingControls;exports.usePristineSnapshotInitializer=c.usePristineSnapshotInitializer;exports.Combobox=k;exports.Visual=M;