efficient-shell 10.24.0 → 11.1.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 +18 -2
- package/dist/Browser-PTDZDMCG.js +44 -0
- package/dist/{Calculator-LENRW34X.js → Calculator-KP57FK7Y.js} +21 -21
- package/dist/{CurrencyConverter-7UMHQS2V.js → CurrencyConverter-W66ZDA6I.js} +6 -6
- package/dist/{Documents-ODZ4AAOY.js → Documents-EASK3J36.js} +15 -15
- package/dist/{Files-BRGTTI2J.js → Files-YT4Z4J36.js} +22 -22
- package/dist/{Notepad-RMRDEGGU.js → Notepad-T6NV4BSM.js} +7 -7
- package/dist/{PomodoroTimer-4566W4F7.js → PomodoroTimer-6B2MNLWD.js} +21 -21
- package/dist/{Preview-7POJP7PB.js → Preview-KHCQHAWG.js} +26 -26
- package/dist/{Sidebar-TU4QCKYJ.js → Sidebar-BCTWRG7P.js} +34 -34
- package/dist/{Spreadsheet-7T4VT5IO.js → Spreadsheet-IQZECLJW.js} +14 -14
- package/dist/{Stock-H73C4R3N.js → Stock-GCCTYXAG.js} +3 -3
- package/dist/{Weather-WF56QCBI.js → Weather-DL4IZELD.js} +17 -17
- package/dist/{WorldClock-5QJNZYYS.js → WorldClock-ZVN5O77W.js} +4 -4
- package/dist/ai/index.js +91 -91
- package/dist/apps/index.js +1 -1
- package/dist/bin/media-host-check.js +1 -1
- package/dist/bin/ui-check.js +1 -1
- package/dist/brand.css +1 -1
- package/dist/chunk-3XZFWR6T.js +13 -0
- package/dist/{chunk-CIHR5ZKF.js → chunk-4DDL6NXB.js} +1 -1
- package/dist/{chunk-USWA6YNZ.js → chunk-5PDHKH2A.js} +3 -3
- package/dist/{chunk-Z6GQFTLJ.js → chunk-5WY5DQI7.js} +1 -1
- package/dist/{chunk-OTITQ3IH.js → chunk-6KGIHI6X.js} +7 -7
- package/dist/{chunk-RSOBUPLK.js → chunk-7DQ3PM5Z.js} +1 -1
- package/dist/chunk-AIJ3G6BD.js +1 -0
- package/dist/{chunk-DRUQH4ZE.js → chunk-AIJ6OR6X.js} +2 -2
- package/dist/{chunk-S5DYR75A.js → chunk-AM6HSHT5.js} +18 -18
- package/dist/{chunk-CQEVJG43.js → chunk-AWGJIDBR.js} +1 -1
- package/dist/{chunk-USVL5SLG.js → chunk-D5HGRACW.js} +1 -1
- package/dist/chunk-ETJRGQNG.js +1 -0
- package/dist/chunk-HNUKXGYP.js +5 -0
- package/dist/{chunk-GOXQJCXG.js → chunk-HUU4XMWE.js} +17 -17
- package/dist/{chunk-Z3SLQKE6.js → chunk-ILY4DU3D.js} +1 -1
- package/dist/{chunk-3FBDLIQW.js → chunk-IQZD6QQF.js} +35 -35
- package/dist/{chunk-IHNOWRTP.js → chunk-KIXTJNHQ.js} +2 -2
- package/dist/{chunk-DGWS4GTI.js → chunk-KXU4ORKE.js} +1 -1
- package/dist/chunk-KYBXJL6A.js +23 -0
- package/dist/chunk-LH7IKIGE.js +1 -0
- package/dist/{chunk-JPOYR5AO.js → chunk-NZISMTQE.js} +5 -5
- package/dist/{chunk-QWCEKHAP.js → chunk-OEPYQUXZ.js} +9 -9
- package/dist/{chunk-HUA3TGMM.js → chunk-P2C33RHT.js} +1 -1
- package/dist/{chunk-CX4XR4HO.js → chunk-PLC656AN.js} +1 -1
- package/dist/chunk-Q5Z3KHT2.js +1 -0
- package/dist/{chunk-RZQGPWSN.js → chunk-QOI4GQVH.js} +1 -1
- package/dist/{chunk-NZ7BFYCM.js → chunk-QYXZC37J.js} +1 -1
- package/dist/{chunk-PVDZG2U2.js → chunk-RBZKV3ED.js} +4 -4
- package/dist/{chunk-EH2BNSG3.js → chunk-SX3SG522.js} +9 -9
- package/dist/{chunk-GC3DA6D6.js → chunk-T6BGS26U.js} +1 -1
- package/dist/chunk-WBJ6KNUF.js +1 -0
- package/dist/data/EntityList.js +1 -1
- package/dist/format/index.d.ts +1 -1
- package/dist/format/index.js +1 -1
- package/dist/forms/DateRangePicker.js +1 -1
- package/dist/forms/Input.d.ts +50 -2
- package/dist/forms/Input.js +1 -1
- package/dist/forms/LinkPicker.js +1 -1
- package/dist/forms/MediaLibrary.js +1 -1
- package/dist/forms/SplitButton.js +1 -1
- package/dist/forms/linkHref.js +1 -1
- package/dist/icons/efficient-glyphs.js +1 -1
- package/dist/icons/efficient-looks.js +1 -1
- package/dist/icons/efficient-meanings.d.ts +2 -2
- package/dist/icons/efficient-meanings.js +1 -1
- package/dist/icons/efficient.js +1 -1
- package/dist/icons/looks/map.js +1 -1
- package/dist/icons/payment.js +1 -1
- package/dist/icons/sets.js +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +666 -667
- package/dist/markup/index.d.ts +55 -11
- package/dist/markup/index.js +1 -1
- package/dist/motion/values.d.ts +75 -0
- package/dist/motion/values.js +1 -0
- package/dist/motion.css +26 -0
- package/dist/page-tabs/index.js +4 -4
- package/dist/shell/ContextMenu.js +1 -1
- package/dist/shell/DropdownMenu.js +1 -1
- package/dist/shell/HelpCenter.js +1 -1
- package/dist/shell/ImageLightbox.js +1 -1
- package/dist/shell/Markdown.js +1 -1
- package/dist/shell/PopupMenu.js +1 -1
- package/dist/shell/SearchableSelect.d.ts +11 -1
- package/dist/shell/SearchableSelect.js +1 -1
- package/dist/shell/TopNav.js +1 -1
- package/dist/telemetry/index.js +1 -1
- package/dist/templates/AuthScreen.js +1 -1
- package/dist/templates/ChatTemplate.js +1 -1
- package/dist/templates/CheckoutTemplate.js +1 -1
- package/dist/templates/DataTablePage.js +1 -1
- package/dist/templates/FormLayoutPage.js +1 -1
- package/dist/tokens/type.d.ts +3 -31
- package/dist/tokens/type.js +1 -1
- package/dist/ui/index.d.ts +2 -1
- package/dist/ui/index.js +1 -1
- package/dist/version.js +1 -1
- package/package.json +3 -2
- package/dist/Browser-KUFFOGYK.js +0 -43
- package/dist/chunk-3C5NKOVF.js +0 -1
- package/dist/chunk-5DIGYJHD.js +0 -1
- package/dist/chunk-7RP7QTRF.js +0 -12
- package/dist/chunk-DHKRXHJN.js +0 -1
- package/dist/chunk-H475WZPF.js +0 -23
- package/dist/chunk-MAMWQCJ6.js +0 -2
- package/dist/chunk-PJPK2ADX.js +0 -1
- /package/dist/{chunk-RKLZDVAO.js → chunk-2F5SLLBJ.js} +0 -0
package/README.md
CHANGED
|
@@ -2242,6 +2242,20 @@ Border width: `--border-hairline` 1px, `--border-strong` 2px, `--border-accent`
|
|
|
2242
2242
|
4px. Code takes the same numbers from `efficient-shell/ui`: `TYPE_SCALE`,
|
|
2243
2243
|
`FONT_WEIGHTS`, `MOTION_DURATIONS`, `BORDER_WIDTHS`.
|
|
2244
2244
|
|
|
2245
|
+
**Page motion.** The animations a website page plays — a block arriving, a card
|
|
2246
|
+
on hover, a row that loops, a number counting up — are not the chrome's
|
|
2247
|
+
motion. Each timed one has a Duration and a Delay in seconds, like Wix:
|
|
2248
|
+
`MOTION_TIMING` gives every group its default, its ends and its step (Entrance
|
|
2249
|
+
0.6 s in 0–4 s, Hover 0.7 s, Loop 50 s in 1–120 s, Click 0.3 s, Count up 1.4 s;
|
|
2250
|
+
every Delay starts at 0). `motionSeconds(group, 'duration' | 'delay', stored)`
|
|
2251
|
+
reads a stored value into its range and onto its step. `MOTION_EASING` has
|
|
2252
|
+
`arrive`, `loop` and `media` (a card picture on hover), `HOVER_MOTION` the
|
|
2253
|
+
hover distances, and `rotateDegrees(spokes)` turns a wheel by one spoke (72°
|
|
2254
|
+
when the count is unknown). `efficient-shell/motion.css` declares the same
|
|
2255
|
+
defaults as `--page-motion-*`, `--page-ease-*` and `--page-hover-*`. A
|
|
2256
|
+
published page takes them from `efficient-shell/format`, the kit from
|
|
2257
|
+
`efficient-shell/ui`.
|
|
2258
|
+
|
|
2245
2259
|
**Corners.** A component does not pick a step of the scale for itself; it asks
|
|
2246
2260
|
for the radius of what it is. Five role tokens, each defaulting to the step that
|
|
2247
2261
|
role has always drawn, so they change nothing until you set one:
|
|
@@ -3965,13 +3979,14 @@ keeps its own renderer and walks the same tree or token list.
|
|
|
3965
3979
|
| `1. ` at the start of a line | a numbered line, one level: 1-3 digits, `. `, words; the number is kept as typed | yes |
|
|
3966
3980
|
| `[x]{underline}`, `[x]{sup}`, `[x]{sub}` | underline, superscript, subscript (tree only) | `applyMark` / `toggleMark` |
|
|
3967
3981
|
| `[x]{color=name}` / `[x]{color=#rrggbb}` | a theme colour by name (`isColorName`), or any colour as exactly six hex digits (`isColorValue`; saved lowercase) (tree only) | `applyColor` / `colorOver` |
|
|
3982
|
+
| `[x]{style=id}` | one of the site's text styles, `heading-1` … `body-7` (`isStyleId`) (tree only) | `styleOver` |
|
|
3968
3983
|
| `@@x@@`, `++x++` | Emphasis, Strong (the storefront's old word styles). `++` opens only at a word start, so `A++ rated tyres, A++ service` is plain text | no — read only |
|
|
3969
3984
|
| `*x*`, `#x#`, `[x]` | legacy accent, bold, italic (per product set) | no — read only |
|
|
3970
3985
|
|
|
3971
3986
|
The three names a merchant sees are in `MARK_NAMES`. A run never crosses a line
|
|
3972
3987
|
break, and runs, spans and links nest up to four levels
|
|
3973
3988
|
(`[**_[x]{sup}_**]{color=accent}`); a fifth stays as typed. Any block after `]`
|
|
3974
|
-
that is not exactly one of the
|
|
3989
|
+
that is not exactly one of the five (`[x]{foo}`, `[x]{color=#f00}`, `[x]{style=Body 6}`,
|
|
3975
3990
|
`[x]{{first_name}}`) is plain text. The spans and the numbered line are read by
|
|
3976
3991
|
`parseMarkup` only: `tokenizeInline` keeps them as text, so a renderer that has
|
|
3977
3992
|
not learned them prints the delimiters.
|
|
@@ -3984,9 +3999,10 @@ not learned them prints the delimiters.
|
|
|
3984
3999
|
| `tokenizeInline(value, rules)`, `stripInline(value, rules)` | The flat reading older renderers use: runs only, no links, no nesting. Tokens ALTERNATE, starting and ending with a `text` token that may be empty. `stripInline` is the only correct source for an `alt`, an `aria-label` or a structured-data field. |
|
|
3985
4000
|
| `applyMark(text, start, end, style, rules?, placeholders?)`, `markedAt`, `MARKUP_TOOLS`, `markupTools`, `COPY_FIELD_TOOLS`, `MARK_PLACEHOLDERS` | The writer behind a toolbar button (pressing the same button again unwraps), whether a button is pressed, and the button descriptors. A copy field offers bold, italic and strike. |
|
|
3986
4001
|
| `applyColor(text, start, end, name)`, `isColorName`, `isColorValue`, `spanFor` | A colour carries a value, so it has its own writer: it writes, changes and (`null`) takes off `[x]{color=name}`, and changes nothing for a value `isColorValue` refuses (`#f00`, `rgb()`, a typo). |
|
|
4002
|
+
| `colorRole(value)`, `COLOR_SLOTS` | The ONE reading of a saved colour: `{ kind: 'slot', slot }` for `main`, `text`, `background` or `muted` — a colour of the theme of the section the words sit in — or `{ kind: 'hex', hex }` for a 6-digit hex. Null for anything else (an old name such as `accent`), which a renderer draws as plain words. Every renderer and panel reads a colour through it and maps the role to its own paint. |
|
|
3987
4003
|
| `findLink`, `writeLink`, `removeLink` | The link window's reading and writing, with the parser's own link rule. |
|
|
3988
4004
|
| `markedLines`, `writeMarkedLines`, `sameMarks` | The saved string as characters, each carrying its runs, and back byte for byte — what an editor that hides the delimiters edits. |
|
|
3989
|
-
| `toggleMark`, `marksIn`, `linkOver`, `unlinkAt`, `colorOver`, `colorIn`, `setList`, `listIn`, `clearMarks`, `clearStyle` | Writers that act on the WORDS whichever runs they sit in, splitting a run rather than crossing a delimiter, and the readers a toolbar draws its pressed state from. |
|
|
4005
|
+
| `toggleMark`, `marksIn`, `linkOver`, `unlinkAt`, `colorOver`, `colorIn`, `styleOver`, `styleIn`, `setList`, `listIn`, `clearMarks`, `clearStyle` | Writers that act on the WORDS whichever runs they sit in, splitting a run rather than crossing a delimiter, and the readers a toolbar draws its pressed state from. |
|
|
3990
4006
|
| `STANDARD_MARKUP`, `STOREFRONT_MARKUP`, `CAMPAIGN_MARKUP`, `RETIRED_MARKS` | The rule sets. The last two add each product's LEGACY runs, designed to be deleted once stored content has been converted. |
|
|
3991
4007
|
|
|
3992
4008
|
Two delimiter choices worth knowing. Italic is `_phrase_`, not `*phrase*`,
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import{InputEndActionButton as e}from"./chunk-HNUKXGYP.js";import"./chunk-NZISMTQE.js";import"./chunk-4DDL6NXB.js";import"./chunk-AYZY3YNC.js";import"./chunk-LE5LWALR.js";import{peekBrowserStartUrl as t,claimBrowserStartUrl as o}from"./chunk-LWLCNQY7.js";import{AboutApp as r}from"./chunk-KIXTJNHQ.js";import{WindowTitle as n}from"./chunk-IQZD6QQF.js";import"./chunk-4LXCCZDM.js";import"./chunk-AW7TOB6N.js";import"./chunk-KNUR2UEG.js";import"./chunk-JDCM2VHG.js";import"./chunk-QYL26AB4.js";import"./chunk-ZDMZM7HD.js";import"./chunk-5A7MWTXX.js";import"./chunk-2E2SUEEE.js";import{confirm as s}from"./chunk-PLK2WHZG.js";import"./chunk-7INZ7O3A.js";import"./chunk-55AEZX6K.js";import"./chunk-3DVNXNTF.js";import"./chunk-ECJKIPWU.js";import"./chunk-VWGWZY7A.js";import"./chunk-7QSDPSXP.js";import"./chunk-OKHKY3ZZ.js";import"./chunk-O3MBPAWZ.js";import"./chunk-2QY5BJLA.js";import"./chunk-UGTRSRIW.js";import"./chunk-KC3EX26K.js";import"./chunk-F3ZOO23R.js";import"./chunk-ETJRGQNG.js";import"./chunk-FZM3ZPW3.js";import"./chunk-CDAJKLGL.js";import"./chunk-6KGIHI6X.js";import"./chunk-URHGHXDN.js";import"./chunk-5QFPTDQF.js";import"./chunk-EOVXFXVV.js";import"./chunk-UQYNPYF4.js";import"./chunk-TE6R53YD.js";import{Icon as a}from"./chunk-2UO47XB4.js";import"./chunk-J75ZT2JQ.js";import"./chunk-R2VKEMZH.js";import"./chunk-MRJKZWWV.js";import"./chunk-WGLHB6WE.js";import"./chunk-NJN5IKWO.js";import"./chunk-PGN5ME7B.js";import"./chunk-62LW225J.js";import"./chunk-GLUJS42B.js";import"./chunk-D65T4H6J.js";import"./chunk-STKJA4PV.js";import"./chunk-5FYDNH4Y.js";import"./chunk-LNXBTK7Q.js";import"./chunk-TWVUQUUD.js";import"./chunk-GDQJBQ5B.js";import"./chunk-C3QOHMR6.js";import{useRef as i,useEffect as l,useState as c}from"react";import{jsxs as m,jsx as u,Fragment as h}from"react/jsx-runtime";var d="react-os-shell:browser-bookmarks",p="react-os-shell:browser-homepage",k="https://en.wikipedia.org/wiki/Main_Page",b=[{label:"Wikipedia",url:"https://en.wikipedia.org/wiki/Main_Page"},{label:"DevDocs",url:"https://devdocs.io"},{label:"Example",url:"https://example.com"}],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 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&&g.has(t[2].toLowerCase())}(t)?"https://"+t:"https://duckduckgo.com/?q="+encodeURIComponent(t):""}var w=["duckduckgo.com","developer.mozilla.org","google.com","gmail.com","youtube.com","facebook.com","instagram.com","whatsapp.com","twitter.com","x.com","github.com","gitlab.com","linkedin.com","reddit.com","pinterest.com","amazon.com","amazon.ca","amazon.co.uk","apple.com","icloud.com","microsoft.com","outlook.com","live.com","office.com","netflix.com","spotify.com","paypal.com","stripe.com","chat.openai.com","chatgpt.com","claude.ai"];function x(){if("undefined"==typeof window)return b;try{const e=localStorage.getItem(d);if(!e)return b;const t=JSON.parse(e);if(Array.isArray(t)&&t.every(e=>"string"==typeof e?.url))return t}catch{}return b}function y(){return"undefined"==typeof window?k:localStorage.getItem(p)||k}function v(){const h=i(void 0);void 0===h.current&&(h.current=t()),l(()=>{null!=h.current&&o(h.current)},[]);const k=h.current?f(h.current.url):"",[b,g]=c(y),[w,v]=c(k||b),[C,W]=c(w),[E,L]=c([w]),[z,D]=c(0),[R,H]=c(0),[S,K]=c(x),[T,Q]=c(!1),[U,Z]=c(null),G=i(null),X=i(null);l(()=>{try{localStorage.setItem(d,JSON.stringify(S))}catch{}},[S]);const J=e=>{const t=f(e);t&&(v(t),W(t),L(e=>{const o=e.slice(0,z+1);return o.push(t),o}),D(e=>e+1),Q(!1))},M=()=>{"undefined"!=typeof window&&window.open(w,"_blank","noopener,noreferrer")},O=()=>{const e=U?.trim();e?(K(t=>[...t,{label:e,url:w}]),Z(null)):Z(null)};l(()=>{if(null===U)return;G.current?.focus(),G.current?.select();const e=e=>{const t=e.target;t?.closest("[data-bookmark-popover]")||Z(null)},t=setTimeout(()=>document.addEventListener("mousedown",e),0);return()=>{clearTimeout(t),document.removeEventListener("mousedown",e)}},[null!==U]);const P=e=>{K(t=>t.filter((t,o)=>o!==e))},A=z>0,B=z<E.length-1,I=S.some(e=>e.url===w),Y="p-2 rounded hover:bg-gray-200 transition-colors text-gray-600 disabled:opacity-30";/* @__PURE__ */
|
|
2
|
+
return m("div",{className:"relative flex flex-col h-full bg-white",children:[
|
|
3
|
+
/* @__PURE__ */u(n,{title:`Browser - ${N(w)}`}),
|
|
4
|
+
/* @__PURE__ */u(r,{app:"browser"}),
|
|
5
|
+
/* @__PURE__ */m("div",{className:"flex items-center gap-1 px-2 py-2 border-b border-line bg-surface-sunken shrink-0",children:[
|
|
6
|
+
/* @__PURE__ */u("button",{onClick:()=>{if(z>0){const e=z-1;D(e),v(E[e]),W(E[e]),Q(!1)}},disabled:!A,className:Y,title:"Back",children:/* @__PURE__ */u(a,{name:"chevron-left",className:"h-4 w-4",strokeWidth:2})}),
|
|
7
|
+
/* @__PURE__ */u("button",{onClick:()=>{if(z<E.length-1){const e=z+1;D(e),v(E[e]),W(E[e]),Q(!1)}},disabled:!B,className:Y,title:"Forward",children:/* @__PURE__ */u(a,{name:"chevron-right",className:"h-4 w-4",strokeWidth:2})}),
|
|
8
|
+
/* @__PURE__ */u("button",{onClick:()=>H(e=>e+1),className:Y,title:"Refresh",children:/* @__PURE__ */u(a,{name:"refresh",className:"h-4 w-4",strokeWidth:1.8})}),
|
|
9
|
+
/* @__PURE__ */u("button",{onClick:()=>J(b),className:Y,title:"Home",children:/* @__PURE__ */u(a,{name:"home",className:"h-4 w-4",strokeWidth:1.8})}),
|
|
10
|
+
/* @__PURE__ */u("form",{onSubmit:e=>{e.preventDefault(),J(C)},className:"flex-1 flex items-center mx-1",children:/* @__PURE__ */m("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
|
+
/* @__PURE__ */u("span",{className:"px-2 text-gray-400 text-xs",children:w.startsWith("https://")?"🔒":"⚠️"}),
|
|
12
|
+
/* @__PURE__ */u("input",{type:"text",value:C,onChange:e=>W(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…"}),w!==C&&
|
|
13
|
+
/* @__PURE__ */u("span",{className:"flex pr-1",children:/* @__PURE__ */u(e,{action:{label:"Reset to current URL",icon:/* @__PURE__ */u(a,{name:"close"}),onClick:()=>W(w)}})})]})}),
|
|
14
|
+
/* @__PURE__ */u("button",{"data-bookmark-popover":!0,onClick:()=>I?P(S.findIndex(e=>e.url===w)):void Z(N(w)),className:Y+" "+(I?"text-yellow-500":""),title:I?"Remove bookmark":"Add bookmark",children:/* @__PURE__ */u(a,{name:"star",className:"h-4 w-4",fill:I?"currentColor":"none",strokeWidth:1.5})}),
|
|
15
|
+
/* @__PURE__ */u("button",{onClick:M,className:Y,title:"Open in new tab",children:/* @__PURE__ */u(a,{name:"external",className:"h-4 w-4",strokeWidth:1.5})}),
|
|
16
|
+
/* @__PURE__ */u("button",{onClick:()=>Q(e=>!e),className:Y,title:"Embedding help",children:/* @__PURE__ */u(a,{name:"help",className:"h-4 w-4",strokeWidth:1.5})})]}),null!==U&&/* @__PURE__ */m("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:[
|
|
17
|
+
/* @__PURE__ */u("div",{className:"text-2xs font-semibold uppercase tracking-wide text-ink-faint mb-1",children:"Bookmark this page"}),
|
|
18
|
+
/* @__PURE__ */u("div",{className:"text-2xs text-ink-faintest truncate mb-2 font-mono",title:w,children:w}),
|
|
19
|
+
/* @__PURE__ */u("input",{ref:G,type:"text",value:U,onChange:e=>Z(e.target.value),onKeyDown:e=>{"Enter"===e.key?O():"Escape"===e.key&&Z(null)},placeholder:"Name",className:"w-full text-sm px-2 h-8 border border-line-strong rounded focus:outline-none focus:border-blue-400 focus:ring-1 focus:ring-blue-200"}),
|
|
20
|
+
/* @__PURE__ */m("div",{className:"flex justify-end gap-1 mt-2",children:[
|
|
21
|
+
/* @__PURE__ */u("button",{onClick:()=>Z(null),className:"px-2 py-1 text-xs text-gray-600 hover:bg-gray-100 rounded",children:"Cancel"}),
|
|
22
|
+
/* @__PURE__ */u("button",{onClick:O,disabled:!U.trim(),className:"px-2 py-1 text-xs bg-blue-500 text-white rounded hover:bg-blue-600 disabled:opacity-40",children:"Save"})]})]}),
|
|
23
|
+
/* @__PURE__ */m("div",{className:"flex items-center gap-0.5 px-2 py-1 border-b border-gray-200 bg-white shrink-0 overflow-x-auto",children:[0===S.length&&/* @__PURE__ */u("span",{className:"text-2xs text-ink-faintest italic px-2",children:"No bookmarks yet — star the address bar to add one."}),S.map((e,t)=>/* @__PURE__ */m("button",{onClick:()=>J(e.url),onContextMenu:async o=>{o.preventDefault();await s({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-ink hover:bg-gray-100 whitespace-nowrap",title:`${e.url}\n(right-click to remove)`,children:[
|
|
24
|
+
/* @__PURE__ */u("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)),
|
|
25
|
+
/* @__PURE__ */u("div",{className:"flex-1"}),
|
|
26
|
+
/* @__PURE__ */u("button",{onClick:()=>{g(w);try{localStorage.setItem(p,w)}catch{}},className:"px-2 py-0.5 text-2xs text-ink-faint hover:text-ink-strong",title:"Set current page as homepage",children:"Set as home"})]}),
|
|
27
|
+
/* @__PURE__ */u("div",{className:"flex-1 relative min-h-0 bg-gray-50",children:/* @__PURE__ */u(j,{url:w,iframeKey:R,iframeRef:X,openExternal:M,showHelp:T,dismissHelp:()=>Q(!1)})})]})}function N(e){try{return new URL(e).hostname.replace(/^www\./,"")}catch{return e}}function j({url:e,iframeKey:t,iframeRef:o,openExternal:r,showHelp:n,dismissHelp:s}){const[i,d]=c(!1);l(()=>{d(!1)},[e]);return function(e){try{const t=new URL(e).hostname.toLowerCase();return w.some(e=>t===e||t.endsWith("."+e))}catch{return!1}}(e)&&!i?/* @__PURE__ */u("div",{className:"absolute inset-0 flex items-center justify-center bg-white p-8",children:/* @__PURE__ */m("div",{className:"max-w-md text-center",children:[
|
|
28
|
+
/* @__PURE__ */u(a,{name:"no-symbol",className:"h-14 w-14 mx-auto text-gray-300 mb-3",strokeWidth:1.2}),
|
|
29
|
+
/* @__PURE__ */m("h3",{className:"text-base font-semibold text-gray-800 mb-1",children:[N(e)," can't be embedded"]}),
|
|
30
|
+
/* @__PURE__ */m("p",{className:"text-sm text-gray-500 mb-4",children:["This site sends an ",
|
|
31
|
+
/* @__PURE__ */u("span",{className:"font-mono text-xs",children:"X-Frame-Options"})," ","or ",
|
|
32
|
+
/* @__PURE__ */u("span",{className:"font-mono text-xs",children:"Content-Security-Policy"})," header that refuses iframe embedding. The browser blocks the load before our app can do anything about it."]}),
|
|
33
|
+
/* @__PURE__ */m("div",{className:"flex flex-col items-center gap-2",children:[
|
|
34
|
+
/* @__PURE__ */m("button",{onClick:r,className:"px-4 py-2 bg-blue-500 text-white text-sm rounded hover:bg-blue-600 inline-flex items-center gap-2",children:[
|
|
35
|
+
/* @__PURE__ */u(a,{name:"external",className:"h-4 w-4",strokeWidth:1.5}),"Open in a new tab"]}),
|
|
36
|
+
/* @__PURE__ */u("button",{onClick:()=>d(!0),className:"text-xs text-gray-500 hover:text-gray-800 underline",children:"Try loading it here anyway"})]})]})}):/* @__PURE__ */m(h,{children:[
|
|
37
|
+
/* @__PURE__ */u("iframe",{ref:o,src:e,className:"absolute inset-0 w-full h-full bg-white",sandbox:"allow-scripts allow-forms allow-popups allow-popups-to-escape-sandbox allow-same-origin allow-modals",referrerPolicy:"no-referrer-when-downgrade"},t+e),n&&/* @__PURE__ */m("div",{className:"absolute top-2 right-2 max-w-sm bg-white border border-gray-200 rounded-md shadow-lg p-3 text-xs text-gray-700 z-10",children:[
|
|
38
|
+
/* @__PURE__ */u("div",{className:"font-medium text-gray-900 mb-1",children:"Why is this page blank?"}),
|
|
39
|
+
/* @__PURE__ */m("p",{className:"mb-2",children:["Most major sites (Google, GitHub, banks, news) refuse to be embedded in an iframe via ",
|
|
40
|
+
/* @__PURE__ */u("span",{className:"font-mono",children:"X-Frame-Options"})," or Content Security Policy. There's no workaround — the browser blocks the load before our app can do anything."]}),
|
|
41
|
+
/* @__PURE__ */m("p",{children:["Hit the ",
|
|
42
|
+
/* @__PURE__ */u("span",{className:"font-medium",children:"↗"})," button to open the page in a real new tab. Sites that ",
|
|
43
|
+
/* @__PURE__ */u("em",{children:"do"})," allow embedding (Wikipedia, DevDocs, your own apps) work fine in here."]}),
|
|
44
|
+
/* @__PURE__ */u("button",{onClick:s,className:"mt-2 text-2xs text-blue-600 hover:underline",children:"Got it"})]})]})}export{v as default};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{loadAppearance as e,WidgetSettingsModal as t}from"./chunk-
|
|
1
|
+
import{loadAppearance as e,WidgetSettingsModal as t}from"./chunk-7DQ3PM5Z.js";import{useWidgetSettings as n}from"./chunk-IQZD6QQF.js";import"./chunk-4LXCCZDM.js";import"./chunk-AW7TOB6N.js";import"./chunk-KNUR2UEG.js";import"./chunk-JDCM2VHG.js";import"./chunk-QYL26AB4.js";import"./chunk-ZDMZM7HD.js";import"./chunk-5A7MWTXX.js";import"./chunk-2E2SUEEE.js";import"./chunk-PLK2WHZG.js";import"./chunk-7INZ7O3A.js";import"./chunk-55AEZX6K.js";import"./chunk-3DVNXNTF.js";import"./chunk-ECJKIPWU.js";import"./chunk-VWGWZY7A.js";import"./chunk-7QSDPSXP.js";import"./chunk-OKHKY3ZZ.js";import"./chunk-O3MBPAWZ.js";import"./chunk-2QY5BJLA.js";import"./chunk-UGTRSRIW.js";import"./chunk-KC3EX26K.js";import"./chunk-F3ZOO23R.js";import"./chunk-FZM3ZPW3.js";import"./chunk-CDAJKLGL.js";import"./chunk-6KGIHI6X.js";import"./chunk-URHGHXDN.js";import"./chunk-5QFPTDQF.js";import"./chunk-EOVXFXVV.js";import"./chunk-UQYNPYF4.js";import"./chunk-TE6R53YD.js";import{Icon as r}from"./chunk-2UO47XB4.js";import"./chunk-J75ZT2JQ.js";import"./chunk-R2VKEMZH.js";import"./chunk-MRJKZWWV.js";import"./chunk-WGLHB6WE.js";import"./chunk-NJN5IKWO.js";import"./chunk-PGN5ME7B.js";import"./chunk-62LW225J.js";import"./chunk-GLUJS42B.js";import"./chunk-D65T4H6J.js";import"./chunk-STKJA4PV.js";import"./chunk-5FYDNH4Y.js";import"./chunk-LNXBTK7Q.js";import"./chunk-TWVUQUUD.js";import"./chunk-GDQJBQ5B.js";import"./chunk-C3QOHMR6.js";import{useState as c,useRef as i,useCallback as o,useEffect as s}from"react";import{jsxs as l,Fragment as a,jsx as u}from"react/jsx-runtime";var h="calc_appearance";function m(){const[m,k]=c("0"),[p,d]=c(null),[b,g]=c(null),[j,N]=c(!1),[y,x]=c(""),[f,v]=c([]),[C,$]=c(!1),[E,W]=c(()=>e(h)),[D,Z]=c(!1),[T,Q]=c(E),K=i(null);n(o(()=>{Q({...E}),Z(!0)},[E]));const w=o(e=>{x(""),k(t=>j||"0"===t?(N(!1),"."===e?"0.":e):"."===e&&t.includes(".")?t:t+e)},[j]),A=o(()=>{k("0"),d(null),g(null),N(!1)},[]),B=o((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}},[]),F=o(e=>{const t=parseFloat(m);if(null!==p&&b&&!j){const e=B(p,t,b);k(String(e)),d(e),v(n=>[`${p} ${b} ${t} = ${e}`,...n].slice(0,20))}else d(t);g(e),N(!0)},[m,p,b,j,B]),J=o(()=>{if(null===p||!b)return;const e=parseFloat(m),t=B(p,e,b),n=`${p} ${b} ${e} =`;v(e=>[`${n} ${t}`,...e].slice(0,20)),x(n),k(String(t)),d(null),g(null),N(!0)},[m,p,b,B]),S=o(()=>{k(e=>String(parseFloat(e)/100))},[]),X=o(()=>{k(e=>e.startsWith("-")?e.slice(1):"0"===e?e:"-"+e)},[]);s(()=>{const e=e=>{const t=e.target.tagName;"INPUT"!==t&&"TEXTAREA"!==t&&"SELECT"!==t&&(e.key>="0"&&e.key<="9"?w(e.key):"."===e.key?w("."):"+"===e.key?F("+"):"-"===e.key?F("-"):"*"===e.key?F("×"):"/"===e.key?(e.preventDefault(),F("÷")):"Enter"===e.key||"="===e.key?("Enter"===e.key&&e.target instanceof Node&&K.current?.contains(e.target)&&e.preventDefault(),J()):"Escape"===e.key?A():"Backspace"===e.key?k(e=>e.length>1?e.slice(0,-1):"0"):"%"===e.key&&S())};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[w,F,J,A,S]);const L="flex items-center justify-center rounded-lg text-sm font-medium transition-colors",M=`${L} bg-white border border-gray-200 text-gray-900 hover:bg-gray-50 active:bg-gray-100`,U=`${L} bg-blue-50 border border-blue-200 text-blue-700 hover:bg-blue-100 active:bg-blue-200`,G=`${L} bg-gray-100 border border-gray-200 text-gray-600 hover:bg-gray-200 active:bg-gray-300`,H=`${L} bg-blue-600 text-white hover:bg-blue-700 active:bg-blue-800`;/* @__PURE__ */
|
|
2
2
|
return l(a,{children:[
|
|
3
3
|
/* @__PURE__ */l("div",{ref:K,className:"flex flex-col h-full",style:{opacity:E.activeOpacity/100,backdropFilter:E.activeBlur>0?`blur(${E.activeBlur}px)`:void 0},children:[
|
|
4
4
|
/* @__PURE__ */l("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:[
|
|
@@ -7,23 +7,23 @@ return l(a,{children:[
|
|
|
7
7
|
/* @__PURE__ */u("button",{onClick:()=>{navigator.clipboard.writeText(m),$(!0),setTimeout(()=>$(!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,C?{name:"check",className:"h-5 w-5 text-green-500",strokeWidth:2}:{name:"copy",className:"h-5 w-5",strokeWidth:2})}),
|
|
8
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)})(m)})]})]}),
|
|
9
9
|
/* @__PURE__ */l("div",{className:"grid grid-cols-4 grid-rows-5 gap-2 flex-1 min-h-0 p-2",children:[
|
|
10
|
-
/* @__PURE__ */u("button",{onClick:
|
|
11
|
-
/* @__PURE__ */u("button",{onClick:
|
|
12
|
-
/* @__PURE__ */u("button",{onClick:
|
|
13
|
-
/* @__PURE__ */u("button",{onClick:()=>
|
|
14
|
-
/* @__PURE__ */u("button",{onClick:()=>
|
|
15
|
-
/* @__PURE__ */u("button",{onClick:()=>
|
|
16
|
-
/* @__PURE__ */u("button",{onClick:()=>
|
|
17
|
-
/* @__PURE__ */u("button",{onClick:()=>
|
|
18
|
-
/* @__PURE__ */u("button",{onClick:()=>
|
|
19
|
-
/* @__PURE__ */u("button",{onClick:()=>
|
|
20
|
-
/* @__PURE__ */u("button",{onClick:()=>
|
|
21
|
-
/* @__PURE__ */u("button",{onClick:()=>
|
|
22
|
-
/* @__PURE__ */u("button",{onClick:()=>
|
|
23
|
-
/* @__PURE__ */u("button",{onClick:()=>
|
|
24
|
-
/* @__PURE__ */u("button",{onClick:()=>
|
|
25
|
-
/* @__PURE__ */u("button",{onClick:()=>
|
|
26
|
-
/* @__PURE__ */u("button",{onClick:()=>
|
|
27
|
-
/* @__PURE__ */u("button",{onClick:()=>
|
|
28
|
-
/* @__PURE__ */u("button",{onClick:
|
|
29
|
-
/* @__PURE__ */u(t,{open:
|
|
10
|
+
/* @__PURE__ */u("button",{onClick:A,className:G,children:"AC"}),
|
|
11
|
+
/* @__PURE__ */u("button",{onClick:X,className:G,children:"+/−"}),
|
|
12
|
+
/* @__PURE__ */u("button",{onClick:S,className:G,children:"%"}),
|
|
13
|
+
/* @__PURE__ */u("button",{onClick:()=>F("÷"),className:`${U} ${"÷"===b?"ring-2 ring-blue-400":""}`,children:"÷"}),
|
|
14
|
+
/* @__PURE__ */u("button",{onClick:()=>w("7"),className:M,children:"7"}),
|
|
15
|
+
/* @__PURE__ */u("button",{onClick:()=>w("8"),className:M,children:"8"}),
|
|
16
|
+
/* @__PURE__ */u("button",{onClick:()=>w("9"),className:M,children:"9"}),
|
|
17
|
+
/* @__PURE__ */u("button",{onClick:()=>F("×"),className:`${U} ${"×"===b?"ring-2 ring-blue-400":""}`,children:"×"}),
|
|
18
|
+
/* @__PURE__ */u("button",{onClick:()=>w("4"),className:M,children:"4"}),
|
|
19
|
+
/* @__PURE__ */u("button",{onClick:()=>w("5"),className:M,children:"5"}),
|
|
20
|
+
/* @__PURE__ */u("button",{onClick:()=>w("6"),className:M,children:"6"}),
|
|
21
|
+
/* @__PURE__ */u("button",{onClick:()=>F("-"),className:`${U} ${"-"===b?"ring-2 ring-blue-400":""}`,children:"−"}),
|
|
22
|
+
/* @__PURE__ */u("button",{onClick:()=>w("1"),className:M,children:"1"}),
|
|
23
|
+
/* @__PURE__ */u("button",{onClick:()=>w("2"),className:M,children:"2"}),
|
|
24
|
+
/* @__PURE__ */u("button",{onClick:()=>w("3"),className:M,children:"3"}),
|
|
25
|
+
/* @__PURE__ */u("button",{onClick:()=>F("+"),className:`${U} ${"+"===b?"ring-2 ring-blue-400":""}`,children:"+"}),
|
|
26
|
+
/* @__PURE__ */u("button",{onClick:()=>w("0"),className:`${M} col-span-2`,children:"0"}),
|
|
27
|
+
/* @__PURE__ */u("button",{onClick:()=>w("."),className:M,children:"."}),
|
|
28
|
+
/* @__PURE__ */u("button",{onClick:J,className:H,children:"="})]})]}),
|
|
29
|
+
/* @__PURE__ */u(t,{open:D,onClose:()=>Z(!1),title:"Calculator Settings",appearance:T,onAppearanceChange:Q,onSave:()=>{W(T),localStorage.setItem(h,JSON.stringify(T)),Z(!1)}})]})}export{m as default};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{loadAppearance as t,WidgetSettingsModal as e}from"./chunk-
|
|
1
|
+
import{loadAppearance as t,WidgetSettingsModal as e}from"./chunk-7DQ3PM5Z.js";import{useWidgetSettings as r}from"./chunk-IQZD6QQF.js";import"./chunk-4LXCCZDM.js";import"./chunk-AW7TOB6N.js";import"./chunk-KNUR2UEG.js";import"./chunk-JDCM2VHG.js";import"./chunk-QYL26AB4.js";import"./chunk-ZDMZM7HD.js";import"./chunk-5A7MWTXX.js";import"./chunk-2E2SUEEE.js";import"./chunk-PLK2WHZG.js";import"./chunk-7INZ7O3A.js";import"./chunk-55AEZX6K.js";import"./chunk-3DVNXNTF.js";import"./chunk-ECJKIPWU.js";import"./chunk-VWGWZY7A.js";import"./chunk-7QSDPSXP.js";import"./chunk-OKHKY3ZZ.js";import"./chunk-O3MBPAWZ.js";import"./chunk-2QY5BJLA.js";import"./chunk-UGTRSRIW.js";import"./chunk-KC3EX26K.js";import"./chunk-F3ZOO23R.js";import"./chunk-FZM3ZPW3.js";import"./chunk-CDAJKLGL.js";import"./chunk-6KGIHI6X.js";import"./chunk-URHGHXDN.js";import"./chunk-5QFPTDQF.js";import"./chunk-EOVXFXVV.js";import"./chunk-UQYNPYF4.js";import"./chunk-TE6R53YD.js";import"./chunk-2UO47XB4.js";import"./chunk-J75ZT2JQ.js";import{LoadingSpinner as n}from"./chunk-R2VKEMZH.js";import"./chunk-MRJKZWWV.js";import"./chunk-WGLHB6WE.js";import"./chunk-NJN5IKWO.js";import"./chunk-PGN5ME7B.js";import"./chunk-62LW225J.js";import"./chunk-GLUJS42B.js";import"./chunk-D65T4H6J.js";import"./chunk-STKJA4PV.js";import"./chunk-5FYDNH4Y.js";import"./chunk-LNXBTK7Q.js";import"./chunk-TWVUQUUD.js";import"./chunk-GDQJBQ5B.js";import"./chunk-C3QOHMR6.js";import{useState as s,useCallback as o,useEffect as c}from"react";import{jsxs as i,Fragment as a,jsx as m}from"react/jsx-runtime";var l=["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",h="currency_appearance",d="currency_rates_cache";function k(t){try{const e=JSON.parse(localStorage.getItem(d)||"{}")[t];if(e&&Date.now()-e.timestamp<36e5)return e.rates}catch{}return null}function g(t,e){try{const r=JSON.parse(localStorage.getItem(d)||"{}");r[t]={rates:e,timestamp:Date.now()},localStorage.setItem(d,JSON.stringify(r))}catch{}}function j(){try{const t=JSON.parse(localStorage.getItem(p)||"");if(Array.isArray(t)&&t.length)return t.slice(0,4)}catch{}return u}var N={USD:"🇺🇸",CNY:"🇨🇳",AUD:"🇦🇺",GBP:"🇬🇧",JPY:"🇯🇵",CAD:"🇨🇦",EUR:"🇪🇺",THB:"🇹🇭",NZD:"🇳🇿",SGD:"🇸🇬",HKD:"🇭🇰",CHF:"🇨🇭",KRW:"🇰🇷",INR:"🇮🇳",MXN:"🇲🇽",BRL:"🇧🇷"};function f(){const[u,d]=s(j),[f,x]=s(()=>t(h)),[y,b]=s({}),[D,S]=s(!1),[v,C]=s(!1),[U,J]=s([]),[B,Z]=s(f),[A,K]=s("USD"),[W,H]=s("CNY");r(o(()=>{J([...u]),Z({...f}),C(!0)},[u,f])),c(()=>{const t=[...new Set(u.map(([t])=>t))];let e=!0;return async function(){S(!0);const r={};for(const e of t){const t=k(e);if(t)r[e]=t;else try{const t=await fetch(`https://open.er-api.com/v6/latest/${e}`),n=await t.json();n.rates&&(r[e]=n.rates,g(e,n.rates))}catch{}}e&&(b(r),S(!1))}(),()=>{e=!1}},[u]);/* @__PURE__ */
|
|
2
2
|
return i(a,{children:[
|
|
3
3
|
/* @__PURE__ */m("div",{style:{backgroundColor:`rgb(var(--taskbar-bg-rgb, 243 244 246) / ${f.activeOpacity/100})`,backdropFilter:f.activeBlur>0?`blur(${f.activeBlur}px)`:void 0},children:/* @__PURE__ */i("div",{className:"px-4 py-3 space-y-1",children:[D&&/* @__PURE__ */m(n,{size:"sm",padding:"py-4",label:"Loading rates"}),u.map(([t,e],r)=>{const n=y[t]?.[e];/* @__PURE__ */
|
|
4
4
|
return i("button",{onClick:()=>{const t=u.map((t,e)=>e===r?[t[1],t[0]]:t);d(t),localStorage.setItem(p,JSON.stringify(t))},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:[
|
|
@@ -9,13 +9,13 @@ return i("button",{onClick:()=>{const t=u.map((t,e)=>e===r?[t[1],t[0]]:t);d(t),l
|
|
|
9
9
|
/* @__PURE__ */m("span",{className:"text-base",children:N[e]||""}),
|
|
10
10
|
/* @__PURE__ */m("span",{className:"text-sm font-semibold text-gray-700",children:e})]}),
|
|
11
11
|
/* @__PURE__ */m("div",{className:"text-base font-mono font-semibold text-gray-900 tabular-nums",children:null!=n?n.toLocaleString(void 0,{minimumFractionDigits:2,maximumFractionDigits:4}):"—"})]},`${t}-${e}-${r}`)})]})}),
|
|
12
|
-
/* @__PURE__ */m(e,{open:v,onClose:()=>C(!1),title:"Currency Settings",appearance:
|
|
12
|
+
/* @__PURE__ */m(e,{open:v,onClose:()=>C(!1),title:"Currency Settings",appearance:B,onAppearanceChange:Z,onSave:()=>{if(0===U.length)return;const t=U.slice(0,4);d(t),x(B),localStorage.setItem(p,JSON.stringify(t)),localStorage.setItem(h,JSON.stringify(B)),C(!1)},children:/* @__PURE__ */i("div",{children:[
|
|
13
13
|
/* @__PURE__ */i("h3",{className:"text-sm font-semibold text-ink mb-2",children:["Currency Pairs ",
|
|
14
14
|
/* @__PURE__ */i("span",{className:"text-2xs font-normal text-ink-faintest",children:["(",U.length,"/",4,")"]})]}),
|
|
15
15
|
/* @__PURE__ */m("div",{className:"space-y-1 mb-2",children:U.map(([t,e],r)=>/* @__PURE__ */i("div",{className:"flex items-center justify-between py-1 px-2 bg-gray-50 rounded",children:[
|
|
16
16
|
/* @__PURE__ */i("span",{className:"text-sm",children:[N[t]||""," ",t," → ",N[e]||""," ",e]}),
|
|
17
|
-
/* @__PURE__ */m("button",{onClick:()=>
|
|
18
|
-
/* @__PURE__ */m("select",{value:
|
|
17
|
+
/* @__PURE__ */m("button",{onClick:()=>J(t=>t.filter((t,e)=>e!==r)),className:"text-red-400 hover:text-red-600",children:"×"})]},r))}),U.length<4?/* @__PURE__ */i("div",{className:"flex items-center gap-2",children:[
|
|
18
|
+
/* @__PURE__ */m("select",{value:A,onChange:t=>K(t.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:l.map(t=>/* @__PURE__ */m("option",{children:t},t))}),
|
|
19
19
|
/* @__PURE__ */m("span",{className:"text-gray-400",children:"→"}),
|
|
20
|
-
/* @__PURE__ */m("select",{value:
|
|
21
|
-
/* @__PURE__ */m("button",{onClick:()=>{W
|
|
20
|
+
/* @__PURE__ */m("select",{value:W,onChange:t=>H(t.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:l.map(t=>/* @__PURE__ */m("option",{children:t},t))}),
|
|
21
|
+
/* @__PURE__ */m("button",{onClick:()=>{A!==W&&U.length<4&&J(t=>[...t,[A,W]])},className:"text-sm font-medium text-blue-600 hover:text-blue-800 px-2",children:"+ Add"})]}):/* @__PURE__ */i("p",{className:"text-2xs text-ink-faintest italic",children:["Max ",4," pairs — remove one to add another."]})]})})]})}export{f as default};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{escapeHtml as e}from"./chunk-G6DKCCWH.js";import{AboutApp as t}from"./chunk-
|
|
1
|
+
import{escapeHtml as e}from"./chunk-G6DKCCWH.js";import{AboutApp as t}from"./chunk-KIXTJNHQ.js";import{WindowTitle as n}from"./chunk-IQZD6QQF.js";import"./chunk-4LXCCZDM.js";import"./chunk-AW7TOB6N.js";import"./chunk-KNUR2UEG.js";import"./chunk-JDCM2VHG.js";import"./chunk-QYL26AB4.js";import"./chunk-ZDMZM7HD.js";import"./chunk-5A7MWTXX.js";import"./chunk-2E2SUEEE.js";import"./chunk-PLK2WHZG.js";import"./chunk-7INZ7O3A.js";import"./chunk-55AEZX6K.js";import"./chunk-3DVNXNTF.js";import"./chunk-ECJKIPWU.js";import"./chunk-VWGWZY7A.js";import"./chunk-7QSDPSXP.js";import"./chunk-OKHKY3ZZ.js";import"./chunk-O3MBPAWZ.js";import{toast_default as r}from"./chunk-7ELJQL7J.js";import"./chunk-2QY5BJLA.js";import"./chunk-UGTRSRIW.js";import"./chunk-KC3EX26K.js";import"./chunk-F3ZOO23R.js";import"./chunk-ETJRGQNG.js";import"./chunk-FZM3ZPW3.js";import"./chunk-CDAJKLGL.js";import{PopupMenu as o,PopupMenuLabel as i,PopupMenuItem as l,PopupMenuDivider as a}from"./chunk-6KGIHI6X.js";import"./chunk-URHGHXDN.js";import"./chunk-5QFPTDQF.js";import"./chunk-EOVXFXVV.js";import"./chunk-UQYNPYF4.js";import"./chunk-TE6R53YD.js";import{Icon as s}from"./chunk-2UO47XB4.js";import"./chunk-J75ZT2JQ.js";import{LoadingSpinner as c}from"./chunk-R2VKEMZH.js";import"./chunk-MRJKZWWV.js";import"./chunk-WGLHB6WE.js";import"./chunk-NJN5IKWO.js";import"./chunk-PGN5ME7B.js";import"./chunk-62LW225J.js";import"./chunk-GLUJS42B.js";import"./chunk-D65T4H6J.js";import"./chunk-STKJA4PV.js";import"./chunk-5FYDNH4Y.js";import"./chunk-LNXBTK7Q.js";import"./chunk-TWVUQUUD.js";import"./chunk-GDQJBQ5B.js";import"./chunk-C3QOHMR6.js";import{useState as m,useRef as h}from"react";import{jsxs as u,jsx as d}from"react/jsx-runtime";var p=/* @__PURE__ */new Set(["txt","md","markdown","csv","tsv","log","json","xml","html","htm","css","js","jsx","ts","tsx","py","rb","go","rs","java","c","h","cpp","hpp","sh","bash","yml","yaml","toml","ini","conf","env","sql"]),g=/* @__PURE__ */new Set(["docx"]),x={filename:"Untitled",kind:"docx",content:"",ext:"docx"};function f(){const[f,k]=m(x),[y,v]=m(!1),[b,j]=m(!1),[w,N]=m(!1),[D,C]=m(null),L=h(null),M=h(null),U=h(null),W=(e,t)=>{U.current?.focus(),document.execCommand(e,!1,t),N(!0)},R=e=>{for(const t of e){if(!t.type.startsWith("image/"))continue;const e=new FileReader;e.onload=()=>{U.current?.focus(),document.execCommand("insertImage",!1,String(e.result)),N(!0)},e.readAsDataURL(t)}},T=e=>{D&&(D.el.removeAttribute("width"),D.el.removeAttribute("height"),D.el.style.width=e??"",D.el.style.height=e?"auto":"",N(!0),C(null))},B=async t=>{const n=(t.name.split(".").pop()||"").toLowerCase();v(!0);try{if(p.has(n)||!g.has(n)&&t.type.startsWith("text/")){const r=await t.text(),o=e(r).replace(/\n/g,"<br>");k({filename:t.name,kind:"text",content:o,ext:n}),N(!1)}else if(g.has(n))try{const e=await(import(
|
|
2
2
|
/* @vite-ignore */
|
|
3
3
|
"mammoth")),r=await t.arrayBuffer(),o=await e.convertToHtml({arrayBuffer:r});k({filename:t.name,kind:"docx",content:o.value||"<p><em>(empty document)</em></p>",ext:n}),N(!1)}catch(e){r.error('Install the optional "mammoth" peer dep to read .docx files.')}else"doc"===n?r.error(".doc is the legacy Word binary format — convert to .docx first."):r.error(`Unsupported file type: .${n||"unknown"}`)}finally{v(!1)}},O=f?.filename?(A=f.filename).length>24?`${A.slice(0,23)}…`:A:"Untitled";var A;/* @__PURE__ */
|
|
4
4
|
return u("div",{className:"relative flex flex-col h-full",onDragOver:e=>{e.preventDefault(),b||j(!0)},onDragLeave:e=>{e.currentTarget===e.target&&j(!1)},onDrop:e=>{e.preventDefault(),j(!1);const t=Array.from(e.dataTransfer.files??[]);0!==t.length&&(t.every(e=>e.type.startsWith("image/"))?R(t):B(t[0]))},children:[
|
|
@@ -8,18 +8,18 @@ return u("div",{className:"relative flex flex-col h-full",onDragOver:e=>{e.preve
|
|
|
8
8
|
/* @__PURE__ */d("input",{ref:L,type:"file",accept:".txt,.md,.csv,.tsv,.log,.json,.xml,.html,.htm,.css,.js,.jsx,.ts,.tsx,.py,.rb,.go,.rs,.java,.c,.h,.cpp,.hpp,.sh,.bash,.yml,.yaml,.toml,.ini,.conf,.env,.sql,.docx,text/*",onChange:e=>{const t=e.target.files?.[0];t&&B(t),L.current&&(L.current.value="")},className:"hidden"}),
|
|
9
9
|
/* @__PURE__ */u("button",{onClick:()=>L.current?.click(),className:"text-xs text-gray-700 hover:text-gray-900 px-2 py-1 rounded hover:bg-gray-200 transition-colors flex items-center gap-1",children:[
|
|
10
10
|
/* @__PURE__ */d(s,{name:"folder-open",className:"h-3.5 w-3.5",strokeWidth:1.5}),"Open"]}),
|
|
11
|
-
/* @__PURE__ */d("button",{onClick:()=>{if(!f)return;const t=
|
|
11
|
+
/* @__PURE__ */d("button",{onClick:()=>{if(!f)return;const t=U.current?.innerHTML??"";if("text"===f.kind){if(/<(b|strong|i|em|u|font|span style|ul|ol|img)|style="[^"]*text-align/i.test(t)){const n=new Blob([`<!doctype html><meta charset="utf-8"><title>${e(f.filename)}</title><body style="font-family:ui-monospace,monospace;white-space:pre-wrap">${t}`],{type:"text/html"}),r=URL.createObjectURL(n),o=document.createElement("a");o.href=r,o.download=`${f.filename.replace(/\.[^.]+$/,"")}.html`,o.click(),URL.revokeObjectURL(r)}else{const e=U.current?.innerText??"",t=new Blob([e],{type:"text/plain"}),n=URL.createObjectURL(t),r=document.createElement("a");r.href=n,r.download=f.filename,r.click(),URL.revokeObjectURL(n)}}else{const n=new Blob([`<!doctype html><meta charset="utf-8"><title>${e(f.filename)}</title>${t}`],{type:"text/html"}),r=URL.createObjectURL(n),o=document.createElement("a");o.href=r,o.download=`${f.filename.replace(/\.docx$/i,"")}.html`,o.click(),URL.revokeObjectURL(r)}},className:"text-xs text-gray-700 hover:text-gray-900 px-2 py-1 rounded hover:bg-gray-200 transition-colors",children:"Save"}),
|
|
12
12
|
/* @__PURE__ */d("span",{className:"text-2xs text-ink-faintest ml-1",children:"TXT · DOCX · Code"}),
|
|
13
13
|
/* @__PURE__ */d("div",{className:"h-4 w-px bg-gray-300 mx-1"}),
|
|
14
14
|
/* @__PURE__ */u("span",{className:"text-xs font-medium text-gray-700 truncate max-w-[200px]",title:f.filename,children:[f.filename,w?" •":""]}),
|
|
15
15
|
/* @__PURE__ */d("div",{className:"h-4 w-px bg-gray-300 mx-1"}),
|
|
16
16
|
/* @__PURE__ */u("div",{className:"flex items-center gap-0.5",children:[
|
|
17
|
-
/* @__PURE__ */d("button",{onMouseDown:e=>e.preventDefault(),onClick:()=>
|
|
18
|
-
/* @__PURE__ */d("button",{onMouseDown:e=>e.preventDefault(),onClick:()=>
|
|
19
|
-
/* @__PURE__ */d("button",{onMouseDown:e=>e.preventDefault(),onClick:()=>
|
|
20
|
-
/* @__PURE__ */d("button",{onMouseDown:e=>e.preventDefault(),onClick:()=>
|
|
17
|
+
/* @__PURE__ */d("button",{onMouseDown:e=>e.preventDefault(),onClick:()=>W("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__ */d("button",{onMouseDown:e=>e.preventDefault(),onClick:()=>W("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__ */d("button",{onMouseDown:e=>e.preventDefault(),onClick:()=>W("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__ */d("button",{onMouseDown:e=>e.preventDefault(),onClick:()=>W("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__ */d("div",{className:"h-4 w-px bg-gray-300 mx-1"}),
|
|
22
|
-
/* @__PURE__ */u("select",{onMouseDown:e=>e.preventDefault(),onChange:e=>{
|
|
22
|
+
/* @__PURE__ */u("select",{onMouseDown:e=>e.preventDefault(),onChange:e=>{W("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__ */d("option",{value:"",disabled:!0,children:"Size"}),
|
|
24
24
|
/* @__PURE__ */d("option",{value:"1",children:"XS"}),
|
|
25
25
|
/* @__PURE__ */d("option",{value:"2",children:"S"}),
|
|
@@ -27,21 +27,21 @@ return u("div",{className:"relative flex flex-col h-full",onDragOver:e=>{e.preve
|
|
|
27
27
|
/* @__PURE__ */d("option",{value:"4",children:"L"}),
|
|
28
28
|
/* @__PURE__ */d("option",{value:"5",children:"XL"}),
|
|
29
29
|
/* @__PURE__ */d("option",{value:"6",children:"2XL"})]}),
|
|
30
|
-
/* @__PURE__ */d("input",{type:"color",defaultValue:"#000000",onChange:e=>
|
|
30
|
+
/* @__PURE__ */d("input",{type:"color",defaultValue:"#000000",onChange:e=>W("foreColor",e.target.value),className:"w-7 h-6 border border-gray-300 rounded cursor-pointer",title:"Text color"}),
|
|
31
31
|
/* @__PURE__ */d("div",{className:"h-4 w-px bg-gray-300 mx-1"}),
|
|
32
|
-
/* @__PURE__ */d("button",{onMouseDown:e=>e.preventDefault(),onClick:()=>
|
|
33
|
-
/* @__PURE__ */d("button",{onMouseDown:e=>e.preventDefault(),onClick:()=>
|
|
32
|
+
/* @__PURE__ */d("button",{onMouseDown:e=>e.preventDefault(),onClick:()=>W("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__ */d("button",{onMouseDown:e=>e.preventDefault(),onClick:()=>W("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__ */d("div",{className:"h-4 w-px bg-gray-300 mx-1"}),
|
|
35
35
|
/* @__PURE__ */u("div",{className:"flex items-center gap-0.5",children:[
|
|
36
|
-
/* @__PURE__ */d("button",{onMouseDown:e=>e.preventDefault(),onClick:()=>
|
|
37
|
-
/* @__PURE__ */d("button",{onMouseDown:e=>e.preventDefault(),onClick:()=>
|
|
38
|
-
/* @__PURE__ */d("button",{onMouseDown:e=>e.preventDefault(),onClick:()=>
|
|
39
|
-
/* @__PURE__ */d("button",{onMouseDown:e=>e.preventDefault(),onClick:()=>
|
|
36
|
+
/* @__PURE__ */d("button",{onMouseDown:e=>e.preventDefault(),onClick:()=>W("justifyLeft"),className:"px-2 py-1 rounded text-gray-700 hover:bg-gray-200 transition-colors",title:"Align left",children:/* @__PURE__ */d("svg",{className:"h-3.5 w-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.8,children:/* @__PURE__ */d("path",{strokeLinecap:"round",d:"M3.75 6h16.5M3.75 12h9.75M3.75 18h14.25"})})}),
|
|
37
|
+
/* @__PURE__ */d("button",{onMouseDown:e=>e.preventDefault(),onClick:()=>W("justifyCenter"),className:"px-2 py-1 rounded text-gray-700 hover:bg-gray-200 transition-colors",title:"Align center",children:/* @__PURE__ */d("svg",{className:"h-3.5 w-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.8,children:/* @__PURE__ */d("path",{strokeLinecap:"round",d:"M3.75 6h16.5M7.125 12h9.75M4.875 18h14.25"})})}),
|
|
38
|
+
/* @__PURE__ */d("button",{onMouseDown:e=>e.preventDefault(),onClick:()=>W("justifyRight"),className:"px-2 py-1 rounded text-gray-700 hover:bg-gray-200 transition-colors",title:"Align right",children:/* @__PURE__ */d("svg",{className:"h-3.5 w-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.8,children:/* @__PURE__ */d("path",{strokeLinecap:"round",d:"M3.75 6h16.5M10.5 12h9.75M6 18h14.25"})})}),
|
|
39
|
+
/* @__PURE__ */d("button",{onMouseDown:e=>e.preventDefault(),onClick:()=>W("justifyFull"),className:"px-2 py-1 rounded text-gray-700 hover:bg-gray-200 transition-colors",title:"Justify",children:/* @__PURE__ */d("svg",{className:"h-3.5 w-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.8,children:/* @__PURE__ */d("path",{strokeLinecap:"round",d:"M3.75 6h16.5M3.75 12h16.5M3.75 18h16.5"})})})]}),
|
|
40
40
|
/* @__PURE__ */d("div",{className:"h-4 w-px bg-gray-300 mx-1"}),
|
|
41
41
|
/* @__PURE__ */d("input",{ref:M,type:"file",accept:"image/*",multiple:!0,className:"hidden",onChange:e=>{e.target.files?.length&&R(Array.from(e.target.files)),M.current&&(M.current.value="")}}),
|
|
42
42
|
/* @__PURE__ */u("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
43
|
/* @__PURE__ */d(s,{name:"image",className:"h-3.5 w-3.5",strokeWidth:1.5}),"Image"]})]}),
|
|
44
|
-
/* @__PURE__ */d("div",{className:"flex-1 min-h-0 overflow-hidden",children:y?/* @__PURE__ */d(c,{size:"sm",padding:"",className:"h-full",label:"Loading"}):/* @__PURE__ */d("div",{className:"h-full overflow-auto "+("docx"===f.kind?"bg-gray-100 px-6 py-8":"bg-white"),children:/* @__PURE__ */d("div",{ref:
|
|
44
|
+
/* @__PURE__ */d("div",{className:"flex-1 min-h-0 overflow-hidden",children:y?/* @__PURE__ */d(c,{size:"sm",padding:"",className:"h-full",label:"Loading"}):/* @__PURE__ */d("div",{className:"h-full overflow-auto "+("docx"===f.kind?"bg-gray-100 px-6 py-8":"bg-white"),children:/* @__PURE__ */d("div",{ref:U,contentEditable:!0,suppressContentEditableWarning:!0,spellCheck:!1,onInput:()=>N(!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(),R(t))},onClick:e=>{const t=e.target;"IMG"===t.tagName&&(e.preventDefault(),C({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-surface p-[1in] shadow text-sm leading-relaxed text-ink-strong 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-ink-strong bg-surface outline-none whitespace-pre-wrap"})})}),b&&/* @__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 a document to open · images insert into the page"})}),D&&/* @__PURE__ */u(o,{minWidth:150,style:{left:D.x,top:D.y},onClose:()=>C(null),children:[
|
|
45
45
|
/* @__PURE__ */d(i,{children:"Image width"}),
|
|
46
46
|
/* @__PURE__ */d(l,{onClick:()=>T("25%"),children:"25%"}),
|
|
47
47
|
/* @__PURE__ */d(l,{onClick:()=>T("50%"),children:"50%"}),
|
|
@@ -1,39 +1,39 @@
|
|
|
1
|
-
import{openPreviewFile as e}from"./chunk-EOWUUOVE.js";import{SidebarLayout as t}from"./chunk-AFG34RBV.js";import"./chunk-QWK6DRSN.js";import"./chunk-Z44JWU75.js";import{Breadcrumbs as n}from"./chunk-XYECIBVX.js";import{formatBytes as a}from"./chunk-GEYM4WN3.js";import"./chunk-Y3JW2GW5.js";import"./chunk-36BRD5J3.js";import"./chunk-LF27WIN2.js";import{getFilesDemoTree as r}from"./chunk-5H4SWQGM.js";import{AboutApp as i}from"./chunk-
|
|
1
|
+
import{openPreviewFile as e}from"./chunk-EOWUUOVE.js";import{SidebarLayout as t}from"./chunk-AFG34RBV.js";import"./chunk-QWK6DRSN.js";import"./chunk-Z44JWU75.js";import{Breadcrumbs as n}from"./chunk-XYECIBVX.js";import{formatBytes as a}from"./chunk-GEYM4WN3.js";import"./chunk-Y3JW2GW5.js";import"./chunk-36BRD5J3.js";import"./chunk-LF27WIN2.js";import{getFilesDemoTree as r}from"./chunk-5H4SWQGM.js";import{AboutApp as i}from"./chunk-KIXTJNHQ.js";import{peekFilesViewRequest as s,consumeFilesViewRequest as o,FILES_SHOW_TRASH_EVENT as l,FILES_OPEN_DESKTOP_FOLDER_EVENT as c,subscribeDesktopFolders as d,getDesktopFoldersSnapshot as m,FolderGlyph as h,DesktopItemMiniIcon as p,desktopItemTypeLabel as u}from"./chunk-JFBL4PR3.js";import"./chunk-ESL5TDNA.js";import"./chunk-VTVSMRFX.js";import{useWindowManager as f,WindowTitle as x}from"./chunk-IQZD6QQF.js";import"./chunk-4LXCCZDM.js";import"./chunk-AW7TOB6N.js";import"./chunk-KNUR2UEG.js";import"./chunk-JDCM2VHG.js";import"./chunk-QYL26AB4.js";import"./chunk-ZDMZM7HD.js";import"./chunk-5A7MWTXX.js";import"./chunk-2E2SUEEE.js";import{confirm as k,prompt as g}from"./chunk-PLK2WHZG.js";import"./chunk-7INZ7O3A.js";import{ItemCount as b}from"./chunk-55AEZX6K.js";import"./chunk-3DVNXNTF.js";import"./chunk-ECJKIPWU.js";import"./chunk-VWGWZY7A.js";import"./chunk-7QSDPSXP.js";import"./chunk-OKHKY3ZZ.js";import"./chunk-O3MBPAWZ.js";import{toast_default as y}from"./chunk-7ELJQL7J.js";import"./chunk-2QY5BJLA.js";import"./chunk-UGTRSRIW.js";import"./chunk-KC3EX26K.js";import"./chunk-F3ZOO23R.js";import"./chunk-ETJRGQNG.js";import"./chunk-FZM3ZPW3.js";import"./chunk-CDAJKLGL.js";import"./chunk-6KGIHI6X.js";import"./chunk-URHGHXDN.js";import"./chunk-5QFPTDQF.js";import"./chunk-EOVXFXVV.js";import"./chunk-UQYNPYF4.js";import"./chunk-TE6R53YD.js";import{Icon as N}from"./chunk-2UO47XB4.js";import"./chunk-J75ZT2JQ.js";import{LoadingSpinner as w}from"./chunk-R2VKEMZH.js";import"./chunk-MRJKZWWV.js";import{TH_ONE_LINE as v}from"./chunk-WGLHB6WE.js";import"./chunk-NJN5IKWO.js";import"./chunk-PGN5ME7B.js";import"./chunk-62LW225J.js";import"./chunk-GLUJS42B.js";import"./chunk-D65T4H6J.js";import"./chunk-STKJA4PV.js";import"./chunk-5FYDNH4Y.js";import"./chunk-LNXBTK7Q.js";import"./chunk-TWVUQUUD.js";import"./chunk-GDQJBQ5B.js";import"./chunk-C3QOHMR6.js";import{useState as j,useEffect as $,useSyncExternalStore as C,useRef as E,useCallback as D}from"react";import{jsxs as L,jsx as T,Fragment as W}from"react/jsx-runtime";var R="undefined"!=typeof window&&window.__REACT_OS_SHELL_FILE_SERVER__||"http://localhost:4000",F={pdf:"pdf",dxf:"dxf",csv:"csv",jpg:"image",jpeg:"image",png:"image",gif:"image",webp:"image",svg:"image",avif:"image",bmp:"image",stp:"3d",step:"3d",stl:"3d",obj:"3d",gltf:"3d",glb:"3d","3mf":"3d",iges:"3d",igs:"3d",ply:"3d",fbx:"3d"};function P(e,t){return"/"===e||""===e?"/"+t:e.replace(/\/$/,"")+"/"+t}function S(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 U(){const U=R.replace(/\/$/,""),I=null!==r(),[M,O]=j("/"),[A,J]=j([]),[B,Q]=j([]),[V,K]=j(null),[G,H]=j(!0),[Z,X]=j(!1),[Y,z]=j(null),[_,q]=j(!1),[ee,te]=j(()=>{const e=s();return"trash"===e?"trash":e?{desktopFolderId:e.folderId}:"files"});$(()=>{o()},[]);const[ne,ae]=j([]);$(()=>{const e=()=>{o(),te("trash")},t=e=>{o();const t=e.detail?.folderId;t&&te({desktopFolderId:t})};return window.addEventListener(l,e),window.addEventListener(c,t),()=>{window.removeEventListener(l,e),window.removeEventListener(c,t)}},[]);const re=C(d,m,m),ie="object"==typeof ee?ee.desktopFolderId:null,se=ie?re?.folders.find(e=>e.id===ie)??null:null,oe=ie&&re?.itemsByFolder[ie]||[];$(()=>{ie&&re&&!re.folders.some(e=>e.id===ie)&&te("files")},[ie,re]);const le=E(0),ce=E(null),{openPage:de,openEntity:me}=f(),he=t=>{"preview-file"===t.entityType&&t.filePath&&t.fileKind?e({filePath:t.filePath,filename:t.label,kind:t.fileKind,onStaged:e=>de(e)}):"page"===t.entityType?de(t.entityId):me(t.entityType,t.entityId,null,t.label)},pe=D((e,t={})=>fetch(e,{...t,credentials:"include"}),[]),ue=D(async()=>{try{const e=await pe(`${U}/api/quota`);if(e.ok){const t=await e.json();z({used:t.used,limit:t.limit})}}catch{}},[pe,U]),fe=D(async e=>{if(K(null),I){const t=function(e){const t=r();if(!t)return[];let n=t;for(const t of e.split("/").filter(Boolean)){const e=n.find(e=>"folder"===e.kind&&e.name===t);if(!e||!e.children)return[];n=e.children}return n.map(e=>({name:e.name,kind:e.kind,size:e.size??0,modifiedAt:e.modifiedAt??""}))}(e);return J(t),O(e),X(!1),H(!1),void("/"===e&&Q(t.filter(e=>"folder"===e.kind).map(e=>e.name)))}H(!0);try{const t=await pe(`${U}/api/files?path=${encodeURIComponent(e)}`);if(!t.ok){const e=await t.json().catch(()=>({}));return void y.error(e.error||`Failed to list (${t.status})`)}const n=await t.json(),a=n.entries||[];J(a),O(n.path||e),X(!1),"/"===(n.path||e)&&Q(a.filter(e=>"folder"===e.kind).map(e=>e.name))}catch(e){X(!0)}finally{H(!1)}ue()},[pe,U,ue,I]),xe=D(async()=>{if(I)return ae([]),void H(!1);H(!0),K(null);try{const e=await pe(`${U}/api/trash`);if(!e.ok){const t=await e.json().catch(()=>({}));return void y.error(t.error||`Failed to list trash (${e.status})`)}const t=await e.json();ae(t.entries||[]),X(!1)}catch{X(!0)}finally{H(!1)}ue()},[pe,U,ue,I]);$(()=>{"files"===ee?fe(M):"trash"===ee&&xe()},[M,ee]);const ke=async e=>{const t=P(M,e.name);try{const n=await pe(`${U}/api/file?path=${encodeURIComponent(t)}`);if(!n.ok)return void y.error(`Download failed (${n.status})`);const a=await n.blob(),r=URL.createObjectURL(a),i=document.createElement("a");i.href=r,i.download=e.name,i.click(),setTimeout(()=>URL.revokeObjectURL(r),1e3)}catch(e){y.error(e?.message||"Download failed")}},ge=async e=>{const t=Array.from(e);for(const e of t){const t=new FormData;t.append("file",e);try{const n=await pe(`${U}/api/upload?path=${encodeURIComponent(M)}`,{method:"POST",body:t});if(!n.ok){const t=await n.json().catch(()=>({}));if(413===n.status){const n=Math.max(0,(t.limit||0)-(t.used||0));y.error(`Quota exceeded — ${a(n)} free, ${e.name} is ${a(t.attempted||e.size)}`)}else y.error(`Upload ${e.name}: ${t.error||n.status}`)}}catch(t){y.error(`Upload ${e.name}: ${t?.message||"failed"}`)}}fe(M)},be=()=>{le.current=0,q(!1)};if($(()=>{const e=()=>be();return window.addEventListener("dragend",e),window.addEventListener("drop",e),()=>{window.removeEventListener("dragend",e),window.removeEventListener("drop",e)}},[]),Z)/* @__PURE__ */
|
|
2
2
|
return L("div",{className:"flex flex-col h-full bg-white",children:[
|
|
3
3
|
/* @__PURE__ */T(x,{title:"Files - offline"}),
|
|
4
4
|
/* @__PURE__ */T("div",{className:"flex-1 flex items-center justify-center p-8 text-center",children:/* @__PURE__ */L("div",{className:"max-w-md",children:[
|
|
5
5
|
/* @__PURE__ */T(N,{name:"close-circle",className:"h-12 w-12 mx-auto text-gray-300 mb-3",strokeWidth:1.4}),
|
|
6
6
|
/* @__PURE__ */T("h3",{className:"text-base font-semibold text-gray-800 mb-1",children:"Can't reach the file server"}),
|
|
7
7
|
/* @__PURE__ */L("p",{className:"text-sm text-gray-500 mb-3",children:["No response from ",
|
|
8
|
-
/* @__PURE__ */T("span",{className:"font-mono",children:
|
|
8
|
+
/* @__PURE__ */T("span",{className:"font-mono",children:U}),". Make sure the server is running — see ",
|
|
9
9
|
/* @__PURE__ */T("span",{className:"font-mono",children:"examples/file-server/README.md"}),"."]}),
|
|
10
|
-
/* @__PURE__ */T("button",{onClick:()=>fe(
|
|
10
|
+
/* @__PURE__ */T("button",{onClick:()=>fe(M),className:"px-3 h-8 text-sm bg-blue-500 text-on-accent rounded hover:bg-blue-600",children:"Retry"})]})})]});const ye="/"===M?[]:M.split("/").filter(Boolean),Ne=Y&&Y.limit>0?Math.min(100,Math.round(Y.used/Y.limit*100)):0,we=Ne>90?"bg-red-500":Ne>75?"bg-amber-500":"bg-blue-500",ve=[{label:"My files",onClick:()=>O("/")},...ye.map((e,t)=>({label:e,onClick:()=>O("/"+ye.slice(0,t+1).join("/"))}))],je=e=>"flex w-full items-center gap-2 rounded-md px-3 min-h-(--row-height-menu) py-2 text-left text-sm transition-colors "+(e?"bg-blue-50 font-medium text-blue-700":"text-gray-700 hover:bg-gray-100"),$e=e=>/* @__PURE__ */T("svg",{className:"h-4 w-4 shrink-0 text-gray-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.6,children:/* @__PURE__ */T("path",{strokeLinecap:"round",strokeLinejoin:"round",d:e})}),Ce=/* @__PURE__ */L("nav",{className:"p-2",children:[
|
|
11
11
|
/* @__PURE__ */T("div",{className:"px-2 py-2 text-2xs font-semibold uppercase tracking-wide text-ink-faintest",children:"Locations"}),
|
|
12
|
-
/* @__PURE__ */L("button",{onClick:()=>{te("files"),
|
|
13
|
-
/* @__PURE__ */T("span",{className:"truncate",children:e})]},e)),!
|
|
12
|
+
/* @__PURE__ */L("button",{onClick:()=>{te("files"),O("/")},className:je("files"===ee&&"/"===M),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"]}),B.map(e=>/* @__PURE__ */L("button",{onClick:()=>{te("files"),O("/"+e)},className:je("files"===ee&&M==="/"+e),children:[$e("M2.25 12.75V12A2.25 2.25 0 014.5 9.75h15A2.25 2.25 0 0121.75 12v.75m-8.69-6.44l-2.12-2.12a1.5 1.5 0 00-1.061-.44H4.5A2.25 2.25 0 002.25 6v12a2.25 2.25 0 002.25 2.25h15A2.25 2.25 0 0021.75 18V9a2.25 2.25 0 00-2.25-2.25h-5.379a1.5 1.5 0 01-1.06-.44z"),
|
|
13
|
+
/* @__PURE__ */T("span",{className:"truncate",children:e})]},e)),!I&&/* @__PURE__ */L("button",{onClick:()=>te("trash"),className:je("trash"===ee),children:[$e("M14.74 9l-.346 9m-4.788 0L9.26 9m9.968-3.21c.342.052.682.107 1.022.166m-1.022-.165L18.16 19.673a2.25 2.25 0 01-2.244 2.077H8.084a2.25 2.25 0 01-2.244-2.077L4.772 5.79"),"Trash"]}),re&&re.folders.length>0&&/* @__PURE__ */L(W,{children:[
|
|
14
14
|
/* @__PURE__ */T("div",{className:"px-2 pt-3 pb-2 text-2xs font-semibold uppercase tracking-wide text-ink-faintest",children:"Desktop"}),re.folders.map(e=>/* @__PURE__ */L("button",{onClick:()=>te({desktopFolderId:e.id}),className:je(ie===e.id),children:[
|
|
15
15
|
/* @__PURE__ */T(h,{className:"h-4 w-4 shrink-0 text-amber-500"}),
|
|
16
16
|
/* @__PURE__ */T("span",{className:"truncate",children:e.name}),
|
|
17
17
|
/* @__PURE__ */T(b,{count:e.itemCount,active:ie===e.id,className:"ml-auto"})]},e.id))]})]});/* @__PURE__ */
|
|
18
|
-
return L("div",{className:"relative flex flex-col h-full bg-white",onDragEnter:e=>{
|
|
19
|
-
/* @__PURE__ */T(x,{title:se?`Files - ${se.name}`:"Files"+("/"===
|
|
18
|
+
return L("div",{className:"relative flex flex-col h-full bg-white",onDragEnter:e=>{I||"object"==typeof ee||e.dataTransfer?.types?.includes?.("Files")&&(e.preventDefault(),le.current++,_||q(!0))},onDragOver:e=>{e.dataTransfer?.types?.includes?.("Files")&&e.preventDefault()},onDragLeave:()=>{le.current>0&&le.current--,0===le.current&&q(!1)},onDrop:e=>{e.preventDefault(),be(),I||"object"==typeof ee||e.dataTransfer.files?.length&&ge(e.dataTransfer.files)},children:[
|
|
19
|
+
/* @__PURE__ */T(x,{title:se?`Files - ${se.name}`:"Files"+("/"===M?"":" - "+M)}),
|
|
20
20
|
/* @__PURE__ */T(i,{app:"files"}),
|
|
21
21
|
/* @__PURE__ */T("input",{ref:ce,type:"file",multiple:!0,className:"hidden",onChange:e=>{e.target.files?.length&&ge(e.target.files),ce.current&&(ce.current.value="")}}),
|
|
22
|
-
/* @__PURE__ */T("div",{className:"flex-1 min-h-0",children:/* @__PURE__ */T(t,{sidebar:
|
|
22
|
+
/* @__PURE__ */T("div",{className:"flex-1 min-h-0",children:/* @__PURE__ */T(t,{sidebar:Ce,storageKey:"files.sidebarWidth",defaultWidth:200,minWidth:150,maxWidth:320,children:/* @__PURE__ */L("div",{className:"flex h-full min-w-0 flex-col",children:[
|
|
23
23
|
/* @__PURE__ */L("div",{className:"flex items-center gap-1 px-2 py-2 border-b border-line bg-surface-sunken shrink-0 text-xs",children:[/* @__PURE__ */L(W,"files"===ee?{children:[
|
|
24
|
-
/* @__PURE__ */T("button",{onClick:()=>
|
|
24
|
+
/* @__PURE__ */T("button",{onClick:()=>O(function(e){if("/"===e||""===e)return"/";const t=e.replace(/\/$/,""),n=t.lastIndexOf("/");return n<=0?"/":t.slice(0,n)}(M)),disabled:"/"===M,className:"px-2 py-1 rounded hover:bg-gray-200 disabled:opacity-30 text-gray-600",title:"Parent folder",children:/* @__PURE__ */T(N,{name:"arrow-left",className:"h-3.5 w-3.5",strokeWidth:2})}),
|
|
25
25
|
/* @__PURE__ */T("div",{className:"flex-1 min-w-0",children:/* @__PURE__ */T(n,{items:ve,maxItems:5})}),
|
|
26
|
-
/* @__PURE__ */T("button",{onClick:()=>fe(
|
|
26
|
+
/* @__PURE__ */T("button",{onClick:()=>fe(M),className:"px-2 py-1 rounded hover:bg-gray-200 text-gray-600",title:"Refresh",children:/* @__PURE__ */T(N,{name:"refresh",className:"h-3.5 w-3.5",strokeWidth:1.8})}),!I&&/* @__PURE__ */L(W,{children:[
|
|
27
27
|
/* @__PURE__ */L("button",{onClick:()=>te("trash"),className:"px-2 py-1 rounded hover:bg-gray-200 text-gray-600 flex items-center gap-1",title:"Open trash",children:[
|
|
28
28
|
/* @__PURE__ */T(N,{name:"trash",className:"h-3.5 w-3.5",strokeWidth:1.5}),"Trash"]}),
|
|
29
|
-
/* @__PURE__ */L("button",{onClick:async()=>{const e=await g({title:"New folder",placeholder:"Folder name",confirmLabel:"Create"});if(!e)return;if(/[\\/]/.test(e))return void y.error("Folder names cannot contain slashes");const t=
|
|
29
|
+
/* @__PURE__ */L("button",{onClick:async()=>{const e=await g({title:"New folder",placeholder:"Folder name",confirmLabel:"Create"});if(!e)return;if(/[\\/]/.test(e))return void y.error("Folder names cannot contain slashes");const t=P(M,e),n=await pe(`${U}/api/folder`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:t})});if(!n.ok){const e=await n.json().catch(()=>({}));return void y.error(e.error||`Create folder failed (${n.status})`)}fe(M)},className:"px-2 py-1 rounded hover:bg-gray-200 text-gray-600 flex items-center gap-1",children:[
|
|
30
30
|
/* @__PURE__ */T(N,{name:"folder-plus",className:"h-3.5 w-3.5",strokeWidth:1.5}),"New Folder"]}),
|
|
31
31
|
/* @__PURE__ */L("button",{onClick:()=>ce.current?.click(),className:"px-2 py-1 rounded bg-blue-500 text-white hover:bg-blue-600 flex items-center gap-1",children:[
|
|
32
32
|
/* @__PURE__ */T(N,{name:"upload",className:"h-3.5 w-3.5",strokeWidth:1.8}),"Upload"]})]})]}:"trash"===ee?{children:[
|
|
33
33
|
/* @__PURE__ */T("button",{onClick:()=>te("files"),className:"px-2 py-1 rounded hover:bg-gray-200 text-gray-600",title:"Back to files",children:/* @__PURE__ */T(N,{name:"arrow-left",className:"h-3.5 w-3.5",strokeWidth:2})}),
|
|
34
34
|
/* @__PURE__ */T("span",{className:"flex-1 text-gray-700 font-medium px-2",children:"Trash"}),
|
|
35
35
|
/* @__PURE__ */T("button",{onClick:xe,className:"px-2 py-1 rounded hover:bg-gray-200 text-gray-600",title:"Refresh",children:/* @__PURE__ */T(N,{name:"refresh",className:"h-3.5 w-3.5",strokeWidth:1.8})}),
|
|
36
|
-
/* @__PURE__ */T("button",{onClick:async()=>{if(0===ne.length)return;if(!await k({title:"Empty trash",message:`${ne.length} item${1===ne.length?"":"s"} will be permanently removed. This can't be undone.`,confirmLabel:"Empty trash",variant:"danger"}))return;const e=await pe(`${
|
|
36
|
+
/* @__PURE__ */T("button",{onClick:async()=>{if(0===ne.length)return;if(!await k({title:"Empty trash",message:`${ne.length} item${1===ne.length?"":"s"} will be permanently removed. This can't be undone.`,confirmLabel:"Empty trash",variant:"danger"}))return;const e=await pe(`${U}/api/trash`,{method:"DELETE"});if(!e.ok){const t=await e.json().catch(()=>({}));return void y.error(t.error||`Empty trash failed (${e.status})`)}xe()},disabled:0===ne.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:[
|
|
37
37
|
/* @__PURE__ */T("button",{onClick:()=>te("files"),className:"px-2 py-1 rounded hover:bg-gray-200 text-gray-600",title:"Back to files",children:/* @__PURE__ */T(N,{name:"arrow-left",className:"h-3.5 w-3.5",strokeWidth:2})}),
|
|
38
38
|
/* @__PURE__ */T(h,{className:"h-4 w-4 text-amber-500 ml-1"}),
|
|
39
39
|
/* @__PURE__ */T("span",{className:"flex-1 text-gray-700 font-medium px-1 truncate",children:se?.name??"Desktop folder"}),
|
|
@@ -48,7 +48,7 @@ return L("div",{className:"relative flex flex-col h-full bg-white",onDragEnter:e
|
|
|
48
48
|
/* @__PURE__ */T("th",{className:`${v} text-left font-medium px-3 h-8 w-28`,children:"Type"}),
|
|
49
49
|
/* @__PURE__ */T("th",{className:`${v} w-56`})]})}),
|
|
50
50
|
/* @__PURE__ */T("tbody",{children:oe.map(e=>{const t=`${e.entityType}|${e.entityId}`;/* @__PURE__ */
|
|
51
|
-
return L("tr",{onClick:()=>K(t),onDoubleClick:()=>he(e),className:"cursor-default border-b border-gray-100 "+(
|
|
51
|
+
return L("tr",{onClick:()=>K(t),onDoubleClick:()=>he(e),className:"cursor-default border-b border-gray-100 "+(V===t?"bg-blue-50":"hover:bg-gray-50"),children:[
|
|
52
52
|
/* @__PURE__ */L("td",{className:"px-3 h-8 flex items-center gap-2",children:[
|
|
53
53
|
/* @__PURE__ */T(p,{item:e}),
|
|
54
54
|
/* @__PURE__ */T("span",{className:"truncate",title:e.label,children:e.label})]}),
|
|
@@ -56,7 +56,7 @@ return L("tr",{onClick:()=>K(t),onDoubleClick:()=>he(e),className:"cursor-defaul
|
|
|
56
56
|
/* @__PURE__ */L("td",{className:"px-3 h-8 text-right whitespace-nowrap",children:[
|
|
57
57
|
/* @__PURE__ */T("button",{onClick:t=>{t.stopPropagation(),he(e)},className:"px-2 py-0.5 rounded hover:bg-gray-200 text-blue-600 text-2xs",children:"Open"}),
|
|
58
58
|
/* @__PURE__ */T("button",{onClick:t=>{t.stopPropagation(),re?.moveToDesktop([e])},className:"px-2 py-0.5 rounded hover:bg-gray-200 text-ink-faint text-2xs ml-1",children:"Move to desktop"}),
|
|
59
|
-
/* @__PURE__ */T("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"===ee?
|
|
59
|
+
/* @__PURE__ */T("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"===ee?G&&0===ne.length?/* @__PURE__ */T(w,{size:"sm",padding:"p-6",label:"Loading"}):0===ne.length?/* @__PURE__ */T("div",{className:"p-10 text-center text-sm text-gray-400",children:"Trash is empty."}):/* @__PURE__ */L("table",{className:"w-full text-sm",children:[
|
|
60
60
|
/* @__PURE__ */T("thead",{className:"bg-surface-sunken text-2xs uppercase tracking-wide text-ink-faint",children:/* @__PURE__ */L("tr",{children:[
|
|
61
61
|
/* @__PURE__ */T("th",{className:`${v} text-left font-medium px-3 h-8`,children:"Name"}),
|
|
62
62
|
/* @__PURE__ */T("th",{className:`${v} text-left font-medium px-3 h-8`,children:"Original location"}),
|
|
@@ -68,21 +68,21 @@ return L("tr",{onClick:()=>K(t),onDoubleClick:()=>he(e),className:"cursor-defaul
|
|
|
68
68
|
/* @__PURE__ */T("span",{className:"truncate",title:e.name,children:e.name})]}),
|
|
69
69
|
/* @__PURE__ */T("td",{className:"px-3 h-8 text-ink-faint text-xs font-mono truncate",title:e.originalPath,children:e.originalPath||"—"}),
|
|
70
70
|
/* @__PURE__ */T("td",{className:"px-3 h-8 text-right tabular-nums text-ink-faint",children:a(e.size)}),
|
|
71
|
-
/* @__PURE__ */T("td",{className:"px-3 h-8 text-right text-ink-faint tabular-nums",children:e.deletedAt?
|
|
71
|
+
/* @__PURE__ */T("td",{className:"px-3 h-8 text-right text-ink-faint tabular-nums",children:e.deletedAt?S(e.deletedAt):"—"}),
|
|
72
72
|
/* @__PURE__ */L("td",{className:"px-3 h-8 text-right whitespace-nowrap",children:[
|
|
73
|
-
/* @__PURE__ */T("button",{onClick:()=>(async e=>{const t=await pe(`${
|
|
74
|
-
/* @__PURE__ */T("button",{onClick:()=>(async e=>{if(!await k({title:"Permanently delete",message:`"${e.name}" will be permanently removed. This can't be undone.`,confirmLabel:"Delete forever",variant:"danger"}))return;const t=await pe(`${
|
|
73
|
+
/* @__PURE__ */T("button",{onClick:()=>(async e=>{const t=await pe(`${U}/api/trash/restore`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({id:e.id})});if(!t.ok){const e=await t.json().catch(()=>({}));return void y.error(e.error||`Restore failed (${t.status})`)}y.success(`Restored "${e.name}"`),xe()})(e),className:"px-2 py-0.5 rounded hover:bg-gray-200 text-blue-600 text-2xs",children:"Restore"}),
|
|
74
|
+
/* @__PURE__ */T("button",{onClick:()=>(async e=>{if(!await k({title:"Permanently delete",message:`"${e.name}" will be permanently removed. This can't be undone.`,confirmLabel:"Delete forever",variant:"danger"}))return;const t=await pe(`${U}/api/trash/${encodeURIComponent(e.id)}`,{method:"DELETE"});if(!t.ok){const e=await t.json().catch(()=>({}));return void y.error(e.error||`Delete failed (${t.status})`)}xe()})(e),className:"px-2 py-0.5 rounded hover:bg-red-100 text-red-600 text-2xs ml-1",children:"Delete forever"})]})]},e.id))})]}):G&&0===A.length?/* @__PURE__ */T(w,{size:"sm",padding:"p-6",label:"Loading"}):0===A.length?/* @__PURE__ */L("div",{className:"p-10 text-center text-sm text-gray-400",children:["Empty folder.",!I&&/* @__PURE__ */L(W,{children:[" Drop files here or click ",
|
|
75
75
|
/* @__PURE__ */T("span",{className:"font-medium",children:"Upload"}),"."]})]}):/* @__PURE__ */L("table",{className:"w-full text-sm",children:[
|
|
76
76
|
/* @__PURE__ */T("thead",{className:"bg-surface-sunken text-2xs uppercase tracking-wide text-ink-faint",children:/* @__PURE__ */L("tr",{children:[
|
|
77
77
|
/* @__PURE__ */T("th",{className:`${v} text-left font-medium px-3 h-8`,children:"Name"}),
|
|
78
78
|
/* @__PURE__ */T("th",{className:`${v} text-right font-medium px-3 h-8 w-24`,children:"Size"}),
|
|
79
79
|
/* @__PURE__ */T("th",{className:`${v} text-right font-medium px-3 h-8 w-40`,children:"Modified"}),
|
|
80
80
|
/* @__PURE__ */T("th",{className:`${v} w-32`})]})}),
|
|
81
|
-
/* @__PURE__ */T("tbody",{children:A.map(t=>/* @__PURE__ */L("tr",{onClick:()=>K(t.name),onDoubleClick:()=>{"folder"===t.kind?
|
|
81
|
+
/* @__PURE__ */T("tbody",{children:A.map(t=>/* @__PURE__ */L("tr",{onClick:()=>K(t.name),onDoubleClick:()=>{"folder"===t.kind?O(P(M,t.name)):(async t=>{if(I)return;const n=P(M,t.name),a=(t.name.split(".").pop()||"").toLowerCase(),r=F[a];r?await e({filePath:n,filename:t.name,kind:r,onStaged:e=>de(e)}):ke(t)})(t)},className:"cursor-default border-b border-gray-100 "+(V===t.name?"bg-blue-50":"hover:bg-gray-50"),children:[
|
|
82
82
|
/* @__PURE__ */L("td",{className:"px-3 h-8 flex items-center gap-2",children:["folder"===t.kind?/* @__PURE__ */T(N,{name:"folder",look:"solid",className:"h-4 w-4 text-amber-500 shrink-0"}):/* @__PURE__ */T(N,{name:"page",className:"h-4 w-4 text-ink-faintest shrink-0",strokeWidth:1.5}),
|
|
83
83
|
/* @__PURE__ */T("span",{className:"truncate",title:t.name,children:t.name})]}),
|
|
84
84
|
/* @__PURE__ */T("td",{className:"px-3 h-8 text-right tabular-nums text-ink-faint",children:"folder"===t.kind?"—":a(t.size)}),
|
|
85
|
-
/* @__PURE__ */T("td",{className:"px-3 h-8 text-right text-ink-faint tabular-nums",children:
|
|
86
|
-
/* @__PURE__ */T("td",{className:"px-3 h-8 text-right whitespace-nowrap",children:!
|
|
87
|
-
/* @__PURE__ */T("button",{onClick:e=>{e.stopPropagation(),(async e=>{const t=await g({title:`Rename ${e.kind}`,defaultValue:e.name,confirmLabel:"Rename"});if(!t||t===e.name)return;if(/[\\/]/.test(t))return void y.error("Names cannot contain slashes");const n=
|
|
88
|
-
/* @__PURE__ */T("button",{onClick:e=>{e.stopPropagation(),(async e=>{if(!await k({title:`Delete ${e.kind}`,message:`"${e.name}"${"folder"===e.kind?" and everything inside":""} will be permanently removed.`,confirmLabel:"Delete",variant:"danger"}))return;const t=
|
|
85
|
+
/* @__PURE__ */T("td",{className:"px-3 h-8 text-right text-ink-faint tabular-nums",children:S(t.modifiedAt)}),
|
|
86
|
+
/* @__PURE__ */T("td",{className:"px-3 h-8 text-right whitespace-nowrap",children:!I&&/* @__PURE__ */L(W,{children:["file"===t.kind&&/* @__PURE__ */T("button",{onClick:e=>{e.stopPropagation(),ke(t)},className:"px-2 py-0.5 rounded hover:bg-gray-200 text-ink-faint text-2xs",children:"Download"}),
|
|
87
|
+
/* @__PURE__ */T("button",{onClick:e=>{e.stopPropagation(),(async e=>{const t=await g({title:`Rename ${e.kind}`,defaultValue:e.name,confirmLabel:"Rename"});if(!t||t===e.name)return;if(/[\\/]/.test(t))return void y.error("Names cannot contain slashes");const n=P(M,e.name),a=P(M,t),r=await pe(`${U}/api/rename`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({from:n,to:a})});if(!r.ok){const e=await r.json().catch(()=>({}));return void y.error(e.error||`Rename failed (${r.status})`)}fe(M)})(t)},className:"px-2 py-0.5 rounded hover:bg-gray-200 text-ink-faint text-2xs ml-1",children:"Rename"}),
|
|
88
|
+
/* @__PURE__ */T("button",{onClick:e=>{e.stopPropagation(),(async e=>{if(!await k({title:`Delete ${e.kind}`,message:`"${e.name}"${"folder"===e.kind?" and everything inside":""} will be permanently removed.`,confirmLabel:"Delete",variant:"danger"}))return;const t=P(M,e.name),n=await pe(`${U}/api/files?path=${encodeURIComponent(t)}`,{method:"DELETE"});if(!n.ok){const e=await n.json().catch(()=>({}));return void y.error(e.error||`Delete failed (${n.status})`)}fe(M)})(t)},className:"px-2 py-0.5 rounded hover:bg-red-100 text-red-600 text-2xs ml-1",children:"Delete"})]})})]},t.name))})]})})]})})}),_&&/* @__PURE__ */T("div",{className:"absolute inset-0 bg-blue-500/15 border-4 border-dashed border-blue-500 pointer-events-none flex items-center justify-center z-20",children:/* @__PURE__ */T("div",{className:"px-4 py-2 rounded-md bg-blue-600 text-white text-sm font-medium shadow-lg",children:"Drop to upload"})})]})}export{U as default};
|