react-semaphor 0.1.115 → 0.1.116

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 (26) hide show
  1. package/dist/chunks/{dashboard-controls-YDGnMyyK.js → dashboard-controls-CRc6gw-F.js} +4 -4
  2. package/dist/chunks/{dashboard-controls-BQDmKxxN.js → dashboard-controls-CqcS1J54.js} +264 -251
  3. package/dist/chunks/{dashboard-json-BHAPV0Eh.js → dashboard-json-BOlcQgKG.js} +1 -1
  4. package/dist/chunks/{dashboard-json-D-gw81va.js → dashboard-json-D-75FAgQ.js} +1 -1
  5. package/dist/chunks/{edit-dashboard-visual-D8DmYTKj.js → edit-dashboard-visual-COf6UbOg.js} +165 -165
  6. package/dist/chunks/{edit-dashboard-visual-CadUC2o0.js → edit-dashboard-visual-tRQ806YP.js} +1 -1
  7. package/dist/chunks/{editor-action-buttons-CJ1R-8qC.js → editor-action-buttons-2B96j5tL.js} +1 -1
  8. package/dist/chunks/{editor-action-buttons-Cz-qv-g3.js → editor-action-buttons-Bh-TPwiy.js} +2 -2
  9. package/dist/chunks/{index-Bf4pgVkQ.js → index-CRDKevb0.js} +2892 -2880
  10. package/dist/chunks/{index-WFJ2bdm0.js → index-F4v-XjnM.js} +67 -67
  11. package/dist/chunks/resource-management-panel-CwGyO8S9.js +6 -0
  12. package/dist/chunks/resource-management-panel-DtwM8NVN.js +895 -0
  13. package/dist/chunks/{schedule-dashboard-BJ0PeQTb.js → schedule-dashboard-CtXspopT.js} +3 -3
  14. package/dist/chunks/{schedule-dashboard-DlYi6cPQ.js → schedule-dashboard-DWh6NWL5.js} +1 -1
  15. package/dist/chunks/{use-visual-utils-DlzVpKYl.js → use-visual-utils-Ce0Sq8Hn.js} +1 -1
  16. package/dist/chunks/{use-visual-utils-DlurLDVv.js → use-visual-utils-DyKq-_On.js} +1 -1
  17. package/dist/dashboard/index.cjs +1 -1
  18. package/dist/dashboard/index.js +1 -1
  19. package/dist/index.cjs +1 -1
  20. package/dist/index.js +4 -4
  21. package/dist/style.css +1 -1
  22. package/dist/surfboard/index.cjs +1 -1
  23. package/dist/surfboard/index.js +1 -1
  24. package/package.json +1 -1
  25. package/dist/chunks/resource-management-panel-BXzn0kHW.js +0 -6
  26. package/dist/chunks/resource-management-panel-ByY6ZxCb.js +0 -878
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("../chunks/index-WFJ2bdm0.js"),r=require("../types/index.cjs");exports.Surfboard=e.DashboardPlus;exports.EMPTY_SELECTION=r.EMPTY_SELECTION;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("../chunks/index-F4v-XjnM.js"),r=require("../types/index.cjs");exports.Surfboard=e.DashboardPlus;exports.EMPTY_SELECTION=r.EMPTY_SELECTION;
@@ -1,4 +1,4 @@
1
- import { a } from "../chunks/index-Bf4pgVkQ.js";
1
+ import { a } from "../chunks/index-CRDKevb0.js";
2
2
  import { EMPTY_SELECTION as E } from "../types/index.js";
3
3
  export {
4
4
  E as EMPTY_SELECTION,
package/package.json CHANGED
@@ -5,7 +5,7 @@
5
5
  "email": "support@semaphor.cloud"
6
6
  },
7
7
  "license": "MIT",
8
- "version": "0.1.115",
8
+ "version": "0.1.116",
9
9
  "description": "Fully interactive and customizable dashboards for your apps.",
10
10
  "keywords": [
11
11
  "react",
@@ -1,6 +0,0 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),s=require("./index-WFJ2bdm0.js"),u=require("react"),re=require("./use-visual-utils-DlurLDVv.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(s.ScrollArea,{className:"w-full flex-1",children:e.jsxs("div",{className:"space-y-4 px-4 py-2",children:[e.jsx("div",{className:"h-9 w-full rounded bg-muted animate-pulse"}),e.jsx("div",{className:"h-9 w-full rounded bg-muted animate-pulse"}),e.jsx("div",{className:"space-y-3 pt-2",children:[...Array(3)].map((t,g)=>e.jsxs("div",{className:"flex gap-3 animate-pulse",children:[e.jsx("div",{className:"h-8 w-8 rounded bg-muted flex-shrink-0"}),e.jsxs("div",{className:"flex-1 space-y-1.5",children:[e.jsx("div",{className:"h-4 w-2/3 rounded bg-muted"}),e.jsx("div",{className:"h-3 w-4/5 rounded bg-muted"})]})]},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:m,onShareVisual:D,formatDate:v}){var L,y,C,P;const{selectVisual:l}=s.useManagementActions(),d=s.useIsVisualSelected(t.id),N=me(t.id),{isConsoleMode:M}=s.useDashboardPreferences(),b=u.useRef(null),[w,S]=u.useState(!1),[V,A]=u.useState(!1);u.useEffect(()=>{p?(S(!0),A(!0)):V&&(S(!1),A(!1))},[p,V]),u.useEffect(()=>{N&&b.current&&b.current.scrollIntoView({behavior:"smooth",block:"center"})},[N]);const T=()=>{l(t),r==null||r(t)};return e.jsxs("div",{ref:b,className:s.cn("group flex cursor-pointer items-start gap-3 rounded-md px-2 py-2 transition-colors hover:bg-muted",N?"bg-purple-500/10":d&&"bg-muted/80"),onClick:T,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:(L=t.description)!=null&&L.trim()?t.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(s.DropdownMenu,{modal:!1,open:w,onOpenChange:S,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:h=>{h.stopPropagation(),a(t)},children:[e.jsx(s.Plus,{className:"mr-2 h-3 w-3"}),"Add"]}),e.jsxs(s.DropdownMenuItem,{onClick:h=>{h.stopPropagation(),r==null||r(t)},children:[e.jsx(he,{className:"mr-2 h-3 w-3"}),"Open"]}),e.jsxs(s.DropdownMenuItem,{onClick:h=>{h.preventDefault(),h.stopPropagation(),m(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:h=>{h.stopPropagation(),f==null||f(t)},children:[e.jsx(s.PenLine,{className:"mr-2 h-3 w-3"}),"Edit details"]}),e.jsxs(s.DropdownMenuItem,{onClick:h=>{h.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:h=>{h.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:[(((y=t.ownership.createdBy)==null?void 0:y.type)==="tenant"||((C=t.ownership.createdBy)==null?void 0:C.type)==="organization"&&M)&&e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(s.User,{className:"h-3 w-3"}),e.jsx("span",{children:((P=t.ownership.createdBy)==null?void 0:P.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:v(t.lastModified)})]})]})]})]})}),e.jsx(s.IconButton,{tooltip:"Add to dashboard",buttonProps:{variant:"ghost",size:"sm",onClick:h=>{h.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]=u.useState(!1),[a,r]=u.useState(null),[f,j]=u.useState(!1),[m,D]=u.useState(null),[v,l]=u.useState(null),[d,N]=u.useState(null),{selectVisual:M}=s.useManagementActions(),{handleEditLibraryVisual:b,handleAddLibraryVisual:w}=re.useVisualUtils(),{resources:S,isLoading:V,isError:A,updateResource:T,deleteResource:L,duplicateResource:y,isDeleting:C}=s.useVisualManagement(()=>{j(!1),D(null)});s.useCurrentUserInfo();const P=S.filter(i=>{var E,o;return((E=i==null?void 0:i.title)==null?void 0:E.toLowerCase().includes(t.toLowerCase()))||((o=i==null?void 0:i.description)==null?void 0:o.toLowerCase().includes(t.toLowerCase()))}),h=i=>new Date(i).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"}),H=i=>{D(i),j(!0)},B=()=>{m&&L(m.id)},{startUpdating:q,stopUpdating:U,isUpdating:x}=s.useResourceUpdateState(),R=(i,E,o)=>{var J;const z=Object.fromEntries(Object.entries(E).filter(([,O])=>O!==void 0));if(Object.keys(z).length===0){(J=o==null?void 0:o.onSuccess)==null||J.call(o);return}const Y=Object.keys(z),G=Y.length===1?Y[0]:void 0;q(i,G),T({resourceId:i,data:z},{onSuccess:()=>{var O;U(i,G),(O=o==null?void 0:o.onSuccess)==null||O.call(o)},onError:()=>{var O;U(i,G),(O=o==null?void 0:o.onError)==null||O.call(o)}})},_=i=>{l(i),y(i,{onSettled:()=>l(null)})},Q=i=>{b(i)},K=i=>{w(i)},X=i=>{const E=S.find(o=>o.id===i);E&&T({resourceId:i,data:{isPrivate:!E.isPrivate}})},W=i=>{r(i),p(!0)},Z=i=>{N(i)},$=()=>{N(null)},k=({title:i,description:E})=>{if(!d)return;const o={};i!==d.title&&(o.title=i),(d.description||"")!==E&&(o.description=E),R(d.id,o,{onSuccess:()=>{N(null)}})};return V?e.jsx(oe,{}):A?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:P.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'})]}):P.map(i=>e.jsx(xe,{visual:i,onAddVisual:K,onOpenVisual:Q,onEditDetails:Z,onDeleteClick:H,onDuplicateVisual:_,onTogglePrivacy:X,onShareVisual:W,isDeleting:C,isDuplicating:v===i.id,formatDate:h},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:$,onSave:k,isSaving:x(d.id)}),e.jsx(s.AlertDialog,{open:f,onOpenChange:i=>{!i&&C||(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 "',m==null?void 0:m.title,'"? This action cannot be undone.']})]}),e.jsxs(s.AlertDialogFooter,{children:[e.jsx(s.AlertDialogCancel,{disabled:C,children:"Cancel"}),e.jsxs(s.AlertDialogAction,{onClick:i=>{i.preventDefault(),i.stopPropagation(),B()},className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",disabled:C,children:[C?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"}),C?"Deleting...":"Delete"]})]})]})})]})}function ge({dashboard:t,isDeleting:g,isDuplicating:p,isDefault:a,onLoadDashboard:r,onEditDetails:f,onDeleteClick:j,onDuplicateDashboard:m,onShareDashboard:D,formatDate:v,onDashboardItemClick:l}){var L,y;const{selectDashboard:d}=s.useManagementActions(),N=s.useIsDashboardSelected(t.id),{userContext:M,isLoading:b}=s.useCurrentUserInfo(),{mutate:w}=s.useDefaultDashboardMutation(),S=((L=M==null?void 0:M.permissions)==null?void 0:L.canEdit)??!1,V=b||!S,A=()=>{d(t),r(t.id),l==null||l(t.id)},T=C=>{C.stopPropagation(),w({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",N&&"bg-muted/80"),onClick:A,children:[e.jsxs(s.Tooltip,{children:[e.jsx(s.TooltipTrigger,{asChild:!0,children:e.jsx("button",{onClick:T,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:(y=t.description)!=null&&y.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:V,onEditDetails:f,onDeleteClick:j,onDuplicateDashboard:m,onShareDashboard:D,formatDate:v})})]})})]},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]=u.useState(!1),[m,D]=u.useState(null),[v,l]=u.useState(!1),[d,N]=u.useState(null),[M,b]=u.useState(null),[w,S]=u.useState(null),V=s.useManagementStore(n=>n.lastSelectedDashboard),A=s.useManagementStore(n=>n.selectedDashboard),T=s.useManagementStore(n=>n.actions.selectDashboard),L=s.useManagementStore(n=>n.actions.clearSelectedDashboard),{tokenProps:y,id:C}=s.useSemaphorContext();s.useRoleAwareDisplayPreferences();const{resources:P,isLoading:h,isError:H,updateResource:B,deleteResource:q,duplicateResource:U,isDeleting:x}=s.useDashboardManagement(()=>{l(!1);const n=d==null?void 0:d.id;N(null),(A==null?void 0:A.id)===n&&(!(y!=null&&y.dashboard_id)&&!C?L():V&&V.id!==n&&T(V))}),{currentUser:R,userContext:_}=s.useCurrentUserInfo(),Q=((te=_==null?void 0:_.permissions)==null?void 0:te.canCreateDashboard)??!1,{data:K}=s.useUserPreferences(),X=((ne=K==null?void 0:K.preference)==null?void 0:ne.defaultDashboardId)||null,W=P.filter(n=>{var I,c;return((I=n==null?void 0:n.title)==null?void 0:I.toLowerCase().includes(g.toLowerCase()))||((c=n==null?void 0:n.description)==null?void 0:c.toLowerCase().includes(g.toLowerCase()))}),Z=n=>new Date(n).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"}),$=n=>{p==null||p(n)},k=n=>{N(n),l(!0)},i=()=>{d&&q(d.id)},E=n=>{b(n),U(n,{onSettled:()=>b(null)})},{startUpdating:o,stopUpdating:z,isUpdating:Y}=s.useResourceUpdateState(),G=(n,I,c)=>{var ae;const ee=Object.fromEntries(Object.entries(I).filter(([,F])=>F!==void 0));if(Object.keys(ee).length===0){(ae=c==null?void 0:c.onSuccess)==null||ae.call(c);return}const ie=Object.keys(ee),se=ie.length===1?ie[0]:void 0;o(n,se),B({resourceId:n,data:ee},{onSuccess:()=>{var F;z(n,se),(F=c==null?void 0:c.onSuccess)==null||F.call(c)},onError:()=>{var F;z(n,se),(F=c==null?void 0:c.onError)==null||F.call(c)}})},J=n=>{const I=P.find(c=>c.id===n);I&&B({resourceId:n,data:{isPrivate:!I.isPrivate}})},O=n=>{D(n),R==null||R.type,j(!0)},le=n=>{a==null||a(n.id),S(n)},de=()=>{S(null)},ce=({title:n,description:I})=>{if(!w)return;const c={};n!==w.title&&(c.title=n),(w.description||"")!==I&&(c.description=I),G(w.id,c,{onSuccess:()=>{S(null)}})};return h?e.jsx(oe,{}):H?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:W.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":Q?'Click "Create" above to add your first dashboard':"No dashboards have been shared with you yet"})]}):W.map(n=>e.jsx(ge,{dashboard:n,isDeleting:x,isDuplicating:M===n.id,isDefault:n.id===X,onLoadDashboard:$,onEditDetails:le,onDeleteClick:k,onDuplicateDashboard:E,onTogglePrivacy:J,onShareDashboard:O,formatDate:Z,onDashboardItemClick:r},n.id))}),f&&m&&e.jsx(s.ShareDialog,{resource:m,resourceType:s.ResourceType.DASHBOARD,onClose:()=>{j(!1),D(null)}}),e.jsx(s.AlertDialog,{open:v,onOpenChange:n=>{!n&&x||(l(n),n||N(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:x,children:"Cancel"}),e.jsxs(s.AlertDialogAction,{onClick:n=>{n.preventDefault(),n.stopPropagation(),i()},className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",disabled:x,children:[x?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"}),x?"Deleting...":"Delete"]})]})]})}),w&&e.jsx(s.ResourceEditDialog,{open:!!w,resourceLabel:"Dashboard",initialTitle:w.title||"",initialDescription:w.description||"",onClose:de,onSave:ce,isSaving:Y(w.id)})]})}function De({open:t,onOpenChange:g,onSubmit:p,isCreating:a}){const[r,f]=u.useState(""),[j,m]=u.useState("");u.useEffect(()=>{t||(f(""),m(""))},[t]);const D=()=>{r.trim()&&p({title:r,description:j})},v=l=>{g(l)};return e.jsx(s.Dialog,{open:t,onOpenChange:v,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=>m(l.target.value),disabled:a})]})]}),e.jsxs(s.DialogFooter,{children:[e.jsx(s.Button,{variant:"outline",onClick:()=>v(!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 U;const f=s.useDashboardStore(x=>x.isDashboardEditing),[j,m]=u.useState(!1),[D,v]=u.useState(""),[l,d]=u.useState(!1),{userContext:N}=s.useCurrentUserInfo(),M=((U=N==null?void 0:N.permissions)==null?void 0:U.canCreateDashboard)??!1,{onCreateSuccess:b}=s.useDashboardCreation({onDashboardSelect:a}),{selectVisual:w}=s.useManagementActions(),{handleEditLibraryVisual:S}=re.useVisualUtils(),{createResource:V,isCreating:A,refetch:T}=s.useDashboardManagement(),{createResource:L,isCreating:y}=s.useVisualManagement(void 0,x=>{m(!1),x&&(w(x),S(x))}),C=r==="overlay",P=ue.useClickOutside(g,{enabled:t&&C}),h=s.cn("flex h-full flex-col border-r bg-background",C?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),H=x=>{},B=x=>{console.log("Editing dashboard:",x)},q=x=>{V(x,{onSuccess:R=>{m(!1),b(R,T)}})};return e.jsx(e.Fragment,{children:(!C||t)&&e.jsxs("div",{ref:P,className:h,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||M)&&e.jsx(s.Button,{size:"sm",variant:"ghost",className:"h-8 w-8 whitespace-nowrap p-0",onClick:()=>m(!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:x=>v(x.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:H,onEditDashboard:B,onDashboardItemClick:a})}),f?e.jsx(De,{open:j,onOpenChange:m,onSubmit:L,isCreating:y}):e.jsx(s.CreateDashboardDialog,{open:j,onOpenChange:m,onSubmit:q,isCreating:A})]})})}exports.ResourceManagementPanel=Ne;