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
|
@@ -1,6 +0,0 @@
|
|
|
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;
|
|
@@ -1 +0,0 @@
|
|
|
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;
|
|
@@ -1,16 +0,0 @@
|
|
|
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
|
-
};
|