efficient-shell 13.19.0 → 13.21.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 +40 -1
- package/dist/{Browser-ZTKWHNYX.js → Browser-AE7OYSTS.js} +12 -12
- package/dist/Calculator-QEQU3W2L.js +29 -0
- package/dist/CurrencyConverter-L22FF4ST.js +21 -0
- package/dist/{Files-R2IVXZJJ.js → Files-Y5UGT3RX.js} +80 -80
- package/dist/Notepad-YZOEXYE3.js +24 -0
- package/dist/{PomodoroTimer-JVCYYGRD.js → PomodoroTimer-6XHLOAJD.js} +21 -21
- package/dist/{Preview-STATKTFB.js → Preview-XQXSRAGY.js} +16 -16
- package/dist/{Stock-S266KGAF.js → Stock-36O4LW46.js} +4 -4
- package/dist/{Weather-TE4TTTQA.js → Weather-BN6AJJ4S.js} +21 -21
- package/dist/{WorldClock-5TPBHBYA.js → WorldClock-TUVIRPTM.js} +6 -6
- package/dist/ai/index.js +8 -8
- package/dist/apps/index.d.ts +1 -1
- package/dist/apps/index.js +1 -1
- package/dist/bin/browser-check.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-2TXQCA4C.js +15 -0
- package/dist/{chunk-34HRPEQD.js → chunk-ABTVRB23.js} +1 -1
- package/dist/{chunk-GEQZUCEO.js → chunk-BVX7LUAW.js} +6 -6
- package/dist/chunk-D4WO73XD.js +91 -0
- package/dist/{chunk-LUCO5PS6.js → chunk-F3E3CEZM.js} +1 -1
- package/dist/{chunk-46A3BMJB.js → chunk-H75CQD46.js} +1 -1
- package/dist/{chunk-QTDR2CTB.js → chunk-IUQJGFEO.js} +3 -3
- package/dist/{chunk-4SYPNE3P.js → chunk-J4CVYOY3.js} +1 -1
- package/dist/chunk-LZOKBMAF.js +1 -0
- package/dist/{chunk-QSJMLHBD.js → chunk-MUNP5Z24.js} +1 -1
- package/dist/{chunk-ENVANMHI.js → chunk-SHHRC5XK.js} +7 -7
- package/dist/{chunk-IQPYTW2O.js → chunk-SOXZRLSD.js} +2 -2
- package/dist/{chunk-EHM3ZVVT.js → chunk-UC5IC3AM.js} +4 -4
- package/dist/{chunk-TKCCJRPE.js → chunk-VRJKV44O.js} +1 -1
- package/dist/{chunk-S7YUQLBN.js → chunk-XXTAMF3O.js} +6 -6
- package/dist/chunk-YI4T5I5D.js +1 -0
- package/dist/data/EntityList.js +1 -1
- package/dist/data/ResizableTable.js +1 -1
- package/dist/forms/BrandAssetEditor.js +1 -1
- package/dist/forms/MediaLibrary.js +1 -1
- package/dist/forms/MediaUploadField.js +1 -1
- package/dist/icons/index.js +1 -1
- package/dist/index.d.ts +4 -3
- package/dist/index.js +662 -665
- package/dist/shell/LanguageSelect.js +1 -1
- package/dist/shell/SettingRow.js +1 -1
- package/dist/shell/SidebarLayout.d.ts +5 -2
- package/dist/shell/SidebarLayout.js +1 -1
- package/dist/telemetry/index.js +1 -1
- package/dist/templates/ChatTemplate.js +1 -1
- package/dist/templates/EmailTemplate.js +1 -1
- package/dist/{types-ClT92-8Z.d.ts → types-DWIjEVSy.d.ts} +5 -5
- package/dist/ui/index.js +1 -1
- package/dist/ui.css +11 -0
- package/dist/version.js +1 -1
- package/package.json +1 -1
- package/dist/Calculator-4UBMDAJO.js +0 -29
- package/dist/CurrencyConverter-H3HHXXKT.js +0 -21
- package/dist/Notepad-Z2XMVRSD.js +0 -24
- package/dist/chunk-HNMWF6OG.js +0 -1
- package/dist/chunk-U5RG34NE.js +0 -14
- package/dist/chunk-ZI2FDUYJ.js +0 -99
package/README.md
CHANGED
|
@@ -161,7 +161,46 @@ That gives you the full desktop with all utility, document and web apps reachabl
|
|
|
161
161
|
|
|
162
162
|
Every window the shell can open lives in a `WindowRegistry` map. Two entry shapes:
|
|
163
163
|
|
|
164
|
-
|
|
164
|
+
### Windows have no title bar
|
|
165
|
+
|
|
166
|
+
Since 2026-11-18 a desktop window draws no title bar. Its Close, Minimize and
|
|
167
|
+
Maximize buttons sit at the window's top-left as three lights (red, amber,
|
|
168
|
+
green; grey on a window that is not the active one), the way a macOS app's do.
|
|
169
|
+
Which of two shapes a window takes depends on what its body starts with:
|
|
170
|
+
|
|
171
|
+
- **A body that starts with a left `SidebarLayout`** (pair it with
|
|
172
|
+
`flushBody`): the sidebar runs to the very top of the window and leaves a
|
|
173
|
+
clear strip there, and the buttons float over it. The window draws nothing
|
|
174
|
+
else at its top: its name is kept for screen readers, and the page beside
|
|
175
|
+
the sidebar names itself in its own top row. The top strip of the whole
|
|
176
|
+
window drags it. Anything in that strip that takes a press of its own keeps
|
|
177
|
+
it: buttons, links, fields, tabs, column headers, resize grips, and any
|
|
178
|
+
element marked `data-no-window-drag`.
|
|
179
|
+
- **Any other body**: one slim row holds the buttons, then the window's name,
|
|
180
|
+
its copy icon and its badges, on the body's own surface, with no line between the row and the body.
|
|
181
|
+
|
|
182
|
+
A right-click on the buttons, the row or the sidebar's strip opens the window
|
|
183
|
+
menu (Minimize, Maximize, Pin on top, Add to desktop, the window's own items,
|
|
184
|
+
Close) that the title-bar icon used to open; the keyboard's menu key does the
|
|
185
|
+
same when the buttons have focus. The buttons are still the window's keyboard
|
|
186
|
+
handle (arrows move, Shift+arrows resize, Ctrl/Cmd+arrows snap, Enter toggles
|
|
187
|
+
maximize). The `icon` a window is given is no longer drawn inside the window;
|
|
188
|
+
the taskbar and the tab strip still draw it. A sidebar on the right, or one
|
|
189
|
+
that does not start in the body's top-left corner, does not take the buttons.
|
|
190
|
+
The Sidebar layout (tabs), widgets and phones are unchanged.
|
|
191
|
+
|
|
192
|
+
**No bottom bar either.** On the desktop a window draws no footer BAR. Its
|
|
193
|
+
buttons stay at the bottom of the window, in the order they always had
|
|
194
|
+
(Undo/Redo, `actionsLeft` and left `ModalActions` on the left; Edit or
|
|
195
|
+
Discard and the `actions` / `ModalActions` buttons on the right), but on the
|
|
196
|
+
body's own surface, with no line above them and no fill. The `footer` facts
|
|
197
|
+
are not drawn on the desktop, so nothing a user needs may live only there. A
|
|
198
|
+
window with no buttons has nothing at its bottom at all. 13.20.0 put the
|
|
199
|
+
buttons at the right of the top row; that crowded a record window's name and
|
|
200
|
+
was reverted in the next release. The Sidebar layout (tabs) and phones keep
|
|
201
|
+
the footer bar.
|
|
202
|
+
|
|
203
|
+
- **Page** — `{ component: LazyExoticComponent, label, size?, widget?, compact?, appStyle?, flushBody?, … }`. Opened via `openPage(routeKey)`. `flushBody` keeps the standard top row + footer but drops the body padding (pair it with `<SidebarLayout>` for two-pane apps).
|
|
165
204
|
- **Entity** — `{ endpoint, render(entity, …), title(entity), footer?, … }`. Opened via `openEntity(typeKey, id)`. The shell GETs `${endpoint}${id}/` (via the consumer-supplied entity fetcher) and hands the result to `render`.
|
|
166
205
|
|
|
167
206
|
#### Edit in the footer
|
|
@@ -1,30 +1,30 @@
|
|
|
1
|
-
import{InputEndActionButton as e}from"./chunk-3SIRRK3F.js";import"./chunk-EX3DARI3.js";import"./chunk-VQBKRBBR.js";import"./chunk-NWS5G7FE.js";import"./chunk-AYZY3YNC.js";import{peekBrowserStartUrl as t,claimBrowserStartUrl as o}from"./chunk-LWLCNQY7.js";import{AboutApp as r}from"./chunk-
|
|
1
|
+
import{InputEndActionButton as e}from"./chunk-3SIRRK3F.js";import"./chunk-EX3DARI3.js";import"./chunk-VQBKRBBR.js";import"./chunk-NWS5G7FE.js";import"./chunk-AYZY3YNC.js";import{peekBrowserStartUrl as t,claimBrowserStartUrl as o}from"./chunk-LWLCNQY7.js";import{AboutApp as r}from"./chunk-SOXZRLSD.js";import{WindowTitle as n}from"./chunk-D4WO73XD.js";import"./chunk-4LXCCZDM.js";import"./chunk-KNUR2UEG.js";import"./chunk-JDCM2VHG.js";import"./chunk-YI4T5I5D.js";import"./chunk-M2TQOJ3G.js";import"./chunk-FBZUEZK7.js";import"./chunk-5A7MWTXX.js";import"./chunk-BG3C4ALM.js";import{confirm as s}from"./chunk-GMLOMLCS.js";import"./chunk-UTQN5AIO.js";import"./chunk-EIFNESXS.js";import"./chunk-SXHV5OLA.js";import"./chunk-SF4IIV5Z.js";import"./chunk-FRCTA5FS.js";import"./chunk-VWGWZY7A.js";import"./chunk-UVHXVSB2.js";import"./chunk-WRV6QKJN.js";import"./chunk-AW7TOB6N.js";import"./chunk-4U5M37SF.js";import"./chunk-F3ZOO23R.js";import"./chunk-2QY5BJLA.js";import"./chunk-UGTRSRIW.js";import"./chunk-DPFEQQQU.js";import"./chunk-LZOKBMAF.js";import"./chunk-DWGYC7OD.js";import"./chunk-YDJ5IZOU.js";import"./chunk-THAPVKEJ.js";import"./chunk-URHGHXDN.js";import"./chunk-5QFPTDQF.js";import"./chunk-UTISUEO4.js";import"./chunk-BUFAJJDZ.js";import{Icon as a}from"./chunk-ISVODSRP.js";import"./chunk-J75ZT2JQ.js";import"./chunk-R2VKEMZH.js";import"./chunk-BWJZTHZ6.js";import"./chunk-TD3ZQD5R.js";import"./chunk-F2RAIGCG.js";import"./chunk-PGN5ME7B.js";import"./chunk-62LW225J.js";import"./chunk-VY3UA6AR.js";import"./chunk-WCCS4VFE.js";import"./chunk-ZDXRSY2Y.js";import"./chunk-STKJA4PV.js";import"./chunk-M6UKCZHT.js";import"./chunk-UQYNPYF4.js";import"./chunk-MRJKZWWV.js";import"./chunk-TWVUQUUD.js";import"./chunk-5FYDNH4Y.js";import"./chunk-LNXBTK7Q.js";import"./chunk-MAFUXCPZ.js";import"./chunk-IUVGHHR3.js";import"./chunk-C3QOHMR6.js";import{useRef as i,useEffect as c,useState as l}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()),c(()=>{null!=h.current&&o(h.current)},[]);const k=h.current?f(h.current.url):"",[b,g]=l(y),[w,v]=l(k||b),[C,R]=l(w),[S,W]=l([w]),[D,U]=l(0),[z,F]=l(0),[T,E]=l(x),[L,A]=l(!1),[O,H]=l(null),I=i(null),Z=i(null);c(()=>{try{localStorage.setItem(d,JSON.stringify(T))}catch{}},[T]);const M=e=>{const t=f(e);t&&(v(t),R(t),W(e=>{const o=e.slice(0,D+1);return o.push(t),o}),U(e=>e+1),A(!1))},G=()=>{"undefined"!=typeof window&&window.open(w,"_blank","noopener,noreferrer")},Q=()=>{const e=O?.trim();e?(E(t=>[...t,{label:e,url:w}]),H(null)):H(null)};c(()=>{if(null===O)return;I.current?.focus(),I.current?.select();const e=e=>{const t=e.target;t?.closest("[data-bookmark-popover]")||H(null)},t=setTimeout(()=>document.addEventListener("mousedown",e),0);return()=>{clearTimeout(t),document.removeEventListener("mousedown",e)}},[null!==O]);const V=e=>{E(t=>t.filter((t,o)=>o!==e))},B=D>0,J=D<S.length-1,Y=T.some(e=>e.url===w),K="p-2 rounded hover:bg-gray-200 transition-colors text-gray-600 disabled:opacity-30";/* @__PURE__ */
|
|
2
2
|
return m("div",{className:"relative flex flex-col h-full bg-white",children:[
|
|
3
3
|
/* @__PURE__ */u(n,{title:`Browser - ${j(w)}`}),
|
|
4
4
|
/* @__PURE__ */u(r,{app:"browser"}),
|
|
5
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(
|
|
7
|
-
/* @__PURE__ */u("button",{onClick:()=>{if(
|
|
6
|
+
/* @__PURE__ */u("button",{onClick:()=>{if(D>0){const e=D-1;U(e),v(S[e]),R(S[e]),A(!1)}},disabled:!B,className:K,title:"Back",children:/* @__PURE__ */u(a,{name:"chevron-left",className:"h-4 w-4",strokeWidth:2})}),
|
|
7
|
+
/* @__PURE__ */u("button",{onClick:()=>{if(D<S.length-1){const e=D+1;U(e),v(S[e]),R(S[e]),A(!1)}},disabled:!J,className:K,title:"Forward",children:/* @__PURE__ */u(a,{name:"chevron-right",className:"h-4 w-4",strokeWidth:2})}),
|
|
8
8
|
/* @__PURE__ */u("button",{onClick:()=>F(e=>e+1),className:K,title:"Refresh",children:/* @__PURE__ */u(a,{name:"refresh",className:"h-4 w-4",strokeWidth:1.8})}),
|
|
9
|
-
/* @__PURE__ */u("button",{onClick:()=>
|
|
10
|
-
/* @__PURE__ */u("form",{onSubmit:e=>{e.preventDefault(),
|
|
9
|
+
/* @__PURE__ */u("button",{onClick:()=>M(b),className:K,title:"Home",children:/* @__PURE__ */u(a,{name:"home",className:"h-4 w-4",strokeWidth:1.8})}),
|
|
10
|
+
/* @__PURE__ */u("form",{onSubmit:e=>{e.preventDefault(),M(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
11
|
/* @__PURE__ */u("span",{className:"px-2 text-gray-400 text-xs",children:w.startsWith("https://")?"🔒":"⚠️"}),
|
|
12
12
|
/* @__PURE__ */u("input",{type:"text",value:C,onChange:e=>R(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
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:()=>R(w)}})})]})}),
|
|
14
|
-
/* @__PURE__ */u("button",{"data-bookmark-popover":!0,onClick:()=>
|
|
14
|
+
/* @__PURE__ */u("button",{"data-bookmark-popover":!0,onClick:()=>Y?V(T.findIndex(e=>e.url===w)):void H(j(w)),className:K+" "+(Y?"text-yellow-500":""),title:Y?"Remove bookmark":"Add bookmark",children:/* @__PURE__ */u(a,{name:"star",className:"h-4 w-4",fill:Y?"currentColor":"none",strokeWidth:1.5})}),
|
|
15
15
|
/* @__PURE__ */u("button",{onClick:G,className:K,title:"Open in new tab",children:/* @__PURE__ */u(a,{name:"external",className:"h-4 w-4",strokeWidth:1.5})}),
|
|
16
|
-
/* @__PURE__ */u("button",{onClick:()=>A(e=>!e),className:K,title:"Embedding help",children:/* @__PURE__ */u(a,{name:"help",className:"h-4 w-4",strokeWidth:1.5})})]}),null!==
|
|
16
|
+
/* @__PURE__ */u("button",{onClick:()=>A(e=>!e),className:K,title:"Embedding help",children:/* @__PURE__ */u(a,{name:"help",className:"h-4 w-4",strokeWidth:1.5})})]}),null!==O&&/* @__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
17
|
/* @__PURE__ */u("div",{className:"text-2xs font-semibold uppercase tracking-wide text-ink-faint mb-1",children:"Bookmark this page"}),
|
|
18
18
|
/* @__PURE__ */u("div",{className:"text-2xs text-ink-faintest truncate mb-2 font-mono",title:w,children:w}),
|
|
19
|
-
/* @__PURE__ */u("input",{ref:
|
|
19
|
+
/* @__PURE__ */u("input",{ref:I,type:"text",value:O,onChange:e=>H(e.target.value),onKeyDown:e=>{"Enter"===e.key?Q():"Escape"===e.key&&H(null)},placeholder:"Name",className:"w-full text-sm px-2 h-8 border border-line-strong rounded focus:outline-none focus:border-blue-400 focus:ring-1 focus:ring-blue-200"}),
|
|
20
20
|
/* @__PURE__ */m("div",{className:"flex justify-end gap-1 mt-2",children:[
|
|
21
|
-
/* @__PURE__ */u("button",{onClick:()=>
|
|
22
|
-
/* @__PURE__ */u("button",{onClick:Q,disabled:!
|
|
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===T.length&&/* @__PURE__ */u("span",{className:"text-2xs text-ink-faintest italic px-2",children:"No bookmarks yet — star the address bar to add one."}),T.map((e,t)=>/* @__PURE__ */m("button",{onClick:()=>
|
|
21
|
+
/* @__PURE__ */u("button",{onClick:()=>H(null),className:"px-2 py-1 text-xs text-gray-600 hover:bg-gray-100 rounded",children:"Cancel"}),
|
|
22
|
+
/* @__PURE__ */u("button",{onClick:Q,disabled:!O.trim(),className:"px-2 py-1 text-xs bg-blue-500 text-white rounded hover:bg-blue-600 disabled:opacity-40",children:"Save"})]})]}),
|
|
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===T.length&&/* @__PURE__ */u("span",{className:"text-2xs text-ink-faintest italic px-2",children:"No bookmarks yet — star the address bar to add one."}),T.map((e,t)=>/* @__PURE__ */m("button",{onClick:()=>M(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"})&&V(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
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
25
|
/* @__PURE__ */u("div",{className:"flex-1"}),
|
|
26
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(N,{url:w,iframeKey:
|
|
27
|
+
/* @__PURE__ */u("div",{className:"flex-1 relative min-h-0 bg-gray-50",children:/* @__PURE__ */u(N,{url:w,iframeKey:z,iframeRef:Z,openExternal:G,showHelp:L,dismissHelp:()=>A(!1)})})]})}function j(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[i,d]=l(!1);c(()=>{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
28
|
/* @__PURE__ */u(a,{name:"no-symbol",className:"h-14 w-14 mx-auto text-gray-300 mb-3",strokeWidth:1.2}),
|
|
29
29
|
/* @__PURE__ */m("h3",{className:"text-base font-semibold text-gray-800 mb-1",children:[j(e)," can't be embedded"]}),
|
|
30
30
|
/* @__PURE__ */m("p",{className:"text-sm text-gray-500 mb-4",children:["This site sends an ",
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import{loadAppearance as e,WidgetSettingsModal as t}from"./chunk-MUNP5Z24.js";import{useWidgetSettings as n}from"./chunk-D4WO73XD.js";import"./chunk-4LXCCZDM.js";import"./chunk-KNUR2UEG.js";import"./chunk-JDCM2VHG.js";import"./chunk-YI4T5I5D.js";import"./chunk-M2TQOJ3G.js";import"./chunk-FBZUEZK7.js";import"./chunk-5A7MWTXX.js";import"./chunk-BG3C4ALM.js";import"./chunk-GMLOMLCS.js";import"./chunk-UTQN5AIO.js";import"./chunk-EIFNESXS.js";import"./chunk-SXHV5OLA.js";import"./chunk-SF4IIV5Z.js";import"./chunk-FRCTA5FS.js";import"./chunk-VWGWZY7A.js";import"./chunk-UVHXVSB2.js";import"./chunk-WRV6QKJN.js";import"./chunk-AW7TOB6N.js";import"./chunk-4U5M37SF.js";import"./chunk-F3ZOO23R.js";import"./chunk-2QY5BJLA.js";import"./chunk-UGTRSRIW.js";import"./chunk-DPFEQQQU.js";import"./chunk-DWGYC7OD.js";import"./chunk-YDJ5IZOU.js";import"./chunk-THAPVKEJ.js";import"./chunk-URHGHXDN.js";import"./chunk-5QFPTDQF.js";import"./chunk-UTISUEO4.js";import"./chunk-BUFAJJDZ.js";import{Icon as r}from"./chunk-ISVODSRP.js";import"./chunk-J75ZT2JQ.js";import"./chunk-R2VKEMZH.js";import"./chunk-BWJZTHZ6.js";import"./chunk-TD3ZQD5R.js";import"./chunk-F2RAIGCG.js";import"./chunk-PGN5ME7B.js";import"./chunk-62LW225J.js";import"./chunk-VY3UA6AR.js";import"./chunk-WCCS4VFE.js";import"./chunk-ZDXRSY2Y.js";import"./chunk-STKJA4PV.js";import"./chunk-M6UKCZHT.js";import"./chunk-UQYNPYF4.js";import"./chunk-MRJKZWWV.js";import"./chunk-TWVUQUUD.js";import"./chunk-5FYDNH4Y.js";import"./chunk-LNXBTK7Q.js";import"./chunk-MAFUXCPZ.js";import"./chunk-IUVGHHR3.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,C]=c(""),[x,f]=c([]),[v,$]=c(!1),[S,T]=c(()=>e(h)),[U,F]=c(!1),[D,E]=c(S),A=i(null);n(o(()=>{E({...S}),F(!0)},[S]));const W=o(e=>{C(""),k(t=>j||"0"===t?(N(!1),"."===e?"0.":e):"."===e&&t.includes(".")?t:t+e)},[j]),Z=o(()=>{k("0"),d(null),g(null),N(!1)},[]),R=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}},[]),M=o(e=>{const t=parseFloat(m);if(null!==p&&b&&!j){const e=R(p,t,b);k(String(e)),d(e),f(n=>[`${p} ${b} ${t} = ${e}`,...n].slice(0,20))}else d(t);g(e),N(!0)},[m,p,b,j,R]),V=o(()=>{if(null===p||!b)return;const e=parseFloat(m),t=R(p,e,b),n=`${p} ${b} ${e} =`;f(e=>[`${n} ${t}`,...e].slice(0,20)),C(n),k(String(t)),d(null),g(null),N(!0)},[m,p,b,R]),J=o(()=>{k(e=>String(parseFloat(e)/100))},[]),O=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?M("+"):"-"===e.key?M("-"):"*"===e.key?M("×"):"/"===e.key?(e.preventDefault(),M("÷")):"Enter"===e.key||"="===e.key?("Enter"===e.key&&e.target instanceof Node&&A.current?.contains(e.target)&&e.preventDefault(),V()):"Escape"===e.key?Z():"Backspace"===e.key?k(e=>e.length>1?e.slice(0,-1):"0"):"%"===e.key&&J())};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[W,M,V,Z,J]);const Q="flex items-center justify-center rounded-lg text-sm font-medium transition-colors",w=`${Q} bg-white border border-gray-200 text-gray-900 hover:bg-gray-50 active:bg-gray-100`,I=`${Q} bg-blue-50 border border-blue-200 text-blue-700 hover:bg-blue-100 active:bg-blue-200`,G=`${Q} bg-gray-100 border border-gray-200 text-gray-600 hover:bg-gray-200 active:bg-gray-300`,H=`${Q} bg-blue-600 text-white hover:bg-blue-700 active:bg-blue-800`;/* @__PURE__ */
|
|
2
|
+
return l(a,{children:[
|
|
3
|
+
/* @__PURE__ */l("div",{ref:A,className:"flex flex-col h-full",style:{opacity:S.activeOpacity/100,backdropFilter:S.activeBlur>0?`blur(${S.activeBlur}px)`:void 0},children:[
|
|
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:[
|
|
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} ${j?"":m}`}),
|
|
6
|
+
/* @__PURE__ */l("div",{className:"flex items-center gap-2",children:[
|
|
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
|
+
/* @__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
|
+
/* @__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:Z,className:G,children:"AC"}),
|
|
11
|
+
/* @__PURE__ */u("button",{onClick:O,className:G,children:"+/−"}),
|
|
12
|
+
/* @__PURE__ */u("button",{onClick:J,className:G,children:"%"}),
|
|
13
|
+
/* @__PURE__ */u("button",{onClick:()=>M("÷"),className:`${I} ${"÷"===b?"ring-2 ring-blue-400":""}`,children:"÷"}),
|
|
14
|
+
/* @__PURE__ */u("button",{onClick:()=>W("7"),className:w,children:"7"}),
|
|
15
|
+
/* @__PURE__ */u("button",{onClick:()=>W("8"),className:w,children:"8"}),
|
|
16
|
+
/* @__PURE__ */u("button",{onClick:()=>W("9"),className:w,children:"9"}),
|
|
17
|
+
/* @__PURE__ */u("button",{onClick:()=>M("×"),className:`${I} ${"×"===b?"ring-2 ring-blue-400":""}`,children:"×"}),
|
|
18
|
+
/* @__PURE__ */u("button",{onClick:()=>W("4"),className:w,children:"4"}),
|
|
19
|
+
/* @__PURE__ */u("button",{onClick:()=>W("5"),className:w,children:"5"}),
|
|
20
|
+
/* @__PURE__ */u("button",{onClick:()=>W("6"),className:w,children:"6"}),
|
|
21
|
+
/* @__PURE__ */u("button",{onClick:()=>M("-"),className:`${I} ${"-"===b?"ring-2 ring-blue-400":""}`,children:"−"}),
|
|
22
|
+
/* @__PURE__ */u("button",{onClick:()=>W("1"),className:w,children:"1"}),
|
|
23
|
+
/* @__PURE__ */u("button",{onClick:()=>W("2"),className:w,children:"2"}),
|
|
24
|
+
/* @__PURE__ */u("button",{onClick:()=>W("3"),className:w,children:"3"}),
|
|
25
|
+
/* @__PURE__ */u("button",{onClick:()=>M("+"),className:`${I} ${"+"===b?"ring-2 ring-blue-400":""}`,children:"+"}),
|
|
26
|
+
/* @__PURE__ */u("button",{onClick:()=>W("0"),className:`${w} col-span-2`,children:"0"}),
|
|
27
|
+
/* @__PURE__ */u("button",{onClick:()=>W("."),className:w,children:"."}),
|
|
28
|
+
/* @__PURE__ */u("button",{onClick:V,className:H,children:"="})]})]}),
|
|
29
|
+
/* @__PURE__ */u(t,{open:U,onClose:()=>F(!1),title:"Calculator Settings",appearance:D,onAppearanceChange:E,onSave:()=>{T(D),localStorage.setItem(h,JSON.stringify(D)),F(!1)}})]})}export{m as default};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import{loadAppearance as t,WidgetSettingsModal as e}from"./chunk-MUNP5Z24.js";import{useWidgetSettings as r}from"./chunk-D4WO73XD.js";import"./chunk-4LXCCZDM.js";import"./chunk-KNUR2UEG.js";import"./chunk-JDCM2VHG.js";import"./chunk-YI4T5I5D.js";import"./chunk-M2TQOJ3G.js";import"./chunk-FBZUEZK7.js";import"./chunk-5A7MWTXX.js";import"./chunk-BG3C4ALM.js";import"./chunk-GMLOMLCS.js";import"./chunk-UTQN5AIO.js";import"./chunk-EIFNESXS.js";import"./chunk-SXHV5OLA.js";import"./chunk-SF4IIV5Z.js";import"./chunk-FRCTA5FS.js";import"./chunk-VWGWZY7A.js";import"./chunk-UVHXVSB2.js";import"./chunk-WRV6QKJN.js";import"./chunk-AW7TOB6N.js";import"./chunk-4U5M37SF.js";import"./chunk-F3ZOO23R.js";import"./chunk-2QY5BJLA.js";import"./chunk-UGTRSRIW.js";import"./chunk-DPFEQQQU.js";import"./chunk-DWGYC7OD.js";import"./chunk-YDJ5IZOU.js";import"./chunk-THAPVKEJ.js";import"./chunk-URHGHXDN.js";import"./chunk-5QFPTDQF.js";import"./chunk-UTISUEO4.js";import"./chunk-BUFAJJDZ.js";import"./chunk-ISVODSRP.js";import"./chunk-J75ZT2JQ.js";import{LoadingSpinner as n}from"./chunk-R2VKEMZH.js";import"./chunk-BWJZTHZ6.js";import"./chunk-TD3ZQD5R.js";import"./chunk-F2RAIGCG.js";import"./chunk-PGN5ME7B.js";import"./chunk-62LW225J.js";import"./chunk-VY3UA6AR.js";import"./chunk-WCCS4VFE.js";import"./chunk-ZDXRSY2Y.js";import"./chunk-STKJA4PV.js";import"./chunk-M6UKCZHT.js";import"./chunk-UQYNPYF4.js";import"./chunk-MRJKZWWV.js";import"./chunk-TWVUQUUD.js";import"./chunk-5FYDNH4Y.js";import"./chunk-LNXBTK7Q.js";import"./chunk-MAFUXCPZ.js";import"./chunk-IUVGHHR3.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 j(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 g(){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(g),[f,x]=s(()=>t(h)),[S,y]=s({}),[D,b]=s(!1),[U,C]=s(!1),[v,A]=s([]),[J,R]=s(f),[F,I]=s("USD"),[O,Z]=s("CNY");r(o(()=>{A([...u]),R({...f}),C(!0)},[u,f])),c(()=>{const t=[...new Set(u.map(([t])=>t))];let e=!0;return async function(){b(!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,j(e,n.rates))}catch{}}e&&(y(r),b(!1))}(),()=>{e=!1}},[u]);/* @__PURE__ */
|
|
2
|
+
return i(a,{children:[
|
|
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=S[t]?.[e];/* @__PURE__ */
|
|
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:[
|
|
5
|
+
/* @__PURE__ */i("div",{className:"flex items-center gap-2",children:[
|
|
6
|
+
/* @__PURE__ */m("span",{className:"text-base",children:N[t]||""}),
|
|
7
|
+
/* @__PURE__ */m("span",{className:"text-sm font-semibold text-gray-700",children:t}),
|
|
8
|
+
/* @__PURE__ */m("svg",{className:"h-3 w-3 text-gray-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:/* @__PURE__ */m("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M7 16V4m0 0L3 8m4-4l4 4m6 0v12m0 0l4-4m-4 4l-4-4"})}),
|
|
9
|
+
/* @__PURE__ */m("span",{className:"text-base",children:N[e]||""}),
|
|
10
|
+
/* @__PURE__ */m("span",{className:"text-sm font-semibold text-gray-700",children:e})]}),
|
|
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:U,onClose:()=>C(!1),title:"Currency Settings",appearance:J,onAppearanceChange:R,onSave:()=>{if(0===v.length)return;const t=v.slice(0,4);d(t),x(J),localStorage.setItem(p,JSON.stringify(t)),localStorage.setItem(h,JSON.stringify(J)),C(!1)},children:/* @__PURE__ */i("div",{children:[
|
|
13
|
+
/* @__PURE__ */i("h3",{className:"text-sm font-semibold text-ink mb-2",children:["Currency Pairs ",
|
|
14
|
+
/* @__PURE__ */i("span",{className:"text-2xs font-normal text-ink-faintest",children:["(",v.length,"/",4,")"]})]}),
|
|
15
|
+
/* @__PURE__ */m("div",{className:"space-y-1 mb-2",children:v.map(([t,e],r)=>/* @__PURE__ */i("div",{className:"flex items-center justify-between py-1 px-2 bg-gray-50 rounded",children:[
|
|
16
|
+
/* @__PURE__ */i("span",{className:"text-sm",children:[N[t]||""," ",t," → ",N[e]||""," ",e]}),
|
|
17
|
+
/* @__PURE__ */m("button",{onClick:()=>A(t=>t.filter((t,e)=>e!==r)),className:"text-red-400 hover:text-red-600",children:"×"})]},r))}),v.length<4?/* @__PURE__ */i("div",{className:"flex items-center gap-2",children:[
|
|
18
|
+
/* @__PURE__ */m("select",{value:F,onChange:t=>I(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
|
+
/* @__PURE__ */m("span",{className:"text-gray-400",children:"→"}),
|
|
20
|
+
/* @__PURE__ */m("select",{value:O,onChange:t=>Z(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:()=>{F!==O&&v.length<4&&A(t=>[...t,[F,O]])},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};
|