efficient-shell 5.2.0 → 5.6.1
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 +165 -33
- package/THIRD_PARTY_NOTICES.md +32 -0
- package/dist/{Browser-FKZ6M2MK.js → Browser-RXGEZ77D.js} +17 -17
- package/dist/Calculator-MVPKTZZF.js +29 -0
- package/dist/ConfirmDialog-XOYCYFA7.js +1 -0
- package/dist/{CurrencyConverter-OV5ZQIAJ.js → CurrencyConverter-2IGOOR3I.js} +8 -8
- package/dist/{Documents-HGGL3AWI.js → Documents-YBLR7WVX.js} +27 -27
- package/dist/Files-7XNR5IL2.js +87 -0
- package/dist/{Notepad-PO724TVP.js → Notepad-ZQYQXV75.js} +13 -13
- package/dist/PdfViewer-SQVMMA7B.js +1 -0
- package/dist/{PomodoroTimer-LN5MYRZO.js → PomodoroTimer-XIUN4M73.js} +19 -19
- package/dist/{Preview-CUOO5WQ7.js → Preview-YCOA5JPP.js} +129 -129
- package/dist/Sidebar-VI7E3EKI.js +44 -0
- package/dist/{Spreadsheet-2N2JXBCY.js → Spreadsheet-SRAUU3OA.js} +14 -14
- package/dist/{Stock-65WVUGLI.js → Stock-7EKOAQ7C.js} +3 -3
- package/dist/{Weather-TXJICMJN.js → Weather-RWI6NKB2.js} +16 -16
- package/dist/{WorldClock-RIHLKZGC.js → WorldClock-CEHWDFEO.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-TKFAFZRY.js → chunk-3HJTOINK.js} +1 -1
- package/dist/{chunk-YJ6JMGMS.js → chunk-4SWPNARR.js} +4 -4
- package/dist/{chunk-Y553QKEH.js → chunk-5ABLFFC5.js} +15 -15
- package/dist/{chunk-JJIPGAXI.js → chunk-6LTDJKIL.js} +72 -71
- package/dist/{chunk-BFFXVA53.js → chunk-7WC3EOFS.js} +1 -1
- package/dist/chunk-AP2QEJXQ.js +1 -0
- package/dist/{chunk-3PTA2C74.js → chunk-CLPJDJH4.js} +1 -1
- package/dist/{chunk-R3622MOL.js → chunk-F6B3J3GW.js} +1 -1
- package/dist/{chunk-UG4ZPXXU.js → chunk-GG7AE6OC.js} +1 -1
- package/dist/{chunk-MTH7EAH3.js → chunk-IMMHJIV5.js} +21 -21
- package/dist/{chunk-ML22KF7T.js → chunk-JXAAZGLJ.js} +1 -1
- package/dist/{chunk-BFUBBDU6.js → chunk-KXAUDC3A.js} +26 -26
- package/dist/{chunk-KHJ5XSEH.js → chunk-N3A3GWJI.js} +8 -8
- package/dist/{chunk-UAJQB45Y.js → chunk-P4CIOJHP.js} +3 -3
- package/dist/{chunk-6GV4467L.js → chunk-RBDGN4YU.js} +5 -5
- package/dist/chunk-RC2EG6P4.js +1026 -0
- package/dist/{chunk-YQI7KXX3.js → chunk-RL626E7Q.js} +2 -2
- package/dist/{chunk-HIAHERCD.js → chunk-RMJZOKHY.js} +9 -9
- package/dist/chunk-SFCDHHQP.js +1 -0
- package/dist/{chunk-M4OGNYOM.js → chunk-SKB6L53D.js} +11 -11
- package/dist/{chunk-H3UEYXRA.js → chunk-TFETN2GI.js} +1 -1
- package/dist/chunk-TNBCUZVE.js +1 -0
- package/dist/{chunk-TLTFS2D6.js → chunk-VWBQ2P5G.js} +56 -56
- package/dist/chunk-WOEFPBQF.js +1 -0
- package/dist/{chunk-ASSDCWKP.js → chunk-WWF2EQXF.js} +1 -1
- package/dist/chunk-XWSWYMGM.js +2 -0
- package/dist/{chunk-SSBOC52S.js → chunk-YGC7AX3X.js} +9 -9
- package/dist/{chunk-QZNRMJE6.js → chunk-YIH6JLMV.js} +2 -2
- package/dist/{chunk-OTP5WPI4.js → chunk-Z7D6Y5WA.js} +16 -16
- package/dist/file-intake/index.js +1 -1
- package/dist/format/index.d.ts +1 -1
- package/dist/format/index.js +1 -1
- package/dist/i18n/index.d.ts +1 -1
- package/dist/icons/efficient-looks.d.ts +28 -0
- package/dist/icons/efficient-looks.js +920 -0
- package/dist/icons/efficient.d.ts +746 -298
- package/dist/icons/efficient.js +336 -470
- package/dist/icons/heroicons.d.ts +1 -1
- package/dist/icons/index.d.ts +10 -4
- package/dist/icons/index.js +1 -1
- package/dist/icons/lucide.d.ts +1 -1
- package/dist/{index-DpUDK9zG.d.ts → index-CHufemKB.d.ts} +69 -1
- package/dist/{index-Dk5VKml6.d.ts → index-ZI6vl2Wq.d.ts} +367 -78
- package/dist/index.d.ts +5 -5
- package/dist/index.js +231 -231
- package/dist/locales/zh-Hans.d.ts +1 -1
- package/dist/locales/zh-Hans.js +1 -1
- package/dist/map/index.js +7 -7
- package/dist/markdown/index.js +1 -1
- package/dist/page-tabs/index.js +5 -5
- package/dist/pdf/index.js +1 -1
- package/dist/{registry-FHdUeVww.d.ts → registry-J-TU7zKx.d.ts} +14 -4
- package/dist/{strings-aKfRDZWB.d.ts → strings-BVB64Nck.d.ts} +26 -0
- package/dist/ui/index.d.ts +4 -4
- package/dist/ui/index.js +1 -1
- package/dist/ui.css +61 -1
- package/package.json +8 -2
- package/dist/Calculator-LBFBTFSD.js +0 -29
- package/dist/ConfirmDialog-JAEFVRJM.js +0 -1
- package/dist/Files-DAQKIF6W.js +0 -87
- package/dist/PdfViewer-6ALXGVTV.js +0 -1
- package/dist/Sidebar-T4ABK2WV.js +0 -44
- package/dist/chunk-4QBLTEFU.js +0 -1
- package/dist/chunk-AJB5G52B.js +0 -1
- package/dist/chunk-FWOPZB6I.js +0 -1
- package/dist/chunk-PS6PSCOR.js +0 -1018
- package/dist/chunk-YKZHOXI4.js +0 -2
|
@@ -1,29 +1,29 @@
|
|
|
1
|
-
import{useDismissPopupsOnOpen as e}from"./chunk-AFYQTVZO.js";import{registerModalEscapeInterceptor as t,Z_LAYERS as n}from"./chunk-X4FJ54PP.js";import{CloseFallbackB as r,WarningFallback as o,CloseFallback as l}from"./chunk-
|
|
1
|
+
import{useDismissPopupsOnOpen as e}from"./chunk-AFYQTVZO.js";import{registerModalEscapeInterceptor as t,Z_LAYERS as n}from"./chunk-X4FJ54PP.js";import{CloseFallbackB as r,WarningFallback as o,CloseFallback as l}from"./chunk-6LTDJKIL.js";import{Icon as i}from"./chunk-XWSWYMGM.js";import{useShellStrings as a,splitAround as s}from"./chunk-TNBCUZVE.js";import{createContext as c,useEffect as d,useRef as u,useId as m,useContext as f,useState as b,useCallback as h}from"react";import{jsxs as g,jsx as p,Fragment as y}from"react/jsx-runtime";var x=["a[href]","button:not([disabled])","input:not([disabled])","select:not([disabled])","textarea:not([disabled])",'[tabindex]:not([tabindex="-1"])'].join(",");function v(e){return Array.from(e.querySelectorAll(x)).filter(e=>null!==e.offsetParent||e===document.activeElement)}var w=[];function N(e){const t=w.findIndex(t=>t!==e&&e.contains(t));-1===t?w.push(e):w.splice(t,0,e)}function k(e){const t=w.lastIndexOf(e);-1!==t&&w.splice(t,1)}var C=/* @__PURE__ */new WeakSet;function L(e){return v(e)}function E(e,t){d(()=>{if(!t)return;const n=e.current;return n?(C.add(n),N(n),()=>{k(n),C.delete(n)}):void 0},[e,t])}function P(e,t){const n=w.lastIndexOf(t),r=n>0?w[n-1]:-1===n?w[w.length-1]??null:null,o=v(r??e.ownerDocument.body).filter(n=>!t.contains(n)&&!e.contains(n)),l=o.find(t=>0!==(e.compareDocumentPosition(t)&Node.DOCUMENT_POSITION_FOLLOWING));return l||(r&&!C.has(r)?o[0]??null:null)}function j(e,t,n){d(()=>{if(!t)return;const r=e.current;if(!r)return;const o=document.activeElement,l=n?.current??v(r)[0]??r;l!==r||r.hasAttribute("tabindex")||r.setAttribute("tabindex","-1"),l.focus();const i=e=>{if("Tab"!==e.key)return;if(w[w.length-1]!==r)return;const t=v(r);if(0===t.length)return void e.preventDefault();const n=t[0],o=t[t.length-1],l=document.activeElement;!e.shiftKey||l!==n&&r.contains(l)?e.shiftKey||l!==o&&r.contains(l)||(e.preventDefault(),n.focus()):(e.preventDefault(),o.focus())};return N(r),document.addEventListener("keydown",i,!0),()=>{k(r),document.removeEventListener("keydown",i,!0),(r.contains(document.activeElement)||document.activeElement===document.body)&&o?.focus?.()}},[e,t,n])}var T=0,W=null;function D(e){d(()=>{if(!e)return;const t=document.body;if(0===T){W={overflow:t.style.overflow,paddingRight:t.style.paddingRight};const e=window.innerWidth-document.documentElement.clientWidth;t.style.overflow="hidden",e>0&&(t.style.paddingRight=`${e}px`)}return T+=1,()=>{0===(T-=1)&&W&&(t.style.overflow=W.overflow,t.style.paddingRight=W.paddingRight,W=null)}},[e])}var F={sm:"max-w-sm",md:"max-w-md",lg:"max-w-lg",xl:"max-w-4xl"};function I({open:o,onClose:l,title:s,description:c,role:f="dialog",children:b,footer:h,blocking:y=!1,size:x="md",initialFocus:v,"aria-label":w,"aria-labelledby":N,"aria-describedby":k,className:C=""}){const L=u(null),E=m(),P=m(),T=!y&&!h,W=m(),I=a().dialog;return e(o),j(L,o,v),D(o),d(()=>{if(o)return t(()=>(y||l(),!0),()=>L.current)},[o,y,l]),o?/* @__PURE__ */g("div",{className:"fixed inset-0",style:{zIndex:n.overlay},role:"presentation",children:[
|
|
2
2
|
/* @__PURE__ */p("div",{className:"fixed inset-0 bg-black/30","aria-hidden":"true"}),
|
|
3
|
-
/* @__PURE__ */p("div",{className:"fixed inset-0 flex items-center justify-center p-4",onClick:y?void 0:e=>{e.target===e.currentTarget&&l()},children:/* @__PURE__ */g("div",{ref:
|
|
4
|
-
return p(
|
|
5
|
-
return p(
|
|
6
|
-
return g(
|
|
7
|
-
/* @__PURE__ */p(
|
|
8
|
-
/* @__PURE__ */p("button",{ref:v,type:"button",onClick:()=>
|
|
9
|
-
/* @__PURE__ */p("button",{type:"button",onClick:()=>
|
|
10
|
-
/* @__PURE__ */p("div",{className:`shrink-0 w-10 h-10 rounded-full flex items-center justify-center ${
|
|
3
|
+
/* @__PURE__ */p("div",{className:"fixed inset-0 flex items-center justify-center p-4",onClick:y?void 0:e=>{e.target===e.currentTarget&&l()},children:/* @__PURE__ */g("div",{ref:L,role:f,"aria-modal":"true","aria-labelledby":s?W:N,"aria-label":s||N?void 0:w,"aria-describedby":k??(c?P:b?E:void 0),className:`relative max-h-full w-full ${F[x]} overflow-y-auto overscroll-contain rounded-(--radius-card) bg-white p-6 shadow-xl ${C}`.trim(),children:[s&&/* @__PURE__ */p("h2",{id:W,className:(T?"pr-8 ":"")+"text-base font-semibold text-gray-900",children:s}),c&&/* @__PURE__ */p("p",{id:P,className:((s?"mt-1":T?"pr-8":"")+" text-sm text-gray-500").trim(),children:c}),b&&/* @__PURE__ */p("div",{id:E,className:"mt-2 text-sm text-gray-600",children:b}),h&&/* @__PURE__ */p("div",{className:"mt-6 flex flex-wrap justify-end gap-3",children:h}),T&&/* @__PURE__ */p("button",{type:"button",onClick:l,"aria-label":I.close,className:"absolute right-3 top-3 rounded-(--radius-control) p-1 text-gray-400 hover:bg-gray-100 hover:text-gray-600 rosh-focus-ring focus-visible:ring-2 focus-visible:ring-[color:var(--rosh-focus-ring-solid)]",children:/* @__PURE__ */p(i,{name:"close",fallback:r,className:"h-5 w-5",strokeWidth:"2",strokeLinecap:"round","aria-hidden":"true"})})]})})]}):null}var O=c(()=>Promise.resolve(!1)),$=()=>f(O),A=()=>Promise.resolve(!1),K=e=>A(e),R=()=>Promise.resolve(!1),S=e=>R(e),M=()=>Promise.resolve(null),V=e=>M(e),z={danger:{icon:"text-red-600 bg-red-100",button:"bg-red-600 hover:bg-red-700 text-white"},warning:{icon:"text-yellow-600 bg-yellow-100",button:"bg-yellow-600 hover:bg-yellow-700 text-white"},info:{icon:"text-blue-600 bg-blue-100",button:"bg-blue-600 hover:bg-blue-700 text-white"}},G="bg-white text-gray-700 border border-gray-300 px-4 py-2 text-sm font-medium rounded-lg hover:bg-gray-50";function J(){/* @__PURE__ */
|
|
4
|
+
return p(i,{name:"warning",fallback:o,className:"h-5 w-5",strokeWidth:1.5,"aria-hidden":"true"})}function U(){/* @__PURE__ */
|
|
5
|
+
return p(i,{name:"close",fallback:l,className:"h-5 w-5",strokeWidth:1.5,"aria-hidden":"true"})}function X({children:e}){const[t,n]=b(!1),[r,o]=b({message:""}),[l,i]=b(0),c=u(),m=u(null),f=u(0),x=u([]),v=u(null),w=u(null),N=h(e=>{m.current=e.id,c.current=e.resolve,i(e.id),o(e.options),n(!0)},[]),k=h(e=>{const t="string"==typeof e?{message:e}:e;return new Promise(e=>{const n={id:++f.current,options:t,resolve:e};null===m.current?N(n):x.current.push(n)})},[N]),[C,L]=b(!1),[E,P]=b({message:""}),[j,T]=b(""),W=u(),D=h(e=>(P(e),T(""),L(!0),new Promise(e=>{W.current=e})),[]),[F,$]=b(!1),[K,S]=b({}),[V,X]=b(""),Y=u(),Z=h(e=>{const t="string"==typeof e?{message:e}:e;return S(t),X(t.defaultValue??""),$(!0),new Promise(e=>{Y.current=e})},[]);d(()=>{A=k,R=D,M=Z},[k,D,Z]);const _=(e,t)=>{if(m.current!==e)return;const r=c.current,o=x.current.shift();o?N(o):(m.current=null,c.current=void 0,n(!1)),r?.(t)},q=e=>{L(!1),T(""),W.current?.(e)},B=e=>{if(e){const e=V.trim();if(!e&&!K.allowEmpty)return $(!1),void Y.current?.(null);$(!1),Y.current?.(e)}else $(!1),Y.current?.(null)},Q=r.variant||(r.confirmLabel?.toLowerCase().includes("delete")||r.message.toLowerCase().includes("delete")?"danger":"info"),H=z[Q],ee=z["warning"===E.variant?"warning":"danger"],te=E.confirmWord,ne=null==te||j===te,re=a().dialog,[oe,le]=s(re.typeToConfirm);/* @__PURE__ */
|
|
6
|
+
return g(O.Provider,{value:k,children:[e,
|
|
7
|
+
/* @__PURE__ */p(I,{open:t,onClose:()=>_(l,!1),initialFocus:v,footer:/* @__PURE__ */g(y,{children:[
|
|
8
|
+
/* @__PURE__ */p("button",{ref:v,type:"button",onClick:()=>_(l,!1),className:G,children:r.cancelLabel||re.cancel}),
|
|
9
|
+
/* @__PURE__ */p("button",{type:"button",onClick:()=>_(l,!0),className:`px-4 py-2 text-sm font-medium rounded-lg ${H.button}`,children:r.confirmLabel||re.ok})]}),children:/* @__PURE__ */g("div",{className:"flex gap-4",children:[
|
|
10
|
+
/* @__PURE__ */p("div",{className:`shrink-0 w-10 h-10 rounded-full flex items-center justify-center ${H.icon}`,children:/* @__PURE__ */p(J,{})}),
|
|
11
11
|
/* @__PURE__ */g("div",{className:"flex-1",children:[
|
|
12
12
|
/* @__PURE__ */p("h2",{className:"text-base font-semibold text-gray-900",children:r.title||re.confirmTitle}),
|
|
13
13
|
/* @__PURE__ */p("p",{className:"mt-2 text-sm text-gray-600",children:r.message})]})]})}),
|
|
14
|
-
/* @__PURE__ */g(
|
|
15
|
-
/* @__PURE__ */p("button",{ref:w,type:"button",onClick:()=>
|
|
16
|
-
/* @__PURE__ */p("button",{type:"button",onClick:()=>
|
|
17
|
-
/* @__PURE__ */p("button",{type:"button",onClick:()=>
|
|
14
|
+
/* @__PURE__ */g(I,{open:C,onClose:()=>q(!1),initialFocus:null!=te?void 0:w,footer:/* @__PURE__ */g(y,{children:[
|
|
15
|
+
/* @__PURE__ */p("button",{ref:w,type:"button",onClick:()=>q(!1),className:G,children:E.cancelLabel||re.destructiveCancel}),
|
|
16
|
+
/* @__PURE__ */p("button",{type:"button",onClick:()=>q(!0),disabled:!ne,className:`px-4 py-2 text-sm font-medium rounded-lg disabled:opacity-40 ${ee.button}`,children:te??E.confirmLabel??re.destructiveConfirm})]}),children:[
|
|
17
|
+
/* @__PURE__ */p("button",{type:"button",onClick:()=>q(!1),"aria-label":re.close,className:"absolute right-4 top-4 rounded-md p-1 text-gray-400 hover:bg-gray-100 hover:text-gray-600",children:/* @__PURE__ */p(U,{})}),
|
|
18
18
|
/* @__PURE__ */g("div",{className:"flex gap-4",children:[
|
|
19
|
-
/* @__PURE__ */p("div",{className:`shrink-0 w-10 h-10 rounded-full flex items-center justify-center ${ee.icon}`,children:/* @__PURE__ */p(
|
|
19
|
+
/* @__PURE__ */p("div",{className:`shrink-0 w-10 h-10 rounded-full flex items-center justify-center ${ee.icon}`,children:/* @__PURE__ */p(J,{})}),
|
|
20
20
|
/* @__PURE__ */g("div",{className:"flex-1",children:[
|
|
21
|
-
/* @__PURE__ */p("h2",{className:"text-base font-semibold text-gray-900 pr-6",children:
|
|
22
|
-
/* @__PURE__ */p("p",{className:"mt-2 text-sm text-gray-600",children:
|
|
21
|
+
/* @__PURE__ */p("h2",{className:"text-base font-semibold text-gray-900 pr-6",children:E.title||re.destructiveTitle}),
|
|
22
|
+
/* @__PURE__ */p("p",{className:"mt-2 text-sm text-gray-600",children:E.message}),null!=te&&/* @__PURE__ */g(y,{children:[
|
|
23
23
|
/* @__PURE__ */g("p",{className:"mt-3 text-sm text-gray-700",children:[oe,
|
|
24
24
|
/* @__PURE__ */p("kbd",{className:"rounded border border-gray-300 bg-gray-50 px-1.5 py-0.5 text-xs font-bold text-red-600 font-mono",children:te}),le]}),
|
|
25
|
-
/* @__PURE__ */p("input",{autoFocus:!0,type:"text",value:j,onChange:e=>
|
|
26
|
-
/* @__PURE__ */g(
|
|
27
|
-
/* @__PURE__ */p("button",{type:"button",onClick:()=>
|
|
28
|
-
/* @__PURE__ */p("button",{type:"button",onClick:()=>
|
|
29
|
-
/* @__PURE__ */p("input",{autoFocus:!0,type:"text",value:
|
|
25
|
+
/* @__PURE__ */p("input",{autoFocus:!0,type:"text",value:j,onChange:e=>T(e.target.value),onKeyDown:e=>{"Enter"===e.key&&j===te&&q(!0)},placeholder:te,className:"mt-2 w-full rounded-md border border-gray-300 px-3 py-2 text-sm focus:border-red-500"})]})]})]})]}),
|
|
26
|
+
/* @__PURE__ */g(I,{open:F,onClose:()=>B(!1),title:K.title||re.promptTitle,footer:/* @__PURE__ */g(y,{children:[
|
|
27
|
+
/* @__PURE__ */p("button",{type:"button",onClick:()=>B(!1),className:G,children:K.cancelLabel||re.cancel}),
|
|
28
|
+
/* @__PURE__ */p("button",{type:"button",onClick:()=>B(!0),disabled:!K.allowEmpty&&!V.trim(),className:"bg-blue-600 hover:bg-blue-700 text-white px-4 py-2 text-sm font-medium rounded-lg disabled:opacity-40",children:K.confirmLabel||re.ok})]}),children:[K.message&&/* @__PURE__ */p("p",{className:"text-sm text-gray-600",children:K.message}),
|
|
29
|
+
/* @__PURE__ */p("input",{autoFocus:!0,type:"text",value:V,onChange:e=>X(e.target.value),onKeyDown:e=>{"Enter"===e.key?B(!0):"Escape"===e.key&&B(!1)},onFocus:e=>e.target.select(),placeholder:K.placeholder,className:"mt-3 w-full rounded-md border border-gray-300 px-3 py-2 text-sm focus:border-blue-500 rosh-focus-ring focus-visible:ring-1 focus-visible:ring-[color:var(--rosh-focus-ring-accent)]"})]})]})}export{X as ConfirmProvider,I as Dialog,K as confirm,S as confirmDestructive,L as focusableIn,V as prompt,P as stopAfter,$ as useConfirm,j as useFocusTrap,D as useScrollLock,E as useTabLayer};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{requestFilesTrashView as n}from"./chunk-
|
|
1
|
+
import{requestFilesTrashView as n}from"./chunk-RL626E7Q.js";var o=null;function r(n){o=n}function t(){return o}function u(){n()}export{t as getFilesDemoTree,u as openFilesInTrashMode,r as setFilesDemoTree};
|
|
@@ -1,54 +1,54 @@
|
|
|
1
|
-
import{toast_default as e}from"./chunk-
|
|
1
|
+
import{toast_default as e}from"./chunk-3HJTOINK.js";import{useShellStrings as t}from"./chunk-TNBCUZVE.js";import{forwardRef as r,useRef as n,useState as o,useMemo as i,useEffect as a,useImperativeHandle as l}from"react";import{jsx as c,jsxs as s,Fragment as d}from"react/jsx-runtime";var h=["#ef4444","#f97316","#eab308","#22c55e","#3b82f6","#8b5cf6","#000000","#ffffff"],u=[{id:"system",name:"fontSystem",css:"-apple-system, system-ui, sans-serif"},{id:"serif",name:"fontSerif",css:'Georgia, "Times New Roman", serif'},{id:"mono",name:"fontMono",css:'ui-monospace, "SF Mono", Menlo, monospace'},{id:"cursive",name:"fontCursive",css:'"Brush Script MT", "Comic Sans MS", cursive'}],p=()=>Math.random().toString(36).slice(2,9),y=r(function({src:r,filename:y,onApply:m,onCancel:g},N){const L=n(null),z=n(null),D=n(null),E=n(null),P=t().annotator,$=n(P);$.current=P;const[I,S]=o("select"),[W,B]=o(h[0]),[R,j]=o(4),[H,T]=o(24),[F,U]=o(u[0].id),[A,O]=o(!0),[K,V]=o(!1),[Z,X]=o(!1),[q,G]=o(null),[Y,_]=o(null),[J,Q]=o(6),[ee,te]=o(12),[re,ne]=o([]),[oe,ie]=o(null),[ae,le]=o(null),[ce,se]=o(null),[de,he]=o(1),[ue,pe]=o(null),[ye,xe]=o(null),[me,ge]=o(null),we=n(null),[fe,be]=o(!1),ve=i(()=>ce?{w:ce.w*de,h:ce.h*de}:null,[ce,de]),ke=ve&&ae?ve.w/ae.w:1,Me=i(()=>re.find(e=>e.id===oe)??null,[re,oe]);a(()=>{"select"===I&&Me&&("color"in Me&&B(Me.color),"stroke"in Me&&j(Me.stroke),"rect"===Me.type&&te(Me.radius),"text"===Me.type&&(T(Me.size),U(Me.font),O(Me.bold),V(Me.italic),X(Me.underline),G(Me.borderColor),_(Me.background),Q(Me.padding)))},[oe]),a(()=>{const t=new Image;t.crossOrigin="anonymous",t.onload=()=>{E.current=t,le({w:t.naturalWidth,h:t.naturalHeight}),ne([]),ie(null)},t.onerror=()=>e.error($.current.loadFailed),t.src=r},[r]),a(()=>{if(!ae)return;const e=()=>{const e=L.current;if(!e)return;const t=e.getBoundingClientRect(),r=Math.max(0,t.width-32),n=Math.max(0,t.height-32);if(0===r||0===n)return;const o=ae.w/ae.h;let i=ae.w,a=ae.h;i>r&&(i=r,a=i/o),a>n&&(a=n,i=a*o),se({w:i,h:a})};e();const t=new ResizeObserver(e);return L.current&&t.observe(L.current),()=>t.disconnect()},[ae]);const Ne=i(()=>re.filter(e=>"mosaic"===e.type),[re]);a(()=>{const e=E.current,t=z.current;if(!e||!t||!ae)return;t.width=ae.w,t.height=ae.h;const r=t.getContext("2d");r.drawImage(e,0,0);for(const e of Ne)C(r,e)},[ae,Ne,ce]);const Ce=e=>{const t=D.current;if(!t)return{x:0,y:0};const r=t.createSVGPoint();r.x=e.clientX,r.y=e.clientY;const n=t.getScreenCTM();if(!n)return{x:0,y:0};const o=r.matrixTransform(n.inverse());return{x:o.x,y:o.y}},Le=e=>{we.current=e,be(!0)};a(()=>{if(!fe)return;const e=e=>{const t=we.current;if(!t)return;const r=Ce(e);if("draw"===t.kind)pe(b(I,t.start,r,W,R,ee));else if("pen"===t.kind){const e=t.points[t.points.length-1];(Math.abs(r.x-e.x)>1||Math.abs(r.y-e.y)>1)&&(t.points.push(r),pe({id:"",type:"draw",points:t.points.slice(),color:W,stroke:R}))}else if("crop"===t.kind)ge(M(t.start,r));else if("move"===t.kind){const e=r.x-t.start.x,n=r.y-t.start.y;ne(r=>r.map(r=>r.id===t.id?v(t.original,e,n):r))}else"resize"===t.kind&&ne(e=>e.map(e=>e.id===t.id?function(e,t,r){if("arrow"===e.type)return"start"===t?{...e,x1:r.x,y1:r.y}:"end"===t?{...e,x2:r.x,y2:r.y}:e;if("text"===e.type||"draw"===e.type)return e;const n=e.x,o=e.x+e.w,i=e.y,a=e.y+e.h;let l=n,c=i,s=o,d=a;"nw"===t&&(l=r.x,c=r.y);"ne"===t&&(s=r.x,c=r.y);"se"===t&&(s=r.x,d=r.y);"sw"===t&&(l=r.x,d=r.y);const h=M({x:l,y:c},{x:s,y:d});return{...e,x:h.x,y:h.y,w:h.w,h:h.h}}(t.original,t.corner,r):e))},t=()=>{const e=we.current;if(we.current=null,be(!1),"draw"===e?.kind)pe(e=>{if(!e||("arrow"===(t=e).type?Math.abs(t.x2-t.x1)<4&&Math.abs(t.y2-t.y1)<4:"draw"===t.type?t.points.length<2:"w"in t&&"h"in t&&(t.w<4||t.h<4)))return null;var t;const r={...e,id:p()};return ne(e=>[...e,r]),ie(r.id),S("select"),null});else if("pen"===e?.kind){if(e.points.length<2)return void pe(null);const t={id:p(),type:"draw",points:e.points,color:W,stroke:R};ne(e=>[...e,t]),ie(t.id),S("select"),pe(null)}};return window.addEventListener("pointermove",e),window.addEventListener("pointerup",t),window.addEventListener("pointercancel",t),()=>{window.removeEventListener("pointermove",e),window.removeEventListener("pointerup",t),window.removeEventListener("pointercancel",t)}},[fe,I,W,R,ee]);a(()=>{const e=e=>{if(!document.activeElement||!/^(INPUT|TEXTAREA)$/.test(document.activeElement.tagName))return!e.metaKey&&!e.ctrlKey||"z"!==e.key&&"Z"!==e.key||e.shiftKey?void(oe&&("Delete"===e.key||"Backspace"===e.key?(e.preventDefault(),ne(e=>e.filter(e=>e.id!==oe)),ie(null)):"Escape"===e.key&&ie(null))):(e.preventDefault(),ne(e=>e.slice(0,-1)),void ie(null))};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[oe]);const ze=e=>{const t=!{bold:A,italic:K,underline:Z}[e];"bold"===e&&O(t),"italic"===e&&V(t),"underline"===e&&X(t),oe&&ne(r=>r.map(r=>r.id===oe&&"text"===r.type?{...r,[e]:t}:r))},De=e=>{G(e),oe&&ne(t=>t.map(t=>t.id===oe&&"text"===t.type?{...t,borderColor:e}:t))},Ee=e=>{_(e),oe&&ne(t=>t.map(t=>t.id===oe&&"text"===t.type?{...t,background:e}:t))},Pe=e=>{if(!ye)return;const t=e??ye.value;if(!t.trim())return ye.editingId&&ne(e=>e.filter(e=>e.id!==ye.editingId)),void xe(null);if(ye.editingId)ne(e=>e.map(e=>e.id===ye.editingId&&"text"===e.type?{...e,text:t}:e));else{const e={id:p(),type:"text",x:ye.x,y:ye.y,text:t,color:W,size:H,font:F,bold:A,italic:K,underline:Z,borderColor:q,background:Y,padding:J};ne(t=>[...t,e]),ie(e.id),S("select")}xe(null)},$e=async()=>{const e=z.current,t=D.current;if(!e||!t||!ae)return null;const r=document.createElement("canvas");r.width=ae.w,r.height=ae.h;const n=r.getContext("2d");n.drawImage(e,0,0);const o=t.cloneNode(!0);o.querySelectorAll("[data-chrome]").forEach(e=>e.remove());const i=(new XMLSerializer).serializeToString(o),a=new Blob([i],{type:"image/svg+xml;charset=utf-8"}),l=URL.createObjectURL(a),c=new Image;return await new Promise(e=>{c.onload=()=>e(),c.onerror=()=>e(),c.src=l}),n.drawImage(c,0,0,ae.w,ae.h),URL.revokeObjectURL(l),r};l(N,()=>({save:async()=>{const t=await $e();t&&t.toBlob(t=>{if(!t)return void e.error($.current.exportFailed);const r=URL.createObjectURL(t),n=document.createElement("a");n.href=r;const o=y.replace(/\.[^.]+$/,"");n.download=`${o}-annotated.png`,n.click(),URL.revokeObjectURL(r)},"image/png")},copy:async()=>{if(!("clipboard"in navigator)||"undefined"==typeof ClipboardItem)return void e.error($.current.clipboardUnsupported);const t=await $e();t&&t.toBlob(async t=>{if(t)try{await navigator.clipboard.write([new ClipboardItem({"image/png":t})]),e.success($.current.copied)}catch{e.error($.current.copyRefused)}else e.error($.current.copyFailed)},"image/png")}}),[ae,y]);const Ie=i(()=>[{id:"select",label:P.toolSelect,icon:/* @__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:"M5 3l7 17 2-7 7-2L5 3z"})})},{id:"draw",label:P.toolDraw,icon:/* @__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.862 4.487l1.687-1.688a1.875 1.875 0 112.652 2.652L6.832 19.82a4.5 4.5 0 01-1.897 1.13l-2.685.8.8-2.685a4.5 4.5 0 011.13-1.897L16.863 4.487z"})})},{id:"rect",label:P.toolRect,icon:/* @__PURE__ */c("svg",{className:"h-4 w-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.8,children:/* @__PURE__ */c("rect",{x:"4",y:"6",width:"16",height:"12",rx:"3"})})},{id:"circle",label:P.toolEllipse,icon:/* @__PURE__ */c("svg",{className:"h-4 w-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.8,children:/* @__PURE__ */c("ellipse",{cx:"12",cy:"12",rx:"8",ry:"6"})})},{id:"arrow",label:P.toolArrow,icon:/* @__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:"M5 19L19 5m0 0h-7m7 0v7"})})},{id:"mosaic",label:P.toolMosaic,icon:/* @__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:"M4 4h6v6H4zM14 4h6v6h-6zM4 14h6v6H4zM14 14h6v6h-6z"})})},{id:"text",label:P.toolText,icon:/* @__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:"M4 6h16M12 6v14M9 20h6"})})},{id:"crop",label:P.toolCrop,icon:/* @__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:"M6 2v15a1 1 0 001 1h15M2 6h15a1 1 0 011 1v15"})})}],[P]),Se=e=>"p-1.5 rounded transition-colors "+(e?"bg-blue-500 text-white":"text-gray-700 hover:bg-gray-200"),We=Me?.type??("select"===I?null:I),Be="rect"===We||"circle"===We||"arrow"===We||"draw"===We,Re="rect"===We,je="text"===We;/* @__PURE__ */
|
|
2
2
|
return s("div",{className:"flex flex-col h-full bg-gray-100",children:[
|
|
3
3
|
/* @__PURE__ */s("div",{className:"flex items-center gap-1.5 px-3 py-2 border-b border-gray-200 bg-white shrink-0 flex-wrap text-[12px]",children:[Ie.map(e=>/* @__PURE__ */c("button",{onClick:()=>{S(e.id),ie(null)},title:e.label,className:Se(I===e.id),children:e.icon},e.id)),
|
|
4
4
|
/* @__PURE__ */c("div",{className:"h-5 w-px bg-gray-300 mx-1"}),
|
|
5
5
|
/* @__PURE__ */c("div",{className:"flex items-center gap-1",children:h.map(e=>/* @__PURE__ */c("button",{onClick:()=>(e=>{B(e),oe&&ne(t=>t.map(t=>t.id!==oe||"mosaic"===t.type?t:{...t,color:e}))})(e),title:e,className:"h-5 w-5 rounded-full border "+(W===e?"ring-2 ring-blue-500 ring-offset-1":"border-gray-300"),style:{background:e}},e))}),Be&&/* @__PURE__ */s(d,{children:[
|
|
6
6
|
/* @__PURE__ */c("div",{className:"h-5 w-px bg-gray-300 mx-1"}),
|
|
7
7
|
/* @__PURE__ */s("label",{className:"flex items-center gap-1.5 text-gray-600",children:[
|
|
8
|
-
/* @__PURE__ */c("span",{children
|
|
8
|
+
/* @__PURE__ */c("span",{children:P.weight}),
|
|
9
9
|
/* @__PURE__ */c("input",{type:"range",min:1,max:20,step:1,value:R,onChange:e=>{return t=Number(e.target.value),j(t),void(oe&&ne(e=>e.map(e=>e.id!==oe?e:"rect"===e.type||"circle"===e.type||"arrow"===e.type||"draw"===e.type?{...e,stroke:t}:e)));var t},className:"w-16 accent-blue-500"}),
|
|
10
10
|
/* @__PURE__ */c("span",{className:"tabular-nums w-5 text-right",children:R})]})]}),Re&&/* @__PURE__ */s(d,{children:[
|
|
11
11
|
/* @__PURE__ */c("div",{className:"h-5 w-px bg-gray-300 mx-1"}),
|
|
12
12
|
/* @__PURE__ */s("label",{className:"flex items-center gap-1.5 text-gray-600",children:[
|
|
13
|
-
/* @__PURE__ */c("span",{children
|
|
13
|
+
/* @__PURE__ */c("span",{children:P.radius}),
|
|
14
14
|
/* @__PURE__ */c("input",{type:"range",min:0,max:48,step:1,value:ee,onChange:e=>{return t=Number(e.target.value),te(t),void(oe&&ne(e=>e.map(e=>e.id===oe&&"rect"===e.type?{...e,radius:t}:e)));var t},className:"w-16 accent-blue-500"}),
|
|
15
15
|
/* @__PURE__ */c("span",{className:"tabular-nums w-6 text-right",children:ee})]})]}),je&&/* @__PURE__ */s(d,{children:[
|
|
16
16
|
/* @__PURE__ */c("div",{className:"h-5 w-px bg-gray-300 mx-1"}),
|
|
17
|
-
/* @__PURE__ */c("select",{value:
|
|
18
|
-
/* @__PURE__ */c("button",{onClick:()=>ze("bold"),className:Se(
|
|
19
|
-
/* @__PURE__ */c("button",{onClick:()=>ze("italic"),className:Se(K),title
|
|
20
|
-
/* @__PURE__ */c("button",{onClick:()=>ze("underline"),className:Se(
|
|
17
|
+
/* @__PURE__ */c("select",{value:F,onChange:e=>{return t=e.target.value,U(t),void(oe&&ne(e=>e.map(e=>e.id===oe&&"text"===e.type?{...e,font:t}:e)));var t},className:"text-xs border border-gray-300 rounded px-1 py-0.5 bg-white",children:u.map(e=>/* @__PURE__ */c("option",{value:e.id,children:P[e.name]},e.id))}),
|
|
18
|
+
/* @__PURE__ */c("button",{onClick:()=>ze("bold"),className:Se(A),title:P.bold,children:/* @__PURE__ */c("span",{className:"font-bold",children:P.boldLetter})}),
|
|
19
|
+
/* @__PURE__ */c("button",{onClick:()=>ze("italic"),className:Se(K),title:P.italic,children:/* @__PURE__ */c("span",{className:"italic",children:P.italicLetter})}),
|
|
20
|
+
/* @__PURE__ */c("button",{onClick:()=>ze("underline"),className:Se(Z),title:P.underline,children:/* @__PURE__ */c("span",{className:"underline",children:P.underlineLetter})}),
|
|
21
21
|
/* @__PURE__ */s("label",{className:"flex items-center gap-1.5 text-gray-600",children:[
|
|
22
|
-
/* @__PURE__ */c("span",{children
|
|
23
|
-
/* @__PURE__ */c("input",{type:"range",min:10,max:96,step:1,value:
|
|
24
|
-
/* @__PURE__ */c("span",{className:"tabular-nums w-7 text-right",children:
|
|
22
|
+
/* @__PURE__ */c("span",{children:P.size}),
|
|
23
|
+
/* @__PURE__ */c("input",{type:"range",min:10,max:96,step:1,value:H,onChange:e=>{return t=Number(e.target.value),T(t),void(oe&&ne(e=>e.map(e=>e.id===oe&&"text"===e.type?{...e,size:t}:e)));var t},className:"w-16 accent-blue-500"}),
|
|
24
|
+
/* @__PURE__ */c("span",{className:"tabular-nums w-7 text-right",children:H})]}),
|
|
25
25
|
/* @__PURE__ */s("label",{className:"flex items-center gap-1 text-gray-600",children:[
|
|
26
|
-
/* @__PURE__ */c("span",{children
|
|
27
|
-
/* @__PURE__ */c("input",{type:"color",value:
|
|
28
|
-
/* @__PURE__ */c("button",{onClick:()=>De(null),title
|
|
26
|
+
/* @__PURE__ */c("span",{children:P.border}),q?/* @__PURE__ */s(d,{children:[
|
|
27
|
+
/* @__PURE__ */c("input",{type:"color",value:q,onChange:e=>De(e.target.value),title:P.borderColor,className:"h-5 w-6 rounded border border-gray-300 bg-white p-0 cursor-pointer"}),
|
|
28
|
+
/* @__PURE__ */c("button",{onClick:()=>De(null),title:P.removeBorder,className:"px-0.5 text-gray-400 hover:text-gray-700",children:"✕"})]}):/* @__PURE__ */c("button",{onClick:()=>De(W),title:P.addBorder,className:"px-1.5 py-0.5 rounded border border-gray-300 text-gray-600 hover:bg-gray-100",children:P.add})]}),
|
|
29
29
|
/* @__PURE__ */s("label",{className:"flex items-center gap-1 text-gray-600",children:[
|
|
30
|
-
/* @__PURE__ */c("span",{children
|
|
31
|
-
/* @__PURE__ */c("input",{type:"color",value:
|
|
32
|
-
/* @__PURE__ */c("button",{onClick:()=>
|
|
30
|
+
/* @__PURE__ */c("span",{children:P.fill}),Y?/* @__PURE__ */s(d,{children:[
|
|
31
|
+
/* @__PURE__ */c("input",{type:"color",value:Y,onChange:e=>Ee(e.target.value),title:P.fillColor,className:"h-5 w-6 rounded border border-gray-300 bg-white p-0 cursor-pointer"}),
|
|
32
|
+
/* @__PURE__ */c("button",{onClick:()=>Ee(null),title:P.removeFill,className:"px-0.5 text-gray-400 hover:text-gray-700",children:"✕"})]}):/* @__PURE__ */c("button",{onClick:()=>Ee("#ffffff"),title:P.addFill,className:"px-1.5 py-0.5 rounded border border-gray-300 text-gray-600 hover:bg-gray-100",children:P.add})]}),
|
|
33
33
|
/* @__PURE__ */s("label",{className:"flex items-center gap-1.5 text-gray-600",children:[
|
|
34
|
-
/* @__PURE__ */c("span",{children
|
|
34
|
+
/* @__PURE__ */c("span",{children:P.padding}),
|
|
35
35
|
/* @__PURE__ */c("input",{type:"range",min:0,max:40,step:1,value:J,onChange:e=>{return t=Number(e.target.value),Q(t),void(oe&&ne(e=>e.map(e=>e.id===oe&&"text"===e.type?{...e,padding:t}:e)));var t},className:"w-14 accent-blue-500"}),
|
|
36
36
|
/* @__PURE__ */c("span",{className:"tabular-nums w-6 text-right",children:J})]})]}),
|
|
37
37
|
/* @__PURE__ */c("div",{className:"h-5 w-px bg-gray-300 mx-1"}),
|
|
38
|
-
/* @__PURE__ */c("button",{onClick:()=>he(e=>Math.max(.25,Math.round(100*(e-.25))/100)),className:"px-2 py-1 rounded hover:bg-gray-200 text-gray-700",title
|
|
38
|
+
/* @__PURE__ */c("button",{onClick:()=>he(e=>Math.max(.25,Math.round(100*(e-.25))/100)),className:"px-2 py-1 rounded hover:bg-gray-200 text-gray-700",title:P.zoomOut,children:"−"}),
|
|
39
39
|
/* @__PURE__ */s("span",{className:"text-gray-600 tabular-nums w-10 text-center",children:[Math.round(100*de),"%"]}),
|
|
40
|
-
/* @__PURE__ */c("button",{onClick:()=>he(e=>Math.min(4,Math.round(100*(e+.25))/100)),className:"px-2 py-1 rounded hover:bg-gray-200 text-gray-700",title
|
|
41
|
-
/* @__PURE__ */c("button",{onClick:()=>he(1),className:"px-2 py-1 rounded hover:bg-gray-200 text-gray-700",title
|
|
40
|
+
/* @__PURE__ */c("button",{onClick:()=>he(e=>Math.min(4,Math.round(100*(e+.25))/100)),className:"px-2 py-1 rounded hover:bg-gray-200 text-gray-700",title:P.zoomIn,children:"+"}),
|
|
41
|
+
/* @__PURE__ */c("button",{onClick:()=>he(1),className:"px-2 py-1 rounded hover:bg-gray-200 text-gray-700",title:P.fitHint,children:P.fit}),
|
|
42
42
|
/* @__PURE__ */c("div",{className:"h-5 w-px bg-gray-300 mx-1"}),
|
|
43
|
-
/* @__PURE__ */c("button",{onClick:()=>{ne(e=>e.slice(0,-1)),ie(null)},disabled:0===re.length,className:"px-2 py-1 rounded hover:bg-gray-200 disabled:opacity-30 text-gray-700",children
|
|
43
|
+
/* @__PURE__ */c("button",{onClick:()=>{ne(e=>e.slice(0,-1)),ie(null)},disabled:0===re.length,className:"px-2 py-1 rounded hover:bg-gray-200 disabled:opacity-30 text-gray-700",children:P.undo}),
|
|
44
44
|
/* @__PURE__ */s("div",{className:"ml-auto flex items-center gap-2",children:[me&&/* @__PURE__ */s(d,{children:[
|
|
45
|
-
/* @__PURE__ */c("button",{onClick:()=>{if(!me||!
|
|
46
|
-
/* @__PURE__ */c("button",{onClick:()=>ge(null),className:"px-2 py-1 rounded hover:bg-gray-200 text-gray-700",children
|
|
47
|
-
/* @__PURE__ */c("button",{onClick:async()=>{const t=await
|
|
45
|
+
/* @__PURE__ */c("button",{onClick:()=>{if(!me||!E.current||!ae)return;const e=me,t=document.createElement("canvas");t.width=Math.round(e.w),t.height=Math.round(e.h);const r=t.getContext("2d"),n=document.createElement("canvas");n.width=ae.w,n.height=ae.h;const o=n.getContext("2d");o.drawImage(E.current,0,0);for(const e of Ne)C(o,e);r.drawImage(n,e.x,e.y,e.w,e.h,0,0,e.w,e.h);const i=new Image;i.onload=()=>{E.current=i,le({w:i.naturalWidth,h:i.naturalHeight}),ne(t=>t.filter(e=>"mosaic"!==e.type).map(t=>v(t,-e.x,-e.y)).filter(e=>function(e,t,r){const n=k(e);return n.x+n.w>0&&n.y+n.h>0&&n.x<t&&n.y<r}(e,i.naturalWidth,i.naturalHeight))),ge(null)},i.src=t.toDataURL("image/png")},className:"px-2 py-1 rounded bg-blue-500 text-white hover:bg-blue-600",children:P.applyCrop}),
|
|
46
|
+
/* @__PURE__ */c("button",{onClick:()=>ge(null),className:"px-2 py-1 rounded hover:bg-gray-200 text-gray-700",children:P.cancel})]}),m&&!me&&/* @__PURE__ */s(d,{children:[g&&/* @__PURE__ */c("button",{onClick:g,className:"px-3 py-1 rounded hover:bg-gray-200 text-gray-700 text-xs font-medium",children:P.cancel}),
|
|
47
|
+
/* @__PURE__ */c("button",{onClick:async()=>{const t=await $e();t?t.toBlob(t=>{t?m(t):e.error($.current.exportFailed)},"image/png"):e.error($.current.exportFailed)},className:"px-3 py-1 rounded bg-blue-500 text-white hover:bg-blue-600 text-xs font-medium",children:P.apply})]})]})]}),
|
|
48
48
|
/* @__PURE__ */c("div",{ref:L,className:"flex-1 overflow-auto bg-gray-200 flex items-center justify-center p-4 relative",children:ve&&ae&&/* @__PURE__ */s("div",{className:"relative shadow-lg rounded overflow-hidden bg-white shrink-0",style:{width:ve.w,height:ve.h},children:[
|
|
49
49
|
/* @__PURE__ */c("canvas",{ref:z,style:{position:"absolute",inset:0,width:"100%",height:"100%",display:"block"}}),
|
|
50
|
-
/* @__PURE__ */s("svg",{ref:D,viewBox:`0 0 ${ae.w} ${ae.h}`,preserveAspectRatio:"none",style:{position:"absolute",inset:0,width:"100%",height:"100%",touchAction:"none",cursor:"select"===I?"default":"text"===I?"text":"crosshair"},onPointerDown:e=>{if("select"===I)return void ie(null);if("text"===I){if(ye)return void
|
|
51
|
-
/* @__PURE__ */c("div",{className:"px-3 py-1.5 border-t border-gray-200 bg-white text-[11px] text-gray-500 shrink-0",children:"select"===I?oe
|
|
50
|
+
/* @__PURE__ */s("svg",{ref:D,viewBox:`0 0 ${ae.w} ${ae.h}`,preserveAspectRatio:"none",style:{position:"absolute",inset:0,width:"100%",height:"100%",touchAction:"none",cursor:"select"===I?"default":"text"===I?"text":"crosshair"},onPointerDown:e=>{if("select"===I)return void ie(null);if("text"===I){if(ye)return void Pe();const t=Ce(e);return void xe({x:t.x,y:t.y,value:""})}const t=Ce(e);if("crop"!==I){if("draw"===I)return Le({kind:"pen",points:[t]}),void pe({id:"",type:"draw",points:[t],color:W,stroke:R});pe(b(I,t,t,W,R,ee)),Le({kind:"draw",start:t})}else Le({kind:"crop",start:t})},children:[re.map(e=>/* @__PURE__ */c(x,{anno:e,selected:oe===e.id,zoom:de,onPointerDown:t=>((e,t)=>{"select"===I&&(e.stopPropagation(),ie(t.id),Le({kind:"move",id:t.id,start:Ce(e),original:t}))})(t,e),onDoubleClick:()=>{var t;"text"===(t=e).type&&xe({x:t.x,y:t.y,value:t.text,editingId:t.id})},onHandlePointerDown:(t,r)=>((e,t,r)=>{e.stopPropagation(),Le({kind:"resize",id:t.id,corner:r,start:Ce(e),original:t})})(t,e,r)},e.id)),ue&&/* @__PURE__ */c(x,{anno:{...ue,id:"__preview"},preview:!0}),me&&/* @__PURE__ */c(w,{rect:me,imageSize:ae})]}),ye&&/* @__PURE__ */c(f,{pendingText:ye,color:W,size:H,font:u.find(e=>e.id===F)?.css??u[0].css,bold:A,italic:K,underline:Z,borderColor:q,background:Y,padding:J,scale:ke,onChange:e=>xe({...ye,value:e}),onCommit:Pe,onCancel:()=>xe(null)})]})}),
|
|
51
|
+
/* @__PURE__ */c("div",{className:"px-3 py-1.5 border-t border-gray-200 bg-white text-[11px] text-gray-500 shrink-0",children:"select"===I?oe?P.hintSelected:P.hintSelect:"text"===I?P.hintText:"crop"===I?P.hintCrop:"draw"===I?P.hintDraw:P.hintShape})]})});function x({anno:e,selected:t,preview:r,zoom:n=1,onPointerDown:o,onDoubleClick:i,onHandlePointerDown:a}){const l=k(e),h=o?{onPointerDown:o,pointerEvents:"all",style:{cursor:"move"}}:{},p=i?{onDoubleClick:i}:{};let y;if("rect"===e.type)y=/* @__PURE__ */c("rect",{x:e.x,y:e.y,width:e.w,height:e.h,rx:e.radius,ry:e.radius,fill:"none",stroke:e.color,strokeWidth:e.stroke,strokeLinecap:"round",strokeLinejoin:"round",...h});else if("circle"===e.type)y=/* @__PURE__ */c("ellipse",{cx:e.x+e.w/2,cy:e.y+e.h/2,rx:e.w/2,ry:e.h/2,fill:"none",stroke:e.color,strokeWidth:e.stroke,...h});else if("arrow"===e.type)y=/* @__PURE__ */c(g,{anno:e,interactive:h});else if("draw"===e.type)y=/* @__PURE__ */c("path",{d:N(e.points),fill:"none",stroke:e.color,strokeWidth:e.stroke,strokeLinecap:"round",strokeLinejoin:"round",...h});else if("mosaic"===e.type)y=/* @__PURE__ */c("rect",{x:e.x,y:e.y,width:e.w,height:e.h,fill:"rgba(0,0,0,0.001)",stroke:t?"#3b82f6":"none",strokeWidth:t?2:0,strokeDasharray:t?"6,4":void 0,...h});else{const t=u.find(t=>t.id===e.font)?.css??u[0].css,r=e.padding??0,n=!!e.borderColor||!!e.background,o=k(e),i=e.borderColor?Math.max(1,Math.round(e.size/12)):0;y=/* @__PURE__ */s("g",{...h,...p,children:[n&&/* @__PURE__ */c("rect",{x:o.x-r,y:o.y-r,width:Math.max(0,o.w)+2*r,height:Math.max(0,o.h)+2*r,rx:Math.min(8,r),ry:Math.min(8,r),fill:e.background??"none",stroke:e.borderColor??"none",strokeWidth:i}),
|
|
52
52
|
/* @__PURE__ */c("text",{x:e.x,y:e.y+e.size,fill:e.color,fontSize:e.size,fontWeight:e.bold?700:400,fontStyle:e.italic?"italic":"normal",textDecoration:e.underline?"underline":void 0,fontFamily:t,style:{userSelect:"none"},children:e.text.split("\n").map((t,r)=>/* @__PURE__ */c("tspan",{x:e.x,dy:0===r?0:1.2*e.size,children:t},r))})]})}/* @__PURE__ */
|
|
53
53
|
return s("g",{children:[y,t&&!r&&/* @__PURE__ */s(d,{children:[
|
|
54
54
|
/* @__PURE__ */c("rect",{"data-chrome":"selection",x:l.x-4,y:l.y-4,width:l.w+8,height:l.h+8,fill:"none",stroke:"#3b82f6",strokeWidth:2/n,strokeDasharray:`${6/n},${4/n}`,pointerEvents:"none"}),a&&/* @__PURE__ */c(m,{anno:e,zoom:n,onHandlePointerDown:a})]})]})}function m({anno:e,zoom:t,onHandlePointerDown:r}){const n=6/t,o=1.5/t,i=e=>({fill:"#fff",stroke:"#3b82f6",strokeWidth:o,pointerEvents:"all",style:{cursor:e},"data-chrome":"handle"});if("arrow"===e.type)/* @__PURE__ */
|
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
import{escapeHtml as e}from"./chunk-BR22X7E5.js";import{useBrowserLayoutEffect as t}from"./chunk-D65T4H6J.js";import{useShellStrings as n}from"./chunk-
|
|
2
|
-
return u("div",{...n,dangerouslySetInnerHTML:r})}function g({columns:e,data:g,onChange:m,onColumnsChange:f,fixedRows:p=!1,minRows:y=15,maxHeight:b="260px",cellStyles:v,onFocusChange:x,onSelectionChange:M}){const D=r(null),k=n().grid,[C,E]=o(null);l(()=>{x?.(C)},[C,x]);const[L,S]=o({}),$=r(null),[A
|
|
1
|
+
import{escapeHtml as e}from"./chunk-BR22X7E5.js";import{useBrowserLayoutEffect as t}from"./chunk-D65T4H6J.js";import{useShellStrings as n}from"./chunk-TNBCUZVE.js";import{useRef as r,useState as o,useEffect as l,useCallback as c,useMemo as a}from"react";import{createPortal as s}from"react-dom";import{jsxs as i,jsx as u,Fragment as d}from"react/jsx-runtime";function h(e,t){const n=e[e.length-1];return n&&!n.some(e=>e.trim())?e:[...e,Array(t).fill("")]}function w({text:t,...n}){const r=a(()=>({__html:e(t)}),[t]);/* @__PURE__ */
|
|
2
|
+
return u("div",{...n,dangerouslySetInnerHTML:r})}function g({columns:e,data:g,onChange:m,onColumnsChange:f,fixedRows:p=!1,minRows:y=15,maxHeight:b="260px",cellStyles:v,onFocusChange:x,onSelectionChange:M}){const D=r(null),k=n().grid,[C,E]=o(null);l(()=>{x?.(C)},[C,x]);const[L,S]=o({}),$=r(null),[N,A]=o({}),z=r(null),[T,O]=o(null),[R,K]=o(null),[P,F]=o(null),[I,X]=o(null),[H,Y]=o(null),j=r(null);t(()=>{const e=j.current;if(!e||e.row!==H?.row||e.col!==H?.col)return;j.current=null;const t=D.current?.querySelector(`[data-row="${e.row}"][data-col="${e.col}"]`);if(!t)return;t.focus();const n=document.createRange();n.selectNodeContents(t),n.collapse(!1);const r=window.getSelection();r?.removeAllRanges(),r?.addRange(n)},[H]);const[B,q]=o(null),[W,U]=o(null);l(()=>{M?.(B&&W?{anchor:B,end:W}:null)},[B,W,M]);const V=r(!1),[_,J]=o(null),Z=r(!1),G=r({a:null,e:null});G.current={a:B,e:W};const Q=B&&W&&(B.row!==W.row||B.col!==W.col),ee=[...g];if(!p)for(;ee.length<y;)ee.push(Array(e.length).fill(""));const te=c((t,n,r)=>{const o=ee.map(e=>[...e]);for(;o.length<=t;)o.push(Array(e.length).fill(""));for(;o[t].length<e.length;)o[t].push("");o[t][n]=r,m(o)},[ee,e.length,m]),ne=c((e,t,n)=>{if(0!==e.button)return;const r=document.activeElement;if(r?.dataset?.row&&r?.dataset?.col){const e=parseInt(r.dataset.row),t=parseInt(r.dataset.col),n=r.textContent||"";if(n!==(ee[e]?.[t]||"")){const r=ee.map(e=>[...e]);r[e]&&(r[e][t]=n,m(r))}}V.current=!0,e.shiftKey&&B||q({row:t,col:n}),U({row:t,col:n})},[ee,m,B]),re=c((e,t)=>{V.current&&U({row:e,col:t})},[]);l(()=>{const e=()=>{V.current=!1};return window.addEventListener("mouseup",e),()=>window.removeEventListener("mouseup",e)},[]),l(()=>{const e=e=>{if(!e.ctrlKey&&!e.metaKey||"c"!==e.key)return;if(!B||!W)return;const t=window.getSelection();if(t&&t.toString().length>0&&!Q)return;const n=Math.min(B.row,W.row),r=Math.max(B.row,W.row),o=Math.min(B.col,W.col),l=Math.max(B.col,W.col),c=[];for(let e=n;e<=r;e++){const t=[];for(let n=o;n<=l;n++)t.push(ee[e]?.[n]||"");c.push(t.join("\t"))}const a=c.join("\n");a&&(e.preventDefault(),navigator.clipboard.writeText(a))};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[B,W,ee,Q]),l(()=>{const t=t=>{if(!C)return;const n=document.activeElement;if(n?.isContentEditable)return;if(!D.current?.contains(n))return;const r=t.clipboardData?.getData("text/plain");if(!r)return;t.preventDefault();const o=r.split("\n").filter(e=>e).map(e=>e.split("\t")),l=ee.map(e=>[...e]);for(let t=0;t<o.length;t++){const n=C.row+t;for(;l.length<=n;)l.push(Array(e.length).fill(""));for(;l[n].length<e.length;)l[n].push("");for(let r=0;r<o[t].length;r++){const c=C.col+r;if(c>=e.length)break;e[c].readOnly||(l[n][c]=o[t][r].trim())}}m(p?l:h(l,e.length)),q({row:C.row,col:C.col}),U({row:Math.min(C.row+o.length-1,l.length-1),col:Math.min(C.col+(o[0]?.length||1)-1,e.length-1)})};return window.addEventListener("paste",t),()=>window.removeEventListener("paste",t)},[C,ee,e,m,p]);const oe=c((t,n,r)=>{const o=t.clipboardData.getData("text/plain");if(!o)return;const l=o.split("\n").map(e=>e.split("\t"));if(l.length<=1&&l[0]?.length<=1)return;t.preventDefault();const c=ee.map(e=>[...e]);for(let t=0;t<l.length;t++){const o=n+t;for(;c.length<=o;)c.push(Array(e.length).fill(""));for(;c[o].length<e.length;)c[o].push("");for(let n=0;n<l[t].length;n++){const a=r+n;if(a>=e.length)break;e[a].readOnly||(c[o][a]=l[t][n].trim())}}m(p?c:h(c,e.length))},[ee,e,m,p]),le=c((t,n,r)=>{let o=n,l=r;if("Tab"===t.key)t.preventDefault(),l=t.shiftKey?r-1:r+1,l>=e.length&&(l=0,o=n+1),l<0&&(l=e.length-1,o=n-1);else if("Enter"===t.key)t.preventDefault(),o=t.shiftKey?n-1:n+1;else if("ArrowDown"===t.key)t.preventDefault(),o=n+1;else if("ArrowUp"===t.key)t.preventDefault(),o=n-1;else if("ArrowLeft"===t.key)t.preventDefault(),l=r-1;else{if("ArrowRight"!==t.key){if("Delete"===t.key||"Backspace"===t.key){const o=t.target;if(o.isContentEditable)return void(o.textContent&&window.getSelection()?.toString()===o.textContent&&(t.preventDefault(),te(n,r,"")));if(t.preventDefault(),B&&W){const t=Math.min(B.row,W.row),n=Math.max(B.row,W.row),r=Math.min(B.col,W.col),o=Math.max(B.col,W.col),l=ee.map(e=>[...e]);for(let c=t;c<=n;c++)for(let t=r;t<=o;t++)l[c]&&!e[t]?.readOnly&&(l[c][t]="");m(l)}else te(n,r,"");return}return}t.preventDefault(),l=r+1}for(;l>=0&&l<e.length&&e[l].readOnly;)l+="Tab"===t.key&&t.shiftKey?-1:1;if(o>=0&&o<ee.length&&l>=0&&l<e.length){const e=D.current?.querySelector(`[data-row="${o}"][data-col="${l}"]`);e&&(e.focus({preventScroll:!0}),e.scrollIntoView({block:"nearest",inline:"nearest"}),E({row:o,col:l}),Y(null),q({row:o,col:l}),U({row:o,col:l}))}},[e,ee,ee.length,te,B,W,m]),ce=c(t=>{if(!p&&t>=ee.length-2){const t=ee.map(e=>[...e]);for(let n=0;n<5;n++)t.push(Array(e.length).fill(""));m(t)}},[p,ee,e.length,m]),[ae,se]=o(null);l(()=>{if(!ae)return;const e=()=>se(null);return window.addEventListener("pointerdown",e),()=>window.removeEventListener("pointerdown",e)},[ae]);const ie=c(t=>{const n=ee.map(e=>[...e]);n.splice(t,0,Array(e.length).fill("")),m(n)},[ee,e.length,m]),ue=c(e=>{if(ee.length<=1)return;const t=ee.filter((t,n)=>n!==e);m(t)},[ee,m]),de=c(e=>{const t=ee.map(t=>{const n=[...t];return n.splice(e,0,""),n});m(t)},[ee,m]),he=c(t=>{if(e.length<=1)return;const n=ee.map(e=>{const n=[...e];return n.splice(t,1),n});m(n)},[ee,e.length,m]),we=c((e,t)=>{e.preventDefault(),p||se({x:e.clientX,y:e.clientY,items:[{label:k.insertRowAbove,onClick:()=>{ie(t),se(null)}},{label:k.insertRowBelow,onClick:()=>{ie(t+1),se(null)}},{label:k.deleteRow(t+1),onClick:()=>{ue(t),se(null)}}]})},[p,ie,ue,k]),ge=c((t,n)=>{t.preventDefault(),p||se({x:t.clientX,y:t.clientY,items:[{label:k.insertColumnLeft,onClick:()=>{de(n),se(null)}},{label:k.insertColumnRight,onClick:()=>{de(n+1),se(null)}},{label:k.deleteColumn(String(e[n]?.title||n+1)),onClick:()=>{he(n),se(null)}}]})},[p,e,de,he,k]),me=t=>L[t]??e[t]?.width??150;l(()=>{const t=e=>{if(!$.current)return;const t=e.clientX-$.current.startX,n=Math.max(40,$.current.startW+t);S(e=>({...e,[$.current.col]:n}))},n=()=>{if($.current&&f){const t=e.map((e,t)=>({...e,width:L[t]??e.width}));t[$.current.col]={...t[$.current.col],width:L[$.current.col]??e[$.current.col].width},f(t)}$.current=null,document.body.style.cursor=""};return window.addEventListener("mousemove",t),window.addEventListener("mouseup",n),()=>{window.removeEventListener("mousemove",t),window.removeEventListener("mouseup",n)}},[e,L,f]);const fe=e=>N[e]??28;l(()=>{const e=e=>{if(!z.current)return;const t=e.clientY-z.current.startY,n=Math.max(20,z.current.startH+t);A(e=>({...e,[z.current.row]:n}))},t=()=>{z.current=null,document.body.style.cursor=""};return window.addEventListener("mousemove",e),window.addEventListener("mouseup",t),()=>{window.removeEventListener("mousemove",e),window.removeEventListener("mouseup",t)}},[]);const pe=c(t=>{const n=document.createElement("canvas").getContext("2d");if(!n)return;n.font="12px ui-monospace, SFMono-Regular, Menlo, monospace";let r=0;for(const e of ee){const o=String(e[t]??"").replace(/<[^>]*>/g,""),l=n.measureText(o).width;l>r&&(r=l)}const o=n.measureText(e[t]?.title??"").width;o>r&&(r=o);const l=Math.max(40,Math.ceil(r+24));if(S(e=>({...e,[t]:l})),f){const n=e.map((e,n)=>({...e,width:n===t?l:L[n]??e.width}));f(n)}},[ee,e,L,f]),ye=c(e=>{A(t=>{const n={...t};return delete n[e],n})},[]),be=c(t=>{const{a:n,e:r}=G.current;if(!n||!r)return;const o=Math.min(n.row,r.row),l=Math.max(n.row,r.row),c=Math.min(n.col,r.col),a=Math.max(n.col,r.col);let s=o,i=l,u=c,d=a;t.row>l?i=t.row:t.row<o&&(s=t.row),t.col>a?d=t.col:t.col<c&&(u=t.col);const h=l-o+1,w=a-c+1,g=ee.map(e=>[...e]);for(;g.length<=i;)g.push(Array(e.length).fill(""));for(const e of g)for(;e.length<=d;)e.push("");function f(e){const t=e.map(e=>parseFloat(e));if(t.length<2||t.some(e=>Number.isNaN(e)))return null;const n=t[1]-t[0];for(let e=2;e<t.length;e++)if(Math.abs(t[e]-t[e-1]-n)>1e-9)return null;return{step:n}}for(let e=s;e<=i;e++)for(let t=u;t<=d;t++){if(e>=o&&e<=l&&t>=c&&t<=a)continue;let n;if(1===w&&u===c&&d===a){const r=f(Array.from({length:h},(e,n)=>g[o+n]?.[t]??""));if(r){const c=parseFloat(g[l]?.[t]??"0"),a=parseFloat(g[o]?.[t]??"0"),s=e>l?e-l:-(o-e);n=String((e>l?c:a)+r.step*s)}else{const r=((e-o)%h+h)%h;n=g[o+r]?.[t]??""}}else if(1===h&&s===o&&i===l){const r=f(Array.from({length:w},(t,n)=>g[e]?.[c+n]??""));if(r){const o=parseFloat(g[e]?.[a]??"0"),l=parseFloat(g[e]?.[c]??"0"),s=t>a?t-a:-(c-t);n=String((t>a?o:l)+r.step*s)}else{const r=((t-c)%w+w)%w;n=g[e]?.[c+r]??""}}else{const r=((e-o)%h+h)%h,l=((t-c)%w+w)%w;n=g[o+r]?.[c+l]??""}g[e][t]=n}m(g),q({row:s,col:u}),U({row:i,col:d})},[ee,e.length,m]);l(()=>{const e=e=>{if(!Z.current)return;const t=document.elementFromPoint(e.clientX,e.clientY),n=t?.closest?.("[data-row][data-col]");if(!n)return;const r=parseInt(n.dataset.row),o=parseInt(n.dataset.col);J({row:r,col:o})},t=()=>{Z.current&&_&&be(_),Z.current=!1,J(null),document.body.style.cursor=""};return window.addEventListener("mousemove",e),window.addEventListener("mouseup",t),()=>{window.removeEventListener("mousemove",e),window.removeEventListener("mouseup",t)}},[_,be]);const ve=e=>{e.preventDefault(),e.stopPropagation(),Z.current=!0,document.body.style.cursor="crosshair"},xe=r(null),[Me,De]=o(0),[ke,Ce]=o(800);l(()=>{const e=xe.current;if(!e)return;const t=()=>Ce(e.clientHeight||800);t();const n=new ResizeObserver(t);return n.observe(e),()=>n.disconnect()},[]);const Ee=ee.length>100,Le=Ee?Math.max(0,Math.floor(Me/28)-20):0,Se=Ee?Math.min(ee.length,Math.ceil((Me+ke)/28)+20):ee.length,$e=a(()=>ee.slice(Le,Se),[ee,Le,Se]),Ne=28*Le,Ae=28*(ee.length-Se),ze="px-2 py-1.5 text-left text-xs font-medium text-gray-500 uppercase bg-gray-100 border-b border-r border-gray-200 select-none";/* @__PURE__ */
|
|
3
3
|
return i("div",{ref:xe,className:"border border-gray-300 rounded overflow-scroll grid-scroll",style:{maxHeight:b,height:b},onScroll:e=>De(e.target.scrollTop),children:[
|
|
4
4
|
/* @__PURE__ */i("table",{ref:D,className:"border-collapse select-none",style:{tableLayout:"fixed",minWidth:36+e.reduce((t,n)=>t+me(e.indexOf(n)),0)},children:[
|
|
5
5
|
/* @__PURE__ */i("colgroup",{children:[
|
|
6
6
|
/* @__PURE__ */u("col",{style:{width:36}}),e.map((e,t)=>/* @__PURE__ */u("col",{style:{width:me(t)}},e.key))]}),
|
|
7
7
|
/* @__PURE__ */u("thead",{className:"sticky top-0 z-10",children:/* @__PURE__ */i("tr",{children:[
|
|
8
|
-
/* @__PURE__ */u("th",{className:ze+" text-center w-9 cursor-pointer hover:bg-gray-200",onClick:()=>{q({row:0,col:0}),
|
|
9
|
-
return i("th",{className:`${ze} cursor-pointer hover:bg-gray-200 relative${r?" !bg-blue-200":""}${I===n?" !bg-blue-100":""}`,style:{width:me(n)},draggable:!0,onDragStart:()=>(e=>F(e))(n),onDragOver:e=>((e,t)=>{e.preventDefault(),X(t)})(e,n),onDrop:()=>(t=>{if(null===P||P===t)return F(null),void X(null);const n=ee.map(e=>{const n=[...e],[r]=n.splice(P,1);return n.splice(t,0,r),n});if(m(n),f){const n=[...e],[r]=n.splice(P,1);n.splice(t,0,r),f(n)}F(null),X(null)})(n),onDragEnd:()=>{F(null),X(null)},onClick:e=>{e.shiftKey&&B||q({row:0,col:n}),
|
|
8
|
+
/* @__PURE__ */u("th",{className:ze+" text-center w-9 cursor-pointer hover:bg-gray-200",onClick:()=>{q({row:0,col:0}),U({row:ee.length-1,col:e.length-1})},title:k.selectAll,children:"#"}),e.map((t,n)=>{const r=B&&W&&Math.min(B.col,W.col)<=n&&n<=Math.max(B.col,W.col)&&0===Math.min(B.row,W.row)&&Math.max(B.row,W.row)===ee.length-1;/* @__PURE__ */
|
|
9
|
+
return i("th",{className:`${ze} cursor-pointer hover:bg-gray-200 relative${r?" !bg-blue-200":""}${I===n?" !bg-blue-100":""}`,style:{width:me(n)},draggable:!0,onDragStart:()=>(e=>F(e))(n),onDragOver:e=>((e,t)=>{e.preventDefault(),X(t)})(e,n),onDrop:()=>(t=>{if(null===P||P===t)return F(null),void X(null);const n=ee.map(e=>{const n=[...e],[r]=n.splice(P,1);return n.splice(t,0,r),n});if(m(n),f){const n=[...e],[r]=n.splice(P,1);n.splice(t,0,r),f(n)}F(null),X(null)})(n),onDragEnd:()=>{F(null),X(null)},onClick:e=>{e.shiftKey&&B||q({row:0,col:n}),U({row:ee.length-1,col:n})},onContextMenu:e=>ge(e,n),children:[t.title,
|
|
10
10
|
/* @__PURE__ */u("div",{className:"absolute -right-1 top-0 bottom-0 w-2 cursor-col-resize z-20",onMouseDown:e=>((e,t)=>{e.preventDefault(),e.stopPropagation(),$.current={col:t,startX:e.clientX,startW:me(t)},document.body.style.cursor="col-resize"})(e,n),onDoubleClick:e=>{e.stopPropagation(),pe(n)},title:k.resize})]},t.key)})]})}),
|
|
11
|
-
/* @__PURE__ */i("tbody",{children:[
|
|
11
|
+
/* @__PURE__ */i("tbody",{children:[Ne>0&&/* @__PURE__ */u("tr",{style:{height:Ne}}),$e.map((t,n)=>{const r=Le+n,o=B&&W&&Math.min(B.row,W.row)<=r&&r<=Math.max(B.row,W.row)&&0===Math.min(B.col,W.col)&&Math.max(B.col,W.col)===e.length-1;/* @__PURE__ */
|
|
12
12
|
return i("tr",{style:{height:fe(r)},children:[
|
|
13
|
-
/* @__PURE__ */i("td",{className:`relative px-1 py-1 text-center text-[10px] text-gray-400 border-b border-r border-gray-200 bg-gray-50 select-none cursor-pointer hover:bg-gray-200${o?" !bg-blue-200 !text-gray-700":""}${R===r?" !bg-blue-100":""}`,draggable:!0,onDragStart:()=>(e=>
|
|
14
|
-
/* @__PURE__ */u("div",{className:"absolute -bottom-1 left-0 right-0 h-2 cursor-row-resize z-20",onMouseDown:e=>((e,t)=>{e.preventDefault(),e.stopPropagation(),z.current={row:t,startY:e.clientY,startH:fe(t)},document.body.style.cursor="row-resize"})(e,r),onDoubleClick:e=>{e.stopPropagation(),ye(r)},title:k.resize})]}),e.map((e,n)=>{const o=B&&W&&function(e,t,n,r){const o=Math.min(e.row,t.row),l=Math.max(e.row,t.row),c=Math.min(e.col,t.col),a=Math.max(e.col,t.col);return n>=o&&n<=l&&r>=c&&r<=a}(B,W,r,n),l=H?.row===r&&H?.col===n&&!e.readOnly,c=C?.row===r&&C?.col===n,a=v?.[`${r}:${n}`],s=B&&W?Math.max(B.row,W.row):-1,d=B&&W?Math.max(B.col,W.col):-1,h=B&&W&&r===s&&n===d,g=
|
|
13
|
+
/* @__PURE__ */i("td",{className:`relative px-1 py-1 text-center text-[10px] text-gray-400 border-b border-r border-gray-200 bg-gray-50 select-none cursor-pointer hover:bg-gray-200${o?" !bg-blue-200 !text-gray-700":""}${R===r?" !bg-blue-100":""}`,draggable:!0,onDragStart:()=>(e=>O(e))(r),onDragOver:e=>((e,t)=>{e.preventDefault(),K(t)})(e,r),onDrop:()=>(e=>{if(null===T||T===e)return O(null),void K(null);const t=ee.map(e=>[...e]),[n]=t.splice(T,1);t.splice(e,0,n),m(t),O(null),K(null)})(r),onDragEnd:()=>{O(null),K(null)},onClick:t=>{t.shiftKey&&B||q({row:r,col:0}),U({row:r,col:e.length-1})},onContextMenu:e=>we(e,r),children:[r+1,
|
|
14
|
+
/* @__PURE__ */u("div",{className:"absolute -bottom-1 left-0 right-0 h-2 cursor-row-resize z-20",onMouseDown:e=>((e,t)=>{e.preventDefault(),e.stopPropagation(),z.current={row:t,startY:e.clientY,startH:fe(t)},document.body.style.cursor="row-resize"})(e,r),onDoubleClick:e=>{e.stopPropagation(),ye(r)},title:k.resize})]}),e.map((e,n)=>{const o=B&&W&&function(e,t,n,r){const o=Math.min(e.row,t.row),l=Math.max(e.row,t.row),c=Math.min(e.col,t.col),a=Math.max(e.col,t.col);return n>=o&&n<=l&&r>=c&&r<=a}(B,W,r,n),l=H?.row===r&&H?.col===n&&!e.readOnly,c=C?.row===r&&C?.col===n,a=v?.[`${r}:${n}`],s=B&&W?Math.max(B.row,W.row):-1,d=B&&W?Math.max(B.col,W.col):-1,h=B&&W&&r===s&&n===d,g=Z.current&&_&&B&&W&&(()=>{const e=Math.min(B.row,W.row),t=Math.max(B.row,W.row),o=Math.min(B.col,W.col),l=Math.max(B.col,W.col);let c=e,a=t,s=o,i=l;return _.row>t?a=_.row:_.row<e&&(c=_.row),_.col>l?i=_.col:_.col<o&&(s=_.col),r>=c&&r<=a&&n>=s&&n<=i&&!(r>=e&&r<=t&&n>=o&&n<=l)})(),m="sm"===a?.fontSize?"text-[11px]":"lg"===a?.fontSize?"text-sm":"xl"===a?.fontSize?"text-base":"text-xs",f=`${a?.bold?" font-bold":""}${a?.italic?" italic":""}${a?.underline?" underline":""}`;/* @__PURE__ */
|
|
15
15
|
return i("td",{className:`relative px-0 py-0 border-b border-r border-gray-200 text-sm${e.readOnly?" bg-gray-50 text-gray-500 cursor-default":" cursor-cell"}${o?" !bg-blue-100":""}${c&&!o?" ring-2 ring-inset ring-blue-400":""}${g?" !bg-blue-50 ring-1 ring-inset ring-blue-300":""}`,onMouseDown:e=>{if(e.target===e.currentTarget){ne(e,r,n);const t=e.currentTarget.querySelector("[data-row][data-col]");t?.focus()}},onMouseEnter:()=>re(r,n),onClick:e=>{if(e.target===e.currentTarget){const t=e.currentTarget.querySelector("[data-row][data-col]");t?.focus()}},onDoubleClick:t=>{t.target!==t.currentTarget||e.readOnly||Y({row:r,col:n})},children:[
|
|
16
|
-
/* @__PURE__ */u(w,{contentEditable:l,suppressContentEditableWarning:!0,tabIndex:0,"data-row":r,"data-col":n,className:`w-full h-full px-2 py-1 rosh-focus-ring whitespace-nowrap overflow-hidden ${"right"===e.align?"text-right":"center"===e.align?"text-center":""} ${e.readOnly?"cursor-default":"cursor-cell"} font-mono ${m}${f}`,onMouseDown:e=>ne(e,r,n),onMouseEnter:()=>re(r,n),onDoubleClick:()=>{e.readOnly||Y({row:r,col:n})},onFocus:()=>{E({row:r,col:n}),
|
|
16
|
+
/* @__PURE__ */u(w,{contentEditable:l,suppressContentEditableWarning:!0,tabIndex:0,"data-row":r,"data-col":n,className:`w-full h-full px-2 py-1 rosh-focus-ring whitespace-nowrap overflow-hidden ${"right"===e.align?"text-right":"center"===e.align?"text-center":""} ${e.readOnly?"cursor-default":"cursor-cell"} font-mono ${m}${f}`,onMouseDown:e=>ne(e,r,n),onMouseEnter:()=>re(r,n),onDoubleClick:()=>{e.readOnly||Y({row:r,col:n})},onFocus:()=>{E({row:r,col:n}),V.current||(q({row:r,col:n}),U({row:r,col:n}))},onBlur:e=>{const o=e.currentTarget.textContent||"";o!==(t[n]||"")&&te(r,n,o),Y(null)},onInput:()=>ce(r),onPaste:e=>oe(e,r,n),onKeyDown:t=>{if(!(l||e.readOnly||1!==t.key.length||t.ctrlKey||t.metaKey||t.altKey))return t.preventDefault(),te(r,n,t.key),j.current={row:r,col:n},void Y({row:r,col:n});le(t,r,n)},text:t[n]||""}),h&&/* @__PURE__ */u("div",{onMouseDown:ve,title:k.fill,className:"absolute -bottom-[3px] -right-[3px] w-[7px] h-[7px] bg-blue-500 border border-white cursor-crosshair z-30 hover:bg-blue-600"})]},n)})]},r)}),Ae>0&&/* @__PURE__ */u("tr",{style:{height:Ae}})]})]}),ae&&s(
|
|
17
17
|
/* @__PURE__ */i(d,{children:[
|
|
18
18
|
/* @__PURE__ */u("div",{className:"fixed inset-0 z-[200]",onPointerDown:()=>se(null)}),
|
|
19
19
|
/* @__PURE__ */u("div",{className:"fixed z-[201] bg-white rounded-lg shadow-lg border border-gray-200 py-1 min-w-[160px]",style:{left:ae.x,top:ae.y},children:ae.items.map((e,t)=>/* @__PURE__ */u("button",{onPointerDown:t=>{t.stopPropagation(),e.onClick()},className:"w-full text-left px-3 py-1.5 text-sm text-gray-700 hover:bg-gray-100",children:e.label},t))})]}),document.body)]})}export{g as EditableGrid,h as withSpareRow};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{CheckFallbackC as e,CopyFallback as t}from"./chunk-
|
|
2
|
-
return u(o
|
|
3
|
-
return u("button",{onClick:
|
|
1
|
+
import{CheckFallbackC as e,CopyFallback as t}from"./chunk-6LTDJKIL.js";import{Icon as r}from"./chunk-XWSWYMGM.js";import{useShellStrings as o}from"./chunk-TNBCUZVE.js";import{useState as c,useRef as a,useEffect as i,useCallback as n}from"react";import{jsx as u}from"react/jsx-runtime";function m(e){const[t,r]=c(!1),o=a(void 0);i(()=>()=>clearTimeout(o.current),[]);return{copied:t,copy:n(t=>{t?.stopPropagation(),navigator.clipboard?.writeText(e).then(()=>{r(!0),clearTimeout(o.current),o.current=setTimeout(()=>r(!1),1500)},()=>{})},[e])}}function p({copied:o,className:c="w-4 h-4"}){/* @__PURE__ */
|
|
2
|
+
return u(r,o?{name:"check",fallback:e,className:`${c} text-green-600`,"aria-hidden":"true"}:{name:"copy",fallback:t,className:c,"aria-hidden":"true"})}function s({text:e}){const{copied:t,copy:r}=m(e),c=o().copy;/* @__PURE__ */
|
|
3
|
+
return u("button",{onClick:r,title:t?c.copiedValue:c.copyValue(e),className:"shrink-0 text-gray-400 hover:text-gray-600 transition-colors",children:/* @__PURE__ */u(p,{copied:t})})}export{s as CopyButton,p as CopyGlyph,m as useCopyText};
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import{
|
|
2
|
-
return u(
|
|
1
|
+
import{VERSION as e}from"./chunk-SFCDHHQP.js";import{useWindowMenuItem as t,Modal as r}from"./chunk-VWBQ2P5G.js";import{navIcons as s}from"./chunk-DSSLOQDW.js";import{InfoFallback as o,WindowFallback as n}from"./chunk-6LTDJKIL.js";import{Icon as i}from"./chunk-XWSWYMGM.js";import{DEFAULT_SHELL_STRINGS as a,useShellStrings as m,splitAround as c}from"./chunk-TNBCUZVE.js";import{useState as l,useCallback as p,isValidElement as d,cloneElement as h}from"react";import{jsx as u,jsxs as f}from"react/jsx-runtime";var x=a.aboutApp,v={spreadsheet:{name:"Spreadsheets",version:"1.1.3",route:"/spreadsheet",description:x.spreadsheet},notepad:{name:"Notepad",version:"1.0.1",route:"/notepad",description:x.notepad},documents:{name:"Documents",version:"1.1.0",route:"/documents",description:x.documents},preview:{name:"Preview",version:"1.4.2",route:"/preview",description:x.preview},files:{name:"Files",version:"1.1.1",route:"/files",description:x.files},browser:{name:"Browser",version:"1.0.1",route:"/browser",description:x.browser}},w=/* @__PURE__ */u(i,{name:"info",fallback:o,className:"h-4 w-4 text-gray-400",strokeWidth:1.5}),g=/* @__PURE__ */u(i,{name:"window",fallback:n,className:"h-9 w-9",strokeWidth:1.5});function N({app:o}){const n=v[o],[i,a]=l(!1),x=p(()=>a(!0),[]),N=m().aboutApp,b=N.title(n.name);if(t(b,x,w),!i)return null;const y=s[n.route],k=d(y)?h(y,{className:"h-9 w-9"}):g,[j,S]=c(N.partOf);/* @__PURE__ */
|
|
2
|
+
return u(r,{open:!0,onClose:()=>a(!1),title:b,size:"sm",compact:!0,bodyScroll:!1,autoHeight:!0,dimensions:[320,320],children:/* @__PURE__ */f("div",{className:"flex flex-col items-center text-center px-5 pt-5 pb-4",children:[
|
|
3
3
|
/* @__PURE__ */u("div",{className:"flex h-16 w-16 items-center justify-center rounded-2xl bg-gray-100 text-gray-600 shrink-0",children:k}),
|
|
4
4
|
/* @__PURE__ */u("h2",{className:"mt-3 text-lg font-bold text-gray-900",children:n.name}),
|
|
5
|
-
/* @__PURE__ */u("p",{className:"text-[11px] font-mono text-gray-400",children:
|
|
6
|
-
/* @__PURE__ */u("p",{className:"mt-2 text-xs text-gray-500 leading-relaxed",children:
|
|
5
|
+
/* @__PURE__ */u("p",{className:"text-[11px] font-mono text-gray-400",children:N.version(n.version)}),
|
|
6
|
+
/* @__PURE__ */u("p",{className:"mt-2 text-xs text-gray-500 leading-relaxed",children:N[o]}),
|
|
7
7
|
/* @__PURE__ */f("div",{className:"mt-4 pt-3 border-t border-gray-200 w-full",children:[
|
|
8
8
|
/* @__PURE__ */f("p",{className:"text-[11px] text-gray-500",children:[j,
|
|
9
|
-
/* @__PURE__ */u("span",{className:"font-medium text-gray-700",children:"efficient-shell"}),S]}),
|
|
9
|
+
/* @__PURE__ */u("span",{className:"font-medium text-gray-700",children:"efficient-shell"}),S]}),e&&/* @__PURE__ */u("p",{className:"mt-0.5 text-[10px] font-mono text-gray-400",children:N.shellVersion(e)})]})]})})}export{N as AboutApp,v as BUILTIN_APP_INFO};
|