efficient-shell 4.166.0 → 4.168.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 +134 -1
- package/dist/{Browser-2MBG34IR.js → Browser-PZPREN6H.js} +14 -14
- package/dist/{Calculator-R3WJTNZ6.js → Calculator-NXMUEH5D.js} +22 -22
- package/dist/{CurrencyConverter-PEXSQQUK.js → CurrencyConverter-3BTIZ2LT.js} +6 -6
- package/dist/{Documents-YL4RIOZO.js → Documents-YAOM3L47.js} +10 -10
- package/dist/{Files-3ZRUTRSB.js → Files-2UHYDMLL.js} +30 -30
- package/dist/{Notepad-3ZM2FR6C.js → Notepad-OWL75AYX.js} +9 -9
- package/dist/{PomodoroTimer-5QHA5UOY.js → PomodoroTimer-SCPEOG6W.js} +27 -27
- package/dist/{Preview-32F4DTCK.js → Preview-5R3QZSJU.js} +16 -16
- package/dist/{Sidebar-QQSRLMJG.js → Sidebar-C5RXL72L.js} +17 -17
- package/dist/{Spreadsheet-GOZI7I4L.js → Spreadsheet-XT4HF7MQ.js} +14 -14
- package/dist/{Stock-XJFITZZA.js → Stock-UGDIALNB.js} +4 -4
- package/dist/{Weather-BDC633GV.js → Weather-CR2MN5XF.js} +15 -15
- package/dist/{WorldClock-ROOVRRCJ.js → WorldClock-JBNJ7C7J.js} +6 -6
- package/dist/apps/index.js +1 -1
- package/dist/bin/ui-check.js +2 -0
- package/dist/brand.css +1 -1
- package/dist/{chunk-HGG5M5AB.js → chunk-6MBERZOS.js} +1 -1
- package/dist/chunk-7U3F53IG.js +1 -0
- package/dist/{chunk-CRI4UFBU.js → chunk-A7Q4BCPI.js} +5 -5
- package/dist/{chunk-7TQ7NMT3.js → chunk-CUX4XGLS.js} +1 -1
- package/dist/{chunk-G5J6YSN5.js → chunk-FVXBJGY5.js} +3 -3
- package/dist/{chunk-JKVDTKBE.js → chunk-GVZLCY3B.js} +290 -284
- package/dist/{chunk-QASZIYLG.js → chunk-JLPJBO7K.js} +1 -1
- package/dist/{chunk-BKDE67DB.js → chunk-JYLI2WXW.js} +2 -2
- package/dist/{chunk-VXBJNMAA.js → chunk-LW27IM3S.js} +98 -98
- package/dist/{chunk-UVZIPXIA.js → chunk-N3ZXQE4M.js} +3 -3
- package/dist/{chunk-7YFAFXQG.js → chunk-PLX2N4N6.js} +2 -2
- package/dist/{chunk-DTRXR6JQ.js → chunk-XKHAP6N2.js} +11 -11
- package/dist/{chunk-HA2WG27U.js → chunk-YWXYBJ5Y.js} +2 -2
- package/dist/{index-DcLqfJX3.d.ts → index-CbLbd__n.d.ts} +61 -3
- package/dist/index.d.ts +2 -2
- package/dist/index.js +56 -56
- package/dist/map/index.js +3 -3
- package/dist/page-tabs/index.js +5 -5
- package/dist/ui/index.d.ts +1 -1
- package/dist/ui/index.js +1 -1
- package/dist/ui.css +12 -0
- package/package.json +9 -2
- package/dist/chunk-VRHUY4P4.js +0 -1
package/README.md
CHANGED
|
@@ -582,7 +582,7 @@ menu open; a radio closes it, as a plain item does.
|
|
|
582
582
|
</PopupSubmenu>
|
|
583
583
|
```
|
|
584
584
|
|
|
585
|
-
### Editor controls — `Slider`, `ColorPicker`, `Tree`, `IconRail`, `ResizeHandle`
|
|
585
|
+
### Editor controls — `Slider`, `ColorPicker`, `Tree`, `SortableList`, `IconRail`, `ResizeHandle`
|
|
586
586
|
|
|
587
587
|
These were folded in from `efficient-easel` under harness UI-24, because the
|
|
588
588
|
website editor and the email designer each drew their own. All of them are on
|
|
@@ -718,6 +718,47 @@ without. Put one in every gap or in none, and use `TreeEmptySlot` for an empty
|
|
|
718
718
|
list. The words come from the catalog: `tree.dragHint`, `tree.moveHint` and
|
|
719
719
|
`tree.insertHere`.
|
|
720
720
|
|
|
721
|
+
**`SortableList`** and **`ListRow`** draw a flat list a person puts in order:
|
|
722
|
+
slides, buttons, links, lines of copy. A list is not a tree: no levels, no
|
|
723
|
+
folding, no selection, and a row is usually a control of its own, so the row
|
|
724
|
+
is a frame (grip, the host's content, trailing actions) and the moving is
|
|
725
|
+
`TreeRow`'s, shared rather than copied.
|
|
726
|
+
|
|
727
|
+
```tsx
|
|
728
|
+
<SortableList aria-label="Slides" spacing="comfortable">
|
|
729
|
+
{slides.map((slide, i) => (
|
|
730
|
+
<Fragment key={slide.id}>
|
|
731
|
+
<ListRow draggable onMove={to => move(i, to)} drop={dropAt(i)} dragging={dragged === i}
|
|
732
|
+
rowProps={{ draggable: true, onDragStart: …, onDragOver: …, onDrop: … }}
|
|
733
|
+
active={open === i} below={open === i ? <SlideSettings … /> : undefined}
|
|
734
|
+
actions={<IconButton aria-label="Delete slide" onClick={() => remove(i)}>…</IconButton>}>
|
|
735
|
+
<button type="button" onClick={() => setOpen(i)}>{slide.name}</button>
|
|
736
|
+
</ListRow>
|
|
737
|
+
{i < slides.length - 1 && <TreeSeam onInsert={() => insertAt(i + 1)} />}
|
|
738
|
+
</Fragment>
|
|
739
|
+
))}
|
|
740
|
+
</SortableList>
|
|
741
|
+
```
|
|
742
|
+
|
|
743
|
+
`SortableList` is `role="list"` and each `ListRow` a `listitem` holding the
|
|
744
|
+
row's bar and, under it, `below` (the item's settings, open), so a drag picks
|
|
745
|
+
up the bar and never the open fields. `draggable` shows the same grip as
|
|
746
|
+
`TreeRow` in the bar's left padding on hover and on focus inside the bar, with
|
|
747
|
+
"Drag to move" in a `Tooltip`; the DOM drag is the host's, on `rowProps`.
|
|
748
|
+
`onMove(to)` takes Alt+ArrowUp / Alt+ArrowDown from anywhere in the bar, a text
|
|
749
|
+
box in it included, and announces them (`aria-keyshortcuts` and a
|
|
750
|
+
description). A native `<select>` keeps the keys. When nothing in the bar takes
|
|
751
|
+
focus (a name, a picture), the bar takes it, or the keyboard could not reach the
|
|
752
|
+
row to move it. `drop` (`before | after`) draws one line in the middle of the
|
|
753
|
+
gap above or below the whole item, and `dragging` fades the row. `actions` sit
|
|
754
|
+
at the bar's end, always showing. `active` keeps the hover ground (its item is
|
|
755
|
+
open), and `flat` drops the hover ground for a row that is a text box.
|
|
756
|
+
`rowRef` reaches the bar, to put the caret back after a move. `spacing` is
|
|
757
|
+
`compact` (4px, the tree's step) or `comfortable` (8px). A `TreeSeam` between
|
|
758
|
+
two rows hands back exactly that step at either, and `TreeEmptySlot` stands in
|
|
759
|
+
for an empty list. The words are the catalog's `tree.dragHint` and
|
|
760
|
+
`tree.moveHint`, so one translation covers both rows.
|
|
761
|
+
|
|
721
762
|
**`IconRail`** and **`IconRailButton`** make a slim strip of icon toggles
|
|
722
763
|
(`role="toolbar"`, `orientation="vertical" | "horizontal"`). A button with a
|
|
723
764
|
boolean `active` is a toggle (`aria-pressed`). Leave `active` out for an action
|
|
@@ -2540,6 +2581,98 @@ missing or cannot be read. All of them are also exported from
|
|
|
2540
2581
|
| `dismissPopups()`, `OVERLAY_OPEN_EVENT` | An overlay calls `dismissPopups()` as it opens; every open kit popup (`Select`, `SearchableSelect`, `TagInput`, `DatePicker`, `DateRangePicker`, `PopupMenu` via its `onClose`, `ServerStatusIndicator`) closes rather than floating over the overlay. The kit's own overlays already call it. A consumer's own popup listens for `OVERLAY_OPEN_EVENT` on `window` while open. |
|
|
2541
2582
|
| `Kbd` constants — `MOD`, `ALT`, `SHIFT`, `ENTER`, `ALT_SHIFT_E`, `CMD_K`, … | Symbol constants for rendering keyboard shortcuts. |
|
|
2542
2583
|
|
|
2584
|
+
### The UI kit check — `efficient-shell-ui-check`
|
|
2585
|
+
|
|
2586
|
+
Every surface a person operates takes its UI from this package (harness
|
|
2587
|
+
UI-24). The package ships the command that holds a repository to it, so every
|
|
2588
|
+
frontend runs the same check, at the version of the kit it has installed:
|
|
2589
|
+
|
|
2590
|
+
```bash
|
|
2591
|
+
npx efficient-shell-ui-check # check; exits 1 on a failure
|
|
2592
|
+
npx efficient-shell-ui-check --print # today's counts, as a baseline
|
|
2593
|
+
npx efficient-shell-ui-check --summary # totals per kind and per folder, as Markdown
|
|
2594
|
+
npx efficient-shell-ui-check --json # the result, for a script
|
|
2595
|
+
npx efficient-shell-ui-check --update # lower the lines whose counts fell
|
|
2596
|
+
npx efficient-shell-ui-check --init # write the first baseline (adoption only)
|
|
2597
|
+
```
|
|
2598
|
+
|
|
2599
|
+
It reads the TypeScript syntax tree, not the text (a comment that mentions
|
|
2600
|
+
`<button>` is not a button), with the repository's own `typescript`. It needs
|
|
2601
|
+
no other install.
|
|
2602
|
+
|
|
2603
|
+
**What it counts.** Each *kind* is one shape of UI a repository draws for
|
|
2604
|
+
itself where the kit has an answer:
|
|
2605
|
+
|
|
2606
|
+
| Kind | Counted | The kit has |
|
|
2607
|
+
|---|---|---|
|
|
2608
|
+
| `button` | a raw `<button>` | `Button`, `IconButton` |
|
|
2609
|
+
| `input` | a raw `<input>` (not `hidden`, not a range) | `Input`, `InputNumber`, `Checkbox`, `Radio`, `Switch` |
|
|
2610
|
+
| `range` | `<input type="range">` | `Slider` |
|
|
2611
|
+
| `textarea` | a raw `<textarea>` | `Textarea` |
|
|
2612
|
+
| `select` | a raw `<select>` | `Select`, `SearchableSelect` |
|
|
2613
|
+
| `dialog` | `<dialog>`, or `role="dialog"` / `"alertdialog"` on a raw element | `Dialog`, `Modal` |
|
|
2614
|
+
| `title` | `title=` on a raw element (not `iframe`, `frame`, `object`, `embed`; never a component's `title` prop) | `Tooltip` |
|
|
2615
|
+
| `portal` | a `createPortal(…)` call | `Popover`, `PopupMenu`, `DropdownMenu`, `Tooltip` |
|
|
2616
|
+
| `native` | `window.confirm` / `alert` / `prompt`, or a bare call nothing in the file binds | `confirm`, `confirmDestructive`, `prompt`, `toast` |
|
|
2617
|
+
| `dark` | a `dark:` variant in a class string | the light class alone; the kit remaps it |
|
|
2618
|
+
| `hex` | a hex colour in a `.tsx` string (not in `href`, `to`, `id`, `key`, `htmlFor`) | a token or a palette class |
|
|
2619
|
+
| `kit` | an import of a second UI kit (`@headlessui`, `@radix-ui`, `@mui`, `antd`, `sonner`, …) | the kit's component |
|
|
2620
|
+
| `icon` | an import of an icon package (`@heroicons`, `lucide-react`, `@tabler/icons`, …) | the icon through this package |
|
|
2621
|
+
| `kit-dep` | one of those packages declared in `package.json` (not `devDependencies`) | remove it |
|
|
2622
|
+
|
|
2623
|
+
Known gaps: `rgb()` / `hsl()` colours, colours in `.ts` maps, and
|
|
2624
|
+
`createElement('button')` are not counted.
|
|
2625
|
+
|
|
2626
|
+
**Two files at the repository root.** `ui-kit.config.json` is written by hand
|
|
2627
|
+
and reviewed:
|
|
2628
|
+
|
|
2629
|
+
```json
|
|
2630
|
+
{
|
|
2631
|
+
"schema": 1,
|
|
2632
|
+
"kinds": ["button", "input", "range", "textarea", "select", "dialog", "title", "portal"],
|
|
2633
|
+
"include": ["src/**/*.tsx"],
|
|
2634
|
+
"exclude": ["**/*.test.tsx"],
|
|
2635
|
+
"output": [
|
|
2636
|
+
{ "files": ["src/blocks/**"], "reason": "The published page draws these for a shopper." }
|
|
2637
|
+
],
|
|
2638
|
+
"allow": [
|
|
2639
|
+
{ "file": "src/Canvas.tsx", "kind": "button", "count": 1, "reason": "The canvas cover: a picture, not a Button." }
|
|
2640
|
+
]
|
|
2641
|
+
}
|
|
2642
|
+
```
|
|
2643
|
+
|
|
2644
|
+
- `kinds` is opt-in. A kind added in a later release is not checked until the
|
|
2645
|
+
repository names it, so upgrading this package never turns a build red.
|
|
2646
|
+
- `include` / `exclude` are globs from the repository root (`**`, `*`, `?`,
|
|
2647
|
+
`{a,b}`). A file is operator UI unless a line here says otherwise.
|
|
2648
|
+
- `output` names what is drawn for someone other than an operator (a published
|
|
2649
|
+
page, an email), each region with its reason. Those files are not read.
|
|
2650
|
+
- `includeImporting` (`files`, `modules`, `reason`) is for a repository that is
|
|
2651
|
+
mostly output: a file under `files` is in scope only when it imports one of
|
|
2652
|
+
`modules`.
|
|
2653
|
+
- `allow` is a count that is meant to stay, with its reason. It is exact too:
|
|
2654
|
+
when the element goes, the entry goes.
|
|
2655
|
+
- A glob that matches no file fails. A line that outlived its files is deleted.
|
|
2656
|
+
|
|
2657
|
+
`ui-kit.baseline.json` is written only by the command: one sorted line per
|
|
2658
|
+
file and kind, and no totals, so two pull requests that each move a different
|
|
2659
|
+
control to the kit do not conflict.
|
|
2660
|
+
|
|
2661
|
+
**The baseline is exact, both ways.** A count above its line fails, with the
|
|
2662
|
+
lines it is on and the component that replaces it. A count below its line
|
|
2663
|
+
fails too, until `--update` lowers it, so the file never claims more than is
|
|
2664
|
+
left. `--update` only lowers and deletes; `--update --allow-move` also follows
|
|
2665
|
+
a renamed or split file, and refuses when any kind's total across the
|
|
2666
|
+
repository would rise. `--init` writes the first baseline and refuses to
|
|
2667
|
+
overwrite one; `--init --kind <kind>` takes the baseline for a kind just added
|
|
2668
|
+
to `kinds`.
|
|
2669
|
+
|
|
2670
|
+
On a pull request (`GITHUB_BASE_REF` set) it also compares with the base
|
|
2671
|
+
branch's baseline: no kind's total may be higher there. `--no-base` skips it.
|
|
2672
|
+
|
|
2673
|
+
Wire it into the job that already gates a merge, for example at the front of
|
|
2674
|
+
the `test` script: `"test": "efficient-shell-ui-check && vitest run"`.
|
|
2675
|
+
|
|
2543
2676
|
## Why it exists
|
|
2544
2677
|
|
|
2545
2678
|
Most "desktop UI" demos on the web are toys with hardcoded windows and no escape hatch. This one was extracted from a working ERP where every entity (sales orders, invoices, vendors, …) opens as its own window with consistent header, footer, hotkeys, depth stacking, and split-view. The shell is **fully decoupled** from any specific backend — every subsystem that needs server data (notifications, bug reports, desktop shortcuts, search, entity fetching) takes its data through callback configs supplied by the consumer. Drop-in localStorage fallbacks ship for prefs and sticky notes so the package works out of the box without a backend.
|
|
@@ -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-6MBERZOS.js";import"./chunk-7U3F53IG.js";import{WindowTitle as r}from"./chunk-LW27IM3S.js";import"./chunk-A7Q4BCPI.js";import"./chunk-DSSLOQDW.js";import"./chunk-5A7MWTXX.js";import"./chunk-JYLI2WXW.js";import"./chunk-6KO2U66R.js";import{confirm as n}from"./chunk-M4DB7UBZ.js";import"./chunk-N3ZXQE4M.js";import"./chunk-AFYQTVZO.js";import"./chunk-HZZNJHRH.js";import"./chunk-X4FJ54PP.js";import"./chunk-NCQLGQYR.js";import"./chunk-D65T4H6J.js";import{useRef as a,useEffect as i,useState as s}from"react";import{jsxs as l,jsx as c,Fragment as m}from"react/jsx-runtime";var d="react-os-shell:browser-bookmarks",u="react-os-shell:browser-homepage",h="https://en.wikipedia.org/wiki/Main_Page",p=[{label:"Wikipedia",url:"https://en.wikipedia.org/wiki/Main_Page"},{label:"DevDocs",url:"https://devdocs.io"},{label:"Example",url:"https://example.com"}],g=new Set(["ac ad ae af ag ai al am ao aq ar as at au aw ax az ba bb bd be bf bg bh bi","bj bm bn bo br bs bt bw by bz ca cc cd cf cg ch ci ck cl cm cn co cr cu cv","cw cx cy cz de dj dk dm do dz ec ee eg er es et eu fi fj fk fm fo fr ga gd","ge gf gg gh gi gl gm gn gp gq gr gs gt gu gw gy hk hm hn hr ht hu id ie il","im in io iq ir is it je jm jo jp ke kg kh ki km kn kp kr kw ky kz la lb lc","li lk lr ls lt lu lv ly ma mc md me mg mh mk ml mm mn mo mp mq mr ms mt mu","mv mw mx my mz na nc ne nf ng ni nl no np nr nu nz om pa pe pf pg ph pk pl","pm pn pr ps pt pw py qa re ro rs ru rw sa sb sc sd se sg sh si sk sl sm sn","so sr ss st su sv sx sy sz tc td tf tg th tj tk tl tm tn to tr tt tv tw tz","ua ug uk us uy uz va vc ve vg vi vn vu wf ws ye yt za zm zw","com net org edu gov mil int info biz name pro app dev xyz online site tech","store shop cloud design digital agency studio media news blog live life","world today email systems solutions services software page link space host","press wiki team group works careers finance capital energy academy"].join(" ").split(" "));function b(e){let t=e.trim();return t?/^[a-z][a-z0-9+.-]*:\/\//i.test(t)?t:function(e){const t=/^([\w-]+\.)+([a-z]{2,})(\/.*)?$/i.exec(e);return null!==t&&g.has(t[2].toLowerCase())}(t)?"https://"+t:"https://duckduckgo.com/?q="+encodeURIComponent(t):""}var k=["duckduckgo.com","developer.mozilla.org","google.com","gmail.com","youtube.com","facebook.com","instagram.com","whatsapp.com","twitter.com","x.com","github.com","gitlab.com","linkedin.com","reddit.com","pinterest.com","amazon.com","amazon.ca","amazon.co.uk","apple.com","icloud.com","microsoft.com","outlook.com","live.com","office.com","netflix.com","spotify.com","paypal.com","stripe.com","chat.openai.com","chatgpt.com","claude.ai"];function f(){if("undefined"==typeof window)return p;try{const e=localStorage.getItem(d);if(!e)return p;const t=JSON.parse(e);if(Array.isArray(t)&&t.every(e=>"string"==typeof e?.url))return t}catch{}return p}function x(){return"undefined"==typeof window?h:localStorage.getItem(u)||h}function w(){const m=a(void 0);void 0===m.current&&(m.current=e()),i(()=>{null!=m.current&&t(m.current)},[]);const h=m.current?b(m.current.url):"",[p,g]=s(x),[k,w]=s(h||p),[N,L]=s(k),[j,C]=s([k]),[z,M]=s(0),[W,S]=s(0),[R,B]=s(f),[H,A]=s(!1),[E,D]=s(null),I=a(null),O=a(null);i(()=>{try{localStorage.setItem(d,JSON.stringify(R))}catch{}},[R]);const T=e=>{const t=b(e);t&&(w(t),L(t),C(e=>{const o=e.slice(0,z+1);return o.push(t),o}),M(e=>e+1),A(!1))},U=()=>{"undefined"!=typeof window&&window.open(k,"_blank","noopener,noreferrer")},P=()=>{const e=E?.trim();e?(B(t=>[...t,{label:e,url:k}]),D(null)):D(null)};i(()=>{if(null===E)return;I.current?.focus(),I.current?.select();const e=e=>{const t=e.target;t?.closest("[data-bookmark-popover]")||D(null)},t=setTimeout(()=>document.addEventListener("mousedown",e),0);return()=>{clearTimeout(t),document.removeEventListener("mousedown",e)}},[null!==E]);const F=e=>{B(t=>t.filter((t,o)=>o!==e))},Q=z>0,X=z<j.length-1,q=R.some(e=>e.url===k),J="p-1.5 rounded hover:bg-gray-200 transition-colors text-gray-600 disabled:opacity-30";/* @__PURE__ */
|
|
2
2
|
return l("div",{className:"relative flex flex-col h-full bg-white",children:[
|
|
3
3
|
/* @__PURE__ */c(r,{title:`Browser - ${v(k)}`}),
|
|
4
4
|
/* @__PURE__ */c(o,{app:"browser"}),
|
|
5
5
|
/* @__PURE__ */l("div",{className:"flex items-center gap-1 px-2 py-1.5 border-b border-gray-200 bg-gray-50 shrink-0",children:[
|
|
6
|
-
/* @__PURE__ */c("button",{onClick:()=>{if(z>0){const e=z-1;M(e),w(j[e]),L(j[e]),
|
|
7
|
-
/* @__PURE__ */c("button",{onClick:()=>{if(z<j.length-1){const e=z+1;M(e),w(j[e]),L(j[e]),
|
|
8
|
-
/* @__PURE__ */c("button",{onClick:()=>
|
|
9
|
-
/* @__PURE__ */c("button",{onClick:()=>
|
|
10
|
-
/* @__PURE__ */c("form",{onSubmit:e=>{e.preventDefault(),
|
|
6
|
+
/* @__PURE__ */c("button",{onClick:()=>{if(z>0){const e=z-1;M(e),w(j[e]),L(j[e]),A(!1)}},disabled:!Q,className:J,title:"Back",children:/* @__PURE__ */c("svg",{className:"h-4 w-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:/* @__PURE__ */c("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M15.75 19.5L8.25 12l7.5-7.5"})})}),
|
|
7
|
+
/* @__PURE__ */c("button",{onClick:()=>{if(z<j.length-1){const e=z+1;M(e),w(j[e]),L(j[e]),A(!1)}},disabled:!X,className:J,title:"Forward",children:/* @__PURE__ */c("svg",{className:"h-4 w-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:/* @__PURE__ */c("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M8.25 4.5l7.5 7.5-7.5 7.5"})})}),
|
|
8
|
+
/* @__PURE__ */c("button",{onClick:()=>S(e=>e+1),className:J,title:"Refresh",children:/* @__PURE__ */c("svg",{className:"h-4 w-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.8,children:/* @__PURE__ */c("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M16.023 9.348h4.992V4.356M2.985 19.644v-4.992h4.992M3.05 9.348a9 9 0 0114.85-3.36L21.015 9.348m0 5.304a9 9 0 01-14.85 3.36l-3.115-3.36"})})}),
|
|
9
|
+
/* @__PURE__ */c("button",{onClick:()=>T(p),className:J,title:"Home",children:/* @__PURE__ */c("svg",{className:"h-4 w-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.8,children:/* @__PURE__ */c("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M2.25 12l8.954-8.955a1.5 1.5 0 012.122 0l8.954 8.955M4.5 9.75v10.125c0 .621.504 1.125 1.125 1.125H9.75v-4.875c0-.621.504-1.125 1.125-1.125h2.25c.621 0 1.125.504 1.125 1.125V21h4.125c.621 0 1.125-.504 1.125-1.125V9.75M8.25 21h8.25"})})}),
|
|
10
|
+
/* @__PURE__ */c("form",{onSubmit:e=>{e.preventDefault(),T(N)},className:"flex-1 flex items-center mx-1",children:/* @__PURE__ */l("div",{className:"flex items-center w-full bg-white border border-gray-300 rounded focus-within:border-blue-400 focus-within:ring-1 focus-within:ring-blue-200",children:[
|
|
11
11
|
/* @__PURE__ */c("span",{className:"px-2 text-gray-400 text-xs",children:k.startsWith("https://")?"🔒":"⚠️"}),
|
|
12
12
|
/* @__PURE__ */c("input",{type:"text",value:N,onChange:e=>L(e.target.value),onFocus:e=>e.target.select(),className:"flex-1 px-1 py-1 text-sm bg-transparent outline-none font-mono",spellCheck:!1,placeholder:"Enter URL or search…"}),k!==N&&/* @__PURE__ */c("button",{type:"button",onClick:()=>L(k),className:"px-1.5 text-[10px] text-gray-400 hover:text-gray-700",title:"Reset to current URL",children:"×"})]})}),
|
|
13
|
-
/* @__PURE__ */c("button",{"data-bookmark-popover":!0,onClick:()=>q?
|
|
14
|
-
/* @__PURE__ */c("button",{onClick:
|
|
15
|
-
/* @__PURE__ */c("button",{onClick:()=>
|
|
13
|
+
/* @__PURE__ */c("button",{"data-bookmark-popover":!0,onClick:()=>q?F(R.findIndex(e=>e.url===k)):void D(v(k)),className:J+" "+(q?"text-yellow-500":""),title:q?"Remove bookmark":"Add bookmark",children:/* @__PURE__ */c("svg",{className:"h-4 w-4",fill:q?"currentColor":"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.5,children:/* @__PURE__ */c("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M11.48 3.499a.562.562 0 011.04 0l2.125 5.111a.563.563 0 00.475.345l5.518.442c.499.04.701.663.321.988l-4.204 3.602a.563.563 0 00-.182.557l1.285 5.385a.562.562 0 01-.84.61l-4.725-2.885a.563.563 0 00-.586 0L6.982 20.54a.562.562 0 01-.84-.61l1.285-5.386a.562.562 0 00-.182-.557l-4.204-3.602a.563.563 0 01.321-.988l5.518-.442a.563.563 0 00.475-.345L11.48 3.5z"})})}),
|
|
14
|
+
/* @__PURE__ */c("button",{onClick:U,className:J,title:"Open in new tab",children:/* @__PURE__ */c("svg",{className:"h-4 w-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.5,children:/* @__PURE__ */c("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M13.5 6H5.25A2.25 2.25 0 003 8.25v10.5A2.25 2.25 0 005.25 21h10.5A2.25 2.25 0 0018 18.75V10.5m-7.5-9L21 3m0 0v6m0-6L9.75 14.25"})})}),
|
|
15
|
+
/* @__PURE__ */c("button",{onClick:()=>A(e=>!e),className:J,title:"Embedding help",children:/* @__PURE__ */c("svg",{className:"h-4 w-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.5,children:/* @__PURE__ */c("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M9.879 7.519c1.171-1.025 3.071-1.025 4.242 0 1.172 1.025 1.172 2.687 0 3.712-.203.179-.43.326-.67.442-.745.361-1.45.999-1.45 1.827v.75M21 12a9 9 0 11-18 0 9 9 0 0118 0zm-9 5.25h.008v.008H12v-.008z"})})})]}),null!==E&&/* @__PURE__ */l("div",{"data-bookmark-popover":!0,className:"absolute right-3 top-12 z-30 w-72 bg-white border border-gray-200 rounded-md shadow-lg p-3",children:[
|
|
16
16
|
/* @__PURE__ */c("div",{className:"text-[11px] font-semibold uppercase tracking-wide text-gray-500 mb-1",children:"Bookmark this page"}),
|
|
17
17
|
/* @__PURE__ */c("div",{className:"text-[11px] text-gray-400 truncate mb-2 font-mono",title:k,children:k}),
|
|
18
|
-
/* @__PURE__ */c("input",{ref:
|
|
18
|
+
/* @__PURE__ */c("input",{ref:I,type:"text",value:E,onChange:e=>D(e.target.value),onKeyDown:e=>{"Enter"===e.key?P():"Escape"===e.key&&D(null)},placeholder:"Name",className:"w-full text-sm px-2 py-1.5 border border-gray-300 rounded focus:outline-none focus:border-blue-400 focus:ring-1 focus:ring-blue-200"}),
|
|
19
19
|
/* @__PURE__ */l("div",{className:"flex justify-end gap-1 mt-2",children:[
|
|
20
|
-
/* @__PURE__ */c("button",{onClick:()=>
|
|
21
|
-
/* @__PURE__ */c("button",{onClick:
|
|
22
|
-
/* @__PURE__ */l("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__ */c("button",{onClick:()=>D(null),className:"px-2 py-1 text-xs text-gray-600 hover:bg-gray-100 rounded",children:"Cancel"}),
|
|
21
|
+
/* @__PURE__ */c("button",{onClick:P,disabled:!E.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__ */l("div",{className:"flex items-center gap-0.5 px-2 py-1 border-b border-gray-200 bg-white shrink-0 overflow-x-auto",children:[0===R.length&&/* @__PURE__ */c("span",{className:"text-[11px] text-gray-400 italic px-2",children:"No bookmarks yet — star the address bar to add one."}),R.map((e,t)=>/* @__PURE__ */l("button",{onClick:()=>T(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"})&&F(t)},className:"flex items-center gap-1.5 px-2 py-0.5 rounded text-[12px] text-gray-700 hover:bg-gray-100 whitespace-nowrap",title:`${e.url}\n(right-click to remove)`,children:[
|
|
23
23
|
/* @__PURE__ */c("img",{src:`https://icons.duckduckgo.com/ip3/${new URL(e.url).hostname}.ico`,alt:"",className:"h-3.5 w-3.5",onError:e=>{e.target.style.visibility="hidden"}}),e.label]},t)),
|
|
24
24
|
/* @__PURE__ */c("div",{className:"flex-1"}),
|
|
25
25
|
/* @__PURE__ */c("button",{onClick:()=>{g(k);try{localStorage.setItem(u,k)}catch{}},className:"px-2 py-0.5 text-[11px] text-gray-500 hover:text-gray-800",title:"Set current page as homepage",children:"Set as home"})]}),
|
|
26
|
-
/* @__PURE__ */c("div",{className:"flex-1 relative min-h-0 bg-gray-50",children:/* @__PURE__ */c(y,{url:k,iframeKey:
|
|
26
|
+
/* @__PURE__ */c("div",{className:"flex-1 relative min-h-0 bg-gray-50",children:/* @__PURE__ */c(y,{url:k,iframeKey:W,iframeRef:O,openExternal:U,showHelp:H,dismissHelp:()=>A(!1)})})]})}function v(e){try{return new URL(e).hostname.replace(/^www\./,"")}catch{return e}}function y({url:e,iframeKey:t,iframeRef:o,openExternal:r,showHelp:n,dismissHelp:a}){const[d,u]=s(!1);i(()=>{u(!1)},[e]);return function(e){try{const t=new URL(e).hostname.toLowerCase();return k.some(e=>t===e||t.endsWith("."+e))}catch{return!1}}(e)&&!d?/* @__PURE__ */c("div",{className:"absolute inset-0 flex items-center justify-center bg-white p-8",children:/* @__PURE__ */l("div",{className:"max-w-md text-center",children:[
|
|
27
27
|
/* @__PURE__ */c("svg",{className:"h-14 w-14 mx-auto text-gray-300 mb-3",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.2,children:/* @__PURE__ */c("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M18.364 18.364A9 9 0 005.636 5.636m12.728 12.728L5.636 5.636m12.728 12.728L21 21M5.636 5.636L3 3m9 9a9 9 0 110-18 9 9 0 010 18z"})}),
|
|
28
28
|
/* @__PURE__ */l("h3",{className:"text-base font-semibold text-gray-800 mb-1",children:[v(e)," can't be embedded"]}),
|
|
29
29
|
/* @__PURE__ */l("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-JLPJBO7K.js";import{useWidgetSettings as n}from"./chunk-LW27IM3S.js";import"./chunk-A7Q4BCPI.js";import"./chunk-DSSLOQDW.js";import"./chunk-5A7MWTXX.js";import"./chunk-JYLI2WXW.js";import"./chunk-6KO2U66R.js";import"./chunk-M4DB7UBZ.js";import"./chunk-N3ZXQE4M.js";import"./chunk-AFYQTVZO.js";import"./chunk-HZZNJHRH.js";import"./chunk-X4FJ54PP.js";import"./chunk-NCQLGQYR.js";import"./chunk-D65T4H6J.js";import{useState as r,useRef as l,useCallback as o,useEffect as i}from"react";import{jsxs as a,Fragment as c,jsx as s}from"react/jsx-runtime";var u="calc_appearance";function d(){const[d,h]=r("0"),[m,k]=r(null),[b,g]=r(null),[p,v]=r(!1),[x,N]=r(""),[y,f]=r([]),[C,$]=r(!1),[j,w]=r(()=>e(u)),[L,E]=r(!1),[S,W]=r(j),B=l(null);n(o(()=>{W({...j}),E(!0)},[j]));const T=o(e=>{N(""),h(t=>p||"0"===t?(v(!1),"."===e?"0.":e):"."===e&&t.includes(".")?t:t+e)},[p]),A=o(()=>{h("0"),k(null),g(null),v(!1)},[]),F=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}},[]),J=o(e=>{const t=parseFloat(d);if(null!==m&&b&&!p){const e=F(m,t,b);h(String(e)),k(e),f(n=>[`${m} ${b} ${t} = ${e}`,...n].slice(0,20))}else k(t);g(e),v(!0)},[d,m,b,p,F]),M=o(()=>{if(null===m||!b)return;const e=parseFloat(d),t=F(m,e,b),n=`${m} ${b} ${e} =`;f(e=>[`${n} ${t}`,...e].slice(0,20)),N(n),h(String(t)),k(null),g(null),v(!0)},[d,m,b,F]),D=o(()=>{h(e=>String(parseFloat(e)/100))},[]),O=o(()=>{h(e=>e.startsWith("-")?e.slice(1):"0"===e?e:"-"+e)},[]);i(()=>{const e=e=>{const t=e.target.tagName;"INPUT"!==t&&"TEXTAREA"!==t&&"SELECT"!==t&&(e.key>="0"&&e.key<="9"?T(e.key):"."===e.key?T("."):"+"===e.key?J("+"):"-"===e.key?J("-"):"*"===e.key?J("×"):"/"===e.key?(e.preventDefault(),J("÷")):"Enter"===e.key||"="===e.key?("Enter"===e.key&&e.target instanceof Node&&B.current?.contains(e.target)&&e.preventDefault(),M()):"Escape"===e.key?A():"Backspace"===e.key?h(e=>e.length>1?e.slice(0,-1):"0"):"%"===e.key&&D())};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[T,J,M,A,D]);const Q="flex items-center justify-center rounded-lg text-sm font-medium transition-colors",X=`${Q} bg-white border border-gray-200 text-gray-900 hover:bg-gray-50 active:bg-gray-100`,H=`${Q} bg-blue-50 border border-blue-200 text-blue-700 hover:bg-blue-100 active:bg-blue-200`,I=`${Q} bg-gray-100 border border-gray-200 text-gray-600 hover:bg-gray-200 active:bg-gray-300`,P=`${Q} bg-blue-600 text-white hover:bg-blue-700 active:bg-blue-800`;/* @__PURE__ */
|
|
2
2
|
return a(c,{children:[
|
|
3
|
-
/* @__PURE__ */a("div",{ref:
|
|
3
|
+
/* @__PURE__ */a("div",{ref:B,className:"flex flex-col h-full",style:{opacity:j.activeOpacity/100,backdropFilter:j.activeBlur>0?`blur(${j.activeBlur}px)`:void 0},children:[
|
|
4
4
|
/* @__PURE__ */a("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
5
|
/* @__PURE__ */s("div",{className:"flex flex-col justify-end flex-1 overflow-hidden",children:y.slice(0,3).reverse().map((e,t)=>/* @__PURE__ */s("div",{className:"text-[11px] text-slate-400 text-right font-mono truncate",children:e},t))}),(x||b&&null!==m)&&/* @__PURE__ */s("div",{className:"text-base text-slate-600 text-right font-mono",children:x||`${m} ${b} ${p?"":d}`}),
|
|
6
6
|
/* @__PURE__ */a("div",{className:"flex items-center gap-2",children:[
|
|
7
7
|
/* @__PURE__ */s("button",{onClick:()=>{navigator.clipboard.writeText(d),$(!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__ */s("svg",C?{className:"h-5 w-5 text-green-500",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:/* @__PURE__ */s("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 13l4 4L19 7"})}:{className:"h-5 w-5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:/* @__PURE__ */s("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z"})})}),
|
|
8
8
|
/* @__PURE__ */s("div",{className:"text-right text-4xl font-mono font-bold text-slate-800 truncate flex-1",children:(e=>{const t=parseFloat(e);return isNaN(t)||e.endsWith(".")||e.endsWith(".0")||Math.abs(t)<1e15&&e.length<16?e:t.toExponential(6)})(d)})]})]}),
|
|
9
9
|
/* @__PURE__ */a("div",{className:"grid grid-cols-4 grid-rows-5 gap-1.5 flex-1 min-h-0 p-2",children:[
|
|
10
|
-
/* @__PURE__ */s("button",{onClick:
|
|
11
|
-
/* @__PURE__ */s("button",{onClick:
|
|
12
|
-
/* @__PURE__ */s("button",{onClick:
|
|
13
|
-
/* @__PURE__ */s("button",{onClick:()=>
|
|
14
|
-
/* @__PURE__ */s("button",{onClick:()=>T("7"),className:
|
|
15
|
-
/* @__PURE__ */s("button",{onClick:()=>T("8"),className:
|
|
16
|
-
/* @__PURE__ */s("button",{onClick:()=>T("9"),className:
|
|
17
|
-
/* @__PURE__ */s("button",{onClick:()=>
|
|
18
|
-
/* @__PURE__ */s("button",{onClick:()=>T("4"),className:
|
|
19
|
-
/* @__PURE__ */s("button",{onClick:()=>T("5"),className:
|
|
20
|
-
/* @__PURE__ */s("button",{onClick:()=>T("6"),className:
|
|
21
|
-
/* @__PURE__ */s("button",{onClick:()=>
|
|
22
|
-
/* @__PURE__ */s("button",{onClick:()=>T("1"),className:
|
|
23
|
-
/* @__PURE__ */s("button",{onClick:()=>T("2"),className:
|
|
24
|
-
/* @__PURE__ */s("button",{onClick:()=>T("3"),className:
|
|
25
|
-
/* @__PURE__ */s("button",{onClick:()=>
|
|
26
|
-
/* @__PURE__ */s("button",{onClick:()=>T("0"),className:`${
|
|
27
|
-
/* @__PURE__ */s("button",{onClick:()=>T("."),className:
|
|
28
|
-
/* @__PURE__ */s("button",{onClick:
|
|
29
|
-
/* @__PURE__ */s(t,{open:
|
|
10
|
+
/* @__PURE__ */s("button",{onClick:A,className:I,children:"AC"}),
|
|
11
|
+
/* @__PURE__ */s("button",{onClick:O,className:I,children:"+/−"}),
|
|
12
|
+
/* @__PURE__ */s("button",{onClick:D,className:I,children:"%"}),
|
|
13
|
+
/* @__PURE__ */s("button",{onClick:()=>J("÷"),className:`${H} ${"÷"===b?"ring-2 ring-blue-400":""}`,children:"÷"}),
|
|
14
|
+
/* @__PURE__ */s("button",{onClick:()=>T("7"),className:X,children:"7"}),
|
|
15
|
+
/* @__PURE__ */s("button",{onClick:()=>T("8"),className:X,children:"8"}),
|
|
16
|
+
/* @__PURE__ */s("button",{onClick:()=>T("9"),className:X,children:"9"}),
|
|
17
|
+
/* @__PURE__ */s("button",{onClick:()=>J("×"),className:`${H} ${"×"===b?"ring-2 ring-blue-400":""}`,children:"×"}),
|
|
18
|
+
/* @__PURE__ */s("button",{onClick:()=>T("4"),className:X,children:"4"}),
|
|
19
|
+
/* @__PURE__ */s("button",{onClick:()=>T("5"),className:X,children:"5"}),
|
|
20
|
+
/* @__PURE__ */s("button",{onClick:()=>T("6"),className:X,children:"6"}),
|
|
21
|
+
/* @__PURE__ */s("button",{onClick:()=>J("-"),className:`${H} ${"-"===b?"ring-2 ring-blue-400":""}`,children:"−"}),
|
|
22
|
+
/* @__PURE__ */s("button",{onClick:()=>T("1"),className:X,children:"1"}),
|
|
23
|
+
/* @__PURE__ */s("button",{onClick:()=>T("2"),className:X,children:"2"}),
|
|
24
|
+
/* @__PURE__ */s("button",{onClick:()=>T("3"),className:X,children:"3"}),
|
|
25
|
+
/* @__PURE__ */s("button",{onClick:()=>J("+"),className:`${H} ${"+"===b?"ring-2 ring-blue-400":""}`,children:"+"}),
|
|
26
|
+
/* @__PURE__ */s("button",{onClick:()=>T("0"),className:`${X} col-span-2`,children:"0"}),
|
|
27
|
+
/* @__PURE__ */s("button",{onClick:()=>T("."),className:X,children:"."}),
|
|
28
|
+
/* @__PURE__ */s("button",{onClick:M,className:P,children:"="})]})]}),
|
|
29
|
+
/* @__PURE__ */s(t,{open:L,onClose:()=>E(!1),title:"Calculator Settings",appearance:S,onAppearanceChange:W,onSave:()=>{w(S),localStorage.setItem(u,JSON.stringify(S)),E(!1)}})]})}export{d 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-JLPJBO7K.js";import{useWidgetSettings as r}from"./chunk-LW27IM3S.js";import"./chunk-A7Q4BCPI.js";import"./chunk-DSSLOQDW.js";import"./chunk-5A7MWTXX.js";import"./chunk-JYLI2WXW.js";import"./chunk-6KO2U66R.js";import"./chunk-M4DB7UBZ.js";import"./chunk-N3ZXQE4M.js";import"./chunk-AFYQTVZO.js";import"./chunk-HZZNJHRH.js";import"./chunk-X4FJ54PP.js";import"./chunk-NCQLGQYR.js";import"./chunk-D65T4H6J.js";import{useState as a,useCallback as n,useEffect as s}from"react";import{jsxs as c,Fragment as o,jsx as i}from"react/jsx-runtime";var l=["USD","CNY","AUD","GBP","EUR","JPY","CAD","THB","NZD","SGD","HKD","CHF","KRW","INR","MXN","BRL"],m=[["USD","CNY"],["USD","AUD"],["GBP","USD"],["USD","JPY"]],u="currency_pairs",p="currency_appearance",d="currency_rates_cache";function h(e){try{const t=JSON.parse(localStorage.getItem(d)||"{}")[e];if(t&&Date.now()-t.timestamp<36e5)return t.rates}catch{}return null}function g(e,t){try{const r=JSON.parse(localStorage.getItem(d)||"{}");r[e]={rates:t,timestamp:Date.now()},localStorage.setItem(d,JSON.stringify(r))}catch{}}function x(){try{const e=JSON.parse(localStorage.getItem(u)||"");if(Array.isArray(e)&&e.length)return e.slice(0,4)}catch{}return m}var y={USD:"🇺🇸",CNY:"🇨🇳",AUD:"🇦🇺",GBP:"🇬🇧",JPY:"🇯🇵",CAD:"🇨🇦",EUR:"🇪🇺",THB:"🇹🇭",NZD:"🇳🇿",SGD:"🇸🇬",HKD:"🇭🇰",CHF:"🇨🇭",KRW:"🇰🇷",INR:"🇮🇳",MXN:"🇲🇽",BRL:"🇧🇷"};function f(){const[m,d]=a(x),[f,N]=a(()=>e(p)),[b,v]=a({}),[S,D]=a(!1),[k,C]=a(!1),[j,J]=a([]),[B,U]=a(f),[A,I]=a("USD"),[L,O]=a("CNY");r(n(()=>{J([...m]),U({...f}),C(!0)},[m,f])),s(()=>{const e=[...new Set(m.map(([e])=>e))];let t=!0;return async function(){D(!0);const r={};for(const t of e){const e=h(t);if(e)r[t]=e;else try{const e=await fetch(`https://open.er-api.com/v6/latest/${t}`),a=await e.json();a.rates&&(r[t]=a.rates,g(t,a.rates))}catch{}}t&&(v(r),D(!1))}(),()=>{t=!1}},[m]);/* @__PURE__ */
|
|
2
2
|
return c(o,{children:[
|
|
3
3
|
/* @__PURE__ */i("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__ */c("div",{className:"px-4 py-3 space-y-1",children:[S&&/* @__PURE__ */i("div",{className:"text-xs text-gray-400 text-center py-4",children:"Loading rates..."}),m.map(([e,t],r)=>{const a=b[e]?.[t];/* @__PURE__ */
|
|
4
4
|
return c("button",{onClick:()=>{const e=m.map((e,t)=>t===r?[e[1],e[0]]:e);d(e),localStorage.setItem(u,JSON.stringify(e))},className:"flex items-center justify-between px-2 py-2 border-b border-gray-200 last:border-0 w-full hover:bg-gray-100 rounded transition-colors cursor-pointer",children:[
|
|
@@ -9,13 +9,13 @@ return c("button",{onClick:()=>{const e=m.map((e,t)=>t===r?[e[1],e[0]]:e);d(e),l
|
|
|
9
9
|
/* @__PURE__ */i("span",{className:"text-base",children:y[t]||""}),
|
|
10
10
|
/* @__PURE__ */i("span",{className:"text-sm font-semibold text-gray-700",children:t})]}),
|
|
11
11
|
/* @__PURE__ */i("div",{className:"text-base font-mono font-semibold text-gray-900 tabular-nums",children:null!=a?a.toLocaleString(void 0,{minimumFractionDigits:2,maximumFractionDigits:4}):"—"})]},`${e}-${t}-${r}`)})]})}),
|
|
12
|
-
/* @__PURE__ */i(t,{open:k,onClose:()=>C(!1),title:"Currency Settings",appearance:B,onAppearanceChange:
|
|
12
|
+
/* @__PURE__ */i(t,{open:k,onClose:()=>C(!1),title:"Currency Settings",appearance:B,onAppearanceChange:U,onSave:()=>{if(0===j.length)return;const e=j.slice(0,4);d(e),N(B),localStorage.setItem(u,JSON.stringify(e)),localStorage.setItem(p,JSON.stringify(B)),C(!1)},children:/* @__PURE__ */c("div",{children:[
|
|
13
13
|
/* @__PURE__ */c("h3",{className:"text-sm font-semibold text-gray-700 mb-2",children:["Currency Pairs ",
|
|
14
14
|
/* @__PURE__ */c("span",{className:"text-[11px] font-normal text-gray-400",children:["(",j.length,"/",4,")"]})]}),
|
|
15
15
|
/* @__PURE__ */i("div",{className:"space-y-1 mb-2",children:j.map(([e,t],r)=>/* @__PURE__ */c("div",{className:"flex items-center justify-between py-1 px-2 bg-gray-50 rounded",children:[
|
|
16
16
|
/* @__PURE__ */c("span",{className:"text-sm",children:[y[e]||""," ",e," → ",y[t]||""," ",t]}),
|
|
17
|
-
/* @__PURE__ */i("button",{onClick:()=>
|
|
18
|
-
/* @__PURE__ */i("select",{value:
|
|
17
|
+
/* @__PURE__ */i("button",{onClick:()=>J(e=>e.filter((e,t)=>t!==r)),className:"text-red-400 hover:text-red-600",children:"×"})]},r))}),j.length<4?/* @__PURE__ */c("div",{className:"flex items-center gap-2",children:[
|
|
18
|
+
/* @__PURE__ */i("select",{value:A,onChange:e=>I(e.target.value),className:"bg-gray-50 border border-gray-200 rounded px-2 py-1 text-sm focus:outline-none focus:ring-1 focus:ring-blue-500",children:l.map(e=>/* @__PURE__ */i("option",{children:e},e))}),
|
|
19
19
|
/* @__PURE__ */i("span",{className:"text-gray-400",children:"→"}),
|
|
20
|
-
/* @__PURE__ */i("select",{value:
|
|
21
|
-
/* @__PURE__ */i("button",{onClick:()=>{
|
|
20
|
+
/* @__PURE__ */i("select",{value:L,onChange:e=>O(e.target.value),className:"bg-gray-50 border border-gray-200 rounded px-2 py-1 text-sm focus:outline-none focus:ring-1 focus:ring-blue-500",children:l.map(e=>/* @__PURE__ */i("option",{children:e},e))}),
|
|
21
|
+
/* @__PURE__ */i("button",{onClick:()=>{A!==L&&j.length<4&&J(e=>[...e,[A,L]])},className:"text-sm font-medium text-blue-600 hover:text-blue-800 px-2",children:"+ Add"})]}):/* @__PURE__ */c("p",{className:"text-[11px] text-gray-400 italic",children:["Max ",4," pairs — remove one to add another."]})]})})]})}export{f as default};
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import{escapeHtml as e}from"./chunk-BR22X7E5.js";import{AboutApp as t}from"./chunk-
|
|
1
|
+
import{escapeHtml as e}from"./chunk-BR22X7E5.js";import{AboutApp as t}from"./chunk-6MBERZOS.js";import{toast_default as n}from"./chunk-KSSAVLO7.js";import"./chunk-7U3F53IG.js";import{WindowTitle as r}from"./chunk-LW27IM3S.js";import"./chunk-A7Q4BCPI.js";import"./chunk-DSSLOQDW.js";import"./chunk-5A7MWTXX.js";import"./chunk-JYLI2WXW.js";import"./chunk-6KO2U66R.js";import"./chunk-M4DB7UBZ.js";import{PopupMenu as o,PopupMenuLabel as l,PopupMenuItem as a,PopupMenuDivider as i}from"./chunk-N3ZXQE4M.js";import"./chunk-AFYQTVZO.js";import"./chunk-HZZNJHRH.js";import"./chunk-X4FJ54PP.js";import"./chunk-NCQLGQYR.js";import"./chunk-D65T4H6J.js";import{useState as s,useRef as c}from"react";import{jsxs as d,jsx as h}from"react/jsx-runtime";var m=/* @__PURE__ */new Set(["txt","md","markdown","csv","tsv","log","json","xml","html","htm","css","js","jsx","ts","tsx","py","rb","go","rs","java","c","h","cpp","hpp","sh","bash","yml","yaml","toml","ini","conf","env","sql"]),u=/* @__PURE__ */new Set(["docx"]),p={filename:"Untitled",kind:"docx",content:"",ext:"docx"};function g(){const[g,x]=s(p),[f,y]=s(!1),[v,b]=s(!1),[k,w]=s(!1),[N,C]=s(null),j=c(null),D=c(null),L=c(null),M=(e,t)=>{L.current?.focus(),document.execCommand(e,!1,t),w(!0)},U=e=>{for(const t of e){if(!t.type.startsWith("image/"))continue;const e=new FileReader;e.onload=()=>{L.current?.focus(),document.execCommand("insertImage",!1,String(e.result)),w(!0)},e.readAsDataURL(t)}},R=e=>{N&&(N.el.removeAttribute("width"),N.el.removeAttribute("height"),N.el.style.width=e??"",N.el.style.height=e?"auto":"",w(!0),C(null))},B=async t=>{const r=(t.name.split(".").pop()||"").toLowerCase();y(!0);try{if(m.has(r)||!u.has(r)&&t.type.startsWith("text/")){const n=await t.text(),o=e(n).replace(/\n/g,"<br>");x({filename:t.name,kind:"text",content:o,ext:r}),w(!1)}else if(u.has(r))try{const e=await(import(
|
|
2
2
|
/* @vite-ignore */
|
|
3
|
-
"mammoth")),n=await t.arrayBuffer(),o=await e.convertToHtml({arrayBuffer:n});x({filename:t.name,kind:"docx",content:o.value||"<p><em>(empty document)</em></p>",ext:r}),w(!1)}catch(e){n.error('Install the optional "mammoth" peer dep to read .docx files.')}else"doc"===r?n.error(".doc is the legacy Word binary format — convert to .docx first."):n.error(`Unsupported file type: .${r||"unknown"}`)}finally{y(!1)}},
|
|
4
|
-
return d("div",{className:"relative flex flex-col h-full",onDragOver:e=>{e.preventDefault(),v||b(!0)},onDragLeave:e=>{e.currentTarget===e.target&&b(!1)},onDrop:e=>{e.preventDefault(),b(!1);const t=Array.from(e.dataTransfer.files??[]);0!==t.length&&(t.every(e=>e.type.startsWith("image/"))?U(t):
|
|
5
|
-
/* @__PURE__ */h(r,{title:`${
|
|
3
|
+
"mammoth")),n=await t.arrayBuffer(),o=await e.convertToHtml({arrayBuffer:n});x({filename:t.name,kind:"docx",content:o.value||"<p><em>(empty document)</em></p>",ext:r}),w(!1)}catch(e){n.error('Install the optional "mammoth" peer dep to read .docx files.')}else"doc"===r?n.error(".doc is the legacy Word binary format — convert to .docx first."):n.error(`Unsupported file type: .${r||"unknown"}`)}finally{y(!1)}},W=g?.filename?(A=g.filename).length>24?`${A.slice(0,23)}…`:A:"Untitled";var A;/* @__PURE__ */
|
|
4
|
+
return d("div",{className:"relative flex flex-col h-full",onDragOver:e=>{e.preventDefault(),v||b(!0)},onDragLeave:e=>{e.currentTarget===e.target&&b(!1)},onDrop:e=>{e.preventDefault(),b(!1);const t=Array.from(e.dataTransfer.files??[]);0!==t.length&&(t.every(e=>e.type.startsWith("image/"))?U(t):B(t[0]))},children:[
|
|
5
|
+
/* @__PURE__ */h(r,{title:`${W}${k?" •":""} - Documents`}),
|
|
6
6
|
/* @__PURE__ */h(t,{app:"documents"}),
|
|
7
7
|
/* @__PURE__ */d("div",{className:"flex items-center flex-wrap gap-x-2 gap-y-1 px-3 py-2 border-b border-gray-200 bg-gray-50 shrink-0",children:[
|
|
8
|
-
/* @__PURE__ */h("input",{ref:j,type:"file",accept:".txt,.md,.csv,.tsv,.log,.json,.xml,.html,.htm,.css,.js,.jsx,.ts,.tsx,.py,.rb,.go,.rs,.java,.c,.h,.cpp,.hpp,.sh,.bash,.yml,.yaml,.toml,.ini,.conf,.env,.sql,.docx,text/*",onChange:e=>{const t=e.target.files?.[0];t&&
|
|
8
|
+
/* @__PURE__ */h("input",{ref:j,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),j.current&&(j.current.value="")},className:"hidden"}),
|
|
9
9
|
/* @__PURE__ */d("button",{onClick:()=>j.current?.click(),className:"text-xs text-gray-700 hover:text-gray-900 px-2 py-1 rounded hover:bg-gray-200 transition-colors flex items-center gap-1",children:[
|
|
10
10
|
/* @__PURE__ */h("svg",{className:"h-3.5 w-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.5,children:/* @__PURE__ */h("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M3.75 9.776c.112-.017.227-.026.344-.026h15.812c.117 0 .232.009.344.026m-16.5 0a2.25 2.25 0 00-1.883 2.542l.857 6a2.25 2.25 0 002.227 1.932H19.05a2.25 2.25 0 002.227-1.932l.857-6a2.25 2.25 0 00-1.883-2.542m-16.5 0V6A2.25 2.25 0 016 3.75h3.879a1.5 1.5 0 011.06.44l2.122 2.12a1.5 1.5 0 001.06.44H18A2.25 2.25 0 0120.25 9v.776"})}),"Open"]}),
|
|
11
11
|
/* @__PURE__ */h("button",{onClick:()=>{if(!g)return;const t=L.current?.innerHTML??"";if("text"===g.kind){if(/<(b|strong|i|em|u|font|span style|ul|ol|img)|style="[^"]*text-align/i.test(t)){const n=new Blob([`<!doctype html><meta charset="utf-8"><title>${e(g.filename)}</title><body style="font-family:ui-monospace,monospace;white-space:pre-wrap">${t}`],{type:"text/html"}),r=URL.createObjectURL(n),o=document.createElement("a");o.href=r,o.download=`${g.filename.replace(/\.[^.]+$/,"")}.html`,o.click(),URL.revokeObjectURL(r)}else{const e=L.current?.innerText??"",t=new Blob([e],{type:"text/plain"}),n=URL.createObjectURL(t),r=document.createElement("a");r.href=n,r.download=g.filename,r.click(),URL.revokeObjectURL(n)}}else{const n=new Blob([`<!doctype html><meta charset="utf-8"><title>${e(g.filename)}</title>${t}`],{type:"text/html"}),r=URL.createObjectURL(n),o=document.createElement("a");o.href=r,o.download=`${g.filename.replace(/\.docx$/i,"")}.html`,o.click(),URL.revokeObjectURL(r)}},className:"text-xs text-gray-700 hover:text-gray-900 px-2 py-1 rounded hover:bg-gray-200 transition-colors",children:"Save"}),
|
|
@@ -43,10 +43,10 @@ return d("div",{className:"relative flex flex-col h-full",onDragOver:e=>{e.preve
|
|
|
43
43
|
/* @__PURE__ */h("svg",{className:"h-3.5 w-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.5,children:/* @__PURE__ */h("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M2.25 15.75l5.159-5.159a2.25 2.25 0 013.182 0l5.159 5.159m-1.5-1.5l1.409-1.409a2.25 2.25 0 013.182 0l2.909 2.909m-18 3.75h16.5a1.5 1.5 0 001.5-1.5V6a1.5 1.5 0 00-1.5-1.5H3.75A1.5 1.5 0 002.25 6v12a1.5 1.5 0 001.5 1.5zm10.5-11.25h.008v.008h-.008V8.25zm.375 0a.375.375 0 11-.75 0 .375.375 0 01.75 0z"})}),"Image"]})]}),
|
|
44
44
|
/* @__PURE__ */h("div",{className:"flex-1 min-h-0 overflow-hidden",children:/* @__PURE__ */h("div",f?{className:"flex items-center justify-center h-full text-sm text-gray-400",children:"Loading…"}:{className:"h-full overflow-auto "+("docx"===g.kind?"bg-gray-100 px-6 py-8":"bg-white"),children:/* @__PURE__ */h("div",{ref:L,contentEditable:!0,suppressContentEditableWarning:!0,spellCheck:!1,onInput:()=>w(!0),onPaste:e=>{const t=Array.from(e.clipboardData?.items??[]).filter(e=>"file"===e.kind&&e.type.startsWith("image/")).map(e=>e.getAsFile()).filter(e=>!!e);t.length&&(e.preventDefault(),U(t))},onClick:e=>{const t=e.target;"IMG"===t.tagName&&(e.preventDefault(),C({x:e.clientX,y:e.clientY,el:t}))},dangerouslySetInnerHTML:{__html:g.content},className:"docx"===g.kind?"docs-editor mx-auto w-[8.5in] min-h-[11in] bg-white p-[1in] shadow text-[14px] leading-relaxed text-gray-800 outline-none focus:ring-2 focus:ring-blue-400/40":"docs-editor block w-full min-h-full p-4 font-mono text-[13px] leading-relaxed text-gray-800 bg-white outline-none whitespace-pre-wrap"})})}),v&&/* @__PURE__ */h("div",{className:"absolute inset-0 bg-blue-500/15 border-4 border-dashed border-blue-500 pointer-events-none flex items-center justify-center z-20",children:/* @__PURE__ */h("div",{className:"px-4 py-2 rounded-md bg-blue-600 text-white text-sm font-medium shadow-lg",children:"Drop a document to open · images insert into the page"})}),N&&/* @__PURE__ */d(o,{minWidth:150,style:{left:N.x,top:N.y},onClose:()=>C(null),children:[
|
|
45
45
|
/* @__PURE__ */h(l,{children:"Image width"}),
|
|
46
|
-
/* @__PURE__ */h(a,{onClick:()=>
|
|
47
|
-
/* @__PURE__ */h(a,{onClick:()=>
|
|
48
|
-
/* @__PURE__ */h(a,{onClick:()=>
|
|
49
|
-
/* @__PURE__ */h(a,{onClick:()=>
|
|
50
|
-
/* @__PURE__ */h(a,{onClick:()=>
|
|
46
|
+
/* @__PURE__ */h(a,{onClick:()=>R("25%"),children:"25%"}),
|
|
47
|
+
/* @__PURE__ */h(a,{onClick:()=>R("50%"),children:"50%"}),
|
|
48
|
+
/* @__PURE__ */h(a,{onClick:()=>R("75%"),children:"75%"}),
|
|
49
|
+
/* @__PURE__ */h(a,{onClick:()=>R("100%"),children:"100%"}),
|
|
50
|
+
/* @__PURE__ */h(a,{onClick:()=>R(null),children:"Original size"}),
|
|
51
51
|
/* @__PURE__ */h(i,{}),
|
|
52
52
|
/* @__PURE__ */h(a,{danger:!0,onClick:()=>{N?.el.remove(),w(!0),C(null)},children:"Remove image"})]})]})}export{g as default};
|