aidevm / assets /DevNotesStickyPanel-BPakpEvi.js
admin08077's picture
Upload 107 files
63c17a0 verified
import{r as d,j as t}from"./react-D_B_5QVd.js";import{u as w,q as v,F as S,S as k,L as C,M as z}from"./index-BdwitBZy.js";import"./jszip-C9ownNzX.js";import"./react-dom-EAO2-NBm.js";import"./scheduler-DYLXRpC5.js";import"./@google-4tyssLU_.js";import"./marked-CesSW9Du.js";import"./idb-Dob3nYDb.js";const g=["bg-yellow-300 text-yellow-900","bg-green-300 text-green-900","bg-blue-300 text-blue-900","bg-pink-300 text-pink-900","bg-purple-300 text-purple-900"],L=()=>{const[o,l]=w("devcore_notes",[]),[n,u]=d.useState(null),[i,x]=d.useState(!1),[m,c]=d.useState(""),f=d.useCallback(async()=>{if(o.length!==0){x(!0),c("");try{const e=o.map(a=>`- ${a.text}`).join(`
`),r=v(e);let s="";for await(const a of r)s+=a,c(s)}catch(e){console.error(e),c("Sorry, an error occurred while summarizing.")}finally{x(!1)}}},[o]),b=()=>{const e={id:Date.now(),text:"New note...",x:50+o.length%10*20,y:50+o.length%10*20,color:g[o.length%g.length]};l([...o,e])},h=(e,r)=>{l(o.map(s=>s.id===e?{...s,text:r}:s))},y=(e,r)=>{r.stopPropagation(),l(o.filter(s=>s.id!==e))},N=(e,r)=>{if(e.target.tagName==="TEXTAREA"||e.target.tagName==="BUTTON")return;const a=e.currentTarget.getBoundingClientRect();u({id:r,offsetX:e.clientX-a.left,offsetY:e.clientY-a.top})},j=e=>{if(!n)return;const r=e.currentTarget.getBoundingClientRect();l(o.map(s=>s.id===n.id?{...s,x:e.clientX-n.offsetX-r.left,y:e.clientY-n.offsetY-r.top}:s))},p=()=>u(null);return t.jsxs("div",{className:"h-full flex flex-col p-4 sm:p-6 lg:p-8 text-text-primary",children:[t.jsxs("header",{className:"mb-6 flex justify-between items-center",children:[t.jsxs("div",{children:[t.jsxs("h1",{className:"text-3xl font-bold flex items-center",children:[t.jsx(S,{}),t.jsx("span",{className:"ml-3",children:"Dev Notes Sticky Panel"})]}),t.jsx("p",{className:"text-text-secondary mt-1",children:"A place for your thoughts, todos, and random ideas."})]}),t.jsxs("div",{className:"flex gap-2",children:[t.jsxs("button",{onClick:f,disabled:i||o.length===0,className:"btn-primary flex items-center gap-2 px-4 py-2",children:[t.jsx(k,{})," ",i?"Summarizing...":"AI Summarize"]}),t.jsx("button",{onClick:b,className:"btn-primary px-6 py-2",children:"Add Note"})]})]}),t.jsx("div",{className:"relative flex-grow bg-background border-2 border-dashed border-border rounded-lg overflow-hidden",onMouseMove:j,onMouseUp:p,onMouseLeave:p,children:o.map(e=>t.jsxs("div",{className:`group absolute w-48 h-48 p-2 flex flex-col shadow-lg cursor-grab active:cursor-grabbing rounded-md transition-transform duration-100 border border-black/30 ${e.color}`,style:{top:e.y,left:e.x,transform:(n==null?void 0:n.id)===e.id?"scale(1.05)":"scale(1)"},onMouseDown:r=>N(r,e.id),children:[t.jsx("button",{onClick:r=>y(e.id,r),className:"absolute -top-2 -right-2 w-6 h-6 rounded-full bg-gray-700 text-white font-bold text-xs flex items-center justify-center opacity-0 group-hover:opacity-100 hover:bg-red-500 transition-all",children:"×"}),t.jsx("textarea",{value:e.text,onChange:r=>h(e.id,r.target.value),className:"w-full h-full bg-transparent resize-none focus:outline-none font-medium p-1 placeholder:text-inherit/50"})]},e.id))}),(i||m)&&t.jsx("div",{className:"fixed inset-0 bg-gray-900/80 backdrop-blur-sm z-50 flex items-center justify-center",onClick:()=>c(""),children:t.jsxs("div",{className:"w-full max-w-2xl bg-surface border border-border rounded-lg shadow-2xl p-6",onClick:e=>e.stopPropagation(),children:[t.jsx("h2",{className:"text-xl font-bold mb-4",children:"AI Summary of Notes"}),i&&!m?t.jsx(C,{}):t.jsx(z,{content:m})]})})]})};export{L as DevNotesStickyPanel};
//# sourceMappingURL=DevNotesStickyPanel-BPakpEvi.js.map