react-semaphor 0.1.142 → 0.1.144
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chunks/{dashboard-controls-BMLlOkS9.js → dashboard-controls-BG6qR7N2.js} +3 -3
- package/dist/chunks/{dashboard-controls-BdQcYRkf.js → dashboard-controls-_rTkbfKU.js} +1 -1
- package/dist/chunks/{dashboard-export-dialog-BpNaUA5x.js → dashboard-export-dialog-BXuJmTUR.js} +1 -1
- package/dist/chunks/{dashboard-export-dialog-CbMcLZvW.js → dashboard-export-dialog-iH6sg1-y.js} +3 -3
- package/dist/chunks/{dashboard-json-DD-d9gYu.js → dashboard-json-CV6LkrYw.js} +1 -1
- package/dist/chunks/{dashboard-json-DgQozDAv.js → dashboard-json-DZkwc1co.js} +1 -1
- package/dist/chunks/edit-dashboard-visual-TG6Ezk2J.js +195 -0
- package/dist/chunks/{edit-dashboard-visual-CRMhXxdG.js → edit-dashboard-visual-tCgjsYbu.js} +4402 -4786
- package/dist/chunks/{editor-action-buttons-CNQtSzD5.js → editor-action-buttons-Cvg5mWPC.js} +2 -2
- package/dist/chunks/{editor-action-buttons-DYrSZQhJ.js → editor-action-buttons-Czzj0JBw.js} +1 -1
- package/dist/chunks/{index-CReqnEJI.js → index-CPBGb2zs.js} +210 -205
- package/dist/chunks/{index-QdSI9E0a.js → index-Do9K-YLk.js} +15834 -15584
- package/dist/chunks/{resource-management-panel-CBXn6QHi.js → resource-management-panel-Chc6oyIG.js} +274 -263
- package/dist/chunks/resource-management-panel-DyeJEtOT.js +6 -0
- package/dist/chunks/{use-visual-utils-BnCl386t.js → use-visual-utils-Bf6l2e8y.js} +1 -1
- package/dist/chunks/{use-visual-utils-BDuNB0Iz.js → use-visual-utils-Dtg1I8ku.js} +1 -1
- package/dist/dashboard/index.cjs +1 -1
- package/dist/dashboard/index.js +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.js +4 -4
- package/dist/style.css +1 -1
- package/dist/surfboard/index.cjs +1 -1
- package/dist/surfboard/index.js +1 -1
- package/package.json +1 -1
- package/dist/chunks/edit-dashboard-visual-CR3NqJ7m.js +0 -200
- package/dist/chunks/resource-management-panel-CXSx9QhW.js +0 -6
- package/dist/chunks/use-click-outside-B9T3lmcw.js +0 -1
- package/dist/chunks/use-click-outside-CMeO_QFI.js +0 -16
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),t=require("./index-CPBGb2zs.js"),c=require("react"),oe=require("./use-visual-utils-Dtg1I8ku.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 ue=t.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 he(s,f={}){const{enabled:x=!0,eventType:o="mousedown"}=f,r=c.useRef(null);return c.useEffect(()=>{const g=j=>{const a=j.target;r.current&&r.current.contains(a)||a instanceof Element&&(a.closest("[data-radix-popper-content-wrapper]")||a.closest("[data-radix-select-content]")||a.closest("[data-radix-popover-content]")||a.closest("[data-radix-dropdown-menu-content]")||a.closest("[data-radix-tooltip-content]")||a.closest('[role="listbox"]')||a.closest('[role="option"]')||a.closest('[role="combobox"]'))||a instanceof Element&&a.hasAttribute("data-radix-")||s()};return x&&document.addEventListener(o,g),()=>{document.removeEventListener(o,g)}},[s,x,o]),r}function re(){return e.jsx("div",{className:"space-y-1 px-2 py-2",children:[...Array(5)].map((s,f)=>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"})]})]},f))})}const me=s=>{const f=t.useDashboardStore(r=>r.isVisualEditing),x=t.useDashboardStore(r=>r.selectedFrameId),o=t.useEditorStore(r=>r.frame);return!!(f&&x&&(o==null?void 0:o.visualId)===s)};function xe({visual:s,isDeleting:f,isDuplicating:x,onAddVisual:o,onOpenVisual:r,onEditDetails:g,onDeleteClick:j,onDuplicateVisual:a,onShareVisual:D,formatDate:y}){var M,S,C,T;const{selectVisual:d}=t.useManagementActions(),u=t.useIsVisualSelected(s.id),p=me(s.id),{isConsoleMode:b}=t.useDashboardPreferences(),E=c.useRef(null),[N,v]=c.useState(!1),[A,V]=c.useState(!1);c.useEffect(()=>{x?(v(!0),V(!0)):A&&(v(!1),V(!1))},[x,A]),c.useEffect(()=>{p&&E.current&&E.current.scrollIntoView({behavior:"smooth",block:"center"})},[p]);const P=()=>{d(s),r==null||r(s)};return e.jsxs("div",{ref:E,className:t.cn("group flex cursor-pointer items-start gap-3 rounded-md px-2 py-2 transition-colors hover:bg-muted",p?"bg-purple-500/10":u&&"bg-muted/80"),onClick:P,children:[e.jsx(t.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:s.title||"Untitled Visual",children:s.title||"Untitled Visual"}),e.jsx("p",{className:"truncate text-xs text-muted-foreground",title:s.description||"No description",children:(M=s.description)!=null&&M.trim()?s.description:"No description"})]}),e.jsxs("div",{className:"flex flex-shrink-0 items-center gap-1",onClick:h=>h.stopPropagation(),children:[e.jsx("div",{className:"opacity-0 transition-opacity group-hover:opacity-100",children:e.jsxs(t.DropdownMenu,{modal:!1,open:N,onOpenChange:v,children:[e.jsx(t.DropdownMenuTrigger,{asChild:!0,children:e.jsx(t.Button,{size:"sm",variant:"ghost",className:"h-6 w-6 p-0",children:e.jsx(t.EllipsisVertical,{className:"h-3 w-3"})})}),e.jsxs(t.DropdownMenuContent,{align:"end",className:"z-[51] w-40",children:[e.jsxs(t.DropdownMenuItem,{onClick:h=>{h.stopPropagation(),o(s)},children:[e.jsx(t.Plus,{className:"mr-2 h-3 w-3"}),"Add"]}),e.jsxs(t.DropdownMenuItem,{onClick:h=>{h.stopPropagation(),r==null||r(s)},children:[e.jsx(ue,{className:"mr-2 h-3 w-3"}),"Open"]}),e.jsxs(t.DropdownMenuItem,{onClick:h=>{h.preventDefault(),h.stopPropagation(),a(s.id)},disabled:x,children:[x?e.jsx(t.LoaderCircle,{className:"mr-2 h-3 w-3 animate-spin"}):e.jsx(t.Copy,{className:"mr-2 h-3 w-3"}),x?"Duplicating...":"Duplicate"]}),s.ownership.isOwner&&e.jsxs(e.Fragment,{children:[e.jsxs(t.DropdownMenuItem,{onClick:h=>{h.stopPropagation(),g==null||g(s)},children:[e.jsx(t.PenLine,{className:"mr-2 h-3 w-3"}),"Edit details"]}),e.jsxs(t.DropdownMenuItem,{onClick:h=>{h.stopPropagation(),D(s)},children:[e.jsx(t.Users,{className:"mr-2 h-3 w-3"}),"Share"]}),e.jsx(t.DropdownMenuSeparator,{}),e.jsxs(t.DropdownMenuItem,{onClick:h=>{h.stopPropagation(),j(s)},className:"text-destructive",disabled:f,children:[e.jsx(t.Trash2,{className:"mr-2 h-3 w-3"}),f?"Deleting...":"Delete"]})]}),e.jsx(t.DropdownMenuSeparator,{}),e.jsxs("div",{className:"space-y-1 px-2 py-2 text-xs text-slate-500 dark:text-slate-400",children:[(((S=s.ownership.createdBy)==null?void 0:S.type)==="tenant"||((C=s.ownership.createdBy)==null?void 0:C.type)==="organization"&&b)&&e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(t.User,{className:"h-3 w-3"}),e.jsx("span",{children:((T=s.ownership.createdBy)==null?void 0:T.name)||"Unknown"})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(t.Calendar,{className:"h-3 w-3"}),e.jsx("span",{children:y(s.lastModified)})]})]})]})]})}),e.jsx(t.IconButton,{tooltip:"Add to dashboard",buttonProps:{variant:"ghost",size:"sm",onClick:h=>{h.stopPropagation(),o(s)}},className:"h-6 w-6 p-0",children:e.jsx(t.Plus,{className:"h-3.5 w-3.5"})})]})]})})]},s.id)}function pe({searchQuery:s}){const[f,x]=c.useState(!1),[o,r]=c.useState(null),[g,j]=c.useState(!1),[a,D]=c.useState(null),[y,d]=c.useState(null),[u,p]=c.useState(null),{selectVisual:b}=t.useManagementActions(),{handleEditLibraryVisual:E,handleAddLibraryVisual:N}=oe.useVisualUtils(),{resources:v,isLoading:A,isError:V,updateResource:P,deleteResource:M,duplicateResource:S,isDeleting:C}=t.useVisualManagement(()=>{j(!1),D(null)});t.useCurrentUserInfo();const T=v.filter(i=>{var L,l;return((L=i==null?void 0:i.title)==null?void 0:L.toLowerCase().includes(s.toLowerCase()))||((l=i==null?void 0:i.description)==null?void 0:l.toLowerCase().includes(s.toLowerCase()))}),h=i=>new Date(i).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"}),U=i=>{D(i),j(!0)},Y=()=>{a&&M(a.id)},{startUpdating:F,stopUpdating:K,isUpdating:R}=t.useResourceUpdateState(),B=(i,L,l)=>{var k;const W=Object.fromEntries(Object.entries(L).filter(([,O])=>O!==void 0));if(Object.keys(W).length===0){(k=l==null?void 0:l.onSuccess)==null||k.call(l);return}const $=Object.keys(W),Z=$.length===1?$[0]:void 0;F(i,Z),P({resourceId:i,data:W},{onSuccess:()=>{var O;K(i,Z),(O=l==null?void 0:l.onSuccess)==null||O.call(l)},onError:()=>{var O;K(i,Z),(O=l==null?void 0:l.onError)==null||O.call(l)}})},z=i=>{d(i),S(i,{onSettled:()=>d(null)})},J=i=>{E(i)},H=i=>{N(i)},Q=i=>{const L=v.find(l=>l.id===i);L&&P({resourceId:i,data:{isPrivate:!L.isPrivate}})},q=i=>{r(i),x(!0)},G=i=>{p(i)},w=()=>{p(null)},X=({title:i,description:L})=>{if(!u)return;const l={};i!==u.title&&(l.title=i),(u.description||"")!==L&&(l.description=L),B(u.id,l,{onSuccess:()=>{p(null)}})};return A?e.jsx(re,{}):V?e.jsx(t.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(t.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(t.Grid3x3,{className:"mx-auto h-12 w-12 text-muted-foreground/50"})}),e.jsx("h3",{className:"mb-1 font-medium text-foreground",children:s?"No visuals found":"No visuals yet"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:s?"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:C,isDuplicating:y===i.id,formatDate:h},i.id))}),f&&o&&e.jsx(t.ShareDialog,{resource:o,resourceType:t.ResourceType.VISUAL,onClose:()=>{x(!1),r(null)}}),u&&e.jsx(t.ResourceEditDialog,{open:!!u,resourceLabel:"Visual",initialTitle:u.title||"",initialDescription:u.description||"",onClose:w,onSave:X,isSaving:R(u.id)}),e.jsx(t.AlertDialog,{open:g,onOpenChange:i=>{!i&&C||(j(i),i||D(null))},children:e.jsxs(t.AlertDialogContent,{children:[e.jsxs(t.AlertDialogHeader,{children:[e.jsx(t.AlertDialogTitle,{children:"Delete Visual"}),e.jsxs(t.AlertDialogDescription,{children:['Are you sure you want to delete "',a==null?void 0:a.title,'"? This action cannot be undone.']})]}),e.jsxs(t.AlertDialogFooter,{children:[e.jsx(t.AlertDialogCancel,{disabled:C,children:"Cancel"}),e.jsxs(t.AlertDialogAction,{onClick:i=>{i.preventDefault(),i.stopPropagation(),Y()},className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",disabled:C,children:[C?e.jsx(t.LoaderCircle,{className:"mr-2 h-3.5 w-3.5 animate-spin"}):e.jsx(t.Trash2,{className:"mr-2 h-3.5 w-3.5"}),C?"Deleting...":"Delete"]})]})]})})]})}function fe({dashboard:s,isDeleting:f,isDuplicating:x,isDefault:o,onLoadDashboard:r,onEditDetails:g,onDeleteClick:j,onDuplicateDashboard:a,onShareDashboard:D,formatDate:y,onDashboardItemClick:d}){var M,S;const{selectDashboard:u}=t.useManagementActions(),p=t.useIsDashboardSelected(s.id),{userContext:b,isLoading:E}=t.useCurrentUserInfo(),{mutate:N}=t.useDefaultDashboardMutation(),v=((M=b==null?void 0:b.permissions)==null?void 0:M.canEdit)??!1,A=E||!v,V=()=>{u(s),r(s.id),d==null||d(s.id)},P=C=>{C.stopPropagation(),N({dashboardId:o?null:s.id})};return e.jsx(t.TooltipProvider,{children:e.jsxs("div",{className:t.cn("group flex cursor-pointer items-start gap-3 rounded-md px-2 py-2 transition-colors hover:bg-muted",p&&"bg-muted/80"),onClick:V,children:[e.jsxs(t.Tooltip,{children:[e.jsx(t.TooltipTrigger,{asChild:!0,children:e.jsx("button",{onClick:P,className:"mt-0.5 flex-shrink-0 rounded p-0.5 hover:bg-muted",children:e.jsx(t.Star,{className:t.cn("h-4 w-4 transition-colors",o?"fill-yellow-400 text-yellow-400":"text-muted-foreground/40 hover:text-yellow-400")})})}),e.jsx(t.TooltipContent,{side:"right",className:"text-xs",children:o?"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:s.title||"Untitled Dashboard",children:s.title||"Untitled Dashboard"}),e.jsx("p",{className:"truncate text-xs text-muted-foreground",title:s.description||"No description",children:(S=s.description)!=null&&S.trim()?s.description:"No description"})]}),e.jsx("div",{className:"flex-shrink-0 opacity-0 transition-opacity group-hover:opacity-100",children:e.jsx(t.DashboardActionsMenu,{dashboard:s,isDeleting:f,isDuplicating:x,shouldHideActions:A,onEditDetails:g,onDeleteClick:j,onDuplicateDashboard:a,onShareDashboard:D,formatDate:y})})]})})]},s.id)})}function ge({onRetry:s}){return e.jsx(t.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(t.Button,{variant:"outline",size:"sm",className:"mt-2",onClick:s,children:"Retry"})]})})}function je(s){var se,ne;const{searchQuery:f,onLoadDashboard:x,onEditDashboard:o,onDashboardItemClick:r}=s,[g,j]=c.useState(!1),[a,D]=c.useState(null),[y,d]=c.useState(!1),[u,p]=c.useState(null),[b,E]=c.useState(null),[N,v]=c.useState(null),A=t.useManagementStore(n=>n.lastSelectedDashboard),V=t.useManagementStore(n=>n.selectedDashboard),P=t.useManagementStore(n=>n.actions.selectDashboard),M=t.useManagementStore(n=>n.actions.clearSelectedDashboard),{tokenProps:S,id:C}=t.useSemaphorContext();t.useRoleAwareDisplayPreferences();const{resources:T,isLoading:h,isError:U,updateResource:Y,deleteResource:F,duplicateResource:K,isDeleting:R}=t.useDashboardManagement(()=>{d(!1);const n=u==null?void 0:u.id;p(null),(V==null?void 0:V.id)===n&&(!(S!=null&&S.dashboard_id)&&!C?M():A&&A.id!==n&&P(A))}),{currentUser:B,userContext:z}=t.useCurrentUserInfo(),J=((se=z==null?void 0:z.permissions)==null?void 0:se.canCreateDashboard)??!1,{data:H}=t.useUserPreferences(),Q=((ne=H==null?void 0:H.preference)==null?void 0:ne.defaultDashboardId)||null,q=T.filter(n=>{var I,m;return((I=n==null?void 0:n.title)==null?void 0:I.toLowerCase().includes(f.toLowerCase()))||((m=n==null?void 0:n.description)==null?void 0:m.toLowerCase().includes(f.toLowerCase()))}),G=n=>new Date(n).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"}),w=n=>{x==null||x(n)},X=n=>{p(n),d(!0)},i=()=>{u&&F(u.id)},L=n=>{E(n),K(n,{onSettled:()=>E(null)})},{startUpdating:l,stopUpdating:W,isUpdating:$}=t.useResourceUpdateState(),Z=(n,I,m)=>{var ae;const ee=Object.fromEntries(Object.entries(I).filter(([,_])=>_!==void 0));if(Object.keys(ee).length===0){(ae=m==null?void 0:m.onSuccess)==null||ae.call(m);return}const ie=Object.keys(ee),te=ie.length===1?ie[0]:void 0;l(n,te),Y({resourceId:n,data:ee},{onSuccess:()=>{var _;W(n,te),(_=m==null?void 0:m.onSuccess)==null||_.call(m)},onError:()=>{var _;W(n,te),(_=m==null?void 0:m.onError)==null||_.call(m)}})},k=n=>{const I=T.find(m=>m.id===n);I&&Y({resourceId:n,data:{isPrivate:!I.isPrivate}})},O=n=>{D(n),B==null||B.type,j(!0)},le=n=>{o==null||o(n.id),v(n)},de=()=>{v(null)},ce=({title:n,description:I})=>{if(!N)return;const m={};n!==N.title&&(m.title=n),(N.description||"")!==I&&(m.description=I),Z(N.id,m,{onSuccess:()=>{v(null)}})};return h?e.jsx(re,{}):U?e.jsx(ge,{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(t.ChartColumn,{className:"mx-auto h-12 w-12 text-muted-foreground/50"})}),e.jsx("h3",{className:"mb-1 font-medium text-foreground",children:f?"No dashboards found":"No dashboards yet"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:f?"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(fe,{dashboard:n,isDeleting:R,isDuplicating:b===n.id,isDefault:n.id===Q,onLoadDashboard:w,onEditDetails:le,onDeleteClick:X,onDuplicateDashboard:L,onTogglePrivacy:k,onShareDashboard:O,formatDate:G,onDashboardItemClick:r},n.id))}),g&&a&&e.jsx(t.ShareDialog,{resource:a,resourceType:t.ResourceType.DASHBOARD,onClose:()=>{j(!1),D(null)}}),e.jsx(t.AlertDialog,{open:y,onOpenChange:n=>{!n&&R||(d(n),n||p(null))},children:e.jsxs(t.AlertDialogContent,{children:[e.jsxs(t.AlertDialogHeader,{children:[e.jsx(t.AlertDialogTitle,{children:"Delete Dashboard"}),e.jsxs(t.AlertDialogDescription,{children:['Are you sure you want to delete "',u==null?void 0:u.title,'"? This action cannot be undone.']})]}),e.jsxs(t.AlertDialogFooter,{children:[e.jsx(t.AlertDialogCancel,{disabled:R,children:"Cancel"}),e.jsxs(t.AlertDialogAction,{onClick:n=>{n.preventDefault(),n.stopPropagation(),i()},className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",disabled:R,children:[R?e.jsx(t.LoaderCircle,{className:"mr-2 h-3.5 w-3.5 animate-spin"}):e.jsx(t.Trash2,{className:"mr-2 h-3.5 w-3.5"}),R?"Deleting...":"Delete"]})]})]})}),N&&e.jsx(t.ResourceEditDialog,{open:!!N,resourceLabel:"Dashboard",initialTitle:N.title||"",initialDescription:N.description||"",onClose:de,onSave:ce,isSaving:$(N.id)})]})}function De({open:s,onOpenChange:f,onSubmit:x,isCreating:o}){const[r,g]=c.useState(""),[j,a]=c.useState("");c.useEffect(()=>{s||(g(""),a(""))},[s]);const D=()=>{r.trim()&&x({title:r,description:j})},y=d=>{f(d)};return e.jsx(t.Dialog,{open:s,onOpenChange:y,children:e.jsxs(t.DialogContent,{children:[e.jsxs(t.DialogHeader,{children:[e.jsx(t.DialogTitle,{children:"Create New Visual"}),e.jsx(t.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(t.Label,{htmlFor:"title",children:"Visual Title"}),e.jsx(t.Input,{id:"title",placeholder:"Enter visual title...",value:r,onChange:d=>g(d.target.value),disabled:o,onKeyDown:d=>{d.key==="Enter"&&!d.shiftKey&&(d.preventDefault(),D())}})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(t.Label,{htmlFor:"description",children:"Description (optional)"}),e.jsx(t.Input,{id:"description",placeholder:"Enter visual description...",value:j,onChange:d=>a(d.target.value),disabled:o})]})]}),e.jsxs(t.DialogFooter,{children:[e.jsx(t.Button,{variant:"outline",onClick:()=>y(!1),disabled:o,children:"Cancel"}),e.jsx(t.Button,{onClick:D,disabled:!r.trim()||o,children:o?e.jsxs(e.Fragment,{children:[e.jsx(t.LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin"}),"Creating..."]}):"Create Visual"})]})]})})}function Ne({isOpen:s,onClose:f,className:x,onDashboardItemClick:o,variant:r="inline"}){var q,G;const g=t.useDashboardStore(w=>w.isDashboardEditing),[j,a]=c.useState(!1),[D,y]=c.useState(""),[d,u]=c.useState(!1),{currentUser:p,userContext:b}=t.useCurrentUserInfo(),E=((q=b==null?void 0:b.permissions)==null?void 0:q.canCreateDashboard)??!1,{onCreateSuccess:N}=t.useDashboardCreation({onDashboardSelect:o}),{selectVisual:v}=t.useManagementActions(),{handleEditLibraryVisual:A}=oe.useVisualUtils(),{createResource:V,isCreating:P,refetch:M}=t.useDashboardManagement(),{createResource:S,isCreating:C}=t.useVisualManagement(void 0,w=>{a(!1),w&&(v(w),A(w))}),T=r==="overlay",h=((p==null?void 0:p.name)??"").trim(),U=((p==null?void 0:p.email)??"").trim(),F=h&&h.toLowerCase()!=="undefined"?h:U||"Current user",K=((G=F.charAt(0))==null?void 0:G.toUpperCase())||"?",R=U&&U.toLowerCase()!=="undefined"?U:"",B=he(f,{enabled:s&&T}),z=t.cn("flex h-full flex-col border-r bg-background",T?t.cn("absolute inset-y-0 left-0 z-[51] w-60 shadow-lg transition-transform duration-300 ease-in-out",s?"translate-x-0":"pointer-events-none -translate-x-full"):"w-full max-w-[17rem] min-w-[11rem] overflow-hidden shadow-sm",x),J=w=>{},H=w=>{console.log("Editing dashboard:",w)},Q=w=>{V(w,{onSuccess:X=>{a(!1),N(X,M)}})};return e.jsx(e.Fragment,{children:(!T||s)&&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:g?"Visuals":"Dashboards"})}),e.jsxs("div",{className:"flex items-center gap-0",children:[e.jsx(t.Button,{size:"sm",variant:"ghost",onClick:()=>u(!d),className:"h-8 w-8 p-0",children:e.jsx(t.Search,{className:"h-3.5 w-3.5"})}),(g||E)&&e.jsx(t.Button,{size:"sm",variant:"ghost",className:"h-8 w-8 whitespace-nowrap p-0",onClick:()=>a(!0),children:e.jsx(t.Plus,{className:"h-3.5 w-3.5"})})]})]}),d&&e.jsx("div",{className:"bg-muted/30 px-4 pb-3",children:e.jsx(t.Input,{placeholder:"Search...",value:D,onChange:w=>y(w.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:g?e.jsx(pe,{searchQuery:D}):e.jsx(je,{searchQuery:D,onLoadDashboard:J,onEditDashboard:H,onDashboardItemClick:o})}),p&&e.jsx(t.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(t.Tooltip,{children:[e.jsx(t.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(t.TooltipContent,{side:"top",className:"max-w-xs",children:e.jsxs("div",{className:"space-y-1",children:[e.jsx("div",{className:"font-medium",children:F}),R&&e.jsx("div",{className:"text-xs text-muted-foreground",children:R}),p.role&&e.jsxs("div",{className:"text-xs text-muted-foreground",children:["Role: ",t.toTitleCase(p.role.replace(/_/g," "))]})]})})]}),e.jsx("span",{className:"truncate text-xs text-muted-foreground",children:F})]})})}),g?e.jsx(De,{open:j,onOpenChange:a,onSubmit:S,isCreating:C}):e.jsx(t.CreateDashboardDialog,{open:j,onOpenChange:a,onSubmit:Q,isCreating:P})]})})}exports.ResourceManagementPanel=Ne;
|
|
@@ -1,4 +1,4 @@
|
|
|
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-
|
|
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-Do9K-YLk.js";
|
|
2
2
|
import { useState as T, useEffect as te, useCallback as V } from "react";
|
|
3
3
|
function re(e) {
|
|
4
4
|
const o = 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-
|
|
1
|
+
"use strict";const o=require("./index-CPBGb2zs.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;
|
package/dist/dashboard/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("../chunks/index-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("../chunks/index-CPBGb2zs.js"),r=require("../types/index.cjs");exports.Dashboard=e.Dashboard;exports.EMPTY_SELECTION=r.EMPTY_SELECTION;
|
package/dist/dashboard/index.js
CHANGED
package/dist/index.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./chunks/index-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./chunks/index-CPBGb2zs.js"),S=require("./types/index.cjs"),a=require("react/jsx-runtime"),g=require("react"),j=require("./chunks/resource-management-panel-DyeJEtOT.js"),c=require("./chunks/dashboard-export-dialog-BXuJmTUR.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.
|
package/dist/index.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { b as S, E as g, F as P, S as w, U as M, m as k, n as A, u as F, o as y, p as L, P as R, q as I, B as V, c as v, r as _, s as U, t as B, v as W, I as j, w as q, x as z, y as O, z as Q, C as G } from "./chunks/index-
|
|
2
|
-
import { Z as oa, _ as na, D as ta, N as ia, a2 as la, R as da, J as ca, J as ua, K as ha, a as pa, T as fa, al as ma, a9 as Ca, W as va, O as ba, Q as Da, a3 as ya, ab as ga, aa as xa, ae as Ea, af as Na, a8 as Ta, V as Sa, a7 as Pa, a0 as wa, a1 as Ma, $ as ka, ac as Aa, a6 as Fa, a5 as La, a4 as Ra, ag as Ia, ad as Va, M as _a, ai as Ua, ak as Ba, aj as Wa, g as ja, A as qa, Y as za, G as Oa, e as Qa, ah as Ga, f as Ha, H as Ka } from "./chunks/index-
|
|
1
|
+
import { b as S, E as g, F as P, S as w, U as M, m as k, n as A, u as F, o as y, p as L, P as R, q as I, B as V, c as v, r as _, s as U, t as B, v as W, I as j, w as q, x as z, y as O, z as Q, C as G } from "./chunks/index-Do9K-YLk.js";
|
|
2
|
+
import { Z as oa, _ as na, D as ta, N as ia, a2 as la, R as da, J as ca, J as ua, K as ha, a as pa, T as fa, al as ma, a9 as Ca, W as va, O as ba, Q as Da, a3 as ya, ab as ga, aa as xa, ae as Ea, af as Na, a8 as Ta, V as Sa, a7 as Pa, a0 as wa, a1 as Ma, $ as ka, ac as Aa, a6 as Fa, a5 as La, a4 as Ra, ag as Ia, ad as Va, M as _a, ai as Ua, ak as Ba, aj as Wa, g as ja, A as qa, Y as za, G as Oa, e as Qa, ah as Ga, f as Ha, H as Ka } from "./chunks/index-Do9K-YLk.js";
|
|
3
3
|
import { EMPTY_SELECTION as $a } 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 H } from "react";
|
|
7
|
-
import { ResourceManagementPanel as Xa } from "./chunks/resource-management-panel-
|
|
8
|
-
import { A as ae, D as ee, S as se, U as re, V as oe, u as ne } from "./chunks/dashboard-export-dialog-
|
|
7
|
+
import { ResourceManagementPanel as Xa } from "./chunks/resource-management-panel-Chc6oyIG.js";
|
|
8
|
+
import { A as ae, D as ee, S as se, U as re, V as oe, u as ne } from "./chunks/dashboard-export-dialog-iH6sg1-y.js";
|
|
9
9
|
import "react-dom";
|
|
10
10
|
/**
|
|
11
11
|
* @license lucide-react v0.453.0 - ISC
|