PageSourceSearch

https://thesheet.com/assets/SheetsPage-Cl9pCv1W.js

js thesheet.com collected 2026-10-02 14:16:04 UTC 12,016 bytes, 16 lines download raw bytes

1import{j as e}from"./vendor-tanstack-BBxR7B6C.js";import{r as c,u as me,L as V}from"./vendor-react-DVVT73CU.js";import{s as z,D as L,p as T,q as O,r as H,am as ue,j as F,aO as he,h as x,$ as ae,aE as te,bx as re,l as xe,by as pe,u as ge,t as je,K as Ne,b8 as G,I as C,P as J,al as fe,A as U,E as Z,F as W,G as k,L as X,T as Y,d as ve,J as we}from"./index-ta93-oWI.js";import{E as ee,P as se}from"./pencil-DNtriQXk.js";import"./vendor-charts-yUtVJANA.js";import"./vendor-supabase-gdPvtqil.js";import"./vendor-tiptap-DDtibdHn.js";import"./vendor-date-VoIYQfZe.js";/**
2 * @license lucide-react v0.462.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 ye=z("FolderInput",[["path",{d:"M2 9V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H20a2 2 0 0 1 2 2v10a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2v-1",key:"fm4g5t"}],["path",{d:"M2 13h10",key:"pgb2dq"}],["path",{d:"m9 16 3-3-3-3",key:"6m91ic"}]]);/**
7 * @license lucide-react v0.462.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 be=z("FolderPlus",[["path",{d:"M12 10v6",key:"1bos4e"}],["path",{d:"M9 13h6",key:"1uhe8q"}],["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}]]);/**
12 * @license lucide-react v0.462.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 Ce=z("House",[["path",{d:"M15 21v-8a1 1 0 0 0-1-1h-4a1 1 0 0 0-1 1v8",key:"5wwlr5"}],["path",{d:"M3 10a2 2 0 0 1 .709-1.528l7-5.999a2 2 0 0 1 2.582 0l7 5.999A2 2 0 0 1 21 10v9a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z",key:"1d0kgt"}]]);function ke({open:j,onOpenChange:m,sheet:r,folders:u,onMove:h}){const[o,S]=c.useState(null),[E,P]=c.useState(new Set),D=()=>{r&&(h(r.id,o),m(!1))},_=t=>{P(p=>{const d=new Set(p);return d.has(t)?d.delete(t):d.add(t),d})},N=t=>u.filter(p=>p.parent_id===t),i=(t,p=0)=>{const d=N(t.id),f=d.length>0,v=E.has(t.id),y=o===t.id,w=(r==null?void 0:r.folder_id)===t.id;return e.jsxs("div",{children:[e.jsxs("button",{onClick:()=>{S(t.id),f&&_(t.id)},disabled:w,className:F("w-full flex items-center gap-2 px-3 py-2 text-sm rounded-lg transition-colors text-left",y?"bg-primary text-primary-foreground":"hover:bg-muted",w&&"opacity-50 cursor-not-allowed"),style:{paddingLeft:`${12+p*16}px`},children:[f&&e.jsx(ae,{className:F("h-4 w-4 shrink-0 transition-transform",v&&"rotate-90")}),!f&&e.jsx("span",{className:"w-4"}),v?e.jsx(te,{className:"h-4 w-4 shrink-0 text-primary"}):e.jsx(re,{className:"h-4 w-4 shrink-0 text-primary"}),e.jsx("span",{className:"truncate",children:t.name}),w&&e.jsx("span",{className:"text-xs text-muted-foreground ml-auto",children:"(current)"})]}),f&&v&&e.jsx("div",{children:d.map(b=>i(b,p+1))})]},t.id)},A=N(null),l=(r==null?void 0:r.folder_id)===null;return e.jsx(L,{open:j,onOpenChange:m,children:e.jsxs(T,{className:"sm:max-w-md",children:[e.jsx(O,{children:e.jsxs(H,{children:['Move "',r==null?void 0:r.name,'" to...']})}),e.jsx(ue,{className:"max-h-[300px] -mx-6 px-6",children:e.jsxs("div",{className:"space-y-1",children:[e.jsxs("button",{onClick:()=>S(null),disabled:l,className:F("w-full flex items-center gap-2 px-3 py-2 text-sm rounded-lg transition-colors text-left",o===null?"bg-primary text-primary-foreground":"hover:bg-muted",l&&"opacity-50 cursor-not-allowed"),children:[e.jsx("span",{className:"w-4"}),e.jsx(Ce,{className:"h-4 w-4 shrink-0"}),e.jsx("span",{children:"Root (No folder)"}),l&&e.jsx("span",{className:"text-xs text-muted-foreground ml-auto",children:"(current)"})]}),A.map(t=>i(t))]})}),e.jsxs(he,{className:"gap-2 sm:gap-0",children:[e.jsx(x,{variant:"outline",onClick:()=>m(!1),children:"Cancel"}),e.jsx(x,{onClick:D,disabled:o===(r==null?void 0:r.folder_id),className:"gradient-primary",children:"Move Here"})]})]})})}function Te(){const j=me(),{sheets:m,createSheet:r,deleteSheet:u,updateSheet:h}=xe(),{folders:o,createFolder:S,updateFolder:E,deleteFolder:P}=pe(),{toggleFavorite:D,isFavorite:_}=ge(),{user:N}=je(),[i,A]=c.useState(""),[l,t]=c.useState(null),[p,d]=c.useState(!1),[f,v]=c.useState(!1),[y,w]=c.useState(""),[b,R]=c.useState(""),[n,g]=c.useState(null),[ne,I]=c.useState(!1),[le,ie]=c.useState(null);o.find(s=>s.id===l);const K=Fe(l,o),oe=o.filter(s=>s.parent_id===l),de=m.filter(s=>s.owner_id===(N==null?void 0:N.id)?s.folder_id===l:l===null),B=i?o.filter(s=>s.name.toLowerCase().includes(i.toLowerCase())):oe,$=i?m.filter(s=>s.name.toLowerCase().includes(i.toLowerCase())):de,ce=(s,a)=>{h.mutate({id:s,folder_id:a})},q=async()=>
16{if(!y.trim())return;const s=await r.mutateAsync(y);l&&await h.mutateAsync({id:s.id,folder_id:l}),w(""),d(!1),j(`/sheet/${s.id}`)},Q=async()=>{b.trim()&&(await S.mutateAsync({name:b,parentId:l}),R(""),v(!1))},M=async()=>{!n||!n.name.trim()||(n.type==="folder"?await E.mutateAsync({id:n.id,name:n.name}):await h.mutateAsync({id:n.id,name:n.name}),g(null))};return e.jsxs("div",{className:"min-h-screen bg-background",children:[e.jsx("header",{className:"sticky top-0 z-10 bg-background/80 backdrop-blur-sm border-b border-border",children:e.jsx("div",{className:"container mx-auto px-4 py-4",children:e.jsxs("div",{className:"flex items-center justify-between gap-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(V,{to:"/",className:"p-2 rounded-lg hover:bg-muted transition-colors",children:e.jsx(Ne,{className:"h-5 w-5 text-muted-foreground"})}),e.jsx("h1",{className:"font-display text-xl font-bold",children:"All Sheets"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(L,{open:f,onOpenChange:v,children:[e.jsx(G,{asChild:!0,children:e.jsxs(x,{variant:"outline",size:"sm",className:"gap-2",children:[e.jsx(be,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"New Folder"})]})}),e.jsxs(T,{children:[e.jsx(O,{children:e.jsx(H,{children:"Create New Folder"})}),e.jsxs("div",{className:"space-y-4 pt-4",children:[e.jsx(C,{placeholder:"Folder name...",value:b,onChange:s=>R(s.target.value),onKeyDown:s=>s.key==="Enter"&&Q(),autoFocus:!0}),e.jsx(x,{onClick:Q,className:"w-full gradient-primary",children:"Create Folder"})]})]})]}),e.jsxs(L,{open:p,onOpenChange:d,children:[e.jsx(G,{asChild:!0,children:e.jsxs(x,{size:"sm",className:"gap-2 gradient-primary",children:[e.jsx(J,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"New Sheet"})]})}),e.jsxs(T,{children:[e.jsx(O,{children:e.jsx(H,{children:"Create New Sheet"})}),e.jsxs("div",{className:"space-y-4 pt-4",children:[e.jsx(C,{placeholder:"Sheet name...",value:y,onChange:s=>w(s.target.value),onKeyDown:s=>s.key==="Enter"&&q(),autoFocus:!0}),e.jsx(x,{onClick:q,className:"w-full gradient-primary",children:"Create Sheet"})]})]})]})]})]})})}),e.jsxs("main",{className:"container mx-auto px-4 py-6",children:[e.jsxs("div",{className:"mb-6 space-y-4",children:[e.jsxs("div",{className:"relative",children:[e.jsx(fe,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(C,{placeholder:"Search sheets and folders...",value:i,onChange:s=>A(s.target.value),className:"pl-9"})]}),!i&&e.jsxs("nav",{className:"flex items-center gap-1 text-sm text-muted-foreground",children:[e.jsx("button",{onClick:()=>t(null),className:F("hover:text-foreground transition-colors",!l&&"text-foreground font-medium"),children:"All Sheets"}),K.map((s,a)=>e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(ae,{className:"h-4 w-4"}),e.jsx("button",{onClick:()=>t(s.id),className:F("hover:text-foreground transition-colors",a===K.length-1&&"text-foreground font-medium"),children:s.name})]},s.id))]})]}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-4",children:[B.map(s=>e.jsxs("div",{className:"group relative bg-card border border-border rounded-xl p-4 hover:border-primary/50 hover:shadow-lg transition-all cursor-pointer",onClick:()=>!i&&t(s.id),children:[e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"p-2 rounded-lg bg-primary/10 text-primary",children:l===s.id?e.jsx(te,{className:"h-5 w-5"}):e.jsx(re,{className:"h-5 w-5"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[(n==null?void 0:n.id)===s.id?e.jsx(C,{value:n.name,onChange:a=>g({...n,name:a.target.value}),onBlur:M,onKeyDown:a=>{a.key==="Enter"&&M(),a.key==="Escape"&&g(null)},onClick:a=>a.stopPropagation(),autoFocus:!0,className:"h-7 text-sm"}):e.jsx("h3",{className:"font-medium truncate",children:s.name}),e.jsxs("p",{className:"text-xs text-muted-foreground mt-1",children:[o.filter(a=>a.parent_id===s.id).length," folders,"," ",m.filter(a=>a.folder_id===s.id).length," sheets"]})]})]}),e.jsxs(U,{children:[e.jsx(Z,{asChild:!0,children:e.jsx(x,{variant:"ghost",size:"icon",className:"absolute top-2 right-2 h-8 w-8 op
16acity-0 group-hover:opacity-100 transition-opacity",onClick:a=>a.stopPropagation(),children:e.jsx(ee,{className:"h-4 w-4"})})}),e.jsxs(W,{align:"end",children:[e.jsxs(k,{onClick:a=>{a.stopPropagation(),g({type:"folder",id:s.id,name:s.name})},children:[e.jsx(se,{className:"h-4 w-4 mr-2"}),"Rename"]}),e.jsxs(k,{onClick:a=>{a.stopPropagation(),P.mutate(s.id)},className:"text-destructive focus:text-destructive",children:[e.jsx(X,{className:"h-4 w-4 mr-2"}),"Delete"]})]})]})]},s.id)),$.map(s=>e.jsxs(V,{to:`/sheet/${s.id}`,className:"group relative bg-card border border-border rounded-xl p-4 hover:border-primary/50 hover:shadow-lg transition-all",children:[e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"p-2 rounded-lg gradient-primary text-primary-foreground",children:e.jsx(Y,{className:"h-5 w-5"})}),e.jsxs("div",{className:"flex-1 min-w-0 pr-8",children:[(n==null?void 0:n.id)===s.id?e.jsx(C,{value:n.name,onChange:a=>g({...n,name:a.target.value}),onBlur:M,onKeyDown:a=>{a.key==="Enter"&&M(),a.key==="Escape"&&g(null)},onClick:a=>a.preventDefault(),autoFocus:!0,className:"h-7 text-sm"}):e.jsx("h3",{className:"font-medium truncate",children:s.name}),e.jsxs("div",{className:"flex items-center justify-between mt-1",children:[e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Updated ",new Date(s.updated_at).toLocaleDateString()]}),e.jsx(ve,{isFavorite:_(s.id),onToggle:()=>D.mutate(s.id),size:"sm",disabled:D.isPending})]})]})]}),e.jsxs(U,{children:[e.jsx(Z,{asChild:!0,children:e.jsx(x,{variant:"ghost",size:"icon",className:"absolute top-2 right-2 h-8 w-8 opacity-0 group-hover:opacity-100 transition-opacity",onClick:a=>a.preventDefault(),children:e.jsx(ee,{className:"h-4 w-4"})})}),e.jsxs(W,{align:"end",children:[e.jsxs(k,{onClick:a=>{a.preventDefault(),g({type:"sheet",id:s.id,name:s.name})},children:[e.jsx(se,{className:"h-4 w-4 mr-2"}),"Rename"]}),e.jsxs(k,{onClick:a=>{a.preventDefault(),ie(s),I(!0)},children:[e.jsx(ye,{className:"h-4 w-4 mr-2"}),"Move to folder"]}),e.jsx(we,{}),e.jsxs(k,{onClick:a=>{a.preventDefault(),u.mutate(s.id)},className:"text-destructive focus:text-destructive",children:[e.jsx(X,{className:"h-4 w-4 mr-2"}),"Delete"]})]})]})]},s.id))]}),B.length===0&&$.length===0&&e.jsxs("div",{className:"text-center py-16",children:[e.jsx("div",{className:"inline-flex p-4 rounded-full bg-muted mb-4",children:e.jsx(Y,{className:"h-8 w-8 text-muted-foreground"})}),e.jsx("h3",{className:"font-medium text-lg mb-2",children:i?"No results found":"No sheets yet"}),e.jsx("p",{className:"text-muted-foreground mb-4",children:i?"Try a different search term":"Create your first sheet to get started"}),!i&&e.jsxs(x,{onClick:()=>d(!0),className:"gradient-primary",children:[e.jsx(J,{className:"h-4 w-4 mr-2"}),"Create Sheet"]})]})]}),e.jsx(ke,{open:ne,onOpenChange:I,sheet:le,folders:o,onMove:ce})]})}function Fe(j,m){if(!j)return[];const r=[];let u=m.find(h=>h.id===j);for(;u;)r.unshift(u),u=u.parent_id?m.find(h=>h.id===u.parent_id):void 0;return r}export{Te as default};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.