efficient-shell 5.1.0 → 5.2.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 +70 -1
- package/dist/{Browser-WUVL7ZSM.js → Browser-FKZ6M2MK.js} +17 -17
- package/dist/Calculator-LBFBTFSD.js +29 -0
- package/dist/ConfirmDialog-JAEFVRJM.js +1 -0
- package/dist/{CurrencyConverter-LF2WHJW4.js → CurrencyConverter-OV5ZQIAJ.js} +6 -6
- package/dist/{Documents-MB4TJGNY.js → Documents-HGGL3AWI.js} +8 -8
- package/dist/Files-DAQKIF6W.js +87 -0
- package/dist/{Notepad-UQSG5BE3.js → Notepad-PO724TVP.js} +11 -11
- package/dist/PdfViewer-6ALXGVTV.js +1 -0
- package/dist/{PomodoroTimer-XARF7DO3.js → PomodoroTimer-LN5MYRZO.js} +20 -20
- package/dist/{Preview-LETK6AJS.js → Preview-CUOO5WQ7.js} +9 -9
- package/dist/Sidebar-T4ABK2WV.js +44 -0
- package/dist/{Spreadsheet-RCHOM2RE.js → Spreadsheet-2N2JXBCY.js} +14 -14
- package/dist/{Stock-25FQMI2G.js → Stock-65WVUGLI.js} +4 -4
- package/dist/{Weather-KLQ55R64.js → Weather-TXJICMJN.js} +15 -15
- package/dist/{WorldClock-RMPU7D2M.js → WorldClock-RIHLKZGC.js} +6 -6
- package/dist/apps/index.js +1 -1
- package/dist/bin/ui-check.js +1 -1
- package/dist/brand.css +1 -1
- package/dist/{chunk-FA6E75W5.js → chunk-3PTA2C74.js} +1 -1
- package/dist/chunk-4QBLTEFU.js +1 -0
- package/dist/{chunk-GPNNQIRY.js → chunk-6GV4467L.js} +1 -1
- package/dist/chunk-AJB5G52B.js +1 -0
- package/dist/{chunk-2KTBZE5F.js → chunk-ASSDCWKP.js} +1 -1
- package/dist/{chunk-LY2G6LHW.js → chunk-BFFXVA53.js} +1 -1
- package/dist/{chunk-4KLBITSY.js → chunk-BFUBBDU6.js} +11 -11
- package/dist/{chunk-JK2KQ4PF.js → chunk-H3UEYXRA.js} +1 -1
- package/dist/{chunk-ZDF5AR5W.js → chunk-HIAHERCD.js} +7 -7
- package/dist/{chunk-XUF7VW4U.js → chunk-JJIPGAXI.js} +29 -28
- package/dist/{chunk-HKLW5KTW.js → chunk-KHJ5XSEH.js} +8 -8
- package/dist/{chunk-DXNCJBGY.js → chunk-M4OGNYOM.js} +6 -6
- package/dist/{chunk-P4SGJTK3.js → chunk-ML22KF7T.js} +1 -1
- package/dist/{chunk-VOY6TCS2.js → chunk-MTH7EAH3.js} +20 -20
- package/dist/{chunk-N3W6PH55.js → chunk-OTP5WPI4.js} +11 -11
- package/dist/chunk-PS6PSCOR.js +1018 -0
- package/dist/{chunk-5LCZFVE4.js → chunk-QZNRMJE6.js} +2 -2
- package/dist/{chunk-XNHYCOPO.js → chunk-R3622MOL.js} +1 -1
- package/dist/{chunk-2TP4GK53.js → chunk-SSBOC52S.js} +6 -6
- package/dist/{chunk-DBB4DB7J.js → chunk-TKFAFZRY.js} +1 -1
- package/dist/{chunk-TMZVVRTA.js → chunk-TLTFS2D6.js} +58 -58
- package/dist/{chunk-6TCHOT4R.js → chunk-UAJQB45Y.js} +1 -1
- package/dist/{chunk-H5NEXQTX.js → chunk-UG4ZPXXU.js} +1 -1
- package/dist/{chunk-LTGIQ7HO.js → chunk-Y553QKEH.js} +14 -14
- package/dist/{chunk-MDI265RK.js → chunk-YJ6JMGMS.js} +1 -1
- package/dist/{chunk-LMIQV3NB.js → chunk-YQI7KXX3.js} +2 -2
- package/dist/file-intake/index.js +1 -1
- package/dist/i18n/index.d.ts +1 -1
- package/dist/{index-CzMz_Y9A.d.ts → index-Dk5VKml6.d.ts} +264 -2
- package/dist/index.d.ts +3 -3
- package/dist/index.js +488 -488
- package/dist/locales/zh-Hans.d.ts +1 -1
- package/dist/locales/zh-Hans.js +1 -1
- package/dist/map/index.js +6 -6
- package/dist/markdown/index.js +1 -1
- package/dist/page-tabs/index.js +5 -5
- package/dist/pdf/index.js +1 -1
- package/dist/{strings-BEuOOURI.d.ts → strings-aKfRDZWB.d.ts} +35 -0
- package/dist/ui/index.d.ts +2 -2
- package/dist/ui/index.js +1 -1
- package/dist/ui.css +63 -0
- package/package.json +1 -1
- package/dist/Calculator-E2CBADVF.js +0 -29
- package/dist/ConfirmDialog-ZM364NPI.js +0 -1
- package/dist/Files-JQYIBZEP.js +0 -87
- package/dist/PdfViewer-4VGNBBED.js +0 -1
- package/dist/Sidebar-VR4QYFQU.js +0 -44
- package/dist/chunk-3JK2LSFU.js +0 -1
- package/dist/chunk-LOXV3J6X.js +0 -1005
- package/dist/chunk-OBMR6BEP.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`, `ImageFocusPoint`, `Tree`, `SortableList`, `IconRail`, `ResizeHandle`
|
|
585
|
+
### Editor controls — `Slider`, `ColorPicker`, `ImageFocusPoint`, `LinkPicker`, `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
|
|
@@ -676,6 +676,49 @@ no open state: the host decides when it is on screen. The maths is exported
|
|
|
676
676
|
too: `parseFocal`, `formatFocal`, `nudgeFocal`, `focalFromRect`,
|
|
677
677
|
`FOCAL_DEFAULT`, `FOCAL_NUDGE_STEP`, `FOCAL_NUDGE_COARSE`.
|
|
678
678
|
|
|
679
|
+
**`LinkPicker`** says where a link goes. It is one part with two modes.
|
|
680
|
+
|
|
681
|
+
```tsx
|
|
682
|
+
// Field: every choice is written at once.
|
|
683
|
+
<LinkPicker label="Button link" value={url} onChange={(url, name) => save(url)}
|
|
684
|
+
kinds={kinds} rules={rules} filtersFor={filtersFor} />
|
|
685
|
+
|
|
686
|
+
// Window: nothing is written until Apply.
|
|
687
|
+
<LinkPicker value={href} onApply={(url) => setLink(url)} onCancel={close}
|
|
688
|
+
onRemove={href ? removeLink : undefined} />
|
|
689
|
+
|
|
690
|
+
// A button's words and its link in one box.
|
|
691
|
+
<TextLinkField label="Button" text={text} onTextChange={setText}
|
|
692
|
+
link={url} onLinkChange={setUrl} kinds={kinds} rules={rules} />
|
|
693
|
+
```
|
|
694
|
+
|
|
695
|
+
`kinds` is the Link type list (Page, Anchor, Blog post, Product, Custom URL —
|
|
696
|
+
whatever the host offers). Each kind has a target: a list, a list in groups, or
|
|
697
|
+
a typed address (`target: { type: 'text' }`). With no `kinds` the part is one
|
|
698
|
+
address box and no type list. `rules` is how the host reads and writes its own
|
|
699
|
+
URLs (`kindOf`, `targetOf`, `readFilter`, `withFilter`, and `isSafe`). The part
|
|
700
|
+
holds no URL rule of its own. `filtersFor` gives the Filter and Value boxes for
|
|
701
|
+
a product listing. A list over 10 options becomes a `SearchableSelect`.
|
|
702
|
+
`onChange` and `onApply` get the picked thing's name as a second argument, so a
|
|
703
|
+
host can fill a label with it.
|
|
704
|
+
|
|
705
|
+
A saved link is never changed just by opening it. A target, filter or value the
|
|
706
|
+
host no longer offers shows as "(unavailable)" and is kept. A kind the author
|
|
707
|
+
picks wins over what the URL looks like, until the link changes from outside
|
|
708
|
+
(Undo). A typed address that fails `isSafe` is refused with the reason: the
|
|
709
|
+
field says it while typing, the window says it on Apply. Without `isSafe` the
|
|
710
|
+
part uses **`isSafeLinkHref`**, the kit's one address rule: `http`, `https`,
|
|
711
|
+
`mailto`, `tel`, or no scheme; never a space or a control character.
|
|
712
|
+
`MarkdownLite` uses the same rule.
|
|
713
|
+
|
|
714
|
+
The window is a `role="dialog"`. The address box gets the caret, with the text
|
|
715
|
+
selected. Enter applies. Escape (from inside the window) and Cancel call
|
|
716
|
+
`onCancel`. Remove shows only when `onRemove` is given. `className` lets a host
|
|
717
|
+
place it (the text toolbar floats it under its buttons). `TextLinkField` is the
|
|
718
|
+
kit `Input` on top and a link row under it, in one box. The row opens the
|
|
719
|
+
window under the box, in the panel's own flow. Words come from the `link`
|
|
720
|
+
section of the strings catalogue; `placeholder` sets the address box's text.
|
|
721
|
+
|
|
679
722
|
**`Tree`**, **`TreeRow`**, **`TreeGroup`**, **`TreeGroupLabel`**,
|
|
680
723
|
**`TreeEmptySlot`** and **`TreeSeam`** draw a layers panel or an outline. They follow the WAI-ARIA
|
|
681
724
|
tree pattern.
|
|
@@ -1535,6 +1578,32 @@ are a person's own choice, so they win over the host's theme, the way a chosen
|
|
|
1535
1578
|
colour theme does. Do not write literal radii (an arbitrary-value radius class,
|
|
1536
1579
|
an inline `borderRadius`): they are the one thing the setting cannot reach.
|
|
1537
1580
|
|
|
1581
|
+
**Spacing and control height.** Every margin, padding and gap is one of ten
|
|
1582
|
+
steps: 2, 4, 8, 12, 16, 20, 24, 32, 40, 48 px — multiples of 4, with 2 kept for
|
|
1583
|
+
hairline gaps. Each lands on a Tailwind utility (`p-0.5` … `p-12`), so markup
|
|
1584
|
+
keeps writing utilities; `p-1.5` (6px) and `p-2.5` (10px) are off the scale.
|
|
1585
|
+
`ui.css` declares the steps as `--space-2` … `--space-48`, and a role per
|
|
1586
|
+
common use, so a value a utility cannot reach still comes from one place:
|
|
1587
|
+
|
|
1588
|
+
| Token | Step | Used for |
|
|
1589
|
+
|---|---|---|
|
|
1590
|
+
| `--space-icon-gap` / `--space-icon-gap-sm` | 8 / 4 | an icon to its word; inside something small |
|
|
1591
|
+
| `--space-control-x-sm` / `--space-control-x` / `--space-control-x-lg` | 8 / 12 / 16 | a control's side padding |
|
|
1592
|
+
| `--space-cell-x` | 12 | a table cell's side padding |
|
|
1593
|
+
| `--space-label` | 4 | a label to its field |
|
|
1594
|
+
| `--space-toolbar` | 8 | between toolbar buttons |
|
|
1595
|
+
| `--space-form-row` | 12 | between form rows |
|
|
1596
|
+
| `--space-card` | 16 | inside a card |
|
|
1597
|
+
| `--space-block` | 16 | between a page's big blocks |
|
|
1598
|
+
| `--space-gutter` | 16 | a page's side gutter |
|
|
1599
|
+
| `--space-panel-group` … `--space-panel-setting` | 2 / 4 / 8 / 12 / 16 (12 narrow) / 32 | an editor panel: one group, a sub-name, a setting's layers, rows, padding, between settings |
|
|
1600
|
+
|
|
1601
|
+
Buttons, fields, selects, segmented controls, filter chips and sidebar and menu
|
|
1602
|
+
rows take their height from `--control-height-sm` / `-md` / `-lg` (24 / 32 /
|
|
1603
|
+
40), not from top and bottom padding. Code takes the same numbers from
|
|
1604
|
+
`efficient-shell/ui`: `SPACING_SCALE`, `SPACING_ROLES`, `CONTROL_HEIGHTS`, and
|
|
1605
|
+
`isSpacingStep('2.5')` for a Tailwind step.
|
|
1606
|
+
|
|
1538
1607
|
**Glass.** Menus, popups, listboxes and tooltips are frosted glass
|
|
1539
1608
|
(`glassStyle()`). `--menu-opacity` (0–1, default `0.95`) sets how much shows
|
|
1540
1609
|
through. `rosh-reduce-transparency` on `<html>` makes every popup one solid
|
|
@@ -1,31 +1,31 @@
|
|
|
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-6GV4467L.js";import{WindowTitle as r}from"./chunk-TLTFS2D6.js";import"./chunk-DSSLOQDW.js";import"./chunk-UAJQB45Y.js";import"./chunk-4QBLTEFU.js";import"./chunk-SSBOC52S.js";import"./chunk-5A7MWTXX.js";import"./chunk-OGXU7QFW.js";import{confirm as a}from"./chunk-MTH7EAH3.js";import"./chunk-HIAHERCD.js";import"./chunk-AFYQTVZO.js";import"./chunk-HZZNJHRH.js";import"./chunk-X4FJ54PP.js";import"./chunk-D65T4H6J.js";import{ChevronLeftFallback as n,ChevronRightFallback as l,RefreshFallback as s,HomeFallback as i,StarFallback as c,ExternalFallback as m,HelpFallback as d,NoSymbolFallback as u}from"./chunk-JJIPGAXI.js";import"./chunk-AJB5G52B.js";import"./chunk-C3QOHMR6.js";import{Icon as h}from"./chunk-YKZHOXI4.js";import{useRef as p,useEffect as b,useState as g}from"react";import{jsxs as f,jsx as k,Fragment as x}from"react/jsx-runtime";var w="react-os-shell:browser-bookmarks",y="react-os-shell:browser-homepage",v="https://en.wikipedia.org/wiki/Main_Page",N=[{label:"Wikipedia",url:"https://en.wikipedia.org/wiki/Main_Page"},{label:"DevDocs",url:"https://devdocs.io"},{label:"Example",url:"https://example.com"}],j=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 C(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&&j.has(t[2].toLowerCase())}(t)?"https://"+t:"https://duckduckgo.com/?q="+encodeURIComponent(t):""}var z=["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 S(){if("undefined"==typeof window)return N;try{const e=localStorage.getItem(w);if(!e)return N;const t=JSON.parse(e);if(Array.isArray(t)&&t.every(e=>"string"==typeof e?.url))return t}catch{}return N}function W(){return"undefined"==typeof window?v:localStorage.getItem(y)||v}function H(){const u=p(void 0);void 0===u.current&&(u.current=e()),b(()=>{null!=u.current&&t(u.current)},[]);const x=u.current?C(u.current.url):"",[v,N]=g(W),[j,z]=g(x||v),[H,E]=g(j),[T,D]=g([j]),[O,A]=g(0),[I,F]=g(0),[J,U]=g(S),[B,P]=g(!1),[X,G]=g(null),M=p(null),Q=p(null);b(()=>{try{localStorage.setItem(w,JSON.stringify(J))}catch{}},[J]);const q=e=>{const t=C(e);t&&(z(t),E(t),D(e=>{const o=e.slice(0,O+1);return o.push(t),o}),A(e=>e+1),P(!1))},$=()=>{"undefined"!=typeof window&&window.open(j,"_blank","noopener,noreferrer")},K=()=>{const e=X?.trim();e?(U(t=>[...t,{label:e,url:j}]),G(null)):G(null)};b(()=>{if(null===X)return;M.current?.focus(),M.current?.select();const e=e=>{const t=e.target;t?.closest("[data-bookmark-popover]")||G(null)},t=setTimeout(()=>document.addEventListener("mousedown",e),0);return()=>{clearTimeout(t),document.removeEventListener("mousedown",e)}},[null!==X]);const Y=e=>{U(t=>t.filter((t,o)=>o!==e))},Z=O>0,_=O<T.length-1,V=J.some(e=>e.url===j),ee="p-1.5 rounded hover:bg-gray-200 transition-colors text-gray-600 disabled:opacity-30";/* @__PURE__ */
|
|
2
2
|
return f("div",{className:"relative flex flex-col h-full bg-white",children:[
|
|
3
|
-
/* @__PURE__ */k(r,{title:`Browser - ${
|
|
3
|
+
/* @__PURE__ */k(r,{title:`Browser - ${L(j)}`}),
|
|
4
4
|
/* @__PURE__ */k(o,{app:"browser"}),
|
|
5
5
|
/* @__PURE__ */f("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__ */k("button",{onClick:()=>{if(
|
|
7
|
-
/* @__PURE__ */k("button",{onClick:()=>{if(
|
|
8
|
-
/* @__PURE__ */k("button",{onClick:()=>
|
|
9
|
-
/* @__PURE__ */k("button",{onClick:()=>
|
|
10
|
-
/* @__PURE__ */k("form",{onSubmit:e=>{e.preventDefault(),
|
|
6
|
+
/* @__PURE__ */k("button",{onClick:()=>{if(O>0){const e=O-1;A(e),z(T[e]),E(T[e]),P(!1)}},disabled:!Z,className:ee,title:"Back",children:/* @__PURE__ */k(h,{name:"chevron-left",fallback:n,className:"h-4 w-4",strokeWidth:2})}),
|
|
7
|
+
/* @__PURE__ */k("button",{onClick:()=>{if(O<T.length-1){const e=O+1;A(e),z(T[e]),E(T[e]),P(!1)}},disabled:!_,className:ee,title:"Forward",children:/* @__PURE__ */k(h,{name:"chevron-right",fallback:l,className:"h-4 w-4",strokeWidth:2})}),
|
|
8
|
+
/* @__PURE__ */k("button",{onClick:()=>F(e=>e+1),className:ee,title:"Refresh",children:/* @__PURE__ */k(h,{name:"refresh",fallback:s,className:"h-4 w-4",strokeWidth:1.8})}),
|
|
9
|
+
/* @__PURE__ */k("button",{onClick:()=>q(v),className:ee,title:"Home",children:/* @__PURE__ */k(h,{name:"home",fallback:i,className:"h-4 w-4",strokeWidth:1.8})}),
|
|
10
|
+
/* @__PURE__ */k("form",{onSubmit:e=>{e.preventDefault(),q(H)},className:"flex-1 flex items-center mx-1",children:/* @__PURE__ */f("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__ */k("span",{className:"px-2 text-gray-400 text-xs",children:j.startsWith("https://")?"🔒":"⚠️"}),
|
|
12
|
-
/* @__PURE__ */k("input",{type:"text",value:
|
|
13
|
-
/* @__PURE__ */k("button",{"data-bookmark-popover":!0,onClick:()=>
|
|
14
|
-
/* @__PURE__ */k("button",{onClick
|
|
15
|
-
/* @__PURE__ */k("button",{onClick:()=>
|
|
12
|
+
/* @__PURE__ */k("input",{type:"text",value:H,onChange:e=>E(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…"}),j!==H&&/* @__PURE__ */k("button",{type:"button",onClick:()=>E(j),className:"px-1.5 text-[10px] text-gray-400 hover:text-gray-700",title:"Reset to current URL",children:"×"})]})}),
|
|
13
|
+
/* @__PURE__ */k("button",{"data-bookmark-popover":!0,onClick:()=>V?Y(J.findIndex(e=>e.url===j)):void G(L(j)),className:ee+" "+(V?"text-yellow-500":""),title:V?"Remove bookmark":"Add bookmark",children:/* @__PURE__ */k(h,{name:"star",fallback:c,className:"h-4 w-4",fill:V?"currentColor":"none",strokeWidth:1.5})}),
|
|
14
|
+
/* @__PURE__ */k("button",{onClick:$,className:ee,title:"Open in new tab",children:/* @__PURE__ */k(h,{name:"external",fallback:m,className:"h-4 w-4",strokeWidth:1.5})}),
|
|
15
|
+
/* @__PURE__ */k("button",{onClick:()=>P(e=>!e),className:ee,title:"Embedding help",children:/* @__PURE__ */k(h,{name:"help",fallback:d,className:"h-4 w-4",strokeWidth:1.5})})]}),null!==X&&/* @__PURE__ */f("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__ */k("div",{className:"text-[11px] font-semibold uppercase tracking-wide text-gray-500 mb-1",children:"Bookmark this page"}),
|
|
17
17
|
/* @__PURE__ */k("div",{className:"text-[11px] text-gray-400 truncate mb-2 font-mono",title:j,children:j}),
|
|
18
|
-
/* @__PURE__ */k("input",{ref:
|
|
18
|
+
/* @__PURE__ */k("input",{ref:M,type:"text",value:X,onChange:e=>G(e.target.value),onKeyDown:e=>{"Enter"===e.key?K():"Escape"===e.key&&G(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__ */f("div",{className:"flex justify-end gap-1 mt-2",children:[
|
|
20
20
|
/* @__PURE__ */k("button",{onClick:()=>G(null),className:"px-2 py-1 text-xs text-gray-600 hover:bg-gray-100 rounded",children:"Cancel"}),
|
|
21
|
-
/* @__PURE__ */k("button",{onClick:
|
|
22
|
-
/* @__PURE__ */f("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===
|
|
21
|
+
/* @__PURE__ */k("button",{onClick:K,disabled:!X.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__ */f("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===J.length&&/* @__PURE__ */k("span",{className:"text-[11px] text-gray-400 italic px-2",children:"No bookmarks yet — star the address bar to add one."}),J.map((e,t)=>/* @__PURE__ */f("button",{onClick:()=>q(e.url),onContextMenu:async o=>{o.preventDefault();await a({title:"Remove bookmark",message:`"${e.label}" will be removed from your bookmarks.`,confirmLabel:"Remove",variant:"danger"})&&Y(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__ */k("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__ */k("div",{className:"flex-1"}),
|
|
25
25
|
/* @__PURE__ */k("button",{onClick:()=>{N(j);try{localStorage.setItem(y,j)}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__ */k("div",{className:"flex-1 relative min-h-0 bg-gray-50",children:/* @__PURE__ */k(
|
|
26
|
+
/* @__PURE__ */k("div",{className:"flex-1 relative min-h-0 bg-gray-50",children:/* @__PURE__ */k(R,{url:j,iframeKey:I,iframeRef:Q,openExternal:$,showHelp:B,dismissHelp:()=>P(!1)})})]})}function L(e){try{return new URL(e).hostname.replace(/^www\./,"")}catch{return e}}function R({url:e,iframeKey:t,iframeRef:o,openExternal:r,showHelp:a,dismissHelp:n}){const[l,s]=g(!1);b(()=>{s(!1)},[e]);return function(e){try{const t=new URL(e).hostname.toLowerCase();return z.some(e=>t===e||t.endsWith("."+e))}catch{return!1}}(e)&&!l?/* @__PURE__ */k("div",{className:"absolute inset-0 flex items-center justify-center bg-white p-8",children:/* @__PURE__ */f("div",{className:"max-w-md text-center",children:[
|
|
27
27
|
/* @__PURE__ */k(h,{name:"no-symbol",fallback:u,className:"h-14 w-14 mx-auto text-gray-300 mb-3",strokeWidth:1.2}),
|
|
28
|
-
/* @__PURE__ */f("h3",{className:"text-base font-semibold text-gray-800 mb-1",children:[
|
|
28
|
+
/* @__PURE__ */f("h3",{className:"text-base font-semibold text-gray-800 mb-1",children:[L(e)," can't be embedded"]}),
|
|
29
29
|
/* @__PURE__ */f("p",{className:"text-sm text-gray-500 mb-4",children:["This site sends an ",
|
|
30
30
|
/* @__PURE__ */k("span",{className:"font-mono text-xs",children:"X-Frame-Options"})," ","or ",
|
|
31
31
|
/* @__PURE__ */k("span",{className:"font-mono text-xs",children:"Content-Security-Policy"})," header that refuses iframe embedding. The browser blocks the load before our app can do anything about it."]}),
|
|
@@ -40,4 +40,4 @@ return f("div",{className:"relative flex flex-col h-full bg-white",children:[
|
|
|
40
40
|
/* @__PURE__ */f("p",{children:["Hit the ",
|
|
41
41
|
/* @__PURE__ */k("span",{className:"font-medium",children:"↗"})," button to open the page in a real new tab. Sites that ",
|
|
42
42
|
/* @__PURE__ */k("em",{children:"do"})," allow embedding (Wikipedia, DevDocs, your own apps) work fine in here."]}),
|
|
43
|
-
/* @__PURE__ */k("button",{onClick:n,className:"mt-2 text-[11px] text-blue-600 hover:underline",children:"Got it"})]})]})}export{
|
|
43
|
+
/* @__PURE__ */k("button",{onClick:n,className:"mt-2 text-[11px] text-blue-600 hover:underline",children:"Got it"})]})]})}export{H as default};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import{loadAppearance as e,WidgetSettingsModal as t}from"./chunk-BFFXVA53.js";import{useWidgetSettings as n}from"./chunk-TLTFS2D6.js";import"./chunk-DSSLOQDW.js";import"./chunk-UAJQB45Y.js";import"./chunk-SSBOC52S.js";import"./chunk-5A7MWTXX.js";import"./chunk-OGXU7QFW.js";import"./chunk-MTH7EAH3.js";import"./chunk-HIAHERCD.js";import"./chunk-AFYQTVZO.js";import"./chunk-HZZNJHRH.js";import"./chunk-X4FJ54PP.js";import"./chunk-D65T4H6J.js";import{CheckFallbackB as l,CopyFallbackB as r}from"./chunk-JJIPGAXI.js";import"./chunk-AJB5G52B.js";import"./chunk-C3QOHMR6.js";import{Icon as c}from"./chunk-YKZHOXI4.js";import{useState as a,useRef as i,useCallback as o,useEffect as s}from"react";import{jsxs as u,Fragment as d,jsx as h}from"react/jsx-runtime";var m="calc_appearance";function b(){const[b,k]=a("0"),[p,g]=a(null),[f,y]=a(null),[x,N]=a(!1),[v,C]=a(""),[$,j]=a([]),[w,S]=a(!1),[A,E]=a(()=>e(m)),[T,F]=a(!1),[H,B]=a(A),J=i(null);n(o(()=>{B({...A}),F(!0)},[A]));const O=o(e=>{C(""),k(t=>x||"0"===t?(N(!1),"."===e?"0.":e):"."===e&&t.includes(".")?t:t+e)},[x]),W=o(()=>{k("0"),g(null),y(null),N(!1)},[]),X=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}},[]),D=o(e=>{const t=parseFloat(b);if(null!==p&&f&&!x){const e=X(p,t,f);k(String(e)),g(e),j(n=>[`${p} ${f} ${t} = ${e}`,...n].slice(0,20))}else g(t);y(e),N(!0)},[b,p,f,x,X]),I=o(()=>{if(null===p||!f)return;const e=parseFloat(b),t=X(p,e,f),n=`${p} ${f} ${e} =`;j(e=>[`${n} ${t}`,...e].slice(0,20)),C(n),k(String(t)),g(null),y(null),N(!0)},[b,p,f,X]),L=o(()=>{k(e=>String(parseFloat(e)/100))},[]),Q=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"?O(e.key):"."===e.key?O("."):"+"===e.key?D("+"):"-"===e.key?D("-"):"*"===e.key?D("×"):"/"===e.key?(e.preventDefault(),D("÷")):"Enter"===e.key||"="===e.key?("Enter"===e.key&&e.target instanceof Node&&J.current?.contains(e.target)&&e.preventDefault(),I()):"Escape"===e.key?W():"Backspace"===e.key?k(e=>e.length>1?e.slice(0,-1):"0"):"%"===e.key&&L())};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[O,D,I,W,L]);const M="flex items-center justify-center rounded-lg text-sm font-medium transition-colors",P=`${M} bg-white border border-gray-200 text-gray-900 hover:bg-gray-50 active:bg-gray-100`,R=`${M} bg-blue-50 border border-blue-200 text-blue-700 hover:bg-blue-100 active:bg-blue-200`,Z=`${M} bg-gray-100 border border-gray-200 text-gray-600 hover:bg-gray-200 active:bg-gray-300`,G=`${M} bg-blue-600 text-white hover:bg-blue-700 active:bg-blue-800`;/* @__PURE__ */
|
|
2
|
+
return u(d,{children:[
|
|
3
|
+
/* @__PURE__ */u("div",{ref:J,className:"flex flex-col h-full",style:{opacity:A.activeOpacity/100,backdropFilter:A.activeBlur>0?`blur(${A.activeBlur}px)`:void 0},children:[
|
|
4
|
+
/* @__PURE__ */u("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__ */h("div",{className:"flex flex-col justify-end flex-1 overflow-hidden",children:$.slice(0,3).reverse().map((e,t)=>/* @__PURE__ */h("div",{className:"text-[11px] text-slate-400 text-right font-mono truncate",children:e},t))}),(v||f&&null!==p)&&/* @__PURE__ */h("div",{className:"text-base text-slate-600 text-right font-mono",children:v||`${p} ${f} ${x?"":b}`}),
|
|
6
|
+
/* @__PURE__ */u("div",{className:"flex items-center gap-2",children:[
|
|
7
|
+
/* @__PURE__ */h("button",{onClick:()=>{navigator.clipboard.writeText(b),S(!0),setTimeout(()=>S(!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__ */h(c,w?{name:"check",fallback:l,className:"h-5 w-5 text-green-500",strokeWidth:2}:{name:"copy",fallback:r,className:"h-5 w-5",strokeWidth:2})}),
|
|
8
|
+
/* @__PURE__ */h("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)})(b)})]})]}),
|
|
9
|
+
/* @__PURE__ */u("div",{className:"grid grid-cols-4 grid-rows-5 gap-1.5 flex-1 min-h-0 p-2",children:[
|
|
10
|
+
/* @__PURE__ */h("button",{onClick:W,className:Z,children:"AC"}),
|
|
11
|
+
/* @__PURE__ */h("button",{onClick:Q,className:Z,children:"+/−"}),
|
|
12
|
+
/* @__PURE__ */h("button",{onClick:L,className:Z,children:"%"}),
|
|
13
|
+
/* @__PURE__ */h("button",{onClick:()=>D("÷"),className:`${R} ${"÷"===f?"ring-2 ring-blue-400":""}`,children:"÷"}),
|
|
14
|
+
/* @__PURE__ */h("button",{onClick:()=>O("7"),className:P,children:"7"}),
|
|
15
|
+
/* @__PURE__ */h("button",{onClick:()=>O("8"),className:P,children:"8"}),
|
|
16
|
+
/* @__PURE__ */h("button",{onClick:()=>O("9"),className:P,children:"9"}),
|
|
17
|
+
/* @__PURE__ */h("button",{onClick:()=>D("×"),className:`${R} ${"×"===f?"ring-2 ring-blue-400":""}`,children:"×"}),
|
|
18
|
+
/* @__PURE__ */h("button",{onClick:()=>O("4"),className:P,children:"4"}),
|
|
19
|
+
/* @__PURE__ */h("button",{onClick:()=>O("5"),className:P,children:"5"}),
|
|
20
|
+
/* @__PURE__ */h("button",{onClick:()=>O("6"),className:P,children:"6"}),
|
|
21
|
+
/* @__PURE__ */h("button",{onClick:()=>D("-"),className:`${R} ${"-"===f?"ring-2 ring-blue-400":""}`,children:"−"}),
|
|
22
|
+
/* @__PURE__ */h("button",{onClick:()=>O("1"),className:P,children:"1"}),
|
|
23
|
+
/* @__PURE__ */h("button",{onClick:()=>O("2"),className:P,children:"2"}),
|
|
24
|
+
/* @__PURE__ */h("button",{onClick:()=>O("3"),className:P,children:"3"}),
|
|
25
|
+
/* @__PURE__ */h("button",{onClick:()=>D("+"),className:`${R} ${"+"===f?"ring-2 ring-blue-400":""}`,children:"+"}),
|
|
26
|
+
/* @__PURE__ */h("button",{onClick:()=>O("0"),className:`${P} col-span-2`,children:"0"}),
|
|
27
|
+
/* @__PURE__ */h("button",{onClick:()=>O("."),className:P,children:"."}),
|
|
28
|
+
/* @__PURE__ */h("button",{onClick:I,className:G,children:"="})]})]}),
|
|
29
|
+
/* @__PURE__ */h(t,{open:T,onClose:()=>F(!1),title:"Calculator Settings",appearance:H,onAppearanceChange:B,onSave:()=>{E(H),localStorage.setItem(m,JSON.stringify(H)),F(!1)}})]})}export{b as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export{ConfirmProvider,confirm,confirmDestructive,prompt,useConfirm}from"./chunk-MTH7EAH3.js";import"./chunk-AFYQTVZO.js";import"./chunk-X4FJ54PP.js";import"./chunk-JJIPGAXI.js";import"./chunk-AJB5G52B.js";import"./chunk-C3QOHMR6.js";import"./chunk-YKZHOXI4.js";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{loadAppearance as e,WidgetSettingsModal as t}from"./chunk-
|
|
1
|
+
import{loadAppearance as e,WidgetSettingsModal as t}from"./chunk-BFFXVA53.js";import{useWidgetSettings as r}from"./chunk-TLTFS2D6.js";import"./chunk-DSSLOQDW.js";import"./chunk-UAJQB45Y.js";import"./chunk-SSBOC52S.js";import"./chunk-5A7MWTXX.js";import"./chunk-OGXU7QFW.js";import"./chunk-MTH7EAH3.js";import"./chunk-HIAHERCD.js";import"./chunk-AFYQTVZO.js";import"./chunk-HZZNJHRH.js";import"./chunk-X4FJ54PP.js";import"./chunk-D65T4H6J.js";import"./chunk-JJIPGAXI.js";import"./chunk-AJB5G52B.js";import"./chunk-C3QOHMR6.js";import"./chunk-YKZHOXI4.js";import{useState as n,useCallback as a,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]=n(x),[f,N]=n(()=>e(p)),[b,S]=n({}),[v,k]=n(!1),[D,j]=n(!1),[C,A]=n([]),[J,H]=n(f),[B,O]=n("USD"),[U,I]=n("CNY");r(a(()=>{A([...m]),H({...f}),j(!0)},[m,f])),s(()=>{const e=[...new Set(m.map(([e])=>e))];let t=!0;return async function(){k(!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}`),n=await e.json();n.rates&&(r[t]=n.rates,g(t,n.rates))}catch{}}t&&(S(r),k(!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:[v&&/* @__PURE__ */i("div",{className:"text-xs text-gray-400 text-center py-4",children:"Loading rates..."}),m.map(([e,t],r)=>{const n=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!=n?n.toLocaleString(void 0,{minimumFractionDigits:2,maximumFractionDigits:4}):"—"})]},`${e}-${t}-${r}`)})]})}),
|
|
12
|
-
/* @__PURE__ */i(t,{open:D,onClose:()=>j(!1),title:"Currency Settings",appearance:
|
|
12
|
+
/* @__PURE__ */i(t,{open:D,onClose:()=>j(!1),title:"Currency Settings",appearance:J,onAppearanceChange:H,onSave:()=>{if(0===C.length)return;const e=C.slice(0,4);d(e),N(J),localStorage.setItem(u,JSON.stringify(e)),localStorage.setItem(p,JSON.stringify(J)),j(!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:["(",C.length,"/",4,")"]})]}),
|
|
15
15
|
/* @__PURE__ */i("div",{className:"space-y-1 mb-2",children:C.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:()=>A(e=>e.filter((e,t)=>t!==r)),className:"text-red-400 hover:text-red-600",children:"×"})]},r))}),C.length<4?/* @__PURE__ */c("div",{className:"flex items-center gap-2",children:[
|
|
18
|
+
/* @__PURE__ */i("select",{value:B,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))}),
|
|
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:U,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))}),
|
|
21
|
+
/* @__PURE__ */i("button",{onClick:()=>{B!==U&&C.length<4&&A(e=>[...e,[B,U]])},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,14 +1,14 @@
|
|
|
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-6GV4467L.js";import{WindowTitle as n}from"./chunk-TLTFS2D6.js";import"./chunk-DSSLOQDW.js";import"./chunk-UAJQB45Y.js";import"./chunk-4QBLTEFU.js";import{toast_default as r}from"./chunk-TKFAFZRY.js";import"./chunk-SSBOC52S.js";import"./chunk-5A7MWTXX.js";import"./chunk-OGXU7QFW.js";import"./chunk-MTH7EAH3.js";import{PopupMenu as o,PopupMenuLabel as l,PopupMenuItem as a,PopupMenuDivider as i}from"./chunk-HIAHERCD.js";import"./chunk-AFYQTVZO.js";import"./chunk-HZZNJHRH.js";import"./chunk-X4FJ54PP.js";import"./chunk-D65T4H6J.js";import{FolderOpenFallback as s,ImageFallback as c}from"./chunk-JJIPGAXI.js";import"./chunk-AJB5G52B.js";import"./chunk-C3QOHMR6.js";import{Icon as d}from"./chunk-YKZHOXI4.js";import{useState as m,useRef as h}from"react";import{jsxs as u,jsx as p}from"react/jsx-runtime";var g=/* @__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"]),x=/* @__PURE__ */new Set(["docx"]),f={filename:"Untitled",kind:"docx",content:"",ext:"docx"};function y(){const[y,v]=m(f),[b,k]=m(!1),[w,N]=m(!1),[j,C]=m(!1),[D,L]=m(null),M=h(null),U=h(null),R=h(null),T=(e,t)=>{R.current?.focus(),document.execCommand(e,!1,t),C(!0)},A=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=>{D&&(D.el.removeAttribute("width"),D.el.removeAttribute("height"),D.el.style.width=e??"",D.el.style.height=e?"auto":"",C(!0),L(null))},O=async t=>{const n=(t.name.split(".").pop()||"").toLowerCase();k(!0);try{if(g.has(n)||!x.has(n)&&t.type.startsWith("text/")){const r=await t.text(),o=e(r).replace(/\n/g,"<br>");v({filename:t.name,kind:"text",content:o,ext:n}),C(!1)}else if(x.has(n))try{const e=await(import(
|
|
2
2
|
/* @vite-ignore */
|
|
3
|
-
"mammoth")),r=await t.arrayBuffer(),o=await e.convertToHtml({arrayBuffer:r});v({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{k(!1)}},S=y?.filename?(
|
|
4
|
-
return u("div",{className:"relative flex flex-col h-full",onDragOver:e=>{e.preventDefault(),w||N(!0)},onDragLeave:e=>{e.currentTarget===e.target&&N(!1)},onDrop:e=>{e.preventDefault(),N(!1);const t=Array.from(e.dataTransfer.files??[]);0!==t.length&&(t.every(e=>e.type.startsWith("image/"))?
|
|
3
|
+
"mammoth")),r=await t.arrayBuffer(),o=await e.convertToHtml({arrayBuffer:r});v({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{k(!1)}},S=y?.filename?(W=y.filename).length>24?`${W.slice(0,23)}…`:W:"Untitled";var W;/* @__PURE__ */
|
|
4
|
+
return u("div",{className:"relative flex flex-col h-full",onDragOver:e=>{e.preventDefault(),w||N(!0)},onDragLeave:e=>{e.currentTarget===e.target&&N(!1)},onDrop:e=>{e.preventDefault(),N(!1);const t=Array.from(e.dataTransfer.files??[]);0!==t.length&&(t.every(e=>e.type.startsWith("image/"))?A(t):O(t[0]))},children:[
|
|
5
5
|
/* @__PURE__ */p(n,{title:`${S}${j?" •":""} - Documents`}),
|
|
6
6
|
/* @__PURE__ */p(t,{app:"documents"}),
|
|
7
7
|
/* @__PURE__ */u("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__ */p("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&&
|
|
8
|
+
/* @__PURE__ */p("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&&O(t),M.current&&(M.current.value="")},className:"hidden"}),
|
|
9
9
|
/* @__PURE__ */u("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__ */p(d,{name:"folder-open",fallback:s,className:"h-3.5 w-3.5",strokeWidth:1.5}),"Open"]}),
|
|
11
|
-
/* @__PURE__ */p("button",{onClick:()=>{if(!y)return;const t=
|
|
11
|
+
/* @__PURE__ */p("button",{onClick:()=>{if(!y)return;const t=R.current?.innerHTML??"";if("text"===y.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(y.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=`${y.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=y.filename,r.click(),URL.revokeObjectURL(n)}}else{const n=new Blob([`<!doctype html><meta charset="utf-8"><title>${e(y.filename)}</title>${t}`],{type:"text/html"}),r=URL.createObjectURL(n),o=document.createElement("a");o.href=r,o.download=`${y.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__ */p("span",{className:"text-[10px] text-gray-400 ml-1",children:"TXT · DOCX · Code"}),
|
|
13
13
|
/* @__PURE__ */p("div",{className:"h-4 w-px bg-gray-300 mx-1"}),
|
|
14
14
|
/* @__PURE__ */u("span",{className:"text-xs font-medium text-gray-700 truncate max-w-[200px]",title:y.filename,children:[y.filename,j?" •":""]}),
|
|
@@ -38,10 +38,10 @@ return u("div",{className:"relative flex flex-col h-full",onDragOver:e=>{e.preve
|
|
|
38
38
|
/* @__PURE__ */p("button",{onMouseDown:e=>e.preventDefault(),onClick:()=>T("justifyRight"),className:"px-2 py-1 rounded text-gray-700 hover:bg-gray-200 transition-colors",title:"Align right",children:/* @__PURE__ */p("svg",{className:"h-3.5 w-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.8,children:/* @__PURE__ */p("path",{strokeLinecap:"round",d:"M3.75 6h16.5M10.5 12h9.75M6 18h14.25"})})}),
|
|
39
39
|
/* @__PURE__ */p("button",{onMouseDown:e=>e.preventDefault(),onClick:()=>T("justifyFull"),className:"px-2 py-1 rounded text-gray-700 hover:bg-gray-200 transition-colors",title:"Justify",children:/* @__PURE__ */p("svg",{className:"h-3.5 w-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.8,children:/* @__PURE__ */p("path",{strokeLinecap:"round",d:"M3.75 6h16.5M3.75 12h16.5M3.75 18h16.5"})})})]}),
|
|
40
40
|
/* @__PURE__ */p("div",{className:"h-4 w-px bg-gray-300 mx-1"}),
|
|
41
|
-
/* @__PURE__ */p("input",{ref:
|
|
42
|
-
/* @__PURE__ */u("button",{onClick:()=>
|
|
41
|
+
/* @__PURE__ */p("input",{ref:U,type:"file",accept:"image/*",multiple:!0,className:"hidden",onChange:e=>{e.target.files?.length&&A(Array.from(e.target.files)),U.current&&(U.current.value="")}}),
|
|
42
|
+
/* @__PURE__ */u("button",{onClick:()=>U.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__ */p(d,{name:"image",fallback:c,className:"h-3.5 w-3.5",strokeWidth:1.5}),"Image"]})]}),
|
|
44
|
-
/* @__PURE__ */p("div",{className:"flex-1 min-h-0 overflow-hidden",children:/* @__PURE__ */p("div",b?{className:"flex items-center justify-center h-full text-sm text-gray-400",children:"Loading…"}:{className:"h-full overflow-auto "+("docx"===y.kind?"bg-gray-100 px-6 py-8":"bg-white"),children:/* @__PURE__ */p("div",{ref:
|
|
44
|
+
/* @__PURE__ */p("div",{className:"flex-1 min-h-0 overflow-hidden",children:/* @__PURE__ */p("div",b?{className:"flex items-center justify-center h-full text-sm text-gray-400",children:"Loading…"}:{className:"h-full overflow-auto "+("docx"===y.kind?"bg-gray-100 px-6 py-8":"bg-white"),children:/* @__PURE__ */p("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(),A(t))},onClick:e=>{const t=e.target;"IMG"===t.tagName&&(e.preventDefault(),L({x:e.clientX,y:e.clientY,el:t}))},dangerouslySetInnerHTML:{__html:y.content},className:"docx"===y.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"})})}),w&&/* @__PURE__ */p("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__ */p("div",{className:"px-4 py-2 rounded-md bg-blue-600 text-white text-sm font-medium shadow-lg",children:"Drop a document to open · images insert into the page"})}),D&&/* @__PURE__ */u(o,{minWidth:150,style:{left:D.x,top:D.y},onClose:()=>L(null),children:[
|
|
45
45
|
/* @__PURE__ */p(l,{children:"Image width"}),
|
|
46
46
|
/* @__PURE__ */p(a,{onClick:()=>B("25%"),children:"25%"}),
|
|
47
47
|
/* @__PURE__ */p(a,{onClick:()=>B("50%"),children:"50%"}),
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import{openPreviewFile as e}from"./chunk-H3UEYXRA.js";import{Breadcrumbs as t}from"./chunk-R3622MOL.js";import{SidebarLayout as a}from"./chunk-YJ6JMGMS.js";import{getFilesDemoTree as r}from"./chunk-ML22KF7T.js";import{AboutApp as n}from"./chunk-6GV4467L.js";import{peekFilesViewRequest as i,consumeFilesViewRequest as s,FILES_SHOW_TRASH_EVENT as l,FILES_OPEN_DESKTOP_FOLDER_EVENT as o,subscribeDesktopFolders as c,getDesktopFoldersSnapshot as d,FolderGlyph as m,DesktopItemMiniIcon as h,desktopItemTypeLabel as p}from"./chunk-YQI7KXX3.js";import"./chunk-ESL5TDNA.js";import"./chunk-VTVSMRFX.js";import{useWindowManager as f,WindowTitle as u}from"./chunk-TLTFS2D6.js";import"./chunk-DSSLOQDW.js";import"./chunk-UAJQB45Y.js";import"./chunk-4QBLTEFU.js";import{toast_default as x}from"./chunk-TKFAFZRY.js";import"./chunk-SSBOC52S.js";import"./chunk-5A7MWTXX.js";import"./chunk-OGXU7QFW.js";import{confirm as g,prompt as y}from"./chunk-MTH7EAH3.js";import"./chunk-HIAHERCD.js";import"./chunk-AFYQTVZO.js";import"./chunk-HZZNJHRH.js";import"./chunk-X4FJ54PP.js";import"./chunk-D65T4H6J.js";import{CloseCircleFallback as b,ArrowLeftFallback as k,RefreshFallback as N,TrashFallback as w,FolderPlusFallback as v,UploadFallbackB as j,FolderFallback as $,PageFallback as C}from"./chunk-JJIPGAXI.js";import"./chunk-AJB5G52B.js";import"./chunk-C3QOHMR6.js";import{formatBytes as L}from"./chunk-W32SKK3D.js";import{Icon as T}from"./chunk-YKZHOXI4.js";import{useState as D,useEffect as E,useSyncExternalStore as R,useRef as S,useCallback as F}from"react";import{jsxs as A,jsx as I,Fragment as O}from"react/jsx-runtime";var P="undefined"!=typeof window&&window.__REACT_OS_SHELL_FILE_SERVER__||"http://localhost:4000",M={pdf:"pdf",dxf:"dxf",csv:"csv",jpg:"image",jpeg:"image",png:"image",gif:"image",webp:"image",svg:"image",avif:"image",bmp:"image",stp:"3d",step:"3d",stl:"3d",obj:"3d",gltf:"3d",glb:"3d","3mf":"3d",iges:"3d",igs:"3d",ply:"3d",fbx:"3d"};function W(e,t){return"/"===e||""===e?"/"+t:e.replace(/\/$/,"")+"/"+t}function U(e){if(!e)return"—";try{const t=new Date(e);return isNaN(t.getTime())?"—":t.toLocaleString(void 0,{dateStyle:"short",timeStyle:"short"})}catch{return e}}function H(){const H=P.replace(/\/$/,""),J=null!==r(),[B,V]=D("/"),[X,z]=D([]),[K,Q]=D([]),[_,Y]=D(null),[G,Z]=D(!0),[q,ee]=D(!1),[te,ae]=D(null),[re,ne]=D(!1),[ie,se]=D(()=>{const e=i();return"trash"===e?"trash":e?{desktopFolderId:e.folderId}:"files"});E(()=>{s()},[]);const[le,oe]=D([]);E(()=>{const e=()=>{s(),se("trash")},t=e=>{s();const t=e.detail?.folderId;t&&se({desktopFolderId:t})};return window.addEventListener(l,e),window.addEventListener(o,t),()=>{window.removeEventListener(l,e),window.removeEventListener(o,t)}},[]);const ce=R(c,d,d),de="object"==typeof ie?ie.desktopFolderId:null,me=de?ce?.folders.find(e=>e.id===de)??null:null,he=de&&ce?.itemsByFolder[de]||[];E(()=>{de&&ce&&!ce.folders.some(e=>e.id===de)&&se("files")},[de,ce]);const pe=S(0),fe=S(null),{openPage:ue,openEntity:xe}=f(),ge=t=>{"preview-file"===t.entityType&&t.filePath&&t.fileKind?e({filePath:t.filePath,filename:t.label,kind:t.fileKind,onStaged:e=>ue(e)}):"page"===t.entityType?ue(t.entityId):xe(t.entityType,t.entityId,null,t.label)},ye=F((e,t={})=>fetch(e,{...t,credentials:"include"}),[]),be=F(async()=>{try{const e=await ye(`${H}/api/quota`);if(e.ok){const t=await e.json();ae({used:t.used,limit:t.limit})}}catch{}},[ye,H]),ke=F(async e=>{if(Y(null),J){const t=function(e){const t=r();if(!t)return[];let a=t;for(const t of e.split("/").filter(Boolean)){const e=a.find(e=>"folder"===e.kind&&e.name===t);if(!e||!e.children)return[];a=e.children}return a.map(e=>({name:e.name,kind:e.kind,size:e.size??0,modifiedAt:e.modifiedAt??""}))}(e);return z(t),V(e),ee(!1),Z(!1),void("/"===e&&Q(t.filter(e=>"folder"===e.kind).map(e=>e.name)))}Z(!0);try{const t=await ye(`${H}/api/files?path=${encodeURIComponent(e)}`);if(!t.ok){const e=await t.json().catch(()=>({}));return void x.error(e.error||`Failed to list (${t.status})`)}const a=await t.json(),r=a.entries||[];z(r),V(a.path||e),ee(!1),"/"===(a.path||e)&&Q(r.filter(e=>"folder"===e.kind).map(e=>e.name))}catch(e){ee(!0)}finally{Z(!1)}be()},[ye,H,be,J]),Ne=F(async()=>{if(J)return oe([]),void Z(!1);Z(!0),Y(null);try{const e=await ye(`${H}/api/trash`);if(!e.ok){const t=await e.json().catch(()=>({}));return void x.error(t.error||`Failed to list trash (${e.status})`)}const t=await e.json();oe(t.entries||[]),ee(!1)}catch{ee(!0)}finally{Z(!1)}be()},[ye,H,be,J]);E(()=>{"files"===ie?ke(B):"trash"===ie&&Ne()},[B,ie]);const we=async e=>{const t=W(B,e.name);try{const a=await ye(`${H}/api/file?path=${encodeURIComponent(t)}`);if(!a.ok)return void x.error(`Download failed (${a.status})`);const r=await a.blob(),n=URL.createObjectURL(r),i=document.createElement("a");i.href=n,i.download=e.name,i.click(),setTimeout(()=>URL.revokeObjectURL(n),1e3)}catch(e){x.error(e?.message||"Download failed")}},ve=async e=>{const t=Array.from(e);for(const e of t){const t=new FormData;t.append("file",e);try{const a=await ye(`${H}/api/upload?path=${encodeURIComponent(B)}`,{method:"POST",body:t});if(!a.ok){const t=await a.json().catch(()=>({}));if(413===a.status){const a=Math.max(0,(t.limit||0)-(t.used||0));x.error(`Quota exceeded — ${L(a)} free, ${e.name} is ${L(t.attempted||e.size)}`)}else x.error(`Upload ${e.name}: ${t.error||a.status}`)}}catch(t){x.error(`Upload ${e.name}: ${t?.message||"failed"}`)}}ke(B)},je=()=>{pe.current=0,ne(!1)};if(E(()=>{const e=()=>je();return window.addEventListener("dragend",e),window.addEventListener("drop",e),()=>{window.removeEventListener("dragend",e),window.removeEventListener("drop",e)}},[]),q)/* @__PURE__ */
|
|
2
|
+
return A("div",{className:"flex flex-col h-full bg-white",children:[
|
|
3
|
+
/* @__PURE__ */I(u,{title:"Files - offline"}),
|
|
4
|
+
/* @__PURE__ */I("div",{className:"flex-1 flex items-center justify-center p-8 text-center",children:/* @__PURE__ */A("div",{className:"max-w-md",children:[
|
|
5
|
+
/* @__PURE__ */I(T,{name:"close-circle",fallback:b,className:"h-12 w-12 mx-auto text-gray-300 mb-3",strokeWidth:1.4}),
|
|
6
|
+
/* @__PURE__ */I("h3",{className:"text-base font-semibold text-gray-800 mb-1",children:"Can't reach the file server"}),
|
|
7
|
+
/* @__PURE__ */A("p",{className:"text-sm text-gray-500 mb-3",children:["No response from ",
|
|
8
|
+
/* @__PURE__ */I("span",{className:"font-mono",children:H}),". Make sure the server is running — see ",
|
|
9
|
+
/* @__PURE__ */I("span",{className:"font-mono",children:"examples/file-server/README.md"}),"."]}),
|
|
10
|
+
/* @__PURE__ */I("button",{onClick:()=>ke(B),className:"px-3 py-1.5 text-sm bg-blue-500 text-white rounded hover:bg-blue-600",children:"Retry"})]})})]});const $e="/"===B?[]:B.split("/").filter(Boolean),Ce=te&&te.limit>0?Math.min(100,Math.round(te.used/te.limit*100)):0,Le=Ce>90?"bg-red-500":Ce>75?"bg-amber-500":"bg-blue-500",Te=[{label:"My files",onClick:()=>V("/")},...$e.map((e,t)=>({label:e,onClick:()=>V("/"+$e.slice(0,t+1).join("/"))}))],De=e=>"flex w-full items-center gap-2 rounded-md px-2.5 py-1.5 text-left text-sm transition-colors "+(e?"bg-blue-50 font-medium text-blue-700":"text-gray-700 hover:bg-gray-100"),Ee=e=>/* @__PURE__ */I("svg",{className:"h-4 w-4 shrink-0 text-gray-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.6,children:/* @__PURE__ */I("path",{strokeLinecap:"round",strokeLinejoin:"round",d:e})}),Re=/* @__PURE__ */A("nav",{className:"p-2",children:[
|
|
11
|
+
/* @__PURE__ */I("div",{className:"px-2 py-1.5 text-[11px] font-semibold uppercase tracking-wide text-gray-400",children:"Locations"}),
|
|
12
|
+
/* @__PURE__ */A("button",{onClick:()=>{se("files"),V("/")},className:De("files"===ie&&"/"===B),children:[Ee("M2.25 12l8.954-8.955a1.5 1.5 0 012.122 0L21.75 12M4.5 9.75v9.75a.75.75 0 00.75.75H9V15a.75.75 0 01.75-.75h4.5A.75.75 0 0115 15v5.25h3.75a.75.75 0 00.75-.75V9.75"),"My files"]}),K.map(e=>/* @__PURE__ */A("button",{onClick:()=>{se("files"),V("/"+e)},className:De("files"===ie&&B==="/"+e),children:[Ee("M2.25 12.75V12A2.25 2.25 0 014.5 9.75h15A2.25 2.25 0 0121.75 12v.75m-8.69-6.44l-2.12-2.12a1.5 1.5 0 00-1.061-.44H4.5A2.25 2.25 0 002.25 6v12a2.25 2.25 0 002.25 2.25h15A2.25 2.25 0 0021.75 18V9a2.25 2.25 0 00-2.25-2.25h-5.379a1.5 1.5 0 01-1.06-.44z"),
|
|
13
|
+
/* @__PURE__ */I("span",{className:"truncate",children:e})]},e)),!J&&/* @__PURE__ */A("button",{onClick:()=>se("trash"),className:De("trash"===ie),children:[Ee("M14.74 9l-.346 9m-4.788 0L9.26 9m9.968-3.21c.342.052.682.107 1.022.166m-1.022-.165L18.16 19.673a2.25 2.25 0 01-2.244 2.077H8.084a2.25 2.25 0 01-2.244-2.077L4.772 5.79"),"Trash"]}),ce&&ce.folders.length>0&&/* @__PURE__ */A(O,{children:[
|
|
14
|
+
/* @__PURE__ */I("div",{className:"px-2 pt-3 pb-1.5 text-[11px] font-semibold uppercase tracking-wide text-gray-400",children:"Desktop"}),ce.folders.map(e=>/* @__PURE__ */A("button",{onClick:()=>se({desktopFolderId:e.id}),className:De(de===e.id),children:[
|
|
15
|
+
/* @__PURE__ */I(m,{className:"h-4 w-4 shrink-0 text-amber-500"}),
|
|
16
|
+
/* @__PURE__ */I("span",{className:"truncate",children:e.name}),e.itemCount>0&&/* @__PURE__ */I("span",{className:"ml-auto text-[10px] text-gray-400 tabular-nums",children:e.itemCount})]},e.id))]})]});/* @__PURE__ */
|
|
17
|
+
return A("div",{className:"relative flex flex-col h-full bg-white",onDragEnter:e=>{J||"object"==typeof ie||e.dataTransfer?.types?.includes?.("Files")&&(e.preventDefault(),pe.current++,re||ne(!0))},onDragOver:e=>{e.dataTransfer?.types?.includes?.("Files")&&e.preventDefault()},onDragLeave:()=>{pe.current>0&&pe.current--,0===pe.current&&ne(!1)},onDrop:e=>{e.preventDefault(),je(),J||"object"==typeof ie||e.dataTransfer.files?.length&&ve(e.dataTransfer.files)},children:[
|
|
18
|
+
/* @__PURE__ */I(u,{title:me?`Files - ${me.name}`:"Files"+("/"===B?"":" - "+B)}),
|
|
19
|
+
/* @__PURE__ */I(n,{app:"files"}),
|
|
20
|
+
/* @__PURE__ */I("input",{ref:fe,type:"file",multiple:!0,className:"hidden",onChange:e=>{e.target.files?.length&&ve(e.target.files),fe.current&&(fe.current.value="")}}),
|
|
21
|
+
/* @__PURE__ */I("div",{className:"flex-1 min-h-0",children:/* @__PURE__ */I(a,{sidebar:Re,storageKey:"files.sidebarWidth",defaultWidth:200,minWidth:150,maxWidth:320,children:/* @__PURE__ */A("div",{className:"flex h-full min-w-0 flex-col",children:[
|
|
22
|
+
/* @__PURE__ */A("div",{className:"flex items-center gap-1 px-2 py-1.5 border-b border-gray-200 bg-gray-50 shrink-0 text-xs",children:[/* @__PURE__ */A(O,"files"===ie?{children:[
|
|
23
|
+
/* @__PURE__ */I("button",{onClick:()=>V(function(e){if("/"===e||""===e)return"/";const t=e.replace(/\/$/,""),a=t.lastIndexOf("/");return a<=0?"/":t.slice(0,a)}(B)),disabled:"/"===B,className:"px-2 py-1 rounded hover:bg-gray-200 disabled:opacity-30 text-gray-600",title:"Parent folder",children:/* @__PURE__ */I(T,{name:"arrow-left",fallback:k,className:"h-3.5 w-3.5",strokeWidth:2})}),
|
|
24
|
+
/* @__PURE__ */I("div",{className:"flex-1 min-w-0",children:/* @__PURE__ */I(t,{items:Te,maxItems:5})}),
|
|
25
|
+
/* @__PURE__ */I("button",{onClick:()=>ke(B),className:"px-2 py-1 rounded hover:bg-gray-200 text-gray-600",title:"Refresh",children:/* @__PURE__ */I(T,{name:"refresh",fallback:N,className:"h-3.5 w-3.5",strokeWidth:1.8})}),!J&&/* @__PURE__ */A(O,{children:[
|
|
26
|
+
/* @__PURE__ */A("button",{onClick:()=>se("trash"),className:"px-2 py-1 rounded hover:bg-gray-200 text-gray-600 flex items-center gap-1",title:"Open trash",children:[
|
|
27
|
+
/* @__PURE__ */I(T,{name:"trash",fallback:w,className:"h-3.5 w-3.5",strokeWidth:1.5}),"Trash"]}),
|
|
28
|
+
/* @__PURE__ */A("button",{onClick:async()=>{const e=await y({title:"New folder",placeholder:"Folder name",confirmLabel:"Create"});if(!e)return;if(/[\\/]/.test(e))return void x.error("Folder names cannot contain slashes");const t=W(B,e),a=await ye(`${H}/api/folder`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:t})});if(!a.ok){const e=await a.json().catch(()=>({}));return void x.error(e.error||`Create folder failed (${a.status})`)}ke(B)},className:"px-2 py-1 rounded hover:bg-gray-200 text-gray-600 flex items-center gap-1",children:[
|
|
29
|
+
/* @__PURE__ */I(T,{name:"folder-plus",fallback:v,className:"h-3.5 w-3.5",strokeWidth:1.5}),"New Folder"]}),
|
|
30
|
+
/* @__PURE__ */A("button",{onClick:()=>fe.current?.click(),className:"px-2 py-1 rounded bg-blue-500 text-white hover:bg-blue-600 flex items-center gap-1",children:[
|
|
31
|
+
/* @__PURE__ */I(T,{name:"upload",fallback:j,className:"h-3.5 w-3.5",strokeWidth:1.8}),"Upload"]})]})]}:"trash"===ie?{children:[
|
|
32
|
+
/* @__PURE__ */I("button",{onClick:()=>se("files"),className:"px-2 py-1 rounded hover:bg-gray-200 text-gray-600",title:"Back to files",children:/* @__PURE__ */I(T,{name:"arrow-left",fallback:k,className:"h-3.5 w-3.5",strokeWidth:2})}),
|
|
33
|
+
/* @__PURE__ */I("span",{className:"flex-1 text-gray-700 font-medium px-2",children:"Trash"}),
|
|
34
|
+
/* @__PURE__ */I("button",{onClick:Ne,className:"px-2 py-1 rounded hover:bg-gray-200 text-gray-600",title:"Refresh",children:/* @__PURE__ */I(T,{name:"refresh",fallback:N,className:"h-3.5 w-3.5",strokeWidth:1.8})}),
|
|
35
|
+
/* @__PURE__ */I("button",{onClick:async()=>{if(0===le.length)return;if(!await g({title:"Empty trash",message:`${le.length} item${1===le.length?"":"s"} will be permanently removed. This can't be undone.`,confirmLabel:"Empty trash",variant:"danger"}))return;const e=await ye(`${H}/api/trash`,{method:"DELETE"});if(!e.ok){const t=await e.json().catch(()=>({}));return void x.error(t.error||`Empty trash failed (${e.status})`)}Ne()},disabled:0===le.length,className:"px-2 py-1 rounded text-red-600 hover:bg-red-50 disabled:opacity-30 flex items-center gap-1",children:"Empty trash"})]}:{children:[
|
|
36
|
+
/* @__PURE__ */I("button",{onClick:()=>se("files"),className:"px-2 py-1 rounded hover:bg-gray-200 text-gray-600",title:"Back to files",children:/* @__PURE__ */I(T,{name:"arrow-left",fallback:k,className:"h-3.5 w-3.5",strokeWidth:2})}),
|
|
37
|
+
/* @__PURE__ */I(m,{className:"h-4 w-4 text-amber-500 ml-1"}),
|
|
38
|
+
/* @__PURE__ */I("span",{className:"flex-1 text-gray-700 font-medium px-1 truncate",children:me?.name??"Desktop folder"}),
|
|
39
|
+
/* @__PURE__ */I("span",{className:"text-[10px] text-gray-400 px-2",children:"Desktop shortcuts"})]}),te&&/* @__PURE__ */A(O,{children:[
|
|
40
|
+
/* @__PURE__ */I("div",{className:"h-4 w-px bg-gray-300 mx-1"}),
|
|
41
|
+
/* @__PURE__ */A("div",{className:"flex items-center gap-1.5",title:`${L(te.used)} of ${L(te.limit)} used`,children:[
|
|
42
|
+
/* @__PURE__ */I("div",{className:"w-20 h-1.5 rounded-full bg-gray-200 overflow-hidden",children:/* @__PURE__ */I("div",{className:`h-full ${Le} transition-all`,style:{width:`${Ce}%`}})}),
|
|
43
|
+
/* @__PURE__ */A("span",{className:"text-[10px] text-gray-500 tabular-nums whitespace-nowrap",children:[L(te.used)," / ",L(te.limit)]})]})]})]}),
|
|
44
|
+
/* @__PURE__ */I("div",{className:"flex-1 overflow-auto",children:"object"==typeof ie?0===he.length?/* @__PURE__ */I("div",{className:"p-10 text-center text-sm text-gray-400",children:"This desktop folder is empty. Drag shortcuts onto it on the desktop."}):/* @__PURE__ */A("table",{className:"w-full text-sm",children:[
|
|
45
|
+
/* @__PURE__ */I("thead",{className:"bg-gray-50 text-[11px] uppercase tracking-wide text-gray-500",children:/* @__PURE__ */A("tr",{children:[
|
|
46
|
+
/* @__PURE__ */I("th",{className:"text-left font-medium px-3 py-1.5",children:"Name"}),
|
|
47
|
+
/* @__PURE__ */I("th",{className:"text-left font-medium px-3 py-1.5 w-28",children:"Type"}),
|
|
48
|
+
/* @__PURE__ */I("th",{className:"w-56"})]})}),
|
|
49
|
+
/* @__PURE__ */I("tbody",{children:he.map(e=>{const t=`${e.entityType}|${e.entityId}`;/* @__PURE__ */
|
|
50
|
+
return A("tr",{onClick:()=>Y(t),onDoubleClick:()=>ge(e),className:"cursor-default border-b border-gray-100 "+(_===t?"bg-blue-50":"hover:bg-gray-50"),children:[
|
|
51
|
+
/* @__PURE__ */A("td",{className:"px-3 py-1.5 flex items-center gap-2",children:[
|
|
52
|
+
/* @__PURE__ */I(h,{item:e}),
|
|
53
|
+
/* @__PURE__ */I("span",{className:"truncate",title:e.label,children:e.label})]}),
|
|
54
|
+
/* @__PURE__ */I("td",{className:"px-3 py-1.5 text-xs text-gray-500",children:p(e)}),
|
|
55
|
+
/* @__PURE__ */A("td",{className:"px-3 py-1.5 text-right whitespace-nowrap",children:[
|
|
56
|
+
/* @__PURE__ */I("button",{onClick:t=>{t.stopPropagation(),ge(e)},className:"px-1.5 py-0.5 rounded hover:bg-gray-200 text-blue-600 text-[11px]",children:"Open"}),
|
|
57
|
+
/* @__PURE__ */I("button",{onClick:t=>{t.stopPropagation(),ce?.moveToDesktop([e])},className:"px-1.5 py-0.5 rounded hover:bg-gray-200 text-gray-500 text-[11px] ml-1",children:"Move to desktop"}),
|
|
58
|
+
/* @__PURE__ */I("button",{onClick:t=>{t.stopPropagation(),ce?.removeShortcuts([e])},className:"px-1.5 py-0.5 rounded hover:bg-red-100 text-red-600 text-[11px] ml-1",children:"Remove"})]})]},t)})})]}):"trash"===ie?G&&0===le.length?/* @__PURE__ */I("div",{className:"p-6 text-center text-sm text-gray-400",children:"Loading…"}):0===le.length?/* @__PURE__ */I("div",{className:"p-10 text-center text-sm text-gray-400",children:"Trash is empty."}):/* @__PURE__ */A("table",{className:"w-full text-sm",children:[
|
|
59
|
+
/* @__PURE__ */I("thead",{className:"bg-gray-50 text-[11px] uppercase tracking-wide text-gray-500",children:/* @__PURE__ */A("tr",{children:[
|
|
60
|
+
/* @__PURE__ */I("th",{className:"text-left font-medium px-3 py-1.5",children:"Name"}),
|
|
61
|
+
/* @__PURE__ */I("th",{className:"text-left font-medium px-3 py-1.5",children:"Original location"}),
|
|
62
|
+
/* @__PURE__ */I("th",{className:"text-right font-medium px-3 py-1.5 w-24",children:"Size"}),
|
|
63
|
+
/* @__PURE__ */I("th",{className:"text-right font-medium px-3 py-1.5 w-40",children:"Deleted"}),
|
|
64
|
+
/* @__PURE__ */I("th",{className:"w-44"})]})}),
|
|
65
|
+
/* @__PURE__ */I("tbody",{children:le.map(e=>/* @__PURE__ */A("tr",{className:"border-b border-gray-100 hover:bg-gray-50",children:[
|
|
66
|
+
/* @__PURE__ */A("td",{className:"px-3 py-1.5 flex items-center gap-2",children:["folder"===e.kind?/* @__PURE__ */I(T,{name:"folder",fallback:$,className:"h-4 w-4 text-amber-500 shrink-0"}):/* @__PURE__ */I(T,{name:"page",fallback:C,className:"h-4 w-4 text-gray-400 shrink-0",strokeWidth:1.5}),
|
|
67
|
+
/* @__PURE__ */I("span",{className:"truncate",title:e.name,children:e.name})]}),
|
|
68
|
+
/* @__PURE__ */I("td",{className:"px-3 py-1.5 text-gray-500 text-xs font-mono truncate",title:e.originalPath,children:e.originalPath||"—"}),
|
|
69
|
+
/* @__PURE__ */I("td",{className:"px-3 py-1.5 text-right tabular-nums text-gray-500",children:L(e.size)}),
|
|
70
|
+
/* @__PURE__ */I("td",{className:"px-3 py-1.5 text-right text-gray-500 tabular-nums",children:e.deletedAt?U(e.deletedAt):"—"}),
|
|
71
|
+
/* @__PURE__ */A("td",{className:"px-3 py-1.5 text-right whitespace-nowrap",children:[
|
|
72
|
+
/* @__PURE__ */I("button",{onClick:()=>(async e=>{const t=await ye(`${H}/api/trash/restore`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({id:e.id})});if(!t.ok){const e=await t.json().catch(()=>({}));return void x.error(e.error||`Restore failed (${t.status})`)}x.success(`Restored "${e.name}"`),Ne()})(e),className:"px-1.5 py-0.5 rounded hover:bg-gray-200 text-blue-600 text-[11px]",children:"Restore"}),
|
|
73
|
+
/* @__PURE__ */I("button",{onClick:()=>(async e=>{if(!await g({title:"Permanently delete",message:`"${e.name}" will be permanently removed. This can't be undone.`,confirmLabel:"Delete forever",variant:"danger"}))return;const t=await ye(`${H}/api/trash/${encodeURIComponent(e.id)}`,{method:"DELETE"});if(!t.ok){const e=await t.json().catch(()=>({}));return void x.error(e.error||`Delete failed (${t.status})`)}Ne()})(e),className:"px-1.5 py-0.5 rounded hover:bg-red-100 text-red-600 text-[11px] ml-1",children:"Delete forever"})]})]},e.id))})]}):G&&0===X.length?/* @__PURE__ */I("div",{className:"p-6 text-center text-sm text-gray-400",children:"Loading…"}):0===X.length?/* @__PURE__ */A("div",{className:"p-10 text-center text-sm text-gray-400",children:["Empty folder.",!J&&/* @__PURE__ */A(O,{children:[" Drop files here or click ",
|
|
74
|
+
/* @__PURE__ */I("span",{className:"font-medium",children:"Upload"}),"."]})]}):/* @__PURE__ */A("table",{className:"w-full text-sm",children:[
|
|
75
|
+
/* @__PURE__ */I("thead",{className:"bg-gray-50 text-[11px] uppercase tracking-wide text-gray-500",children:/* @__PURE__ */A("tr",{children:[
|
|
76
|
+
/* @__PURE__ */I("th",{className:"text-left font-medium px-3 py-1.5",children:"Name"}),
|
|
77
|
+
/* @__PURE__ */I("th",{className:"text-right font-medium px-3 py-1.5 w-24",children:"Size"}),
|
|
78
|
+
/* @__PURE__ */I("th",{className:"text-right font-medium px-3 py-1.5 w-40",children:"Modified"}),
|
|
79
|
+
/* @__PURE__ */I("th",{className:"w-32"})]})}),
|
|
80
|
+
/* @__PURE__ */I("tbody",{children:X.map(t=>/* @__PURE__ */A("tr",{onClick:()=>Y(t.name),onDoubleClick:()=>{"folder"===t.kind?V(W(B,t.name)):(async t=>{if(J)return;const a=W(B,t.name),r=(t.name.split(".").pop()||"").toLowerCase(),n=M[r];n?await e({filePath:a,filename:t.name,kind:n,onStaged:e=>ue(e)}):we(t)})(t)},className:"cursor-default border-b border-gray-100 "+(_===t.name?"bg-blue-50":"hover:bg-gray-50"),children:[
|
|
81
|
+
/* @__PURE__ */A("td",{className:"px-3 py-1.5 flex items-center gap-2",children:["folder"===t.kind?/* @__PURE__ */I(T,{name:"folder",fallback:$,className:"h-4 w-4 text-amber-500 shrink-0"}):/* @__PURE__ */I(T,{name:"page",fallback:C,className:"h-4 w-4 text-gray-400 shrink-0",strokeWidth:1.5}),
|
|
82
|
+
/* @__PURE__ */I("span",{className:"truncate",title:t.name,children:t.name})]}),
|
|
83
|
+
/* @__PURE__ */I("td",{className:"px-3 py-1.5 text-right tabular-nums text-gray-500",children:"folder"===t.kind?"—":L(t.size)}),
|
|
84
|
+
/* @__PURE__ */I("td",{className:"px-3 py-1.5 text-right text-gray-500 tabular-nums",children:U(t.modifiedAt)}),
|
|
85
|
+
/* @__PURE__ */I("td",{className:"px-3 py-1.5 text-right whitespace-nowrap",children:!J&&/* @__PURE__ */A(O,{children:["file"===t.kind&&/* @__PURE__ */I("button",{onClick:e=>{e.stopPropagation(),we(t)},className:"px-1.5 py-0.5 rounded hover:bg-gray-200 text-gray-500 text-[11px]",children:"Download"}),
|
|
86
|
+
/* @__PURE__ */I("button",{onClick:e=>{e.stopPropagation(),(async e=>{const t=await y({title:`Rename ${e.kind}`,defaultValue:e.name,confirmLabel:"Rename"});if(!t||t===e.name)return;if(/[\\/]/.test(t))return void x.error("Names cannot contain slashes");const a=W(B,e.name),r=W(B,t),n=await ye(`${H}/api/rename`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({from:a,to:r})});if(!n.ok){const e=await n.json().catch(()=>({}));return void x.error(e.error||`Rename failed (${n.status})`)}ke(B)})(t)},className:"px-1.5 py-0.5 rounded hover:bg-gray-200 text-gray-500 text-[11px] ml-1",children:"Rename"}),
|
|
87
|
+
/* @__PURE__ */I("button",{onClick:e=>{e.stopPropagation(),(async e=>{if(!await g({title:`Delete ${e.kind}`,message:`"${e.name}"${"folder"===e.kind?" and everything inside":""} will be permanently removed.`,confirmLabel:"Delete",variant:"danger"}))return;const t=W(B,e.name),a=await ye(`${H}/api/files?path=${encodeURIComponent(t)}`,{method:"DELETE"});if(!a.ok){const e=await a.json().catch(()=>({}));return void x.error(e.error||`Delete failed (${a.status})`)}ke(B)})(t)},className:"px-1.5 py-0.5 rounded hover:bg-red-100 text-red-600 text-[11px] ml-1",children:"Delete"})]})})]},t.name))})]})})]})})}),re&&/* @__PURE__ */I("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__ */I("div",{className:"px-4 py-2 rounded-md bg-blue-600 text-white text-sm font-medium shadow-lg",children:"Drop to upload"})})]})}export{H as default};
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import{getNumberingConfigs as e}from"./chunk-
|
|
2
|
-
/* @__PURE__ */N("div",{className:"p-2 border-b border-gray-200",children:/* @__PURE__ */k("button",{onClick:()=>{
|
|
1
|
+
import{getNumberingConfigs as e}from"./chunk-ASSDCWKP.js";import{SidebarLayout as t}from"./chunk-YJ6JMGMS.js";import{AboutApp as r}from"./chunk-6GV4467L.js";import{useWindowManager as n,client_default as o}from"./chunk-TLTFS2D6.js";import"./chunk-DSSLOQDW.js";import"./chunk-UAJQB45Y.js";import"./chunk-4QBLTEFU.js";import{toast_default as i}from"./chunk-TKFAFZRY.js";import{useShellPrefs as a}from"./chunk-SSBOC52S.js";import"./chunk-5A7MWTXX.js";import"./chunk-OGXU7QFW.js";import"./chunk-MTH7EAH3.js";import"./chunk-HIAHERCD.js";import"./chunk-AFYQTVZO.js";import"./chunk-HZZNJHRH.js";import"./chunk-X4FJ54PP.js";import"./chunk-D65T4H6J.js";import{AddFallback as l,BookmarkFallback as s,BookmarkFallbackB as c,TrashFallback as d,PageFallback as p,CheckFallback as m}from"./chunk-JJIPGAXI.js";import"./chunk-AJB5G52B.js";import"./chunk-C3QOHMR6.js";import{timeAgo as u}from"./chunk-W32SKK3D.js";import{Icon as h}from"./chunk-YKZHOXI4.js";import{useRef as y,useEffect as g,useState as x,useCallback as b}from"react";import{useQuery as f}from"@tanstack/react-query";import{jsxs as k,Fragment as v,jsx as N}from"react/jsx-runtime";var w=[{key:"yellow",bg:"bg-yellow-100",border:"border-yellow-300",text:"text-yellow-900",dot:"bg-yellow-400"},{key:"blue",bg:"bg-blue-100",border:"border-blue-300",text:"text-blue-900",dot:"bg-blue-400"},{key:"green",bg:"bg-green-100",border:"border-green-300",text:"text-green-900",dot:"bg-green-400"},{key:"pink",bg:"bg-pink-100",border:"border-pink-300",text:"text-pink-900",dot:"bg-pink-400"},{key:"purple",bg:"bg-purple-100",border:"border-purple-300",text:"text-purple-900",dot:"bg-purple-400"},{key:"orange",bg:"bg-orange-100",border:"border-orange-300",text:"text-orange-900",dot:"bg-orange-400"},{key:"white",bg:"bg-white",border:"border-gray-300",text:"text-gray-900",dot:"bg-gray-300"}];var _={sales_order:{entityType:"order",endpoint:"/orders/sales-orders/"},purchase_order:{entityType:"purchase_order",endpoint:"/purchase-orders/"},invoice:{entityType:"invoice",endpoint:"/invoicing/invoices/"},vendor_invoice:{entityType:"vendor_invoice",endpoint:"/invoicing/vendor-invoices/"},shipment:{entityType:"shipment",endpoint:"/shipments/delivery-notes/"},receipt:{entityType:"payment",endpoint:"/invoicing/payments/"},vendor_payment:{entityType:"vendor_payment",endpoint:"/invoicing/vendor-payments/"},vendor_price_sheet:{entityType:"vendor_price_sheet",endpoint:"/pricing/manufacturer-price-sheets/"},client_price_sheet:{entityType:"price_sheet",endpoint:"/pricing/price-sheets/"},qc_report:{entityType:"qc_report",endpoint:"/qc-reports/"},warranty_claim:{entityType:"warranty_claim",endpoint:"/warranty-claims/claims/"},vendor_shipment:{entityType:"vendor_shipment",endpoint:"/shipments/goods-receipts/"}},T=/\[([ xX]?)\]/g;function j(){const{openEntity:j}=n(),{prefs:S,save:C}=a(),{data:$}=f({queryKey:["numbering-configs"],queryFn:()=>e(),retry:!1}),W=y({});g(()=>{if(!$)return;const e={};for(const t of $){const r=_[t.entity_type];if(!r)continue;const n=(t.prefix||"").replace("#","").toUpperCase();if(n&&(e[n]={...r,prefix:t.prefix}),t.alt_prefix){const n=t.alt_prefix.replace("#","").toUpperCase();n&&(e[n]={...r,prefix:t.alt_prefix})}}W.current=e},[$]);const X=S.notepad_notes||[],[O,D]=x(null),[A,H]=x(""),[F,I]=x(""),[J,P]=x("yellow"),[K,q]=x(!1),[B,E]=x(!1),M=y(null),Q=y(),R=X.find(e=>e.id===O);g(()=>{if(!O&&X.length>0){const e=X[0];D(e.id),H(e.title),I(e.content),P(e.color)}},[X.length]);const U=b(e=>{C({notepad_notes:e})},[C]),Z=b(()=>{if(!O||!K)return;const e=X.map(e=>e.id===O?{...e,title:A,content:F,color:J,updated_at:/* @__PURE__ */(new Date).toISOString()}:e);U(e),q(!1)},[O,K,A,F,J,X,U]);g(()=>{if(K)return Q.current&&clearTimeout(Q.current),Q.current=setTimeout(Z,800),()=>{Q.current&&clearTimeout(Q.current)}},[K,Z]),g(()=>()=>{K&&Z()},[]);const G=e=>{K&&Z(),D(e.id),H(e.title),I(e.content),P(e.color),q(!1),E(!1)},L=e=>{const t=F.slice(0,e),r=F.slice(e).match(/^\[([ xX]?)\]/);if(!r)return;const n="x"===r[1]||"X"===r[1]?"[ ]":"[x]",o=F.slice(e+r[0].length);I(t+n+o),q(!0)},Y=async(e,t)=>{const r=W.current[e];if(!r)return;const n=`${e}#${t}`;try{const{data:e}=await o.get(r.endpoint,{params:{search:n,page_size:1}}),t=(e?.results??e??[])[0];t?j(r.entityType,t.id,t,n):i.error(`${n} not found`)}catch{i.error(`Failed to look up ${n}`)}},V="Start writing...\n\nTips:\n [] Type [] for a checkbox, click to toggle\n SO#35001 Type XX#NNNNN to link entities (SO, PO, CI, VI, PL, etc.)",z=/* @__PURE__ */k(v,{children:[
|
|
2
|
+
/* @__PURE__ */N("div",{className:"p-2 border-b border-gray-200",children:/* @__PURE__ */k("button",{onClick:()=>{K&&Z();const e={id:`note-${Date.now()}-${Math.random().toString(36).slice(2,6)}`,title:"",content:"",color:"yellow",sticky:!1,updated_at:/* @__PURE__ */(new Date).toISOString()},t=[e,...X];U(t),D(e.id),H(""),I(""),P("yellow"),q(!1),E(!0),setTimeout(()=>M.current?.focus(),50)},className:"w-full flex items-center justify-center gap-1.5 rounded-lg bg-blue-600 text-white px-3 py-1.5 text-sm font-medium hover:bg-blue-700 transition-colors",children:[
|
|
3
3
|
/* @__PURE__ */N(h,{name:"add",fallback:l,className:"h-4 w-4",strokeWidth:2}),"New Note"]})}),
|
|
4
|
-
/* @__PURE__ */N("div",{className:"flex-1 overflow-y-auto",children:0===
|
|
5
|
-
return k("button",{onClick:()=>
|
|
4
|
+
/* @__PURE__ */N("div",{className:"flex-1 overflow-y-auto",children:0===X.length?/* @__PURE__ */N("p",{className:"text-sm text-gray-400 text-center py-8 px-4",children:"No notes yet. Create one to get started."}):X.map(e=>{const t=(r=e.color,w.find(e=>e.key===r)||w[0]);var r;/* @__PURE__ */
|
|
5
|
+
return k("button",{onClick:()=>G(e),className:"w-full text-left px-3 py-2.5 border-b border-gray-100 transition-colors "+(O===e.id?"bg-blue-50":"hover:bg-gray-50"),children:[
|
|
6
6
|
/* @__PURE__ */k("div",{className:"flex items-center gap-2",children:[
|
|
7
7
|
/* @__PURE__ */N("div",{className:`w-2.5 h-2.5 rounded-full shrink-0 ${t.dot}`}),
|
|
8
8
|
/* @__PURE__ */N("span",{className:"text-sm font-medium text-gray-900 truncate flex-1",children:e.title||"Untitled"}),e.sticky&&/* @__PURE__ */N(h,{name:"bookmark",fallback:s,className:"h-3 w-3 text-amber-500 shrink-0"})]}),
|
|
@@ -10,16 +10,16 @@ return k("button",{onClick:()=>Q(e),className:"w-full text-left px-3 py-2.5 bord
|
|
|
10
10
|
/* @__PURE__ */N("p",{className:"text-[10px] text-gray-300 mt-0.5 ml-4.5",children:u(e.updated_at)})]},e.id)})})]});/* @__PURE__ */
|
|
11
11
|
return k("div",{className:"h-full",children:[
|
|
12
12
|
/* @__PURE__ */N(r,{app:"notepad"}),
|
|
13
|
-
/* @__PURE__ */N(t,{sidebar:z,storageKey:"notepad.sidebarWidth",defaultWidth:224,minWidth:180,maxWidth:360,children:
|
|
13
|
+
/* @__PURE__ */N(t,{sidebar:z,storageKey:"notepad.sidebarWidth",defaultWidth:224,minWidth:180,maxWidth:360,children:O?/* @__PURE__ */k("div",{className:"flex-1 flex flex-col min-w-0",children:[
|
|
14
14
|
/* @__PURE__ */k("div",{className:"flex items-center gap-2 px-4 py-2 border-b border-gray-200",children:[
|
|
15
|
-
/* @__PURE__ */N("input",{value:
|
|
16
|
-
/* @__PURE__ */N("div",{className:"flex gap-1",children:w.map(e=>/* @__PURE__ */N("button",{onClick:()=>{
|
|
17
|
-
/* @__PURE__ */N("button",{onClick:()=>(e=>{const t=
|
|
18
|
-
/* @__PURE__ */N("button",{onClick:()=>(e=>{const t=
|
|
19
|
-
return N("div",{className:c?"line-through text-gray-400":"",children:n},r)})})(
|
|
15
|
+
/* @__PURE__ */N("input",{value:A,onChange:e=>{H(e.target.value),q(!0)},placeholder:"Note title...",className:"flex-1 text-lg font-semibold text-gray-900 outline-none bg-transparent placeholder:text-gray-300"}),
|
|
16
|
+
/* @__PURE__ */N("div",{className:"flex gap-1",children:w.map(e=>/* @__PURE__ */N("button",{onClick:()=>{P(e.key),q(!0)},className:`w-5 h-5 rounded-full border-2 transition-all ${e.dot} ${J===e.key?"border-gray-600 scale-110":"border-transparent hover:border-gray-400"}`,title:e.key},e.key))}),
|
|
17
|
+
/* @__PURE__ */N("button",{onClick:()=>(e=>{const t=X.map(t=>t.id===e?{...t,sticky:!t.sticky}:t);U(t);const r=t.find(t=>t.id===e);i.success(r?.sticky?"Pinned to desktop":"Removed from desktop")})(O),title:R?.sticky?"Remove from desktop":"Pin to desktop",className:"p-1 rounded transition-colors "+(R?.sticky?"text-amber-500 hover:text-amber-600":"text-gray-300 hover:text-amber-400"),children:/* @__PURE__ */N(h,{name:"bookmark",fallback:c,className:"h-4 w-4",fill:R?.sticky?"currentColor":"none",strokeWidth:1.5})}),
|
|
18
|
+
/* @__PURE__ */N("button",{onClick:()=>(e=>{const t=X.filter(t=>t.id!==e);if(U(t),O===e){const e=t[0];e?G(e):(D(null),H(""),I(""))}})(O),title:"Delete note",className:"p-1 rounded text-gray-300 hover:text-red-500 transition-colors",children:/* @__PURE__ */N(h,{name:"trash",fallback:d,className:"h-4 w-4",strokeWidth:1.5})})]}),B?/* @__PURE__ */N("textarea",{ref:M,value:F,onChange:e=>{I(e.target.value),q(!0)},onBlur:()=>{E(!1),K&&Z()},placeholder:V,className:"flex-1 p-4 text-sm text-gray-700 outline-none resize-none bg-transparent leading-relaxed placeholder:text-gray-300 font-mono"}):/* @__PURE__ */N("div",{onClick:()=>{E(!0),setTimeout(()=>M.current?.focus(),50)},className:"flex-1 p-4 text-sm text-gray-700 overflow-y-auto leading-relaxed cursor-text",children:F?(e=>{if(!e)return[];const t=e.split("\n");return t.map((e,r)=>{const n=[];let o=0;const i=[],a=/([A-Z]{2,4})#(\d{4,6})/g;let l;for(;null!==(l=a.exec(e));){const e=l[1],t=l[2];if(W.current[e]){const n=l.index,o=l[0];i.push({idx:n,len:o.length,render:()=>/* @__PURE__ */N("button",{onClick:()=>Y(e,t),className:"text-blue-600 hover:text-blue-800 hover:underline font-medium cursor-pointer",children:o},`ref-${r}-${n}`)})}}T.lastIndex=0;let s=0;for(let e=0;e<r;e++)s+=t[e].length+1;for(;null!==(l=T.exec(e));){const e="x"===l[1]||"X"===l[1],t=l.index,n=s+t;i.push({idx:t,len:l[0].length,render:()=>/* @__PURE__ */N("button",{onClick:()=>L(n),className:`inline-flex items-center justify-center w-4 h-4 rounded border ${e?"bg-blue-500 border-blue-500 text-white":"border-gray-400 bg-white hover:border-blue-400"} cursor-pointer align-text-bottom mr-0.5`,children:e&&/* @__PURE__ */N(h,{name:"check",fallback:m,className:"w-3 h-3",strokeWidth:3})},`cb-${r}-${t}`)})}i.sort((e,t)=>e.idx-t.idx);for(const t of i)t.idx>o&&n.push(/* @__PURE__ */N("span",{children:e.slice(o,t.idx)},`t-${r}-${o}`)),n.push(t.render()),o=t.idx+t.len;o<e.length&&n.push(/* @__PURE__ */N("span",{children:e.slice(o)},`t-${r}-${o}`)),0===n.length&&n.push(/* @__PURE__ */N("span",{children:""},`empty-${r}`));const c=/^\[x\]/i.test(e.trimStart());/* @__PURE__ */
|
|
19
|
+
return N("div",{className:c?"line-through text-gray-400":"",children:n},r)})})(F):/* @__PURE__ */N("p",{className:"text-gray-300 whitespace-pre-line",children:V})}),
|
|
20
20
|
/* @__PURE__ */k("div",{className:"px-4 py-1.5 border-t border-gray-100 flex items-center gap-4 text-[10px] text-gray-400",children:[
|
|
21
21
|
/* @__PURE__ */N("span",{children:"[] checkbox"}),
|
|
22
22
|
/* @__PURE__ */N("span",{children:"SO#35001 entity link"}),
|
|
23
|
-
/* @__PURE__ */N("span",{className:"ml-auto",children:
|
|
23
|
+
/* @__PURE__ */N("span",{className:"ml-auto",children:B?"Editing":"Click to edit"})]})]}):/* @__PURE__ */N("div",{className:"flex-1 flex items-center justify-center",children:/* @__PURE__ */k("div",{className:"text-center text-gray-400",children:[
|
|
24
24
|
/* @__PURE__ */N(h,{name:"page",fallback:p,className:"h-12 w-12 mx-auto mb-3 text-gray-300",strokeWidth:1}),
|
|
25
25
|
/* @__PURE__ */N("p",{className:"text-sm",children:"Select a note or create a new one"})]})})})]})}export{j as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export{PdfViewer as default,fitScale,pdfWasmParams}from"./chunk-Y553QKEH.js";import"./chunk-TKFAFZRY.js";import"./chunk-JJIPGAXI.js";import"./chunk-AJB5G52B.js";import"./chunk-C3QOHMR6.js";import"./chunk-YKZHOXI4.js";
|