react-semaphor 0.1.209 → 0.1.210
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-BAOrAMV9.js +42 -0
- package/dist/chunks/{dashboard-controls-BNTI4r0_.js → dashboard-controls-C08300Wi.js} +504 -456
- package/dist/chunks/{dashboard-json-kIoBtmBF.js → dashboard-json-DlEE5-WA.js} +1 -1
- package/dist/chunks/{dashboard-json-BjOqpGbW.js → dashboard-json-GjDBGO26.js} +1 -1
- package/dist/chunks/{dashboard-summary-settings-dialog-BoX18wiA.js → dashboard-summary-settings-dialog-QUuhhXU9.js} +1 -1
- package/dist/chunks/{dashboard-summary-settings-dialog-CO1SwHHD.js → dashboard-summary-settings-dialog-THx-gjnG.js} +1 -1
- package/dist/chunks/{edit-dashboard-visual-DG4VLoJF.js → edit-dashboard-visual-Bsmow1Pa.js} +3422 -3536
- package/dist/chunks/edit-dashboard-visual-PfWJXb2-.js +164 -0
- package/dist/chunks/editor-action-buttons-DNbp_ZWy.js +404 -0
- package/dist/chunks/editor-action-buttons-FPyaC09X.js +21 -0
- package/dist/chunks/{index-D0TdW88i.js → index-CAVrkf9d.js} +2196 -2180
- package/dist/chunks/{index-DSA80lEg.js → index-CXKjmjfB.js} +67 -67
- package/dist/chunks/normalize-dashboard-for-dirty-check-D9x96J2F.js +1 -0
- package/dist/chunks/normalize-dashboard-for-dirty-check-XKgH3GFX.js +119 -0
- package/dist/chunks/notification-bell-BqvKQSw9.js +6 -0
- package/dist/chunks/notification-bell-C3a7wC1u.js +871 -0
- package/dist/chunks/{resource-management-panel-DS_WEv1x.js → resource-management-panel-BVTgbma8.js} +343 -332
- package/dist/chunks/resource-management-panel-C5NjrVsA.js +6 -0
- package/dist/chunks/{use-role-aware-display-preferences-DfihB5pN.js → use-role-aware-display-preferences-DxCPoCgr.js} +1 -1
- package/dist/chunks/{use-role-aware-display-preferences-D8j5_cnK.js → use-role-aware-display-preferences-l7NFLYnn.js} +1 -1
- package/dist/chunks/{use-visual-utils-CzcVz3zB.js → use-visual-utils-B82Q-Ytl.js} +1 -1
- package/dist/chunks/{use-visual-utils-BfLXO_vi.js → use-visual-utils-D9IJz9R0.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 +44 -40
- package/dist/shared/index.cjs +1 -0
- package/dist/shared/index.js +6 -0
- package/dist/style.css +1 -1
- package/dist/surfboard/index.cjs +1 -1
- package/dist/surfboard/index.js +2 -2
- package/dist/types/main.d.ts +39 -1
- package/dist/types/shared.d.ts +1762 -0
- package/package.json +6 -1
- package/dist/chunks/dashboard-controls-Dcpx9_an.js +0 -42
- package/dist/chunks/edit-dashboard-visual-B9HuGExj.js +0 -179
- package/dist/chunks/editor-action-buttons-CDTIx_Jc.js +0 -11
- package/dist/chunks/editor-action-buttons-CszdZ4Fw.js +0 -345
- package/dist/chunks/notification-bell-D2V1-ARa.js +0 -11
- package/dist/chunks/notification-bell-DFiRaeJQ.js +0 -862
- package/dist/chunks/resource-management-panel-BhiWNPcw.js +0 -6
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),s=require("./index-DSA80lEg.js"),c=require("react"),le=require("./use-visual-utils-CzcVz3zB.js"),he=require("./use-role-aware-display-preferences-D8j5_cnK.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 me=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 xe(t,f={}){const{enabled:p=!0,eventType:o="mousedown"}=f,r=c.useRef(null);return c.useEffect(()=>{const u=j=>{const i=j.target;r.current&&r.current.contains(i)||i instanceof Element&&(i.closest("[data-radix-popper-content-wrapper]")||i.closest("[data-radix-select-content]")||i.closest("[data-radix-popover-content]")||i.closest("[data-radix-dropdown-menu-content]")||i.closest("[data-radix-tooltip-content]")||i.closest('[role="listbox"]')||i.closest('[role="option"]')||i.closest('[role="combobox"]'))||i instanceof Element&&i.hasAttribute("data-radix-")||t()};return p&&document.addEventListener(o,u),()=>{document.removeEventListener(o,u)}},[t,p,o]),r}function de(){return e.jsx("div",{className:"space-y-1 px-2 py-2",children:[...Array(5)].map((t,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 pe=t=>{const f=s.useDashboardStore(r=>r.isVisualEditing),p=s.useDashboardStore(r=>r.selectedFrameId),o=s.useEditorStore(r=>r.frame);return!!(f&&p&&(o==null?void 0:o.visualId)===t)};function fe({visual:t,isDeleting:f,isDuplicating:p,onAddVisual:o,onOpenVisual:r,onEditDetails:u,onDeleteClick:j,onDuplicateVisual:i,onShareVisual:D,formatDate:v}){var M,R,P,w;const{selectVisual:h}=s.useManagementActions(),m=s.useIsVisualSelected(t.id),d=pe(t.id),{isConsoleMode:L}=s.useDashboardPreferences(),E=c.useRef(null),[N,y]=c.useState(!1),[S,b]=c.useState(!1);c.useEffect(()=>{p?(y(!0),b(!0)):S&&(y(!1),b(!1))},[p,S]),c.useEffect(()=>{d&&E.current&&E.current.scrollIntoView({behavior:"smooth",block:"center"})},[d]);const H=()=>{h(t),r==null||r(t)};return e.jsx("div",{ref:E,className:s.cn("group flex cursor-pointer items-start rounded-md px-2 py-2 transition-colors hover:bg-muted",d?"bg-purple-500/10":m&&"bg-muted/80"),onClick:H,children: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:g=>g.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:g=>{g.stopPropagation(),o(t)},children:[e.jsx(s.Plus,{className:"mr-2 h-3 w-3"}),"Add"]}),e.jsxs(s.DropdownMenuItem,{onClick:g=>{g.stopPropagation(),r==null||r(t)},children:[e.jsx(me,{className:"mr-2 h-3 w-3"}),"Open"]}),e.jsxs(s.DropdownMenuItem,{onClick:g=>{g.preventDefault(),g.stopPropagation(),i(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:g=>{g.stopPropagation(),u==null||u(t)},children:[e.jsx(s.PenLine,{className:"mr-2 h-3 w-3"}),"Edit details"]}),e.jsxs(s.DropdownMenuItem,{onClick:g=>{g.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:g=>{g.stopPropagation(),j(t)},className:"text-destructive",disabled:f,children:[e.jsx(s.Trash2,{className:"mr-2 h-3 w-3"}),f?"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:[(((R=t.ownership.createdBy)==null?void 0:R.type)==="tenant"||((P=t.ownership.createdBy)==null?void 0:P.type)==="organization"&&L)&&e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(s.User,{className:"h-3 w-3"}),e.jsx("span",{children:((w=t.ownership.createdBy)==null?void 0:w.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.jsxs(s.Button,{size:"sm",variant:"outline",className:"h-7 gap-1 px-2 text-xs",onClick:g=>{g.stopPropagation(),o(t)},children:[e.jsx(s.Plus,{className:"h-3.5 w-3.5"}),"Add"]})]})]})})},t.id)}function ge({searchQuery:t}){const[f,p]=c.useState(!1),[o,r]=c.useState(null),[u,j]=c.useState(!1),[i,D]=c.useState(null),[v,h]=c.useState(null),[m,d]=c.useState(null),{selectVisual:L}=s.useManagementActions(),{handleEditLibraryVisual:E,handleAddLibraryVisual:N}=le.useVisualUtils(),{resources:y,isLoading:S,isError:b,isFetching:H,updateResource:M,deleteResource:R,duplicateResource:P,isDeleting:w,isDuplicating:g,isUpdating:Z}=s.useVisualManagement(()=>{j(!1),D(null)});s.useCurrentUserInfo();const G=y.filter(a=>{var V,l;return((V=a==null?void 0:a.title)==null?void 0:V.toLowerCase().includes(t.toLowerCase()))||((l=a==null?void 0:a.description)==null?void 0:l.toLowerCase().includes(t.toLowerCase()))}),q=a=>new Date(a).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"}),I=a=>{D(a),j(!0)},U=()=>{i&&R(i.id)},{startUpdating:te,stopUpdating:A,isUpdating:k}=s.useResourceUpdateState(),W=(a,V,l)=>{var se;const Q=Object.fromEntries(Object.entries(V).filter(([,O])=>O!==void 0));if(Object.keys(Q).length===0){(se=l==null?void 0:l.onSuccess)==null||se.call(l);return}const ee=Object.keys(Q),X=ee.length===1?ee[0]:void 0;te(a,X),M({resourceId:a,data:Q},{onSuccess:()=>{var O;A(a,X),(O=l==null?void 0:l.onSuccess)==null||O.call(l)},onError:()=>{var O;A(a,X),(O=l==null?void 0:l.onError)==null||O.call(l)}})},B=a=>{h(a),P(a,{onSettled:()=>h(null)})},F=a=>{E(a)},Y=a=>{N(a)},_=a=>{const V=y.find(l=>l.id===a);V&&M({resourceId:a,data:{isPrivate:!V.isPrivate}})},J=a=>{r(a),p(!0)},$=a=>{d(a)},K=()=>{d(null)},C=({title:a,description:V})=>{if(!m)return;const l={};a!==m.title&&(l.title=a),(m.description||"")!==V&&(l.description=V),W(m.id,l,{onSuccess:()=>{d(null)}})};return S?e.jsx(de,{}):b?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:G.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 "New" above to add your first visual'})]}):G.map(a=>e.jsx(fe,{visual:a,onAddVisual:Y,onOpenVisual:F,onEditDetails:$,onDeleteClick:I,onDuplicateVisual:B,onTogglePrivacy:_,onShareVisual:J,isDeleting:w,isDuplicating:v===a.id,formatDate:q},a.id))}),f&&o&&e.jsx(s.ShareDialog,{resource:o,resourceType:s.ResourceType.VISUAL,onClose:()=>{p(!1),r(null)}}),m&&e.jsx(s.ResourceEditDialog,{open:!!m,resourceLabel:"Visual",initialTitle:m.title||"",initialDescription:m.description||"",onClose:K,onSave:C,isSaving:k(m.id)}),e.jsx(s.AlertDialog,{open:u,onOpenChange:a=>{!a&&w||(j(a),a||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 "',i==null?void 0:i.title,'"? This action cannot be undone.']})]}),e.jsxs(s.AlertDialogFooter,{children:[e.jsx(s.AlertDialogCancel,{disabled:w,children:"Cancel"}),e.jsxs(s.AlertDialogAction,{onClick:a=>{a.preventDefault(),a.stopPropagation(),U()},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 je({dashboard:t,isDeleting:f,isDuplicating:p,onLoadDashboard:o,onEditDetails:r,onDeleteClick:u,onDuplicateDashboard:j,onShareDashboard:i,formatDate:D,onDashboardItemClick:v}){var S,b;const{selectDashboard:h}=s.useManagementActions(),m=s.useIsDashboardSelected(t.id),{userContext:d,isLoading:L}=s.useCurrentUserInfo(),E=((S=d==null?void 0:d.permissions)==null?void 0:S.canEdit)??!1,N=L||!E,y=()=>{h(t),o(t.id),v==null||v(t.id)};return e.jsx("div",{className:s.cn("group flex cursor-pointer items-start rounded-md px-2 py-2 transition-colors hover:bg-muted",m&&"bg-muted/80"),onClick:y,children: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:(b=t.description)!=null&&b.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:f,isDuplicating:p,shouldHideActions:N,onEditDetails:r,onDeleteClick:u,onDuplicateDashboard:j,onShareDashboard:i,formatDate:D})})]})})},t.id)}function De({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 Ne(t){var ie;const{searchQuery:f,onLoadDashboard:p,onEditDashboard:o,onDashboardItemClick:r}=t,[u,j]=c.useState(!1),[i,D]=c.useState(null),[v,h]=c.useState(!1),[m,d]=c.useState(null),[L,E]=c.useState(null),[N,y]=c.useState(null),S=s.useManagementStore(n=>n.lastSelectedDashboard),b=s.useManagementStore(n=>n.selectedDashboard),H=s.useManagementStore(n=>n.actions.selectDashboard),M=s.useManagementStore(n=>n.actions.clearSelectedDashboard),{tokenProps:R,id:P}=s.useSemaphorContext();he.useRoleAwareDisplayPreferences();const{resources:w,isLoading:g,isError:Z,isFetching:G,updateResource:q,deleteResource:I,duplicateResource:U,isUpdating:te,isDeleting:A,isDuplicating:k,refetch:W}=s.useDashboardManagement(()=>{h(!1);const n=m==null?void 0:m.id;d(null),(b==null?void 0:b.id)===n&&(!(R!=null&&R.dashboard_id)&&!P?M():S&&S.id!==n&&H(S))}),{currentUser:B,userContext:F}=s.useCurrentUserInfo(),Y=((ie=F==null?void 0:F.permissions)==null?void 0:ie.canCreateDashboard)??!1,_=w.filter(n=>{var T,x;return((T=n==null?void 0:n.title)==null?void 0:T.toLowerCase().includes(f.toLowerCase()))||((x=n==null?void 0:n.description)==null?void 0:x.toLowerCase().includes(f.toLowerCase()))}),J=n=>new Date(n).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"}),$=n=>{p==null||p(n)},K=n=>{d(n),h(!0)},C=()=>{m&&I(m.id)},a=n=>{E(n),U(n,{onSettled:()=>E(null)})},{startUpdating:V,stopUpdating:l,isUpdating:Q}=s.useResourceUpdateState(),ee=(n,T,x)=>{var oe;const ne=Object.fromEntries(Object.entries(T).filter(([,z])=>z!==void 0));if(Object.keys(ne).length===0){(oe=x==null?void 0:x.onSuccess)==null||oe.call(x);return}const re=Object.keys(ne),ae=re.length===1?re[0]:void 0;V(n,ae),q({resourceId:n,data:ne},{onSuccess:()=>{var z;l(n,ae),(z=x==null?void 0:x.onSuccess)==null||z.call(x)},onError:()=>{var z;l(n,ae),(z=x==null?void 0:x.onError)==null||z.call(x)}})},X=n=>{const T=w.find(x=>x.id===n);T&&q({resourceId:n,data:{isPrivate:!T.isPrivate}})},se=n=>{D(n),B==null||B.type,j(!0)},O=n=>{o==null||o(n.id),y(n)},ce=()=>{y(null)},ue=({title:n,description:T})=>{if(!N)return;const x={};n!==N.title&&(x.title=n),(N.description||"")!==T&&(x.description=T),ee(N.id,x,{onSuccess:()=>{y(null)}})};return g?e.jsx(de,{}):Z?e.jsx(De,{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:_.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:f?"No dashboards found":"No dashboards yet"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:f?"Try adjusting your search":Y?'Click "New" above to add your first dashboard':"No dashboards have been shared with you yet"})]}):_.map(n=>e.jsx(je,{dashboard:n,isDeleting:A,isDuplicating:L===n.id,onLoadDashboard:$,onEditDetails:O,onDeleteClick:K,onDuplicateDashboard:a,onTogglePrivacy:X,onShareDashboard:se,formatDate:J,onDashboardItemClick:r},n.id))}),u&&i&&e.jsx(s.ShareDialog,{resource:i,resourceType:s.ResourceType.DASHBOARD,onClose:()=>{j(!1),D(null)}}),e.jsx(s.AlertDialog,{open:v,onOpenChange:n=>{!n&&A||(h(n),n||d(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 "',m==null?void 0:m.title,'"? This action cannot be undone.']})]}),e.jsxs(s.AlertDialogFooter,{children:[e.jsx(s.AlertDialogCancel,{disabled:A,children:"Cancel"}),e.jsxs(s.AlertDialogAction,{onClick:n=>{n.preventDefault(),n.stopPropagation(),C()},className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",disabled:A,children:[A?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"}),A?"Deleting...":"Delete"]})]})]})}),N&&e.jsx(s.ResourceEditDialog,{open:!!N,resourceLabel:"Dashboard",initialTitle:N.title||"",initialDescription:N.description||"",onClose:ce,onSave:ue,isSaving:Q(N.id)})]})}function we({open:t,onOpenChange:f,onSubmit:p,isCreating:o}){const[r,u]=c.useState(""),[j,i]=c.useState("");c.useEffect(()=>{t||(u(""),i(""))},[t]);const D=()=>{r.trim()&&p({title:r,description:j})},v=h=>{f(h)};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$1,{id:"title",placeholder:"Enter visual title...",value:r,onChange:h=>u(h.target.value),disabled:o,onKeyDown:h=>{h.key==="Enter"&&!h.shiftKey&&(h.preventDefault(),D())}})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(s.Label,{htmlFor:"description",children:"Description (optional)"}),e.jsx(s.Input$1,{id:"description",placeholder:"Enter visual description...",value:j,onChange:h=>i(h.target.value),disabled:o})]})]}),e.jsxs(s.DialogFooter,{children:[e.jsx(s.Button,{variant:"outline",onClick:()=>v(!1),disabled:o,children:"Cancel"}),e.jsx(s.Button,{onClick:D,disabled:!r.trim()||o,children:o?e.jsxs(e.Fragment,{children:[e.jsx(s.LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin"}),"Creating..."]}):"Create Visual"})]})]})})}function Ce({isOpen:t,onClose:f,className:p,onDashboardItemClick:o,variant:r="inline"}){var $,K;const u=s.useDashboardStore(C=>C.isDashboardEditing),[j,i]=c.useState(!1),[D,v]=c.useState(""),[h,m]=c.useState(!1),{currentUser:d,userContext:L}=s.useCurrentUserInfo(),E=(($=L==null?void 0:L.permissions)==null?void 0:$.canCreateDashboard)??!1,{onCreateSuccess:N}=s.useDashboardCreation({onDashboardSelect:o}),{selectVisual:y}=s.useManagementActions(),{handleEditLibraryVisual:S}=le.useVisualUtils(),{createResource:b,isCreating:H,refetch:M}=s.useDashboardManagement(),{createResource:R,isCreating:P}=s.useVisualManagement(void 0,C=>{i(!1),C&&(y(C),S(C))}),w=r==="overlay",g=u?"New Visual":"New",Z=u?"New Visual":"New Dashboard",G=u?"Search visuals...":"Search dashboards...",q=u?"Collapse visuals panel":"Collapse dashboard panel",I=((d==null?void 0:d.name)??"").trim(),U=((d==null?void 0:d.email)??"").trim(),A=I&&I.toLowerCase()!=="undefined"?I:U||"Current user",k=((K=A.charAt(0))==null?void 0:K.toUpperCase())||"?",W=U&&U.toLowerCase()!=="undefined"?U:"",B=xe(f,{enabled:t&&w}),F=s.cn("flex h-full flex-col border-r bg-background",w?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),Y=C=>{},_=C=>{console.log("Editing dashboard:",C)},J=C=>{b(C,{onSuccess:a=>{i(!1),N(a,M)}})};return e.jsx(e.Fragment,{children:(!w||t)&&e.jsxs("div",{ref:B,className:F,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:u?"Visuals":"Dashboards"})}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(s.Button,{size:"sm",variant:"ghost",onClick:()=>m(!h),className:"h-8 w-8 p-0","aria-label":h?"Hide search":"Show search",children:e.jsx(s.Search,{className:"h-3.5 w-3.5"})}),(u||E)&&e.jsxs(s.Button,{size:"sm",variant:"ghost",className:"h-8 gap-1.5 whitespace-nowrap px-2 text-xs",onClick:()=>i(!0),"aria-label":Z,children:[e.jsx(s.Plus,{className:"h-3.5 w-3.5"}),g]}),e.jsx(s.Button,{size:"sm",variant:"secondary",className:"h-7 w-7 p-0.5",onClick:f,"aria-label":q,children:e.jsx(s.ChevronLeft,{className:"h-3.5 w-3.5"})})]})]}),h&&e.jsx("div",{className:"bg-muted/30 px-4 pb-3",children:e.jsx(s.Input$1,{placeholder:G,value:D,onChange:C=>v(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:u?e.jsx(ge,{searchQuery:D}):e.jsx(Ne,{searchQuery:D,onLoadDashboard:Y,onEditDashboard:_,onDashboardItemClick:o})}),d&&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:A}),W&&e.jsx("div",{className:"text-xs text-muted-foreground",children:W}),d.role&&e.jsxs("div",{className:"text-xs text-muted-foreground",children:["Role: ",s.toTitleCase(d.role.replace(/_/g," "))]})]})})]}),e.jsx("span",{className:"truncate text-xs text-muted-foreground",children:A})]})})}),u?e.jsx(we,{open:j,onOpenChange:i,onSubmit:R,isCreating:P}):e.jsx(s.CreateDashboardDialog,{open:j,onOpenChange:i,onSubmit:J,isCreating:H})]})})}exports.ResourceManagementPanel=Ce;
|