efficient-shell 8.13.0 → 8.15.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -0
- package/dist/{Browser-OOJUPENB.js → Browser-XELHJME5.js} +14 -14
- package/dist/{Calculator-PPH3FLQG.js → Calculator-NPBOUICN.js} +22 -22
- package/dist/{CurrencyConverter-GTICX6V3.js → CurrencyConverter-NTJJAE7V.js} +8 -8
- package/dist/{Documents-RXNGM2OY.js → Documents-AVAYAW4T.js} +15 -15
- package/dist/{Files-G2FQ5Z3R.js → Files-KZWWBH6Q.js} +87 -87
- package/dist/{Notepad-7777T6ES.js → Notepad-FJELN7GD.js} +10 -10
- package/dist/{PomodoroTimer-VPRRRXVE.js → PomodoroTimer-LBB7U6QS.js} +19 -19
- package/dist/{Preview-QBWSY7W7.js → Preview-ILPASIEM.js} +34 -34
- package/dist/{Spreadsheet-JIOTLCIK.js → Spreadsheet-J62PVFXA.js} +10 -10
- package/dist/{Stock-OIDTOA6E.js → Stock-NBXKAAIF.js} +3 -3
- package/dist/{Weather-XT3S2O4X.js → Weather-M7NGMQFP.js} +16 -16
- package/dist/{WorldClock-QFPWQDD2.js → WorldClock-YQQJXAUG.js} +4 -4
- 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/charts/BoxPlotChart.js +1 -1
- package/dist/charts/CandlestickChart.js +1 -1
- package/dist/charts/CartesianPlot.js +1 -1
- package/dist/charts/ChordChart.js +1 -1
- package/dist/charts/ColumnChart.js +1 -1
- package/dist/charts/HeatmapChart.js +1 -1
- package/dist/charts/HistogramChart.js +1 -1
- package/dist/charts/RadarChart.js +1 -1
- package/dist/charts/RangeChart.js +1 -1
- package/dist/charts/SankeyChart.js +1 -1
- package/dist/charts/ScatterChart.js +1 -1
- package/dist/charts/SunburstChart.js +1 -1
- package/dist/charts/TimeSeriesChart.js +1 -1
- package/dist/charts/TreemapChart.js +1 -1
- package/dist/charts/WaterfallChart.js +1 -1
- package/dist/{chunk-QQVLFDX6.js → chunk-3MZTDNAW.js} +4 -4
- package/dist/{chunk-B4LK7WL6.js → chunk-3VCAQ72C.js} +2 -2
- package/dist/{chunk-4GEAEYKA.js → chunk-3WUR24KP.js} +49 -49
- package/dist/{chunk-J6QU5JTZ.js → chunk-5PYRVXWN.js} +1 -1
- package/dist/{chunk-Q7OGTJET.js → chunk-ARC3R4I2.js} +1 -1
- package/dist/chunk-ES4HIX3L.js +2 -0
- package/dist/{chunk-7GU3LUMW.js → chunk-FEIVDR4M.js} +6 -6
- package/dist/{chunk-PPSIMRJM.js → chunk-FPI7WBMU.js} +4 -4
- package/dist/{chunk-XMGXVMVS.js → chunk-JM2XJJRB.js} +5 -5
- package/dist/{chunk-CXDJXNPZ.js → chunk-LATFMUX6.js} +1 -1
- package/dist/{chunk-RP4ZLTXA.js → chunk-LT2MMSHH.js} +12 -12
- package/dist/{chunk-EDYCBXWD.js → chunk-OFXGSEYD.js} +4 -4
- package/dist/{chunk-BGVN7HOZ.js → chunk-RPAKTBQT.js} +2 -2
- package/dist/{chunk-LPYFS4RV.js → chunk-UCMPHYBP.js} +14 -14
- package/dist/{chunk-UWHGJTAL.js → chunk-VCEARTZR.js} +5 -5
- package/dist/{chunk-OS6GGLQQ.js → chunk-VQUMEECM.js} +2 -2
- package/dist/{chunk-6AB42T2W.js → chunk-XNIMCECI.js} +1 -1
- package/dist/chunk-YHYL2WSG.js +1 -0
- package/dist/{chunk-HTOZWATN.js → chunk-ZKVWQY4V.js} +1 -1
- package/dist/hooks/useTheme.d.ts +1 -1
- package/dist/index.d.ts +14 -2
- package/dist/index.js +694 -694
- package/dist/page-tabs/index.js +4 -4
- package/dist/shell/ConfirmDialog.js +1 -1
- package/dist/shell/Dialog.js +1 -1
- package/dist/telemetry/index.js +1 -1
- package/dist/templates/DashboardTemplate.js +1 -1
- package/dist/templates/ErrorBoundary.d.ts +1 -1
- package/dist/ui/index.js +1 -1
- package/dist/version.js +1 -1
- package/package.json +1 -1
- package/dist/chunk-KV5VLPII.js +0 -1
- package/dist/chunk-YEY6YPTM.js +0 -2
package/README.md
CHANGED
|
@@ -1565,6 +1565,7 @@ All exports are named — `import { Modal, ... } from 'efficient-shell'`.
|
|
|
1565
1565
|
| `useWindowManager()` | `{ openPage, openEntity, closeEntity, openWindows, … }` |
|
|
1566
1566
|
| `usePageSearch()` | The search text this page window was opened with (`openPage(path, { search })`), or `''`. Seed a list's search box with it: `useState(usePageSearch())`. |
|
|
1567
1567
|
| `useWindowDirty(dirty)` | Registers controlled unsaved state with the enclosing `PageWindow`; multiple registrations aggregate with any-dirty semantics, and calls outside a managed page window are ignored. |
|
|
1568
|
+
| `createWindowTarget(windowKey)` / `useWindowTarget(target)` | The staging channel for a window that is mounted once and retargeted (one Edit window every "Edit" button points at). `set(target)` shows the window and brings it forward; `set(null)` closes it. While the window's `Modal` holds unsaved changes, `set(target)` first asks the same "Discard changes?" its ✕ asks, and stays put on Keep Editing. Pass `{ askDiscard: false }` only when nothing is lost (re-pointing at the record just saved). |
|
|
1568
1569
|
| `useTheme()` | `{ theme, resolved }` — current theme + system-resolved value. |
|
|
1569
1570
|
| `useAppUpdate({ currentVersion, versionUrl?, pollMs? })` | The deployed version once it differs from the running one, else `null` — what `AppUpdateBanner` draws by, for a host that wants its own notice. Polling stops once an update is known. |
|
|
1570
1571
|
| `useNewHotkey(handler)` | Cmd/Ctrl+N — for "create new entity" buttons. |
|
|
@@ -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-VQUMEECM.js";import{WindowTitle as r}from"./chunk-3WUR24KP.js";import"./chunk-TPDOOCFS.js";import"./chunk-AW7TOB6N.js";import"./chunk-KNUR2UEG.js";import"./chunk-JDCM2VHG.js";import"./chunk-LR2X6MKB.js";import"./chunk-5A7MWTXX.js";import"./chunk-Y53KNQKL.js";import"./chunk-JF45HC5H.js";import"./chunk-5GHLKEJQ.js";import{confirm as n}from"./chunk-LT2MMSHH.js";import"./chunk-ARC3R4I2.js";import"./chunk-VWGWZY7A.js";import"./chunk-PKXQDCNR.js";import"./chunk-KC3EX26K.js";import"./chunk-7IF3RZF3.js";import"./chunk-GZCAFWWB.js";import"./chunk-UGTRSRIW.js";import"./chunk-QR4RM7PO.js";import"./chunk-BOGBLZKS.js";import"./chunk-CDAJKLGL.js";import"./chunk-QMQVOUIV.js";import"./chunk-YHYL2WSG.js";import"./chunk-FSP63GKK.js";import"./chunk-K7U4RWXJ.js";import"./chunk-ABJ4LWOW.js";import{Icon as a}from"./chunk-VJPJNCB4.js";import"./chunk-J75ZT2JQ.js";import"./chunk-Q5MD3VY6.js";import"./chunk-MRJKZWWV.js";import"./chunk-Z3WKHMVB.js";import"./chunk-PGN5ME7B.js";import"./chunk-62LW225J.js";import"./chunk-T53TXXOC.js";import"./chunk-D65T4H6J.js";import"./chunk-DTJRIWFR.js";import"./chunk-TWVUQUUD.js";import"./chunk-OVNRVFWS.js";import"./chunk-C3QOHMR6.js";import{useRef as s,useEffect as i,useState as l}from"react";import{jsxs as c,jsx as m,Fragment as u}from"react/jsx-runtime";var d="react-os-shell:browser-bookmarks",h="react-os-shell:browser-homepage",p="https://en.wikipedia.org/wiki/Main_Page",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 k(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 f=["duckduckgo.com","developer.mozilla.org","google.com","gmail.com","youtube.com","facebook.com","instagram.com","whatsapp.com","twitter.com","x.com","github.com","gitlab.com","linkedin.com","reddit.com","pinterest.com","amazon.com","amazon.ca","amazon.co.uk","apple.com","icloud.com","microsoft.com","outlook.com","live.com","office.com","netflix.com","spotify.com","paypal.com","stripe.com","chat.openai.com","chatgpt.com","claude.ai"];function x(){if("undefined"==typeof window)return g;try{const e=localStorage.getItem(d);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 u=s(void 0);void 0===u.current&&(u.current=e()),i(()=>{null!=u.current&&t(u.current)},[]);const p=u.current?k(u.current.url):"",[g,b]=l(w),[f,y]=l(p||g),[j,C]=l(f),[W,R]=l([f]),[z,L]=l(0),[S,K]=l(0),[M,H]=l(x),[T,E]=l(!1),[J,O]=l(null),U=s(null),D=s(null);i(()=>{try{localStorage.setItem(d,JSON.stringify(M))}catch{}},[M]);const G=e=>{const t=k(e);t&&(y(t),C(t),R(e=>{const o=e.slice(0,z+1);return o.push(t),o}),L(e=>e+1),E(!1))},B=()=>{"undefined"!=typeof window&&window.open(f,"_blank","noopener,noreferrer")},F=()=>{const e=J?.trim();e?(H(t=>[...t,{label:e,url:f}]),O(null)):O(null)};i(()=>{if(null===J)return;U.current?.focus(),U.current?.select();const e=e=>{const t=e.target;t?.closest("[data-bookmark-popover]")||O(null)},t=setTimeout(()=>document.addEventListener("mousedown",e),0);return()=>{clearTimeout(t),document.removeEventListener("mousedown",e)}},[null!==J]);const P=e=>{H(t=>t.filter((t,o)=>o!==e))},Q=z>0,V=z<W.length-1,I=M.some(e=>e.url===f),A="p-2 rounded hover:bg-gray-200 transition-colors text-gray-600 disabled:opacity-30";/* @__PURE__ */
|
|
2
2
|
return c("div",{className:"relative flex flex-col h-full bg-white",children:[
|
|
3
3
|
/* @__PURE__ */m(r,{title:`Browser - ${v(f)}`}),
|
|
4
4
|
/* @__PURE__ */m(o,{app:"browser"}),
|
|
5
5
|
/* @__PURE__ */c("div",{className:"flex items-center gap-1 px-2 py-2 border-b border-gray-200 bg-gray-50 shrink-0",children:[
|
|
6
|
-
/* @__PURE__ */m("button",{onClick:()=>{if(z>0){const e=z-1;L(e),y(W[e]),C(W[e]),
|
|
7
|
-
/* @__PURE__ */m("button",{onClick:()=>{if(z<W.length-1){const e=z+1;L(e),y(W[e]),C(W[e]),
|
|
8
|
-
/* @__PURE__ */m("button",{onClick:()=>
|
|
9
|
-
/* @__PURE__ */m("button",{onClick:()=>
|
|
10
|
-
/* @__PURE__ */m("form",{onSubmit:e=>{e.preventDefault(),
|
|
6
|
+
/* @__PURE__ */m("button",{onClick:()=>{if(z>0){const e=z-1;L(e),y(W[e]),C(W[e]),E(!1)}},disabled:!Q,className:A,title:"Back",children:/* @__PURE__ */m(a,{name:"chevron-left",className:"h-4 w-4",strokeWidth:2})}),
|
|
7
|
+
/* @__PURE__ */m("button",{onClick:()=>{if(z<W.length-1){const e=z+1;L(e),y(W[e]),C(W[e]),E(!1)}},disabled:!V,className:A,title:"Forward",children:/* @__PURE__ */m(a,{name:"chevron-right",className:"h-4 w-4",strokeWidth:2})}),
|
|
8
|
+
/* @__PURE__ */m("button",{onClick:()=>K(e=>e+1),className:A,title:"Refresh",children:/* @__PURE__ */m(a,{name:"refresh",className:"h-4 w-4",strokeWidth:1.8})}),
|
|
9
|
+
/* @__PURE__ */m("button",{onClick:()=>G(g),className:A,title:"Home",children:/* @__PURE__ */m(a,{name:"home",className:"h-4 w-4",strokeWidth:1.8})}),
|
|
10
|
+
/* @__PURE__ */m("form",{onSubmit:e=>{e.preventDefault(),G(j)},className:"flex-1 flex items-center mx-1",children:/* @__PURE__ */c("div",{className:"flex items-center w-full bg-white border border-gray-300 rounded focus-within:border-blue-400 focus-within:ring-1 focus-within:ring-blue-200",children:[
|
|
11
11
|
/* @__PURE__ */m("span",{className:"px-2 text-gray-400 text-xs",children:f.startsWith("https://")?"🔒":"⚠️"}),
|
|
12
12
|
/* @__PURE__ */m("input",{type:"text",value:j,onChange:e=>C(e.target.value),onFocus:e=>e.target.select(),className:"flex-1 px-1 py-1 text-sm bg-transparent outline-none font-mono",spellCheck:!1,placeholder:"Enter URL or search…"}),f!==j&&/* @__PURE__ */m("button",{type:"button",onClick:()=>C(f),className:"px-2 text-2xs text-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:()=>I?P(M.findIndex(e=>e.url===f)):void O(v(f)),className:A+" "+(I?"text-yellow-500":""),title:I?"Remove bookmark":"Add bookmark",children:/* @__PURE__ */m(a,{name:"star",className:"h-4 w-4",fill:I?"currentColor":"none",strokeWidth:1.5})}),
|
|
14
|
+
/* @__PURE__ */m("button",{onClick:B,className:A,title:"Open in new tab",children:/* @__PURE__ */m(a,{name:"external",className:"h-4 w-4",strokeWidth:1.5})}),
|
|
15
|
+
/* @__PURE__ */m("button",{onClick:()=>E(e=>!e),className:A,title:"Embedding help",children:/* @__PURE__ */m(a,{name:"help",className:"h-4 w-4",strokeWidth:1.5})})]}),null!==J&&/* @__PURE__ */c("div",{"data-bookmark-popover":!0,className:"absolute right-3 top-12 z-30 w-72 bg-white border border-gray-200 rounded-md shadow-lg p-3",children:[
|
|
16
16
|
/* @__PURE__ */m("div",{className:"text-2xs font-semibold uppercase tracking-wide text-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:f,children:f}),
|
|
18
|
-
/* @__PURE__ */m("input",{ref:
|
|
18
|
+
/* @__PURE__ */m("input",{ref:U,type:"text",value:J,onChange:e=>O(e.target.value),onKeyDown:e=>{"Enter"===e.key?F():"Escape"===e.key&&O(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:
|
|
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:()=>O(null),className:"px-2 py-1 text-xs text-gray-600 hover:bg-gray-100 rounded",children:"Cancel"}),
|
|
21
|
+
/* @__PURE__ */m("button",{onClick:F,disabled:!J.trim(),className:"px-2 py-1 text-xs bg-blue-500 text-white rounded hover:bg-blue-600 disabled:opacity-40",children:"Save"})]})]}),
|
|
22
|
+
/* @__PURE__ */c("div",{className:"flex items-center gap-0.5 px-2 py-1 border-b border-gray-200 bg-white shrink-0 overflow-x-auto",children:[0===M.length&&/* @__PURE__ */m("span",{className:"text-2xs text-gray-400 italic px-2",children:"No bookmarks yet — star the address bar to add one."}),M.map((e,t)=>/* @__PURE__ */c("button",{onClick:()=>G(e.url),onContextMenu:async o=>{o.preventDefault();await n({title:"Remove bookmark",message:`"${e.label}" will be removed from your bookmarks.`,confirmLabel:"Remove",variant:"danger"})&&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(f);try{localStorage.setItem(h,f)}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:f,iframeKey:
|
|
26
|
+
/* @__PURE__ */m("div",{className:"flex-1 relative min-h-0 bg-gray-50",children:/* @__PURE__ */m(N,{url:f,iframeKey:S,iframeRef:D,openExternal:B,showHelp:T,dismissHelp:()=>E(!1)})})]})}function v(e){try{return new URL(e).hostname.replace(/^www\./,"")}catch{return e}}function N({url:e,iframeKey:t,iframeRef:o,openExternal:r,showHelp:n,dismissHelp:s}){const[d,h]=l(!1);i(()=>{h(!1)},[e]);return function(e){try{const t=new URL(e).hostname.toLowerCase();return f.some(e=>t===e||t.endsWith("."+e))}catch{return!1}}(e)&&!d?/* @__PURE__ */m("div",{className:"absolute inset-0 flex items-center justify-center bg-white p-8",children:/* @__PURE__ */c("div",{className:"max-w-md text-center",children:[
|
|
27
27
|
/* @__PURE__ */m(a,{name:"no-symbol",className:"h-14 w-14 mx-auto text-gray-300 mb-3",strokeWidth:1.2}),
|
|
28
28
|
/* @__PURE__ */c("h3",{className:"text-base font-semibold text-gray-800 mb-1",children:[v(e)," can't be embedded"]}),
|
|
29
29
|
/* @__PURE__ */c("p",{className:"text-sm text-gray-500 mb-4",children:["This site sends an ",
|
|
@@ -1,29 +1,29 @@
|
|
|
1
|
-
import{loadAppearance as e,WidgetSettingsModal as t}from"./chunk-
|
|
1
|
+
import{loadAppearance as e,WidgetSettingsModal as t}from"./chunk-XNIMCECI.js";import{useWidgetSettings as n}from"./chunk-3WUR24KP.js";import"./chunk-TPDOOCFS.js";import"./chunk-AW7TOB6N.js";import"./chunk-KNUR2UEG.js";import"./chunk-JDCM2VHG.js";import"./chunk-LR2X6MKB.js";import"./chunk-5A7MWTXX.js";import"./chunk-Y53KNQKL.js";import"./chunk-JF45HC5H.js";import"./chunk-5GHLKEJQ.js";import"./chunk-LT2MMSHH.js";import"./chunk-ARC3R4I2.js";import"./chunk-VWGWZY7A.js";import"./chunk-PKXQDCNR.js";import"./chunk-KC3EX26K.js";import"./chunk-7IF3RZF3.js";import"./chunk-GZCAFWWB.js";import"./chunk-UGTRSRIW.js";import"./chunk-QR4RM7PO.js";import"./chunk-BOGBLZKS.js";import"./chunk-CDAJKLGL.js";import"./chunk-QMQVOUIV.js";import"./chunk-FSP63GKK.js";import"./chunk-K7U4RWXJ.js";import"./chunk-ABJ4LWOW.js";import{Icon as r}from"./chunk-VJPJNCB4.js";import"./chunk-J75ZT2JQ.js";import"./chunk-Q5MD3VY6.js";import"./chunk-MRJKZWWV.js";import"./chunk-Z3WKHMVB.js";import"./chunk-PGN5ME7B.js";import"./chunk-62LW225J.js";import"./chunk-T53TXXOC.js";import"./chunk-D65T4H6J.js";import"./chunk-DTJRIWFR.js";import"./chunk-TWVUQUUD.js";import"./chunk-OVNRVFWS.js";import"./chunk-C3QOHMR6.js";import{useState as c,useRef as i,useCallback as l,useEffect as o}from"react";import{jsxs as s,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),[N,j]=c(!1),[y,C]=c(""),[x,f]=c([]),[v,$]=c(!1),[W,R]=c(()=>e(h)),[T,K]=c(!1),[E,J]=c(W),w=i(null);n(l(()=>{J({...W}),K(!0)},[W]));const M=l(e=>{C(""),k(t=>N||"0"===t?(j(!1),"."===e?"0.":e):"."===e&&t.includes(".")?t:t+e)},[N]),S=l(()=>{k("0"),d(null),g(null),j(!1)},[]),F=l((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}},[]),B=l(e=>{const t=parseFloat(m);if(null!==p&&b&&!N){const e=F(p,t,b);k(String(e)),d(e),f(n=>[`${p} ${b} ${t} = ${e}`,...n].slice(0,20))}else d(t);g(e),j(!0)},[m,p,b,N,F]),L=l(()=>{if(null===p||!b)return;const e=parseFloat(m),t=F(p,e,b),n=`${p} ${b} ${e} =`;f(e=>[`${n} ${t}`,...e].slice(0,20)),C(n),k(String(t)),d(null),g(null),j(!0)},[m,p,b,F]),O=l(()=>{k(e=>String(parseFloat(e)/100))},[]),A=l(()=>{k(e=>e.startsWith("-")?e.slice(1):"0"===e?e:"-"+e)},[]);o(()=>{const e=e=>{const t=e.target.tagName;"INPUT"!==t&&"TEXTAREA"!==t&&"SELECT"!==t&&(e.key>="0"&&e.key<="9"?M(e.key):"."===e.key?M("."):"+"===e.key?B("+"):"-"===e.key?B("-"):"*"===e.key?B("×"):"/"===e.key?(e.preventDefault(),B("÷")):"Enter"===e.key||"="===e.key?("Enter"===e.key&&e.target instanceof Node&&w.current?.contains(e.target)&&e.preventDefault(),L()):"Escape"===e.key?S():"Backspace"===e.key?k(e=>e.length>1?e.slice(0,-1):"0"):"%"===e.key&&O())};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[M,B,L,S,O]);const V="flex items-center justify-center rounded-lg text-sm font-medium transition-colors",D=`${V} bg-white border border-gray-200 text-gray-900 hover:bg-gray-50 active:bg-gray-100`,G=`${V} bg-blue-50 border border-blue-200 text-blue-700 hover:bg-blue-100 active:bg-blue-200`,Q=`${V} bg-gray-100 border border-gray-200 text-gray-600 hover:bg-gray-200 active:bg-gray-300`,U=`${V} bg-blue-600 text-white hover:bg-blue-700 active:bg-blue-800`;/* @__PURE__ */
|
|
2
2
|
return s(a,{children:[
|
|
3
3
|
/* @__PURE__ */s("div",{ref:w,className:"flex flex-col h-full",style:{opacity:W.activeOpacity/100,backdropFilter:W.activeBlur>0?`blur(${W.activeBlur}px)`:void 0},children:[
|
|
4
4
|
/* @__PURE__ */s("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:
|
|
5
|
+
/* @__PURE__ */u("div",{className:"flex flex-col justify-end flex-1 overflow-hidden",children:x.slice(0,3).reverse().map((e,t)=>/* @__PURE__ */u("div",{className:"text-2xs text-slate-400 text-right font-mono truncate",children:e},t))}),(y||b&&null!==p)&&/* @__PURE__ */u("div",{className:"text-base text-slate-600 text-right font-mono",children:y||`${p} ${b} ${N?"":m}`}),
|
|
6
6
|
/* @__PURE__ */s("div",{className:"flex items-center gap-2",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,v?{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__ */s("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:S,className:Q,children:"AC"}),
|
|
11
|
+
/* @__PURE__ */u("button",{onClick:A,className:Q,children:"+/−"}),
|
|
12
|
+
/* @__PURE__ */u("button",{onClick:O,className:Q,children:"%"}),
|
|
13
|
+
/* @__PURE__ */u("button",{onClick:()=>B("÷"),className:`${G} ${"÷"===b?"ring-2 ring-blue-400":""}`,children:"÷"}),
|
|
14
|
+
/* @__PURE__ */u("button",{onClick:()=>M("7"),className:D,children:"7"}),
|
|
15
|
+
/* @__PURE__ */u("button",{onClick:()=>M("8"),className:D,children:"8"}),
|
|
16
|
+
/* @__PURE__ */u("button",{onClick:()=>M("9"),className:D,children:"9"}),
|
|
17
|
+
/* @__PURE__ */u("button",{onClick:()=>B("×"),className:`${G} ${"×"===b?"ring-2 ring-blue-400":""}`,children:"×"}),
|
|
18
|
+
/* @__PURE__ */u("button",{onClick:()=>M("4"),className:D,children:"4"}),
|
|
19
|
+
/* @__PURE__ */u("button",{onClick:()=>M("5"),className:D,children:"5"}),
|
|
20
|
+
/* @__PURE__ */u("button",{onClick:()=>M("6"),className:D,children:"6"}),
|
|
21
|
+
/* @__PURE__ */u("button",{onClick:()=>B("-"),className:`${G} ${"-"===b?"ring-2 ring-blue-400":""}`,children:"−"}),
|
|
22
|
+
/* @__PURE__ */u("button",{onClick:()=>M("1"),className:D,children:"1"}),
|
|
23
|
+
/* @__PURE__ */u("button",{onClick:()=>M("2"),className:D,children:"2"}),
|
|
24
|
+
/* @__PURE__ */u("button",{onClick:()=>M("3"),className:D,children:"3"}),
|
|
25
|
+
/* @__PURE__ */u("button",{onClick:()=>B("+"),className:`${G} ${"+"===b?"ring-2 ring-blue-400":""}`,children:"+"}),
|
|
26
|
+
/* @__PURE__ */u("button",{onClick:()=>M("0"),className:`${D} col-span-2`,children:"0"}),
|
|
27
|
+
/* @__PURE__ */u("button",{onClick:()=>M("."),className:D,children:"."}),
|
|
28
|
+
/* @__PURE__ */u("button",{onClick:L,className:U,children:"="})]})]}),
|
|
29
|
+
/* @__PURE__ */u(t,{open:T,onClose:()=>K(!1),title:"Calculator Settings",appearance:E,onAppearanceChange:J,onSave:()=>{R(E),localStorage.setItem(h,JSON.stringify(E)),K(!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-XNIMCECI.js";import{useWidgetSettings as r}from"./chunk-3WUR24KP.js";import"./chunk-TPDOOCFS.js";import"./chunk-AW7TOB6N.js";import"./chunk-KNUR2UEG.js";import"./chunk-JDCM2VHG.js";import"./chunk-LR2X6MKB.js";import"./chunk-5A7MWTXX.js";import"./chunk-Y53KNQKL.js";import"./chunk-JF45HC5H.js";import"./chunk-5GHLKEJQ.js";import"./chunk-LT2MMSHH.js";import"./chunk-ARC3R4I2.js";import"./chunk-VWGWZY7A.js";import"./chunk-PKXQDCNR.js";import"./chunk-KC3EX26K.js";import"./chunk-7IF3RZF3.js";import"./chunk-GZCAFWWB.js";import"./chunk-UGTRSRIW.js";import"./chunk-QR4RM7PO.js";import"./chunk-BOGBLZKS.js";import"./chunk-CDAJKLGL.js";import"./chunk-QMQVOUIV.js";import"./chunk-FSP63GKK.js";import"./chunk-K7U4RWXJ.js";import"./chunk-ABJ4LWOW.js";import"./chunk-VJPJNCB4.js";import"./chunk-J75ZT2JQ.js";import{LoadingSpinner as n}from"./chunk-Q5MD3VY6.js";import"./chunk-MRJKZWWV.js";import"./chunk-Z3WKHMVB.js";import"./chunk-PGN5ME7B.js";import"./chunk-62LW225J.js";import"./chunk-T53TXXOC.js";import"./chunk-D65T4H6J.js";import"./chunk-DTJRIWFR.js";import"./chunk-TWVUQUUD.js";import"./chunk-OVNRVFWS.js";import"./chunk-C3QOHMR6.js";import{useState as s,useCallback as a,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",h="currency_appearance",d="currency_rates_cache";function g(t){try{const e=JSON.parse(localStorage.getItem(d)||"{}")[t];if(e&&Date.now()-e.timestamp<36e5)return e.rates}catch{}return null}function k(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 N(){try{const t=JSON.parse(localStorage.getItem(p)||"");if(Array.isArray(t)&&t.length)return t.slice(0,4)}catch{}return u}var f={USD:"🇺🇸",CNY:"🇨🇳",AUD:"🇦🇺",GBP:"🇬🇧",JPY:"🇯🇵",CAD:"🇨🇦",EUR:"🇪🇺",THB:"🇹🇭",NZD:"🇳🇿",SGD:"🇸🇬",HKD:"🇭🇰",CHF:"🇨🇭",KRW:"🇰🇷",INR:"🇮🇳",MXN:"🇲🇽",BRL:"🇧🇷"};function j(){const[u,d]=s(N),[j,y]=s(()=>t(h)),[x,b]=s({}),[S,C]=s(!1),[D,v]=s(!1),[R,J]=s([]),[U,W]=s(j),[K,B]=s("USD"),[O,M]=s("CNY");r(a(()=>{J([...u]),W({...j}),v(!0)},[u,j])),o(()=>{const t=[...new Set(u.map(([t])=>t))];let e=!0;return async function(){C(!0);const r={};for(const e of t){const t=g(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,k(e,n.rates))}catch{}}e&&(b(r),C(!1))}(),()=>{e=!1}},[u]);/* @__PURE__ */
|
|
2
2
|
return c(i,{children:[
|
|
3
3
|
/* @__PURE__ */l("div",{style:{backgroundColor:`rgb(var(--taskbar-bg-rgb, 243 244 246) / ${j.activeOpacity/100})`,backdropFilter:j.activeBlur>0?`blur(${j.activeBlur}px)`:void 0},children:/* @__PURE__ */c("div",{className:"px-4 py-3 space-y-1",children:[S&&/* @__PURE__ */l(n,{size:"sm",padding:"py-4",label:"Loading rates"}),u.map(([t,e],r)=>{const n=x[t]?.[e];/* @__PURE__ */
|
|
4
4
|
return c("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 c("button",{onClick:()=>{const t=u.map((t,e)=>e===r?[t[1],t[0]]:t);d(t),l
|
|
|
9
9
|
/* @__PURE__ */l("span",{className:"text-base",children:f[e]||""}),
|
|
10
10
|
/* @__PURE__ */l("span",{className:"text-sm font-semibold text-gray-700",children:e})]}),
|
|
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}):"—"})]},`${t}-${e}-${r}`)})]})}),
|
|
12
|
-
/* @__PURE__ */l(e,{open:
|
|
12
|
+
/* @__PURE__ */l(e,{open:D,onClose:()=>v(!1),title:"Currency Settings",appearance:U,onAppearanceChange:W,onSave:()=>{if(0===R.length)return;const t=R.slice(0,4);d(t),y(U),localStorage.setItem(p,JSON.stringify(t)),localStorage.setItem(h,JSON.stringify(U)),v(!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
|
-
/* @__PURE__ */c("span",{className:"text-2xs font-normal text-gray-400",children:["(",
|
|
15
|
-
/* @__PURE__ */l("div",{className:"space-y-1 mb-2",children:
|
|
14
|
+
/* @__PURE__ */c("span",{className:"text-2xs font-normal text-gray-400",children:["(",R.length,"/",4,")"]})]}),
|
|
15
|
+
/* @__PURE__ */l("div",{className:"space-y-1 mb-2",children:R.map(([t,e],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:[f[t]||""," ",t," → ",f[e]||""," ",e]}),
|
|
17
|
-
/* @__PURE__ */l("button",{onClick:()=>
|
|
18
|
-
/* @__PURE__ */l("select",{value:K,onChange:t=>
|
|
17
|
+
/* @__PURE__ */l("button",{onClick:()=>J(t=>t.filter((t,e)=>e!==r)),className:"text-red-400 hover:text-red-600",children:"×"})]},r))}),R.length<4?/* @__PURE__ */c("div",{className:"flex items-center gap-2",children:[
|
|
18
|
+
/* @__PURE__ */l("select",{value:K,onChange:t=>B(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:m.map(t=>/* @__PURE__ */l("option",{children:t},t))}),
|
|
19
19
|
/* @__PURE__ */l("span",{className:"text-gray-400",children:"→"}),
|
|
20
|
-
/* @__PURE__ */l("select",{value:
|
|
21
|
-
/* @__PURE__ */l("button",{onClick:()=>{K!==
|
|
20
|
+
/* @__PURE__ */l("select",{value:O,onChange:t=>M(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:m.map(t=>/* @__PURE__ */l("option",{children:t},t))}),
|
|
21
|
+
/* @__PURE__ */l("button",{onClick:()=>{K!==O&&R.length<4&&J(t=>[...t,[K,O]])},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{j as default};
|
|
@@ -1,12 +1,12 @@
|
|
|
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-VQUMEECM.js";import{WindowTitle as n}from"./chunk-3WUR24KP.js";import"./chunk-TPDOOCFS.js";import"./chunk-AW7TOB6N.js";import"./chunk-KNUR2UEG.js";import"./chunk-JDCM2VHG.js";import"./chunk-LR2X6MKB.js";import"./chunk-5A7MWTXX.js";import"./chunk-Y53KNQKL.js";import"./chunk-JF45HC5H.js";import"./chunk-5GHLKEJQ.js";import"./chunk-LT2MMSHH.js";import"./chunk-ARC3R4I2.js";import"./chunk-VWGWZY7A.js";import"./chunk-PKXQDCNR.js";import"./chunk-KC3EX26K.js";import{toast_default as r}from"./chunk-2LKH6JM5.js";import{PopupMenu as o,PopupMenuLabel as i,PopupMenuItem as l,PopupMenuDivider as a}from"./chunk-7IF3RZF3.js";import"./chunk-GZCAFWWB.js";import"./chunk-UGTRSRIW.js";import"./chunk-QR4RM7PO.js";import"./chunk-BOGBLZKS.js";import"./chunk-CDAJKLGL.js";import"./chunk-QMQVOUIV.js";import"./chunk-YHYL2WSG.js";import"./chunk-FSP63GKK.js";import"./chunk-K7U4RWXJ.js";import"./chunk-ABJ4LWOW.js";import{Icon as s}from"./chunk-VJPJNCB4.js";import"./chunk-J75ZT2JQ.js";import{LoadingSpinner as c}from"./chunk-Q5MD3VY6.js";import"./chunk-MRJKZWWV.js";import"./chunk-Z3WKHMVB.js";import"./chunk-PGN5ME7B.js";import"./chunk-62LW225J.js";import"./chunk-T53TXXOC.js";import"./chunk-D65T4H6J.js";import"./chunk-DTJRIWFR.js";import"./chunk-TWVUQUUD.js";import"./chunk-OVNRVFWS.js";import"./chunk-C3QOHMR6.js";import{useState as m,useRef as d}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]=m(x),[k,v]=m(!1),[b,w]=m(!1),[j,C]=m(!1),[N,D]=m(null),M=d(null),L=d(null),R=d(null),W=(e,t)=>{R.current?.focus(),document.execCommand(e,!1,t),C(!0)},U=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)),C(!0)},e.readAsDataURL(t)}},B=e=>{N&&(N.el.removeAttribute("width"),N.el.removeAttribute("height"),N.el.style.width=e??"",N.el.style.height=e?"auto":"",C(!0),D(null))},T=async t=>{const n=(t.name.split(".").pop()||"").toLowerCase();v(!0);try{if(p.has(n)||!g.has(n)&&t.type.startsWith("text/")){const r=await t.text(),o=e(r).replace(/\n/g,"<br>");y({filename:t.name,kind:"text",content:o,ext:n}),C(!1)}else if(g.has(n))try{const e=await(import(
|
|
2
2
|
/* @vite-ignore */
|
|
3
|
-
"mammoth")),r=await t.arrayBuffer(),o=await e.convertToHtml({arrayBuffer:r});y({filename:t.name,kind:"docx",content:o.value||"<p><em>(empty document)</em></p>",ext:n}),
|
|
4
|
-
return h("div",{className:"relative flex flex-col h-full",onDragOver:e=>{e.preventDefault(),b||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/"))?U(t):
|
|
5
|
-
/* @__PURE__ */u(n,{title:`${
|
|
3
|
+
"mammoth")),r=await t.arrayBuffer(),o=await e.convertToHtml({arrayBuffer:r});y({filename:t.name,kind:"docx",content:o.value||"<p><em>(empty document)</em></p>",ext:n}),C(!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?(S=f.filename).length>24?`${S.slice(0,23)}…`:S:"Untitled";var S;/* @__PURE__ */
|
|
4
|
+
return h("div",{className:"relative flex flex-col h-full",onDragOver:e=>{e.preventDefault(),b||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/"))?U(t):T(t[0]))},children:[
|
|
5
|
+
/* @__PURE__ */u(n,{title:`${O}${j?" •":""} - 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:
|
|
9
|
-
/* @__PURE__ */h("button",{onClick:()=>
|
|
8
|
+
/* @__PURE__ */u("input",{ref:M,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&&T(t),M.current&&(M.current.value="")},className:"hidden"}),
|
|
9
|
+
/* @__PURE__ */h("button",{onClick:()=>M.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__ */u(s,{name:"folder-open",className:"h-3.5 w-3.5",strokeWidth:1.5}),"Open"]}),
|
|
11
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"}),
|
|
@@ -38,15 +38,15 @@ return h("div",{className:"relative flex flex-col h-full",onDragOver:e=>{e.preve
|
|
|
38
38
|
/* @__PURE__ */u("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__ */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
39
|
/* @__PURE__ */u("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__ */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
|
-
/* @__PURE__ */u("input",{ref:
|
|
42
|
-
/* @__PURE__ */h("button",{onClick:()=>
|
|
41
|
+
/* @__PURE__ */u("input",{ref:L,type:"file",accept:"image/*",multiple:!0,className:"hidden",onChange:e=>{e.target.files?.length&&U(Array.from(e.target.files)),L.current&&(L.current.value="")}}),
|
|
42
|
+
/* @__PURE__ */h("button",{onClick:()=>L.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__ */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:k?/* @__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:()=>
|
|
44
|
+
/* @__PURE__ */u("div",{className:"flex-1 min-h-0 overflow-hidden",children:k?/* @__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:()=>C(!0),onPaste:e=>{const t=Array.from(e.clipboardData?.items??[]).filter(e=>"file"===e.kind&&e.type.startsWith("image/")).map(e=>e.getAsFile()).filter(e=>!!e);t.length&&(e.preventDefault(),U(t))},onClick:e=>{const t=e.target;"IMG"===t.tagName&&(e.preventDefault(),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"})})}),b&&/* @__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"})}),N&&/* @__PURE__ */h(o,{minWidth:150,style:{left:N.x,top:N.y},onClose:()=>D(null),children:[
|
|
45
45
|
/* @__PURE__ */u(i,{children:"Image width"}),
|
|
46
|
-
/* @__PURE__ */u(l,{onClick:()=>
|
|
47
|
-
/* @__PURE__ */u(l,{onClick:()=>
|
|
48
|
-
/* @__PURE__ */u(l,{onClick:()=>
|
|
49
|
-
/* @__PURE__ */u(l,{onClick:()=>
|
|
50
|
-
/* @__PURE__ */u(l,{onClick:()=>
|
|
46
|
+
/* @__PURE__ */u(l,{onClick:()=>B("25%"),children:"25%"}),
|
|
47
|
+
/* @__PURE__ */u(l,{onClick:()=>B("50%"),children:"50%"}),
|
|
48
|
+
/* @__PURE__ */u(l,{onClick:()=>B("75%"),children:"75%"}),
|
|
49
|
+
/* @__PURE__ */u(l,{onClick:()=>B("100%"),children:"100%"}),
|
|
50
|
+
/* @__PURE__ */u(l,{onClick:()=>B(null),children:"Original size"}),
|
|
51
51
|
/* @__PURE__ */u(a,{}),
|
|
52
|
-
/* @__PURE__ */u(l,{danger:!0,onClick:()=>{
|
|
52
|
+
/* @__PURE__ */u(l,{danger:!0,onClick:()=>{N?.el.remove(),C(!0),D(null)},children:"Remove image"})]})]})}export{f as default};
|