efficient-shell 7.45.0 → 7.47.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 +65 -0
- package/dist/{Browser-7M22OFSW.js → Browser-5AN7EBVV.js} +14 -14
- package/dist/Calculator-YGJ7I5VT.js +29 -0
- package/dist/ConfirmDialog-OJLZG4QL.js +1 -0
- package/dist/{CurrencyConverter-4QTVWEFM.js → CurrencyConverter-PH75TBDL.js} +6 -6
- package/dist/{Documents-LELK7IBM.js → Documents-HZF3MZCH.js} +22 -22
- package/dist/Files-5H7LBVIF.js +87 -0
- package/dist/{Notepad-CLHKYQ34.js → Notepad-WTWGNCLT.js} +14 -14
- package/dist/PdfViewer-D4GRPG4G.js +1 -0
- package/dist/{PomodoroTimer-L45QS5OR.js → PomodoroTimer-BUKDNFPJ.js} +24 -24
- package/dist/{Preview-47BCBIP4.js → Preview-ZMDRH6GO.js} +65 -65
- package/dist/Sidebar-A3UG662D.js +44 -0
- package/dist/{Spreadsheet-6NX5WA4J.js → Spreadsheet-WOSOG5TR.js} +13 -13
- package/dist/{Stock-ZZ6AM43M.js → Stock-FB5VIBVY.js} +3 -3
- package/dist/{Weather-K3BZD2NX.js → Weather-2MOP5LTK.js} +17 -17
- package/dist/{WorldClock-5STYQA56.js → WorldClock-KMMKBE4B.js} +6 -6
- package/dist/ai/index.d.ts +271 -0
- package/dist/ai/index.js +37 -0
- package/dist/ai.css +2 -0
- package/dist/apps/index.js +1 -1
- package/dist/bin/ui-check.js +1 -1
- package/dist/brand.css +1 -1
- package/dist/{chunk-JJBFXVOY.js → chunk-3RKM5ZGV.js} +2 -2
- package/dist/{chunk-YRLOXHKG.js → chunk-3ZZ2UPNR.js} +1 -1
- package/dist/{chunk-DENNF2LM.js → chunk-4FQTMGCA.js} +2 -2
- package/dist/{chunk-M2AM6DAA.js → chunk-4QW4I2XQ.js} +1 -1
- package/dist/{chunk-GM2ASLIK.js → chunk-4TOFAEAW.js} +29 -29
- package/dist/{chunk-XDR3Y3WU.js → chunk-55NGVBTR.js} +5 -5
- package/dist/{chunk-G4UIEBPD.js → chunk-BFJRKFOH.js} +13 -13
- package/dist/{chunk-HPUHB47C.js → chunk-BMYURA2N.js} +1 -1
- package/dist/chunk-CLYMUTNF.js +27 -0
- package/dist/{chunk-PR7MCFEU.js → chunk-EZTEOTUD.js} +95 -95
- package/dist/{chunk-FQIZMZDX.js → chunk-FBXOKW33.js} +3 -3
- package/dist/{chunk-K6YIBHZN.js → chunk-FGPEAC7B.js} +16 -16
- package/dist/{chunk-XYG3CVL5.js → chunk-FY3H52BM.js} +1 -1
- package/dist/{chunk-UNLQRUWP.js → chunk-GFWRYNPX.js} +18 -18
- package/dist/{chunk-LK7BWXYY.js → chunk-JFZLYYAN.js} +1 -1
- package/dist/{chunk-JXMYF3JR.js → chunk-JGWOY2KV.js} +9 -9
- package/dist/{chunk-UNA3BQJI.js → chunk-MMLU5ZHI.js} +9 -9
- package/dist/{chunk-ABKFLSHY.js → chunk-NX5HJ6L5.js} +1 -1
- package/dist/chunk-OQBWV2RH.js +1020 -0
- package/dist/chunk-RWNNFCSA.js +1 -0
- package/dist/chunk-UBXRSOQ6.js +47 -0
- package/dist/chunk-USLPE6K3.js +1 -0
- package/dist/{chunk-CWCKDF37.js → chunk-VJ6KJYRS.js} +3 -3
- package/dist/{chunk-LTEM56OL.js → chunk-WSRZRWN7.js} +1 -1
- package/dist/{chunk-3G5TA3IF.js → chunk-YT4B3NSV.js} +4 -3
- package/dist/{chunk-HQ74L5MM.js → chunk-YWJD6RUT.js} +1 -1
- package/dist/{chunk-X6NYTLYX.js → chunk-ZELMENOO.js} +2 -2
- package/dist/icons/index.js +1 -1
- package/dist/{index-BWDtKUcA.d.ts → index-BI54lOAz.d.ts} +30 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js +682 -682
- package/dist/map/index.js +8 -8
- package/dist/markdown/index.js +1 -1
- package/dist/page-tabs/index.js +5 -5
- package/dist/pdf/index.js +1 -1
- package/dist/telemetry/index.js +1 -1
- package/dist/ui/index.d.ts +1 -1
- package/dist/ui/index.js +1 -1
- package/package.json +21 -4
- package/dist/Calculator-LKWOOCNC.js +0 -29
- package/dist/ConfirmDialog-ZT3XT66V.js +0 -1
- package/dist/Files-LAWZGFQQ.js +0 -87
- package/dist/PdfViewer-VJ743BW7.js +0 -1
- package/dist/Sidebar-AYYJL3IJ.js +0 -44
- package/dist/chunk-NGWXT4QX.js +0 -1
- package/dist/chunk-NZBFQTOB.js +0 -27
- package/dist/chunk-WGSCC6QU.js +0 -1050
package/README.md
CHANGED
|
@@ -1454,6 +1454,7 @@ All exports are named — `import { Modal, ... } from 'efficient-shell'`.
|
|
|
1454
1454
|
| `Avatar`, `AvatarGroup` | User avatar with initials fallback + status dot; overlapping stack with +N overflow. |
|
|
1455
1455
|
| `Banner` | Static in-flow alert (`tone`: info / success / warning / danger / neutral). `neutral` is a note that is none of the other four ("Prices exclude GST"): grey in the kit's neutral, the same wash and ink as a neutral `StatusBadge` (`--status-neutral-soft` / `--status-neutral-soft-ink`, `--status-neutral-solid` when `emphasis="solid"`), with the info glyph. `action` renders a control at the right edge — after the text, so a screen reader reaches the problem before the remedy, and before the dismiss ×, so "Update card" is never past "close this". Vertically centred against the words and `shrink-0`, so a message that wraps does not drag the button down or squeeze it — and on a narrow banner (a phone, a narrow column: the words keep at least 12rem) it drops UNDER the words rather than leave them a column one word wide. A banner that names a condition and leaves the fix three menus away is the usual shape of a notice nobody acts on. |
|
|
1456
1456
|
| `Tabs`, `Accordion`, `Tooltip` | Controlled tab strip, collapsible sections, solid hover/focus tooltip. `Tabs variant="pill"` draws the same strip as `Segmented` (the active tab solid blue on the grey track); use it when each choice shows its own panel, and `Segmented` when the choice is a value. `block` gives every tab an equal share of the strip's width, in either look (the same word as `Segmented`'s `block`): the editors' settings panel uses it for its two icon-only tabs, Design (`adjust`) and Animation (`animation`), with the `underline` look, so the chosen tab is a blue icon over a blue underline. Each `Accordion` title is a heading holding its button, `<h3><button aria-expanded aria-controls>`, the WAI-ARIA accordion pattern; `level` (2–6, default 3) sets the heading under the host's own, and the heading draws nothing of its own. An open item's panel is a region named by its button. A tooltip's `side` is a preference: near an edge the bubble slides along that side to stay 8 px clear of it, and flips to the opposite side when its own has no room, keeping inside the screen and inside the shell window that owns its trigger (UI-11). It never leaves that box: a bubble wider than the room wraps, and one taller than the room is cut off at it. The bubble is drawn on `<body>`, in a `fixed` layer laid over its trigger, so a scrolling pane or an `overflow-hidden` box around the trigger cannot cut it off; it follows the trigger when that moves and closes once the trigger has scrolled out of sight. A small arrow on the edge facing the trigger points at the trigger's centre wherever the bubble ended up, kept clear of the bubble's corners; it is the bubble's own surface (`.rosh-tooltip-arrow` in `ui.css`), seamless, and hidden from assistive technology. The bubble is SOLID, not glass, in every setting: the kit's solid popup surface (`--rosh-glass-surface`, `--rosh-glass-solid-border`, `--rosh-glass-solid-shadow`), so words behind a small bubble never mix with its own. |
|
|
1457
|
+
| `StepChain`, `StepChainItem` | A chain of steps for work in progress — a one-line summary that opens to steps, each with a status glyph (`pending`, `active`, `complete`, `failed`, `stopped`, `waiting`, `skipped`), a label, a one-line `description` and folded detail. Open while `busy`, folded to its summary when the work is done, and a click always wins; `aria-expanded` on the toggle, the summary is a polite live region, the spinner and chevron respect reduced motion. Modelled on the "Chain of Thought" shape of Vercel AI Elements (no code copied). The assistant chat's tool calls and a plan checklist draw with it. |
|
|
1457
1458
|
| `Stepper` | A linear wizard's progress strip — numbered circles, connectors, `aria-current="step"`. Controlled like Tabs; completed steps are clickable to go back (when `onChange` is wired), upcoming steps never are — moving forward belongs to the wizard's own Continue button, behind its validation. |
|
|
1458
1459
|
| `DataTable` | Read-only table for server-driven lists: it renders and reports, and never sorts or pages its own `data`. Controlled sort and pager, row selection, column groups, pinned columns, windowed rendering. `onRow` gives a row `onClick`, a `className`, any `data-*` attributes for its `<tr>` — a test's or a stylesheet's hook (`data-testid`, `data-state`) — the pointer and the keyboard coming in and out (`onMouseEnter` … `onBlur`) and `current`. `rowHref` makes each row one real link (`onRowPress` a button) with its controls still pressable — see [DataTable rows that are links](#datatable-rows-that-are-links). `stackOnNarrow` turns each row into a labelled card on a narrow container — see [DataTable on a narrow screen](#datatable-on-a-narrow-screen). |
|
|
1459
1460
|
| `Pagination` | Numbered page control (pairs with tables; complements `ListFooter`). |
|
|
@@ -3959,6 +3960,70 @@ Every word the map draws on its own account — a group's name, "Full screen",
|
|
|
3959
3960
|
the could-not-draw line, `SelectedCard`'s buttons — is the `map` section of
|
|
3960
3961
|
`ShellStrings`.
|
|
3961
3962
|
|
|
3963
|
+
### AI — `efficient-shell/ai`
|
|
3964
|
+
|
|
3965
|
+
One chat for the admin portal, the dealer portal and the storefront. It talks
|
|
3966
|
+
to the backend's `POST <apiBase>/assistant/chat/` (a Vercel AI UI-message
|
|
3967
|
+
stream) and restores a thread from `GET <apiBase>/assistant/chat/<id>/`. The
|
|
3968
|
+
server keeps the history and every pending approval, so a request carries only
|
|
3969
|
+
the new text or the approval answers plus the conversation id; the message
|
|
3970
|
+
history is never sent.
|
|
3971
|
+
|
|
3972
|
+
It needs the Vercel AI SDK, as optional peers: `npm i ai @ai-sdk/react` (and
|
|
3973
|
+
`zod`, which `ai` requires). A host that never imports this entry installs
|
|
3974
|
+
none of them. `StepChain`, which the chat draws its tool calls and plans with,
|
|
3975
|
+
is a general UI-kit component: import it from `efficient-shell/ui`, not from
|
|
3976
|
+
here.
|
|
3977
|
+
|
|
3978
|
+
```tsx
|
|
3979
|
+
import { AssistantChat } from 'efficient-shell/ai';
|
|
3980
|
+
|
|
3981
|
+
<AssistantChat
|
|
3982
|
+
variant="panel" // 'panel' | 'window' | 'bubble'
|
|
3983
|
+
apiBase="/api/v1"
|
|
3984
|
+
getHeaders={async () => ({ Authorization: `Bearer ${await token()}`, 'X-Portal-Audience': 'dealer' })}
|
|
3985
|
+
conversationId={saved?.id} // restored on mount
|
|
3986
|
+
onConversation={(c) => save(c)} // { id, guestToken? }, or null for a new chat
|
|
3987
|
+
toolLabels={{
|
|
3988
|
+
check_stock: { label: 'Check stock', done: 'Checked stock', describe: (i) => `for ${i.part_number}` },
|
|
3989
|
+
create_quote: 'Create quote',
|
|
3990
|
+
}}
|
|
3991
|
+
/>
|
|
3992
|
+
```
|
|
3993
|
+
|
|
3994
|
+
* `window` fills its container (a shell window); `panel` is a docked side
|
|
3995
|
+
panel; `bubble` is a floating launcher that opens the panel.
|
|
3996
|
+
* Tool calls read as one status line ("Checked stock for PN-1042") with their
|
|
3997
|
+
input behind Details as a list, never as JSON. Reasoning and tool output
|
|
3998
|
+
show only in `window`. A tool that needs approval shows Approve / Deny; the
|
|
3999
|
+
answer continues the turn on its own.
|
|
4000
|
+
* To show a person's reply the moment it is sent, pass `subscribe`: called once
|
|
4001
|
+
the conversation exists with `(conversation, refresh)`, it opens the host's
|
|
4002
|
+
live channel (the storefront opens the backend's chat socket) and calls
|
|
4003
|
+
`refresh()` when something arrived; return a function that closes it. The
|
|
4004
|
+
chat adds only the staff and system messages it is missing, waits for a
|
|
4005
|
+
streaming turn to end, and never replaces what is on screen. With it, the
|
|
4006
|
+
chat does not read the history after each turn.
|
|
4007
|
+
* A host that is not a portal and does not compile this package with Tailwind
|
|
4008
|
+
imports `efficient-shell/ai.css`: only the utilities the chat is
|
|
4009
|
+
drawn with, scoped under `.rosh-assistant` (the `bubble` variant wraps itself in
|
|
4010
|
+
it), with their values inlined: no reset, no theme variables, nothing that can
|
|
4011
|
+
override a host's own `font-mono` or `bg-white` (never `ui.css`, which
|
|
4012
|
+
restyles bare elements). The launcher and panel stack on `--z-window` (1000 when the
|
|
4013
|
+
host does not define it).
|
|
4014
|
+
* `getHeaders` is called per request (JWT, `X-Portal-Audience`, or the guest
|
|
4015
|
+
`X-Chat-Token`); `credentials` sets the fetch credentials mode; `labels`
|
|
4016
|
+
rewords or translates the chat's own text.
|
|
4017
|
+
* **Plans.** When the assistant needs two or more changes, the server sends a
|
|
4018
|
+
`data-plan` part (re-sent whole, same id, on every change). The chat pins it
|
|
4019
|
+
above the composer as a `StepChain` ("Plan: 2 of 3 done · in progress"):
|
|
4020
|
+
open while the plan waits or runs, folded to that line once it has ended and
|
|
4021
|
+
until the next message; the line is announced as it changes. The plan's
|
|
4022
|
+
approval is one card in the thread, never folded, listing every step by its
|
|
4023
|
+
`toolLabels` name and inputs, with one Approve plan / Deny. Every status shown
|
|
4024
|
+
is the server's record of what ran. A reload restores a plan still waiting or
|
|
4025
|
+
running from the history's `plans`.
|
|
4026
|
+
|
|
3962
4027
|
### Formatters
|
|
3963
4028
|
|
|
3964
4029
|
One copy of each, for every portal. Dates follow two settings of the reader's:
|
|
@@ -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-55NGVBTR.js";import{WindowTitle as r}from"./chunk-EZTEOTUD.js";import"./chunk-VJ6KJYRS.js";import"./chunk-JGWOY2KV.js";import"./chunk-USLPE6K3.js";import"./chunk-KNUR2UEG.js";import{confirm as a}from"./chunk-GFWRYNPX.js";import"./chunk-DSSLOQDW.js";import"./chunk-5A7MWTXX.js";import"./chunk-MMLU5ZHI.js";import"./chunk-UVBK6YSR.js";import"./chunk-G5GERM76.js";import"./chunk-3E27HV76.js";import"./chunk-7IQ3B77H.js";import"./chunk-FIEA5CGB.js";import"./chunk-K7PQXJO7.js";import"./chunk-D65T4H6J.js";import{Icon as n}from"./chunk-YT4B3NSV.js";import"./chunk-LVCRH3K6.js";import"./chunk-C3QOHMR6.js";import"./chunk-2J6F4EE7.js";import{useRef as s,useEffect as l,useState as i}from"react";import{jsxs as c,jsx as m,Fragment as d}from"react/jsx-runtime";var u="react-os-shell:browser-bookmarks",h="react-os-shell:browser-homepage",p="https://en.wikipedia.org/wiki/Main_Page",g=[{label:"Wikipedia",url:"https://en.wikipedia.org/wiki/Main_Page"},{label:"DevDocs",url:"https://devdocs.io"},{label:"Example",url:"https://example.com"}],b=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 f(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&&b.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 x(){if("undefined"==typeof window)return g;try{const e=localStorage.getItem(u);if(!e)return g;const t=JSON.parse(e);if(Array.isArray(t)&&t.every(e=>"string"==typeof e?.url))return t}catch{}return g}function w(){return"undefined"==typeof window?p:localStorage.getItem(h)||p}function y(){const d=s(void 0);void 0===d.current&&(d.current=e()),l(()=>{null!=d.current&&t(d.current)},[]);const p=d.current?f(d.current.url):"",[g,b]=i(w),[k,y]=i(p||g),[j,C]=i(k),[z,R]=i([k]),[S,E]=i(0),[W,L]=i(0),[H,T]=i(x),[U,D]=i(!1),[O,G]=i(null),K=s(null),I=s(null);l(()=>{try{localStorage.setItem(u,JSON.stringify(H))}catch{}},[H]);const M=e=>{const t=f(e);t&&(y(t),C(t),R(e=>{const o=e.slice(0,S+1);return o.push(t),o}),E(e=>e+1),D(!1))},B=()=>{"undefined"!=typeof window&&window.open(k,"_blank","noopener,noreferrer")},J=()=>{const e=O?.trim();e?(T(t=>[...t,{label:e,url:k}]),G(null)):G(null)};l(()=>{if(null===O)return;K.current?.focus(),K.current?.select();const e=e=>{const t=e.target;t?.closest("[data-bookmark-popover]")||G(null)},t=setTimeout(()=>document.addEventListener("mousedown",e),0);return()=>{clearTimeout(t),document.removeEventListener("mousedown",e)}},[null!==O]);const P=e=>{T(t=>t.filter((t,o)=>o!==e))},F=S>0,V=S<z.length-1,q=H.some(e=>e.url===k),X="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(k)}`}),
|
|
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-gray-200 bg-gray-50 shrink-0",children:[
|
|
6
|
-
/* @__PURE__ */m("button",{onClick:()=>{if(
|
|
7
|
-
/* @__PURE__ */m("button",{onClick:()=>{if(
|
|
8
|
-
/* @__PURE__ */m("button",{onClick:()=>L(e=>e+1),className:
|
|
9
|
-
/* @__PURE__ */m("button",{onClick:()=>
|
|
10
|
-
/* @__PURE__ */m("form",{onSubmit:e=>{e.preventDefault(),
|
|
6
|
+
/* @__PURE__ */m("button",{onClick:()=>{if(S>0){const e=S-1;E(e),y(z[e]),C(z[e]),D(!1)}},disabled:!F,className:X,title:"Back",children:/* @__PURE__ */m(n,{name:"chevron-left",className:"h-4 w-4",strokeWidth:2})}),
|
|
7
|
+
/* @__PURE__ */m("button",{onClick:()=>{if(S<z.length-1){const e=S+1;E(e),y(z[e]),C(z[e]),D(!1)}},disabled:!V,className:X,title:"Forward",children:/* @__PURE__ */m(n,{name:"chevron-right",className:"h-4 w-4",strokeWidth:2})}),
|
|
8
|
+
/* @__PURE__ */m("button",{onClick:()=>L(e=>e+1),className:X,title:"Refresh",children:/* @__PURE__ */m(n,{name:"refresh",className:"h-4 w-4",strokeWidth:1.8})}),
|
|
9
|
+
/* @__PURE__ */m("button",{onClick:()=>M(g),className:X,title:"Home",children:/* @__PURE__ */m(n,{name:"home",className:"h-4 w-4",strokeWidth:1.8})}),
|
|
10
|
+
/* @__PURE__ */m("form",{onSubmit:e=>{e.preventDefault(),M(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:k.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…"}),k!==j&&/* @__PURE__ */m("button",{type:"button",onClick:()=>C(k),className:"px-2 text-2xs text-gray-400 hover:text-gray-700",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?P(H.findIndex(e=>e.url===k)):void G(v(k)),className:X+" "+(q?"text-yellow-500":""),title:q?"Remove bookmark":"Add bookmark",children:/* @__PURE__ */m(n,{name:"star",className:"h-4 w-4",fill:q?"currentColor":"none",strokeWidth:1.5})}),
|
|
14
|
+
/* @__PURE__ */m("button",{onClick:B,className:X,title:"Open in new tab",children:/* @__PURE__ */m(n,{name:"external",className:"h-4 w-4",strokeWidth:1.5})}),
|
|
15
|
+
/* @__PURE__ */m("button",{onClick:()=>D(e=>!e),className:X,title:"Embedding help",children:/* @__PURE__ */m(n,{name:"help",className:"h-4 w-4",strokeWidth:1.5})})]}),null!==O&&/* @__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-gray-500 mb-1",children:"Bookmark this page"}),
|
|
17
17
|
/* @__PURE__ */m("div",{className:"text-2xs text-gray-400 truncate mb-2 font-mono",title:k,children:k}),
|
|
18
|
-
/* @__PURE__ */m("input",{ref:
|
|
18
|
+
/* @__PURE__ */m("input",{ref:K,type:"text",value:O,onChange:e=>G(e.target.value),onKeyDown:e=>{"Enter"===e.key?J():"Escape"===e.key&&G(null)},placeholder:"Name",className:"w-full text-sm px-2 h-8 border border-gray-300 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:J,disabled:!
|
|
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:()=>G(null),className:"px-2 py-1 text-xs text-gray-600 hover:bg-gray-100 rounded",children:"Cancel"}),
|
|
21
|
+
/* @__PURE__ */m("button",{onClick:J,disabled:!O.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===H.length&&/* @__PURE__ */m("span",{className:"text-2xs text-gray-400 italic px-2",children:"No bookmarks yet — star the address bar to add one."}),H.map((e,t)=>/* @__PURE__ */c("button",{onClick:()=>M(e.url),onContextMenu:async o=>{o.preventDefault();await a({title:"Remove bookmark",message:`"${e.label}" will be removed from your bookmarks.`,confirmLabel:"Remove",variant:"danger"})&&P(t)},className:"flex items-center gap-2 px-2 py-0.5 rounded text-xs text-gray-700 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:()=>{b(k);try{localStorage.setItem(h,k)}catch{}},className:"px-2 py-0.5 text-2xs text-gray-500 hover:text-gray-800",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:k,iframeKey:
|
|
26
|
+
/* @__PURE__ */m("div",{className:"flex-1 relative min-h-0 bg-gray-50",children:/* @__PURE__ */m(N,{url:k,iframeKey:W,iframeRef:I,openExternal:B,showHelp:U,dismissHelp:()=>D(!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:a,dismissHelp:s}){const[u,h]=i(!1);l(()=>{h(!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)&&!u?/* @__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(n,{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 ",
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import{loadAppearance as e,WidgetSettingsModal as t}from"./chunk-BMYURA2N.js";import{useWidgetSettings as n}from"./chunk-EZTEOTUD.js";import"./chunk-VJ6KJYRS.js";import"./chunk-JGWOY2KV.js";import"./chunk-KNUR2UEG.js";import"./chunk-GFWRYNPX.js";import"./chunk-DSSLOQDW.js";import"./chunk-5A7MWTXX.js";import"./chunk-MMLU5ZHI.js";import"./chunk-UVBK6YSR.js";import"./chunk-G5GERM76.js";import"./chunk-3E27HV76.js";import"./chunk-7IQ3B77H.js";import"./chunk-FIEA5CGB.js";import"./chunk-K7PQXJO7.js";import"./chunk-D65T4H6J.js";import{Icon as r}from"./chunk-YT4B3NSV.js";import"./chunk-LVCRH3K6.js";import"./chunk-C3QOHMR6.js";import"./chunk-2J6F4EE7.js";import{useState as l,useRef as c,useCallback as i,useEffect as a}from"react";import{jsxs as o,Fragment as s,jsx as u}from"react/jsx-runtime";var h="calc_appearance";function d(){const[d,m]=l("0"),[k,b]=l(null),[p,g]=l(null),[N,y]=l(!1),[x,f]=l(""),[v,C]=l([]),[$,j]=l(!1),[E,w]=l(()=>e(h)),[S,T]=l(!1),[R,W]=l(E),B=c(null);n(i(()=>{W({...E}),T(!0)},[E]));const F=i(e=>{f(""),m(t=>N||"0"===t?(y(!1),"."===e?"0.":e):"."===e&&t.includes(".")?t:t+e)},[N]),A=i(()=>{m("0"),b(null),g(null),y(!1)},[]),J=i((e,t,n)=>{switch(n){case"+":return e+t;case"-":return e-t;case"×":return e*t;case"÷":return 0===t?0:e/t;default:return t}},[]),M=i(e=>{const t=parseFloat(d);if(null!==k&&p&&!N){const e=J(k,t,p);m(String(e)),b(e),C(n=>[`${k} ${p} ${t} = ${e}`,...n].slice(0,20))}else b(t);g(e),y(!0)},[d,k,p,N,J]),O=i(()=>{if(null===k||!p)return;const e=parseFloat(d),t=J(k,e,p),n=`${k} ${p} ${e} =`;C(e=>[`${n} ${t}`,...e].slice(0,20)),f(n),m(String(t)),b(null),g(null),y(!0)},[d,k,p,J]),U=i(()=>{m(e=>String(parseFloat(e)/100))},[]),D=i(()=>{m(e=>e.startsWith("-")?e.slice(1):"0"===e?e:"-"+e)},[]);a(()=>{const e=e=>{const t=e.target.tagName;"INPUT"!==t&&"TEXTAREA"!==t&&"SELECT"!==t&&(e.key>="0"&&e.key<="9"?F(e.key):"."===e.key?F("."):"+"===e.key?M("+"):"-"===e.key?M("-"):"*"===e.key?M("×"):"/"===e.key?(e.preventDefault(),M("÷")):"Enter"===e.key||"="===e.key?("Enter"===e.key&&e.target instanceof Node&&B.current?.contains(e.target)&&e.preventDefault(),O()):"Escape"===e.key?A():"Backspace"===e.key?m(e=>e.length>1?e.slice(0,-1):"0"):"%"===e.key&&U())};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[F,M,O,A,U]);const G="flex items-center justify-center rounded-lg text-sm font-medium transition-colors",H=`${G} bg-white border border-gray-200 text-gray-900 hover:bg-gray-50 active:bg-gray-100`,K=`${G} bg-blue-50 border border-blue-200 text-blue-700 hover:bg-blue-100 active:bg-blue-200`,L=`${G} bg-gray-100 border border-gray-200 text-gray-600 hover:bg-gray-200 active:bg-gray-300`,V=`${G} bg-blue-600 text-white hover:bg-blue-700 active:bg-blue-800`;/* @__PURE__ */
|
|
2
|
+
return o(s,{children:[
|
|
3
|
+
/* @__PURE__ */o("div",{ref:B,className:"flex flex-col h-full",style:{opacity:E.activeOpacity/100,backdropFilter:E.activeBlur>0?`blur(${E.activeBlur}px)`:void 0},children:[
|
|
4
|
+
/* @__PURE__ */o("div",{className:"bg-slate-200 rounded-t-lg px-4 py-2 group/display relative flex flex-col justify-end min-h-[120px] border-b border-slate-300",children:[
|
|
5
|
+
/* @__PURE__ */u("div",{className:"flex flex-col justify-end flex-1 overflow-hidden",children:v.slice(0,3).reverse().map((e,t)=>/* @__PURE__ */u("div",{className:"text-2xs text-slate-400 text-right font-mono truncate",children:e},t))}),(x||p&&null!==k)&&/* @__PURE__ */u("div",{className:"text-base text-slate-600 text-right font-mono",children:x||`${k} ${p} ${N?"":d}`}),
|
|
6
|
+
/* @__PURE__ */o("div",{className:"flex items-center gap-2",children:[
|
|
7
|
+
/* @__PURE__ */u("button",{onClick:()=>{navigator.clipboard.writeText(d),j(!0),setTimeout(()=>j(!1),1200)},title:"Copy result",className:"shrink-0 text-slate-300 hover:text-slate-500 transition-colors opacity-0 group-hover/display:opacity-100",children:/* @__PURE__ */u(r,$?{name:"check",className:"h-5 w-5 text-green-500",strokeWidth:2}:{name:"copy",className:"h-5 w-5",strokeWidth:2})}),
|
|
8
|
+
/* @__PURE__ */u("div",{className:"text-right text-4xl font-mono font-bold text-slate-800 truncate flex-1",children:(e=>{const t=parseFloat(e);return isNaN(t)||e.endsWith(".")||e.endsWith(".0")||Math.abs(t)<1e15&&e.length<16?e:t.toExponential(6)})(d)})]})]}),
|
|
9
|
+
/* @__PURE__ */o("div",{className:"grid grid-cols-4 grid-rows-5 gap-2 flex-1 min-h-0 p-2",children:[
|
|
10
|
+
/* @__PURE__ */u("button",{onClick:A,className:L,children:"AC"}),
|
|
11
|
+
/* @__PURE__ */u("button",{onClick:D,className:L,children:"+/−"}),
|
|
12
|
+
/* @__PURE__ */u("button",{onClick:U,className:L,children:"%"}),
|
|
13
|
+
/* @__PURE__ */u("button",{onClick:()=>M("÷"),className:`${K} ${"÷"===p?"ring-2 ring-blue-400":""}`,children:"÷"}),
|
|
14
|
+
/* @__PURE__ */u("button",{onClick:()=>F("7"),className:H,children:"7"}),
|
|
15
|
+
/* @__PURE__ */u("button",{onClick:()=>F("8"),className:H,children:"8"}),
|
|
16
|
+
/* @__PURE__ */u("button",{onClick:()=>F("9"),className:H,children:"9"}),
|
|
17
|
+
/* @__PURE__ */u("button",{onClick:()=>M("×"),className:`${K} ${"×"===p?"ring-2 ring-blue-400":""}`,children:"×"}),
|
|
18
|
+
/* @__PURE__ */u("button",{onClick:()=>F("4"),className:H,children:"4"}),
|
|
19
|
+
/* @__PURE__ */u("button",{onClick:()=>F("5"),className:H,children:"5"}),
|
|
20
|
+
/* @__PURE__ */u("button",{onClick:()=>F("6"),className:H,children:"6"}),
|
|
21
|
+
/* @__PURE__ */u("button",{onClick:()=>M("-"),className:`${K} ${"-"===p?"ring-2 ring-blue-400":""}`,children:"−"}),
|
|
22
|
+
/* @__PURE__ */u("button",{onClick:()=>F("1"),className:H,children:"1"}),
|
|
23
|
+
/* @__PURE__ */u("button",{onClick:()=>F("2"),className:H,children:"2"}),
|
|
24
|
+
/* @__PURE__ */u("button",{onClick:()=>F("3"),className:H,children:"3"}),
|
|
25
|
+
/* @__PURE__ */u("button",{onClick:()=>M("+"),className:`${K} ${"+"===p?"ring-2 ring-blue-400":""}`,children:"+"}),
|
|
26
|
+
/* @__PURE__ */u("button",{onClick:()=>F("0"),className:`${H} col-span-2`,children:"0"}),
|
|
27
|
+
/* @__PURE__ */u("button",{onClick:()=>F("."),className:H,children:"."}),
|
|
28
|
+
/* @__PURE__ */u("button",{onClick:O,className:V,children:"="})]})]}),
|
|
29
|
+
/* @__PURE__ */u(t,{open:S,onClose:()=>T(!1),title:"Calculator Settings",appearance:R,onAppearanceChange:W,onSave:()=>{w(R),localStorage.setItem(h,JSON.stringify(R)),T(!1)}})]})}export{d as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export{ConfirmProvider,confirm,confirmDestructive,prompt,useConfirm}from"./chunk-GFWRYNPX.js";import"./chunk-UVBK6YSR.js";import"./chunk-FIEA5CGB.js";import"./chunk-K7PQXJO7.js";import"./chunk-YT4B3NSV.js";import"./chunk-LVCRH3K6.js";import"./chunk-C3QOHMR6.js";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import{loadAppearance as e,WidgetSettingsModal as t}from"./chunk-
|
|
1
|
+
import{loadAppearance as e,WidgetSettingsModal as t}from"./chunk-BMYURA2N.js";import{useWidgetSettings as r}from"./chunk-EZTEOTUD.js";import"./chunk-VJ6KJYRS.js";import"./chunk-JGWOY2KV.js";import"./chunk-KNUR2UEG.js";import"./chunk-GFWRYNPX.js";import"./chunk-DSSLOQDW.js";import"./chunk-5A7MWTXX.js";import"./chunk-MMLU5ZHI.js";import"./chunk-UVBK6YSR.js";import"./chunk-G5GERM76.js";import"./chunk-3E27HV76.js";import"./chunk-7IQ3B77H.js";import"./chunk-FIEA5CGB.js";import"./chunk-K7PQXJO7.js";import"./chunk-D65T4H6J.js";import"./chunk-YT4B3NSV.js";import"./chunk-LVCRH3K6.js";import"./chunk-C3QOHMR6.js";import{LoadingSpinner as n}from"./chunk-2J6F4EE7.js";import{useState as a,useCallback as s,useEffect as o}from"react";import{jsxs as c,Fragment as i,jsx as l}from"react/jsx-runtime";var m=["USD","CNY","AUD","GBP","EUR","JPY","CAD","THB","NZD","SGD","HKD","CHF","KRW","INR","MXN","BRL"],u=[["USD","CNY"],["USD","AUD"],["GBP","USD"],["USD","JPY"]],p="currency_pairs",d="currency_appearance",h="currency_rates_cache";function g(e){try{const t=JSON.parse(localStorage.getItem(h)||"{}")[e];if(t&&Date.now()-t.timestamp<36e5)return t.rates}catch{}return null}function f(e,t){try{const r=JSON.parse(localStorage.getItem(h)||"{}");r[e]={rates:t,timestamp:Date.now()},localStorage.setItem(h,JSON.stringify(r))}catch{}}function y(){try{const e=JSON.parse(localStorage.getItem(p)||"");if(Array.isArray(e)&&e.length)return e.slice(0,4)}catch{}return u}var x={USD:"🇺🇸",CNY:"🇨🇳",AUD:"🇦🇺",GBP:"🇬🇧",JPY:"🇯🇵",CAD:"🇨🇦",EUR:"🇪🇺",THB:"🇹🇭",NZD:"🇳🇿",SGD:"🇸🇬",HKD:"🇭🇰",CHF:"🇨🇭",KRW:"🇰🇷",INR:"🇮🇳",MXN:"🇲🇽",BRL:"🇧🇷"};function N(){const[u,h]=a(y),[N,b]=a(()=>e(d)),[S,k]=a({}),[v,D]=a(!1),[j,C]=a(!1),[U,J]=a([]),[R,B]=a(N),[O,Y]=a("USD"),[A,H]=a("CNY");r(s(()=>{J([...u]),B({...N}),C(!0)},[u,N])),o(()=>{const e=[...new Set(u.map(([e])=>e))];let t=!0;return async function(){D(!0);const r={};for(const t of e){const e=g(t);if(e)r[t]=e;else try{const e=await fetch(`https://open.er-api.com/v6/latest/${t}`),n=await e.json();n.rates&&(r[t]=n.rates,f(t,n.rates))}catch{}}t&&(k(r),D(!1))}(),()=>{t=!1}},[u]);/* @__PURE__ */
|
|
2
2
|
return c(i,{children:[
|
|
3
|
-
/* @__PURE__ */l("div",{style:{backgroundColor:`rgb(var(--taskbar-bg-rgb, 243 244 246) / ${N.activeOpacity/100})`,backdropFilter:N.activeBlur>0?`blur(${N.activeBlur}px)`:void 0},children:/* @__PURE__ */c("div",{className:"px-4 py-3 space-y-1",children:[v&&/* @__PURE__ */l(n,{size:"sm",padding:"py-4",label:"Loading rates"}),u.map(([e,t],r)=>{const n=
|
|
3
|
+
/* @__PURE__ */l("div",{style:{backgroundColor:`rgb(var(--taskbar-bg-rgb, 243 244 246) / ${N.activeOpacity/100})`,backdropFilter:N.activeBlur>0?`blur(${N.activeBlur}px)`:void 0},children:/* @__PURE__ */c("div",{className:"px-4 py-3 space-y-1",children:[v&&/* @__PURE__ */l(n,{size:"sm",padding:"py-4",label:"Loading rates"}),u.map(([e,t],r)=>{const n=S[e]?.[t];/* @__PURE__ */
|
|
4
4
|
return c("button",{onClick:()=>{const e=u.map((e,t)=>t===r?[e[1],e[0]]:e);h(e),localStorage.setItem(p,JSON.stringify(e))},className:"flex items-center justify-between px-2 py-2 border-b border-gray-200 last:border-0 w-full hover:bg-gray-100 rounded transition-colors cursor-pointer",children:[
|
|
5
5
|
/* @__PURE__ */c("div",{className:"flex items-center gap-2",children:[
|
|
6
6
|
/* @__PURE__ */l("span",{className:"text-base",children:x[e]||""}),
|
|
@@ -9,13 +9,13 @@ return c("button",{onClick:()=>{const e=u.map((e,t)=>t===r?[e[1],e[0]]:e);h(e),l
|
|
|
9
9
|
/* @__PURE__ */l("span",{className:"text-base",children:x[t]||""}),
|
|
10
10
|
/* @__PURE__ */l("span",{className:"text-sm font-semibold text-gray-700",children:t})]}),
|
|
11
11
|
/* @__PURE__ */l("div",{className:"text-base font-mono font-semibold text-gray-900 tabular-nums",children:null!=n?n.toLocaleString(void 0,{minimumFractionDigits:2,maximumFractionDigits:4}):"—"})]},`${e}-${t}-${r}`)})]})}),
|
|
12
|
-
/* @__PURE__ */l(t,{open:
|
|
12
|
+
/* @__PURE__ */l(t,{open:j,onClose:()=>C(!1),title:"Currency Settings",appearance:R,onAppearanceChange:B,onSave:()=>{if(0===U.length)return;const e=U.slice(0,4);h(e),b(R),localStorage.setItem(p,JSON.stringify(e)),localStorage.setItem(d,JSON.stringify(R)),C(!1)},children:/* @__PURE__ */c("div",{children:[
|
|
13
13
|
/* @__PURE__ */c("h3",{className:"text-sm font-semibold text-gray-700 mb-2",children:["Currency Pairs ",
|
|
14
14
|
/* @__PURE__ */c("span",{className:"text-2xs font-normal text-gray-400",children:["(",U.length,"/",4,")"]})]}),
|
|
15
15
|
/* @__PURE__ */l("div",{className:"space-y-1 mb-2",children:U.map(([e,t],r)=>/* @__PURE__ */c("div",{className:"flex items-center justify-between py-1 px-2 bg-gray-50 rounded",children:[
|
|
16
16
|
/* @__PURE__ */c("span",{className:"text-sm",children:[x[e]||""," ",e," → ",x[t]||""," ",t]}),
|
|
17
17
|
/* @__PURE__ */l("button",{onClick:()=>J(e=>e.filter((e,t)=>t!==r)),className:"text-red-400 hover:text-red-600",children:"×"})]},r))}),U.length<4?/* @__PURE__ */c("div",{className:"flex items-center gap-2",children:[
|
|
18
|
-
/* @__PURE__ */l("select",{value:
|
|
18
|
+
/* @__PURE__ */l("select",{value:O,onChange:e=>Y(e.target.value),className:"bg-gray-50 border border-gray-200 rounded px-2 py-1 text-sm focus:outline-none focus:ring-1 focus:ring-blue-500",children:m.map(e=>/* @__PURE__ */l("option",{children:e},e))}),
|
|
19
19
|
/* @__PURE__ */l("span",{className:"text-gray-400",children:"→"}),
|
|
20
|
-
/* @__PURE__ */l("select",{value:
|
|
21
|
-
/* @__PURE__ */l("button",{onClick:()=>{A
|
|
20
|
+
/* @__PURE__ */l("select",{value:A,onChange:e=>H(e.target.value),className:"bg-gray-50 border border-gray-200 rounded px-2 py-1 text-sm focus:outline-none focus:ring-1 focus:ring-blue-500",children:m.map(e=>/* @__PURE__ */l("option",{children:e},e))}),
|
|
21
|
+
/* @__PURE__ */l("button",{onClick:()=>{O!==A&&U.length<4&&J(e=>[...e,[O,A]])},className:"text-sm font-medium text-blue-600 hover:text-blue-800 px-2",children:"+ Add"})]}):/* @__PURE__ */c("p",{className:"text-2xs text-gray-400 italic",children:["Max ",4," pairs — remove one to add another."]})]})})]})}export{N as default};
|
|
@@ -1,25 +1,25 @@
|
|
|
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-55NGVBTR.js";import{WindowTitle as n}from"./chunk-EZTEOTUD.js";import"./chunk-VJ6KJYRS.js";import{toast_default as r}from"./chunk-WSRZRWN7.js";import"./chunk-JGWOY2KV.js";import"./chunk-USLPE6K3.js";import"./chunk-KNUR2UEG.js";import"./chunk-GFWRYNPX.js";import"./chunk-DSSLOQDW.js";import"./chunk-5A7MWTXX.js";import{PopupMenu as o,PopupMenuLabel as l,PopupMenuItem as a,PopupMenuDivider as i}from"./chunk-MMLU5ZHI.js";import"./chunk-UVBK6YSR.js";import"./chunk-G5GERM76.js";import"./chunk-3E27HV76.js";import"./chunk-7IQ3B77H.js";import"./chunk-FIEA5CGB.js";import"./chunk-K7PQXJO7.js";import"./chunk-D65T4H6J.js";import{Icon as s}from"./chunk-YT4B3NSV.js";import"./chunk-LVCRH3K6.js";import"./chunk-C3QOHMR6.js";import{LoadingSpinner as c}from"./chunk-2J6F4EE7.js";import{useState as d,useRef as m}from"react";import{jsxs as h,jsx as u}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]=d(x),[v,b]=d(!1),[k,w]=d(!1),[N,j]=d(!1),[C,D]=d(null),L=m(null),M=m(null),R=m(null),U=(e,t)=>{R.current?.focus(),document.execCommand(e,!1,t),j(!0)},W=e=>{for(const t of e){if(!t.type.startsWith("image/"))continue;const e=new FileReader;e.onload=()=>{R.current?.focus(),document.execCommand("insertImage",!1,String(e.result)),j(!0)},e.readAsDataURL(t)}},B=e=>{C&&(C.el.removeAttribute("width"),C.el.removeAttribute("height"),C.el.style.width=e??"",C.el.style.height=e?"auto":"",j(!0),D(null))},S=async t=>{const n=(t.name.split(".").pop()||"").toLowerCase();b(!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}),j(!1)}else if(g.has(n))try{const e=await(import(
|
|
2
2
|
/* @vite-ignore */
|
|
3
|
-
"mammoth")),
|
|
4
|
-
return h("div",{className:"relative flex flex-col h-full",onDragOver:e=>{e.preventDefault(),k||w(!0)},onDragLeave:e=>{e.currentTarget===e.target&&w(!1)},onDrop:e=>{e.preventDefault(),w(!1);const t=Array.from(e.dataTransfer.files??[]);0!==t.length&&(t.every(e=>e.type.startsWith("image/"))?W(t):
|
|
5
|
-
/* @__PURE__ */u(
|
|
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}),j(!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{b(!1)}},T=f?.filename?(O=f.filename).length>24?`${O.slice(0,23)}…`:O:"Untitled";var O;/* @__PURE__ */
|
|
4
|
+
return h("div",{className:"relative flex flex-col h-full",onDragOver:e=>{e.preventDefault(),k||w(!0)},onDragLeave:e=>{e.currentTarget===e.target&&w(!1)},onDrop:e=>{e.preventDefault(),w(!1);const t=Array.from(e.dataTransfer.files??[]);0!==t.length&&(t.every(e=>e.type.startsWith("image/"))?W(t):S(t[0]))},children:[
|
|
5
|
+
/* @__PURE__ */u(n,{title:`${T}${N?" •":""} - Documents`}),
|
|
6
6
|
/* @__PURE__ */u(t,{app:"documents"}),
|
|
7
7
|
/* @__PURE__ */h("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__ */u("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__ */u("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&&S(t),L.current&&(L.current.value="")},className:"hidden"}),
|
|
9
9
|
/* @__PURE__ */h("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
|
-
/* @__PURE__ */u(
|
|
11
|
-
/* @__PURE__ */u("button",{onClick:()=>{if(!f)return;const t=
|
|
10
|
+
/* @__PURE__ */u(s,{name:"folder-open",className:"h-3.5 w-3.5",strokeWidth:1.5}),"Open"]}),
|
|
11
|
+
/* @__PURE__ */u("button",{onClick:()=>{if(!f)return;const t=R.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=R.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"}),
|
|
12
12
|
/* @__PURE__ */u("span",{className:"text-2xs text-gray-400 ml-1",children:"TXT · DOCX · Code"}),
|
|
13
13
|
/* @__PURE__ */u("div",{className:"h-4 w-px bg-gray-300 mx-1"}),
|
|
14
14
|
/* @__PURE__ */h("span",{className:"text-xs font-medium text-gray-700 truncate max-w-[200px]",title:f.filename,children:[f.filename,N?" •":""]}),
|
|
15
15
|
/* @__PURE__ */u("div",{className:"h-4 w-px bg-gray-300 mx-1"}),
|
|
16
16
|
/* @__PURE__ */h("div",{className:"flex items-center gap-0.5",children:[
|
|
17
|
-
/* @__PURE__ */u("button",{onMouseDown:e=>e.preventDefault(),onClick:()=>
|
|
18
|
-
/* @__PURE__ */u("button",{onMouseDown:e=>e.preventDefault(),onClick:()=>
|
|
19
|
-
/* @__PURE__ */u("button",{onMouseDown:e=>e.preventDefault(),onClick:()=>
|
|
20
|
-
/* @__PURE__ */u("button",{onMouseDown:e=>e.preventDefault(),onClick:()=>
|
|
17
|
+
/* @__PURE__ */u("button",{onMouseDown:e=>e.preventDefault(),onClick:()=>U("bold"),className:"px-2 py-1 text-xs rounded font-bold text-gray-700 hover:bg-gray-200 transition-colors",title:"Bold",children:"B"}),
|
|
18
|
+
/* @__PURE__ */u("button",{onMouseDown:e=>e.preventDefault(),onClick:()=>U("italic"),className:"px-2 py-1 text-xs rounded italic text-gray-700 hover:bg-gray-200 transition-colors",title:"Italic",children:"I"}),
|
|
19
|
+
/* @__PURE__ */u("button",{onMouseDown:e=>e.preventDefault(),onClick:()=>U("underline"),className:"px-2 py-1 text-xs rounded underline text-gray-700 hover:bg-gray-200 transition-colors",title:"Underline",children:"U"}),
|
|
20
|
+
/* @__PURE__ */u("button",{onMouseDown:e=>e.preventDefault(),onClick:()=>U("strikeThrough"),className:"px-2 py-1 text-xs rounded line-through text-gray-700 hover:bg-gray-200 transition-colors",title:"Strikethrough",children:"S"})]}),
|
|
21
21
|
/* @__PURE__ */u("div",{className:"h-4 w-px bg-gray-300 mx-1"}),
|
|
22
|
-
/* @__PURE__ */h("select",{onMouseDown:e=>e.preventDefault(),onChange:e=>{
|
|
22
|
+
/* @__PURE__ */h("select",{onMouseDown:e=>e.preventDefault(),onChange:e=>{U("fontSize",e.target.value),e.currentTarget.value=""},defaultValue:"",className:"text-xs border border-gray-300 rounded px-1 py-0.5 bg-white",children:[
|
|
23
23
|
/* @__PURE__ */u("option",{value:"",disabled:!0,children:"Size"}),
|
|
24
24
|
/* @__PURE__ */u("option",{value:"1",children:"XS"}),
|
|
25
25
|
/* @__PURE__ */u("option",{value:"2",children:"S"}),
|
|
@@ -27,21 +27,21 @@ return h("div",{className:"relative flex flex-col h-full",onDragOver:e=>{e.preve
|
|
|
27
27
|
/* @__PURE__ */u("option",{value:"4",children:"L"}),
|
|
28
28
|
/* @__PURE__ */u("option",{value:"5",children:"XL"}),
|
|
29
29
|
/* @__PURE__ */u("option",{value:"6",children:"2XL"})]}),
|
|
30
|
-
/* @__PURE__ */u("input",{type:"color",defaultValue:"#000000",onChange:e=>
|
|
30
|
+
/* @__PURE__ */u("input",{type:"color",defaultValue:"#000000",onChange:e=>U("foreColor",e.target.value),className:"w-7 h-6 border border-gray-300 rounded cursor-pointer",title:"Text color"}),
|
|
31
31
|
/* @__PURE__ */u("div",{className:"h-4 w-px bg-gray-300 mx-1"}),
|
|
32
|
-
/* @__PURE__ */u("button",{onMouseDown:e=>e.preventDefault(),onClick:()=>
|
|
33
|
-
/* @__PURE__ */u("button",{onMouseDown:e=>e.preventDefault(),onClick:()=>
|
|
32
|
+
/* @__PURE__ */u("button",{onMouseDown:e=>e.preventDefault(),onClick:()=>U("insertUnorderedList"),className:"px-2 py-1 text-xs rounded text-gray-700 hover:bg-gray-200 transition-colors",title:"Bulleted list",children:"• List"}),
|
|
33
|
+
/* @__PURE__ */u("button",{onMouseDown:e=>e.preventDefault(),onClick:()=>U("insertOrderedList"),className:"px-2 py-1 text-xs rounded text-gray-700 hover:bg-gray-200 transition-colors",title:"Numbered list",children:"1."}),
|
|
34
34
|
/* @__PURE__ */u("div",{className:"h-4 w-px bg-gray-300 mx-1"}),
|
|
35
35
|
/* @__PURE__ */h("div",{className:"flex items-center gap-0.5",children:[
|
|
36
|
-
/* @__PURE__ */u("button",{onMouseDown:e=>e.preventDefault(),onClick:()=>
|
|
37
|
-
/* @__PURE__ */u("button",{onMouseDown:e=>e.preventDefault(),onClick:()=>
|
|
38
|
-
/* @__PURE__ */u("button",{onMouseDown:e=>e.preventDefault(),onClick:()=>
|
|
39
|
-
/* @__PURE__ */u("button",{onMouseDown:e=>e.preventDefault(),onClick:()=>
|
|
36
|
+
/* @__PURE__ */u("button",{onMouseDown:e=>e.preventDefault(),onClick:()=>U("justifyLeft"),className:"px-2 py-1 rounded text-gray-700 hover:bg-gray-200 transition-colors",title:"Align left",children:/* @__PURE__ */u("svg",{className:"h-3.5 w-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.8,children:/* @__PURE__ */u("path",{strokeLinecap:"round",d:"M3.75 6h16.5M3.75 12h9.75M3.75 18h14.25"})})}),
|
|
37
|
+
/* @__PURE__ */u("button",{onMouseDown:e=>e.preventDefault(),onClick:()=>U("justifyCenter"),className:"px-2 py-1 rounded text-gray-700 hover:bg-gray-200 transition-colors",title:"Align center",children:/* @__PURE__ */u("svg",{className:"h-3.5 w-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.8,children:/* @__PURE__ */u("path",{strokeLinecap:"round",d:"M3.75 6h16.5M7.125 12h9.75M4.875 18h14.25"})})}),
|
|
38
|
+
/* @__PURE__ */u("button",{onMouseDown:e=>e.preventDefault(),onClick:()=>U("justifyRight"),className:"px-2 py-1 rounded text-gray-700 hover:bg-gray-200 transition-colors",title:"Align right",children:/* @__PURE__ */u("svg",{className:"h-3.5 w-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.8,children:/* @__PURE__ */u("path",{strokeLinecap:"round",d:"M3.75 6h16.5M10.5 12h9.75M6 18h14.25"})})}),
|
|
39
|
+
/* @__PURE__ */u("button",{onMouseDown:e=>e.preventDefault(),onClick:()=>U("justifyFull"),className:"px-2 py-1 rounded text-gray-700 hover:bg-gray-200 transition-colors",title:"Justify",children:/* @__PURE__ */u("svg",{className:"h-3.5 w-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.8,children:/* @__PURE__ */u("path",{strokeLinecap:"round",d:"M3.75 6h16.5M3.75 12h16.5M3.75 18h16.5"})})})]}),
|
|
40
40
|
/* @__PURE__ */u("div",{className:"h-4 w-px bg-gray-300 mx-1"}),
|
|
41
41
|
/* @__PURE__ */u("input",{ref:M,type:"file",accept:"image/*",multiple:!0,className:"hidden",onChange:e=>{e.target.files?.length&&W(Array.from(e.target.files)),M.current&&(M.current.value="")}}),
|
|
42
42
|
/* @__PURE__ */h("button",{onClick:()=>M.current?.click(),className:"px-2 py-1 text-xs rounded text-gray-700 hover:bg-gray-200 transition-colors flex items-center gap-1",title:"Insert image (or paste / drop one)",children:[
|
|
43
|
-
/* @__PURE__ */u(
|
|
44
|
-
/* @__PURE__ */u("div",{className:"flex-1 min-h-0 overflow-hidden",children:v?/* @__PURE__ */u(
|
|
43
|
+
/* @__PURE__ */u(s,{name:"image",className:"h-3.5 w-3.5",strokeWidth:1.5}),"Image"]})]}),
|
|
44
|
+
/* @__PURE__ */u("div",{className:"flex-1 min-h-0 overflow-hidden",children:v?/* @__PURE__ */u(c,{size:"sm",padding:"",className:"h-full",label:"Loading"}):/* @__PURE__ */u("div",{className:"h-full overflow-auto "+("docx"===f.kind?"bg-gray-100 px-6 py-8":"bg-white"),children:/* @__PURE__ */u("div",{ref:R,contentEditable:!0,suppressContentEditableWarning:!0,spellCheck:!1,onInput:()=>j(!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(),W(t))},onClick:e=>{const t=e.target;"IMG"===t.tagName&&(e.preventDefault(),D({x:e.clientX,y:e.clientY,el:t}))},dangerouslySetInnerHTML:{__html:f.content},className:"docx"===f.kind?"docs-editor mx-auto w-[8.5in] min-h-[11in] bg-white p-[1in] shadow text-sm 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-sm leading-relaxed text-gray-800 bg-white outline-none whitespace-pre-wrap"})})}),k&&/* @__PURE__ */u("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__ */u("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"})}),C&&/* @__PURE__ */h(o,{minWidth:150,style:{left:C.x,top:C.y},onClose:()=>D(null),children:[
|
|
45
45
|
/* @__PURE__ */u(l,{children:"Image width"}),
|
|
46
46
|
/* @__PURE__ */u(a,{onClick:()=>B("25%"),children:"25%"}),
|
|
47
47
|
/* @__PURE__ */u(a,{onClick:()=>B("50%"),children:"50%"}),
|
|
@@ -49,4 +49,4 @@ return h("div",{className:"relative flex flex-col h-full",onDragOver:e=>{e.preve
|
|
|
49
49
|
/* @__PURE__ */u(a,{onClick:()=>B("100%"),children:"100%"}),
|
|
50
50
|
/* @__PURE__ */u(a,{onClick:()=>B(null),children:"Original size"}),
|
|
51
51
|
/* @__PURE__ */u(i,{}),
|
|
52
|
-
/* @__PURE__ */u(a,{danger:!0,onClick:()=>{
|
|
52
|
+
/* @__PURE__ */u(a,{danger:!0,onClick:()=>{C?.el.remove(),j(!0),D(null)},children:"Remove image"})]})]})}export{f as default};
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import{openPreviewFile as e}from"./chunk-FY3H52BM.js";import{Breadcrumbs as t}from"./chunk-YWJD6RUT.js";import{TH_ONE_LINE as a}from"./chunk-AHN2BTZR.js";import{SidebarLayout as r}from"./chunk-FBXOKW33.js";import{getFilesDemoTree as n}from"./chunk-3ZZ2UPNR.js";import{AboutApp as s}from"./chunk-55NGVBTR.js";import{peekFilesViewRequest as i,consumeFilesViewRequest as l,FILES_SHOW_TRASH_EVENT as o,FILES_OPEN_DESKTOP_FOLDER_EVENT as d,subscribeDesktopFolders as c,getDesktopFoldersSnapshot as m,FolderGlyph as h,DesktopItemMiniIcon as p,desktopItemTypeLabel as u}from"./chunk-4FQTMGCA.js";import"./chunk-ESL5TDNA.js";import"./chunk-VTVSMRFX.js";import{useWindowManager as f,WindowTitle as x}from"./chunk-EZTEOTUD.js";import"./chunk-VJ6KJYRS.js";import{toast_default as g}from"./chunk-WSRZRWN7.js";import"./chunk-JGWOY2KV.js";import"./chunk-USLPE6K3.js";import"./chunk-KNUR2UEG.js";import{confirm as y,prompt as b}from"./chunk-GFWRYNPX.js";import"./chunk-DSSLOQDW.js";import"./chunk-5A7MWTXX.js";import"./chunk-MMLU5ZHI.js";import"./chunk-UVBK6YSR.js";import"./chunk-G5GERM76.js";import"./chunk-3E27HV76.js";import"./chunk-7IQ3B77H.js";import"./chunk-FIEA5CGB.js";import"./chunk-K7PQXJO7.js";import"./chunk-D65T4H6J.js";import{Icon as k}from"./chunk-YT4B3NSV.js";import"./chunk-LVCRH3K6.js";import"./chunk-C3QOHMR6.js";import{formatBytes as N}from"./chunk-W32SKK3D.js";import{LoadingSpinner as w}from"./chunk-2J6F4EE7.js";import{useState as v,useEffect as $,useSyncExternalStore as j,useRef as C,useCallback as E}from"react";import{jsxs as T,jsx as D,Fragment as L}from"react/jsx-runtime";var R="undefined"!=typeof window&&window.__REACT_OS_SHELL_FILE_SERVER__||"http://localhost:4000",S={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 W(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 P(){const P=R.replace(/\/$/,""),M=null!==n(),[O,U]=v("/"),[I,A]=v([]),[V,B]=v([]),[K,H]=v(null),[z,J]=v(!0),[G,_]=v(!1),[Y,Q]=v(null),[X,Z]=v(!1),[q,ee]=v(()=>{const e=i();return"trash"===e?"trash":e?{desktopFolderId:e.folderId}:"files"});$(()=>{l()},[]);const[te,ae]=v([]);$(()=>{const e=()=>{l(),ee("trash")},t=e=>{l();const t=e.detail?.folderId;t&&ee({desktopFolderId:t})};return window.addEventListener(o,e),window.addEventListener(d,t),()=>{window.removeEventListener(o,e),window.removeEventListener(d,t)}},[]);const re=j(c,m,m),ne="object"==typeof q?q.desktopFolderId:null,se=ne?re?.folders.find(e=>e.id===ne)??null:null,ie=ne&&re?.itemsByFolder[ne]||[];$(()=>{ne&&re&&!re.folders.some(e=>e.id===ne)&&ee("files")},[ne,re]);const le=C(0),oe=C(null),{openPage:de,openEntity:ce}=f(),me=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):ce(t.entityType,t.entityId,null,t.label)},he=E((e,t={})=>fetch(e,{...t,credentials:"include"}),[]),pe=E(async()=>{try{const e=await he(`${P}/api/quota`);if(e.ok){const t=await e.json();Q({used:t.used,limit:t.limit})}}catch{}},[he,P]),ue=E(async e=>{if(H(null),M){const t=function(e){const t=n();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 A(t),U(e),_(!1),J(!1),void("/"===e&&B(t.filter(e=>"folder"===e.kind).map(e=>e.name)))}J(!0);try{const t=await he(`${P}/api/files?path=${encodeURIComponent(e)}`);if(!t.ok){const e=await t.json().catch(()=>({}));return void g.error(e.error||`Failed to list (${t.status})`)}const a=await t.json(),r=a.entries||[];A(r),U(a.path||e),_(!1),"/"===(a.path||e)&&B(r.filter(e=>"folder"===e.kind).map(e=>e.name))}catch(e){_(!0)}finally{J(!1)}pe()},[he,P,pe,M]),fe=E(async()=>{if(M)return ae([]),void J(!1);J(!0),H(null);try{const e=await he(`${P}/api/trash`);if(!e.ok){const t=await e.json().catch(()=>({}));return void g.error(t.error||`Failed to list trash (${e.status})`)}const t=await e.json();ae(t.entries||[]),_(!1)}catch{_(!0)}finally{J(!1)}pe()},[he,P,pe,M]);$(()=>{"files"===q?ue(O):"trash"===q&&fe()},[O,q]);const xe=async e=>{const t=W(O,e.name);try{const a=await he(`${P}/api/file?path=${encodeURIComponent(t)}`);if(!a.ok)return void g.error(`Download failed (${a.status})`);const r=await a.blob(),n=URL.createObjectURL(r),s=document.createElement("a");s.href=n,s.download=e.name,s.click(),setTimeout(()=>URL.revokeObjectURL(n),1e3)}catch(e){g.error(e?.message||"Download failed")}},ge=async e=>{const t=Array.from(e);for(const e of t){const t=new FormData;t.append("file",e);try{const a=await he(`${P}/api/upload?path=${encodeURIComponent(O)}`,{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));g.error(`Quota exceeded — ${N(a)} free, ${e.name} is ${N(t.attempted||e.size)}`)}else g.error(`Upload ${e.name}: ${t.error||a.status}`)}}catch(t){g.error(`Upload ${e.name}: ${t?.message||"failed"}`)}}ue(O)},ye=()=>{le.current=0,Z(!1)};if($(()=>{const e=()=>ye();return window.addEventListener("dragend",e),window.addEventListener("drop",e),()=>{window.removeEventListener("dragend",e),window.removeEventListener("drop",e)}},[]),G)/* @__PURE__ */
|
|
2
|
+
return T("div",{className:"flex flex-col h-full bg-white",children:[
|
|
3
|
+
/* @__PURE__ */D(x,{title:"Files - offline"}),
|
|
4
|
+
/* @__PURE__ */D("div",{className:"flex-1 flex items-center justify-center p-8 text-center",children:/* @__PURE__ */T("div",{className:"max-w-md",children:[
|
|
5
|
+
/* @__PURE__ */D(k,{name:"close-circle",className:"h-12 w-12 mx-auto text-gray-300 mb-3",strokeWidth:1.4}),
|
|
6
|
+
/* @__PURE__ */D("h3",{className:"text-base font-semibold text-gray-800 mb-1",children:"Can't reach the file server"}),
|
|
7
|
+
/* @__PURE__ */T("p",{className:"text-sm text-gray-500 mb-3",children:["No response from ",
|
|
8
|
+
/* @__PURE__ */D("span",{className:"font-mono",children:P}),". Make sure the server is running — see ",
|
|
9
|
+
/* @__PURE__ */D("span",{className:"font-mono",children:"examples/file-server/README.md"}),"."]}),
|
|
10
|
+
/* @__PURE__ */D("button",{onClick:()=>ue(O),className:"px-3 h-8 text-sm bg-blue-500 text-white rounded hover:bg-blue-600",children:"Retry"})]})})]});const be="/"===O?[]:O.split("/").filter(Boolean),ke=Y&&Y.limit>0?Math.min(100,Math.round(Y.used/Y.limit*100)):0,Ne=ke>90?"bg-red-500":ke>75?"bg-amber-500":"bg-blue-500",we=[{label:"My files",onClick:()=>U("/")},...be.map((e,t)=>({label:e,onClick:()=>U("/"+be.slice(0,t+1).join("/"))}))],ve=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__ */D("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__ */D("path",{strokeLinecap:"round",strokeLinejoin:"round",d:e})}),je=/* @__PURE__ */T("nav",{className:"p-2",children:[
|
|
11
|
+
/* @__PURE__ */D("div",{className:"px-2 py-2 text-2xs font-semibold uppercase tracking-wide text-gray-400",children:"Locations"}),
|
|
12
|
+
/* @__PURE__ */T("button",{onClick:()=>{ee("files"),U("/")},className:ve("files"===q&&"/"===O),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__ */T("button",{onClick:()=>{ee("files"),U("/"+e)},className:ve("files"===q&&O==="/"+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__ */D("span",{className:"truncate",children:e})]},e)),!M&&/* @__PURE__ */T("button",{onClick:()=>ee("trash"),className:ve("trash"===q),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__ */T(L,{children:[
|
|
14
|
+
/* @__PURE__ */D("div",{className:"px-2 pt-3 pb-2 text-2xs font-semibold uppercase tracking-wide text-gray-400",children:"Desktop"}),re.folders.map(e=>/* @__PURE__ */T("button",{onClick:()=>ee({desktopFolderId:e.id}),className:ve(ne===e.id),children:[
|
|
15
|
+
/* @__PURE__ */D(h,{className:"h-4 w-4 shrink-0 text-amber-500"}),
|
|
16
|
+
/* @__PURE__ */D("span",{className:"truncate",children:e.name}),e.itemCount>0&&/* @__PURE__ */D("span",{className:"ml-auto text-2xs text-gray-400 tabular-nums",children:e.itemCount})]},e.id))]})]});/* @__PURE__ */
|
|
17
|
+
return T("div",{className:"relative flex flex-col h-full bg-white",onDragEnter:e=>{M||"object"==typeof q||e.dataTransfer?.types?.includes?.("Files")&&(e.preventDefault(),le.current++,X||Z(!0))},onDragOver:e=>{e.dataTransfer?.types?.includes?.("Files")&&e.preventDefault()},onDragLeave:()=>{le.current>0&&le.current--,0===le.current&&Z(!1)},onDrop:e=>{e.preventDefault(),ye(),M||"object"==typeof q||e.dataTransfer.files?.length&&ge(e.dataTransfer.files)},children:[
|
|
18
|
+
/* @__PURE__ */D(x,{title:se?`Files - ${se.name}`:"Files"+("/"===O?"":" - "+O)}),
|
|
19
|
+
/* @__PURE__ */D(s,{app:"files"}),
|
|
20
|
+
/* @__PURE__ */D("input",{ref:oe,type:"file",multiple:!0,className:"hidden",onChange:e=>{e.target.files?.length&&ge(e.target.files),oe.current&&(oe.current.value="")}}),
|
|
21
|
+
/* @__PURE__ */D("div",{className:"flex-1 min-h-0",children:/* @__PURE__ */D(r,{sidebar:je,storageKey:"files.sidebarWidth",defaultWidth:200,minWidth:150,maxWidth:320,children:/* @__PURE__ */T("div",{className:"flex h-full min-w-0 flex-col",children:[
|
|
22
|
+
/* @__PURE__ */T("div",{className:"flex items-center gap-1 px-2 py-2 border-b border-gray-200 bg-gray-50 shrink-0 text-xs",children:[/* @__PURE__ */T(L,"files"===q?{children:[
|
|
23
|
+
/* @__PURE__ */D("button",{onClick:()=>U(function(e){if("/"===e||""===e)return"/";const t=e.replace(/\/$/,""),a=t.lastIndexOf("/");return a<=0?"/":t.slice(0,a)}(O)),disabled:"/"===O,className:"px-2 py-1 rounded hover:bg-gray-200 disabled:opacity-30 text-gray-600",title:"Parent folder",children:/* @__PURE__ */D(k,{name:"arrow-left",className:"h-3.5 w-3.5",strokeWidth:2})}),
|
|
24
|
+
/* @__PURE__ */D("div",{className:"flex-1 min-w-0",children:/* @__PURE__ */D(t,{items:we,maxItems:5})}),
|
|
25
|
+
/* @__PURE__ */D("button",{onClick:()=>ue(O),className:"px-2 py-1 rounded hover:bg-gray-200 text-gray-600",title:"Refresh",children:/* @__PURE__ */D(k,{name:"refresh",className:"h-3.5 w-3.5",strokeWidth:1.8})}),!M&&/* @__PURE__ */T(L,{children:[
|
|
26
|
+
/* @__PURE__ */T("button",{onClick:()=>ee("trash"),className:"px-2 py-1 rounded hover:bg-gray-200 text-gray-600 flex items-center gap-1",title:"Open trash",children:[
|
|
27
|
+
/* @__PURE__ */D(k,{name:"trash",className:"h-3.5 w-3.5",strokeWidth:1.5}),"Trash"]}),
|
|
28
|
+
/* @__PURE__ */T("button",{onClick:async()=>{const e=await b({title:"New folder",placeholder:"Folder name",confirmLabel:"Create"});if(!e)return;if(/[\\/]/.test(e))return void g.error("Folder names cannot contain slashes");const t=W(O,e),a=await he(`${P}/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 g.error(e.error||`Create folder failed (${a.status})`)}ue(O)},className:"px-2 py-1 rounded hover:bg-gray-200 text-gray-600 flex items-center gap-1",children:[
|
|
29
|
+
/* @__PURE__ */D(k,{name:"folder-plus",className:"h-3.5 w-3.5",strokeWidth:1.5}),"New Folder"]}),
|
|
30
|
+
/* @__PURE__ */T("button",{onClick:()=>oe.current?.click(),className:"px-2 py-1 rounded bg-blue-500 text-white hover:bg-blue-600 flex items-center gap-1",children:[
|
|
31
|
+
/* @__PURE__ */D(k,{name:"upload",className:"h-3.5 w-3.5",strokeWidth:1.8}),"Upload"]})]})]}:"trash"===q?{children:[
|
|
32
|
+
/* @__PURE__ */D("button",{onClick:()=>ee("files"),className:"px-2 py-1 rounded hover:bg-gray-200 text-gray-600",title:"Back to files",children:/* @__PURE__ */D(k,{name:"arrow-left",className:"h-3.5 w-3.5",strokeWidth:2})}),
|
|
33
|
+
/* @__PURE__ */D("span",{className:"flex-1 text-gray-700 font-medium px-2",children:"Trash"}),
|
|
34
|
+
/* @__PURE__ */D("button",{onClick:fe,className:"px-2 py-1 rounded hover:bg-gray-200 text-gray-600",title:"Refresh",children:/* @__PURE__ */D(k,{name:"refresh",className:"h-3.5 w-3.5",strokeWidth:1.8})}),
|
|
35
|
+
/* @__PURE__ */D("button",{onClick:async()=>{if(0===te.length)return;if(!await y({title:"Empty trash",message:`${te.length} item${1===te.length?"":"s"} will be permanently removed. This can't be undone.`,confirmLabel:"Empty trash",variant:"danger"}))return;const e=await he(`${P}/api/trash`,{method:"DELETE"});if(!e.ok){const t=await e.json().catch(()=>({}));return void g.error(t.error||`Empty trash failed (${e.status})`)}fe()},disabled:0===te.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:[
|
|
36
|
+
/* @__PURE__ */D("button",{onClick:()=>ee("files"),className:"px-2 py-1 rounded hover:bg-gray-200 text-gray-600",title:"Back to files",children:/* @__PURE__ */D(k,{name:"arrow-left",className:"h-3.5 w-3.5",strokeWidth:2})}),
|
|
37
|
+
/* @__PURE__ */D(h,{className:"h-4 w-4 text-amber-500 ml-1"}),
|
|
38
|
+
/* @__PURE__ */D("span",{className:"flex-1 text-gray-700 font-medium px-1 truncate",children:se?.name??"Desktop folder"}),
|
|
39
|
+
/* @__PURE__ */D("span",{className:"text-2xs text-gray-400 px-2",children:"Desktop shortcuts"})]}),Y&&/* @__PURE__ */T(L,{children:[
|
|
40
|
+
/* @__PURE__ */D("div",{className:"h-4 w-px bg-gray-300 mx-1"}),
|
|
41
|
+
/* @__PURE__ */T("div",{className:"flex items-center gap-2",title:`${N(Y.used)} of ${N(Y.limit)} used`,children:[
|
|
42
|
+
/* @__PURE__ */D("div",{className:"w-20 h-1.5 rounded-full bg-gray-200 overflow-hidden",children:/* @__PURE__ */D("div",{className:`h-full ${Ne} transition-all`,style:{width:`${ke}%`}})}),
|
|
43
|
+
/* @__PURE__ */T("span",{className:"text-2xs text-gray-500 tabular-nums whitespace-nowrap",children:[N(Y.used)," / ",N(Y.limit)]})]})]})]}),
|
|
44
|
+
/* @__PURE__ */D("div",{className:"flex-1 overflow-auto",children:"object"==typeof q?0===ie.length?/* @__PURE__ */D("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__ */T("table",{className:"w-full text-sm",children:[
|
|
45
|
+
/* @__PURE__ */D("thead",{className:"bg-gray-50 text-2xs uppercase tracking-wide text-gray-500",children:/* @__PURE__ */T("tr",{children:[
|
|
46
|
+
/* @__PURE__ */D("th",{className:`${a} text-left font-medium px-3 h-8`,children:"Name"}),
|
|
47
|
+
/* @__PURE__ */D("th",{className:`${a} text-left font-medium px-3 h-8 w-28`,children:"Type"}),
|
|
48
|
+
/* @__PURE__ */D("th",{className:`${a} w-56`})]})}),
|
|
49
|
+
/* @__PURE__ */D("tbody",{children:ie.map(e=>{const t=`${e.entityType}|${e.entityId}`;/* @__PURE__ */
|
|
50
|
+
return T("tr",{onClick:()=>H(t),onDoubleClick:()=>me(e),className:"cursor-default border-b border-gray-100 "+(K===t?"bg-blue-50":"hover:bg-gray-50"),children:[
|
|
51
|
+
/* @__PURE__ */T("td",{className:"px-3 h-8 flex items-center gap-2",children:[
|
|
52
|
+
/* @__PURE__ */D(p,{item:e}),
|
|
53
|
+
/* @__PURE__ */D("span",{className:"truncate",title:e.label,children:e.label})]}),
|
|
54
|
+
/* @__PURE__ */D("td",{className:"px-3 h-8 text-xs text-gray-500",children:u(e)}),
|
|
55
|
+
/* @__PURE__ */T("td",{className:"px-3 h-8 text-right whitespace-nowrap",children:[
|
|
56
|
+
/* @__PURE__ */D("button",{onClick:t=>{t.stopPropagation(),me(e)},className:"px-2 py-0.5 rounded hover:bg-gray-200 text-blue-600 text-2xs",children:"Open"}),
|
|
57
|
+
/* @__PURE__ */D("button",{onClick:t=>{t.stopPropagation(),re?.moveToDesktop([e])},className:"px-2 py-0.5 rounded hover:bg-gray-200 text-gray-500 text-2xs ml-1",children:"Move to desktop"}),
|
|
58
|
+
/* @__PURE__ */D("button",{onClick:t=>{t.stopPropagation(),re?.removeShortcuts([e])},className:"px-2 py-0.5 rounded hover:bg-red-100 text-red-600 text-2xs ml-1",children:"Remove"})]})]},t)})})]}):"trash"===q?z&&0===te.length?/* @__PURE__ */D(w,{size:"sm",padding:"p-6",label:"Loading"}):0===te.length?/* @__PURE__ */D("div",{className:"p-10 text-center text-sm text-gray-400",children:"Trash is empty."}):/* @__PURE__ */T("table",{className:"w-full text-sm",children:[
|
|
59
|
+
/* @__PURE__ */D("thead",{className:"bg-gray-50 text-2xs uppercase tracking-wide text-gray-500",children:/* @__PURE__ */T("tr",{children:[
|
|
60
|
+
/* @__PURE__ */D("th",{className:`${a} text-left font-medium px-3 h-8`,children:"Name"}),
|
|
61
|
+
/* @__PURE__ */D("th",{className:`${a} text-left font-medium px-3 h-8`,children:"Original location"}),
|
|
62
|
+
/* @__PURE__ */D("th",{className:`${a} text-right font-medium px-3 h-8 w-24`,children:"Size"}),
|
|
63
|
+
/* @__PURE__ */D("th",{className:`${a} text-right font-medium px-3 h-8 w-40`,children:"Deleted"}),
|
|
64
|
+
/* @__PURE__ */D("th",{className:`${a} w-44`})]})}),
|
|
65
|
+
/* @__PURE__ */D("tbody",{children:te.map(e=>/* @__PURE__ */T("tr",{className:"border-b border-gray-100 hover:bg-gray-50",children:[
|
|
66
|
+
/* @__PURE__ */T("td",{className:"px-3 h-8 flex items-center gap-2",children:["folder"===e.kind?/* @__PURE__ */D(k,{name:"folder",look:"solid",className:"h-4 w-4 text-amber-500 shrink-0"}):/* @__PURE__ */D(k,{name:"page",className:"h-4 w-4 text-gray-400 shrink-0",strokeWidth:1.5}),
|
|
67
|
+
/* @__PURE__ */D("span",{className:"truncate",title:e.name,children:e.name})]}),
|
|
68
|
+
/* @__PURE__ */D("td",{className:"px-3 h-8 text-gray-500 text-xs font-mono truncate",title:e.originalPath,children:e.originalPath||"—"}),
|
|
69
|
+
/* @__PURE__ */D("td",{className:"px-3 h-8 text-right tabular-nums text-gray-500",children:N(e.size)}),
|
|
70
|
+
/* @__PURE__ */D("td",{className:"px-3 h-8 text-right text-gray-500 tabular-nums",children:e.deletedAt?F(e.deletedAt):"—"}),
|
|
71
|
+
/* @__PURE__ */T("td",{className:"px-3 h-8 text-right whitespace-nowrap",children:[
|
|
72
|
+
/* @__PURE__ */D("button",{onClick:()=>(async e=>{const t=await he(`${P}/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 g.error(e.error||`Restore failed (${t.status})`)}g.success(`Restored "${e.name}"`),fe()})(e),className:"px-2 py-0.5 rounded hover:bg-gray-200 text-blue-600 text-2xs",children:"Restore"}),
|
|
73
|
+
/* @__PURE__ */D("button",{onClick:()=>(async e=>{if(!await y({title:"Permanently delete",message:`"${e.name}" will be permanently removed. This can't be undone.`,confirmLabel:"Delete forever",variant:"danger"}))return;const t=await he(`${P}/api/trash/${encodeURIComponent(e.id)}`,{method:"DELETE"});if(!t.ok){const e=await t.json().catch(()=>({}));return void g.error(e.error||`Delete failed (${t.status})`)}fe()})(e),className:"px-2 py-0.5 rounded hover:bg-red-100 text-red-600 text-2xs ml-1",children:"Delete forever"})]})]},e.id))})]}):z&&0===I.length?/* @__PURE__ */D(w,{size:"sm",padding:"p-6",label:"Loading"}):0===I.length?/* @__PURE__ */T("div",{className:"p-10 text-center text-sm text-gray-400",children:["Empty folder.",!M&&/* @__PURE__ */T(L,{children:[" Drop files here or click ",
|
|
74
|
+
/* @__PURE__ */D("span",{className:"font-medium",children:"Upload"}),"."]})]}):/* @__PURE__ */T("table",{className:"w-full text-sm",children:[
|
|
75
|
+
/* @__PURE__ */D("thead",{className:"bg-gray-50 text-2xs uppercase tracking-wide text-gray-500",children:/* @__PURE__ */T("tr",{children:[
|
|
76
|
+
/* @__PURE__ */D("th",{className:`${a} text-left font-medium px-3 h-8`,children:"Name"}),
|
|
77
|
+
/* @__PURE__ */D("th",{className:`${a} text-right font-medium px-3 h-8 w-24`,children:"Size"}),
|
|
78
|
+
/* @__PURE__ */D("th",{className:`${a} text-right font-medium px-3 h-8 w-40`,children:"Modified"}),
|
|
79
|
+
/* @__PURE__ */D("th",{className:`${a} w-32`})]})}),
|
|
80
|
+
/* @__PURE__ */D("tbody",{children:I.map(t=>/* @__PURE__ */T("tr",{onClick:()=>H(t.name),onDoubleClick:()=>{"folder"===t.kind?U(W(O,t.name)):(async t=>{if(M)return;const a=W(O,t.name),r=(t.name.split(".").pop()||"").toLowerCase(),n=S[r];n?await e({filePath:a,filename:t.name,kind:n,onStaged:e=>de(e)}):xe(t)})(t)},className:"cursor-default border-b border-gray-100 "+(K===t.name?"bg-blue-50":"hover:bg-gray-50"),children:[
|
|
81
|
+
/* @__PURE__ */T("td",{className:"px-3 h-8 flex items-center gap-2",children:["folder"===t.kind?/* @__PURE__ */D(k,{name:"folder",look:"solid",className:"h-4 w-4 text-amber-500 shrink-0"}):/* @__PURE__ */D(k,{name:"page",className:"h-4 w-4 text-gray-400 shrink-0",strokeWidth:1.5}),
|
|
82
|
+
/* @__PURE__ */D("span",{className:"truncate",title:t.name,children:t.name})]}),
|
|
83
|
+
/* @__PURE__ */D("td",{className:"px-3 h-8 text-right tabular-nums text-gray-500",children:"folder"===t.kind?"—":N(t.size)}),
|
|
84
|
+
/* @__PURE__ */D("td",{className:"px-3 h-8 text-right text-gray-500 tabular-nums",children:F(t.modifiedAt)}),
|
|
85
|
+
/* @__PURE__ */D("td",{className:"px-3 h-8 text-right whitespace-nowrap",children:!M&&/* @__PURE__ */T(L,{children:["file"===t.kind&&/* @__PURE__ */D("button",{onClick:e=>{e.stopPropagation(),xe(t)},className:"px-2 py-0.5 rounded hover:bg-gray-200 text-gray-500 text-2xs",children:"Download"}),
|
|
86
|
+
/* @__PURE__ */D("button",{onClick:e=>{e.stopPropagation(),(async e=>{const t=await b({title:`Rename ${e.kind}`,defaultValue:e.name,confirmLabel:"Rename"});if(!t||t===e.name)return;if(/[\\/]/.test(t))return void g.error("Names cannot contain slashes");const a=W(O,e.name),r=W(O,t),n=await he(`${P}/api/rename`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({from:a,to:r})});if(!n.ok){const e=await n.json().catch(()=>({}));return void g.error(e.error||`Rename failed (${n.status})`)}ue(O)})(t)},className:"px-2 py-0.5 rounded hover:bg-gray-200 text-gray-500 text-2xs ml-1",children:"Rename"}),
|
|
87
|
+
/* @__PURE__ */D("button",{onClick:e=>{e.stopPropagation(),(async e=>{if(!await y({title:`Delete ${e.kind}`,message:`"${e.name}"${"folder"===e.kind?" and everything inside":""} will be permanently removed.`,confirmLabel:"Delete",variant:"danger"}))return;const t=W(O,e.name),a=await he(`${P}/api/files?path=${encodeURIComponent(t)}`,{method:"DELETE"});if(!a.ok){const e=await a.json().catch(()=>({}));return void g.error(e.error||`Delete failed (${a.status})`)}ue(O)})(t)},className:"px-2 py-0.5 rounded hover:bg-red-100 text-red-600 text-2xs ml-1",children:"Delete"})]})})]},t.name))})]})})]})})}),X&&/* @__PURE__ */D("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__ */D("div",{className:"px-4 py-2 rounded-md bg-blue-600 text-white text-sm font-medium shadow-lg",children:"Drop to upload"})})]})}export{P as default};
|