efficient-shell 10.17.0 → 10.18.0
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/{Browser-Q5BYSSW3.js → Browser-UWCA2UQO.js} +14 -14
- package/dist/{Documents-GGEPMWB5.js → Documents-NRS6FCCD.js} +5 -5
- package/dist/{Files-OVNXUYOV.js → Files-OGBZKSHI.js} +15 -15
- package/dist/{Notepad-L2LOWTSE.js → Notepad-CMLPGGRI.js} +8 -8
- package/dist/{Preview-HM2Z3EJO.js → Preview-XPSNRIYM.js} +24 -24
- package/dist/{Spreadsheet-2E4TQ64O.js → Spreadsheet-WLRVB7LK.js} +9 -9
- package/dist/ai/index.d.ts +19 -3
- package/dist/ai/index.js +91 -80
- package/dist/ai.css +1 -1
- package/dist/apps/index.js +1 -1
- package/dist/bin/media-host-check.js +1 -1
- package/dist/bin/ui-check.js +1 -1
- package/dist/brand.css +1 -1
- package/dist/{chunk-CUHUZBFH.js → chunk-5HO53ZE7.js} +5 -5
- package/dist/{chunk-CXYHFGUY.js → chunk-FTF6JKD5.js} +3 -3
- package/dist/{chunk-ZHAWOZA7.js → chunk-GMOEYB4X.js} +11 -11
- package/dist/{chunk-HJW67KA7.js → chunk-GNNY35U6.js} +1 -1
- package/dist/{chunk-NNZFC4O7.js → chunk-KDXH6FLQ.js} +1 -1
- package/dist/{chunk-B23RG53S.js → chunk-LAO5ZHQ6.js} +4 -4
- package/dist/chunk-VNKAIEJ6.js +1 -0
- package/dist/{chunk-RT4WOEVS.js → chunk-XK42AQOJ.js} +4 -4
- package/dist/{chunk-WTYQF7XJ.js → chunk-ZWMODDVE.js} +2 -2
- package/dist/forms/BorderInput.js +1 -1
- package/dist/forms/BrandAssetEditor.js +1 -1
- package/dist/forms/ColorPicker.js +1 -1
- package/dist/forms/LinkPicker.js +1 -1
- package/dist/forms/MediaLibrary.js +1 -1
- package/dist/forms/MediaUploadField.js +1 -1
- package/dist/index.js +119 -119
- package/dist/telemetry/index.js +1 -1
- package/dist/ui/index.js +1 -1
- package/dist/version.js +1 -1
- package/package.json +1 -1
- package/dist/chunk-WRQ4A5QY.js +0 -1
|
@@ -1,29 +1,29 @@
|
|
|
1
|
-
import{peekBrowserStartUrl as e,claimBrowserStartUrl as t}from"./chunk-LWLCNQY7.js";import{AboutApp as o}from"./chunk-
|
|
1
|
+
import{peekBrowserStartUrl as e,claimBrowserStartUrl as t}from"./chunk-LWLCNQY7.js";import{AboutApp as o}from"./chunk-GNNY35U6.js";import{WindowTitle as r}from"./chunk-2YSGXZOL.js";import"./chunk-CY5N5OA3.js";import"./chunk-AW7TOB6N.js";import"./chunk-KNUR2UEG.js";import"./chunk-JDCM2VHG.js";import"./chunk-QYL26AB4.js";import"./chunk-ZDMZM7HD.js";import"./chunk-5A7MWTXX.js";import"./chunk-2E2SUEEE.js";import{confirm as n}from"./chunk-PLK2WHZG.js";import"./chunk-7INZ7O3A.js";import"./chunk-KC3EX26K.js";import"./chunk-FOFZI62F.js";import"./chunk-3DVNXNTF.js";import"./chunk-ECJKIPWU.js";import"./chunk-VWGWZY7A.js";import"./chunk-7QSDPSXP.js";import"./chunk-UGTRSRIW.js";import"./chunk-EPY34L26.js";import"./chunk-CDAJKLGL.js";import"./chunk-VNKAIEJ6.js";import"./chunk-4WEFGKJL.js";import"./chunk-URHGHXDN.js";import"./chunk-5QFPTDQF.js";import"./chunk-TXDA7TTP.js";import"./chunk-I4VIEGCX.js";import"./chunk-UQYNPYF4.js";import"./chunk-34URULVW.js";import{Icon as s}from"./chunk-2UO47XB4.js";import"./chunk-J75ZT2JQ.js";import"./chunk-R2VKEMZH.js";import"./chunk-MRJKZWWV.js";import"./chunk-MVZRZTQP.js";import"./chunk-6XBWM453.js";import"./chunk-PGN5ME7B.js";import"./chunk-62LW225J.js";import"./chunk-GLUJS42B.js";import"./chunk-D65T4H6J.js";import"./chunk-F27JJHNJ.js";import"./chunk-TWVUQUUD.js";import"./chunk-GDQJBQ5B.js";import"./chunk-C3QOHMR6.js";import{useRef as a,useEffect as i,useState as l}from"react";import{jsxs as c,jsx as m,Fragment as u}from"react/jsx-runtime";var d="react-os-shell:browser-bookmarks",h="react-os-shell:browser-homepage",p="https://en.wikipedia.org/wiki/Main_Page",b=[{label:"Wikipedia",url:"https://en.wikipedia.org/wiki/Main_Page"},{label:"DevDocs",url:"https://devdocs.io"},{label:"Example",url:"https://example.com"}],k=new Set(["ac ad ae af ag ai al am ao aq ar as at au aw ax az ba bb bd be bf bg bh bi","bj bm bn bo br bs bt bw by bz ca cc cd cf cg ch ci ck cl cm cn co cr cu cv","cw cx cy cz de dj dk dm do dz ec ee eg er es et eu fi fj fk fm fo fr ga gd","ge gf gg gh gi gl gm gn gp gq gr gs gt gu gw gy hk hm hn hr ht hu id ie il","im in io iq ir is it je jm jo jp ke kg kh ki km kn kp kr kw ky kz la lb lc","li lk lr ls lt lu lv ly ma mc md me mg mh mk ml mm mn mo mp mq mr ms mt mu","mv mw mx my mz na nc ne nf ng ni nl no np nr nu nz om pa pe pf pg ph pk pl","pm pn pr ps pt pw py qa re ro rs ru rw sa sb sc sd se sg sh si sk sl sm sn","so sr ss st su sv sx sy sz tc td tf tg th tj tk tl tm tn to tr tt tv tw tz","ua ug uk us uy uz va vc ve vg vi vn vu wf ws ye yt za zm zw","com net org edu gov mil int info biz name pro app dev xyz online site tech","store shop cloud design digital agency studio media news blog live life","world today email systems solutions services software page link space host","press wiki team group works careers finance capital energy academy"].join(" ").split(" "));function g(e){let t=e.trim();return t?/^[a-z][a-z0-9+.-]*:\/\//i.test(t)?t:function(e){const t=/^([\w-]+\.)+([a-z]{2,})(\/.*)?$/i.exec(e);return null!==t&&k.has(t[2].toLowerCase())}(t)?"https://"+t:"https://duckduckgo.com/?q="+encodeURIComponent(t):""}var f=["duckduckgo.com","developer.mozilla.org","google.com","gmail.com","youtube.com","facebook.com","instagram.com","whatsapp.com","twitter.com","x.com","github.com","gitlab.com","linkedin.com","reddit.com","pinterest.com","amazon.com","amazon.ca","amazon.co.uk","apple.com","icloud.com","microsoft.com","outlook.com","live.com","office.com","netflix.com","spotify.com","paypal.com","stripe.com","chat.openai.com","chatgpt.com","claude.ai"];function x(){if("undefined"==typeof window)return b;try{const e=localStorage.getItem(d);if(!e)return b;const t=JSON.parse(e);if(Array.isArray(t)&&t.every(e=>"string"==typeof e?.url))return t}catch{}return b}function w(){return"undefined"==typeof window?p:localStorage.getItem(h)||p}function y(){const u=a(void 0);void 0===u.current&&(u.current=e()),i(()=>{null!=u.current&&t(u.current)},[]);const p=u.current?g(u.current.url):"",[b,k]=l(w),[f,y]=l(p||b),[j,C]=l(f),[W,z]=l([f]),[E,L]=l(0),[R,U]=l(0),[S,D]=l(x),[T,G]=l(!1),[J,H]=l(null),P=a(null),M=a(null);i(()=>{try{localStorage.setItem(d,JSON.stringify(S))}catch{}},[S]);const F=e=>{const t=g(e);t&&(y(t),C(t),z(e=>{const o=e.slice(0,E+1);return o.push(t),o}),L(e=>e+1),G(!1))},I=()=>{"undefined"!=typeof window&&window.open(f,"_blank","noopener,noreferrer")},K=()=>{const e=J?.trim();e?(D(t=>[...t,{label:e,url:f}]),H(null)):H(null)};i(()=>{if(null===J)return;P.current?.focus(),P.current?.select();const e=e=>{const t=e.target;t?.closest("[data-bookmark-popover]")||H(null)},t=setTimeout(()=>document.addEventListener("mousedown",e),0);return()=>{clearTimeout(t),document.removeEventListener("mousedown",e)}},[null!==J]);const O=e=>{D(t=>t.filter((t,o)=>o!==e))},X=E>0,A=E<W.length-1,Q=S.some(e=>e.url===f),Z="p-2 rounded hover:bg-gray-200 transition-colors text-gray-600 disabled:opacity-30";/* @__PURE__ */
|
|
2
2
|
return c("div",{className:"relative flex flex-col h-full bg-white",children:[
|
|
3
3
|
/* @__PURE__ */m(r,{title:`Browser - ${v(f)}`}),
|
|
4
4
|
/* @__PURE__ */m(o,{app:"browser"}),
|
|
5
5
|
/* @__PURE__ */c("div",{className:"flex items-center gap-1 px-2 py-2 border-b border-line bg-surface-sunken shrink-0",children:[
|
|
6
|
-
/* @__PURE__ */m("button",{onClick:()=>{if(
|
|
7
|
-
/* @__PURE__ */m("button",{onClick:()=>{if(
|
|
8
|
-
/* @__PURE__ */m("button",{onClick:()=>
|
|
9
|
-
/* @__PURE__ */m("button",{onClick:()=>
|
|
10
|
-
/* @__PURE__ */m("form",{onSubmit:e=>{e.preventDefault(),
|
|
6
|
+
/* @__PURE__ */m("button",{onClick:()=>{if(E>0){const e=E-1;L(e),y(W[e]),C(W[e]),G(!1)}},disabled:!X,className:Z,title:"Back",children:/* @__PURE__ */m(s,{name:"chevron-left",className:"h-4 w-4",strokeWidth:2})}),
|
|
7
|
+
/* @__PURE__ */m("button",{onClick:()=>{if(E<W.length-1){const e=E+1;L(e),y(W[e]),C(W[e]),G(!1)}},disabled:!A,className:Z,title:"Forward",children:/* @__PURE__ */m(s,{name:"chevron-right",className:"h-4 w-4",strokeWidth:2})}),
|
|
8
|
+
/* @__PURE__ */m("button",{onClick:()=>U(e=>e+1),className:Z,title:"Refresh",children:/* @__PURE__ */m(s,{name:"refresh",className:"h-4 w-4",strokeWidth:1.8})}),
|
|
9
|
+
/* @__PURE__ */m("button",{onClick:()=>F(b),className:Z,title:"Home",children:/* @__PURE__ */m(s,{name:"home",className:"h-4 w-4",strokeWidth:1.8})}),
|
|
10
|
+
/* @__PURE__ */m("form",{onSubmit:e=>{e.preventDefault(),F(j)},className:"flex-1 flex items-center mx-1",children:/* @__PURE__ */c("div",{className:"flex items-center w-full bg-white border border-gray-300 rounded focus-within:border-blue-400 focus-within:ring-1 focus-within:ring-blue-200",children:[
|
|
11
11
|
/* @__PURE__ */m("span",{className:"px-2 text-gray-400 text-xs",children:f.startsWith("https://")?"🔒":"⚠️"}),
|
|
12
12
|
/* @__PURE__ */m("input",{type:"text",value:j,onChange:e=>C(e.target.value),onFocus:e=>e.target.select(),className:"flex-1 px-1 py-1 text-sm bg-transparent outline-none font-mono",spellCheck:!1,placeholder:"Enter URL or search…"}),f!==j&&/* @__PURE__ */m("button",{type:"button",onClick:()=>C(f),className:"px-2 text-2xs text-ink-faintest hover:text-ink",title:"Reset to current URL",children:"×"})]})}),
|
|
13
|
-
/* @__PURE__ */m("button",{"data-bookmark-popover":!0,onClick:()=>
|
|
14
|
-
/* @__PURE__ */m("button",{onClick:
|
|
15
|
-
/* @__PURE__ */m("button",{onClick:()=>
|
|
13
|
+
/* @__PURE__ */m("button",{"data-bookmark-popover":!0,onClick:()=>Q?O(S.findIndex(e=>e.url===f)):void H(v(f)),className:Z+" "+(Q?"text-yellow-500":""),title:Q?"Remove bookmark":"Add bookmark",children:/* @__PURE__ */m(s,{name:"star",className:"h-4 w-4",fill:Q?"currentColor":"none",strokeWidth:1.5})}),
|
|
14
|
+
/* @__PURE__ */m("button",{onClick:I,className:Z,title:"Open in new tab",children:/* @__PURE__ */m(s,{name:"external",className:"h-4 w-4",strokeWidth:1.5})}),
|
|
15
|
+
/* @__PURE__ */m("button",{onClick:()=>G(e=>!e),className:Z,title:"Embedding help",children:/* @__PURE__ */m(s,{name:"help",className:"h-4 w-4",strokeWidth:1.5})})]}),null!==J&&/* @__PURE__ */c("div",{"data-bookmark-popover":!0,className:"absolute right-3 top-12 z-30 w-72 bg-white border border-gray-200 rounded-md shadow-lg p-3",children:[
|
|
16
16
|
/* @__PURE__ */m("div",{className:"text-2xs font-semibold uppercase tracking-wide text-ink-faint mb-1",children:"Bookmark this page"}),
|
|
17
17
|
/* @__PURE__ */m("div",{className:"text-2xs text-ink-faintest truncate mb-2 font-mono",title:f,children:f}),
|
|
18
|
-
/* @__PURE__ */m("input",{ref:P,type:"text",value:J,onChange:e=>
|
|
18
|
+
/* @__PURE__ */m("input",{ref:P,type:"text",value:J,onChange:e=>H(e.target.value),onKeyDown:e=>{"Enter"===e.key?K():"Escape"===e.key&&H(null)},placeholder:"Name",className:"w-full text-sm px-2 h-8 border border-line-strong rounded focus:outline-none focus:border-blue-400 focus:ring-1 focus:ring-blue-200"}),
|
|
19
19
|
/* @__PURE__ */c("div",{className:"flex justify-end gap-1 mt-2",children:[
|
|
20
|
-
/* @__PURE__ */m("button",{onClick:()=>
|
|
21
|
-
/* @__PURE__ */m("button",{onClick:
|
|
22
|
-
/* @__PURE__ */c("div",{className:"flex items-center gap-0.5 px-2 py-1 border-b border-gray-200 bg-white shrink-0 overflow-x-auto",children:[0===
|
|
20
|
+
/* @__PURE__ */m("button",{onClick:()=>H(null),className:"px-2 py-1 text-xs text-gray-600 hover:bg-gray-100 rounded",children:"Cancel"}),
|
|
21
|
+
/* @__PURE__ */m("button",{onClick:K,disabled:!J.trim(),className:"px-2 py-1 text-xs bg-blue-500 text-white rounded hover:bg-blue-600 disabled:opacity-40",children:"Save"})]})]}),
|
|
22
|
+
/* @__PURE__ */c("div",{className:"flex items-center gap-0.5 px-2 py-1 border-b border-gray-200 bg-white shrink-0 overflow-x-auto",children:[0===S.length&&/* @__PURE__ */m("span",{className:"text-2xs text-ink-faintest italic px-2",children:"No bookmarks yet — star the address bar to add one."}),S.map((e,t)=>/* @__PURE__ */c("button",{onClick:()=>F(e.url),onContextMenu:async o=>{o.preventDefault();await n({title:"Remove bookmark",message:`"${e.label}" will be removed from your bookmarks.`,confirmLabel:"Remove",variant:"danger"})&&O(t)},className:"flex items-center gap-2 px-2 py-0.5 rounded text-xs text-ink hover:bg-gray-100 whitespace-nowrap",title:`${e.url}\n(right-click to remove)`,children:[
|
|
23
23
|
/* @__PURE__ */m("img",{src:`https://icons.duckduckgo.com/ip3/${new URL(e.url).hostname}.ico`,alt:"",className:"h-3.5 w-3.5",onError:e=>{e.target.style.visibility="hidden"}}),e.label]},t)),
|
|
24
24
|
/* @__PURE__ */m("div",{className:"flex-1"}),
|
|
25
25
|
/* @__PURE__ */m("button",{onClick:()=>{k(f);try{localStorage.setItem(h,f)}catch{}},className:"px-2 py-0.5 text-2xs text-ink-faint hover:text-ink-strong",title:"Set current page as homepage",children:"Set as home"})]}),
|
|
26
|
-
/* @__PURE__ */m("div",{className:"flex-1 relative min-h-0 bg-gray-50",children:/* @__PURE__ */m(N,{url:f,iframeKey:
|
|
26
|
+
/* @__PURE__ */m("div",{className:"flex-1 relative min-h-0 bg-gray-50",children:/* @__PURE__ */m(N,{url:f,iframeKey:R,iframeRef:M,openExternal:I,showHelp:T,dismissHelp:()=>G(!1)})})]})}function v(e){try{return new URL(e).hostname.replace(/^www\./,"")}catch{return e}}function N({url:e,iframeKey:t,iframeRef:o,openExternal:r,showHelp:n,dismissHelp:a}){const[d,h]=l(!1);i(()=>{h(!1)},[e]);return function(e){try{const t=new URL(e).hostname.toLowerCase();return f.some(e=>t===e||t.endsWith("."+e))}catch{return!1}}(e)&&!d?/* @__PURE__ */m("div",{className:"absolute inset-0 flex items-center justify-center bg-white p-8",children:/* @__PURE__ */c("div",{className:"max-w-md text-center",children:[
|
|
27
27
|
/* @__PURE__ */m(s,{name:"no-symbol",className:"h-14 w-14 mx-auto text-gray-300 mb-3",strokeWidth:1.2}),
|
|
28
28
|
/* @__PURE__ */c("h3",{className:"text-base font-semibold text-gray-800 mb-1",children:[v(e)," can't be embedded"]}),
|
|
29
29
|
/* @__PURE__ */c("p",{className:"text-sm text-gray-500 mb-4",children:["This site sends an ",
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import{escapeHtml as e}from"./chunk-G6DKCCWH.js";import{AboutApp as t}from"./chunk-
|
|
1
|
+
import{escapeHtml as e}from"./chunk-G6DKCCWH.js";import{AboutApp as t}from"./chunk-GNNY35U6.js";import{WindowTitle as n}from"./chunk-2YSGXZOL.js";import"./chunk-CY5N5OA3.js";import"./chunk-AW7TOB6N.js";import"./chunk-KNUR2UEG.js";import"./chunk-JDCM2VHG.js";import"./chunk-QYL26AB4.js";import"./chunk-ZDMZM7HD.js";import"./chunk-5A7MWTXX.js";import"./chunk-2E2SUEEE.js";import"./chunk-PLK2WHZG.js";import"./chunk-7INZ7O3A.js";import"./chunk-KC3EX26K.js";import"./chunk-FOFZI62F.js";import"./chunk-3DVNXNTF.js";import"./chunk-ECJKIPWU.js";import"./chunk-VWGWZY7A.js";import"./chunk-7QSDPSXP.js";import{toast_default as r}from"./chunk-7ELJQL7J.js";import"./chunk-UGTRSRIW.js";import"./chunk-EPY34L26.js";import"./chunk-CDAJKLGL.js";import"./chunk-VNKAIEJ6.js";import{PopupMenu as o,PopupMenuLabel as i,PopupMenuItem as l,PopupMenuDivider as a}from"./chunk-4WEFGKJL.js";import"./chunk-URHGHXDN.js";import"./chunk-5QFPTDQF.js";import"./chunk-TXDA7TTP.js";import"./chunk-I4VIEGCX.js";import"./chunk-UQYNPYF4.js";import"./chunk-34URULVW.js";import{Icon as s}from"./chunk-2UO47XB4.js";import"./chunk-J75ZT2JQ.js";import{LoadingSpinner as c}from"./chunk-R2VKEMZH.js";import"./chunk-MRJKZWWV.js";import"./chunk-MVZRZTQP.js";import"./chunk-6XBWM453.js";import"./chunk-PGN5ME7B.js";import"./chunk-62LW225J.js";import"./chunk-GLUJS42B.js";import"./chunk-D65T4H6J.js";import"./chunk-F27JJHNJ.js";import"./chunk-TWVUQUUD.js";import"./chunk-GDQJBQ5B.js";import"./chunk-C3QOHMR6.js";import{useState as m,useRef as h}from"react";import{jsxs as u,jsx as d}from"react/jsx-runtime";var p=/* @__PURE__ */new Set(["txt","md","markdown","csv","tsv","log","json","xml","html","htm","css","js","jsx","ts","tsx","py","rb","go","rs","java","c","h","cpp","hpp","sh","bash","yml","yaml","toml","ini","conf","env","sql"]),g=/* @__PURE__ */new Set(["docx"]),x={filename:"Untitled",kind:"docx",content:"",ext:"docx"};function f(){const[f,y]=m(x),[k,v]=m(!1),[b,j]=m(!1),[w,N]=m(!1),[C,D]=m(null),L=h(null),M=h(null),U=h(null),W=(e,t)=>{U.current?.focus(),document.execCommand(e,!1,t),N(!0)},R=e=>{for(const t of e){if(!t.type.startsWith("image/"))continue;const e=new FileReader;e.onload=()=>{U.current?.focus(),document.execCommand("insertImage",!1,String(e.result)),N(!0)},e.readAsDataURL(t)}},T=e=>{C&&(C.el.removeAttribute("width"),C.el.removeAttribute("height"),C.el.style.width=e??"",C.el.style.height=e?"auto":"",N(!0),D(null))},B=async t=>{const n=(t.name.split(".").pop()||"").toLowerCase();v(!0);try{if(p.has(n)||!g.has(n)&&t.type.startsWith("text/")){const r=await t.text(),o=e(r).replace(/\n/g,"<br>");y({filename:t.name,kind:"text",content:o,ext:n}),N(!1)}else if(g.has(n))try{const e=await(import(
|
|
2
2
|
/* @vite-ignore */
|
|
3
|
-
"mammoth")),r=await t.arrayBuffer(),o=await e.convertToHtml({arrayBuffer:r});y({filename:t.name,kind:"docx",content:o.value||"<p><em>(empty document)</em></p>",ext:n}),N(!1)}catch(e){r.error('Install the optional "mammoth" peer dep to read .docx files.')}else"doc"===n?r.error(".doc is the legacy Word binary format — convert to .docx first."):r.error(`Unsupported file type: .${n||"unknown"}`)}finally{v(!1)}},
|
|
4
|
-
return u("div",{className:"relative flex flex-col h-full",onDragOver:e=>{e.preventDefault(),b||j(!0)},onDragLeave:e=>{e.currentTarget===e.target&&j(!1)},onDrop:e=>{e.preventDefault(),j(!1);const t=Array.from(e.dataTransfer.files??[]);0!==t.length&&(t.every(e=>e.type.startsWith("image/"))?R(t):
|
|
5
|
-
/* @__PURE__ */d(n,{title:`${
|
|
3
|
+
"mammoth")),r=await t.arrayBuffer(),o=await e.convertToHtml({arrayBuffer:r});y({filename:t.name,kind:"docx",content:o.value||"<p><em>(empty document)</em></p>",ext:n}),N(!1)}catch(e){r.error('Install the optional "mammoth" peer dep to read .docx files.')}else"doc"===n?r.error(".doc is the legacy Word binary format — convert to .docx first."):r.error(`Unsupported file type: .${n||"unknown"}`)}finally{v(!1)}},A=f?.filename?(E=f.filename).length>24?`${E.slice(0,23)}…`:E:"Untitled";var E;/* @__PURE__ */
|
|
4
|
+
return u("div",{className:"relative flex flex-col h-full",onDragOver:e=>{e.preventDefault(),b||j(!0)},onDragLeave:e=>{e.currentTarget===e.target&&j(!1)},onDrop:e=>{e.preventDefault(),j(!1);const t=Array.from(e.dataTransfer.files??[]);0!==t.length&&(t.every(e=>e.type.startsWith("image/"))?R(t):B(t[0]))},children:[
|
|
5
|
+
/* @__PURE__ */d(n,{title:`${A}${w?" •":""} - Documents`}),
|
|
6
6
|
/* @__PURE__ */d(t,{app:"documents"}),
|
|
7
7
|
/* @__PURE__ */u("div",{className:"flex items-center flex-wrap gap-x-2 gap-y-1 px-3 py-2 border-b border-gray-200 bg-gray-50 shrink-0",children:[
|
|
8
|
-
/* @__PURE__ */d("input",{ref:L,type:"file",accept:".txt,.md,.csv,.tsv,.log,.json,.xml,.html,.htm,.css,.js,.jsx,.ts,.tsx,.py,.rb,.go,.rs,.java,.c,.h,.cpp,.hpp,.sh,.bash,.yml,.yaml,.toml,.ini,.conf,.env,.sql,.docx,text/*",onChange:e=>{const t=e.target.files?.[0];t&&
|
|
8
|
+
/* @__PURE__ */d("input",{ref:L,type:"file",accept:".txt,.md,.csv,.tsv,.log,.json,.xml,.html,.htm,.css,.js,.jsx,.ts,.tsx,.py,.rb,.go,.rs,.java,.c,.h,.cpp,.hpp,.sh,.bash,.yml,.yaml,.toml,.ini,.conf,.env,.sql,.docx,text/*",onChange:e=>{const t=e.target.files?.[0];t&&B(t),L.current&&(L.current.value="")},className:"hidden"}),
|
|
9
9
|
/* @__PURE__ */u("button",{onClick:()=>L.current?.click(),className:"text-xs text-gray-700 hover:text-gray-900 px-2 py-1 rounded hover:bg-gray-200 transition-colors flex items-center gap-1",children:[
|
|
10
10
|
/* @__PURE__ */d(s,{name:"folder-open",className:"h-3.5 w-3.5",strokeWidth:1.5}),"Open"]}),
|
|
11
11
|
/* @__PURE__ */d("button",{onClick:()=>{if(!f)return;const t=U.current?.innerHTML??"";if("text"===f.kind){if(/<(b|strong|i|em|u|font|span style|ul|ol|img)|style="[^"]*text-align/i.test(t)){const n=new Blob([`<!doctype html><meta charset="utf-8"><title>${e(f.filename)}</title><body style="font-family:ui-monospace,monospace;white-space:pre-wrap">${t}`],{type:"text/html"}),r=URL.createObjectURL(n),o=document.createElement("a");o.href=r,o.download=`${f.filename.replace(/\.[^.]+$/,"")}.html`,o.click(),URL.revokeObjectURL(r)}else{const e=U.current?.innerText??"",t=new Blob([e],{type:"text/plain"}),n=URL.createObjectURL(t),r=document.createElement("a");r.href=n,r.download=f.filename,r.click(),URL.revokeObjectURL(n)}}else{const n=new Blob([`<!doctype html><meta charset="utf-8"><title>${e(f.filename)}</title>${t}`],{type:"text/html"}),r=URL.createObjectURL(n),o=document.createElement("a");o.href=r,o.download=`${f.filename.replace(/\.docx$/i,"")}.html`,o.click(),URL.revokeObjectURL(r)}},className:"text-xs text-gray-700 hover:text-gray-900 px-2 py-1 rounded hover:bg-gray-200 transition-colors",children:"Save"}),
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{openPreviewFile as e}from"./chunk-EOWUUOVE.js";import{SidebarLayout as t}from"./chunk-XCHAU2UN.js";import"./chunk-QWK6DRSN.js";import"./chunk-5QGBVTGS.js";import{Breadcrumbs as a}from"./chunk-XYECIBVX.js";import{formatBytes as n}from"./chunk-GEYM4WN3.js";import"./chunk-Y3JW2GW5.js";import"./chunk-36BRD5J3.js";import"./chunk-LF27WIN2.js";import{getFilesDemoTree as r}from"./chunk-U2RFKQVA.js";import{AboutApp as i}from"./chunk-
|
|
1
|
+
import{openPreviewFile as e}from"./chunk-EOWUUOVE.js";import{SidebarLayout as t}from"./chunk-XCHAU2UN.js";import"./chunk-QWK6DRSN.js";import"./chunk-5QGBVTGS.js";import{Breadcrumbs as a}from"./chunk-XYECIBVX.js";import{formatBytes as n}from"./chunk-GEYM4WN3.js";import"./chunk-Y3JW2GW5.js";import"./chunk-36BRD5J3.js";import"./chunk-LF27WIN2.js";import{getFilesDemoTree as r}from"./chunk-U2RFKQVA.js";import{AboutApp as i}from"./chunk-GNNY35U6.js";import{peekFilesViewRequest as s,consumeFilesViewRequest as o,FILES_SHOW_TRASH_EVENT as l,FILES_OPEN_DESKTOP_FOLDER_EVENT as c,subscribeDesktopFolders as d,getDesktopFoldersSnapshot as m,FolderGlyph as h,DesktopItemMiniIcon as p,desktopItemTypeLabel as u}from"./chunk-E5QPXEKN.js";import"./chunk-ESL5TDNA.js";import"./chunk-VTVSMRFX.js";import{useWindowManager as f,WindowTitle as x}from"./chunk-2YSGXZOL.js";import"./chunk-CY5N5OA3.js";import"./chunk-AW7TOB6N.js";import"./chunk-KNUR2UEG.js";import"./chunk-JDCM2VHG.js";import"./chunk-QYL26AB4.js";import"./chunk-ZDMZM7HD.js";import"./chunk-5A7MWTXX.js";import"./chunk-2E2SUEEE.js";import{confirm as g,prompt as k}from"./chunk-PLK2WHZG.js";import"./chunk-7INZ7O3A.js";import"./chunk-KC3EX26K.js";import{ItemCount as b}from"./chunk-FOFZI62F.js";import"./chunk-3DVNXNTF.js";import"./chunk-ECJKIPWU.js";import"./chunk-VWGWZY7A.js";import"./chunk-7QSDPSXP.js";import{toast_default as y}from"./chunk-7ELJQL7J.js";import"./chunk-UGTRSRIW.js";import"./chunk-EPY34L26.js";import"./chunk-CDAJKLGL.js";import"./chunk-VNKAIEJ6.js";import"./chunk-4WEFGKJL.js";import"./chunk-URHGHXDN.js";import"./chunk-5QFPTDQF.js";import"./chunk-TXDA7TTP.js";import"./chunk-I4VIEGCX.js";import"./chunk-UQYNPYF4.js";import"./chunk-34URULVW.js";import{Icon as N}from"./chunk-2UO47XB4.js";import"./chunk-J75ZT2JQ.js";import{LoadingSpinner as w}from"./chunk-R2VKEMZH.js";import"./chunk-MRJKZWWV.js";import{TH_ONE_LINE as v}from"./chunk-MVZRZTQP.js";import"./chunk-6XBWM453.js";import"./chunk-PGN5ME7B.js";import"./chunk-62LW225J.js";import"./chunk-GLUJS42B.js";import"./chunk-D65T4H6J.js";import"./chunk-F27JJHNJ.js";import"./chunk-TWVUQUUD.js";import"./chunk-GDQJBQ5B.js";import"./chunk-C3QOHMR6.js";import{useState as j,useEffect as $,useSyncExternalStore as C,useRef as E,useCallback as L}from"react";import{jsxs as D,jsx as T,Fragment as R}from"react/jsx-runtime";var W="undefined"!=typeof window&&window.__REACT_OS_SHELL_FILE_SERVER__||"http://localhost:4000",U={pdf:"pdf",dxf:"dxf",csv:"csv",jpg:"image",jpeg:"image",png:"image",gif:"image",webp:"image",svg:"image",avif:"image",bmp:"image",stp:"3d",step:"3d",stl:"3d",obj:"3d",gltf:"3d",glb:"3d","3mf":"3d",iges:"3d",igs:"3d",ply:"3d",fbx:"3d"};function P(e,t){return"/"===e||""===e?"/"+t:e.replace(/\/$/,"")+"/"+t}function F(e){if(!e)return"—";try{const t=new Date(e);return isNaN(t.getTime())?"—":t.toLocaleString(void 0,{dateStyle:"short",timeStyle:"short"})}catch{return e}}function S(){const S=W.replace(/\/$/,""),I=null!==r(),[A,M]=j("/"),[O,J]=j([]),[V,G]=j([]),[B,Q]=j(null),[K,X]=j(!0),[H,Z]=j(!1),[z,Y]=j(null),[_,q]=j(!1),[ee,te]=j(()=>{const e=s();return"trash"===e?"trash":e?{desktopFolderId:e.folderId}:"files"});$(()=>{o()},[]);const[ae,ne]=j([]);$(()=>{const e=()=>{o(),te("trash")},t=e=>{o();const t=e.detail?.folderId;t&&te({desktopFolderId:t})};return window.addEventListener(l,e),window.addEventListener(c,t),()=>{window.removeEventListener(l,e),window.removeEventListener(c,t)}},[]);const re=C(d,m,m),ie="object"==typeof ee?ee.desktopFolderId:null,se=ie?re?.folders.find(e=>e.id===ie)??null:null,oe=ie&&re?.itemsByFolder[ie]||[];$(()=>{ie&&re&&!re.folders.some(e=>e.id===ie)&&te("files")},[ie,re]);const le=E(0),ce=E(null),{openPage:de,openEntity:me}=f(),he=t=>{"preview-file"===t.entityType&&t.filePath&&t.fileKind?e({filePath:t.filePath,filename:t.label,kind:t.fileKind,onStaged:e=>de(e)}):"page"===t.entityType?de(t.entityId):me(t.entityType,t.entityId,null,t.label)},pe=L((e,t={})=>fetch(e,{...t,credentials:"include"}),[]),ue=L(async()=>{try{const e=await pe(`${S}/api/quota`);if(e.ok){const t=await e.json();Y({used:t.used,limit:t.limit})}}catch{}},[pe,S]),fe=L(async e=>{if(Q(null),I){const t=function(e){const t=r();if(!t)return[];let a=t;for(const t of e.split("/").filter(Boolean)){const e=a.find(e=>"folder"===e.kind&&e.name===t);if(!e||!e.children)return[];a=e.children}return a.map(e=>({name:e.name,kind:e.kind,size:e.size??0,modifiedAt:e.modifiedAt??""}))}(e);return J(t),M(e),Z(!1),X(!1),void("/"===e&&G(t.filter(e=>"folder"===e.kind).map(e=>e.name)))}X(!0);try{const t=await pe(`${S}/api/files?path=${encodeURIComponent(e)}`);if(!t.ok){const e=await t.json().catch(()=>({}));return void y.error(e.error||`Failed to list (${t.status})`)}const a=await t.json(),n=a.entries||[];J(n),M(a.path||e),Z(!1),"/"===(a.path||e)&&G(n.filter(e=>"folder"===e.kind).map(e=>e.name))}catch(e){Z(!0)}finally{X(!1)}ue()},[pe,S,ue,I]),xe=L(async()=>{if(I)return ne([]),void X(!1);X(!0),Q(null);try{const e=await pe(`${S}/api/trash`);if(!e.ok){const t=await e.json().catch(()=>({}));return void y.error(t.error||`Failed to list trash (${e.status})`)}const t=await e.json();ne(t.entries||[]),Z(!1)}catch{Z(!0)}finally{X(!1)}ue()},[pe,S,ue,I]);$(()=>{"files"===ee?fe(A):"trash"===ee&&xe()},[A,ee]);const ge=async e=>{const t=P(A,e.name);try{const a=await pe(`${S}/api/file?path=${encodeURIComponent(t)}`);if(!a.ok)return void y.error(`Download failed (${a.status})`);const n=await a.blob(),r=URL.createObjectURL(n),i=document.createElement("a");i.href=r,i.download=e.name,i.click(),setTimeout(()=>URL.revokeObjectURL(r),1e3)}catch(e){y.error(e?.message||"Download failed")}},ke=async e=>{const t=Array.from(e);for(const e of t){const t=new FormData;t.append("file",e);try{const a=await pe(`${S}/api/upload?path=${encodeURIComponent(A)}`,{method:"POST",body:t});if(!a.ok){const t=await a.json().catch(()=>({}));if(413===a.status){const a=Math.max(0,(t.limit||0)-(t.used||0));y.error(`Quota exceeded — ${n(a)} free, ${e.name} is ${n(t.attempted||e.size)}`)}else y.error(`Upload ${e.name}: ${t.error||a.status}`)}}catch(t){y.error(`Upload ${e.name}: ${t?.message||"failed"}`)}}fe(A)},be=()=>{le.current=0,q(!1)};if($(()=>{const e=()=>be();return window.addEventListener("dragend",e),window.addEventListener("drop",e),()=>{window.removeEventListener("dragend",e),window.removeEventListener("drop",e)}},[]),H)/* @__PURE__ */
|
|
2
2
|
return D("div",{className:"flex flex-col h-full bg-white",children:[
|
|
3
3
|
/* @__PURE__ */T(x,{title:"Files - offline"}),
|
|
4
4
|
/* @__PURE__ */T("div",{className:"flex-1 flex items-center justify-center p-8 text-center",children:/* @__PURE__ */D("div",{className:"max-w-md",children:[
|
|
@@ -7,26 +7,26 @@ return D("div",{className:"flex flex-col h-full bg-white",children:[
|
|
|
7
7
|
/* @__PURE__ */D("p",{className:"text-sm text-gray-500 mb-3",children:["No response from ",
|
|
8
8
|
/* @__PURE__ */T("span",{className:"font-mono",children:S}),". Make sure the server is running — see ",
|
|
9
9
|
/* @__PURE__ */T("span",{className:"font-mono",children:"examples/file-server/README.md"}),"."]}),
|
|
10
|
-
/* @__PURE__ */T("button",{onClick:()=>fe(
|
|
10
|
+
/* @__PURE__ */T("button",{onClick:()=>fe(A),className:"px-3 h-8 text-sm bg-blue-500 text-on-accent rounded hover:bg-blue-600",children:"Retry"})]})})]});const ye="/"===A?[]:A.split("/").filter(Boolean),Ne=z&&z.limit>0?Math.min(100,Math.round(z.used/z.limit*100)):0,we=Ne>90?"bg-red-500":Ne>75?"bg-amber-500":"bg-blue-500",ve=[{label:"My files",onClick:()=>M("/")},...ye.map((e,t)=>({label:e,onClick:()=>M("/"+ye.slice(0,t+1).join("/"))}))],je=e=>"flex w-full items-center gap-2 rounded-md px-3 min-h-(--row-height-menu) py-2 text-left text-sm transition-colors "+(e?"bg-blue-50 font-medium text-blue-700":"text-gray-700 hover:bg-gray-100"),$e=e=>/* @__PURE__ */T("svg",{className:"h-4 w-4 shrink-0 text-gray-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.6,children:/* @__PURE__ */T("path",{strokeLinecap:"round",strokeLinejoin:"round",d:e})}),Ce=/* @__PURE__ */D("nav",{className:"p-2",children:[
|
|
11
11
|
/* @__PURE__ */T("div",{className:"px-2 py-2 text-2xs font-semibold uppercase tracking-wide text-ink-faintest",children:"Locations"}),
|
|
12
|
-
/* @__PURE__ */D("button",{onClick:()=>{te("files"),M("/")},className:je("files"===ee&&"/"===
|
|
13
|
-
/* @__PURE__ */T("span",{className:"truncate",children:e})]},e)),!
|
|
12
|
+
/* @__PURE__ */D("button",{onClick:()=>{te("files"),M("/")},className:je("files"===ee&&"/"===A),children:[$e("M2.25 12l8.954-8.955a1.5 1.5 0 012.122 0L21.75 12M4.5 9.75v9.75a.75.75 0 00.75.75H9V15a.75.75 0 01.75-.75h4.5A.75.75 0 0115 15v5.25h3.75a.75.75 0 00.75-.75V9.75"),"My files"]}),V.map(e=>/* @__PURE__ */D("button",{onClick:()=>{te("files"),M("/"+e)},className:je("files"===ee&&A==="/"+e),children:[$e("M2.25 12.75V12A2.25 2.25 0 014.5 9.75h15A2.25 2.25 0 0121.75 12v.75m-8.69-6.44l-2.12-2.12a1.5 1.5 0 00-1.061-.44H4.5A2.25 2.25 0 002.25 6v12a2.25 2.25 0 002.25 2.25h15A2.25 2.25 0 0021.75 18V9a2.25 2.25 0 00-2.25-2.25h-5.379a1.5 1.5 0 01-1.06-.44z"),
|
|
13
|
+
/* @__PURE__ */T("span",{className:"truncate",children:e})]},e)),!I&&/* @__PURE__ */D("button",{onClick:()=>te("trash"),className:je("trash"===ee),children:[$e("M14.74 9l-.346 9m-4.788 0L9.26 9m9.968-3.21c.342.052.682.107 1.022.166m-1.022-.165L18.16 19.673a2.25 2.25 0 01-2.244 2.077H8.084a2.25 2.25 0 01-2.244-2.077L4.772 5.79"),"Trash"]}),re&&re.folders.length>0&&/* @__PURE__ */D(R,{children:[
|
|
14
14
|
/* @__PURE__ */T("div",{className:"px-2 pt-3 pb-2 text-2xs font-semibold uppercase tracking-wide text-ink-faintest",children:"Desktop"}),re.folders.map(e=>/* @__PURE__ */D("button",{onClick:()=>te({desktopFolderId:e.id}),className:je(ie===e.id),children:[
|
|
15
15
|
/* @__PURE__ */T(h,{className:"h-4 w-4 shrink-0 text-amber-500"}),
|
|
16
16
|
/* @__PURE__ */T("span",{className:"truncate",children:e.name}),
|
|
17
17
|
/* @__PURE__ */T(b,{count:e.itemCount,active:ie===e.id,className:"ml-auto"})]},e.id))]})]});/* @__PURE__ */
|
|
18
|
-
return D("div",{className:"relative flex flex-col h-full bg-white",onDragEnter:e=>{
|
|
19
|
-
/* @__PURE__ */T(x,{title:se?`Files - ${se.name}`:"Files"+("/"===
|
|
18
|
+
return D("div",{className:"relative flex flex-col h-full bg-white",onDragEnter:e=>{I||"object"==typeof ee||e.dataTransfer?.types?.includes?.("Files")&&(e.preventDefault(),le.current++,_||q(!0))},onDragOver:e=>{e.dataTransfer?.types?.includes?.("Files")&&e.preventDefault()},onDragLeave:()=>{le.current>0&&le.current--,0===le.current&&q(!1)},onDrop:e=>{e.preventDefault(),be(),I||"object"==typeof ee||e.dataTransfer.files?.length&&ke(e.dataTransfer.files)},children:[
|
|
19
|
+
/* @__PURE__ */T(x,{title:se?`Files - ${se.name}`:"Files"+("/"===A?"":" - "+A)}),
|
|
20
20
|
/* @__PURE__ */T(i,{app:"files"}),
|
|
21
21
|
/* @__PURE__ */T("input",{ref:ce,type:"file",multiple:!0,className:"hidden",onChange:e=>{e.target.files?.length&&ke(e.target.files),ce.current&&(ce.current.value="")}}),
|
|
22
22
|
/* @__PURE__ */T("div",{className:"flex-1 min-h-0",children:/* @__PURE__ */T(t,{sidebar:Ce,storageKey:"files.sidebarWidth",defaultWidth:200,minWidth:150,maxWidth:320,children:/* @__PURE__ */D("div",{className:"flex h-full min-w-0 flex-col",children:[
|
|
23
23
|
/* @__PURE__ */D("div",{className:"flex items-center gap-1 px-2 py-2 border-b border-line bg-surface-sunken shrink-0 text-xs",children:[/* @__PURE__ */D(R,"files"===ee?{children:[
|
|
24
|
-
/* @__PURE__ */T("button",{onClick:()=>M(function(e){if("/"===e||""===e)return"/";const t=e.replace(/\/$/,""),a=t.lastIndexOf("/");return a<=0?"/":t.slice(0,a)}(
|
|
24
|
+
/* @__PURE__ */T("button",{onClick:()=>M(function(e){if("/"===e||""===e)return"/";const t=e.replace(/\/$/,""),a=t.lastIndexOf("/");return a<=0?"/":t.slice(0,a)}(A)),disabled:"/"===A,className:"px-2 py-1 rounded hover:bg-gray-200 disabled:opacity-30 text-gray-600",title:"Parent folder",children:/* @__PURE__ */T(N,{name:"arrow-left",className:"h-3.5 w-3.5",strokeWidth:2})}),
|
|
25
25
|
/* @__PURE__ */T("div",{className:"flex-1 min-w-0",children:/* @__PURE__ */T(a,{items:ve,maxItems:5})}),
|
|
26
|
-
/* @__PURE__ */T("button",{onClick:()=>fe(
|
|
26
|
+
/* @__PURE__ */T("button",{onClick:()=>fe(A),className:"px-2 py-1 rounded hover:bg-gray-200 text-gray-600",title:"Refresh",children:/* @__PURE__ */T(N,{name:"refresh",className:"h-3.5 w-3.5",strokeWidth:1.8})}),!I&&/* @__PURE__ */D(R,{children:[
|
|
27
27
|
/* @__PURE__ */D("button",{onClick:()=>te("trash"),className:"px-2 py-1 rounded hover:bg-gray-200 text-gray-600 flex items-center gap-1",title:"Open trash",children:[
|
|
28
28
|
/* @__PURE__ */T(N,{name:"trash",className:"h-3.5 w-3.5",strokeWidth:1.5}),"Trash"]}),
|
|
29
|
-
/* @__PURE__ */D("button",{onClick:async()=>{const e=await k({title:"New folder",placeholder:"Folder name",confirmLabel:"Create"});if(!e)return;if(/[\\/]/.test(e))return void y.error("Folder names cannot contain slashes");const t=P(
|
|
29
|
+
/* @__PURE__ */D("button",{onClick:async()=>{const e=await k({title:"New folder",placeholder:"Folder name",confirmLabel:"Create"});if(!e)return;if(/[\\/]/.test(e))return void y.error("Folder names cannot contain slashes");const t=P(A,e),a=await pe(`${S}/api/folder`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:t})});if(!a.ok){const e=await a.json().catch(()=>({}));return void y.error(e.error||`Create folder failed (${a.status})`)}fe(A)},className:"px-2 py-1 rounded hover:bg-gray-200 text-gray-600 flex items-center gap-1",children:[
|
|
30
30
|
/* @__PURE__ */T(N,{name:"folder-plus",className:"h-3.5 w-3.5",strokeWidth:1.5}),"New Folder"]}),
|
|
31
31
|
/* @__PURE__ */D("button",{onClick:()=>ce.current?.click(),className:"px-2 py-1 rounded bg-blue-500 text-white hover:bg-blue-600 flex items-center gap-1",children:[
|
|
32
32
|
/* @__PURE__ */T(N,{name:"upload",className:"h-3.5 w-3.5",strokeWidth:1.8}),"Upload"]})]})]}:"trash"===ee?{children:[
|
|
@@ -48,7 +48,7 @@ return D("div",{className:"relative flex flex-col h-full bg-white",onDragEnter:e
|
|
|
48
48
|
/* @__PURE__ */T("th",{className:`${v} text-left font-medium px-3 h-8 w-28`,children:"Type"}),
|
|
49
49
|
/* @__PURE__ */T("th",{className:`${v} w-56`})]})}),
|
|
50
50
|
/* @__PURE__ */T("tbody",{children:oe.map(e=>{const t=`${e.entityType}|${e.entityId}`;/* @__PURE__ */
|
|
51
|
-
return D("tr",{onClick:()=>
|
|
51
|
+
return D("tr",{onClick:()=>Q(t),onDoubleClick:()=>he(e),className:"cursor-default border-b border-gray-100 "+(B===t?"bg-blue-50":"hover:bg-gray-50"),children:[
|
|
52
52
|
/* @__PURE__ */D("td",{className:"px-3 h-8 flex items-center gap-2",children:[
|
|
53
53
|
/* @__PURE__ */T(p,{item:e}),
|
|
54
54
|
/* @__PURE__ */T("span",{className:"truncate",title:e.label,children:e.label})]}),
|
|
@@ -71,18 +71,18 @@ return D("tr",{onClick:()=>G(t),onDoubleClick:()=>he(e),className:"cursor-defaul
|
|
|
71
71
|
/* @__PURE__ */T("td",{className:"px-3 h-8 text-right text-ink-faint tabular-nums",children:e.deletedAt?F(e.deletedAt):"—"}),
|
|
72
72
|
/* @__PURE__ */D("td",{className:"px-3 h-8 text-right whitespace-nowrap",children:[
|
|
73
73
|
/* @__PURE__ */T("button",{onClick:()=>(async e=>{const t=await pe(`${S}/api/trash/restore`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({id:e.id})});if(!t.ok){const e=await t.json().catch(()=>({}));return void y.error(e.error||`Restore failed (${t.status})`)}y.success(`Restored "${e.name}"`),xe()})(e),className:"px-2 py-0.5 rounded hover:bg-gray-200 text-blue-600 text-2xs",children:"Restore"}),
|
|
74
|
-
/* @__PURE__ */T("button",{onClick:()=>(async e=>{if(!await g({title:"Permanently delete",message:`"${e.name}" will be permanently removed. This can't be undone.`,confirmLabel:"Delete forever",variant:"danger"}))return;const t=await pe(`${S}/api/trash/${encodeURIComponent(e.id)}`,{method:"DELETE"});if(!t.ok){const e=await t.json().catch(()=>({}));return void y.error(e.error||`Delete failed (${t.status})`)}xe()})(e),className:"px-2 py-0.5 rounded hover:bg-red-100 text-red-600 text-2xs ml-1",children:"Delete forever"})]})]},e.id))})]}):K&&0===O.length?/* @__PURE__ */T(w,{size:"sm",padding:"p-6",label:"Loading"}):0===O.length?/* @__PURE__ */D("div",{className:"p-10 text-center text-sm text-gray-400",children:["Empty folder.",!
|
|
74
|
+
/* @__PURE__ */T("button",{onClick:()=>(async e=>{if(!await g({title:"Permanently delete",message:`"${e.name}" will be permanently removed. This can't be undone.`,confirmLabel:"Delete forever",variant:"danger"}))return;const t=await pe(`${S}/api/trash/${encodeURIComponent(e.id)}`,{method:"DELETE"});if(!t.ok){const e=await t.json().catch(()=>({}));return void y.error(e.error||`Delete failed (${t.status})`)}xe()})(e),className:"px-2 py-0.5 rounded hover:bg-red-100 text-red-600 text-2xs ml-1",children:"Delete forever"})]})]},e.id))})]}):K&&0===O.length?/* @__PURE__ */T(w,{size:"sm",padding:"p-6",label:"Loading"}):0===O.length?/* @__PURE__ */D("div",{className:"p-10 text-center text-sm text-gray-400",children:["Empty folder.",!I&&/* @__PURE__ */D(R,{children:[" Drop files here or click ",
|
|
75
75
|
/* @__PURE__ */T("span",{className:"font-medium",children:"Upload"}),"."]})]}):/* @__PURE__ */D("table",{className:"w-full text-sm",children:[
|
|
76
76
|
/* @__PURE__ */T("thead",{className:"bg-surface-sunken text-2xs uppercase tracking-wide text-ink-faint",children:/* @__PURE__ */D("tr",{children:[
|
|
77
77
|
/* @__PURE__ */T("th",{className:`${v} text-left font-medium px-3 h-8`,children:"Name"}),
|
|
78
78
|
/* @__PURE__ */T("th",{className:`${v} text-right font-medium px-3 h-8 w-24`,children:"Size"}),
|
|
79
79
|
/* @__PURE__ */T("th",{className:`${v} text-right font-medium px-3 h-8 w-40`,children:"Modified"}),
|
|
80
80
|
/* @__PURE__ */T("th",{className:`${v} w-32`})]})}),
|
|
81
|
-
/* @__PURE__ */T("tbody",{children:O.map(t=>/* @__PURE__ */D("tr",{onClick:()=>
|
|
81
|
+
/* @__PURE__ */T("tbody",{children:O.map(t=>/* @__PURE__ */D("tr",{onClick:()=>Q(t.name),onDoubleClick:()=>{"folder"===t.kind?M(P(A,t.name)):(async t=>{if(I)return;const a=P(A,t.name),n=(t.name.split(".").pop()||"").toLowerCase(),r=U[n];r?await e({filePath:a,filename:t.name,kind:r,onStaged:e=>de(e)}):ge(t)})(t)},className:"cursor-default border-b border-gray-100 "+(B===t.name?"bg-blue-50":"hover:bg-gray-50"),children:[
|
|
82
82
|
/* @__PURE__ */D("td",{className:"px-3 h-8 flex items-center gap-2",children:["folder"===t.kind?/* @__PURE__ */T(N,{name:"folder",look:"solid",className:"h-4 w-4 text-amber-500 shrink-0"}):/* @__PURE__ */T(N,{name:"page",className:"h-4 w-4 text-ink-faintest shrink-0",strokeWidth:1.5}),
|
|
83
83
|
/* @__PURE__ */T("span",{className:"truncate",title:t.name,children:t.name})]}),
|
|
84
84
|
/* @__PURE__ */T("td",{className:"px-3 h-8 text-right tabular-nums text-ink-faint",children:"folder"===t.kind?"—":n(t.size)}),
|
|
85
85
|
/* @__PURE__ */T("td",{className:"px-3 h-8 text-right text-ink-faint tabular-nums",children:F(t.modifiedAt)}),
|
|
86
|
-
/* @__PURE__ */T("td",{className:"px-3 h-8 text-right whitespace-nowrap",children:!
|
|
87
|
-
/* @__PURE__ */T("button",{onClick:e=>{e.stopPropagation(),(async e=>{const t=await k({title:`Rename ${e.kind}`,defaultValue:e.name,confirmLabel:"Rename"});if(!t||t===e.name)return;if(/[\\/]/.test(t))return void y.error("Names cannot contain slashes");const a=P(
|
|
88
|
-
/* @__PURE__ */T("button",{onClick:e=>{e.stopPropagation(),(async e=>{if(!await g({title:`Delete ${e.kind}`,message:`"${e.name}"${"folder"===e.kind?" and everything inside":""} will be permanently removed.`,confirmLabel:"Delete",variant:"danger"}))return;const t=P(
|
|
86
|
+
/* @__PURE__ */T("td",{className:"px-3 h-8 text-right whitespace-nowrap",children:!I&&/* @__PURE__ */D(R,{children:["file"===t.kind&&/* @__PURE__ */T("button",{onClick:e=>{e.stopPropagation(),ge(t)},className:"px-2 py-0.5 rounded hover:bg-gray-200 text-ink-faint text-2xs",children:"Download"}),
|
|
87
|
+
/* @__PURE__ */T("button",{onClick:e=>{e.stopPropagation(),(async e=>{const t=await k({title:`Rename ${e.kind}`,defaultValue:e.name,confirmLabel:"Rename"});if(!t||t===e.name)return;if(/[\\/]/.test(t))return void y.error("Names cannot contain slashes");const a=P(A,e.name),n=P(A,t),r=await pe(`${S}/api/rename`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({from:a,to:n})});if(!r.ok){const e=await r.json().catch(()=>({}));return void y.error(e.error||`Rename failed (${r.status})`)}fe(A)})(t)},className:"px-2 py-0.5 rounded hover:bg-gray-200 text-ink-faint text-2xs ml-1",children:"Rename"}),
|
|
88
|
+
/* @__PURE__ */T("button",{onClick:e=>{e.stopPropagation(),(async e=>{if(!await g({title:`Delete ${e.kind}`,message:`"${e.name}"${"folder"===e.kind?" and everything inside":""} will be permanently removed.`,confirmLabel:"Delete",variant:"danger"}))return;const t=P(A,e.name),a=await pe(`${S}/api/files?path=${encodeURIComponent(t)}`,{method:"DELETE"});if(!a.ok){const e=await a.json().catch(()=>({}));return void y.error(e.error||`Delete failed (${a.status})`)}fe(A)})(t)},className:"px-2 py-0.5 rounded hover:bg-red-100 text-red-600 text-2xs ml-1",children:"Delete"})]})})]},t.name))})]})})]})})}),_&&/* @__PURE__ */T("div",{className:"absolute inset-0 bg-blue-500/15 border-4 border-dashed border-blue-500 pointer-events-none flex items-center justify-center z-20",children:/* @__PURE__ */T("div",{className:"px-4 py-2 rounded-md bg-blue-600 text-white text-sm font-medium shadow-lg",children:"Drop to upload"})})]})}export{S as default};
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import{getNumberingConfigs as e}from"./chunk-NVD4AI5Y.js";import{SidebarLayout as t}from"./chunk-XCHAU2UN.js";import"./chunk-QWK6DRSN.js";import"./chunk-5QGBVTGS.js";import{timeAgo as r}from"./chunk-GEYM4WN3.js";import"./chunk-Y3JW2GW5.js";import"./chunk-36BRD5J3.js";import"./chunk-LF27WIN2.js";import{AboutApp as n}from"./chunk-
|
|
2
|
-
/* @__PURE__ */x("div",{className:"p-2 border-b border-gray-200",children:/* @__PURE__ */h("button",{onClick:()=>{$&&
|
|
1
|
+
import{getNumberingConfigs as e}from"./chunk-NVD4AI5Y.js";import{SidebarLayout as t}from"./chunk-XCHAU2UN.js";import"./chunk-QWK6DRSN.js";import"./chunk-5QGBVTGS.js";import{timeAgo as r}from"./chunk-GEYM4WN3.js";import"./chunk-Y3JW2GW5.js";import"./chunk-36BRD5J3.js";import"./chunk-LF27WIN2.js";import{AboutApp as n}from"./chunk-GNNY35U6.js";import{useWindowManager as o,client_default as i}from"./chunk-2YSGXZOL.js";import"./chunk-CY5N5OA3.js";import"./chunk-AW7TOB6N.js";import"./chunk-KNUR2UEG.js";import"./chunk-JDCM2VHG.js";import"./chunk-QYL26AB4.js";import"./chunk-ZDMZM7HD.js";import"./chunk-5A7MWTXX.js";import"./chunk-2E2SUEEE.js";import"./chunk-PLK2WHZG.js";import"./chunk-7INZ7O3A.js";import{useShellPrefs as c}from"./chunk-KC3EX26K.js";import"./chunk-FOFZI62F.js";import"./chunk-3DVNXNTF.js";import"./chunk-ECJKIPWU.js";import"./chunk-VWGWZY7A.js";import"./chunk-7QSDPSXP.js";import{toast_default as s}from"./chunk-7ELJQL7J.js";import"./chunk-UGTRSRIW.js";import"./chunk-EPY34L26.js";import"./chunk-CDAJKLGL.js";import"./chunk-VNKAIEJ6.js";import"./chunk-4WEFGKJL.js";import"./chunk-URHGHXDN.js";import"./chunk-5QFPTDQF.js";import"./chunk-TXDA7TTP.js";import"./chunk-I4VIEGCX.js";import"./chunk-UQYNPYF4.js";import"./chunk-34URULVW.js";import{Icon as l}from"./chunk-2UO47XB4.js";import"./chunk-J75ZT2JQ.js";import"./chunk-R2VKEMZH.js";import"./chunk-MRJKZWWV.js";import"./chunk-MVZRZTQP.js";import"./chunk-6XBWM453.js";import"./chunk-PGN5ME7B.js";import"./chunk-62LW225J.js";import"./chunk-GLUJS42B.js";import"./chunk-D65T4H6J.js";import"./chunk-F27JJHNJ.js";import"./chunk-TWVUQUUD.js";import"./chunk-GDQJBQ5B.js";import"./chunk-C3QOHMR6.js";import{useRef as a,useEffect as p,useState as d,useCallback as m}from"react";import{useQuery as u}from"@tanstack/react-query";import{jsxs as h,Fragment as g,jsx as x}from"react/jsx-runtime";var y=[{key:"yellow",bg:"bg-yellow-100",border:"border-yellow-300",text:"text-yellow-900",dot:"bg-yellow-400"},{key:"blue",bg:"bg-blue-100",border:"border-blue-300",text:"text-blue-900",dot:"bg-blue-400"},{key:"green",bg:"bg-green-100",border:"border-green-300",text:"text-green-900",dot:"bg-green-400"},{key:"pink",bg:"bg-pink-100",border:"border-pink-300",text:"text-pink-900",dot:"bg-pink-400"},{key:"purple",bg:"bg-purple-100",border:"border-purple-300",text:"text-purple-900",dot:"bg-purple-400"},{key:"orange",bg:"bg-orange-100",border:"border-orange-300",text:"text-orange-900",dot:"bg-orange-400"},{key:"white",bg:"bg-white",border:"border-gray-300",text:"text-gray-900",dot:"bg-gray-300"}];var k={sales_order:{entityType:"order",endpoint:"/orders/sales-orders/"},purchase_order:{entityType:"purchase_order",endpoint:"/purchase-orders/"},invoice:{entityType:"invoice",endpoint:"/invoicing/invoices/"},vendor_invoice:{entityType:"vendor_invoice",endpoint:"/invoicing/vendor-invoices/"},shipment:{entityType:"shipment",endpoint:"/shipments/delivery-notes/"},receipt:{entityType:"payment",endpoint:"/invoicing/payments/"},vendor_payment:{entityType:"vendor_payment",endpoint:"/invoicing/vendor-payments/"},vendor_price_sheet:{entityType:"vendor_price_sheet",endpoint:"/pricing/manufacturer-price-sheets/"},client_price_sheet:{entityType:"price_sheet",endpoint:"/pricing/price-sheets/"},qc_report:{entityType:"qc_report",endpoint:"/qc-reports/"},warranty_claim:{entityType:"warranty_claim",endpoint:"/warranty-claims/claims/"},vendor_shipment:{entityType:"vendor_shipment",endpoint:"/shipments/goods-receipts/"}},b=/\[([ xX]?)\]/g;function f(){const{openEntity:f}=o(),{prefs:N,save:j}=c(),{data:v}=u({queryKey:["numbering-configs"],queryFn:()=>e(),retry:!1}),w=a({});p(()=>{if(!v)return;const e={};for(const t of v){const r=k[t.entity_type];if(!r)continue;const n=(t.prefix||"").replace("#","").toUpperCase();if(n&&(e[n]={...r,prefix:t.prefix}),t.alt_prefix){const n=t.alt_prefix.replace("#","").toUpperCase();n&&(e[n]={...r,prefix:t.alt_prefix})}}w.current=e},[v]);const T=N.notepad_notes||[],[_,W]=d(null),[C,U]=d(""),[D,J]=d(""),[S,X]=d("yellow"),[$,E]=d(!1),[G,I]=d(!1),L=a(null),Q=a();p(()=>{if(!_&&T.length>0){const e=T[0];W(e.id),U(e.title),J(e.content),X(e.color)}},[T.length]);const K=m(e=>{j({notepad_notes:e})},[j]),O=m(()=>{if(!_||!$)return;const e=T.map(e=>e.id===_?{...e,title:C,content:D,color:S,updated_at:/* @__PURE__ */(new Date).toISOString()}:e);K(e),E(!1)},[_,$,C,D,S,T,K]);p(()=>{if($)return Q.current&&clearTimeout(Q.current),Q.current=setTimeout(O,800),()=>{Q.current&&clearTimeout(Q.current)}},[$,O]),p(()=>()=>{$&&O()},[]);const V=e=>{$&&O(),W(e.id),U(e.title),J(e.content),X(e.color),E(!1),I(!1)},Z=e=>{const t=D.slice(0,e),r=D.slice(e).match(/^\[([ xX]?)\]/);if(!r)return;const n="x"===r[1]||"X"===r[1]?"[ ]":"[x]",o=D.slice(e+r[0].length);J(t+n+o),E(!0)},A=async(e,t)=>{const r=w.current[e];if(!r)return;const n=`${e}#${t}`;try{const{data:e}=await i.get(r.endpoint,{params:{search:n,page_size:1}}),t=(e?.results??e??[])[0];t?f(r.entityType,t.id,t,n):s.error(`${n} not found`)}catch{s.error(`Failed to look up ${n}`)}},F="Start writing...\n\nTips:\n [] Type [] for a checkbox, click to toggle\n SO#35001 Type XX#NNNNN to link entities (SO, PO, CI, VI, PL, etc.)",M=/* @__PURE__ */h(g,{children:[
|
|
2
|
+
/* @__PURE__ */x("div",{className:"p-2 border-b border-gray-200",children:/* @__PURE__ */h("button",{onClick:()=>{$&&O();const e={id:`note-${Date.now()}-${Math.random().toString(36).slice(2,6)}`,title:"",content:"",color:"yellow",updated_at:/* @__PURE__ */(new Date).toISOString()},t=[e,...T];K(t),W(e.id),U(""),J(""),X("yellow"),E(!1),I(!0),setTimeout(()=>L.current?.focus(),50)},className:"w-full flex items-center justify-center gap-2 rounded-lg bg-accent-fill text-on-accent px-3 min-h-8 py-1 text-sm font-medium hover:bg-accent-fill-hover transition-colors",children:[
|
|
3
3
|
/* @__PURE__ */x(l,{name:"add",className:"h-4 w-4",strokeWidth:2}),"New Note"]})}),
|
|
4
4
|
/* @__PURE__ */x("div",{className:"flex-1 overflow-y-auto",children:0===T.length?/* @__PURE__ */x("p",{className:"text-sm text-gray-400 text-center py-8 px-4",children:"No notes yet. Create one to get started."}):T.map(e=>{const t=(n=e.color,y.find(e=>e.key===n)||y[0]);var n;/* @__PURE__ */
|
|
5
|
-
return h("button",{onClick:()=>
|
|
5
|
+
return h("button",{onClick:()=>V(e),className:"w-full text-left px-3 py-3 border-b border-line-subtle transition-colors "+(_===e.id?"bg-accent-tint":"hover:bg-row-hover"),children:[
|
|
6
6
|
/* @__PURE__ */h("div",{className:"flex items-center gap-2",children:[
|
|
7
7
|
/* @__PURE__ */x("div",{className:`w-3 h-3 rounded-full shrink-0 ${t.dot}`}),
|
|
8
8
|
/* @__PURE__ */x("span",{className:"text-sm font-medium text-gray-900 truncate flex-1",children:e.title||"Untitled"})]}),
|
|
@@ -10,12 +10,12 @@ return h("button",{onClick:()=>O(e),className:"w-full text-left px-3 py-3 border
|
|
|
10
10
|
/* @__PURE__ */x("p",{className:"text-2xs text-gray-300 mt-0.5 ml-5",children:r(e.updated_at)})]},e.id)})})]});/* @__PURE__ */
|
|
11
11
|
return h("div",{className:"h-full",children:[
|
|
12
12
|
/* @__PURE__ */x(n,{app:"notepad"}),
|
|
13
|
-
/* @__PURE__ */x(t,{sidebar:
|
|
13
|
+
/* @__PURE__ */x(t,{sidebar:M,storageKey:"notepad.sidebarWidth",defaultWidth:224,minWidth:180,maxWidth:360,children:_?/* @__PURE__ */h("div",{className:"flex-1 flex flex-col min-w-0",children:[
|
|
14
14
|
/* @__PURE__ */h("div",{className:"flex items-center gap-2 px-4 py-2 border-b border-gray-200",children:[
|
|
15
|
-
/* @__PURE__ */x("input",{value:C,onChange:e=>{
|
|
16
|
-
/* @__PURE__ */x("div",{className:"flex gap-1",children:y.map(e=>/* @__PURE__ */x("button",{onClick:()=>{X(e.key),E(!0)},className:`w-5 h-5 rounded-full border-2 transition-all ${e.dot} ${
|
|
17
|
-
/* @__PURE__ */x("button",{onClick:()=>(e=>{const t=T.filter(t=>t.id!==e);if(
|
|
18
|
-
return x("div",{className:p?"line-through text-gray-400":"",children:n},r)})})(
|
|
15
|
+
/* @__PURE__ */x("input",{value:C,onChange:e=>{U(e.target.value),E(!0)},placeholder:"Note title...",className:"flex-1 text-lg font-semibold text-gray-900 outline-none bg-transparent placeholder:text-gray-300"}),
|
|
16
|
+
/* @__PURE__ */x("div",{className:"flex gap-1",children:y.map(e=>/* @__PURE__ */x("button",{onClick:()=>{X(e.key),E(!0)},className:`w-5 h-5 rounded-full border-2 transition-all ${e.dot} ${S===e.key?"border-gray-600 scale-110":"border-transparent hover:border-gray-400"}`,title:e.key},e.key))}),
|
|
17
|
+
/* @__PURE__ */x("button",{onClick:()=>(e=>{const t=T.filter(t=>t.id!==e);if(K(t),_===e){const e=t[0];e?V(e):(W(null),U(""),J(""))}})(_),title:"Delete note",className:"p-1 rounded text-gray-300 hover:text-red-500 transition-colors",children:/* @__PURE__ */x(l,{name:"trash",className:"h-4 w-4",strokeWidth:1.5})})]}),G?/* @__PURE__ */x("textarea",{ref:L,value:D,onChange:e=>{J(e.target.value),E(!0)},onBlur:()=>{I(!1),$&&O()},placeholder:F,className:"flex-1 p-4 text-sm text-gray-700 outline-none resize-none bg-transparent leading-relaxed placeholder:text-gray-300 font-mono"}):/* @__PURE__ */x("div",{onClick:()=>{I(!0),setTimeout(()=>L.current?.focus(),50)},className:"flex-1 p-4 text-sm text-gray-700 overflow-y-auto leading-relaxed cursor-text",children:D?(e=>{if(!e)return[];const t=e.split("\n");return t.map((e,r)=>{const n=[];let o=0;const i=[],c=/([A-Z]{2,4})#(\d{4,6})/g;let s;for(;null!==(s=c.exec(e));){const e=s[1],t=s[2];if(w.current[e]){const n=s.index,o=s[0];i.push({idx:n,len:o.length,render:()=>/* @__PURE__ */x("button",{onClick:()=>A(e,t),className:"text-blue-600 hover:text-blue-800 hover:underline font-medium cursor-pointer",children:o},`ref-${r}-${n}`)})}}b.lastIndex=0;let a=0;for(let e=0;e<r;e++)a+=t[e].length+1;for(;null!==(s=b.exec(e));){const e="x"===s[1]||"X"===s[1],t=s.index,n=a+t;i.push({idx:t,len:s[0].length,render:()=>/* @__PURE__ */x("button",{onClick:()=>Z(n),className:`inline-flex items-center justify-center w-4 h-4 rounded border ${e?"bg-blue-500 border-blue-500 text-white":"border-gray-400 bg-white hover:border-blue-400"} cursor-pointer align-text-bottom mr-0.5`,children:e&&/* @__PURE__ */x(l,{name:"check",className:"w-3 h-3",strokeWidth:3})},`cb-${r}-${t}`)})}i.sort((e,t)=>e.idx-t.idx);for(const t of i)t.idx>o&&n.push(/* @__PURE__ */x("span",{children:e.slice(o,t.idx)},`t-${r}-${o}`)),n.push(t.render()),o=t.idx+t.len;o<e.length&&n.push(/* @__PURE__ */x("span",{children:e.slice(o)},`t-${r}-${o}`)),0===n.length&&n.push(/* @__PURE__ */x("span",{children:""},`empty-${r}`));const p=/^\[x\]/i.test(e.trimStart());/* @__PURE__ */
|
|
18
|
+
return x("div",{className:p?"line-through text-gray-400":"",children:n},r)})})(D):/* @__PURE__ */x("p",{className:"text-gray-300 whitespace-pre-line",children:F})}),
|
|
19
19
|
/* @__PURE__ */h("div",{className:"px-4 min-h-8 py-1 border-t border-line-subtle flex items-center gap-4 text-2xs text-ink-faintest",children:[
|
|
20
20
|
/* @__PURE__ */x("span",{children:"[] checkbox"}),
|
|
21
21
|
/* @__PURE__ */x("span",{children:"SO#35001 entity link"}),
|