efficient-shell 4.149.0 → 4.150.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/README.md +1 -0
- package/dist/{Browser-X7A3FHG7.js → Browser-6DPP4K2O.js} +10 -10
- package/dist/{Documents-UGRUMAU6.js → Documents-LDCCZRKT.js} +10 -10
- package/dist/{Files-2QJVZTEH.js → Files-QUAXBRVO.js} +28 -28
- package/dist/{Notepad-RPB76OQY.js → Notepad-CYFDC4FM.js} +10 -10
- package/dist/{Preview-BNEOTMJL.js → Preview-GZP7YTW3.js} +13 -13
- package/dist/{Spreadsheet-XWOKXVPA.js → Spreadsheet-MXNEADWG.js} +12 -12
- package/dist/apps/index.js +1 -1
- package/dist/chunk-BJVY3LPW.js +1 -0
- package/dist/{chunk-ZSDLYYQA.js → chunk-IQVJ3C3D.js} +1 -1
- package/dist/{chunk-IH3W7GR5.js → chunk-SWU7CXZB.js} +416 -416
- package/dist/{index-BMISANa_.d.ts → index-DQ52lM8L.d.ts} +19 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js +32 -32
- package/dist/ui/index.d.ts +1 -1
- package/dist/ui/index.js +1 -1
- package/package.json +1 -1
- package/dist/chunk-2Q3T5CT3.js +0 -1
package/README.md
CHANGED
|
@@ -498,6 +498,7 @@ All exports are named — `import { Modal, ... } from 'efficient-shell'`.
|
|
|
498
498
|
| `SettingRow` | One setting: its name and current value on one baseline, the explanation at full width beneath in a smaller voice. The value never shrinks, so a short badge keeps its line instead of folding into a narrow column. Handles a value that is a control (`controlId` labels it), a read-only fact, a value nobody knows (an em dash in the faint ink, never an empty cell), and a `quiet` row nothing can write yet. `DescriptionList` is the record-detail neighbour and stays that. |
|
|
499
499
|
| `Button`, `Input`, `Textarea`, `Select`, `Checkbox`, `Radio`, `Switch`, `FormField`, `Label` | Form controls — controlled (`value`/`onChange`); `Input`/`Textarea` forward native props for react-hook-form. `Button` and `Switch` take `disabledReason`: persistent text beside the control wired with `aria-describedby`, never a `title` — a tooltip needs a hover a disabled control does not reliably get. `Switch` also takes `disabledReasonId`, so a panel whose controls are all dead for one reason states it once and points every control at it. A `Select` option carries an optional `description`, rendered as a second muted line **in the open list only** — the closed trigger stays one line, so one explained option cannot change the height of every field in the row. `NativeSelect` (and so `Select` on touch) ignores it: an `<option>` holds text and nothing else. An option also takes `lang` (a BCP 47 tag) when its label is written in another language than the page's — a language picker naming each language in its own words: it goes on the option in the open list, on the native `<option>` and on the closed trigger's label while chosen, so a screen reader and the font fallback treat each name as its own language (WCAG 3.1.2). On the desktop listbox, `title` joins `aria-label` / `aria-labelledby` / `aria-describedby` on the VISIBLE trigger button — it used to ride the native spread onto the `sr-only` `<select>`, where a tooltip has no pointer that can reach it and a fallback name sits on an `aria-hidden` element. `name`, `required` and the forwarded ref stay on the native control, which is what it is for. A `Checkbox` or `Radio` with both a `label` and a `description` is NAMED by the label and DESCRIBED by the description (`aria-labelledby` / `aria-describedby`); the whole row is still its `<label>`, so its words still tick it. |
|
|
500
500
|
| `buttonClasses`, `iconButtonClasses` | `Button`'s and `IconButton`'s look as a class string, for something that must navigate and so cannot be a `<button>`: `<Link href="/organisations/new" className={buttonClasses({ variant: 'secondary' })}>Add a business</Link>`. Same options and defaults as the component (`variant`, `size`, `block`, `className`), and the components render through these functions, so the two cannot drift. What the string cannot give an `<a>`: a disabled state (`disabled:` never matches an anchor — drop the `href`, add `role="link"` and `aria-disabled="true"`, or render a disabled `Button`), and the cursor (an `<a href>` gets the browser's pointer, a `<button>` the host's preflight; set it once for both). Keep its `inline-flex` — ask for `block` rather than passing a display utility. An icon-only link still needs the `aria-label` `IconButton` would have required. Client references, like every kit function: call them in a `'use client'` file. |
|
|
501
|
+
| `labelClasses` | `Label`'s look as a class string, for a `<label>` a host lays out itself — beside a check box, in a row with its control, `sr-only`: `<label htmlFor="x" className={labelClasses({ inline: true, className: 'flex gap-2' })}>`. `inline: true` drops `Label`'s block layout (`mb-1 block`) and keeps its size, weight and ink; without it the string is exactly what `Label` renders. A client reference: call it in a `'use client'` file. |
|
|
501
502
|
| `Segmented` | A row of mutually exclusive options, all visible: a button group, or with `name` a real radio group that submits. Named by `label`, or by an element already on the page (`aria-labelledby`, a list row's own heading) and described by another (`aria-describedby`); an option's `title` says on hover what choosing it means. |
|
|
502
503
|
| `RadioGroup` | One choice from a short visible list, with the group chrome each panel used to rebuild: a `role="radiogroup"` named by its own label (`aria-labelledby`, because `<label for>` cannot name a div), the `hint`/`error`/`required` wiring borrowed from `FormField`, and `orientation` for a row that wraps rather than compresses. The options are real native radios sharing one `name`, which is what gives the group its arrow keys, its disabled-skipping and its single tab stop — all from the user agent, none of it hand-rolled. `value: null` is "nothing chosen yet", not a silent first option. |
|
|
503
504
|
| `Snippet` | A value the user copies rather than reads — an endpoint, a tenant id, a shell command. Monospace, truncated with the whole value on its `title` (`multiline` wraps instead), and a copy button that flips to a check for two seconds and says "Copied" through an `aria-live` region. `value` is what reaches the clipboard and `children` is what is shown, so a masked key displays masked and copies whole. `symbol` prints a leading glyph that is never copied and has **no default** — a URL has no `$` in front of it. A refused clipboard toasts rather than looking like it worked. Not a read-only `Input`: a value that can only be copied is not a control and should not take a tab stop or invite an edit. `id` and `aria-describedby` land on the COPY BUTTON — the only focusable thing in the row, and a labelable one — so a wrapping `FormField` really does label it and its hint is really announced; with `hideCopyButton` they fall back to the box, because an id that resolves to nothing is not wiring. |
|
|
@@ -1,4 +1,4 @@
|
|
|
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-IQVJ3C3D.js";import"./chunk-BJVY3LPW.js";import{WindowTitle as r}from"./chunk-ET5HXDOR.js";import"./chunk-V453E4KU.js";import"./chunk-UB4JIOLD.js";import"./chunk-PH3PRIFP.js";import"./chunk-ZBIWNVJS.js";import{confirm as n}from"./chunk-QOXIUJTN.js";import"./chunk-57MIENLJ.js";import"./chunk-MAIHBBWT.js";import"./chunk-TR6PLN7W.js";import"./chunk-D65T4H6J.js";import{useRef as a,useEffect as i,useState as l}from"react";import{jsxs as s,jsx as c,Fragment as m}from"react/jsx-runtime";var d="react-os-shell:browser-bookmarks",u="react-os-shell:browser-homepage",h="https://en.wikipedia.org/wiki/Main_Page",p=[{label:"Wikipedia",url:"https://en.wikipedia.org/wiki/Main_Page"},{label:"DevDocs",url:"https://devdocs.io"},{label:"Example",url:"https://example.com"}],g=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 b(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&&g.has(t[2].toLowerCase())}(t)?"https://"+t:"https://duckduckgo.com/?q="+encodeURIComponent(t):""}var k=["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 f(){if("undefined"==typeof window)return p;try{const e=localStorage.getItem(d);if(!e)return p;const t=JSON.parse(e);if(Array.isArray(t)&&t.every(e=>"string"==typeof e?.url))return t}catch{}return p}function x(){return"undefined"==typeof window?h:localStorage.getItem(u)||h}function w(){const m=a(void 0);void 0===m.current&&(m.current=e()),i(()=>{null!=m.current&&t(m.current)},[]);const h=m.current?b(m.current.url):"",[p,g]=l(x),[k,w]=l(h||p),[N,L]=l(k),[C,j]=l([k]),[z,M]=l(0),[W,B]=l(0),[R,H]=l(f),[S,E]=l(!1),[I,A]=l(null),D=a(null),T=a(null);i(()=>{try{localStorage.setItem(d,JSON.stringify(R))}catch{}},[R]);const P=e=>{const t=b(e);t&&(w(t),L(t),j(e=>{const o=e.slice(0,z+1);return o.push(t),o}),M(e=>e+1),E(!1))},J=()=>{"undefined"!=typeof window&&window.open(k,"_blank","noopener,noreferrer")},O=()=>{const e=I?.trim();e?(H(t=>[...t,{label:e,url:k}]),A(null)):A(null)};i(()=>{if(null===I)return;D.current?.focus(),D.current?.select();const e=e=>{const t=e.target;t?.closest("[data-bookmark-popover]")||A(null)},t=setTimeout(()=>document.addEventListener("mousedown",e),0);return()=>{clearTimeout(t),document.removeEventListener("mousedown",e)}},[null!==I]);const U=e=>{H(t=>t.filter((t,o)=>o!==e))},V=z>0,q=z<C.length-1,F=R.some(e=>e.url===k),$="p-1.5 rounded hover:bg-gray-200 transition-colors text-gray-600 disabled:opacity-30";/* @__PURE__ */
|
|
2
2
|
return s("div",{className:"relative flex flex-col h-full bg-white",children:[
|
|
3
3
|
/* @__PURE__ */c(r,{title:`Browser - ${v(k)}`}),
|
|
4
4
|
/* @__PURE__ */c(o,{app:"browser"}),
|
|
@@ -6,24 +6,24 @@ return s("div",{className:"relative flex flex-col h-full bg-white",children:[
|
|
|
6
6
|
/* @__PURE__ */c("button",{onClick:()=>{if(z>0){const e=z-1;M(e),w(C[e]),L(C[e]),E(!1)}},disabled:!V,className:$,title:"Back",children:/* @__PURE__ */c("svg",{className:"h-4 w-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:/* @__PURE__ */c("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M15.75 19.5L8.25 12l7.5-7.5"})})}),
|
|
7
7
|
/* @__PURE__ */c("button",{onClick:()=>{if(z<C.length-1){const e=z+1;M(e),w(C[e]),L(C[e]),E(!1)}},disabled:!q,className:$,title:"Forward",children:/* @__PURE__ */c("svg",{className:"h-4 w-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:/* @__PURE__ */c("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M8.25 4.5l7.5 7.5-7.5 7.5"})})}),
|
|
8
8
|
/* @__PURE__ */c("button",{onClick:()=>B(e=>e+1),className:$,title:"Refresh",children:/* @__PURE__ */c("svg",{className:"h-4 w-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.8,children:/* @__PURE__ */c("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M16.023 9.348h4.992V4.356M2.985 19.644v-4.992h4.992M3.05 9.348a9 9 0 0114.85-3.36L21.015 9.348m0 5.304a9 9 0 01-14.85 3.36l-3.115-3.36"})})}),
|
|
9
|
-
/* @__PURE__ */c("button",{onClick:()=>
|
|
10
|
-
/* @__PURE__ */c("form",{onSubmit:e=>{e.preventDefault(),
|
|
9
|
+
/* @__PURE__ */c("button",{onClick:()=>P(p),className:$,title:"Home",children:/* @__PURE__ */c("svg",{className:"h-4 w-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.8,children:/* @__PURE__ */c("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M2.25 12l8.954-8.955a1.5 1.5 0 012.122 0l8.954 8.955M4.5 9.75v10.125c0 .621.504 1.125 1.125 1.125H9.75v-4.875c0-.621.504-1.125 1.125-1.125h2.25c.621 0 1.125.504 1.125 1.125V21h4.125c.621 0 1.125-.504 1.125-1.125V9.75M8.25 21h8.25"})})}),
|
|
10
|
+
/* @__PURE__ */c("form",{onSubmit:e=>{e.preventDefault(),P(N)},className:"flex-1 flex items-center mx-1",children:/* @__PURE__ */s("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__ */c("span",{className:"px-2 text-gray-400 text-xs",children:k.startsWith("https://")?"🔒":"⚠️"}),
|
|
12
12
|
/* @__PURE__ */c("input",{type:"text",value:N,onChange:e=>L(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…"}),k!==N&&/* @__PURE__ */c("button",{type:"button",onClick:()=>L(k),className:"px-1.5 text-[10px] text-gray-400 hover:text-gray-700",title:"Reset to current URL",children:"×"})]})}),
|
|
13
|
-
/* @__PURE__ */c("button",{"data-bookmark-popover":!0,onClick:()=>F?
|
|
14
|
-
/* @__PURE__ */c("button",{onClick:
|
|
15
|
-
/* @__PURE__ */c("button",{onClick:()=>E(e=>!e),className:$,title:"Embedding help",children:/* @__PURE__ */c("svg",{className:"h-4 w-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.5,children:/* @__PURE__ */c("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M9.879 7.519c1.171-1.025 3.071-1.025 4.242 0 1.172 1.025 1.172 2.687 0 3.712-.203.179-.43.326-.67.442-.745.361-1.45.999-1.45 1.827v.75M21 12a9 9 0 11-18 0 9 9 0 0118 0zm-9 5.25h.008v.008H12v-.008z"})})})]}),null!==
|
|
13
|
+
/* @__PURE__ */c("button",{"data-bookmark-popover":!0,onClick:()=>F?U(R.findIndex(e=>e.url===k)):void A(v(k)),className:$+" "+(F?"text-yellow-500":""),title:F?"Remove bookmark":"Add bookmark",children:/* @__PURE__ */c("svg",{className:"h-4 w-4",fill:F?"currentColor":"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.5,children:/* @__PURE__ */c("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M11.48 3.499a.562.562 0 011.04 0l2.125 5.111a.563.563 0 00.475.345l5.518.442c.499.04.701.663.321.988l-4.204 3.602a.563.563 0 00-.182.557l1.285 5.385a.562.562 0 01-.84.61l-4.725-2.885a.563.563 0 00-.586 0L6.982 20.54a.562.562 0 01-.84-.61l1.285-5.386a.562.562 0 00-.182-.557l-4.204-3.602a.563.563 0 01.321-.988l5.518-.442a.563.563 0 00.475-.345L11.48 3.5z"})})}),
|
|
14
|
+
/* @__PURE__ */c("button",{onClick:J,className:$,title:"Open in new tab",children:/* @__PURE__ */c("svg",{className:"h-4 w-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.5,children:/* @__PURE__ */c("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M13.5 6H5.25A2.25 2.25 0 003 8.25v10.5A2.25 2.25 0 005.25 21h10.5A2.25 2.25 0 0018 18.75V10.5m-7.5-9L21 3m0 0v6m0-6L9.75 14.25"})})}),
|
|
15
|
+
/* @__PURE__ */c("button",{onClick:()=>E(e=>!e),className:$,title:"Embedding help",children:/* @__PURE__ */c("svg",{className:"h-4 w-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.5,children:/* @__PURE__ */c("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M9.879 7.519c1.171-1.025 3.071-1.025 4.242 0 1.172 1.025 1.172 2.687 0 3.712-.203.179-.43.326-.67.442-.745.361-1.45.999-1.45 1.827v.75M21 12a9 9 0 11-18 0 9 9 0 0118 0zm-9 5.25h.008v.008H12v-.008z"})})})]}),null!==I&&/* @__PURE__ */s("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__ */c("div",{className:"text-[11px] font-semibold uppercase tracking-wide text-gray-500 mb-1",children:"Bookmark this page"}),
|
|
17
17
|
/* @__PURE__ */c("div",{className:"text-[11px] text-gray-400 truncate mb-2 font-mono",title:k,children:k}),
|
|
18
|
-
/* @__PURE__ */c("input",{ref:
|
|
18
|
+
/* @__PURE__ */c("input",{ref:D,type:"text",value:I,onChange:e=>A(e.target.value),onKeyDown:e=>{"Enter"===e.key?O():"Escape"===e.key&&A(null)},placeholder:"Name",className:"w-full text-sm px-2 py-1.5 border border-gray-300 rounded focus:outline-none focus:border-blue-400 focus:ring-1 focus:ring-blue-200"}),
|
|
19
19
|
/* @__PURE__ */s("div",{className:"flex justify-end gap-1 mt-2",children:[
|
|
20
20
|
/* @__PURE__ */c("button",{onClick:()=>A(null),className:"px-2 py-1 text-xs text-gray-600 hover:bg-gray-100 rounded",children:"Cancel"}),
|
|
21
|
-
/* @__PURE__ */c("button",{onClick:
|
|
22
|
-
/* @__PURE__ */s("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===R.length&&/* @__PURE__ */c("span",{className:"text-[11px] text-gray-400 italic px-2",children:"No bookmarks yet — star the address bar to add one."}),R.map((e,t)=>/* @__PURE__ */s("button",{onClick:()=>
|
|
21
|
+
/* @__PURE__ */c("button",{onClick:O,disabled:!I.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__ */s("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===R.length&&/* @__PURE__ */c("span",{className:"text-[11px] text-gray-400 italic px-2",children:"No bookmarks yet — star the address bar to add one."}),R.map((e,t)=>/* @__PURE__ */s("button",{onClick:()=>P(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"})&&U(t)},className:"flex items-center gap-1.5 px-2 py-0.5 rounded text-[12px] text-gray-700 hover:bg-gray-100 whitespace-nowrap",title:`${e.url}\n(right-click to remove)`,children:[
|
|
23
23
|
/* @__PURE__ */c("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__ */c("div",{className:"flex-1"}),
|
|
25
25
|
/* @__PURE__ */c("button",{onClick:()=>{g(k);try{localStorage.setItem(u,k)}catch{}},className:"px-2 py-0.5 text-[11px] text-gray-500 hover:text-gray-800",title:"Set current page as homepage",children:"Set as home"})]}),
|
|
26
|
-
/* @__PURE__ */c("div",{className:"flex-1 relative min-h-0 bg-gray-50",children:/* @__PURE__ */c(y,{url:k,iframeKey:W,iframeRef:
|
|
26
|
+
/* @__PURE__ */c("div",{className:"flex-1 relative min-h-0 bg-gray-50",children:/* @__PURE__ */c(y,{url:k,iframeKey:W,iframeRef:T,openExternal:J,showHelp:S,dismissHelp:()=>E(!1)})})]})}function v(e){try{return new URL(e).hostname.replace(/^www\./,"")}catch{return e}}function y({url:e,iframeKey:t,iframeRef:o,openExternal:r,showHelp:n,dismissHelp:a}){const[d,u]=l(!1);i(()=>{u(!1)},[e]);return function(e){try{const t=new URL(e).hostname.toLowerCase();return k.some(e=>t===e||t.endsWith("."+e))}catch{return!1}}(e)&&!d?/* @__PURE__ */c("div",{className:"absolute inset-0 flex items-center justify-center bg-white p-8",children:/* @__PURE__ */s("div",{className:"max-w-md text-center",children:[
|
|
27
27
|
/* @__PURE__ */c("svg",{className:"h-14 w-14 mx-auto text-gray-300 mb-3",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.2,children:/* @__PURE__ */c("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M18.364 18.364A9 9 0 005.636 5.636m12.728 12.728L5.636 5.636m12.728 12.728L21 21M5.636 5.636L3 3m9 9a9 9 0 110-18 9 9 0 010 18z"})}),
|
|
28
28
|
/* @__PURE__ */s("h3",{className:"text-base font-semibold text-gray-800 mb-1",children:[v(e)," can't be embedded"]}),
|
|
29
29
|
/* @__PURE__ */s("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-BR22X7E5.js";import{AboutApp as t}from"./chunk-
|
|
1
|
+
import{escapeHtml as e}from"./chunk-BR22X7E5.js";import{AboutApp as t}from"./chunk-IQVJ3C3D.js";import{toast_default as n}from"./chunk-KKOHUQPF.js";import"./chunk-BJVY3LPW.js";import{WindowTitle as r}from"./chunk-ET5HXDOR.js";import"./chunk-V453E4KU.js";import"./chunk-UB4JIOLD.js";import"./chunk-PH3PRIFP.js";import{PopupMenu as o,PopupMenuLabel as l,PopupMenuItem as a,PopupMenuDivider as i}from"./chunk-ZBIWNVJS.js";import"./chunk-QOXIUJTN.js";import"./chunk-57MIENLJ.js";import"./chunk-MAIHBBWT.js";import"./chunk-TR6PLN7W.js";import"./chunk-D65T4H6J.js";import{useState as s,useRef as c}from"react";import{jsxs as d,jsx as h}from"react/jsx-runtime";var m=/* @__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"]),u=/* @__PURE__ */new Set(["docx"]),p={filename:"Untitled",kind:"docx",content:"",ext:"docx"};function g(){const[g,x]=s(p),[f,y]=s(!1),[v,b]=s(!1),[k,w]=s(!1),[N,C]=s(null),D=c(null),j=c(null),L=c(null),M=(e,t)=>{L.current?.focus(),document.execCommand(e,!1,t),w(!0)},U=e=>{for(const t of e){if(!t.type.startsWith("image/"))continue;const e=new FileReader;e.onload=()=>{L.current?.focus(),document.execCommand("insertImage",!1,String(e.result)),w(!0)},e.readAsDataURL(t)}},B=e=>{N&&(N.el.removeAttribute("width"),N.el.removeAttribute("height"),N.el.style.width=e??"",N.el.style.height=e?"auto":"",w(!0),C(null))},R=async t=>{const r=(t.name.split(".").pop()||"").toLowerCase();y(!0);try{if(m.has(r)||!u.has(r)&&t.type.startsWith("text/")){const n=await t.text(),o=e(n).replace(/\n/g,"<br>");x({filename:t.name,kind:"text",content:o,ext:r}),w(!1)}else if(u.has(r))try{const e=await(import(
|
|
2
2
|
/* @vite-ignore */
|
|
3
|
-
"mammoth")),n=await t.arrayBuffer(),o=await e.convertToHtml({arrayBuffer:n});x({filename:t.name,kind:"docx",content:o.value||"<p><em>(empty document)</em></p>",ext:r}),w(!1)}catch(e){n.error('Install the optional "mammoth" peer dep to read .docx files.')}else"doc"===r?n.error(".doc is the legacy Word binary format — convert to .docx first."):n.error(`Unsupported file type: .${r||"unknown"}`)}finally{y(!1)}},
|
|
4
|
-
return d("div",{className:"relative flex flex-col h-full",onDragOver:e=>{e.preventDefault(),v||b(!0)},onDragLeave:e=>{e.currentTarget===e.target&&b(!1)},onDrop:e=>{e.preventDefault(),b(!1);const t=Array.from(e.dataTransfer.files??[]);0!==t.length&&(t.every(e=>e.type.startsWith("image/"))?U(t):
|
|
5
|
-
/* @__PURE__ */h(r,{title:`${
|
|
3
|
+
"mammoth")),n=await t.arrayBuffer(),o=await e.convertToHtml({arrayBuffer:n});x({filename:t.name,kind:"docx",content:o.value||"<p><em>(empty document)</em></p>",ext:r}),w(!1)}catch(e){n.error('Install the optional "mammoth" peer dep to read .docx files.')}else"doc"===r?n.error(".doc is the legacy Word binary format — convert to .docx first."):n.error(`Unsupported file type: .${r||"unknown"}`)}finally{y(!1)}},I=g?.filename?(W=g.filename).length>24?`${W.slice(0,23)}…`:W:"Untitled";var W;/* @__PURE__ */
|
|
4
|
+
return d("div",{className:"relative flex flex-col h-full",onDragOver:e=>{e.preventDefault(),v||b(!0)},onDragLeave:e=>{e.currentTarget===e.target&&b(!1)},onDrop:e=>{e.preventDefault(),b(!1);const t=Array.from(e.dataTransfer.files??[]);0!==t.length&&(t.every(e=>e.type.startsWith("image/"))?U(t):R(t[0]))},children:[
|
|
5
|
+
/* @__PURE__ */h(r,{title:`${I}${k?" •":""} - Documents`}),
|
|
6
6
|
/* @__PURE__ */h(t,{app:"documents"}),
|
|
7
7
|
/* @__PURE__ */d("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__ */h("input",{ref:D,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__ */h("input",{ref:D,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&&R(t),D.current&&(D.current.value="")},className:"hidden"}),
|
|
9
9
|
/* @__PURE__ */d("button",{onClick:()=>D.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__ */h("svg",{className:"h-3.5 w-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.5,children:/* @__PURE__ */h("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M3.75 9.776c.112-.017.227-.026.344-.026h15.812c.117 0 .232.009.344.026m-16.5 0a2.25 2.25 0 00-1.883 2.542l.857 6a2.25 2.25 0 002.227 1.932H19.05a2.25 2.25 0 002.227-1.932l.857-6a2.25 2.25 0 00-1.883-2.542m-16.5 0V6A2.25 2.25 0 016 3.75h3.879a1.5 1.5 0 011.06.44l2.122 2.12a1.5 1.5 0 001.06.44H18A2.25 2.25 0 0120.25 9v.776"})}),"Open"]}),
|
|
11
11
|
/* @__PURE__ */h("button",{onClick:()=>{if(!g)return;const t=L.current?.innerHTML??"";if("text"===g.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(g.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=`${g.filename.replace(/\.[^.]+$/,"")}.html`,o.click(),URL.revokeObjectURL(r)}else{const e=L.current?.innerText??"",t=new Blob([e],{type:"text/plain"}),n=URL.createObjectURL(t),r=document.createElement("a");r.href=n,r.download=g.filename,r.click(),URL.revokeObjectURL(n)}}else{const n=new Blob([`<!doctype html><meta charset="utf-8"><title>${e(g.filename)}</title>${t}`],{type:"text/html"}),r=URL.createObjectURL(n),o=document.createElement("a");o.href=r,o.download=`${g.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"}),
|
|
@@ -43,10 +43,10 @@ return d("div",{className:"relative flex flex-col h-full",onDragOver:e=>{e.preve
|
|
|
43
43
|
/* @__PURE__ */h("svg",{className:"h-3.5 w-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.5,children:/* @__PURE__ */h("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M2.25 15.75l5.159-5.159a2.25 2.25 0 013.182 0l5.159 5.159m-1.5-1.5l1.409-1.409a2.25 2.25 0 013.182 0l2.909 2.909m-18 3.75h16.5a1.5 1.5 0 001.5-1.5V6a1.5 1.5 0 00-1.5-1.5H3.75A1.5 1.5 0 002.25 6v12a1.5 1.5 0 001.5 1.5zm10.5-11.25h.008v.008h-.008V8.25zm.375 0a.375.375 0 11-.75 0 .375.375 0 01.75 0z"})}),"Image"]})]}),
|
|
44
44
|
/* @__PURE__ */h("div",{className:"flex-1 min-h-0 overflow-hidden",children:/* @__PURE__ */h("div",f?{className:"flex items-center justify-center h-full text-sm text-gray-400",children:"Loading…"}:{className:"h-full overflow-auto "+("docx"===g.kind?"bg-gray-100 px-6 py-8":"bg-white"),children:/* @__PURE__ */h("div",{ref:L,contentEditable:!0,suppressContentEditableWarning:!0,spellCheck:!1,onInput:()=>w(!0),onPaste:e=>{const t=Array.from(e.clipboardData?.items??[]).filter(e=>"file"===e.kind&&e.type.startsWith("image/")).map(e=>e.getAsFile()).filter(e=>!!e);t.length&&(e.preventDefault(),U(t))},onClick:e=>{const t=e.target;"IMG"===t.tagName&&(e.preventDefault(),C({x:e.clientX,y:e.clientY,el:t}))},dangerouslySetInnerHTML:{__html:g.content},className:"docx"===g.kind?"docs-editor mx-auto w-[8.5in] min-h-[11in] bg-white p-[1in] shadow text-[14px] leading-relaxed text-gray-800 outline-none focus:ring-2 focus:ring-blue-400/40":"docs-editor block w-full min-h-full p-4 font-mono text-[13px] leading-relaxed text-gray-800 bg-white outline-none whitespace-pre-wrap"})})}),v&&/* @__PURE__ */h("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__ */h("div",{className:"px-4 py-2 rounded-md bg-blue-600 text-white text-sm font-medium shadow-lg",children:"Drop a document to open · images insert into the page"})}),N&&/* @__PURE__ */d(o,{minWidth:150,style:{left:N.x,top:N.y},onClose:()=>C(null),children:[
|
|
45
45
|
/* @__PURE__ */h(l,{children:"Image width"}),
|
|
46
|
-
/* @__PURE__ */h(a,{onClick:()=>
|
|
47
|
-
/* @__PURE__ */h(a,{onClick:()=>
|
|
48
|
-
/* @__PURE__ */h(a,{onClick:()=>
|
|
49
|
-
/* @__PURE__ */h(a,{onClick:()=>
|
|
50
|
-
/* @__PURE__ */h(a,{onClick:()=>
|
|
46
|
+
/* @__PURE__ */h(a,{onClick:()=>B("25%"),children:"25%"}),
|
|
47
|
+
/* @__PURE__ */h(a,{onClick:()=>B("50%"),children:"50%"}),
|
|
48
|
+
/* @__PURE__ */h(a,{onClick:()=>B("75%"),children:"75%"}),
|
|
49
|
+
/* @__PURE__ */h(a,{onClick:()=>B("100%"),children:"100%"}),
|
|
50
|
+
/* @__PURE__ */h(a,{onClick:()=>B(null),children:"Original size"}),
|
|
51
51
|
/* @__PURE__ */h(i,{}),
|
|
52
52
|
/* @__PURE__ */h(a,{danger:!0,onClick:()=>{N?.el.remove(),w(!0),C(null)},children:"Remove image"})]})]})}export{g as default};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{openPreviewFile as e}from"./chunk-4FS742BM.js";import{Breadcrumbs as t}from"./chunk-I55UMU3R.js";import{SidebarLayout as r}from"./chunk-SLCR26NK.js";import{getFilesDemoTree as a}from"./chunk-FHTLC7HH.js";import{AboutApp as n}from"./chunk-
|
|
1
|
+
import{openPreviewFile as e}from"./chunk-4FS742BM.js";import{Breadcrumbs as t}from"./chunk-I55UMU3R.js";import{SidebarLayout as r}from"./chunk-SLCR26NK.js";import{getFilesDemoTree as a}from"./chunk-FHTLC7HH.js";import{AboutApp as n}from"./chunk-IQVJ3C3D.js";import{peekFilesViewRequest as i,consumeFilesViewRequest as o,FILES_SHOW_TRASH_EVENT as s,FILES_OPEN_DESKTOP_FOLDER_EVENT as l,subscribeDesktopFolders as d,getDesktopFoldersSnapshot as c,FolderGlyph as m,DesktopItemMiniIcon as h,desktopItemTypeLabel as p}from"./chunk-NPJH5MD7.js";import"./chunk-ESL5TDNA.js";import{toast_default as u}from"./chunk-KKOHUQPF.js";import"./chunk-VTVSMRFX.js";import"./chunk-BJVY3LPW.js";import{useWindowManager as f,WindowTitle as x}from"./chunk-ET5HXDOR.js";import"./chunk-V453E4KU.js";import"./chunk-UB4JIOLD.js";import"./chunk-PH3PRIFP.js";import"./chunk-ZBIWNVJS.js";import{confirm as g,prompt as y}from"./chunk-QOXIUJTN.js";import"./chunk-57MIENLJ.js";import"./chunk-MAIHBBWT.js";import"./chunk-TR6PLN7W.js";import"./chunk-D65T4H6J.js";import{useState as b,useEffect as k,useSyncExternalStore as v,useRef as w,useCallback as N}from"react";import{jsxs as L,jsx as j,Fragment as C}from"react/jsx-runtime";var $="undefined"!=typeof window&&window.__REACT_OS_SHELL_FILE_SERVER__||"http://localhost:4000",M={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 D(e,t){return"/"===e||""===e?"/"+t:e.replace(/\/$/,"")+"/"+t}function T(e){if(!e)return"—";const t=["B","KB","MB","GB"];let r=e,a=0;for(;r>=1024&&a<t.length-1;)r/=1024,a++;return`${r<10?r.toFixed(1):Math.round(r)} ${t[a]}`}function E(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 R(){const R=$.replace(/\/$/,""),A=null!==a(),[B,P]=b("/"),[I,F]=b([]),[S,H]=b([]),[V,W]=b(null),[O,U]=b(!0),[z,J]=b(!1),[K,_]=b(null),[Q,X]=b(!1),[q,G]=b(()=>{const e=i();return"trash"===e?"trash":e?{desktopFolderId:e.folderId}:"files"});k(()=>{o()},[]);const[Y,Z]=b([]);k(()=>{const e=()=>{o(),G("trash")},t=e=>{o();const t=e.detail?.folderId;t&&G({desktopFolderId:t})};return window.addEventListener(s,e),window.addEventListener(l,t),()=>{window.removeEventListener(s,e),window.removeEventListener(l,t)}},[]);const ee=v(d,c,c),te="object"==typeof q?q.desktopFolderId:null,re=te?ee?.folders.find(e=>e.id===te)??null:null,ae=te&&ee?.itemsByFolder[te]||[];k(()=>{te&&ee&&!ee.folders.some(e=>e.id===te)&&G("files")},[te,ee]);const ne=w(0),ie=w(null),{openPage:oe,openEntity:se}=f(),le=t=>{"preview-file"===t.entityType&&t.filePath&&t.fileKind?e({filePath:t.filePath,filename:t.label,kind:t.fileKind,onStaged:e=>oe(e)}):"page"===t.entityType?oe(t.entityId):se(t.entityType,t.entityId,null,t.label)},de=N((e,t={})=>fetch(e,{...t,credentials:"include"}),[]),ce=N(async()=>{try{const e=await de(`${R}/api/quota`);if(e.ok){const t=await e.json();_({used:t.used,limit:t.limit})}}catch{}},[de,R]),me=N(async e=>{if(W(null),A){const t=function(e){const t=a();if(!t)return[];let r=t;for(const t of e.split("/").filter(Boolean)){const e=r.find(e=>"folder"===e.kind&&e.name===t);if(!e||!e.children)return[];r=e.children}return r.map(e=>({name:e.name,kind:e.kind,size:e.size??0,modifiedAt:e.modifiedAt??""}))}(e);return F(t),P(e),J(!1),U(!1),void("/"===e&&H(t.filter(e=>"folder"===e.kind).map(e=>e.name)))}U(!0);try{const t=await de(`${R}/api/files?path=${encodeURIComponent(e)}`);if(!t.ok){const e=await t.json().catch(()=>({}));return void u.error(e.error||`Failed to list (${t.status})`)}const r=await t.json(),a=r.entries||[];F(a),P(r.path||e),J(!1),"/"===(r.path||e)&&H(a.filter(e=>"folder"===e.kind).map(e=>e.name))}catch(e){J(!0)}finally{U(!1)}ce()},[de,R,ce,A]),he=N(async()=>{if(A)return Z([]),void U(!1);U(!0),W(null);try{const e=await de(`${R}/api/trash`);if(!e.ok){const t=await e.json().catch(()=>({}));return void u.error(t.error||`Failed to list trash (${e.status})`)}const t=await e.json();Z(t.entries||[]),J(!1)}catch{J(!0)}finally{U(!1)}ce()},[de,R,ce,A]);k(()=>{"files"===q?me(B):"trash"===q&&he()},[B,q]);const pe=async e=>{const t=D(B,e.name);try{const r=await de(`${R}/api/file?path=${encodeURIComponent(t)}`);if(!r.ok)return void u.error(`Download failed (${r.status})`);const a=await r.blob(),n=URL.createObjectURL(a),i=document.createElement("a");i.href=n,i.download=e.name,i.click(),setTimeout(()=>URL.revokeObjectURL(n),1e3)}catch(e){u.error(e?.message||"Download failed")}},ue=async e=>{const t=Array.from(e);for(const e of t){const t=new FormData;t.append("file",e);try{const r=await de(`${R}/api/upload?path=${encodeURIComponent(B)}`,{method:"POST",body:t});if(!r.ok){const t=await r.json().catch(()=>({}));if(413===r.status){const r=Math.max(0,(t.limit||0)-(t.used||0));u.error(`Quota exceeded — ${T(r)} free, ${e.name} is ${T(t.attempted||e.size)}`)}else u.error(`Upload ${e.name}: ${t.error||r.status}`)}}catch(t){u.error(`Upload ${e.name}: ${t?.message||"failed"}`)}}me(B)},fe=()=>{ne.current=0,X(!1)};if(k(()=>{const e=()=>fe();return window.addEventListener("dragend",e),window.addEventListener("drop",e),()=>{window.removeEventListener("dragend",e),window.removeEventListener("drop",e)}},[]),z)/* @__PURE__ */
|
|
2
2
|
return L("div",{className:"flex flex-col h-full bg-white",children:[
|
|
3
3
|
/* @__PURE__ */j(x,{title:"Files - offline"}),
|
|
4
4
|
/* @__PURE__ */j("div",{className:"flex-1 flex items-center justify-center p-8 text-center",children:/* @__PURE__ */L("div",{className:"max-w-md",children:[
|
|
@@ -7,49 +7,49 @@ return L("div",{className:"flex flex-col h-full bg-white",children:[
|
|
|
7
7
|
/* @__PURE__ */j("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M12 21a9 9 0 100-18 9 9 0 000 18z"})]}),
|
|
8
8
|
/* @__PURE__ */j("h3",{className:"text-base font-semibold text-gray-800 mb-1",children:"Can't reach the file server"}),
|
|
9
9
|
/* @__PURE__ */L("p",{className:"text-sm text-gray-500 mb-3",children:["No response from ",
|
|
10
|
-
/* @__PURE__ */j("span",{className:"font-mono",children:
|
|
10
|
+
/* @__PURE__ */j("span",{className:"font-mono",children:R}),". Make sure the server is running — see ",
|
|
11
11
|
/* @__PURE__ */j("span",{className:"font-mono",children:"examples/file-server/README.md"}),"."]}),
|
|
12
12
|
/* @__PURE__ */j("button",{onClick:()=>me(B),className:"px-3 py-1.5 text-sm bg-blue-500 text-white rounded hover:bg-blue-600",children:"Retry"})]})})]});const xe="/"===B?[]:B.split("/").filter(Boolean),ge=K&&K.limit>0?Math.min(100,Math.round(K.used/K.limit*100)):0,ye=ge>90?"bg-red-500":ge>75?"bg-amber-500":"bg-blue-500",be=[{label:"My files",onClick:()=>P("/")},...xe.map((e,t)=>({label:e,onClick:()=>P("/"+xe.slice(0,t+1).join("/"))}))],ke=e=>"flex w-full items-center gap-2 rounded-md px-2.5 py-1.5 text-left text-sm transition-colors "+(e?"bg-blue-50 font-medium text-blue-700":"text-gray-700 hover:bg-gray-100"),ve=e=>/* @__PURE__ */j("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__ */j("path",{strokeLinecap:"round",strokeLinejoin:"round",d:e})}),we=/* @__PURE__ */L("nav",{className:"p-2",children:[
|
|
13
13
|
/* @__PURE__ */j("div",{className:"px-2 py-1.5 text-[11px] font-semibold uppercase tracking-wide text-gray-400",children:"Locations"}),
|
|
14
|
-
/* @__PURE__ */L("button",{onClick:()=>{
|
|
15
|
-
/* @__PURE__ */j("span",{className:"truncate",children:e})]},e)),!
|
|
16
|
-
/* @__PURE__ */j("div",{className:"px-2 pt-3 pb-1.5 text-[11px] font-semibold uppercase tracking-wide text-gray-400",children:"Desktop"}),ee.folders.map(e=>/* @__PURE__ */L("button",{onClick:()=>
|
|
14
|
+
/* @__PURE__ */L("button",{onClick:()=>{G("files"),P("/")},className:ke("files"===q&&"/"===B),children:[ve("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"]}),S.map(e=>/* @__PURE__ */L("button",{onClick:()=>{G("files"),P("/"+e)},className:ke("files"===q&&B==="/"+e),children:[ve("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"),
|
|
15
|
+
/* @__PURE__ */j("span",{className:"truncate",children:e})]},e)),!A&&/* @__PURE__ */L("button",{onClick:()=>G("trash"),className:ke("trash"===q),children:[ve("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"]}),ee&&ee.folders.length>0&&/* @__PURE__ */L(C,{children:[
|
|
16
|
+
/* @__PURE__ */j("div",{className:"px-2 pt-3 pb-1.5 text-[11px] font-semibold uppercase tracking-wide text-gray-400",children:"Desktop"}),ee.folders.map(e=>/* @__PURE__ */L("button",{onClick:()=>G({desktopFolderId:e.id}),className:ke(te===e.id),children:[
|
|
17
17
|
/* @__PURE__ */j(m,{className:"h-4 w-4 shrink-0 text-amber-500"}),
|
|
18
18
|
/* @__PURE__ */j("span",{className:"truncate",children:e.name}),e.itemCount>0&&/* @__PURE__ */j("span",{className:"ml-auto text-[10px] text-gray-400 tabular-nums",children:e.itemCount})]},e.id))]})]});/* @__PURE__ */
|
|
19
|
-
return L("div",{className:"relative flex flex-col h-full bg-white",onDragEnter:e=>{
|
|
19
|
+
return L("div",{className:"relative flex flex-col h-full bg-white",onDragEnter:e=>{A||"object"==typeof q||e.dataTransfer?.types?.includes?.("Files")&&(e.preventDefault(),ne.current++,Q||X(!0))},onDragOver:e=>{e.dataTransfer?.types?.includes?.("Files")&&e.preventDefault()},onDragLeave:()=>{ne.current>0&&ne.current--,0===ne.current&&X(!1)},onDrop:e=>{e.preventDefault(),fe(),A||"object"==typeof q||e.dataTransfer.files?.length&&ue(e.dataTransfer.files)},children:[
|
|
20
20
|
/* @__PURE__ */j(x,{title:re?`Files - ${re.name}`:"Files"+("/"===B?"":" - "+B)}),
|
|
21
21
|
/* @__PURE__ */j(n,{app:"files"}),
|
|
22
22
|
/* @__PURE__ */j("input",{ref:ie,type:"file",multiple:!0,className:"hidden",onChange:e=>{e.target.files?.length&&ue(e.target.files),ie.current&&(ie.current.value="")}}),
|
|
23
23
|
/* @__PURE__ */j("div",{className:"flex-1 min-h-0",children:/* @__PURE__ */j(r,{sidebar:we,storageKey:"files.sidebarWidth",defaultWidth:200,minWidth:150,maxWidth:320,children:/* @__PURE__ */L("div",{className:"flex h-full min-w-0 flex-col",children:[
|
|
24
|
-
/* @__PURE__ */L("div",{className:"flex items-center gap-1 px-2 py-1.5 border-b border-gray-200 bg-gray-50 shrink-0 text-xs",children:[/* @__PURE__ */L(C,"files"===
|
|
24
|
+
/* @__PURE__ */L("div",{className:"flex items-center gap-1 px-2 py-1.5 border-b border-gray-200 bg-gray-50 shrink-0 text-xs",children:[/* @__PURE__ */L(C,"files"===q?{children:[
|
|
25
25
|
/* @__PURE__ */j("button",{onClick:()=>P(function(e){if("/"===e||""===e)return"/";const t=e.replace(/\/$/,""),r=t.lastIndexOf("/");return r<=0?"/":t.slice(0,r)}(B)),disabled:"/"===B,className:"px-2 py-1 rounded hover:bg-gray-200 disabled:opacity-30 text-gray-600",title:"Parent folder",children:/* @__PURE__ */j("svg",{className:"h-3.5 w-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:/* @__PURE__ */j("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M10.5 19.5L3 12m0 0l7.5-7.5M3 12h18"})})}),
|
|
26
26
|
/* @__PURE__ */j("div",{className:"flex-1 min-w-0",children:/* @__PURE__ */j(t,{items:be,maxItems:5})}),
|
|
27
|
-
/* @__PURE__ */j("button",{onClick:()=>me(B),className:"px-2 py-1 rounded hover:bg-gray-200 text-gray-600",title:"Refresh",children:/* @__PURE__ */j("svg",{className:"h-3.5 w-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.8,children:/* @__PURE__ */j("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M16.023 9.348h4.992V4.356M2.985 19.644v-4.992h4.992M3.05 9.348a9 9 0 0114.85-3.36L21.015 9.348m0 5.304a9 9 0 01-14.85 3.36l-3.115-3.36"})})}),!
|
|
28
|
-
/* @__PURE__ */L("button",{onClick:()=>
|
|
27
|
+
/* @__PURE__ */j("button",{onClick:()=>me(B),className:"px-2 py-1 rounded hover:bg-gray-200 text-gray-600",title:"Refresh",children:/* @__PURE__ */j("svg",{className:"h-3.5 w-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.8,children:/* @__PURE__ */j("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M16.023 9.348h4.992V4.356M2.985 19.644v-4.992h4.992M3.05 9.348a9 9 0 0114.85-3.36L21.015 9.348m0 5.304a9 9 0 01-14.85 3.36l-3.115-3.36"})})}),!A&&/* @__PURE__ */L(C,{children:[
|
|
28
|
+
/* @__PURE__ */L("button",{onClick:()=>G("trash"),className:"px-2 py-1 rounded hover:bg-gray-200 text-gray-600 flex items-center gap-1",title:"Open trash",children:[
|
|
29
29
|
/* @__PURE__ */j("svg",{className:"h-3.5 w-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.5,children:/* @__PURE__ */j("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"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.79m14.456 0a48.108 48.108 0 00-3.478-.397m-12 .562c.34-.059.68-.114 1.022-.165m0 0a48.11 48.11 0 013.478-.397m7.5 0v-.916c0-1.18-.91-2.164-2.09-2.201a51.964 51.964 0 00-3.32 0c-1.18.037-2.09 1.022-2.09 2.201v.916m7.5 0a48.667 48.667 0 00-7.5 0"})}),"Trash"]}),
|
|
30
|
-
/* @__PURE__ */L("button",{onClick:async()=>{const e=await y({title:"New folder",placeholder:"Folder name",confirmLabel:"Create"});if(!e)return;if(/[\\/]/.test(e))return void u.error("Folder names cannot contain slashes");const t=
|
|
30
|
+
/* @__PURE__ */L("button",{onClick:async()=>{const e=await y({title:"New folder",placeholder:"Folder name",confirmLabel:"Create"});if(!e)return;if(/[\\/]/.test(e))return void u.error("Folder names cannot contain slashes");const t=D(B,e),r=await de(`${R}/api/folder`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:t})});if(!r.ok){const e=await r.json().catch(()=>({}));return void u.error(e.error||`Create folder failed (${r.status})`)}me(B)},className:"px-2 py-1 rounded hover:bg-gray-200 text-gray-600 flex items-center gap-1",children:[
|
|
31
31
|
/* @__PURE__ */j("svg",{className:"h-3.5 w-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.5,children:/* @__PURE__ */j("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M12 10.5v6m3-3H9m4.06-7.19l-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"})}),"New Folder"]}),
|
|
32
32
|
/* @__PURE__ */L("button",{onClick:()=>ie.current?.click(),className:"px-2 py-1 rounded bg-blue-500 text-white hover:bg-blue-600 flex items-center gap-1",children:[
|
|
33
|
-
/* @__PURE__ */j("svg",{className:"h-3.5 w-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.8,children:/* @__PURE__ */j("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M3 16.5v2.25A2.25 2.25 0 005.25 21h13.5A2.25 2.25 0 0021 18.75V16.5M7.5 7.5L12 3m0 0l4.5 4.5M12 3v13.5"})}),"Upload"]})]})]}:"trash"===
|
|
34
|
-
/* @__PURE__ */j("button",{onClick:()=>
|
|
33
|
+
/* @__PURE__ */j("svg",{className:"h-3.5 w-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.8,children:/* @__PURE__ */j("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M3 16.5v2.25A2.25 2.25 0 005.25 21h13.5A2.25 2.25 0 0021 18.75V16.5M7.5 7.5L12 3m0 0l4.5 4.5M12 3v13.5"})}),"Upload"]})]})]}:"trash"===q?{children:[
|
|
34
|
+
/* @__PURE__ */j("button",{onClick:()=>G("files"),className:"px-2 py-1 rounded hover:bg-gray-200 text-gray-600",title:"Back to files",children:/* @__PURE__ */j("svg",{className:"h-3.5 w-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:/* @__PURE__ */j("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M10.5 19.5L3 12m0 0l7.5-7.5M3 12h18"})})}),
|
|
35
35
|
/* @__PURE__ */j("span",{className:"flex-1 text-gray-700 font-medium px-2",children:"Trash"}),
|
|
36
36
|
/* @__PURE__ */j("button",{onClick:he,className:"px-2 py-1 rounded hover:bg-gray-200 text-gray-600",title:"Refresh",children:/* @__PURE__ */j("svg",{className:"h-3.5 w-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.8,children:/* @__PURE__ */j("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M16.023 9.348h4.992V4.356M2.985 19.644v-4.992h4.992M3.05 9.348a9 9 0 0114.85-3.36L21.015 9.348m0 5.304a9 9 0 01-14.85 3.36l-3.115-3.36"})})}),
|
|
37
|
-
/* @__PURE__ */j("button",{onClick:async()=>{if(0===
|
|
38
|
-
/* @__PURE__ */j("button",{onClick:()=>
|
|
37
|
+
/* @__PURE__ */j("button",{onClick:async()=>{if(0===Y.length)return;if(!await g({title:"Empty trash",message:`${Y.length} item${1===Y.length?"":"s"} will be permanently removed. This can't be undone.`,confirmLabel:"Empty trash",variant:"danger"}))return;const e=await de(`${R}/api/trash`,{method:"DELETE"});if(!e.ok){const t=await e.json().catch(()=>({}));return void u.error(t.error||`Empty trash failed (${e.status})`)}he()},disabled:0===Y.length,className:"px-2 py-1 rounded text-red-600 hover:bg-red-50 disabled:opacity-30 flex items-center gap-1",children:"Empty trash"})]}:{children:[
|
|
38
|
+
/* @__PURE__ */j("button",{onClick:()=>G("files"),className:"px-2 py-1 rounded hover:bg-gray-200 text-gray-600",title:"Back to files",children:/* @__PURE__ */j("svg",{className:"h-3.5 w-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:/* @__PURE__ */j("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M10.5 19.5L3 12m0 0l7.5-7.5M3 12h18"})})}),
|
|
39
39
|
/* @__PURE__ */j(m,{className:"h-4 w-4 text-amber-500 ml-1"}),
|
|
40
40
|
/* @__PURE__ */j("span",{className:"flex-1 text-gray-700 font-medium px-1 truncate",children:re?.name??"Desktop folder"}),
|
|
41
41
|
/* @__PURE__ */j("span",{className:"text-[10px] text-gray-400 px-2",children:"Desktop shortcuts"})]}),K&&/* @__PURE__ */L(C,{children:[
|
|
42
42
|
/* @__PURE__ */j("div",{className:"h-4 w-px bg-gray-300 mx-1"}),
|
|
43
|
-
/* @__PURE__ */L("div",{className:"flex items-center gap-1.5",title:`${
|
|
43
|
+
/* @__PURE__ */L("div",{className:"flex items-center gap-1.5",title:`${T(K.used)} of ${T(K.limit)} used`,children:[
|
|
44
44
|
/* @__PURE__ */j("div",{className:"w-20 h-1.5 rounded-full bg-gray-200 overflow-hidden",children:/* @__PURE__ */j("div",{className:`h-full ${ye} transition-all`,style:{width:`${ge}%`}})}),
|
|
45
|
-
/* @__PURE__ */L("span",{className:"text-[10px] text-gray-500 tabular-nums whitespace-nowrap",children:[
|
|
46
|
-
/* @__PURE__ */j("div",{className:"flex-1 overflow-auto",children:"object"==typeof
|
|
45
|
+
/* @__PURE__ */L("span",{className:"text-[10px] text-gray-500 tabular-nums whitespace-nowrap",children:[T(K.used)," / ",T(K.limit)]})]})]})]}),
|
|
46
|
+
/* @__PURE__ */j("div",{className:"flex-1 overflow-auto",children:"object"==typeof q?0===ae.length?/* @__PURE__ */j("div",{className:"p-10 text-center text-sm text-gray-400",children:"This desktop folder is empty. Drag shortcuts onto it on the desktop."}):/* @__PURE__ */L("table",{className:"w-full text-sm",children:[
|
|
47
47
|
/* @__PURE__ */j("thead",{className:"bg-gray-50 text-[11px] uppercase tracking-wide text-gray-500",children:/* @__PURE__ */L("tr",{children:[
|
|
48
48
|
/* @__PURE__ */j("th",{className:"text-left font-medium px-3 py-1.5",children:"Name"}),
|
|
49
49
|
/* @__PURE__ */j("th",{className:"text-left font-medium px-3 py-1.5 w-28",children:"Type"}),
|
|
50
50
|
/* @__PURE__ */j("th",{className:"w-56"})]})}),
|
|
51
51
|
/* @__PURE__ */j("tbody",{children:ae.map(e=>{const t=`${e.entityType}|${e.entityId}`;/* @__PURE__ */
|
|
52
|
-
return L("tr",{onClick:()=>
|
|
52
|
+
return L("tr",{onClick:()=>W(t),onDoubleClick:()=>le(e),className:"cursor-default border-b border-gray-100 "+(V===t?"bg-blue-50":"hover:bg-gray-50"),children:[
|
|
53
53
|
/* @__PURE__ */L("td",{className:"px-3 py-1.5 flex items-center gap-2",children:[
|
|
54
54
|
/* @__PURE__ */j(h,{item:e}),
|
|
55
55
|
/* @__PURE__ */j("span",{className:"truncate",title:e.label,children:e.label})]}),
|
|
@@ -57,33 +57,33 @@ return L("tr",{onClick:()=>U(t),onDoubleClick:()=>le(e),className:"cursor-defaul
|
|
|
57
57
|
/* @__PURE__ */L("td",{className:"px-3 py-1.5 text-right whitespace-nowrap",children:[
|
|
58
58
|
/* @__PURE__ */j("button",{onClick:t=>{t.stopPropagation(),le(e)},className:"px-1.5 py-0.5 rounded hover:bg-gray-200 text-blue-600 text-[11px]",children:"Open"}),
|
|
59
59
|
/* @__PURE__ */j("button",{onClick:t=>{t.stopPropagation(),ee?.moveToDesktop([e])},className:"px-1.5 py-0.5 rounded hover:bg-gray-200 text-gray-500 text-[11px] ml-1",children:"Move to desktop"}),
|
|
60
|
-
/* @__PURE__ */j("button",{onClick:t=>{t.stopPropagation(),ee?.removeShortcuts([e])},className:"px-1.5 py-0.5 rounded hover:bg-red-100 text-red-600 text-[11px] ml-1",children:"Remove"})]})]},t)})})]}):"trash"===
|
|
60
|
+
/* @__PURE__ */j("button",{onClick:t=>{t.stopPropagation(),ee?.removeShortcuts([e])},className:"px-1.5 py-0.5 rounded hover:bg-red-100 text-red-600 text-[11px] ml-1",children:"Remove"})]})]},t)})})]}):"trash"===q?O&&0===Y.length?/* @__PURE__ */j("div",{className:"p-6 text-center text-sm text-gray-400",children:"Loading…"}):0===Y.length?/* @__PURE__ */j("div",{className:"p-10 text-center text-sm text-gray-400",children:"Trash is empty."}):/* @__PURE__ */L("table",{className:"w-full text-sm",children:[
|
|
61
61
|
/* @__PURE__ */j("thead",{className:"bg-gray-50 text-[11px] uppercase tracking-wide text-gray-500",children:/* @__PURE__ */L("tr",{children:[
|
|
62
62
|
/* @__PURE__ */j("th",{className:"text-left font-medium px-3 py-1.5",children:"Name"}),
|
|
63
63
|
/* @__PURE__ */j("th",{className:"text-left font-medium px-3 py-1.5",children:"Original location"}),
|
|
64
64
|
/* @__PURE__ */j("th",{className:"text-right font-medium px-3 py-1.5 w-24",children:"Size"}),
|
|
65
65
|
/* @__PURE__ */j("th",{className:"text-right font-medium px-3 py-1.5 w-40",children:"Deleted"}),
|
|
66
66
|
/* @__PURE__ */j("th",{className:"w-44"})]})}),
|
|
67
|
-
/* @__PURE__ */j("tbody",{children:
|
|
67
|
+
/* @__PURE__ */j("tbody",{children:Y.map(e=>/* @__PURE__ */L("tr",{className:"border-b border-gray-100 hover:bg-gray-50",children:[
|
|
68
68
|
/* @__PURE__ */L("td",{className:"px-3 py-1.5 flex items-center gap-2",children:["folder"===e.kind?/* @__PURE__ */j("svg",{className:"h-4 w-4 text-amber-500 shrink-0",fill:"currentColor",viewBox:"0 0 24 24",children:/* @__PURE__ */j("path",{d:"M2.25 7.125A2.25 2.25 0 014.5 4.875h4.504c.61 0 1.193.243 1.624.673l1.494 1.494a.75.75 0 00.53.22h7.098A2.25 2.25 0 0122 9.51v8.366A2.25 2.25 0 0119.75 20.125H4.25A2.25 2.25 0 012 17.875V7.125z"})}):/* @__PURE__ */j("svg",{className:"h-4 w-4 text-gray-400 shrink-0",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.5,children:/* @__PURE__ */j("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M19.5 14.25v-2.625a3.375 3.375 0 00-3.375-3.375h-1.5A1.125 1.125 0 0113.5 7.125v-1.5a3.375 3.375 0 00-3.375-3.375H8.25m2.25 0H5.625c-.621 0-1.125.504-1.125 1.125v17.25c0 .621.504 1.125 1.125 1.125h12.75c.621 0 1.125-.504 1.125-1.125V11.25a9 9 0 00-9-9z"})}),
|
|
69
69
|
/* @__PURE__ */j("span",{className:"truncate",title:e.name,children:e.name})]}),
|
|
70
70
|
/* @__PURE__ */j("td",{className:"px-3 py-1.5 text-gray-500 text-xs font-mono truncate",title:e.originalPath,children:e.originalPath||"—"}),
|
|
71
|
-
/* @__PURE__ */j("td",{className:"px-3 py-1.5 text-right tabular-nums text-gray-500",children:
|
|
71
|
+
/* @__PURE__ */j("td",{className:"px-3 py-1.5 text-right tabular-nums text-gray-500",children:T(e.size)}),
|
|
72
72
|
/* @__PURE__ */j("td",{className:"px-3 py-1.5 text-right text-gray-500 tabular-nums",children:e.deletedAt?E(e.deletedAt):"—"}),
|
|
73
73
|
/* @__PURE__ */L("td",{className:"px-3 py-1.5 text-right whitespace-nowrap",children:[
|
|
74
|
-
/* @__PURE__ */j("button",{onClick:()=>(async e=>{const t=await de(`${
|
|
75
|
-
/* @__PURE__ */j("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 de(`${
|
|
74
|
+
/* @__PURE__ */j("button",{onClick:()=>(async e=>{const t=await de(`${R}/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 u.error(e.error||`Restore failed (${t.status})`)}u.success(`Restored "${e.name}"`),he()})(e),className:"px-1.5 py-0.5 rounded hover:bg-gray-200 text-blue-600 text-[11px]",children:"Restore"}),
|
|
75
|
+
/* @__PURE__ */j("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 de(`${R}/api/trash/${encodeURIComponent(e.id)}`,{method:"DELETE"});if(!t.ok){const e=await t.json().catch(()=>({}));return void u.error(e.error||`Delete failed (${t.status})`)}he()})(e),className:"px-1.5 py-0.5 rounded hover:bg-red-100 text-red-600 text-[11px] ml-1",children:"Delete forever"})]})]},e.id))})]}):O&&0===I.length?/* @__PURE__ */j("div",{className:"p-6 text-center text-sm text-gray-400",children:"Loading…"}):0===I.length?/* @__PURE__ */L("div",{className:"p-10 text-center text-sm text-gray-400",children:["Empty folder.",!A&&/* @__PURE__ */L(C,{children:[" Drop files here or click ",
|
|
76
76
|
/* @__PURE__ */j("span",{className:"font-medium",children:"Upload"}),"."]})]}):/* @__PURE__ */L("table",{className:"w-full text-sm",children:[
|
|
77
77
|
/* @__PURE__ */j("thead",{className:"bg-gray-50 text-[11px] uppercase tracking-wide text-gray-500",children:/* @__PURE__ */L("tr",{children:[
|
|
78
78
|
/* @__PURE__ */j("th",{className:"text-left font-medium px-3 py-1.5",children:"Name"}),
|
|
79
79
|
/* @__PURE__ */j("th",{className:"text-right font-medium px-3 py-1.5 w-24",children:"Size"}),
|
|
80
80
|
/* @__PURE__ */j("th",{className:"text-right font-medium px-3 py-1.5 w-40",children:"Modified"}),
|
|
81
81
|
/* @__PURE__ */j("th",{className:"w-32"})]})}),
|
|
82
|
-
/* @__PURE__ */j("tbody",{children:I.map(t=>/* @__PURE__ */L("tr",{onClick:()=>
|
|
82
|
+
/* @__PURE__ */j("tbody",{children:I.map(t=>/* @__PURE__ */L("tr",{onClick:()=>W(t.name),onDoubleClick:()=>{"folder"===t.kind?P(D(B,t.name)):(async t=>{if(A)return;const r=D(B,t.name),a=(t.name.split(".").pop()||"").toLowerCase(),n=M[a];n?await e({filePath:r,filename:t.name,kind:n,onStaged:e=>oe(e)}):pe(t)})(t)},className:"cursor-default border-b border-gray-100 "+(V===t.name?"bg-blue-50":"hover:bg-gray-50"),children:[
|
|
83
83
|
/* @__PURE__ */L("td",{className:"px-3 py-1.5 flex items-center gap-2",children:["folder"===t.kind?/* @__PURE__ */j("svg",{className:"h-4 w-4 text-amber-500 shrink-0",fill:"currentColor",viewBox:"0 0 24 24",children:/* @__PURE__ */j("path",{d:"M2.25 7.125A2.25 2.25 0 014.5 4.875h4.504c.61 0 1.193.243 1.624.673l1.494 1.494a.75.75 0 00.53.22h7.098A2.25 2.25 0 0122 9.51v8.366A2.25 2.25 0 0119.75 20.125H4.25A2.25 2.25 0 012 17.875V7.125z"})}):/* @__PURE__ */j("svg",{className:"h-4 w-4 text-gray-400 shrink-0",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.5,children:/* @__PURE__ */j("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M19.5 14.25v-2.625a3.375 3.375 0 00-3.375-3.375h-1.5A1.125 1.125 0 0113.5 7.125v-1.5a3.375 3.375 0 00-3.375-3.375H8.25m2.25 0H5.625c-.621 0-1.125.504-1.125 1.125v17.25c0 .621.504 1.125 1.125 1.125h12.75c.621 0 1.125-.504 1.125-1.125V11.25a9 9 0 00-9-9z"})}),
|
|
84
84
|
/* @__PURE__ */j("span",{className:"truncate",title:t.name,children:t.name})]}),
|
|
85
|
-
/* @__PURE__ */j("td",{className:"px-3 py-1.5 text-right tabular-nums text-gray-500",children:"folder"===t.kind?"—":
|
|
85
|
+
/* @__PURE__ */j("td",{className:"px-3 py-1.5 text-right tabular-nums text-gray-500",children:"folder"===t.kind?"—":T(t.size)}),
|
|
86
86
|
/* @__PURE__ */j("td",{className:"px-3 py-1.5 text-right text-gray-500 tabular-nums",children:E(t.modifiedAt)}),
|
|
87
|
-
/* @__PURE__ */j("td",{className:"px-3 py-1.5 text-right whitespace-nowrap",children:!
|
|
88
|
-
/* @__PURE__ */j("button",{onClick:e=>{e.stopPropagation(),(async e=>{const t=await y({title:`Rename ${e.kind}`,defaultValue:e.name,confirmLabel:"Rename"});if(!t||t===e.name)return;if(/[\\/]/.test(t))return void u.error("Names cannot contain slashes");const r=
|
|
89
|
-
/* @__PURE__ */j("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=
|
|
87
|
+
/* @__PURE__ */j("td",{className:"px-3 py-1.5 text-right whitespace-nowrap",children:!A&&/* @__PURE__ */L(C,{children:["file"===t.kind&&/* @__PURE__ */j("button",{onClick:e=>{e.stopPropagation(),pe(t)},className:"px-1.5 py-0.5 rounded hover:bg-gray-200 text-gray-500 text-[11px]",children:"Download"}),
|
|
88
|
+
/* @__PURE__ */j("button",{onClick:e=>{e.stopPropagation(),(async e=>{const t=await y({title:`Rename ${e.kind}`,defaultValue:e.name,confirmLabel:"Rename"});if(!t||t===e.name)return;if(/[\\/]/.test(t))return void u.error("Names cannot contain slashes");const r=D(B,e.name),a=D(B,t),n=await de(`${R}/api/rename`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({from:r,to:a})});if(!n.ok){const e=await n.json().catch(()=>({}));return void u.error(e.error||`Rename failed (${n.status})`)}me(B)})(t)},className:"px-1.5 py-0.5 rounded hover:bg-gray-200 text-gray-500 text-[11px] ml-1",children:"Rename"}),
|
|
89
|
+
/* @__PURE__ */j("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=D(B,e.name),r=await de(`${R}/api/files?path=${encodeURIComponent(t)}`,{method:"DELETE"});if(!r.ok){const e=await r.json().catch(()=>({}));return void u.error(e.error||`Delete failed (${r.status})`)}me(B)})(t)},className:"px-1.5 py-0.5 rounded hover:bg-red-100 text-red-600 text-[11px] ml-1",children:"Delete"})]})})]},t.name))})]})})]})})}),Q&&/* @__PURE__ */j("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__ */j("div",{className:"px-4 py-2 rounded-md bg-blue-600 text-white text-sm font-medium shadow-lg",children:"Drop to upload"})})]})}export{R as default};
|
|
@@ -1,25 +1,25 @@
|
|
|
1
|
-
import{SidebarLayout as e}from"./chunk-SLCR26NK.js";import{AboutApp as t}from"./chunk-
|
|
2
|
-
/* @__PURE__ */h("div",{className:"p-2 border-b border-gray-200",children:/* @__PURE__ */p("button",{onClick:()=>{
|
|
1
|
+
import{SidebarLayout as e}from"./chunk-SLCR26NK.js";import{AboutApp as t}from"./chunk-IQVJ3C3D.js";import{toast_default as r}from"./chunk-KKOHUQPF.js";import"./chunk-BJVY3LPW.js";import{useWindowManager as n,client_default as o}from"./chunk-ET5HXDOR.js";import{useShellPrefs as i}from"./chunk-V453E4KU.js";import"./chunk-UB4JIOLD.js";import"./chunk-PH3PRIFP.js";import"./chunk-ZBIWNVJS.js";import"./chunk-QOXIUJTN.js";import"./chunk-57MIENLJ.js";import"./chunk-MAIHBBWT.js";import"./chunk-TR6PLN7W.js";import"./chunk-D65T4H6J.js";import{useRef as l,useEffect as a,useState as s,useCallback as c}from"react";import{useQuery as d}from"@tanstack/react-query";import{jsxs as p,Fragment as u,jsx as h}from"react/jsx-runtime";var m=[{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 g={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/"}},x=/\[([ xX]?)\]/g;function y(){const{openEntity:y}=n(),{prefs:b,save:f}=i(),{data:k}=d({queryKey:["numbering-configs"],queryFn:()=>o.get("/auth/numbering-configs/").then(e=>e.data?.results??e.data??[]),retry:!1}),v=l({});a(()=>{if(!k)return;const e={};for(const t of k){const r=g[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})}}v.current=e},[k]);const N=b.notepad_notes||[],[w,_]=s(null),[T,j]=s(""),[C,$]=s(""),[L,S]=s("yellow"),[W,B]=s(!1),[I,M]=s(!1),D=l(null),O=l(),P=N.find(e=>e.id===w);a(()=>{if(!w&&N.length>0){const e=N[0];_(e.id),j(e.title),$(e.content),S(e.color)}},[N.length]);const X=c(e=>{f({notepad_notes:e})},[f]),H=c(()=>{if(!w||!W)return;const e=N.map(e=>e.id===w?{...e,title:T,content:C,color:L,updated_at:/* @__PURE__ */(new Date).toISOString()}:e);X(e),B(!1)},[w,W,T,C,L,N,X]);a(()=>{if(W)return O.current&&clearTimeout(O.current),O.current=setTimeout(H,800),()=>{O.current&&clearTimeout(O.current)}},[W,H]),a(()=>()=>{W&&H()},[]);const V=e=>{W&&H(),_(e.id),j(e.title),$(e.content),S(e.color),B(!1),M(!1)},J=e=>{const t=Date.now()-new Date(e).getTime(),r=Math.floor(t/6e4);if(r<1)return"just now";if(r<60)return`${r}m ago`;const n=Math.floor(r/60);if(n<24)return`${n}h ago`;return`${Math.floor(n/24)}d ago`},U=e=>{const t=C.slice(0,e),r=C.slice(e).match(/^\[([ xX]?)\]/);if(!r)return;const n="x"===r[1]||"X"===r[1]?"[ ]":"[x]",o=C.slice(e+r[0].length);$(t+n+o),B(!0)},q=async(e,t)=>{const n=v.current[e];if(!n)return;const i=`${e}#${t}`;try{const{data:e}=await o.get(n.endpoint,{params:{search:i,page_size:1}}),t=(e?.results??e??[])[0];t?y(n.entityType,t.id,t,i):r.error(`${i} not found`)}catch{r.error(`Failed to look up ${i}`)}},E="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.)",K=/* @__PURE__ */p(u,{children:[
|
|
2
|
+
/* @__PURE__ */h("div",{className:"p-2 border-b border-gray-200",children:/* @__PURE__ */p("button",{onClick:()=>{W&&H();const e={id:`note-${Date.now()}-${Math.random().toString(36).slice(2,6)}`,title:"",content:"",color:"yellow",sticky:!1,updated_at:/* @__PURE__ */(new Date).toISOString()},t=[e,...N];X(t),_(e.id),j(""),$(""),S("yellow"),B(!1),M(!0),setTimeout(()=>D.current?.focus(),50)},className:"w-full flex items-center justify-center gap-1.5 rounded-lg bg-blue-600 text-white px-3 py-1.5 text-sm font-medium hover:bg-blue-700 transition-colors",children:[
|
|
3
3
|
/* @__PURE__ */h("svg",{className:"h-4 w-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:/* @__PURE__ */h("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M12 4.5v15m7.5-7.5h-15"})}),"New Note"]})}),
|
|
4
4
|
/* @__PURE__ */h("div",{className:"flex-1 overflow-y-auto",children:0===N.length?/* @__PURE__ */h("p",{className:"text-sm text-gray-400 text-center py-8 px-4",children:"No notes yet. Create one to get started."}):N.map(e=>{const t=(r=e.color,m.find(e=>e.key===r)||m[0]);var r;/* @__PURE__ */
|
|
5
|
-
return p("button",{onClick:()=>
|
|
5
|
+
return p("button",{onClick:()=>V(e),className:"w-full text-left px-3 py-2.5 border-b border-gray-100 transition-colors "+(w===e.id?"bg-blue-50":"hover:bg-gray-50"),children:[
|
|
6
6
|
/* @__PURE__ */p("div",{className:"flex items-center gap-2",children:[
|
|
7
7
|
/* @__PURE__ */h("div",{className:`w-2.5 h-2.5 rounded-full shrink-0 ${t.dot}`}),
|
|
8
8
|
/* @__PURE__ */h("span",{className:"text-sm font-medium text-gray-900 truncate flex-1",children:e.title||"Untitled"}),e.sticky&&/* @__PURE__ */h("svg",{className:"h-3 w-3 text-amber-500 shrink-0",fill:"currentColor",viewBox:"0 0 24 24",children:/* @__PURE__ */h("path",{d:"M5 5a2 2 0 012-2h10a2 2 0 012 2v16l-7-3.5L5 21V5z"})})]}),
|
|
9
9
|
/* @__PURE__ */h("p",{className:"text-xs text-gray-400 mt-0.5 truncate ml-4.5",children:e.content.replace(/\[[ xX]?\]/g,"").slice(0,60)||"Empty note"}),
|
|
10
|
-
/* @__PURE__ */h("p",{className:"text-[10px] text-gray-300 mt-0.5 ml-4.5",children:
|
|
10
|
+
/* @__PURE__ */h("p",{className:"text-[10px] text-gray-300 mt-0.5 ml-4.5",children:J(e.updated_at)})]},e.id)})})]});/* @__PURE__ */
|
|
11
11
|
return p("div",{className:"h-full",children:[
|
|
12
12
|
/* @__PURE__ */h(t,{app:"notepad"}),
|
|
13
|
-
/* @__PURE__ */h(e,{sidebar:
|
|
13
|
+
/* @__PURE__ */h(e,{sidebar:K,storageKey:"notepad.sidebarWidth",defaultWidth:224,minWidth:180,maxWidth:360,children:w?/* @__PURE__ */p("div",{className:"flex-1 flex flex-col min-w-0",children:[
|
|
14
14
|
/* @__PURE__ */p("div",{className:"flex items-center gap-2 px-4 py-2 border-b border-gray-200",children:[
|
|
15
|
-
/* @__PURE__ */h("input",{value:T,onChange:e=>{j(e.target.value),
|
|
16
|
-
/* @__PURE__ */h("div",{className:"flex gap-1",children:m.map(e=>/* @__PURE__ */h("button",{onClick:()=>{S(e.key),
|
|
15
|
+
/* @__PURE__ */h("input",{value:T,onChange:e=>{j(e.target.value),B(!0)},placeholder:"Note title...",className:"flex-1 text-lg font-semibold text-gray-900 outline-none bg-transparent placeholder:text-gray-300"}),
|
|
16
|
+
/* @__PURE__ */h("div",{className:"flex gap-1",children:m.map(e=>/* @__PURE__ */h("button",{onClick:()=>{S(e.key),B(!0)},className:`w-5 h-5 rounded-full border-2 transition-all ${e.dot} ${L===e.key?"border-gray-600 scale-110":"border-transparent hover:border-gray-400"}`,title:e.key},e.key))}),
|
|
17
17
|
/* @__PURE__ */h("button",{onClick:()=>(e=>{const t=N.map(t=>t.id===e?{...t,sticky:!t.sticky}:t);X(t);const n=t.find(t=>t.id===e);r.success(n?.sticky?"Pinned to desktop":"Removed from desktop")})(w),title:P?.sticky?"Remove from desktop":"Pin to desktop",className:"p-1 rounded transition-colors "+(P?.sticky?"text-amber-500 hover:text-amber-600":"text-gray-300 hover:text-amber-400"),children:/* @__PURE__ */h("svg",{className:"h-4 w-4",fill:P?.sticky?"currentColor":"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.5,children:/* @__PURE__ */h("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 5a2 2 0 012-2h10a2 2 0 012 2v16l-7-3.5L5 21V5z"})})}),
|
|
18
|
-
/* @__PURE__ */h("button",{onClick:()=>(e=>{const t=N.filter(t=>t.id!==e);if(X(t),w===e){const e=t[0];e?
|
|
19
|
-
return h("div",{className:c?"line-through text-gray-400":"",children:n},r)})})(C):/* @__PURE__ */h("p",{className:"text-gray-300 whitespace-pre-line",children:
|
|
18
|
+
/* @__PURE__ */h("button",{onClick:()=>(e=>{const t=N.filter(t=>t.id!==e);if(X(t),w===e){const e=t[0];e?V(e):(_(null),j(""),$(""))}})(w),title:"Delete note",className:"p-1 rounded text-gray-300 hover:text-red-500 transition-colors",children:/* @__PURE__ */h("svg",{className:"h-4 w-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.5,children:/* @__PURE__ */h("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"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.79m14.456 0a48.108 48.108 0 00-3.478-.397m-12 .562c.34-.059.68-.114 1.022-.165m0 0a48.11 48.11 0 013.478-.397m7.5 0v-.916c0-1.18-.91-2.164-2.09-2.201a51.964 51.964 0 00-3.32 0c-1.18.037-2.09 1.022-2.09 2.201v.916m7.5 0a48.667 48.667 0 00-7.5 0"})})})]}),I?/* @__PURE__ */h("textarea",{ref:D,value:C,onChange:e=>{$(e.target.value),B(!0)},onBlur:()=>{M(!1),W&&H()},placeholder:E,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__ */h("div",{onClick:()=>{M(!0),setTimeout(()=>D.current?.focus(),50)},className:"flex-1 p-4 text-sm text-gray-700 overflow-y-auto leading-relaxed cursor-text",children:C?(e=>{if(!e)return[];const t=e.split("\n");return t.map((e,r)=>{const n=[];let o=0;const i=[],l=/([A-Z]{2,4})#(\d{4,6})/g;let a;for(;null!==(a=l.exec(e));){const e=a[1],t=a[2];if(v.current[e]){const n=a.index,o=a[0];i.push({idx:n,len:o.length,render:()=>/* @__PURE__ */h("button",{onClick:()=>q(e,t),className:"text-blue-600 hover:text-blue-800 hover:underline font-medium cursor-pointer",children:o},`ref-${r}-${n}`)})}}x.lastIndex=0;let s=0;for(let e=0;e<r;e++)s+=t[e].length+1;for(;null!==(a=x.exec(e));){const e="x"===a[1]||"X"===a[1],t=a.index,n=s+t;i.push({idx:t,len:a[0].length,render:()=>/* @__PURE__ */h("button",{onClick:()=>U(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__ */h("svg",{className:"w-3 h-3",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:3,children:/* @__PURE__ */h("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M4.5 12.75l6 6 9-13.5"})})},`cb-${r}-${t}`)})}i.sort((e,t)=>e.idx-t.idx);for(const t of i)t.idx>o&&n.push(/* @__PURE__ */h("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__ */h("span",{children:e.slice(o)},`t-${r}-${o}`)),0===n.length&&n.push(/* @__PURE__ */h("span",{children:""},`empty-${r}`));const c=/^\[x\]/i.test(e.trimStart());/* @__PURE__ */
|
|
19
|
+
return h("div",{className:c?"line-through text-gray-400":"",children:n},r)})})(C):/* @__PURE__ */h("p",{className:"text-gray-300 whitespace-pre-line",children:E})}),
|
|
20
20
|
/* @__PURE__ */p("div",{className:"px-4 py-1.5 border-t border-gray-100 flex items-center gap-4 text-[10px] text-gray-400",children:[
|
|
21
21
|
/* @__PURE__ */h("span",{children:"[] checkbox"}),
|
|
22
22
|
/* @__PURE__ */h("span",{children:"SO#35001 entity link"}),
|
|
23
|
-
/* @__PURE__ */h("span",{className:"ml-auto",children:
|
|
23
|
+
/* @__PURE__ */h("span",{className:"ml-auto",children:I?"Editing":"Click to edit"})]})]}):/* @__PURE__ */h("div",{className:"flex-1 flex items-center justify-center",children:/* @__PURE__ */p("div",{className:"text-center text-gray-400",children:[
|
|
24
24
|
/* @__PURE__ */h("svg",{className:"h-12 w-12 mx-auto mb-3 text-gray-300",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1,children:/* @__PURE__ */h("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M19.5 14.25v-2.625a3.375 3.375 0 00-3.375-3.375h-1.5A1.125 1.125 0 0113.5 7.125v-1.5a3.375 3.375 0 00-3.375-3.375H8.25m2.25 0H5.625c-.621 0-1.125.504-1.125 1.125v17.25c0 .621.504 1.125 1.125 1.125h12.75c.621 0 1.125-.504 1.125-1.125V11.25a9 9 0 00-9-9z"})}),
|
|
25
25
|
/* @__PURE__ */h("p",{className:"text-sm",children:"Select a note or create a new one"})]})})})]})}export{y as default};
|