react-semaphor 0.1.294 → 0.1.296
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/{braces-DfDQiR3J.js → braces-BNXseceK.js} +1 -1
- package/dist/chunks/{braces-DR-GdaLC.js → braces-DVrX_3Q_.js} +1 -1
- package/dist/chunks/dashboard-controls-CKKZcVA5.js +2219 -0
- package/dist/chunks/dashboard-controls-DS2xJxHU.js +47 -0
- package/dist/chunks/dashboard-filter-controls-button-nqfmscB7.js +11 -0
- package/dist/chunks/{dashboard-filter-controls-button-DxgGUl00.js → dashboard-filter-controls-button-xPaIlNHP.js} +501 -495
- package/dist/chunks/{dashboard-json-BvTeHePu.js → dashboard-json-cuj9vYY9.js} +1 -1
- package/dist/chunks/{dashboard-json-DQW8TN0I.js → dashboard-json-ovQyHWw6.js} +1 -1
- package/dist/chunks/{dashboard-summary-settings-dialog-BsmKiGud.js → dashboard-summary-settings-dialog-BUg3Qyhh.js} +1 -1
- package/dist/chunks/{dashboard-summary-settings-dialog-q7fx3YAK.js → dashboard-summary-settings-dialog-DF076HeJ.js} +1 -1
- package/dist/chunks/{edit-dashboard-visual-RVl9nbDZ.js → edit-dashboard-visual-32TAM00c.js} +5373 -5302
- package/dist/chunks/edit-dashboard-visual-BtiMcO-L.js +183 -0
- package/dist/chunks/{index-DerPpfv0.js → index-BDeJH9hO.js} +103982 -88259
- package/dist/chunks/index-Dbrs96G8.js +1533 -0
- package/dist/chunks/{resource-management-panel-epydPwyM.js → resource-management-panel-2qcXsKwg.js} +2 -2
- package/dist/chunks/{resource-management-panel-DnZ1rw1A.js → resource-management-panel-C4qoxy_g.js} +31 -30
- package/dist/chunks/use-create-flow-overlay-state-BMD3YRzU.js +21 -0
- package/dist/chunks/{use-create-flow-overlay-state-C5vdfXhM.js → use-create-flow-overlay-state-CHeppRNE.js} +572 -568
- package/dist/chunks/{use-visual-utils-D9Kknvjl.js → use-visual-utils-BIHLaVwh.js} +70 -68
- package/dist/chunks/use-visual-utils-dOYWf6nM.js +1 -0
- package/dist/dashboard/index.cjs +1 -1
- package/dist/dashboard/index.js +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.js +113 -112
- package/dist/style.css +1 -1
- package/dist/surfboard/index.cjs +1 -1
- package/dist/surfboard/index.js +2 -2
- package/dist/types/dashboard.d.ts +271 -0
- package/dist/types/main.d.ts +324 -0
- package/dist/types/shared.d.ts +240 -0
- package/dist/types/surfboard.d.ts +271 -0
- package/dist/types/types.d.ts +271 -0
- package/package.json +7 -1
- package/dist/chunks/dashboard-controls-C3Z9bpYE.js +0 -2014
- package/dist/chunks/dashboard-controls-DGEVXgP5.js +0 -47
- package/dist/chunks/dashboard-filter-controls-button-BIYT1ucX.js +0 -11
- package/dist/chunks/edit-dashboard-visual-ChKj-Lzr.js +0 -183
- package/dist/chunks/index-BlspGR07.js +0 -1435
- package/dist/chunks/use-create-flow-overlay-state-Bcg4EgoD.js +0 -21
- package/dist/chunks/use-visual-utils-Dw_yw9zU.js +0 -1
package/dist/chunks/{resource-management-panel-epydPwyM.js → resource-management-panel-2qcXsKwg.js}
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),t=require("./index-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),t=require("./index-Dbrs96G8.js"),h=require("react"),ne=require("./use-visual-utils-dOYWf6nM.js");/**
|
|
2
2
|
* @license lucide-react v0.453.0 - ISC
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the ISC license.
|
|
5
5
|
* See the LICENSE file in the root directory of this source tree.
|
|
6
|
-
*/const ae=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 ie(s,m={}){const{enabled:p=!0,eventType:l="mousedown"}=m,i=h.useRef(null);return h.useEffect(()=>{const x=w=>{const r=w.target;i.current&&i.current.contains(r)||r instanceof Element&&(r.closest("[data-radix-popper-content-wrapper]")||r.closest("[data-radix-select-content]")||r.closest("[data-radix-popover-content]")||r.closest("[data-radix-dropdown-menu-content]")||r.closest("[data-radix-tooltip-content]")||r.closest('[role="listbox"]')||r.closest('[role="option"]')||r.closest('[role="combobox"]'))||r instanceof Element&&r.hasAttribute("data-radix-")||s()};return p&&document.addEventListener(l,x),()=>{document.removeEventListener(l,x)}},[s,p,l]),i}function oe(){return e.jsx("div",{className:"space-y-1.5 py-1",children:[...Array(5)].map((s,m)=>e.jsxs("div",{className:"flex animate-pulse items-start gap-3 rounded-xl border border-transparent px-2.5 py-2.5",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"})]})]},m))})}const le=s=>{const m=t.useDashboardStore(i=>i.isVisualEditing),p=t.useDashboardStore(i=>i.selectedFrameId),l=t.useEditorStore(i=>i.frame);return!!(m&&p&&(l==null?void 0:l.visualId)===s)};function de({visual:s,isDeleting:m,isDuplicating:p,onAddVisual:l,onOpenVisual:i,onEditDetails:x,onDeleteClick:w,onDuplicateVisual:r,onShareVisual:N,formatDate:b}){var O,T,U,P;const{selectVisual:f}=t.useManagementActions(),d=t.useIsVisualSelected(s.id),u=le(s.id),A=t.useDashboardStore(a=>a.isVisualEditing),{isConsoleMode:R}=t.useDashboardPreferences(),j=h.useRef(null),[S,v]=h.useState(!1),[E,L]=h.useState(!1);h.useEffect(()=>{p?(v(!0),L(!0)):E&&(v(!1),L(!1))},[p,E]),h.useEffect(()=>{u&&j.current&&j.current.scrollIntoView({behavior:"smooth",block:"center"})},[u]);const C=()=>{f(s),i==null||i(s)},y=a=>{a.currentTarget===a.target&&(a.key==="Enter"||a.key===" ")&&(a.preventDefault(),C())};return e.jsxs("div",{ref:j,className:t.cn("group flex cursor-pointer items-start gap-1 rounded-[5px] px-2 py-1.5 transition-colors hover:bg-muted/50 focus-within:bg-muted/50",u?"bg-muted ring-1 ring-inset ring-foreground/20":d&&"bg-muted"),onClick:C,children:[e.jsxs("div",{role:"button",tabIndex:0,className:"min-w-0 flex-1 cursor-pointer focus-visible:outline-none",onKeyDown:y,children:[e.jsx("p",{className:"truncate text-[13px] font-medium leading-5 text-foreground",title:s.title||"Untitled Visual",children:s.title||"Untitled Visual"}),e.jsx("p",{className:"truncate text-[11px] leading-4 text-muted-foreground",title:s.description||"No description",children:(O=s.description)!=null&&O.trim()?s.description:"No description"})]}),e.jsx("div",{className:t.cn("flex shrink-0 items-center transition-opacity",d||u||S?"pointer-events-auto opacity-100":"pointer-events-none opacity-0 group-hover:pointer-events-auto group-hover:opacity-100 group-focus-within:pointer-events-auto group-focus-within:opacity-100"),onClick:a=>a.stopPropagation(),children:e.jsxs("div",{className:"inline-flex h-7 items-stretch overflow-hidden rounded-[5px] border border-border/60 bg-background",children:[e.jsxs(t.Button,{size:"xs",variant:"ghost",className:"h-full rounded-none border-0 shadow-none hover:bg-accent/50",disabled:A,onClick:a=>{a.stopPropagation(),l(s)},"aria-label":`Add ${s.title||"visual"}`,children:[e.jsx(t.Plus,{className:"h-3.5 w-3.5"}),"Add"]}),e.jsxs(t.DropdownMenu,{modal:!1,open:S,onOpenChange:v,children:[e.jsx(t.DropdownMenuTrigger,{asChild:!0,children:e.jsx(t.Button,{size:"xs",variant:"ghost",className:"h-full w-7 rounded-none border-0 border-l border-border/60 px-0 shadow-none hover:bg-accent/50","aria-label":"Open visual actions",children:e.jsx(t.EllipsisVertical,{className:"h-3.5 w-3.5"})})}),e.jsxs(t.DropdownMenuContent,{align:"end",className:"z-[51] w-44 rounded-[6px] border border-border/60 p-1 shadow-sm",children:[e.jsxs(t.DropdownMenuItem,{onClick:a=>{a.stopPropagation(),l(s)},disabled:A,children:[e.jsx(t.Plus,{className:"h-3.5 w-3.5"}),"Add"]}),e.jsxs(t.DropdownMenuItem,{onClick:a=>{a.stopPropagation(),i==null||i(s)},children:[e.jsx(ae,{className:"h-3.5 w-3.5"}),"Open"]}),e.jsxs(t.DropdownMenuItem,{onClick:a=>{a.preventDefault(),a.stopPropagation(),r(s.id)},disabled:p,children:[p?e.jsx(t.LoaderCircle,{className:"h-3.5 w-3.5 animate-spin"}):e.jsx(t.Copy,{className:"h-3.5 w-3.5"}),p?"Duplicating…":"Duplicate"]}),s.ownership.isOwner&&e.jsxs(e.Fragment,{children:[e.jsxs(t.DropdownMenuItem,{onClick:a=>{a.stopPropagation(),x==null||x(s)},children:[e.jsx(t.PenLine,{className:"h-3.5 w-3.5"}),"Edit details"]}),e.jsxs(t.DropdownMenuItem,{onClick:a=>{a.stopPropagation(),N(s)},children:[e.jsx(t.Users,{className:"h-3.5 w-3.5"}),"Share"]}),e.jsx(t.DropdownMenuSeparator,{}),e.jsxs(t.DropdownMenuItem,{onClick:a=>{a.stopPropagation(),w(s)},className:"text-destructive focus:bg-destructive/10 focus:text-destructive",disabled:m,children:[e.jsx(t.Trash2,{className:"h-3.5 w-3.5"}),m?"Deleting…":"Delete"]})]}),e.jsx(t.DropdownMenuSeparator,{}),e.jsxs("div",{className:"space-y-1 px-2 py-1.5 text-[11px] text-muted-foreground",children:[(((T=s.ownership.createdBy)==null?void 0:T.type)==="tenant"||((U=s.ownership.createdBy)==null?void 0:U.type)==="organization"&&R)&&e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(t.User,{className:"h-3 w-3"}),e.jsx("span",{children:((P=s.ownership.createdBy)==null?void 0:P.name)||"Unknown"})]}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(t.Calendar,{className:"h-3 w-3"}),e.jsx("span",{children:b(s.lastModified)})]})]})]})]})]})})]})}function ce({searchQuery:s}){const[m,p]=h.useState(!1),[l,i]=h.useState(null),[x,w]=h.useState(!1),[r,N]=h.useState(null),[b,f]=h.useState(null),[d,u]=h.useState(null),{handleEditLibraryVisual:A,handleAddLibraryVisual:R}=ne.useVisualUtils(),{resources:j,isLoading:S,isError:v,updateResource:E,deleteResource:L,duplicateResource:C,isDeleting:y}=t.useVisualManagement(()=>{w(!1),N(null)}),O=j.filter(o=>{var M,c;return((M=o==null?void 0:o.title)==null?void 0:M.toLowerCase().includes(s.toLowerCase()))||((c=o==null?void 0:o.description)==null?void 0:c.toLowerCase().includes(s.toLowerCase()))}),T=o=>new Date(o).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"}),U=o=>{N(o),w(!0)},P=()=>{r&&L(r.id)},{startUpdating:a,stopUpdating:_,isUpdating:F}=t.useResourceUpdateState(),V=(o,M,c)=>{var Q;const B=Object.fromEntries(Object.entries(M).filter(([,I])=>I!==void 0));if(Object.keys(B).length===0){(Q=c==null?void 0:c.onSuccess)==null||Q.call(c);return}const D=Object.keys(B),H=D.length===1?D[0]:void 0;a(o,H),E({resourceId:o,data:B},{onSuccess:()=>{var I;_(o,H),(I=c==null?void 0:c.onSuccess)==null||I.call(c)},onError:()=>{var I;_(o,H),(I=c==null?void 0:c.onError)==null||I.call(c)}})},G=o=>{f(o),C(o,{onSettled:()=>f(null)})},z=o=>{A(o)},W=o=>{R(o)},X=o=>{i(o),p(!0)},Y=o=>{u(o)},$=()=>{u(null)},J=({title:o,description:M})=>{if(!d)return;const c={};o!==d.title&&(c.title=o),(d.description||"")!==M&&(c.description=M),V(d.id,c,{onSuccess:()=>{u(null)}})};return S?e.jsx(oe,{}):v?e.jsx(t.ScrollArea,{className:"w-full flex-1 pr-2",children:e.jsxs("div",{className:"flex flex-col items-center gap-1.5 px-4 py-10 text-center",children:[e.jsx("p",{className:"text-[12px] text-destructive",children:"Failed to load visuals"}),e.jsx(t.Button,{variant:"outline",size:"xs",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-0.5 overflow-y-auto",children:O.length===0?e.jsxs("div",{className:"flex flex-col items-center gap-1.5 px-4 py-10 text-center",children:[e.jsx(t.Grid3x3,{className:"h-5 w-5 text-muted-foreground/60"}),e.jsx("h3",{className:"text-[13px] font-medium text-foreground",children:s?"No visuals found":"No visuals yet"}),e.jsx("p",{className:"text-[12px] text-muted-foreground",children:s?"Try adjusting your search.":'Click "New" above to add your first visual.'})]}):O.map(o=>e.jsx(de,{visual:o,onAddVisual:W,onOpenVisual:z,onEditDetails:Y,onDeleteClick:U,onDuplicateVisual:G,onShareVisual:X,isDeleting:y,isDuplicating:b===o.id,formatDate:T},o.id))}),m&&l&&e.jsx(t.ShareDialog,{resource:l,resourceType:t.ResourceType.VISUAL,onClose:()=>{p(!1),i(null)}}),d&&e.jsx(t.ResourceEditDialog,{open:!!d,resourceLabel:"Visual",initialTitle:d.title||"",initialDescription:d.description||"",onClose:$,onSave:J,isSaving:F(d.id)}),e.jsx(t.AlertDialog,{open:x,onOpenChange:o=>{!o&&y||(w(o),o||N(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 "',r==null?void 0:r.title,'"? This action cannot be undone.']})]}),e.jsxs(t.AlertDialogFooter,{children:[e.jsx(t.AlertDialogCancel,{disabled:y,children:"Cancel"}),e.jsxs(t.AlertDialogAction,{onClick:o=>{o.preventDefault(),o.stopPropagation(),P()},disabled:y,children:[y?e.jsx(t.LoaderCircle,{className:"h-3.5 w-3.5 animate-spin"}):e.jsx(t.Trash2,{className:"h-3.5 w-3.5"}),y?"Deleting…":"Delete"]})]})]})})]})}function ue({dashboard:s,isDeleting:m,isDuplicating:p,onLoadDashboard:l,onEditDetails:i,onDeleteClick:x,onDuplicateDashboard:w,onShareDashboard:r,formatDate:N,onDashboardItemClick:b}){var E,L;const{selectDashboard:f}=t.useManagementActions(),d=t.useIsDashboardSelected(s.id),{userContext:u,isLoading:A}=t.useCurrentUserInfo(),R=((E=u==null?void 0:u.permissions)==null?void 0:E.canEdit)??!1,j=A||!R,S=()=>{f(s),l(s.id),b==null||b(s.id)},v=C=>{C.currentTarget===C.target&&(C.key==="Enter"||C.key===" ")&&(C.preventDefault(),S())};return e.jsxs("div",{className:t.cn("group flex cursor-pointer items-start gap-1 rounded-[5px] px-2 py-1.5 transition-colors hover:bg-muted/50 focus-within:bg-muted/50",d&&"bg-muted"),onClick:S,children:[e.jsxs("div",{role:"button",tabIndex:0,className:"min-w-0 flex-1 cursor-pointer focus-visible:outline-none",onKeyDown:v,children:[e.jsx("p",{className:"truncate text-[13px] font-medium leading-5 text-foreground",title:s.title||"Untitled Dashboard",children:s.title||"Untitled Dashboard"}),e.jsx("p",{className:"truncate text-[11px] leading-4 text-muted-foreground",title:s.description||"No description",children:(L=s.description)!=null&&L.trim()?s.description:"No description"})]}),e.jsx("div",{className:t.cn("shrink-0 transition-opacity",d?"opacity-100":"opacity-0 group-hover:opacity-100 group-focus-within:opacity-100"),children:e.jsx(t.DashboardActionsMenu,{dashboard:s,isDeleting:m,isDuplicating:p,shouldHideActions:j,onEditDetails:i,onDeleteClick:x,onDuplicateDashboard:w,onShareDashboard:r,formatDate:N})})]})}function he({onRetry:s}){return e.jsx(t.ScrollArea,{className:"w-full flex-1 pr-2",children:e.jsxs("div",{className:"rounded-xl border border-dashed border-border/60 bg-muted/20 px-4 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 xe(s){var ee;const{searchQuery:m,onLoadDashboard:p,onEditDashboard:l,onDashboardItemClick:i}=s,[x,w]=h.useState(!1),[r,N]=h.useState(null),[b,f]=h.useState(!1),[d,u]=h.useState(null),[A,R]=h.useState(null),[j,S]=h.useState(null),v=t.useManagementStore(n=>n.lastSelectedDashboard),E=t.useManagementStore(n=>n.selectedDashboard),L=t.useManagementStore(n=>n.actions.selectDashboard),C=t.useManagementStore(n=>n.actions.clearSelectedDashboard),{tokenProps:y,id:O}=t.useSemaphorContext(),{resources:T,isLoading:U,isError:P,updateResource:a,deleteResource:_,duplicateResource:F,isDeleting:V}=t.useDashboardManagement(()=>{f(!1);const n=d==null?void 0:d.id;u(null),(E==null?void 0:E.id)===n&&(!(y!=null&&y.dashboard_id)&&!O?C():v&&v.id!==n&&L(v))}),{userContext:G}=t.useCurrentUserInfo(),z=((ee=G==null?void 0:G.permissions)==null?void 0:ee.canCreateDashboard)??!1,W=T.filter(n=>{var K,g;return((K=n==null?void 0:n.title)==null?void 0:K.toLowerCase().includes(m.toLowerCase()))||((g=n==null?void 0:n.description)==null?void 0:g.toLowerCase().includes(m.toLowerCase()))}),X=n=>new Date(n).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"}),Y=n=>{p==null||p(n)},$=n=>{u(n),f(!0)},J=()=>{d&&_(d.id)},o=n=>{R(n),F(n,{onSettled:()=>R(null)})},{startUpdating:M,stopUpdating:c,isUpdating:B}=t.useResourceUpdateState(),D=(n,K,g)=>{var se;const Z=Object.fromEntries(Object.entries(K).filter(([,q])=>q!==void 0));if(Object.keys(Z).length===0){(se=g==null?void 0:g.onSuccess)==null||se.call(g);return}const te=Object.keys(Z),k=te.length===1?te[0]:void 0;M(n,k),a({resourceId:n,data:Z},{onSuccess:()=>{var q;c(n,k),(q=g==null?void 0:g.onSuccess)==null||q.call(g)},onError:()=>{var q;c(n,k),(q=g==null?void 0:g.onError)==null||q.call(g)}})},H=n=>{N(n),w(!0)},Q=n=>{l==null||l(n.id),S(n)},I=()=>{S(null)},re=({title:n,description:K})=>{if(!j)return;const g={};n!==j.title&&(g.title=n),(j.description||"")!==K&&(g.description=K),D(j.id,g,{onSuccess:()=>{S(null)}})};return U?e.jsx(oe,{}):P?e.jsx(he,{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-0.5 overflow-y-auto",children:W.length===0?e.jsxs("div",{className:"flex flex-col items-center gap-1.5 px-4 py-10 text-center",children:[e.jsx(t.ChartColumn,{className:"h-5 w-5 text-muted-foreground/60"}),e.jsx("h3",{className:"text-[13px] font-medium text-foreground",children:m?"No dashboards found":"No dashboards yet"}),e.jsx("p",{className:"text-[12px] text-muted-foreground",children:m?"Try adjusting your search.":z?'Click "New" above to add your first dashboard.':"No dashboards have been shared with you yet."})]}):W.map(n=>e.jsx(ue,{dashboard:n,isDeleting:V,isDuplicating:A===n.id,onLoadDashboard:Y,onEditDetails:Q,onDeleteClick:$,onDuplicateDashboard:o,onShareDashboard:H,formatDate:X,onDashboardItemClick:i},n.id))}),x&&r&&e.jsx(t.ShareDialog,{resource:r,resourceType:t.ResourceType.DASHBOARD,onClose:()=>{w(!1),N(null)}}),e.jsx(t.AlertDialog,{open:b,onOpenChange:n=>{!n&&V||(f(n),n||u(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 "',d==null?void 0:d.title,'"? This action cannot be undone.']})]}),e.jsxs(t.AlertDialogFooter,{children:[e.jsx(t.AlertDialogCancel,{disabled:V,children:"Cancel"}),e.jsxs(t.AlertDialogAction,{onClick:n=>{n.preventDefault(),n.stopPropagation(),J()},disabled:V,children:[V?e.jsx(t.LoaderCircle,{className:"h-3.5 w-3.5 animate-spin"}):e.jsx(t.Trash2,{className:"h-3.5 w-3.5"}),V?"Deleting…":"Delete"]})]})]})}),j&&e.jsx(t.ResourceEditDialog,{open:!!j,resourceLabel:"Dashboard",initialTitle:j.title||"",initialDescription:j.description||"",onClose:I,onSave:re,isSaving:B(j.id)})]})}function pe({open:s,onOpenChange:m,onSubmit:p,isCreating:l}){const[i,x]=h.useState(""),[w,r]=h.useState("");h.useEffect(()=>{s||(x(""),r(""))},[s]);const N=()=>{i.trim()&&p({title:i,description:w})},b=f=>{m(f)};return e.jsx(t.Dialog,{open:s,onOpenChange:b,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:i,onChange:f=>x(f.target.value),disabled:l,onKeyDown:f=>{f.key==="Enter"&&!f.shiftKey&&(f.preventDefault(),N())}})]}),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:w,onChange:f=>r(f.target.value),disabled:l})]})]}),e.jsxs(t.DialogFooter,{children:[e.jsx(t.Button,{variant:"outline",onClick:()=>b(!1),disabled:l,children:"Cancel"}),e.jsx(t.Button,{onClick:N,disabled:!i.trim()||l,children:l?e.jsxs(e.Fragment,{children:[e.jsx(t.LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin"}),"Creating..."]}):"Create Visual"})]})]})})}function me({isOpen:s,onClose:m,className:p,onDashboardItemClick:l,variant:i="inline"}){var c,B;const x=t.useDashboardStore(D=>D.isDashboardEditing),[w,r]=h.useState(!1),[N,b]=h.useState(""),[f,d]=h.useState(!1),{currentUser:u,userContext:A}=t.useCurrentUserInfo(),R=((c=A==null?void 0:A.permissions)==null?void 0:c.canCreateDashboard)??!1,{onCreateSuccess:j}=t.useDashboardCreation({onDashboardSelect:l}),{selectVisual:S}=t.useManagementActions(),{handleEditLibraryVisual:v}=ne.useVisualUtils(),{createResource:E,isCreating:L,refetch:C}=t.useDashboardManagement(),{createResource:y,isCreating:O}=t.useVisualManagement(void 0,D=>{r(!1),D&&(S(D),v(D))}),T=i==="overlay",U=x?"New Visual":"New",P=x?"New Visual":"New Dashboard",a=x?"Search visuals...":"Search dashboards...",_=x?"Collapse visuals panel":"Collapse dashboard panel",F=((u==null?void 0:u.name)??"").trim(),V=((u==null?void 0:u.email)??"").trim(),z=F&&F.toLowerCase()!=="undefined"?F:V||"Current user",W=((B=z.charAt(0))==null?void 0:B.toUpperCase())||"?",X=V&&V.toLowerCase()!=="undefined"?V:"",Y=ie(m,{enabled:s&&T}),$=t.cn("flex h-full flex-col border-r border-border/60 bg-background",T?t.cn("absolute inset-y-0 left-0 z-[51] w-60 overflow-hidden 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",p),J=D=>{},o=D=>{console.log("Editing dashboard:",D)},M=D=>{E(D,{onSuccess:H=>{r(!1),j(H,C)}})};return e.jsx(e.Fragment,{children:(!T||s)&&e.jsxs("div",{ref:Y,className:$,children:[e.jsx("div",{className:"border-b border-border/60 bg-background",children:f?e.jsxs("div",{className:"flex h-11 items-center gap-1 px-3",children:[e.jsx(t.Search,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground"}),e.jsx("input",{autoFocus:!0,value:N,onChange:D=>b(D.target.value),onKeyDown:D=>{D.key==="Escape"&&(b(""),d(!1))},placeholder:a,className:"h-7 min-w-0 flex-1 bg-transparent text-[13px] text-foreground placeholder:text-muted-foreground focus:outline-none","aria-label":a}),e.jsx(t.Button,{size:"xs",variant:"ghost",className:"w-7 shrink-0 px-0 text-muted-foreground hover:text-foreground",onClick:()=>{b(""),d(!1)},"aria-label":"Close search",children:e.jsx(t.X,{className:"h-3.5 w-3.5"})})]}):e.jsxs("div",{className:"flex h-11 items-center justify-between gap-2 px-3",children:[e.jsx("h2",{className:"whitespace-nowrap text-[13px] font-medium text-foreground",children:x?"Visuals":"Dashboards"}),e.jsxs("div",{className:"flex items-center gap-0.5",children:[e.jsx(t.Button,{size:"xs",variant:"ghost",onClick:()=>d(!0),className:"w-7 px-0 text-muted-foreground hover:text-foreground","aria-label":"Search",children:e.jsx(t.Search,{className:"h-3.5 w-3.5"})}),(x||R)&&e.jsxs(t.Button,{size:"xs",variant:"outline",onClick:()=>r(!0),"aria-label":P,children:[e.jsx(t.Plus,{className:"h-3.5 w-3.5"}),U]}),e.jsx(t.Button,{size:"xs",variant:"ghost",className:"w-7 px-0 text-muted-foreground hover:text-foreground",onClick:m,"aria-label":_,children:e.jsx(t.PanelLeft,{className:"h-3.5 w-3.5"})})]})]})}),e.jsx("div",{className:"flex flex-1 flex-col overflow-auto px-1.5 py-2",children:x?e.jsx(ce,{searchQuery:N}):e.jsx(xe,{searchQuery:N,onLoadDashboard:J,onEditDashboard:o,onDashboardItemClick:l})}),u&&e.jsx(t.TooltipProvider,{children:e.jsx("div",{className:"border-t border-border/60 px-3 py-2",children:e.jsxs(t.Tooltip,{children:[e.jsx(t.TooltipTrigger,{asChild:!0,children:e.jsxs("div",{className:"flex cursor-default items-center gap-2",children:[e.jsx("div",{className:"flex h-6 w-6 shrink-0 items-center justify-center rounded-full bg-muted text-[10px] font-medium text-muted-foreground",children:W}),e.jsx("span",{className:"truncate text-[12px] text-muted-foreground",children:z})]})}),e.jsx(t.TooltipContent,{side:"top",className:"max-w-xs",children:e.jsxs("div",{className:"space-y-0.5",children:[e.jsx("div",{className:"font-medium",children:z}),X&&e.jsx("div",{className:"text-[11px] opacity-80",children:X}),u.role&&e.jsxs("div",{className:"text-[11px] opacity-80",children:["Role: ",t.toTitleCase(u.role.replace(/_/g," "))]})]})})]})})}),x?e.jsx(pe,{open:w,onOpenChange:r,onSubmit:y,isCreating:O}):e.jsx(t.CreateDashboardDialog,{open:w,onOpenChange:r,onSubmit:M,isCreating:L})]})})}exports.ResourceManagementPanel=me;
|
|
6
|
+
*/const ae=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 ie(s,m={}){const{enabled:p=!0,eventType:l="mousedown"}=m,i=h.useRef(null);return h.useEffect(()=>{const x=w=>{const r=w.target;i.current&&i.current.contains(r)||r instanceof Element&&(r.closest("[data-radix-popper-content-wrapper]")||r.closest("[data-radix-select-content]")||r.closest("[data-radix-popover-content]")||r.closest("[data-radix-dropdown-menu-content]")||r.closest("[data-radix-tooltip-content]")||r.closest('[role="listbox"]')||r.closest('[role="option"]')||r.closest('[role="combobox"]'))||r instanceof Element&&r.hasAttribute("data-radix-")||s()};return p&&document.addEventListener(l,x),()=>{document.removeEventListener(l,x)}},[s,p,l]),i}function oe(){return e.jsx("div",{className:"space-y-1.5 py-1",children:[...Array(5)].map((s,m)=>e.jsxs("div",{className:"flex animate-pulse items-start gap-3 rounded-xl border border-transparent px-2.5 py-2.5",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"})]})]},m))})}const le=s=>{const m=t.useDashboardStore(i=>i.isVisualEditing),p=t.useDashboardStore(i=>i.selectedFrameId),l=t.useEditorStore(i=>i.frame);return!!(m&&p&&(l==null?void 0:l.visualId)===s)};function de({visual:s,isDeleting:m,isDuplicating:p,onAddVisual:l,onOpenVisual:i,onEditDetails:x,onDeleteClick:w,onDuplicateVisual:r,onShareVisual:N,formatDate:b}){var O,T,U,P;const{selectVisual:f}=t.useManagementActions(),d=t.useIsVisualSelected(s.id),u=le(s.id),A=t.useDashboardStore(a=>a.isVisualEditing),{isConsoleMode:R}=t.useDashboardPreferences(),j=h.useRef(null),[S,v]=h.useState(!1),[E,L]=h.useState(!1);h.useEffect(()=>{p?(v(!0),L(!0)):E&&(v(!1),L(!1))},[p,E]),h.useEffect(()=>{u&&j.current&&j.current.scrollIntoView({behavior:"smooth",block:"center"})},[u]);const C=()=>{f(s),i==null||i(s)},y=a=>{a.currentTarget===a.target&&(a.key==="Enter"||a.key===" ")&&(a.preventDefault(),C())};return e.jsxs("div",{ref:j,className:t.cn("group flex cursor-pointer items-start gap-1 rounded-[5px] px-2 py-1.5 transition-colors hover:bg-muted/50 focus-within:bg-muted/50",u?"bg-muted ring-1 ring-inset ring-foreground/20":d&&"bg-muted"),onClick:C,children:[e.jsxs("div",{role:"button",tabIndex:0,className:"min-w-0 flex-1 cursor-pointer focus-visible:outline-none",onKeyDown:y,children:[e.jsx("p",{className:"truncate text-[13px] font-medium leading-5 text-foreground",title:s.title||"Untitled Visual",children:s.title||"Untitled Visual"}),e.jsx("p",{className:"truncate text-[11px] leading-4 text-muted-foreground",title:s.description||"No description",children:(O=s.description)!=null&&O.trim()?s.description:"No description"})]}),e.jsx("div",{className:t.cn("flex shrink-0 items-center transition-opacity",d||u||S?"pointer-events-auto opacity-100":"pointer-events-none opacity-0 group-hover:pointer-events-auto group-hover:opacity-100 group-focus-within:pointer-events-auto group-focus-within:opacity-100"),onClick:a=>a.stopPropagation(),children:e.jsxs("div",{className:"inline-flex h-7 items-stretch overflow-hidden rounded-[5px] border border-border/60 bg-background",children:[e.jsxs(t.Button,{size:"xs",variant:"ghost",className:"h-full rounded-none border-0 shadow-none hover:bg-accent/50",disabled:A,onClick:a=>{a.stopPropagation(),l(s)},"aria-label":`Add ${s.title||"visual"}`,children:[e.jsx(t.Plus,{className:"h-3.5 w-3.5"}),"Add"]}),e.jsxs(t.DropdownMenu,{modal:!1,open:S,onOpenChange:v,children:[e.jsx(t.DropdownMenuTrigger,{asChild:!0,children:e.jsx(t.Button,{size:"xs",variant:"ghost",className:"h-full w-7 rounded-none border-0 border-l border-border/60 px-0 shadow-none hover:bg-accent/50","aria-label":"Open visual actions",children:e.jsx(t.EllipsisVertical,{className:"h-3.5 w-3.5"})})}),e.jsxs(t.DropdownMenuContent,{align:"end",className:"z-[51] w-44 rounded-[6px] border border-border/60 p-1 shadow-sm",children:[e.jsxs(t.DropdownMenuItem,{onClick:a=>{a.stopPropagation(),l(s)},disabled:A,children:[e.jsx(t.Plus,{className:"h-3.5 w-3.5"}),"Add"]}),e.jsxs(t.DropdownMenuItem,{onClick:a=>{a.stopPropagation(),i==null||i(s)},children:[e.jsx(ae,{className:"h-3.5 w-3.5"}),"Open"]}),e.jsxs(t.DropdownMenuItem,{onClick:a=>{a.preventDefault(),a.stopPropagation(),r(s.id)},disabled:p,children:[p?e.jsx(t.LoaderCircle,{className:"h-3.5 w-3.5 animate-spin"}):e.jsx(t.Copy,{className:"h-3.5 w-3.5"}),p?"Duplicating…":"Duplicate"]}),s.ownership.isOwner&&e.jsxs(e.Fragment,{children:[e.jsxs(t.DropdownMenuItem,{onClick:a=>{a.stopPropagation(),x==null||x(s)},children:[e.jsx(t.PenLine,{className:"h-3.5 w-3.5"}),"Edit details"]}),e.jsxs(t.DropdownMenuItem,{onClick:a=>{a.stopPropagation(),N(s)},children:[e.jsx(t.Users,{className:"h-3.5 w-3.5"}),"Share"]}),e.jsx(t.DropdownMenuSeparator,{}),e.jsxs(t.DropdownMenuItem,{onClick:a=>{a.stopPropagation(),w(s)},className:"text-destructive focus:bg-destructive/10 focus:text-destructive",disabled:m,children:[e.jsx(t.Trash2,{className:"h-3.5 w-3.5"}),m?"Deleting…":"Delete"]})]}),e.jsx(t.DropdownMenuSeparator,{}),e.jsxs("div",{className:"space-y-1 px-2 py-1.5 text-[11px] text-muted-foreground",children:[(((T=s.ownership.createdBy)==null?void 0:T.type)==="tenant"||((U=s.ownership.createdBy)==null?void 0:U.type)==="organization"&&R)&&e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(t.User,{className:"h-3 w-3"}),e.jsx("span",{children:((P=s.ownership.createdBy)==null?void 0:P.name)||"Unknown"})]}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(t.Calendar,{className:"h-3 w-3"}),e.jsx("span",{children:b(s.lastModified)})]})]})]})]})]})})]})}function ce({searchQuery:s}){const[m,p]=h.useState(!1),[l,i]=h.useState(null),[x,w]=h.useState(!1),[r,N]=h.useState(null),[b,f]=h.useState(null),[d,u]=h.useState(null),{handleEditLibraryVisual:A,handleAddLibraryVisual:R}=ne.useVisualUtils(),{resources:j,isLoading:S,isError:v,updateResource:E,deleteResource:L,duplicateResource:C,isDeleting:y}=t.useVisualManagement(()=>{w(!1),N(null)}),O=j.filter(o=>{var M,c;return((M=o==null?void 0:o.title)==null?void 0:M.toLowerCase().includes(s.toLowerCase()))||((c=o==null?void 0:o.description)==null?void 0:c.toLowerCase().includes(s.toLowerCase()))}),T=o=>new Date(o).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"}),U=o=>{N(o),w(!0)},P=()=>{r&&L(r.id)},{startUpdating:a,stopUpdating:_,isUpdating:F}=t.useResourceUpdateState(),V=(o,M,c)=>{var Q;const B=Object.fromEntries(Object.entries(M).filter(([,I])=>I!==void 0));if(Object.keys(B).length===0){(Q=c==null?void 0:c.onSuccess)==null||Q.call(c);return}const D=Object.keys(B),H=D.length===1?D[0]:void 0;a(o,H),E({resourceId:o,data:B},{onSuccess:()=>{var I;_(o,H),(I=c==null?void 0:c.onSuccess)==null||I.call(c)},onError:()=>{var I;_(o,H),(I=c==null?void 0:c.onError)==null||I.call(c)}})},G=o=>{f(o),C(o,{onSettled:()=>f(null)})},z=o=>{A(o)},W=o=>{R(o)},X=o=>{i(o),p(!0)},Y=o=>{u(o)},$=()=>{u(null)},J=({title:o,description:M})=>{if(!d)return;const c={};o!==d.title&&(c.title=o),(d.description||"")!==M&&(c.description=M),V(d.id,c,{onSuccess:()=>{u(null)}})};return S?e.jsx(oe,{}):v?e.jsx(t.ScrollArea,{className:"w-full flex-1 pr-2",children:e.jsxs("div",{className:"flex flex-col items-center gap-1.5 px-4 py-10 text-center",children:[e.jsx("p",{className:"text-[12px] text-destructive",children:"Failed to load visuals"}),e.jsx(t.Button,{variant:"outline",size:"xs",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-0.5 overflow-y-auto",children:O.length===0?e.jsxs("div",{className:"flex flex-col items-center gap-1.5 px-4 py-10 text-center",children:[e.jsx(t.Grid3x3,{className:"h-5 w-5 text-muted-foreground/60"}),e.jsx("h3",{className:"text-[13px] font-medium text-foreground",children:s?"No visuals found":"No visuals yet"}),e.jsx("p",{className:"text-[12px] text-muted-foreground",children:s?"Try adjusting your search.":'Click "New" above to add your first visual.'})]}):O.map(o=>e.jsx(de,{visual:o,onAddVisual:W,onOpenVisual:z,onEditDetails:Y,onDeleteClick:U,onDuplicateVisual:G,onShareVisual:X,isDeleting:y,isDuplicating:b===o.id,formatDate:T},o.id))}),m&&l&&e.jsx(t.ShareDialog,{resource:l,resourceType:t.ResourceType.VISUAL,onClose:()=>{p(!1),i(null)}}),d&&e.jsx(t.ResourceEditDialog,{open:!!d,resourceLabel:"Visual",initialTitle:d.title||"",initialDescription:d.description||"",onClose:$,onSave:J,isSaving:F(d.id)}),e.jsx(t.AlertDialog,{open:x,onOpenChange:o=>{!o&&y||(w(o),o||N(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 "',r==null?void 0:r.title,'"? This action cannot be undone.']})]}),e.jsxs(t.AlertDialogFooter,{children:[e.jsx(t.AlertDialogCancel,{disabled:y,children:"Cancel"}),e.jsxs(t.AlertDialogAction,{onClick:o=>{o.preventDefault(),o.stopPropagation(),P()},disabled:y,children:[y?e.jsx(t.LoaderCircle,{className:"h-3.5 w-3.5 animate-spin"}):e.jsx(t.Trash2,{className:"h-3.5 w-3.5"}),y?"Deleting…":"Delete"]})]})]})})]})}function ue({dashboard:s,isDeleting:m,isDuplicating:p,onLoadDashboard:l,onEditDetails:i,onDeleteClick:x,onDuplicateDashboard:w,onShareDashboard:r,formatDate:N,onDashboardItemClick:b}){var E,L;const{selectDashboard:f}=t.useManagementActions(),d=t.useIsDashboardSelected(s.id),{userContext:u,isLoading:A}=t.useCurrentUserInfo(),R=((E=u==null?void 0:u.permissions)==null?void 0:E.canEdit)??!1,j=A||!R,S=()=>{f(s),l(s.id),b==null||b(s.id)},v=C=>{C.currentTarget===C.target&&(C.key==="Enter"||C.key===" ")&&(C.preventDefault(),S())};return e.jsxs("div",{className:t.cn("group flex cursor-pointer items-start gap-1 rounded-[5px] px-2 py-1.5 transition-colors hover:bg-muted/50 focus-within:bg-muted/50",d&&"bg-muted"),onClick:S,children:[e.jsxs("div",{role:"button",tabIndex:0,className:"min-w-0 flex-1 cursor-pointer focus-visible:outline-none",onKeyDown:v,children:[e.jsx("p",{className:"truncate text-[13px] font-medium leading-5 text-foreground",title:s.title||"Untitled Dashboard",children:s.title||"Untitled Dashboard"}),e.jsx("p",{className:"truncate text-[11px] leading-4 text-muted-foreground",title:s.description||"No description",children:(L=s.description)!=null&&L.trim()?s.description:"No description"})]}),e.jsx("div",{className:t.cn("shrink-0 transition-opacity",d?"opacity-100":"opacity-0 group-hover:opacity-100 group-focus-within:opacity-100"),children:e.jsx(t.DashboardActionsMenu,{dashboard:s,isDeleting:m,isDuplicating:p,shouldHideActions:j,onEditDetails:i,onDeleteClick:x,onDuplicateDashboard:w,onShareDashboard:r,formatDate:N})})]})}function he({onRetry:s}){return e.jsx(t.ScrollArea,{className:"w-full flex-1 pr-2",children:e.jsxs("div",{className:"rounded-xl border border-dashed border-border/60 bg-muted/20 px-4 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 xe(s){var ee;const{searchQuery:m,onLoadDashboard:p,onEditDashboard:l,onDashboardItemClick:i}=s,[x,w]=h.useState(!1),[r,N]=h.useState(null),[b,f]=h.useState(!1),[d,u]=h.useState(null),[A,R]=h.useState(null),[j,S]=h.useState(null),v=t.useManagementStore(n=>n.lastSelectedDashboard),E=t.useManagementStore(n=>n.selectedDashboard),L=t.useManagementStore(n=>n.actions.selectDashboard),C=t.useManagementStore(n=>n.actions.clearSelectedDashboard),{tokenProps:y,id:O}=t.useSemaphorContext(),{resources:T,isLoading:U,isError:P,updateResource:a,deleteResource:_,duplicateResource:F,isDeleting:V}=t.useDashboardManagement(()=>{f(!1);const n=d==null?void 0:d.id;u(null),(E==null?void 0:E.id)===n&&(!(y!=null&&y.dashboard_id)&&!O?C():v&&v.id!==n&&L(v))}),{userContext:G}=t.useCurrentUserInfo(),z=((ee=G==null?void 0:G.permissions)==null?void 0:ee.canCreateDashboard)??!1,W=T.filter(n=>{var K,g;return((K=n==null?void 0:n.title)==null?void 0:K.toLowerCase().includes(m.toLowerCase()))||((g=n==null?void 0:n.description)==null?void 0:g.toLowerCase().includes(m.toLowerCase()))}),X=n=>new Date(n).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"}),Y=n=>{p==null||p(n)},$=n=>{u(n),f(!0)},J=()=>{d&&_(d.id)},o=n=>{R(n),F(n,{onSettled:()=>R(null)})},{startUpdating:M,stopUpdating:c,isUpdating:B}=t.useResourceUpdateState(),D=(n,K,g)=>{var se;const Z=Object.fromEntries(Object.entries(K).filter(([,q])=>q!==void 0));if(Object.keys(Z).length===0){(se=g==null?void 0:g.onSuccess)==null||se.call(g);return}const te=Object.keys(Z),k=te.length===1?te[0]:void 0;M(n,k),a({resourceId:n,data:Z},{onSuccess:()=>{var q;c(n,k),(q=g==null?void 0:g.onSuccess)==null||q.call(g)},onError:()=>{var q;c(n,k),(q=g==null?void 0:g.onError)==null||q.call(g)}})},H=n=>{N(n),w(!0)},Q=n=>{l==null||l(n.id),S(n)},I=()=>{S(null)},re=({title:n,description:K})=>{if(!j)return;const g={};n!==j.title&&(g.title=n),(j.description||"")!==K&&(g.description=K),D(j.id,g,{onSuccess:()=>{S(null)}})};return U?e.jsx(oe,{}):P?e.jsx(he,{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-0.5 overflow-y-auto",children:W.length===0?e.jsxs("div",{className:"flex flex-col items-center gap-1.5 px-4 py-10 text-center",children:[e.jsx(t.ChartColumn,{className:"h-5 w-5 text-muted-foreground/60"}),e.jsx("h3",{className:"text-[13px] font-medium text-foreground",children:m?"No dashboards found":"No dashboards yet"}),e.jsx("p",{className:"text-[12px] text-muted-foreground",children:m?"Try adjusting your search.":z?'Click "New" above to add your first dashboard.':"No dashboards have been shared with you yet."})]}):W.map(n=>e.jsx(ue,{dashboard:n,isDeleting:V,isDuplicating:A===n.id,onLoadDashboard:Y,onEditDetails:Q,onDeleteClick:$,onDuplicateDashboard:o,onShareDashboard:H,formatDate:X,onDashboardItemClick:i},n.id))}),x&&r&&e.jsx(t.ShareDialog,{resource:r,resourceType:t.ResourceType.DASHBOARD,onClose:()=>{w(!1),N(null)}}),e.jsx(t.AlertDialog,{open:b,onOpenChange:n=>{!n&&V||(f(n),n||u(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 "',d==null?void 0:d.title,'"? This action cannot be undone.']})]}),e.jsxs(t.AlertDialogFooter,{children:[e.jsx(t.AlertDialogCancel,{disabled:V,children:"Cancel"}),e.jsxs(t.AlertDialogAction,{onClick:n=>{n.preventDefault(),n.stopPropagation(),J()},disabled:V,children:[V?e.jsx(t.LoaderCircle,{className:"h-3.5 w-3.5 animate-spin"}):e.jsx(t.Trash2,{className:"h-3.5 w-3.5"}),V?"Deleting…":"Delete"]})]})]})}),j&&e.jsx(t.ResourceEditDialog,{open:!!j,resourceLabel:"Dashboard",initialTitle:j.title||"",initialDescription:j.description||"",onClose:I,onSave:re,isSaving:B(j.id)})]})}function pe({open:s,onOpenChange:m,onSubmit:p,isCreating:l}){const[i,x]=h.useState(""),[w,r]=h.useState("");h.useEffect(()=>{s||(x(""),r(""))},[s]);const N=()=>{i.trim()&&p({title:i,description:w})},b=f=>{m(f)};return e.jsx(t.Dialog,{open:s,onOpenChange:b,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:i,onChange:f=>x(f.target.value),disabled:l,onKeyDown:f=>{f.key==="Enter"&&!f.shiftKey&&(f.preventDefault(),N())}})]}),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:w,onChange:f=>r(f.target.value),disabled:l})]})]}),e.jsxs(t.DialogFooter,{children:[e.jsx(t.Button,{variant:"outline",onClick:()=>b(!1),disabled:l,children:"Cancel"}),e.jsx(t.Button,{onClick:N,disabled:!i.trim()||l,children:l?e.jsxs(e.Fragment,{children:[e.jsx(t.LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin"}),"Creating..."]}):"Create Visual"})]})]})})}function me({isOpen:s,onClose:m,className:p,onDashboardItemClick:l,variant:i="inline"}){var c,B;const x=t.useDashboardStore(D=>D.isDashboardEditing),[w,r]=h.useState(!1),[N,b]=h.useState(""),[f,d]=h.useState(!1),{currentUser:u,userContext:A}=t.useCurrentUserInfo(),R=((c=A==null?void 0:A.permissions)==null?void 0:c.canCreateDashboard)??!1,{onCreateSuccess:j}=t.useDashboardCreation({onDashboardSelect:l}),{selectVisual:S}=t.useManagementActions(),{handleEditLibraryVisual:v}=ne.useVisualUtils(),{createResource:E,isCreating:L,refetch:C}=t.useDashboardManagement(),{createResource:y,isCreating:O}=t.useVisualManagement(void 0,D=>{r(!1),D&&(S(D),v(D))}),T=i==="overlay",U=x?"New Visual":"New",P=x?"New Visual":"New Dashboard",a=x?"Search visuals...":"Search dashboards...",_=x?"Collapse visuals panel":"Collapse dashboard panel",F=((u==null?void 0:u.name)??"").trim(),V=((u==null?void 0:u.email)??"").trim(),z=F&&F.toLowerCase()!=="undefined"?F:V||"Current user",W=((B=z.charAt(0))==null?void 0:B.toUpperCase())||"?",X=V&&V.toLowerCase()!=="undefined"?V:"",Y=ie(m,{enabled:s&&T}),$=t.cn("flex h-full flex-col border-r border-border/60 bg-background",T?t.cn("absolute inset-y-0 left-0 z-[51] w-60 overflow-hidden 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",p),J=D=>{},o=D=>{console.log("Editing dashboard:",D)},M=D=>{E(D,{onSuccess:H=>{r(!1),j(H,C)}})};return e.jsx(e.Fragment,{children:(!T||s)&&e.jsxs("div",{ref:Y,className:$,children:[e.jsx("div",{className:"border-b border-border/60 bg-background",children:f?e.jsxs("div",{className:"flex h-10 items-center gap-1 px-3",children:[e.jsx(t.Search,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground"}),e.jsx("input",{autoFocus:!0,value:N,onChange:D=>b(D.target.value),onKeyDown:D=>{D.key==="Escape"&&(b(""),d(!1))},placeholder:a,className:"h-7 min-w-0 flex-1 bg-transparent text-[13px] text-foreground placeholder:text-muted-foreground focus:outline-none","aria-label":a}),e.jsx(t.Button,{size:"xs",variant:"ghost",className:"w-7 shrink-0 px-0 text-muted-foreground hover:text-foreground",onClick:()=>{b(""),d(!1)},"aria-label":"Close search",children:e.jsx(t.X,{className:"h-3.5 w-3.5"})})]}):e.jsxs("div",{className:"flex h-10 items-center justify-between gap-2 px-3",children:[e.jsx("h2",{className:"whitespace-nowrap text-[13px] font-medium text-foreground",children:x?"Visuals":"Dashboards"}),e.jsxs("div",{className:"flex items-center gap-0.5",children:[e.jsx(t.Button,{size:"xs",variant:"ghost",onClick:()=>d(!0),className:"w-7 px-0 text-muted-foreground hover:text-foreground","aria-label":"Search",children:e.jsx(t.Search,{className:"h-3.5 w-3.5"})}),(x||R)&&e.jsxs(t.Button,{size:"xs",variant:"outline",onClick:()=>r(!0),"aria-label":P,children:[e.jsx(t.Plus,{className:"h-3.5 w-3.5"}),U]}),e.jsx(t.Button,{size:"xs",variant:"ghost",className:"w-7 px-0 text-muted-foreground hover:text-foreground",onClick:m,"aria-label":_,children:e.jsx(t.PanelLeft,{className:"h-3.5 w-3.5"})})]})]})}),e.jsx("div",{className:"flex flex-1 flex-col overflow-auto px-1.5 py-2",children:x?e.jsx(ce,{searchQuery:N}):e.jsx(xe,{searchQuery:N,onLoadDashboard:J,onEditDashboard:o,onDashboardItemClick:l})}),u&&e.jsx(t.TooltipProvider,{children:e.jsx("div",{className:"border-t border-border/60 px-3 py-2",children:e.jsxs(t.Tooltip,{children:[e.jsx(t.TooltipTrigger,{asChild:!0,children:e.jsxs("div",{className:"flex cursor-default items-center gap-2",children:[e.jsx("div",{className:"flex h-6 w-6 shrink-0 items-center justify-center rounded-full bg-muted text-[10px] font-medium text-muted-foreground",children:W}),e.jsx("span",{className:"truncate text-[12px] text-muted-foreground",children:z})]})}),e.jsx(t.TooltipContent,{side:"top",className:"max-w-xs",children:e.jsxs("div",{className:"space-y-0.5",children:[e.jsx("div",{className:"font-medium",children:z}),X&&e.jsx("div",{className:"text-[11px] opacity-80",children:X}),u.role&&e.jsxs("div",{className:"text-[11px] opacity-80",children:["Role:"," ",t.toTitleCase(u.role.replace(/_/g," "))]})]})})]})})}),x?e.jsx(pe,{open:w,onOpenChange:r,onSubmit:y,isCreating:O}):e.jsx(t.CreateDashboardDialog,{open:w,onOpenChange:r,onSubmit:M,isCreating:L})]})})}exports.ResourceManagementPanel=me;
|
package/dist/chunks/{resource-management-panel-DnZ1rw1A.js → resource-management-panel-C4qoxy_g.js}
RENAMED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx as e, jsxs as n, Fragment as le } from "react/jsx-runtime";
|
|
2
|
-
import { c as je, u as ne, W as Fe, N as de,
|
|
2
|
+
import { c as je, u as ne, W as Fe, N as de, cE as ze, cF as Be, b as Q, B as I, cx as ie, cG as He, cH as Ke, cI as _e, cJ as We, cK as J, x as se, cL as Xe, cM as Ye, cN as Ge, cO as fe, cl as ce, cP as $e, cQ as Je, cR as we, cS as Ne, cT as be, cU as Qe, ao as ye, ak as Ce, cV as ve, cW as Se, cX as Ee, cY as Ve, cZ as Le, c_ as Ae, c$ as Oe, d0 as Re, d1 as Te, d2 as Ze, d3 as ue, d4 as qe, ai as te, d as ke, d5 as Ue, d6 as et, e as tt, f as nt, g as at, h as st, i as ot, L as ge, I as xe, w as rt, d7 as it, d8 as De, X as lt, d9 as dt, bV as ct, bW as ut, bX as ht, bY as pt, da as mt, db as ft } from "./index-BDeJH9hO.js";
|
|
3
3
|
import gt, { useRef as xt, useEffect as ae, useState as w } from "react";
|
|
4
|
-
import { u as Ie } from "./use-visual-utils-
|
|
4
|
+
import { u as Ie } from "./use-visual-utils-BIHLaVwh.js";
|
|
5
5
|
/**
|
|
6
6
|
* @license lucide-react v0.453.0 - ISC
|
|
7
7
|
*
|
|
@@ -208,7 +208,7 @@ function bt({
|
|
|
208
208
|
r.stopPropagation(), h == null || h(t);
|
|
209
209
|
},
|
|
210
210
|
children: [
|
|
211
|
-
/* @__PURE__ */ e(
|
|
211
|
+
/* @__PURE__ */ e(Ye, { className: "h-3.5 w-3.5" }),
|
|
212
212
|
"Edit details"
|
|
213
213
|
]
|
|
214
214
|
}
|
|
@@ -220,7 +220,7 @@ function bt({
|
|
|
220
220
|
r.stopPropagation(), b(t);
|
|
221
221
|
},
|
|
222
222
|
children: [
|
|
223
|
-
/* @__PURE__ */ e(
|
|
223
|
+
/* @__PURE__ */ e(Ge, { className: "h-3.5 w-3.5" }),
|
|
224
224
|
"Share"
|
|
225
225
|
]
|
|
226
226
|
}
|
|
@@ -323,21 +323,21 @@ function yt({ searchQuery: t }) {
|
|
|
323
323
|
}
|
|
324
324
|
}
|
|
325
325
|
);
|
|
326
|
-
},
|
|
326
|
+
}, Y = (s) => {
|
|
327
327
|
f(s), C(s, {
|
|
328
328
|
onSettled: () => f(null)
|
|
329
329
|
});
|
|
330
330
|
}, H = (s) => {
|
|
331
331
|
A(s);
|
|
332
|
-
},
|
|
332
|
+
}, G = (s) => {
|
|
333
333
|
T(s);
|
|
334
334
|
}, $ = (s) => {
|
|
335
335
|
i(s), p(!0);
|
|
336
336
|
}, Z = (s) => {
|
|
337
337
|
u(s);
|
|
338
|
-
},
|
|
338
|
+
}, q = () => {
|
|
339
339
|
u(null);
|
|
340
|
-
},
|
|
340
|
+
}, k = ({
|
|
341
341
|
title: s,
|
|
342
342
|
description: R
|
|
343
343
|
}) => {
|
|
@@ -370,11 +370,11 @@ function yt({ searchQuery: t }) {
|
|
|
370
370
|
bt,
|
|
371
371
|
{
|
|
372
372
|
visual: s,
|
|
373
|
-
onAddVisual:
|
|
373
|
+
onAddVisual: G,
|
|
374
374
|
onOpenVisual: H,
|
|
375
375
|
onEditDetails: Z,
|
|
376
376
|
onDeleteClick: j,
|
|
377
|
-
onDuplicateVisual:
|
|
377
|
+
onDuplicateVisual: Y,
|
|
378
378
|
onShareVisual: $,
|
|
379
379
|
isDeleting: v,
|
|
380
380
|
isDuplicating: y === s.id,
|
|
@@ -399,8 +399,8 @@ function yt({ searchQuery: t }) {
|
|
|
399
399
|
resourceLabel: "Visual",
|
|
400
400
|
initialTitle: d.title || "",
|
|
401
401
|
initialDescription: d.description || "",
|
|
402
|
-
onClose:
|
|
403
|
-
onSave:
|
|
402
|
+
onClose: q,
|
|
403
|
+
onSave: k,
|
|
404
404
|
isSaving: B(d.id)
|
|
405
405
|
}
|
|
406
406
|
),
|
|
@@ -503,7 +503,7 @@ function Ct({
|
|
|
503
503
|
d ? "opacity-100" : "opacity-0 group-hover:opacity-100 group-focus-within:opacity-100"
|
|
504
504
|
),
|
|
505
505
|
children: /* @__PURE__ */ e(
|
|
506
|
-
|
|
506
|
+
qe,
|
|
507
507
|
{
|
|
508
508
|
dashboard: t,
|
|
509
509
|
isDeleting: m,
|
|
@@ -540,7 +540,7 @@ function St(t) {
|
|
|
540
540
|
(a) => a.actions.selectDashboard
|
|
541
541
|
), C = te(
|
|
542
542
|
(a) => a.actions.clearSelectedDashboard
|
|
543
|
-
), { tokenProps: v, id: M } =
|
|
543
|
+
), { tokenProps: v, id: M } = ke(), {
|
|
544
544
|
resources: U,
|
|
545
545
|
isLoading: j,
|
|
546
546
|
isError: F,
|
|
@@ -552,7 +552,7 @@ function St(t) {
|
|
|
552
552
|
f(!1);
|
|
553
553
|
const a = d == null ? void 0 : d.id;
|
|
554
554
|
u(null), (V == null ? void 0 : V.id) === a && (!(v != null && v.dashboard_id) && !M ? C() : E && E.id !== a && O(E));
|
|
555
|
-
}), { userContext:
|
|
555
|
+
}), { userContext: Y } = ue(), H = ((he = Y == null ? void 0 : Y.permissions) == null ? void 0 : he.canCreateDashboard) ?? !1, G = U.filter(
|
|
556
556
|
(a) => {
|
|
557
557
|
var _, g;
|
|
558
558
|
return ((_ = a == null ? void 0 : a.title) == null ? void 0 : _.toLowerCase().includes(m.toLowerCase())) || ((g = a == null ? void 0 : a.description) == null ? void 0 : g.toLowerCase().includes(m.toLowerCase()));
|
|
@@ -563,9 +563,9 @@ function St(t) {
|
|
|
563
563
|
year: "numeric"
|
|
564
564
|
}), Z = (a) => {
|
|
565
565
|
p == null || p(a);
|
|
566
|
-
},
|
|
566
|
+
}, q = (a) => {
|
|
567
567
|
u(a), f(!0);
|
|
568
|
-
},
|
|
568
|
+
}, k = () => {
|
|
569
569
|
d && X(d.id);
|
|
570
570
|
}, s = (a) => {
|
|
571
571
|
T(a), B(a, {
|
|
@@ -621,11 +621,11 @@ function St(t) {
|
|
|
621
621
|
});
|
|
622
622
|
};
|
|
623
623
|
return j ? /* @__PURE__ */ e(Me, {}) : F ? /* @__PURE__ */ e(vt, { onRetry: () => window.location.reload() }) : /* @__PURE__ */ n("div", { className: "flex h-full flex-1 flex-col", children: [
|
|
624
|
-
/* @__PURE__ */ e("div", { className: "flex flex-1 basis-0 flex-col gap-0.5 overflow-y-auto", children:
|
|
624
|
+
/* @__PURE__ */ e("div", { className: "flex flex-1 basis-0 flex-col gap-0.5 overflow-y-auto", children: G.length === 0 ? /* @__PURE__ */ n("div", { className: "flex flex-col items-center gap-1.5 px-4 py-10 text-center", children: [
|
|
625
625
|
/* @__PURE__ */ e(et, { className: "h-5 w-5 text-muted-foreground/60" }),
|
|
626
626
|
/* @__PURE__ */ e("h3", { className: "text-[13px] font-medium text-foreground", children: m ? "No dashboards found" : "No dashboards yet" }),
|
|
627
627
|
/* @__PURE__ */ e("p", { className: "text-[12px] text-muted-foreground", children: m ? "Try adjusting your search." : H ? 'Click "New" above to add your first dashboard.' : "No dashboards have been shared with you yet." })
|
|
628
|
-
] }) :
|
|
628
|
+
] }) : G.map((a) => /* @__PURE__ */ e(
|
|
629
629
|
Ct,
|
|
630
630
|
{
|
|
631
631
|
dashboard: a,
|
|
@@ -633,7 +633,7 @@ function St(t) {
|
|
|
633
633
|
isDuplicating: A === a.id,
|
|
634
634
|
onLoadDashboard: Z,
|
|
635
635
|
onEditDetails: ee,
|
|
636
|
-
onDeleteClick:
|
|
636
|
+
onDeleteClick: q,
|
|
637
637
|
onDuplicateDashboard: s,
|
|
638
638
|
onShareDashboard: K,
|
|
639
639
|
formatDate: $,
|
|
@@ -673,7 +673,7 @@ function St(t) {
|
|
|
673
673
|
Te,
|
|
674
674
|
{
|
|
675
675
|
onClick: (a) => {
|
|
676
|
-
a.preventDefault(), a.stopPropagation(),
|
|
676
|
+
a.preventDefault(), a.stopPropagation(), k();
|
|
677
677
|
},
|
|
678
678
|
disabled: L,
|
|
679
679
|
children: [
|
|
@@ -797,16 +797,16 @@ function Rt({
|
|
|
797
797
|
(D) => {
|
|
798
798
|
o(!1), D && (S(D), E(D));
|
|
799
799
|
}
|
|
800
|
-
), U = i === "overlay", j = h ? "New Visual" : "New", F = h ? "New Visual" : "New Dashboard", r = h ? "Search visuals..." : "Search dashboards...", X = h ? "Collapse visuals panel" : "Collapse dashboard panel", B = ((u == null ? void 0 : u.name) ?? "").trim(), L = ((u == null ? void 0 : u.email) ?? "").trim(), H = B && B.toLowerCase() !== "undefined" ? B : L || "Current user",
|
|
800
|
+
), U = i === "overlay", j = h ? "New Visual" : "New", F = h ? "New Visual" : "New Dashboard", r = h ? "Search visuals..." : "Search dashboards...", X = h ? "Collapse visuals panel" : "Collapse dashboard panel", B = ((u == null ? void 0 : u.name) ?? "").trim(), L = ((u == null ? void 0 : u.email) ?? "").trim(), H = B && B.toLowerCase() !== "undefined" ? B : L || "Current user", G = ((z = H.charAt(0)) == null ? void 0 : z.toUpperCase()) || "?", $ = L && L.toLowerCase() !== "undefined" ? L : "", Z = wt(m, {
|
|
801
801
|
enabled: t && U
|
|
802
|
-
}),
|
|
802
|
+
}), q = Q(
|
|
803
803
|
"flex h-full flex-col border-r border-border/60 bg-background",
|
|
804
804
|
U ? Q(
|
|
805
805
|
"absolute inset-y-0 left-0 z-[51] w-60 overflow-hidden shadow-lg transition-transform duration-300 ease-in-out",
|
|
806
806
|
t ? "translate-x-0" : "pointer-events-none -translate-x-full"
|
|
807
807
|
) : "w-full max-w-[17rem] min-w-[11rem] overflow-hidden",
|
|
808
808
|
p
|
|
809
|
-
),
|
|
809
|
+
), k = (D) => {
|
|
810
810
|
}, s = (D) => {
|
|
811
811
|
console.log("Editing dashboard:", D);
|
|
812
812
|
}, R = (D) => {
|
|
@@ -816,8 +816,8 @@ function Rt({
|
|
|
816
816
|
}
|
|
817
817
|
});
|
|
818
818
|
};
|
|
819
|
-
return /* @__PURE__ */ e(le, { children: (!U || t) && /* @__PURE__ */ n("div", { ref: Z, className:
|
|
820
|
-
/* @__PURE__ */ e("div", { className: "border-b border-border/60 bg-background", children: f ? /* @__PURE__ */ n("div", { className: "flex h-
|
|
819
|
+
return /* @__PURE__ */ e(le, { children: (!U || t) && /* @__PURE__ */ n("div", { ref: Z, className: q, children: [
|
|
820
|
+
/* @__PURE__ */ e("div", { className: "border-b border-border/60 bg-background", children: f ? /* @__PURE__ */ n("div", { className: "flex h-10 items-center gap-1 px-3", children: [
|
|
821
821
|
/* @__PURE__ */ e(De, { className: "h-3.5 w-3.5 shrink-0 text-muted-foreground" }),
|
|
822
822
|
/* @__PURE__ */ e(
|
|
823
823
|
"input",
|
|
@@ -846,7 +846,7 @@ function Rt({
|
|
|
846
846
|
children: /* @__PURE__ */ e(lt, { className: "h-3.5 w-3.5" })
|
|
847
847
|
}
|
|
848
848
|
)
|
|
849
|
-
] }) : /* @__PURE__ */ n("div", { className: "flex h-
|
|
849
|
+
] }) : /* @__PURE__ */ n("div", { className: "flex h-10 items-center justify-between gap-2 px-3", children: [
|
|
850
850
|
/* @__PURE__ */ e("h2", { className: "whitespace-nowrap text-[13px] font-medium text-foreground", children: h ? "Visuals" : "Dashboards" }),
|
|
851
851
|
/* @__PURE__ */ n("div", { className: "flex items-center gap-0.5", children: [
|
|
852
852
|
/* @__PURE__ */ e(
|
|
@@ -890,21 +890,22 @@ function Rt({
|
|
|
890
890
|
St,
|
|
891
891
|
{
|
|
892
892
|
searchQuery: b,
|
|
893
|
-
onLoadDashboard:
|
|
893
|
+
onLoadDashboard: k,
|
|
894
894
|
onEditDashboard: s,
|
|
895
895
|
onDashboardItemClick: l
|
|
896
896
|
}
|
|
897
897
|
) }),
|
|
898
898
|
u && /* @__PURE__ */ e(ct, { children: /* @__PURE__ */ e("div", { className: "border-t border-border/60 px-3 py-2", children: /* @__PURE__ */ n(ut, { children: [
|
|
899
899
|
/* @__PURE__ */ e(ht, { asChild: !0, children: /* @__PURE__ */ n("div", { className: "flex cursor-default items-center gap-2", children: [
|
|
900
|
-
/* @__PURE__ */ e("div", { className: "flex h-6 w-6 shrink-0 items-center justify-center rounded-full bg-muted text-[10px] font-medium text-muted-foreground", children:
|
|
900
|
+
/* @__PURE__ */ e("div", { className: "flex h-6 w-6 shrink-0 items-center justify-center rounded-full bg-muted text-[10px] font-medium text-muted-foreground", children: G }),
|
|
901
901
|
/* @__PURE__ */ e("span", { className: "truncate text-[12px] text-muted-foreground", children: H })
|
|
902
902
|
] }) }),
|
|
903
903
|
/* @__PURE__ */ e(pt, { side: "top", className: "max-w-xs", children: /* @__PURE__ */ n("div", { className: "space-y-0.5", children: [
|
|
904
904
|
/* @__PURE__ */ e("div", { className: "font-medium", children: H }),
|
|
905
905
|
$ && /* @__PURE__ */ e("div", { className: "text-[11px] opacity-80", children: $ }),
|
|
906
906
|
u.role && /* @__PURE__ */ n("div", { className: "text-[11px] opacity-80", children: [
|
|
907
|
-
"Role:
|
|
907
|
+
"Role:",
|
|
908
|
+
" ",
|
|
908
909
|
mt(u.role.replace(/_/g, " "))
|
|
909
910
|
] })
|
|
910
911
|
] }) })
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";const t=require("./index-Dbrs96G8.js"),e=require("react/jsx-runtime"),v=require("react"),se=require("./use-visual-utils-dOYWf6nM.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 Se=t.createLucideIcon("CircleX",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"m9 9 6 6",key:"z0biqf"}]]);/**
|
|
7
|
+
* @license lucide-react v0.453.0 - ISC
|
|
8
|
+
*
|
|
9
|
+
* This source code is licensed under the ISC license.
|
|
10
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
11
|
+
*/const he=t.createLucideIcon("Library",[["path",{d:"m16 6 4 14",key:"ji33uf"}],["path",{d:"M12 6v14",key:"1n7gus"}],["path",{d:"M8 8v12",key:"1gg7y9"}],["path",{d:"M4 4v16",key:"6qkkli"}]]);/**
|
|
12
|
+
* @license lucide-react v0.453.0 - ISC
|
|
13
|
+
*
|
|
14
|
+
* This source code is licensed under the ISC license.
|
|
15
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
16
|
+
*/const ge=t.createLucideIcon("Link2",[["path",{d:"M9 17H7A5 5 0 0 1 7 7h2",key:"8i5ue5"}],["path",{d:"M15 7h2a5 5 0 1 1 0 10h-2",key:"1b9ql8"}],["line",{x1:"8",x2:"16",y1:"12",y2:"12",key:"1jonct"}]]);/**
|
|
17
|
+
* @license lucide-react v0.453.0 - ISC
|
|
18
|
+
*
|
|
19
|
+
* This source code is licensed under the ISC license.
|
|
20
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
21
|
+
*/const re=t.createLucideIcon("Save",[["path",{d:"M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z",key:"1c8476"}],["path",{d:"M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7",key:"1ydtos"}],["path",{d:"M7 3v4a1 1 0 0 0 1 1h7",key:"t51u73"}]]);function ae(){var f,j;const l=t.useEditorStore(b=>b.card),a=t.useEditorStore(b=>b.frame),i=v.useMemo(()=>t.findCustomVisualConfigCard(a,l),[a,l]),{manifest:d}=t.useCustomVisual(((f=i==null?void 0:i.customCardPreferences)==null?void 0:f.url)||""),x=v.useMemo(()=>{var b;return(b=d==null?void 0:d.visuals)==null?void 0:b.find(p=>{var C;return p.name===((C=i==null?void 0:i.customCardPreferences)==null?void 0:C.componentName)})},[d,(j=i==null?void 0:i.customCardPreferences)==null?void 0:j.componentName]),u=t.resolveMultiInputType(i,x),h=v.useMemo(()=>t.getCustomVisualInputCards({frame:a,configCard:i,isMultiInputVisual:u==="multiple"}),[a,i,u]),y=v.useMemo(()=>{const b=h.findIndex(p=>(p==null?void 0:p.id)===l.id);return b<0?-1:t.getSlotIndexForCard(l,b)},[h,l]);return v.useMemo(()=>!i||u!=="multiple"||y<0?l.type:t.getEffectiveCardTypeForSlot(l,y,x==null?void 0:x.slots)??l.type,[i,u,y,l,x==null?void 0:x.slots])}function Ne({type:l,isLinked:a,className:i,showLabel:d=!1,showLocal:x=!1}){const u=t.useDashboardStore(S=>S.selectedFrameId),h=t.useManagementStore(S=>S.selectedVisual),y=t.useEditorStore(S=>S.frame);let f;if(l)f=l;else if(a!==void 0)f=a?"linked":"library";else if(!!!(y!=null&&y.visualId||h!=null&&h.id)&&u)f="local";else if(h&&!u)f="library";else if(y!=null&&y.visualId&&u)f="linked";else if(h!=null&&h.id&&u)f="library";else return null;if(f==="local"&&!x)return null;const j={local:"border-slate-200/70 bg-slate-50/80 text-slate-700 shadow-sm hover:bg-slate-100/80 dark:border-slate-700 dark:bg-slate-900/70 dark:text-slate-200 dark:hover:bg-slate-800/80",linked:"border-purple-200/70 bg-gradient-to-r from-purple-50/50 to-purple-100/30 text-purple-900 shadow-sm hover:from-purple-100/60 hover:to-purple-100/50 hover:shadow-md dark:border-purple-800/50 dark:from-purple-950/40 dark:to-purple-900/30 dark:text-purple-100 dark:hover:from-purple-950/60 dark:hover:to-purple-900/50",library:"border-blue-200/70 bg-gradient-to-r from-blue-50/50 to-blue-100/30 text-blue-900 shadow-sm hover:from-blue-100/60 hover:to-blue-100/50 hover:shadow-md dark:border-blue-800/50 dark:from-blue-950/40 dark:to-blue-900/30 dark:text-blue-100 dark:hover:from-blue-950/60 dark:hover:to-blue-900/50"},b={local:"Local to this dashboard: Changes made here only affect this dashboard copy.",linked:"Linked to library: Changes made here update the library visual and all linked instances.",library:"Library visual: Share and reuse this visual across multiple dashboards."},p={local:"border-slate-200 bg-slate-50 text-slate-900 dark:border-slate-700 dark:bg-slate-900 dark:text-slate-100",linked:"border-purple-200 bg-purple-50 text-purple-900 dark:border-purple-800 dark:bg-purple-950 dark:text-purple-100",library:"border-blue-200 bg-blue-50 text-blue-900 dark:border-blue-800 dark:bg-blue-950 dark:text-blue-100"},C={local:"fill-slate-50 dark:fill-slate-900",linked:"fill-purple-50 dark:fill-purple-950",library:"fill-blue-50 dark:fill-blue-950"},w={local:e.jsx("span",{className:"h-2 w-2 rounded-full bg-current/70"}),linked:e.jsx(ge,{className:"h-3.5 w-3.5"}),library:e.jsx(he,{className:"h-3.5 w-3.5"})},k={local:"Local",linked:"Linked",library:"Library"};return e.jsx(t.TooltipProvider,{children:e.jsxs(t.Tooltip,{delayDuration:300,children:[e.jsx(t.TooltipTrigger,{asChild:!0,children:e.jsxs(t.Badge,{variant:"outline",className:t.cn("cursor-help select-none transition-all",j[f],i),children:[w[f],d&&e.jsx("span",{className:"ml-1 text-xs font-medium leading-none",children:k[f]})]})}),e.jsxs(t.TooltipContent,{side:"bottom",className:t.cn("max-w-xs",p[f]),children:[e.jsx(t.TooltipArrow,{className:C[f]}),e.jsx("p",{children:b[f]})]})]})})}function De(l,a){return{...l,sql:"",python:"",config:void 0,customCfg:"",preferences:{},interactionConfig:void 0,linkedInteractionTargetOverrides:void 0,dynamicCardPreferences:void 0,customCardPreferences:a?l.customCardPreferences:void 0,visualizationMode:"builtin",type:a?l.type:"bar"}}function le(l){const a=t.getDynamicFrameSaveIssue(l);return a?(t.ue.error(a),!1):!0}function Ee({className:l,variant:a="outline"}){const i=t.useEditorStore(u=>u.onSave),{getUpdatedFrame:d}=se.useVisualUtils();function x(){const u=d();le(u)&&(i==null||i(u))}return e.jsxs(t.Button,{onClick:x,className:l,size:"xs",variant:a,children:[e.jsx(t.Check,{className:"h-3.5 w-3.5"}),"Accept"]})}function we({className:l,variant:a="default"}){const i=t.useQueryClient(),[d,x]=v.useState(!1),u=t.useDashboardStore(C=>C.actions.setIsDashboardPanelOpen),{setIsVisualEditing:h}=t.useDashboardActions(),{getUpdatedFrame:y}=se.useVisualUtils(),f=t.useSelectedVisual(),j=t.useEditorStore(C=>C.frame),b=t.useUpdateVisualMutation(),p=()=>{const C=y();if(!le(C))return;const w=(j==null?void 0:j.visualId)||(f==null?void 0:f.id);if(!w){t.ue.error("No visual to save");return}x(!0),b.mutate({visualId:w,data:{frameObject:C}},{onSuccess:()=>{x(!1),u(!0),t.ue.success("Visual updated successfully"),i.invalidateQueries({queryKey:["resource-by-id","visual",w],exact:!0})},onError:()=>{x(!1),t.ue.error("Failed to update visual")}})};return e.jsx(t.Button,{onClick:p,className:l,size:"xs",variant:a,children:d?e.jsxs(e.Fragment,{children:[e.jsx(t.LoaderCircle,{className:"h-3.5 w-3.5 animate-spin"}),"Saving"]}):e.jsxs(e.Fragment,{children:[e.jsx(re,{className:"h-3.5 w-3.5"}),"Save to Library"]})})}function Ve({className:l}){const a=t.useQueryClient(),[i,d]=v.useState(!1),x=t.useSelectedVisual(),u=t.useEditorStore(k=>k.frame),h=t.useDashboardStore(k=>k.selectedSheetId),y=t.useDashboardStore(k=>k.dashboard),{updateFrame:f,setIsVisualEditing:j}=t.useDashboardActions(),{getUpdatedFrame:b}=se.useVisualUtils(),p=t.useUpdateVisualMutation(),C=t.useResolveExistingFrameSemanticExecutionPayload(),w=async()=>{if(!h){t.ue.error("No sheet selected");return}const k=(u==null?void 0:u.visualId)||(x==null?void 0:x.id);if(!k){t.ue.error("No visual to update");return}d(!0);try{const S=b();if(!le(S)){d(!1);return}const F={...S,visualId:k},Q=t.findDashboardFrameById(y,F.id),R=await C(F,{previousFrame:Q});await p.mutateAsync({visualId:k,data:{frameObject:S}}),f(h,F,{semanticExecutionPayload:R}),a.invalidateQueries({queryKey:["visuals"]}),a.invalidateQueries({queryKey:["visual",k]}),t.ue.success("Saved to library and applied locally"),setTimeout(()=>{j(!1)},300)}catch(S){console.error("Failed to save and apply:",S),t.ue.error(S instanceof Error?S.message:"Failed to save and apply changes")}finally{d(!1)}};return e.jsx(t.Button,{onClick:w,className:l,size:"xs",variant:"default",disabled:i,children:i?e.jsxs(e.Fragment,{children:[e.jsx(t.LoaderCircle,{className:"h-3.5 w-3.5 animate-spin"}),"Saving..."]}):e.jsxs(e.Fragment,{children:[e.jsx(re,{className:"h-3.5 w-3.5"}),"Save & Apply"]})})}function Te({className:l}){const{setTempQueryData:a,setSqlGen:i}=t.useEditorActions(),d=t.useQueryClient(),x=t.useEditorStore(p=>p.tempQueryData),u=t.useEditorStore(p=>p.onClose),h=t.useEditorStore(p=>p.card),y=ae(),f=v.useMemo(()=>y!==h.type?{...h,type:y}:h,[h,y]),{queryKey:j}=t.useEditorCardQuery(f);function b(){if(x){const{queryKey:p,queryData:C}=x;p&&C&&d.setQueryData(p,C)}i({}),u==null||u()}return e.jsxs(t.Button,{onClick:b,className:l,size:"xs",variant:"outline",children:[e.jsx(t.X,{className:"h-3.5 w-3.5"}),"Close"]})}function Ie({label:l="Clear",variant:a="secondary",className:i}={}){const{setTempQueryData:d}=t.useEditorActions(),x=t.useQueryClient(),u=t.useEditorStore(_=>_.tempQueryData),h=t.useEditorStore(_=>_.card),y=ae(),f=v.useMemo(()=>y!==h.type?{...h,type:y}:h,[h,y]),{queryKey:j}=t.useEditorCardQuery(f),{setCardSql:b,setSqlGen:p,setCardPython:C,setCardCustomCfg:w,setCardPreferences:k,clearQueryConfig:S,setCardConfig:F,setCardType:Q,setFrame:R,setCard:$,setActiveTabCardId:U}=t.useEditorActions();function J(){var P,H,I,Y;const _=x.getQueryData(j);u!=null&&u.queryData||d({queryKey:j,queryData:_}),x.setQueryData(j,null),x.removeQueries({queryKey:j,exact:!0}),b(""),p({}),S(),F(void 0),C(""),w(""),k({});const r=t.useEditorStore.getState().frame,V=t.useEditorStore.getState().card,T=t.findCustomVisualConfigCard(r,V),q=((P=T==null?void 0:T.customCardPreferences)==null?void 0:P.visualType)==="multiple"||!!((H=T==null?void 0:T.customCardPreferences)!=null&&H.dataInputCardIds)||(((I=T==null?void 0:T.customCardPreferences)==null?void 0:I.minInputs)||0)>1||(((Y=T==null?void 0:T.customCardPreferences)==null?void 0:Y.maxInputs)||0)>1,A=De(V,q);R({...r,cards:r.cards.map(M=>M.id===A.id?A:M)}),U(A.id),$(A),q||Q("bar")}return e.jsxs(t.Button,{onClick:J,className:i,size:"xs",variant:a,children:[e.jsx(t.X,{className:"h-3.5 w-3.5"}),l]})}function be(l){const{control:a,onChange:i}=l;return e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsx(t.Label,{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:"Label"}),e.jsx(t.Input,{size:"xs",value:a.label,placeholder:"Control label",onChange:d=>i(d.target.value)})]})}function Fe(l){const{currentStep:a,labels:i}=l;return e.jsx("div",{className:"sticky top-0 z-10 -mx-1 border-b border-border/60 bg-background/95 px-1 pb-2.5 pt-1 backdrop-blur supports-[backdrop-filter]:bg-background/85",children:e.jsx("div",{className:"flex flex-wrap items-center gap-2 sm:gap-2.5",children:i.map((d,x)=>{const u=x+1,h=u===a,y=u<a;return e.jsxs(v.Fragment,{children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:t.cn("flex h-5 w-5 items-center justify-center rounded-full border text-[10px] font-medium tabular-nums",h?"border-foreground bg-foreground text-background":y?"border-foreground/30 bg-foreground/10 text-foreground":"border-border/60 bg-background text-muted-foreground"),children:u}),e.jsx("span",{className:t.cn("text-[12px]",h?"font-medium text-foreground":"text-muted-foreground"),children:d})]}),x<i.length-1?e.jsx("span",{className:"h-px w-4 bg-border/60 sm:w-6","aria-hidden":"true"}):null]},d)})})})}function G(l){const{secondary:a,tertiary:i,primary:d}=l;return e.jsxs("div",{className:"sticky bottom-0 z-10 -mx-1 flex justify-end gap-2 border-t bg-background/95 px-1 pb-1 pt-3 backdrop-blur supports-[backdrop-filter]:bg-background/85",children:[a,i,d]})}function Le(l){const{control:a,scope:i,detail:d}=l;return e.jsxs("div",{className:"flex items-start gap-2.5 rounded-[6px] border border-border/60 bg-muted/30 px-3 py-2.5",children:[e.jsx(t.CircleCheck,{className:"mt-0.5 h-3.5 w-3.5 shrink-0 text-foreground"}),e.jsxs("div",{className:"min-w-0 space-y-0.5",children:[e.jsx("div",{className:"text-[13px] font-medium text-foreground",children:a.label}),e.jsxs("div",{className:"text-[12px] text-muted-foreground",children:[t.getFriendlyTypeOption(a.type).label," ·"," ",t.getControlOptionPreview(a)," ·"," ",t.getPlacementLabel(i,a.placement)]}),d?e.jsx("div",{className:"text-[12px] text-muted-foreground",children:d}):null]})]})}function me(l){const{control:a,defaultValue:i,availableFieldChoices:d,availableMetricChoices:x,previewControlDefinitions:u,previewControlValues:h,onControlChange:y,onLabelChange:f,onDefaultValueChange:j,onBack:b,onNext:p,nextDisabled:C}=l;return e.jsxs("div",{className:"space-y-3",children:[e.jsx(be,{control:a,onChange:f}),e.jsx(t.ControlDefinitionOptionsEditor,{control:a,availableFieldChoices:d,availableMetricChoices:x,previewControlDefinitions:u,previewControlValues:h,controlLifecycle:"create",onChange:y}),e.jsx(t.ControlDefaultValueEditor,{control:a,value:i,onChange:j,allowNoDefault:!0,allowCardDefault:!0,hint:"This is the value viewers will see first.",previewControlDefinitions:u,previewControlValues:h}),e.jsx(G,{secondary:e.jsx(t.Button,{type:"button",variant:"outline",size:"xs",onClick:b,children:"Back"}),primary:e.jsx(t.Button,{type:"button",size:"xs",onClick:p,disabled:C,children:"Next"})})]})}const Be=new Set(["grain_selector","aggregation_selector","field_selector","metric_selector"]);function xe(l){const{text:a,ariaLabel:i}=l,[d,x]=v.useState(!1);return e.jsxs("button",{type:"button","aria-label":i,onClick:async()=>{try{await navigator.clipboard.writeText(a),x(!0),setTimeout(()=>x(!1),1200)}catch(u){console.error("Failed to copy",u)}},className:"group flex w-full items-center justify-between gap-2 rounded-[4px] bg-muted/40 px-2 py-1 text-left transition-colors hover:bg-muted/60 focus-visible:bg-muted/60 focus-visible:outline-none",children:[e.jsx("code",{className:"min-w-0 truncate font-mono text-[12px] text-foreground",children:a}),e.jsx("span",{className:"shrink-0 text-[11px] text-muted-foreground opacity-0 transition-opacity group-hover:opacity-100",children:d?"Copied":"Click to copy"})]})}function fe(l){const{control:a,scope:i,createdReference:d,explorerContent:x,sqlDescription:u,summaryDetail:h,onBack:y,onCancel:f,onDone:j}=l,b=Be.has(a.type),p=d.match(/\[\[param\.(.+?)\]\]/),C=p?`{{ param('${p[1]}') }}`:"";return e.jsxs("div",{className:"space-y-4",children:[e.jsx(Le,{control:a,scope:i,detail:h}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-[13px] font-medium text-foreground",children:"How cards use this control"}),e.jsxs("div",{className:"divide-y divide-border/60 overflow-hidden rounded-[6px] border border-border/60",children:[b?e.jsxs("div",{className:"space-y-1 px-3 py-2.5",children:[e.jsx("p",{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:"Explorer cards"}),e.jsx("div",{className:"text-[12px] text-muted-foreground",children:x})]}):null,e.jsxs("div",{className:"space-y-1.5 px-3 py-2.5",children:[e.jsx("p",{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:"SQL cards"}),e.jsx(xe,{text:d,ariaLabel:"Copy SQL control reference"}),C?e.jsx(xe,{text:C,ariaLabel:"Copy Jinja control reference"}):null,e.jsxs("p",{className:"text-[12px] text-muted-foreground",children:[u," ",e.jsx("a",{href:"https://docs.semaphor.cloud/docs/concepts/template-expressions",target:"_blank",rel:"noreferrer",className:"underline underline-offset-2 hover:text-foreground",children:"Template expressions docs"}),"."]})]})]})]}),e.jsx(G,{secondary:e.jsx(t.Button,{type:"button",variant:"outline",size:"xs",onClick:y,children:"Back"}),tertiary:e.jsx(t.Button,{type:"button",variant:"outline",size:"xs",onClick:f,children:"Cancel"}),primary:e.jsx(t.Button,{type:"button",size:"xs",onClick:j,children:"Done"})})]})}function _e(l){const a=t.createBlankControl(l.scope,l.existingControls,l.reservedIds),i=l.type===a.type?{...a,label:t.DEFAULT_LABEL_BY_TYPE[l.type]}:{...t.applyControlTypeChange({controls:[{...a,label:t.DEFAULT_LABEL_BY_TYPE[l.type]}],controlId:a.id,nextType:l.type}).controls[0],label:t.DEFAULT_LABEL_BY_TYPE[l.type]};return{step:2,control:i,defaultValue:t.getDefaultValueForType(i,void 0)}}function qe({scope:l,controls:a,reservedControlIds:i,defaultValues:d,onChange:x,emptyMessage:u,initialCreateFlow:h=!1,usageByControlId:y,availableFieldChoices:f,availableMetricChoices:j,structuralParticipants:b,structuralParticipantIdsByControlId:p,card:C,allowedControlTypes:w,onCreateFlowActiveChange:k,onCreateFlowComplete:S}){const F=v.useMemo(()=>new Set(i||[]),[i]),Q=t.getPlacementOptionsForScope(l),R=t.getDefaultPlacement(l),[$,U]=v.useState(null),[J,_]=v.useState(null),[r,V]=v.useState(()=>h?{step:1,control:t.createBlankControl(l,a,Array.from(F))}:null),T=v.useRef({}),q=v.useRef(void 0),A=v.useRef(h),P=v.useMemo(()=>{const s=t.getFriendlyControlTypeOptions({scope:l,card:C});if(!w)return s;const o=new Set(w);return s.filter(n=>o.has(n.value))},[w,C,l]),H=v.useCallback(s=>{const o=t.getFriendlyControlTypeOptions({scope:l,card:C,includeType:w?void 0:s});if(!w)return o;const n=new Set(w);return o.filter(c=>n.has(c.value))},[w,C,l]),I=v.useCallback(s=>l==="dashboard"&&(s==="field_selector"||s==="metric_selector"),[l]),Y=v.useMemo(()=>r?t.getEligibleParticipantsForStructuralControl(b||[],r.control.type):[],[r,b]),M=v.useMemo(()=>{if(!r)return{fields:f||[],metrics:j||[]};if(!I(r.control.type))return{fields:f||[],metrics:j||[]};const s=r.selectedCardIds||[],o=t.getCompatibleStructuralChoiceCatalog({controlType:r.control.type,participants:b||[],selectedCardIds:s});return{fields:r.control.type==="field_selector"?o.choices.map(n=>({option:n,target:o.fieldTargetMap[n.value]})):[],metrics:r.control.type==="metric_selector"?o.choices.map(n=>({option:n,target:o.metricTargetMap[n.value]})):[]}},[f,j,r,I,b]);v.useEffect(()=>{k==null||k(!!r)},[r,k]),v.useEffect(()=>{const s=h&&!A.current;A.current=h,s&&(V({step:1,control:t.createBlankControl(l,a,Array.from(F))}),_(null),U(null))},[a,h,F,l]);const ye=s=>{if(!I(s.type))return{fields:f||[],metrics:j||[]};const o=(p==null?void 0:p[s.id])||[];if(o.length===0)return{fields:f||[],metrics:j||[]};const n=t.getCompatibleStructuralChoiceCatalog({controlType:s.type,participants:b||[],selectedCardIds:o});return{fields:s.type==="field_selector"?n.choices.map(c=>({option:c,target:n.fieldTargetMap[c.value]})):[],metrics:s.type==="metric_selector"?n.choices.map(c=>({option:c,target:n.metricTargetMap[c.value]})):[]}},ne=s=>{if(!I(s.control.type))return{nextControl:s.control,cardBindingsById:void 0};const o=(p==null?void 0:p[s.control.id])||[],n=t.getCompatibleStructuralChoiceCatalog({controlType:s.control.type,participants:b||[],selectedCardIds:s.nextSelectedCardIds}),c=t.reconcileStructuralControlChoices({control:s.control,choices:n.choices}),g=Object.fromEntries(o.filter(D=>!s.nextSelectedCardIds.includes(D)).map(D=>[D,void 0]));return s.nextSelectedCardIds.length>0&&c.source.kind==="manual"&&c.source.options.length>0&&Object.assign(g,t.buildStructuralControlBindingsForParticipants({control:c,participants:b||[],selectedCardIds:s.nextSelectedCardIds})),{nextControl:c,cardBindingsById:g}},B=v.useCallback((s,o=d,n={type:"update"})=>{const c=s.map(g=>(t.resolveAuthoringControlDefaultValue({control:g,defaultValues:o}),t.syncSqlQueryControlExecutionRequirement(g)));x(c,o,n)},[d,x]),K=(s,o)=>{const n=a.find(E=>E.id===s);let c=a.map(E=>E.id!==s?E:o(E));const g=c.find(E=>E.id===s);let D,m;if(g&&l==="dashboard"&&(g.type==="field_selector"||g.type==="metric_selector")){const E=(p==null?void 0:p[g.id])||[],z=ne({control:g,nextSelectedCardIds:E});c=c.map(O=>O.id===s?z.nextControl:O),D=z.cardBindingsById,m=[g.id]}else if(n&&l==="dashboard"&&(n.type==="field_selector"||n.type==="metric_selector")){const E=(p==null?void 0:p[n.id])||[];D=Object.fromEntries(E.map(z=>[z,void 0])),m=[n.id]}const N=c.find(E=>E.id===s);let L=d;if(n&&N){const E=t.resolveAuthoringControlDefaultValue({control:n,defaultValues:d});n.source.kind==="manual"&&N.source.kind==="sql_query"&&(T.current[s]=E);const z=E===void 0&&n.source.kind==="sql_query"&&N.source.kind==="manual"?T.current[s]:E,O=t.getNextEditedControlDefaultValue({previousControl:n,nextControl:N,currentDefaultValue:z});N.source.kind==="manual"&&(T.current[s]=O),d&&(L={...d},O===void 0?delete L[s]:L[s]=O),c=c.map(pe=>pe.id===s?{...N,defaultValue:O}:pe)}B(c,L,{type:"update",cardBindingsById:D,affectedBindingControlIds:m})},ve=(s,o)=>{const n=o.trim();if(n.length===0||n===s||F.has(n)||a.some(D=>D.id===n&&D.id!==s))return;const c=a.map(D=>D.id===s?{...D,id:n}:D);if(!d){B(c,void 0,{type:"rename",oldId:s,newId:n});return}const g={...d};Object.prototype.hasOwnProperty.call(g,s)&&(g[n]=g[s],delete g[s]),B(c,g,{type:"rename",oldId:s,newId:n})},Ce=s=>{const o=a.filter(c=>c.id!==s);if(!d){B(o,void 0,{type:"remove",controlId:s});return}const n={...d};delete n[s],B(o,n,{type:"remove",controlId:s})},je=v.useCallback(()=>{q.current=void 0,V({step:1,control:t.createBlankControl(l,a,Array.from(F))}),_(null),U(null)},[a,F,l]),X=s=>{V(o=>o&&(()=>{const n=s(o.control);o.control.source.kind==="manual"&&n.source.kind==="sql_query"&&(q.current=o.defaultValue);const c=o.defaultValue===void 0&&o.control.source.kind==="sql_query"&&n.source.kind==="manual"?q.current:o.defaultValue,g=t.getNextEditedControlDefaultValue({previousControl:o.control,nextControl:n,currentDefaultValue:c});return n.source.kind==="manual"&&(q.current=g),{...o,control:n,defaultValue:g}})())},oe=s=>{V(o=>o&&(o.control.source.kind==="manual"&&(q.current=s),{...o,defaultValue:s}))},W=(()=>{if(!r)return!1;if(r.step===2&&I(r.control.type))return(r.selectedCardIds||[]).length>0;if(r.step!==2&&r.step!==3||!r.control.label.trim())return!1;const o=r.control.source.kind==="sql_query"?r.control:t.ensureManualSource(r.control);if(o.source.kind==="manual"&&(t.needsManualOptions(o)&&o.source.options.length===0||o.source.options.some(c=>c.label.trim().length===0||c.value.trim().length===0)))return!1;if(o.source.kind==="sql_query"){const{connectionId:n,sql:c,valueColumn:g}=o.source;return n.trim().length>0&&c.trim().length>0&&g.trim().length>0}return t.hasConcreteDefaultValue(t.getDefaultValueForType(o,r.defaultValue))})(),ie=()=>{var D;if(!r)return;const s=t.ensureManualSource(r.control),o=t.deriveUniqueControlId({label:s.label,fallbackId:s.id,existingControls:a,reservedIds:Array.from(F)}),n={...s,id:o},c=l==="dashboard"&&(n.type==="field_selector"||n.type==="metric_selector")&&((D=r.selectedCardIds)!=null&&D.length)?t.buildStructuralControlBindingsForParticipants({control:n,participants:b||[],selectedCardIds:r.selectedCardIds}):void 0,g=t.getDefaultValueForType(n,r.defaultValue);V({step:l==="dashboard"&&(n.type==="field_selector"||n.type==="metric_selector")?4:3,control:n,defaultValue:g,createdControlId:o,selectedCardIds:r.selectedCardIds,cardBindingsById:c})},Z=v.useCallback(()=>{V(null)},[]),de=v.useCallback(()=>{if(!(r!=null&&r.createdControlId)){V(null);return}const s=r.control,o=r.createdControlId,n=t.getDefaultValueForType(s,r.defaultValue);if(d){const c={...d};n===void 0?delete c[o]:c[o]=n,B([...a,{...s,defaultValue:n}],c,{type:"add",cardBindingsById:r.cardBindingsById})}else B([...a,{...s,defaultValue:n}],void 0,{type:"add",cardBindingsById:r.cardBindingsById});_(o),V(null),S==null||S()},[a,r,d,B,S]),ke=r?I(r.control.type)?["Choose type","Select cards","Configure","Finish"]:["Choose type","Configure","Finish"]:[],ce=r!=null&&r.createdControlId?`[[param.${r.createdControlId}]]`:r?`[[param.${t.slugifyControlValue(r.control.label)||r.control.id}]]`:"",ee=t.buildAuthoringPreviewControlValues({controls:a,defaultValues:d}),te=r?[...a,r.control]:a,ue=r?t.buildAuthoringPreviewControlValues({controls:te,defaultValues:d,overrides:[{controlId:r.control.id,value:r.defaultValue}]}):ee;return e.jsxs("div",{className:"space-y-4",children:[r?e.jsxs("div",{className:"space-y-4 pb-1",children:[e.jsx(Fe,{currentStep:r.step,labels:ke}),r.step===1&&(()=>{const s=new Set(["grain_selector","aggregation_selector","field_selector","metric_selector"]),o=P.filter(g=>!s.has(g.value)),n=P.filter(g=>s.has(g.value)),c=g=>e.jsxs("button",{type:"button",className:"rounded-[6px] border border-border/60 bg-background px-3 py-2.5 text-left transition-colors hover:bg-muted/40 focus-visible:bg-muted/40 focus-visible:outline-none",onClick:()=>V(_e({scope:l,existingControls:a,reservedIds:Array.from(F),type:g.value})),children:[e.jsx("div",{className:"text-[13px] font-medium text-foreground",children:g.label}),e.jsx("p",{className:"mt-0.5 text-[12px] text-muted-foreground",children:g.description})]},g.value);return e.jsxs("div",{className:"space-y-4",children:[l==="card"&&(C==null?void 0:C.sql)==null?e.jsx("p",{className:"text-[12px] text-muted-foreground",children:"Explorer cards support displayed metric, group by field, aggregation, and time grain controls here."}):null,o.length>0&&e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("p",{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:"Input controls"}),e.jsx("div",{className:"grid gap-1.5 sm:grid-cols-2",children:o.map(c)})]}),n.length>0&&e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("p",{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:"Data-driven controls"}),e.jsx("div",{className:"grid gap-1.5 sm:grid-cols-2",children:n.map(c)})]}),e.jsx(G,{secondary:e.jsx(t.Button,{type:"button",variant:"outline",size:"xs",onClick:Z,children:"Back to controls"})})]})})(),r.step===2&&I(r.control.type)&&e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"space-y-3",children:[e.jsx(be,{control:r.control,onChange:s=>X(o=>({...o,label:s}))}),e.jsx("p",{className:"text-[12px] text-muted-foreground",children:"Choose which cards should respond to this shared control."})]}),Y.length===0?e.jsx("div",{className:"rounded-[6px] border border-border/60 bg-muted/30 px-3 py-2.5 text-[12px] text-muted-foreground",children:"No eligible cards are available yet. Add compatible metrics or group-by fields to cards first."}):e.jsx("div",{className:"space-y-1 rounded-[6px] border border-border/60 bg-background p-2",children:Y.map(s=>{const o=(r.selectedCardIds||[]).includes(s.cardId);return e.jsxs("label",{className:"flex items-start gap-2 rounded-[4px] px-1.5 py-1 text-[13px] hover:bg-muted/40",children:[e.jsx(t.Checkbox,{checked:o,onCheckedChange:n=>V(c=>c&&{...c,selectedCardIds:n===!0?[...c.selectedCardIds||[],s.cardId]:(c.selectedCardIds||[]).filter(g=>g!==s.cardId)})}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"font-medium text-foreground",children:s.title}),e.jsx("div",{className:"text-[12px] text-muted-foreground",children:r.control.type==="field_selector"?`${s.fieldChoices.length} compatible group-by fields`:`${s.metricChoices.length} compatible metrics`})]})]},s.cardId)})}),e.jsx(G,{secondary:e.jsx(t.Button,{type:"button",variant:"outline",size:"xs",onClick:()=>V(s=>s&&{...s,step:1,selectedCardIds:[]}),children:"Back"}),primary:e.jsx(t.Button,{type:"button",size:"xs",onClick:()=>V(s=>s&&{...s,step:3}),disabled:!W,children:"Next"})})]}),r.step===2&&!I(r.control.type)&&e.jsx(me,{control:r.control,defaultValue:r.defaultValue,availableFieldChoices:M.fields,availableMetricChoices:M.metrics,previewControlDefinitions:te,previewControlValues:ue,onControlChange:s=>X(()=>s),onLabelChange:s=>X(o=>({...o,label:s})),onDefaultValueChange:oe,onBack:()=>V(s=>s&&{...s,step:1}),onNext:ie,nextDisabled:!W}),r.step===3&&I(r.control.type)&&e.jsx(me,{control:r.control,defaultValue:r.defaultValue,availableFieldChoices:M.fields,availableMetricChoices:M.metrics,previewControlDefinitions:te,previewControlValues:ue,onControlChange:s=>X(()=>s),onLabelChange:s=>X(o=>({...o,label:s})),onDefaultValueChange:oe,onBack:()=>V(s=>s&&{...s,step:2}),onNext:ie,nextDisabled:!W}),r.step===3&&!I(r.control.type)&&e.jsx(fe,{control:r.control,scope:l,createdReference:ce,explorerContent:e.jsxs(e.Fragment,{children:["Open the card and use"," ",e.jsx("span",{className:"font-medium text-foreground",children:"Settings → Controls"})," ","to choose what this control changes."]}),sqlDescription:"Reference this control directly in the SQL editor.",onBack:()=>V(s=>s&&{...s,step:2}),onCancel:Z,onDone:de}),r.step===4&&I(r.control.type)&&e.jsx(fe,{control:r.control,scope:l,createdReference:ce,summaryDetail:e.jsxs(e.Fragment,{children:["Used by ",(r.selectedCardIds||[]).length," selected card",(r.selectedCardIds||[]).length===1?"":"s"]}),explorerContent:e.jsx(e.Fragment,{children:"Selected cards have been set up to respond to this control automatically."}),sqlDescription:"SQL cards can still reference this control directly in the SQL editor.",onBack:()=>V(s=>s&&{...s,step:3}),onCancel:Z,onDone:de})]}):null,!r&&a.length===0?e.jsx("div",{className:"rounded-md border border-dashed p-3 text-sm text-muted-foreground",children:u}):null,!r&&a.map(s=>{const o=ye(s),n=y==null?void 0:y[s.id],c=t.resolveAuthoringControlDefaultValue({control:s,defaultValues:d}),g=J===s.id,D="inline-flex shrink-0 items-center rounded-[4px] border border-border/60 bg-muted/40 px-1.5 py-0.5 text-[11px] font-medium text-muted-foreground";return e.jsxs("div",{className:"rounded-[6px] border border-border/60",children:[e.jsxs("div",{className:"flex items-center gap-2 px-3 py-2.5",children:[e.jsxs("button",{type:"button",className:"flex min-w-0 flex-1 items-start gap-2 rounded-[4px] text-left focus:outline-none focus-visible:bg-muted/40",onClick:()=>_(m=>m===s.id?null:s.id),children:[g?e.jsx(t.ChevronDown,{className:"mt-0.5 h-3.5 w-3.5 shrink-0 text-muted-foreground"}):e.jsx(t.ChevronRight,{className:"mt-0.5 h-3.5 w-3.5 shrink-0 text-muted-foreground"}),e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[e.jsx("span",{className:"truncate text-[13px] font-medium text-foreground",children:s.label||"Untitled control"}),e.jsx("span",{className:D,children:t.getFriendlyTypeOption(s.type).label}),e.jsx("span",{className:D,children:t.getPlacementLabel(l,s.placement)})]}),e.jsxs("div",{className:"mt-0.5 text-[12px] text-muted-foreground",children:[t.getControlOptionPreview(s),n!=null&&n.status?` · ${n.status}`:""]})]})]}),e.jsx(t.Button,{type:"button",size:"xs",variant:"ghost",className:"h-7 w-7 shrink-0 p-0 text-muted-foreground",onClick:()=>Ce(s.id),"aria-label":`Remove ${s.label}`,children:e.jsx(t.Trash2,{className:"h-3.5 w-3.5"})})]}),g&&e.jsxs("div",{className:"space-y-4 border-t border-border/60 px-3 py-3",children:[e.jsxs("div",{className:"grid gap-3 md:grid-cols-3",children:[e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsx(t.Label,{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:"Label"}),e.jsx(t.Input,{size:"xs",value:s.label,placeholder:"Control label",onChange:m=>K(s.id,N=>({...N,label:m.target.value}))})]}),e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsx(t.Label,{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:"Type"}),e.jsxs(t.Select,{value:s.type,onValueChange:m=>{const N=t.applyControlTypeChange({controls:a,controlId:s.id,nextType:m,defaultValues:d});B(N.controls,N.defaultValues)},children:[e.jsx(t.SelectTrigger,{size:"xs",children:e.jsx(t.SelectValue,{})}),e.jsx(t.SelectContent,{children:H(s.type).map(m=>e.jsx(t.SelectItem,{value:m.value,children:m.label},m.value))})]})]}),e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsx(t.Label,{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:"Show in"}),e.jsxs(t.Select,{value:s.placement||R,onValueChange:m=>K(s.id,N=>({...N,placement:m})),children:[e.jsx(t.SelectTrigger,{size:"xs",children:e.jsx(t.SelectValue,{})}),e.jsx(t.SelectContent,{children:Q.map(m=>e.jsx(t.SelectItem,{value:m.value,children:m.label},m.value))})]})]})]}),I(s.type)?e.jsx(t.StructuralParticipantSelector,{type:s.type,participants:t.getEligibleParticipantsForStructuralControl(b||[],s.type).map(m=>({cardId:m.cardId,title:m.title,choiceCount:s.type==="field_selector"?m.fieldChoices.length:m.metricChoices.length})),selectedCardIds:(p==null?void 0:p[s.id])||[],onChange:m=>{const N=ne({control:s,nextSelectedCardIds:m}),L=a.map(E=>E.id===s.id?N.nextControl:E);B(L,d,{type:"update",cardBindingsById:N.cardBindingsById})}}):null,e.jsx(t.ControlDefinitionOptionsEditor,{control:s,availableFieldChoices:o.fields,availableMetricChoices:o.metrics,previewControlDefinitions:a,previewControlValues:ee,controlLifecycle:"edit",onChange:m=>K(s.id,()=>m)}),s.initialValueStrategy==="saved_default"&&e.jsx(t.ControlDefaultValueEditor,{control:s,value:c,allowNoDefault:!0,allowCardDefault:!0,previewControlDefinitions:a,previewControlValues:ee,onChange:m=>{const N=a.map(L=>L.id===s.id?{...L,defaultValue:m}:L);if(s.source.kind==="manual"&&(T.current[s.id]=m),d){const L={...d};m===void 0?delete L[s.id]:L[s.id]=m,B(N,L);return}B(N,void 0)}}),e.jsxs(t.Collapsible,{open:$===s.id,onOpenChange:m=>U(m?s.id:null),children:[e.jsx(t.CollapsibleTrigger,{asChild:!0,children:e.jsxs(t.Button,{type:"button",variant:"ghost",size:"xs",className:"-ml-2 gap-1 text-muted-foreground hover:text-foreground",children:[$===s.id?e.jsx(t.ChevronDown,{className:"h-3.5 w-3.5"}):e.jsx(t.ChevronRight,{className:"h-3.5 w-3.5"}),"Advanced"]})}),e.jsxs(t.CollapsibleContent,{className:"space-y-3 pt-2",children:[e.jsxs("div",{className:"grid gap-3 md:grid-cols-2",children:[e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsx(t.Label,{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:"Control ID"}),e.jsx(t.ControlIdInput,{controlId:s.id,onCommit:m=>ve(s.id,m)},s.id)]}),e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsx(t.Label,{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:"Initial value"}),e.jsxs(t.Select,{value:s.initialValueStrategy,onValueChange:m=>K(s.id,N=>({...N,initialValueStrategy:m})),children:[e.jsx(t.SelectTrigger,{size:"xs",children:e.jsx(t.SelectValue,{})}),e.jsx(t.SelectContent,{children:t.INITIAL_VALUE_STRATEGY_OPTIONS.map(m=>e.jsx(t.SelectItem,{value:m.value,children:m.label},m.value))})]})]})]}),e.jsx(t.ControlVisibilitySettings,{control:s,onChange:m=>K(s.id,()=>m)})]})]})]})]},s.id)}),!r&&e.jsxs(t.Button,{type:"button",variant:"outline",size:"xs",onClick:je,children:[e.jsx(t.Plus,{className:"h-3.5 w-3.5"}),"Add control"]})]})}function Ae(l){const{open:a,onOpenChange:i,initialCreateFlowActive:d=!1,dismissMode:x="passive"}=l,u=a!==void 0,[h,y]=v.useState(!1),[f,j]=v.useState(d),b=u?a:h,p=v.useCallback(k=>{!k&&f&&x==="passive"||(u||y(k),k||j(!1),i==null||i(k))},[u,f,x,i]),C=v.useCallback(()=>{u||y(!1),j(!1),i==null||i(!1)},[u,i]);v.useEffect(()=>{b||j(!1)},[b]);const w=v.useCallback(k=>{f&&k.preventDefault()},[f]);return{forceClose:C,handleOpenChange:p,isCreateFlowActive:f,preventPassiveDismissDuringCreate:w,resolvedOpen:b,setIsCreateFlowActive:j}}exports.CircleX=Se;exports.ControlDefinitionListEditor=qe;exports.EditorAcceptButton=Ee;exports.EditorCancelButton=Te;exports.EditorClearButton=Ie;exports.Library=he;exports.Link2=ge;exports.Save=re;exports.VisualBadge=Ne;exports.VisualSaveAndApplyButton=Ve;exports.VisualSaveButton=we;exports.useCreateFlowOverlayState=Ae;exports.useEffectiveEditorCardType=ae;
|