@betteroffice/xlsx-react 0.0.6 → 0.0.7
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/dist/index.d.ts +139 -2
- package/dist/index.js +1 -1
- package/package.json +3 -3
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as react from 'react';
|
|
2
|
-
import { ReactNode } from 'react';
|
|
2
|
+
import { CSSProperties, ReactNode } from 'react';
|
|
3
3
|
import { WorkbookHandle } from '@betteroffice/xlsx';
|
|
4
4
|
import { CollaborationReplica } from '@betteroffice/xlsx/collaboration';
|
|
5
5
|
import { Translations, TFunction } from '@betteroffice/xlsx-i18n';
|
|
@@ -48,6 +48,143 @@ interface XlsxEditorProps {
|
|
|
48
48
|
*/
|
|
49
49
|
declare function XlsxEditor({ i18n, ...props }: XlsxEditorProps): react.JSX.Element;
|
|
50
50
|
|
|
51
|
+
type NumberFormat = 'automatic' | 'plainText' | 'number' | 'percent' | 'scientific' | 'currency' | 'date' | 'time' | 'custom';
|
|
52
|
+
type BorderPreset = 'all' | 'inner' | 'horizontal' | 'vertical' | 'outer' | 'left' | 'top' | 'right' | 'bottom' | 'none';
|
|
53
|
+
type BorderStyle = 'solid' | 'dashed' | 'dotted' | 'double';
|
|
54
|
+
type HorizontalAlignment = 'left' | 'center' | 'right';
|
|
55
|
+
type VerticalAlignment = 'top' | 'middle' | 'bottom';
|
|
56
|
+
type TextWrapping = 'overflow' | 'wrap' | 'clip';
|
|
57
|
+
type MergeAction = 'all' | 'horizontal' | 'vertical' | 'unmerge';
|
|
58
|
+
interface SelectionFormatting {
|
|
59
|
+
paintFormat?: boolean;
|
|
60
|
+
numberFormat?: NumberFormat;
|
|
61
|
+
numberFormatPattern?: string;
|
|
62
|
+
fontFamily?: string;
|
|
63
|
+
fontSize?: number;
|
|
64
|
+
bold?: boolean;
|
|
65
|
+
italic?: boolean;
|
|
66
|
+
strikethrough?: boolean;
|
|
67
|
+
textColor?: string;
|
|
68
|
+
fillColor?: string;
|
|
69
|
+
borderPreset?: BorderPreset;
|
|
70
|
+
borderStyle?: BorderStyle;
|
|
71
|
+
borderColor?: string;
|
|
72
|
+
horizontalAlignment?: HorizontalAlignment;
|
|
73
|
+
verticalAlignment?: VerticalAlignment;
|
|
74
|
+
textWrapping?: TextWrapping;
|
|
75
|
+
}
|
|
76
|
+
type FormattingAction = 'paintFormat' | 'currency' | 'percent' | 'decreaseDecimal' | 'increaseDecimal' | 'bold' | 'italic' | 'strikethrough' | {
|
|
77
|
+
type: 'numberFormat';
|
|
78
|
+
value: NumberFormat;
|
|
79
|
+
} | {
|
|
80
|
+
type: 'fontFamily';
|
|
81
|
+
value: string;
|
|
82
|
+
} | {
|
|
83
|
+
type: 'fontSize';
|
|
84
|
+
value: number;
|
|
85
|
+
} | {
|
|
86
|
+
type: 'textColor';
|
|
87
|
+
value: string;
|
|
88
|
+
} | {
|
|
89
|
+
type: 'fillColor';
|
|
90
|
+
value: string;
|
|
91
|
+
} | {
|
|
92
|
+
type: 'borderPreset';
|
|
93
|
+
value: BorderPreset;
|
|
94
|
+
} | {
|
|
95
|
+
type: 'borderStyle';
|
|
96
|
+
value: BorderStyle;
|
|
97
|
+
} | {
|
|
98
|
+
type: 'borderColor';
|
|
99
|
+
value: string;
|
|
100
|
+
} | {
|
|
101
|
+
type: 'horizontalAlignment';
|
|
102
|
+
value: HorizontalAlignment;
|
|
103
|
+
} | {
|
|
104
|
+
type: 'verticalAlignment';
|
|
105
|
+
value: VerticalAlignment;
|
|
106
|
+
} | {
|
|
107
|
+
type: 'textWrapping';
|
|
108
|
+
value: TextWrapping;
|
|
109
|
+
};
|
|
110
|
+
interface SelectionShape {
|
|
111
|
+
rows: number;
|
|
112
|
+
columns: number;
|
|
113
|
+
canUnmerge?: boolean;
|
|
114
|
+
}
|
|
115
|
+
interface ToolbarProps {
|
|
116
|
+
currentFormatting?: SelectionFormatting;
|
|
117
|
+
selectionShape?: SelectionShape;
|
|
118
|
+
onFormat?: (action: FormattingAction) => void;
|
|
119
|
+
onMerge?: (action: MergeAction) => void;
|
|
120
|
+
onSearchMenus?: () => void;
|
|
121
|
+
onUndo?: () => void;
|
|
122
|
+
onRedo?: () => void;
|
|
123
|
+
canUndo?: boolean;
|
|
124
|
+
canRedo?: boolean;
|
|
125
|
+
onPrint?: () => void;
|
|
126
|
+
zoom?: number;
|
|
127
|
+
onZoomChange?: (zoom: number) => void;
|
|
128
|
+
fontFamilies?: readonly string[];
|
|
129
|
+
fontSizes?: readonly number[];
|
|
130
|
+
disabled?: boolean;
|
|
131
|
+
className?: string;
|
|
132
|
+
style?: CSSProperties;
|
|
133
|
+
children?: ReactNode;
|
|
134
|
+
}
|
|
135
|
+
declare function Toolbar(explicitProps: ToolbarProps): react.JSX.Element;
|
|
136
|
+
|
|
137
|
+
type EditorToolbarProps = ToolbarProps;
|
|
138
|
+
declare const EditorToolbarContext: react.Context<ToolbarProps | null>;
|
|
139
|
+
declare function useEditorToolbar(): ToolbarProps;
|
|
140
|
+
|
|
141
|
+
interface EditorToolbarComponent {
|
|
142
|
+
(props: EditorToolbarProps & {
|
|
143
|
+
children: ReactNode;
|
|
144
|
+
}): React.JSX.Element;
|
|
145
|
+
Toolbar: typeof Toolbar;
|
|
146
|
+
}
|
|
147
|
+
declare const EditorToolbar: EditorToolbarComponent;
|
|
148
|
+
|
|
149
|
+
interface ToolbarButtonProps {
|
|
150
|
+
active?: boolean;
|
|
151
|
+
disabled?: boolean;
|
|
152
|
+
title: string;
|
|
153
|
+
onClick?: () => void;
|
|
154
|
+
children: ReactNode;
|
|
155
|
+
style?: CSSProperties;
|
|
156
|
+
testId?: string;
|
|
157
|
+
ariaExpanded?: boolean;
|
|
158
|
+
}
|
|
159
|
+
declare function ToolbarButton({ active, disabled, title, onClick, children, style, testId, ariaExpanded, }: ToolbarButtonProps): react.JSX.Element;
|
|
160
|
+
declare function ToolbarGroup({ label, children, style, }: {
|
|
161
|
+
label: string;
|
|
162
|
+
children: ReactNode;
|
|
163
|
+
style?: CSSProperties;
|
|
164
|
+
}): react.JSX.Element;
|
|
165
|
+
declare function ToolbarSeparator(): react.JSX.Element;
|
|
166
|
+
interface ToolbarDropdownProps {
|
|
167
|
+
title: string;
|
|
168
|
+
trigger: ReactNode;
|
|
169
|
+
children: (close: () => void) => ReactNode;
|
|
170
|
+
disabled?: boolean;
|
|
171
|
+
active?: boolean;
|
|
172
|
+
menuWidth?: number;
|
|
173
|
+
style?: CSSProperties;
|
|
174
|
+
testId?: string;
|
|
175
|
+
}
|
|
176
|
+
declare function ToolbarDropdown({ title, trigger, children, disabled, active, menuWidth, style, testId, }: ToolbarDropdownProps): react.JSX.Element;
|
|
177
|
+
interface ToolbarMenuItemProps {
|
|
178
|
+
label: string;
|
|
179
|
+
icon?: ReactNode;
|
|
180
|
+
selected?: boolean;
|
|
181
|
+
disabled?: boolean;
|
|
182
|
+
onClick?: () => void;
|
|
183
|
+
close?: () => void;
|
|
184
|
+
}
|
|
185
|
+
declare function ToolbarMenuItem({ label, icon, selected, disabled, onClick, close, }: ToolbarMenuItemProps): react.JSX.Element;
|
|
186
|
+
declare function ToolbarMenuSeparator(): react.JSX.Element;
|
|
187
|
+
|
|
51
188
|
interface LocaleProviderProps {
|
|
52
189
|
i18n?: Translations;
|
|
53
190
|
children: ReactNode;
|
|
@@ -57,4 +194,4 @@ declare function useTranslation(): {
|
|
|
57
194
|
t: TFunction;
|
|
58
195
|
};
|
|
59
196
|
|
|
60
|
-
export { LocaleProvider, type LocaleProviderProps, XlsxEditor, type XlsxEditorApi, type XlsxEditorCollaborationOptions, type XlsxEditorProps, useTranslation };
|
|
197
|
+
export { type BorderPreset, type BorderStyle, EditorToolbar, EditorToolbarContext, type EditorToolbarProps, type FormattingAction, type HorizontalAlignment, LocaleProvider, type LocaleProviderProps, type MergeAction, type NumberFormat, type SelectionFormatting, type SelectionShape, type TextWrapping, Toolbar, ToolbarButton, ToolbarDropdown, ToolbarGroup, ToolbarMenuItem, ToolbarMenuSeparator, type ToolbarProps, ToolbarSeparator, type VerticalAlignment, XlsxEditor, type XlsxEditorApi, type XlsxEditorCollaborationOptions, type XlsxEditorProps, Toolbar as XlsxToolbar, useEditorToolbar, useTranslation };
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import {createContext,useMemo,useContext,useRef,useState,useEffect,useCallback}from'react';import {isPngExportAvailable,isProposalsAvailable,initWasm,openWorkbook,selectionAt,paintDisplayList,buildA11yGrid,cellAtPoint,moveFocus,normalizeRange,toTsv,fromTsv,StaleProposalError,selectionKeyReducer,extendTo,rangeRect,cellRect}from'@betteroffice/xlsx';import {en,deepMerge,createT}from'@betteroffice/xlsx-i18n';import {jsx,jsxs,Fragment}from'react/jsx-runtime';var Ye=createContext(en),Ve=createContext("en");function de({i18n:r,children:i}){let u=typeof r?._lang=="string"?r._lang:"en",f=useMemo(()=>deepMerge(en,r),[r]);return jsx(Ve.Provider,{value:u,children:jsx(Ye.Provider,{value:f,children:i})})}function N(){let r=useContext(Ye),i=useContext(Ve);return {t:useMemo(()=>createT(r,i),[r,i])}}function qe({rect:r,color:i,newText:u,agentId:f}){return jsxs("div",{"data-testid":"xlsx-proposal-decoration","aria-hidden":"true",style:{position:"absolute",left:r.x,top:r.y,width:r.w,height:r.h,boxSizing:"border-box",border:`1.5px dashed ${i}`,pointerEvents:"none",overflow:"hidden"},children:[jsx("span",{style:{position:"absolute",left:0,right:0,bottom:1,textAlign:"center",opacity:.6,color:i,font:"11px system-ui, sans-serif",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",padding:"0 2px"},children:u}),jsx("span",{title:`${f}: ${u}`,style:{position:"absolute",top:0,right:0,width:6,height:6,background:i,pointerEvents:"auto"}})]})}var Je=["#7c3aed","#0891b2","#c2410c","#4d7c0f","#be185d","#1d4ed8"];function Pt(r){let i=2166136261;for(let u=0;u<r.length;u++)i^=r.charCodeAt(u),i=Math.imul(i,16777619);return (i>>>0)%Je.length}function ue(r){return Je[Pt(r)]}function Qe({proposals:r,staleFor:i,onAccept:u,onReject:f,style:y}){let{t:x}=N();return jsx("div",{"data-testid":"xlsx-proposals-panel",role:"region","aria-label":x("proposals.panelLabel"),style:{position:"absolute",top:"100%",right:0,marginTop:4,width:320,maxHeight:420,overflowY:"auto",background:"#ffffff",border:"1px solid #d0d0d0",borderRadius:10,boxShadow:"0 6px 24px rgba(0, 0, 0, 0.16)",padding:8,zIndex:10,font:"13px system-ui, sans-serif",textAlign:"left",...y},children:r.length===0?jsx("div",{style:{padding:12,color:"#707070",textAlign:"center"},children:x("proposals.empty")}):r.map(n=>{let w=ue(n.agentId),H=i[n.id];return jsxs("div",{"data-testid":"xlsx-proposal","data-proposal-id":n.id,style:{borderLeft:`3px solid ${w}`,padding:"8px 10px",marginBottom:8,background:"#fafafa",borderRadius:4},children:[jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"baseline"},children:[jsx("strong",{style:{color:w},children:n.agentId}),jsx("span",{style:{color:"#707070",fontSize:12},children:x("proposals.cellCount",{count:n.cells.length})})]}),n.note&&jsx("div",{style:{color:"#404040",margin:"4px 0"},children:n.note}),jsx("ul",{style:{listStyle:"none",margin:"6px 0",padding:0},children:n.cells.map(A=>jsxs("li",{"data-testid":"xlsx-proposal-cell",style:{fontVariantNumeric:"tabular-nums",lineHeight:1.5},children:[jsx("strong",{"data-testid":"xlsx-proposal-cell-a1",children:A.a1}),":"," ",jsx("span",{style:{color:"#909090"},children:A.oldText||"\u2205"})," ",x("proposals.changeArrow")," ",jsx("span",{"data-testid":"xlsx-proposal-cell-new",style:{color:w},children:A.newText})]},A.a1))}),H&&H.length>0&&jsx("div",{"data-testid":"xlsx-proposal-stale",role:"alert",style:{color:"#b45309",background:"#fef3c7",borderRadius:4,padding:"4px 6px",margin:"4px 0",fontSize:12},children:x("proposals.staleWarning",{cells:H.join(", ")})}),jsxs("div",{style:{display:"flex",gap:6,marginTop:4},children:[jsx("button",{"data-testid":"xlsx-proposal-accept",onClick:()=>u(n.id),style:{padding:"3px 10px",cursor:"pointer"},children:x("proposals.accept")}),H&&H.length>0&&jsx("button",{"data-testid":"xlsx-proposal-force",onClick:()=>u(n.id,true),style:{padding:"3px 10px",cursor:"pointer",color:"#b45309"},children:x("proposals.forceApply")}),jsx("button",{"data-testid":"xlsx-proposal-reject",onClick:()=>f(n.id),style:{padding:"3px 10px",cursor:"pointer"},children:x("proposals.reject")})]})]},n.id)})})}var K=96,O=24,be="#217346",lt=46,Ot="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";function zt(r,i,u){let f=[{op:"fillRect",x:0,y:0,w:r,h:i,color:"#ffffff"}],y=Math.ceil(r/K),x=Math.ceil(i/O);for(let n=0;n<=y;n++)f.push({op:"line",x1:n*K,y1:0,x2:n*K,y2:i,width:1,color:"#e0e0e0"});for(let n=0;n<=x;n++)f.push({op:"line",x1:0,y1:n*O,x2:r,y2:n*O,width:1,color:"#e0e0e0"});return f.push({op:"fillRect",x:0,y:0,w:r,h:O,color:"#f3f3f3"}),f.push({op:"fillRect",x:0,y:0,w:K,h:i,color:"#f3f3f3"}),f.push({op:"text",x:K+8,y:O+18,text:u,fontSize:14,color:"#202020",clip:{x:K,y:O,w:K*3,h:O},align:"left"}),{width:r,height:i,commands:f}}function ot(r,i){if(!r||r.length<2)return i;let u=[];for(let y=1;y<r.length;y++)u.push(r[y]-r[y-1]);u.sort((y,x)=>y-x);let f=u[u.length>>1];return f>0?f:i}function Ft(r,i,u){let f=ot(r?.grid?.rowOffsets,O),y=ot(r?.grid?.colOffsets,K),x=Math.max(1,Math.round(i.contentHeight/f))+1,n=Math.max(1,Math.round(i.contentWidth/y))+1,w=Math.max(1,Math.floor(u/f));return {rows:x,cols:n,rowsPerPage:w}}function nt(r,i,u){let f=new Blob([new Uint8Array(r)],{type:u}),y=URL.createObjectURL(f),x=document.createElement("a");x.href=y,x.download=i,document.body.appendChild(x),x.click(),x.remove(),URL.revokeObjectURL(y);}function $t(r){return `${(r??"workbook.xlsx").replace(/\.xlsx$/i,"")}.png`}var Ut={position:"absolute",width:1,height:1,margin:-1,padding:0,border:0,overflow:"hidden",clip:"rect(0 0 0 0)",whiteSpace:"nowrap"},M={shell:{flex:"0 0 auto",minHeight:lt,padding:"4px 0 5px",borderBottom:"1px solid #e2e8f0",background:"#ffffff",color:"#0f172a",boxSizing:"border-box"},rail:{display:"flex",alignItems:"center",minHeight:36,margin:"0 8px",padding:"4px 8px",borderRadius:999,background:"#f1f5f9",boxSizing:"border-box",overflowX:"auto",overflowY:"hidden"},group:{display:"inline-flex",alignItems:"center",gap:1,padding:"0 6px",borderRight:"1px solid rgba(226, 232, 240, 0.9)",flex:"0 0 auto"},formulaGroup:{display:"flex",alignItems:"center",gap:4,flex:"1 1 320px",minWidth:240,padding:"0 6px",borderRight:"1px solid rgba(226, 232, 240, 0.9)"},nameBox:{appearance:"none",width:64,height:28,flex:"0 0 auto",boxSizing:"border-box",border:"1px solid #e2e8f0",borderRadius:6,background:"#f8fafc",color:"#0f172a",font:"600 12px ui-monospace, SFMono-Regular, Menlo, monospace",textAlign:"center",outlineColor:"#2563eb"},formulaMark:{display:"grid",placeItems:"center",width:20,height:28,flex:"0 0 auto",color:"#64748b",font:"italic 700 12px Georgia, serif",userSelect:"none"},formulaInput:{appearance:"none",flex:"1 1 260px",minWidth:140,height:28,boxSizing:"border-box",border:"1px solid #e2e8f0",borderRadius:6,padding:"0 8px",background:"#ffffff",color:"#0f172a",font:"13px ui-sans-serif, system-ui, sans-serif",outlineColor:"#2563eb"},proposals:{marginLeft:"auto",paddingLeft:6,flex:"0 0 auto"},count:{display:"inline-grid",placeItems:"center",minWidth:15,height:15,marginLeft:-3,padding:"0 4px",borderRadius:8,background:"#0f172a",color:"#ffffff",fontSize:10,fontWeight:700,lineHeight:1,boxSizing:"border-box"}};function q(r,i=false){return {appearance:"none",display:"inline-flex",alignItems:"center",justifyContent:"center",gap:2,width:28,height:28,padding:0,border:0,borderRadius:6,background:i?"#0f172a":"transparent",color:r?i?"#ffffff":"#64748b":"#94a3b8",cursor:r?"pointer":"default",opacity:r?1:.32}}function J({name:r}){return jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",focusable:"false",style:{flex:"0 0 auto"},children:[r==="save"&&jsx("path",{d:"M12 3v11m0 0 4-4m-4 4-4-4M5 19h14"}),r==="image"&&jsxs(Fragment,{children:[jsx("rect",{x:"3",y:"5",width:"18",height:"14",rx:"2"}),jsx("circle",{cx:"8.5",cy:"9.5",r:"1.25"}),jsx("path",{d:"m6 17 4.5-4.5 3.25 3.25L16 13.5l2 2"})]}),r==="undo"&&jsx("path",{d:"m9 7-5 5 5 5M5 12h9a6 6 0 0 1 6 6"}),r==="redo"&&jsx("path",{d:"m15 7 5 5-5 5m4-5h-9a6 6 0 0 0-6 6"}),r==="proposals"&&jsxs(Fragment,{children:[jsx("path",{d:"m12 3 1.25 3.75L17 8l-3.75 1.25L12 13l-1.25-3.75L7 8l3.75-1.25L12 3Z"}),jsx("path",{d:"m18 14 .75 2.25L21 17l-2.25.75L18 20l-.75-2.25L15 17l2.25-.75L18 14Z"})]})]})}function Nt({i18n:r,...i}){return jsx(de,{i18n:r,children:jsx(_t,{...i})})}function _t({file:r,fileName:i,onSave:u,collaboration:f,onReady:y,className:x}){let{t:n}=N(),w=f!==void 0,H=f?.clientId,A=f?.initialUpdate,Q=f?.onReplica,De=useRef(null),z=useRef(null),xe=useRef(null),b=useRef(null),he=useRef(null),$=useRef(null),Te=useRef(null),me=useRef(false),ee=useRef(false),Ie=useRef(y);Ie.current=y;let[d,X]=useState(null),[ye,v]=useState(null),[te,at]=useState(null),[c,C]=useState(null),[E,U]=useState(null),[Me,ve]=useState(null),[oe,_]=useState(null),[He,it]=useState(lt),[Ae,Xe]=useState(0),[j,ne]=useState([]),[we,Be]=useState(false),[Le,We]=useState(null),[st,G]=useState({}),m=d?.activeSheet??0,Ke=useMemo(()=>isPngExportAvailable(),[]),Oe=useMemo(()=>isProposalsAvailable(),[]);useEffect(()=>{let e=De.current;if(!e)return;let t=()=>it(e.offsetHeight);t();let o=new ResizeObserver(t);return o.observe(e),()=>o.disconnect()},[]);let B=useCallback(()=>{let e=b.current;if(!e){ne([]);return}try{ne(e.listProposals());}catch{ne([]);}},[]);useEffect(()=>{if(U(null),_(null),ne([]),G({}),Be(false),We(null),!r){b.current=null,X(null),C(null),v(null);return}b.current=null,X(null),C(null);let e=null,t=()=>{},o=()=>{},l=false,a=()=>{let p=o;o=()=>{};try{p();}catch{}};return initWasm().then(()=>{if(!l)try{e=openWorkbook(r,{collaborative:w,clientId:H}),A&&e.applyUpdate(A.slice()),b.current=e,t=e.onUpdate(()=>{if(!(l||!e))try{X(e.sheetInfo()),Xe(h=>h+1),G({}),B(),v(null);}catch(h){v(h instanceof Error?h.message:String(h));}}),X(e.sheetInfo()),C(selectionAt({row:0,col:0})),We(e),v(null),B();let p=Ie.current?.({handle:e,refreshProposals:B});typeof p=="function"&&(o=p);}catch(p){a(),t(),t=()=>{},e?.dispose(),e=null,b.current=null,X(null),C(null),v(p instanceof Error?p.message:String(p));}},p=>{l||(b.current=null,X(null),C(null),v(p instanceof Error?p.message:String(p)));}),()=>{l=true,a(),t(),e?.dispose(),b.current=null;}},[r,w,H,A,B]),useEffect(()=>{if(!(!Q||!Le))return Q(Le),()=>Q(null)},[Q,Le]);let Se=useCallback(()=>{let e=z.current,t=xe.current;if(!e||!t)return;let o=t.getContext("2d");if(!o)return;let l=window.devicePixelRatio||1,a=e.clientWidth,p=e.clientHeight;if(a===0||p===0)return;t.width=Math.round(a*l),t.height=Math.round(p*l),t.style.width=`${a}px`,t.style.height=`${p}px`;let h=b.current,T;if(h)try{T=h.displayList({x:e.scrollLeft,y:e.scrollTop,width:a,height:p});}catch{return}else T=zt(a,p,n("editor.demoCellText"));paintDisplayList(o,T,l),he.current=T,at(T);},[n]);useEffect(()=>{let e=z.current;if(!e)return;let t=()=>{$.current==null&&($.current=requestAnimationFrame(()=>{$.current=null,Se();}));};Se(),e.addEventListener("scroll",t,{passive:true});let o=new ResizeObserver(t);return o.observe(e),()=>{e.removeEventListener("scroll",t),o.disconnect(),$.current!=null&&(cancelAnimationFrame($.current),$.current=null);}},[Se,d,ye,Ae]),useEffect(()=>{let e=b.current;if(!e||!c||!d){ve(null);return}try{ve(e.cell(m,c.focus.row,c.focus.col));}catch{ve(null);}},[c,d,m,Ae]),useEffect(()=>{let e=()=>{me.current=false;};return window.addEventListener("mouseup",e),()=>window.removeEventListener("mouseup",e)},[]);let re=useMemo(()=>!te||!d?null:buildA11yGrid(te,c,d.sheetNames[m]??"",{gridLabel:n("a11y.gridLabel"),rowHeaderLabel:n("a11y.rowHeaderLabel"),columnHeaderLabel:n("a11y.columnHeaderLabel"),cellLabel:n("a11y.cellLabel"),cellLabelSelected:n("a11y.cellLabelSelected"),emptyCellLabel:n("a11y.emptyCellLabel"),emptyCellLabelSelected:n("a11y.emptyCellLabelSelected")}),[te,c,d,m,n]),k=useCallback(()=>{z.current?.focus({preventScroll:true});},[]);useEffect(()=>{E&&Te.current?.focus({preventScroll:true});},[E]);let S=useCallback(e=>{X(e.sheetInfo),Xe(t=>t+1);},[]),D=useCallback(()=>Ft(he.current,d,z.current?.clientHeight??0),[d]),le=useCallback((e,t)=>{let o=xe.current,l=he.current?.grid;if(!o||!l)return null;let a=o.getBoundingClientRect();return cellAtPoint(l,e-a.left,t-a.top)},[]),ae=useCallback(e=>{let t=b.current;if(!t||!c)return;let{row:o,col:l}=c.focus,a=e??"";if(e===void 0)try{a=t.cell(m,o,l).input;}catch{a="";}U({row:o,col:l,value:a});},[c,m]),Ce=useCallback(e=>{let t=b.current;if(!t||!E)return;ee.current=true;let{row:o,col:l,value:a}=E;try{S(t.editCell(m,o,l,a));}catch(h){v(h instanceof Error?h.message:String(h));}U(null);let p=selectionAt({row:o,col:l});C(e?moveFocus(p,e,{limits:D()}):p),k();},[E,m,S,D,k]),ct=useCallback(()=>{ee.current=true,U(null),k();},[k]),ie=useCallback(()=>{let e=b.current;if(!e||!c)return;let t=normalizeRange(c),o=[];for(let l=t.top;l<=t.bottom;l++)for(let a=t.left;a<=t.right;a++)o.push({row:l,col:a,input:""});try{S(e.editCells(m,o));}catch(l){v(l instanceof Error?l.message:String(l));}},[c,m,S]),se=useCallback(async()=>{let e=b.current;if(!e||!c)return;let t=normalizeRange(c);try{let o=e.cell(m,t.top,t.left).a1,l=e.cell(m,t.bottom,t.right).a1,a=e.rangeCells(m,`${o}:${l}`),p=toTsv(a.map(h=>h.map(T=>({input:T.input,isFormula:T.isFormula}))));await navigator.clipboard.writeText(p);}catch{}},[c,m]),ze=useCallback(async()=>{await se(),ie();},[se,ie]),Fe=useCallback(async()=>{let e=b.current;if(!e||!c)return;let t;try{t=await navigator.clipboard.readText();}catch{return}let o=fromTsv(t);if(o.length===0)return;let l=normalizeRange(c),a=[],p=1;o.forEach((h,T)=>{p=Math.max(p,h.length),h.forEach((wt,Lt)=>a.push({row:l.top+T,col:l.left+Lt,input:wt}));});try{S(e.editCells(m,a));}catch(h){v(h instanceof Error?h.message:String(h));return}C({anchor:{row:l.top,col:l.left},focus:{row:l.top+o.length-1,col:l.left+p-1}});},[c,m,S]),Ee=useCallback(()=>{let e=b.current;if(!(!e||w))try{S(e.undo());}catch(t){v(t instanceof Error?t.message:String(t));}},[S,w]),ce=useCallback(()=>{let e=b.current;if(!(!e||w))try{S(e.redo());}catch(t){v(t instanceof Error?t.message:String(t));}},[S,w]),dt=useCallback((e,t)=>{let o=b.current;if(o)try{S(o.acceptProposal(e,{force:t})),G(({[e]:l,...a})=>a),B(),k();}catch(l){l instanceof StaleProposalError?G(a=>({...a,[e]:l.cells})):v(l instanceof Error?l.message:String(l));}},[S,B,k]),ut=useCallback(e=>{let t=b.current;if(t)try{t.rejectProposal(e),G(({[e]:o,...l})=>l),B();}catch(o){v(o instanceof Error?o.message:String(o));}},[B]),Pe=useCallback(()=>{let e=b.current;if(e)try{let t=e.save();u?u(t):nt(t,i??"workbook.xlsx",Ot);}catch(t){v(t instanceof Error?t.message:String(t));}},[u,i]),pt=useCallback(()=>{let e=b.current,t=z.current;if(!(!e||!t))try{let o=e.renderPng({x:t.scrollLeft,y:t.scrollTop,width:t.clientWidth,height:t.clientHeight});nt(o,$t(i),"image/png");}catch(o){v(o instanceof Error?o.message:String(o));}},[i]),$e=useCallback(e=>{let t=b.current;if(!t||!c||oe==null)return;let{row:o,col:l}=c.focus;try{S(t.editCell(m,o,l,oe));}catch(a){v(a instanceof Error?a.message:String(a));}_(null),e&&C(a=>a&&moveFocus(a,e,{limits:D()}));},[c,oe,m,S,D]),ft=useCallback(e=>{if(!b.current||!c||!d||E)return;let o=e.metaKey||e.ctrlKey,l=e.key.toLowerCase();if(o){if(l==="c"){se(),e.preventDefault();return}if(l==="v"){Fe(),e.preventDefault();return}if(l==="x"){ze(),e.preventDefault();return}if(l==="z"){e.shiftKey?ce():Ee(),e.preventDefault();return}if(l==="y"){ce(),e.preventDefault();return}if(l==="s"){Pe(),e.preventDefault();return}}let a=selectionKeyReducer(c,{key:e.key,shiftKey:e.shiftKey,metaKey:e.metaKey,ctrlKey:e.ctrlKey,altKey:e.altKey},D());switch(a.type){case "move":C(a.selection),e.preventDefault();break;case "startEdit":ae(a.initialInput),e.preventDefault();break;case "clear":ie(),e.preventDefault();break;}},[c,d,E,D,se,Fe,ze,Ee,ce,Pe,ae,ie]),gt=useCallback(e=>{if(!c)return;let t=le(e.clientX,e.clientY);t&&(e.shiftKey?C(o=>o&&extendTo(o,t,D())):C(selectionAt(t)),me.current=true,k());},[c,le,D,k]),bt=useCallback(e=>{if(!me.current)return;let t=le(e.clientX,e.clientY);t&&C(o=>o&&extendTo(o,t,D()));},[le,D]),xt=useCallback(()=>{c&&ae();},[c,ae]),W=te?.grid,Y=W&&c?rangeRect(W,normalizeRange(c)):null,V=W&&c?cellRect(W,c.focus.row,c.focus.col):null,Z=W&&E?cellRect(W,E.row,E.col):null,ht=d?d.contentWidth:void 0,mt=d?d.contentHeight:void 0,yt=oe??Me?.input??"",vt=e=>{let t=b.current;if(t)try{t.setActiveSheet(e);let o=z.current;o&&(o.scrollLeft=0,o.scrollTop=0),C(selectionAt({row:0,col:0})),U(null),_(null),X(t.sheetInfo());}catch(o){v(o instanceof Error?o.message:String(o));}};return jsxs("div",{className:x,role:"application","aria-label":n("editor.appLabel"),style:{position:"relative",display:"flex",flexDirection:"column",width:"100%",height:"100%",minWidth:0,color:"#202124",background:"#ffffff",fontFamily:"ui-sans-serif, system-ui, sans-serif"},children:[jsx("div",{ref:De,"data-testid":"xlsx-toolbar",style:M.shell,children:jsxs("div",{style:M.rail,role:"group","aria-label":n("toolbar.actionsLabel"),children:[jsxs("div",{style:{...M.group,paddingLeft:0},role:"group","aria-label":n("toolbar.fileActionsLabel"),children:[jsx("button",{type:"button","data-testid":"xlsx-save",onClick:Pe,disabled:!d,"aria-label":n("toolbar.save"),title:n("toolbar.save"),style:q(!!d),children:jsx(J,{name:"save"})}),jsx("button",{type:"button","data-testid":"xlsx-export-png",onClick:pt,disabled:!d||!Ke,"aria-label":n("toolbar.exportPng"),title:n("toolbar.exportPng"),style:q(!!(d&&Ke)),children:jsx(J,{name:"image"})})]}),jsxs("div",{style:M.group,role:"group","aria-label":n("toolbar.historyLabel"),children:[jsx("button",{type:"button","data-testid":"xlsx-undo",onClick:Ee,disabled:!d||w,"aria-label":n("toolbar.undo"),title:n("toolbar.undo"),style:q(!!(d&&!w)),children:jsx(J,{name:"undo"})}),jsx("button",{type:"button","data-testid":"xlsx-redo",onClick:ce,disabled:!d||w,"aria-label":n("toolbar.redo"),title:n("toolbar.redo"),style:q(!!(d&&!w)),children:jsx(J,{name:"redo"})})]}),jsxs("div",{style:M.formulaGroup,role:"group","aria-label":n("toolbar.formulaBarLabel"),children:[jsx("input",{"data-testid":"xlsx-name-box",readOnly:true,value:Me?.a1??"",placeholder:n("toolbar.nameBoxPlaceholder"),"aria-label":n("toolbar.nameBoxPlaceholder"),style:M.nameBox}),jsx("span",{style:M.formulaMark,"aria-hidden":"true",children:"fx"}),jsx("input",{"data-testid":"xlsx-formula-input",value:yt,placeholder:n("toolbar.formulaPlaceholder"),"aria-label":n("toolbar.formulaPlaceholder"),disabled:!d,onChange:e=>_(e.target.value),onKeyDown:e=>{e.key==="Enter"?($e(e.shiftKey?"up":"down"),k(),e.preventDefault()):e.key==="Escape"&&(_(null),k(),e.preventDefault());},onBlur:()=>$e(),style:M.formulaInput})]}),Oe&&jsx("div",{style:M.proposals,children:jsxs("button",{type:"button","data-testid":"xlsx-proposals-button",onClick:()=>Be(e=>!e),disabled:!d,"aria-expanded":we,"aria-label":n("proposals.panelLabel"),title:n("proposals.panelLabel"),style:{...q(!!d,we),width:j.length>0?42:28},children:[jsx(J,{name:"proposals"}),j.length>0&&jsx("span",{"data-testid":"xlsx-proposals-count",style:M.count,children:j.length})]})})]})}),Oe&&we&&jsx(Qe,{proposals:j,staleFor:st,onAccept:dt,onReject:ut,style:{top:He+4,right:8,width:"min(320px, calc(100% - 16px))",maxHeight:`min(420px, calc(100% - ${He+12}px))`}}),jsxs("div",{ref:z,"data-testid":"xlsx-scroll",tabIndex:0,onKeyDown:ft,onMouseDown:gt,onMouseMove:bt,onDoubleClick:xt,style:{position:"relative",flex:1,overflow:"auto",minHeight:0,outline:"none"},children:[jsx("div",{style:{position:"absolute",top:0,left:0,width:ht??"100%",height:mt??"100%"}}),jsxs("div",{style:{position:"sticky",top:0,left:0,width:0,height:0},children:[jsx("canvas",{ref:xe,style:{display:"block",position:"absolute",top:0,left:0}}),jsxs("div",{"data-testid":"xlsx-overlay-host",style:{position:"absolute",top:0,left:0,width:0,height:0,pointerEvents:"none"},children:[Y&&jsx("div",{"data-testid":"xlsx-selection",style:{position:"absolute",left:Y.x,top:Y.y,width:Y.w,height:Y.h,boxSizing:"border-box",border:`1px solid ${be}`,background:"rgba(33, 115, 70, 0.12)"}}),V&&!E&&jsx("div",{style:{position:"absolute",left:V.x,top:V.y,width:V.w,height:V.h,boxSizing:"border-box",border:`2px solid ${be}`}}),W&&j.flatMap(e=>e.cells.map(t=>{if(t.sheet!==m)return null;let o=cellRect(W,t.row,t.col);return o?jsx(qe,{rect:o,color:ue(e.agentId),newText:t.newText,agentId:e.agentId},`${e.id}:${t.a1}`):null})),E&&Z&&jsx("input",{ref:Te,"data-testid":"xlsx-cell-editor",value:E.value,onChange:e=>U(t=>t&&{...t,value:e.target.value}),onKeyDown:e=>{e.stopPropagation(),e.key==="Enter"?(Ce(e.shiftKey?"up":"down"),e.preventDefault()):e.key==="Tab"?(Ce(e.shiftKey?"left":"right"),e.preventDefault()):e.key==="Escape"&&(ct(),e.preventDefault());},onBlur:()=>{if(ee.current){ee.current=false;return}Ce();},style:{position:"absolute",left:Z.x,top:Z.y,width:Z.w,height:Z.h,boxSizing:"border-box",border:`2px solid ${be}`,padding:"0 3px",font:"13px system-ui, sans-serif",background:"#ffffff",pointerEvents:"auto",outline:"none"}})]})]})]}),re&&jsxs("div",{style:Ut,role:"grid","aria-label":re.label,children:[jsxs("div",{role:"row",children:[jsx("span",{role:"columnheader"}),re.columnHeaders.map(e=>jsx("span",{role:"columnheader",children:e.label},e.col))]}),re.rows.map(e=>jsxs("div",{role:"row",children:[jsx("span",{role:"rowheader",children:e.header}),e.cells.map(t=>jsx("span",{role:"gridcell","aria-selected":t.selected,children:t.label},t.col))]},e.row))]}),ye&&jsxs("div",{"data-testid":"xlsx-error",role:"alert",style:{position:"absolute",inset:0,display:"grid",placeItems:"center",padding:16,textAlign:"center",color:"#b00020"},children:[n("editor.openError"),": ",ye]}),d&&d.sheetNames.length>0&&jsx("div",{"data-testid":"xlsx-sheet-tabs",role:"tablist","aria-label":n("editor.sheetTabsLabel"),style:{display:"flex",gap:2,padding:"4px 6px",borderTop:"1px solid #e0e0e0",background:"#fafafa",overflowX:"auto"},children:d.sheetNames.map((e,t)=>{let o=t===d.activeSheet;return jsx("button",{role:"tab","aria-selected":o,onClick:()=>vt(t),style:{border:"none",padding:"4px 12px",cursor:"pointer",borderBottom:o?`2px solid ${be}`:"2px solid transparent",fontWeight:o?600:400,background:o?"#ffffff":"transparent"},children:e},t)})})]})}export{de as LocaleProvider,Nt as XlsxEditor,N as useTranslation};
|
|
1
|
+
import {createContext,useMemo,useContext,useState,useRef,useCallback,useEffect}from'react';import {isPngExportAvailable,isProposalsAvailable,initWasm,openWorkbook,selectionAt,paintDisplayList,normalizeRange,buildA11yGrid,cellAtPoint,moveFocus,toTsv,fromTsv,StaleProposalError,selectionKeyReducer,extendTo,rangeRect,cellRect}from'@betteroffice/xlsx';import {en,deepMerge,createT}from'@betteroffice/xlsx-i18n';import {jsx,jsxs,Fragment}from'react/jsx-runtime';var Ut=createContext(en),Gt=createContext("en");function rt({i18n:t,children:r}){let i=typeof t?._lang=="string"?t._lang:"en",c=useMemo(()=>deepMerge(en,t),[t]);return jsx(Gt.Provider,{value:i,children:jsx(Ut.Provider,{value:c,children:r})})}function ye(){let t=useContext(Ut),r=useContext(Gt);return {t:useMemo(()=>createT(t,r),[t,r])}}var De=createContext(null);function Io(){let t=useContext(De);if(!t)throw new Error("useEditorToolbar must be used within an <EditorToolbar> component");return t}function k({name:t,size:r=20,style:i}){return jsxs("svg",{width:r,height:r,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",focusable:"false",style:{display:"inline-flex",flexShrink:0,...i},children:[t==="search"&&jsxs(Fragment,{children:[jsx("circle",{cx:"10.5",cy:"10.5",r:"6"}),jsx("path",{d:"m15 15 4.5 4.5"})]}),t==="undo"&&jsx("path",{d:"m9 7-5 5 5 5M5 12h9a6 6 0 0 1 6 6"}),t==="redo"&&jsx("path",{d:"m15 7 5 5-5 5m4-5h-9a6 6 0 0 0-6 6"}),t==="print"&&jsxs(Fragment,{children:[jsx("path",{d:"M7 9V4h10v5M7 18H5a2 2 0 0 1-2-2v-5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2v5a2 2 0 0 1-2 2h-2"}),jsx("path",{d:"M7 14h10v6H7z"}),jsx("path",{d:"M17.5 12h.01"})]}),t==="formatPaint"&&jsxs(Fragment,{children:[jsx("path",{d:"M5 4h11v5H5zM8 9v3h5V9"}),jsx("path",{d:"M10.5 12v8"})]}),t==="decimalDecrease"&&jsxs(Fragment,{children:[jsx("path",{d:"M5 7h1M9 7h1M14 7h1M18 7h1"}),jsx("path",{d:"M5 16h1M9 16h1"}),jsx("path",{d:"m15 12-4 4 4 4M11 16h8"})]}),t==="decimalIncrease"&&jsxs(Fragment,{children:[jsx("path",{d:"M5 7h1M9 7h1"}),jsx("path",{d:"M5 16h1M9 16h1M14 16h1M18 16h1"}),jsx("path",{d:"m15 3 4 4-4 4M19 7h-8"})]}),t==="bold"&&jsx("path",{d:"M7 4h6a4 4 0 0 1 0 8H7zm0 8h7a4 4 0 0 1 0 8H7z"}),t==="italic"&&jsx("path",{d:"M10 4h8M6 20h8M14 4 10 20"}),t==="strikethrough"&&jsx(Fragment,{children:jsx("path",{d:"M5 12h14M8 7.5A4.5 4.5 0 0 1 12.5 4c2.2 0 3.7 1 4.5 2.5M8 16.5c.8 2.1 2.4 3.5 5 3.5 2.8 0 4.5-1.4 4.5-3.5 0-2.3-2-3.3-5.5-4.5"})}),t==="textColor"&&jsxs(Fragment,{children:[jsx("path",{d:"m7 16 5-12 5 12M9 11h6"}),jsx("path",{d:"M5 20h14",strokeWidth:"3"})]}),t==="fillColor"&&jsxs(Fragment,{children:[jsx("path",{d:"m7 4 10 10-6 6-7-7zM5 12h12"}),jsx("path",{d:"M18 17c0-1 1-2 1-2s1 1 1 2a1 1 0 0 1-2 0Z"})]}),t==="borders"&&jsx(Fragment,{children:jsx("path",{d:"M4 4h16v16H4zM12 4v16M4 12h16"})}),t==="merge"&&jsxs(Fragment,{children:[jsx("path",{d:"M4 5h16v14H4z"}),jsx("path",{d:"m8 9 3 3-3 3M16 9l-3 3 3 3"})]}),t==="alignLeft"&&jsx("path",{d:"M4 6h16M4 10h11M4 14h16M4 18h11"}),t==="verticalAlignCenter"&&jsxs(Fragment,{children:[jsx("path",{d:"M4 4h16M4 20h16M8 12h8"}),jsx("path",{d:"m10 9 2 3 2-3M10 15l2-3 2 3"})]}),t==="wrap"&&jsxs(Fragment,{children:[jsx("path",{d:"M4 6h16M4 11h12a3 3 0 0 1 0 6h-3"}),jsx("path",{d:"m15 14-3 3 3 3M4 17h5"})]}),t==="more"&&jsxs(Fragment,{children:[jsx("circle",{cx:"5",cy:"12",r:"1",fill:"currentColor",stroke:"none"}),jsx("circle",{cx:"12",cy:"12",r:"1",fill:"currentColor",stroke:"none"}),jsx("circle",{cx:"19",cy:"12",r:"1",fill:"currentColor",stroke:"none"})]}),t==="chevronDown"&&jsx("path",{d:"m7 10 5 5 5-5"}),t==="remove"&&jsx("path",{d:"M5 12h14"}),t==="add"&&jsx("path",{d:"M12 5v14M5 12h14"}),t==="check"&&jsx("path",{d:"m5 12 4 4L19 6"}),t==="save"&&jsx("path",{d:"M12 3v11m0 0 4-4m-4 4-4-4M5 19h14"}),t==="image"&&jsxs(Fragment,{children:[jsx("rect",{x:"3",y:"5",width:"18",height:"14",rx:"2"}),jsx("circle",{cx:"8.5",cy:"9.5",r:"1.25"}),jsx("path",{d:"m6 17 4.5-4.5 3.25 3.25L16 13.5l2 2"})]}),t==="proposals"&&jsxs(Fragment,{children:[jsx("path",{d:"m12 3 1.25 3.75L17 8l-3.75 1.25L12 13l-1.25-3.75L7 8l3.75-1.25L12 3Z"}),jsx("path",{d:"m18 14 .75 2.25L21 17l-2.25.75L18 20l-.75-2.25L15 17l2.25-.75L18 14Z"})]})]})}var T={text:"#3c4043",muted:"#5f6368",disabled:"#9aa0a6",hover:"#e2e7ef",active:"#d3e3fd",border:"#c7cacf",surface:"#ffffff",rail:"#edf2fa"},Ho={appearance:"none",display:"inline-flex",alignItems:"center",justifyContent:"center",gap:2,minWidth:28,height:28,padding:"0 5px",border:0,borderRadius:4,color:T.text,font:"500 13px ui-sans-serif, system-ui, sans-serif",lineHeight:1,whiteSpace:"nowrap",boxSizing:"border-box"};function _t(t,r,i,c){return {...Ho,background:r?T.active:i&&!t?T.hover:"transparent",color:t?T.disabled:T.text,cursor:t?"default":"pointer",opacity:t?.48:1,...c}}function H({active:t=false,disabled:r=false,title:i,onClick:c,children:h,style:g,testId:s,ariaExpanded:F}){let[R,z]=useState(false);return jsx("button",{type:"button","data-testid":s,disabled:r,"aria-label":i,"aria-pressed":t||void 0,"aria-expanded":F,title:i,onMouseDown:O=>O.preventDefault(),onMouseEnter:()=>z(true),onMouseLeave:()=>z(false),onClick:r?void 0:c,style:_t(r,t,R,g),children:h})}function K({label:t,children:r,style:i}){return jsx("div",{role:"group","aria-label":t,style:{display:"inline-flex",alignItems:"center",gap:1,flex:"0 0 auto",...i},children:r})}function $e(){return jsx("div",{role:"separator",style:{width:1,height:24,margin:"0 5px",background:T.border,flex:"0 0 auto"}})}function ce({title:t,trigger:r,children:i,disabled:c=false,active:h=false,menuWidth:g=220,style:s,testId:F}){let[R,z]=useState(false),[O,q]=useState(false),[U,ae]=useState({top:0,left:0}),x=useRef(null),_=useRef(null),I=useCallback(()=>z(false),[]);return useEffect(()=>{if(!R||!x.current)return;let B=x.current.getBoundingClientRect(),J=Math.min(B.left,Math.max(8,window.innerWidth-g-8));ae({top:B.bottom+4,left:J});},[R,g]),useEffect(()=>{if(!R)return;let B=Y=>{let S=Y.target;!x.current?.contains(S)&&!_.current?.contains(S)&&I();},J=Y=>{Y.key==="Escape"&&I();},v=()=>I();return document.addEventListener("mousedown",B),document.addEventListener("keydown",J),window.addEventListener("scroll",v,true),()=>{document.removeEventListener("mousedown",B),document.removeEventListener("keydown",J),window.removeEventListener("scroll",v,true);}},[R,I]),jsxs("div",{style:{position:"relative",display:"inline-flex",flex:"0 0 auto"},children:[jsx("button",{ref:x,type:"button","data-testid":F,disabled:c,"aria-label":t,"aria-haspopup":"menu","aria-expanded":R,title:t,onMouseDown:B=>B.preventDefault(),onMouseEnter:()=>q(true),onMouseLeave:()=>q(false),onClick:()=>!c&&z(B=>!B),style:_t(c,h||R,O,s),children:r}),R&&jsx("div",{ref:_,role:"menu","aria-label":t,onMouseDown:B=>B.preventDefault(),style:{position:"fixed",top:U.top,left:U.left,zIndex:1e4,width:g,maxHeight:"min(440px, calc(100vh - 16px))",overflowY:"auto",padding:6,border:`1px solid ${T.border}`,borderRadius:8,background:T.surface,boxShadow:"0 4px 16px rgba(60, 64, 67, 0.24)",boxSizing:"border-box"},children:i(I)})]})}function te({label:t,icon:r,selected:i=false,disabled:c=false,onClick:h,close:g}){let[s,F]=useState(false);return jsxs("button",{type:"button",role:"menuitem",disabled:c,"aria-label":t,onMouseEnter:()=>F(true),onMouseLeave:()=>F(false),onClick:()=>{c||(h?.(),g?.());},style:{appearance:"none",display:"flex",alignItems:"center",gap:10,width:"100%",minHeight:32,padding:"5px 9px",border:0,borderRadius:4,background:s&&!c?T.hover:"transparent",color:c?T.disabled:T.text,cursor:c?"default":"pointer",opacity:c?.48:1,font:"400 13px ui-sans-serif, system-ui, sans-serif",textAlign:"left",boxSizing:"border-box"},children:[jsx("span",{style:{display:"inline-grid",placeItems:"center",width:20,flex:"0 0 auto"},children:r}),jsx("span",{style:{flex:1},children:t}),i&&jsx("span",{"aria-hidden":"true",children:"\u2713"})]})}function Oe(){return jsx("div",{role:"separator",style:{height:1,margin:"5px 2px",background:T.border}})}function xt({mode:t,value:r,label:i,onChange:c,disabled:h=false}){let[g,s]=useState(false);return jsxs("label",{title:i,"aria-label":i,style:{position:"relative",display:"inline-grid",placeItems:"center",width:28,height:28,borderRadius:4,background:g&&!h?T.hover:"transparent",color:h?T.disabled:T.text,cursor:h?"default":"pointer",opacity:h?.48:1,boxSizing:"border-box"},onMouseEnter:()=>s(true),onMouseLeave:()=>s(false),children:[jsx(k,{name:t==="text"?"textColor":"fillColor",size:20}),jsx("span",{"aria-hidden":"true",style:{position:"absolute",left:5,right:5,bottom:2,height:3,borderRadius:2,background:r}}),jsx("input",{type:"color",value:r,disabled:h,"aria-label":i,onChange:F=>c?.(F.target.value),style:{position:"absolute",inset:0,width:"100%",height:"100%",opacity:0}})]})}function Ct({value:t,options:r,label:i,onCommit:c,disabled:h=false,width:g=72,inputStyle:s,testId:F}){let[R,z]=useState(t),[O,q]=useState(false),[U,ae]=useState({top:0,left:0,width:g}),x=useRef(null),_=useRef(null),I=useRef(null);useEffect(()=>z(t),[t]);let B=useCallback(()=>q(false),[]);useEffect(()=>{if(!O||!x.current)return;let v=x.current.getBoundingClientRect();ae({top:v.bottom+4,left:v.left,width:Math.max(v.width,g)});},[O,g]),useEffect(()=>{if(!O)return;let v=S=>{let Q=S.target;!x.current?.contains(Q)&&!_.current?.contains(Q)&&B();},Y=S=>{S.key==="Escape"&&(z(t),B());};return document.addEventListener("mousedown",v),document.addEventListener("keydown",Y),()=>{document.removeEventListener("mousedown",v),document.removeEventListener("keydown",Y);}},[O,B,t]);let J=useCallback(()=>{!h&&c&&R.trim()?c(R.trim()):z(t);},[h,c,R,t]);return jsxs("div",{ref:x,style:{display:"inline-flex",alignItems:"center",width:g,height:28,border:`1px solid ${T.border}`,borderRadius:4,background:h?"rgba(255,255,255,0.5)":T.surface,opacity:h?.48:1,boxSizing:"border-box",flex:"0 0 auto"},children:[jsx("input",{ref:I,"data-testid":F,role:"combobox","aria-label":i,"aria-autocomplete":"list","aria-expanded":O,disabled:h,value:R,onFocus:v=>{h||(q(true),v.currentTarget.select());},onChange:v=>z(v.target.value),onKeyDown:v=>{v.key==="Enter"?(J(),B(),v.currentTarget.blur()):v.key==="ArrowDown"&&(q(true),v.preventDefault());},onBlur:()=>{requestAnimationFrame(()=>{_.current?.contains(document.activeElement)||J();});},style:{appearance:"none",width:"calc(100% - 22px)",height:26,padding:"0 2px 0 7px",border:0,outline:0,background:"transparent",color:T.text,font:"500 13px ui-sans-serif, system-ui, sans-serif",boxSizing:"border-box",...s}}),jsx("button",{type:"button",disabled:h,tabIndex:-1,"aria-label":i,title:i,onMouseDown:v=>v.preventDefault(),onClick:()=>{h||(q(v=>!v),I.current?.focus());},style:{appearance:"none",display:"grid",placeItems:"center",width:21,height:26,padding:0,border:0,background:"transparent",color:T.muted,cursor:h?"default":"pointer"},children:jsx(k,{name:"chevronDown",size:14})}),O&&!h&&jsx("div",{ref:_,role:"listbox","aria-label":i,style:{position:"fixed",top:U.top,left:U.left,zIndex:1e4,width:U.width,maxHeight:260,overflowY:"auto",padding:4,border:`1px solid ${T.border}`,borderRadius:6,background:T.surface,boxShadow:"0 4px 16px rgba(60, 64, 67, 0.24)",boxSizing:"border-box"},children:r.map(v=>jsx("button",{type:"button",role:"option","aria-selected":v.value===t,onMouseDown:Y=>Y.preventDefault(),onClick:()=>{z(v.label),c?.(v.value),B();},style:{appearance:"none",display:"block",width:"100%",minHeight:28,padding:"4px 7px",border:0,borderRadius:3,background:v.value===t?T.active:"transparent",color:T.text,cursor:"pointer",font:"400 13px ui-sans-serif, system-ui, sans-serif",textAlign:"left"},children:v.label},v.value))})]})}var Xo=[.5,.75,.9,1,1.25,1.5,2],_o=["Arial","Calibri","Cambria","Georgia","Roboto","Times New Roman","Verdana"],Vo=[8,9,10,11,12,14,16,18,20,24,28,36,48,72],Zo=["automatic","plainText","number","percent","scientific","currency","date","time","custom"],Yo=["all","inner","horizontal","vertical","outer","left","top","right","bottom","none"],jo=["solid","dashed","dotted","double"],qo=["left","center","right"],Jo=["top","middle","bottom"],Qo=["overflow","wrap","clip"];function er(t){let r={};for(let i of Object.keys(t))t[i]!==void 0&&(r[i]=t[i]);return r}function tr(t){let r=useContext(De);return r?{...r,...er(t)}:t}function jt({preset:t}){let r=i=>t===i||t==="all"||t==="outer"?2:.6;return jsxs("svg",{width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",stroke:"currentColor","aria-hidden":"true",children:[t!=="none"&&jsxs(Fragment,{children:[jsx("path",{d:"M3 3h14",strokeWidth:r("top")}),jsx("path",{d:"M17 3v14",strokeWidth:r("right")}),jsx("path",{d:"M3 17h14",strokeWidth:r("bottom")}),jsx("path",{d:"M3 3v14",strokeWidth:r("left")}),(t==="all"||t==="inner"||t==="horizontal")&&jsx("path",{d:"M3 10h14",strokeWidth:"1.5"}),(t==="all"||t==="inner"||t==="vertical")&&jsx("path",{d:"M10 3v14",strokeWidth:"1.5"})]}),t==="none"&&jsx("path",{d:"M4 4h12v12H4zM3 17 17 3",strokeWidth:"1.5"})]})}function qt({value:t}){let r=t==="left"?3:t==="center"?5:7,i=t==="left"?15:t==="center"?17:19;return jsxs("svg",{width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",stroke:"currentColor",strokeWidth:"1.6","aria-hidden":"true",children:[jsx("path",{d:"M3 4h14M3 10h14M3 16h14"}),jsx("path",{d:`M${r} 7h${i-r}M${r} 13h${i-r}`})]})}function Jt({value:t}){return jsxs("svg",{width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",stroke:"currentColor",strokeWidth:"1.6","aria-hidden":"true",children:[jsx("path",{d:"M3 3h14M3 17h14"}),jsx("path",{d:`M6 ${t==="top"?5:t==="middle"?10:15}h8`}),jsx("path",{d:t==="top"?"m8 8 2-3 2 3":t==="bottom"?"m8 12 2 3 2-3":"m8 7 2 3 2-3m-4 6 2-3 2 3"})]})}function or({value:t}){return jsx("svg",{width:"44",height:"12",viewBox:"0 0 44 12",fill:"none",stroke:"currentColor","aria-hidden":"true",children:t==="double"?jsx(Fragment,{children:jsx("path",{d:"M2 4h40M2 8h40"})}):jsx("path",{d:"M2 6h40",strokeWidth:"2",strokeDasharray:t==="dashed"?"7 4":t==="dotted"?"1 4":void 0})})}function Qt(t,r,i){return i>0?r.find(c=>c>t)??t+1:[...r].reverse().find(c=>c<t)??Math.max(1,t-1)}function nt(t){let{t:r}=ye(),{currentFormatting:i={},selectionShape:c,onFormat:h,onMerge:g,onSearchMenus:s,onUndo:F,onRedo:R,canUndo:z=false,canRedo:O=false,onPrint:q,zoom:U=1,onZoomChange:ae,fontFamilies:x=_o,fontSizes:_=Vo,disabled:I=false,className:B,style:J,children:v}=tr(t),Y=useRef(null),[S,Q]=useState(Number.POSITIVE_INFINITY),w=!I&&!!h,E=!I&&!!g,me=i.fontSize??10,Ke=(c?.rows??1)>1,f=(c?.columns??1)>1,G=Ke||f;useEffect(()=>{let b=Y.current;if(!b)return;let d=()=>Q(b.clientWidth);d();let we=new ResizeObserver(d);return we.observe(b),()=>we.disconnect()},[]);let V=useMemo(()=>Xo.map(b=>({value:`${b*100}%`,label:`${b*100}%`})),[]),he=useMemo(()=>_.map(b=>({value:String(b),label:String(b)})),[_]),D=b=>{w&&h?.(b);},Ae=b=>jsx(Fragment,{children:Zo.map(d=>jsx(te,{label:r(`toolbar.numberFormats.${d}`),selected:i.numberFormat===d,disabled:!w,onClick:()=>D({type:"numberFormat",value:d}),close:b},d))}),Ce=b=>jsxs(Fragment,{children:[Yo.map(d=>jsx(te,{icon:jsx(jt,{preset:d}),label:r(`toolbar.borderPresets.${d}`),selected:i.borderPreset===d,disabled:!w,onClick:()=>D({type:"borderPreset",value:d}),close:b},d)),jsx(Oe,{}),jo.map(d=>jsx(te,{icon:jsx(or,{value:d}),label:r(`toolbar.borderStyles.${d}`),selected:i.borderStyle===d,disabled:!w,onClick:()=>D({type:"borderStyle",value:d}),close:b},d)),jsx(Oe,{}),jsxs("label",{style:{position:"relative",display:"flex",alignItems:"center",gap:10,minHeight:32,padding:"5px 9px",color:T.text,font:"400 13px ui-sans-serif, system-ui, sans-serif",cursor:w?"pointer":"default"},children:[jsx("span",{style:{width:20,height:5,borderRadius:2,background:i.borderColor??"#000000"}}),jsx("span",{children:r("toolbar.borderColor")}),jsx("input",{type:"color",value:i.borderColor??"#000000",disabled:!w,"aria-label":r("toolbar.borderColor"),onChange:d=>D({type:"borderColor",value:d.target.value}),style:{position:"absolute",inset:0,width:"100%",height:"100%",opacity:0}})]})]}),Se=b=>jsxs(Fragment,{children:[jsx(te,{label:r("toolbar.merge.all"),disabled:!E||!G,onClick:()=>g?.("all"),close:b}),jsx(te,{label:r("toolbar.merge.horizontal"),disabled:!E||!f,onClick:()=>g?.("horizontal"),close:b}),jsx(te,{label:r("toolbar.merge.vertical"),disabled:!E||!Ke,onClick:()=>g?.("vertical"),close:b}),jsx(Oe,{}),jsx(te,{label:r("toolbar.merge.unmerge"),disabled:!E||!c?.canUnmerge,onClick:()=>g?.("unmerge"),close:b})]}),Xe=b=>jsx(Fragment,{children:qo.map(d=>jsx(te,{icon:jsx(qt,{value:d}),label:r(`toolbar.horizontalAlign.${d}`),selected:i.horizontalAlignment===d,disabled:!w,onClick:()=>D({type:"horizontalAlignment",value:d}),close:b},d))}),st=b=>jsx(Fragment,{children:Jo.map(d=>jsx(te,{icon:jsx(Jt,{value:d}),label:r(`toolbar.verticalAlign.${d}`),selected:i.verticalAlignment===d,disabled:!w,onClick:()=>D({type:"verticalAlignment",value:d}),close:b},d))}),L=b=>jsx(Fragment,{children:Qo.map(d=>jsx(te,{label:r(`toolbar.wrapping.${d}`),selected:i.textWrapping===d,disabled:!w,onClick:()=>D({type:"textWrapping",value:d}),close:b},d))}),ge=[{key:"search",width:29,node:jsx(K,{label:r("toolbar.groups.search"),children:jsx(H,{title:r("toolbar.searchMenus"),onClick:s,testId:"xlsx-search-menus",children:jsx(k,{name:"search"})})})},{key:"history",width:58,node:jsxs(K,{label:r("toolbar.groups.history"),children:[jsx(H,{title:r("toolbar.undo"),disabled:I||!z||!F,onClick:F,testId:"xlsx-undo",children:jsx(k,{name:"undo"})}),jsx(H,{title:r("toolbar.redo"),disabled:I||!O||!R,onClick:R,testId:"xlsx-redo",children:jsx(k,{name:"redo"})})]})},{key:"print",width:29,node:jsx(K,{label:r("toolbar.groups.print"),children:jsx(H,{title:r("toolbar.print"),disabled:I||!q,onClick:q,children:jsx(k,{name:"print"})})})},{key:"paint",width:29,node:jsx(K,{label:r("toolbar.groups.paintFormat"),children:jsx(H,{title:r("toolbar.paintFormat"),active:i.paintFormat,disabled:!w,onClick:()=>D("paintFormat"),children:jsx(k,{name:"formatPaint"})})})},{key:"zoom",width:82,node:jsx(K,{label:r("toolbar.groups.zoom"),children:jsx(Ct,{value:`${Math.round(U*100)}%`,options:V,label:r("toolbar.zoomValue",{value:`${Math.round(U*100)}%`}),disabled:I||!ae,onCommit:b=>{let d=Number.parseFloat(b.replace("%",""));Number.isFinite(d)&&d>=25&&d<=400&&ae?.(d/100);},width:76,testId:"xlsx-zoom"})})},{key:"number",width:202,node:jsxs(Fragment,{children:[jsx($e,{}),jsxs(K,{label:r("toolbar.groups.number"),children:[jsx(H,{title:r("toolbar.currency"),disabled:!w,onClick:()=>D("currency"),children:jsx("span",{style:{fontSize:16},children:r("toolbar.currencySymbol")})}),jsx(H,{title:r("toolbar.percent"),disabled:!w,onClick:()=>D("percent"),children:jsx("span",{style:{fontSize:15},children:"%"})}),jsx(H,{title:r("toolbar.decreaseDecimal"),disabled:!w,onClick:()=>D("decreaseDecimal"),children:jsx(k,{name:"decimalDecrease"})}),jsx(H,{title:r("toolbar.increaseDecimal"),disabled:!w,onClick:()=>D("increaseDecimal"),children:jsx(k,{name:"decimalIncrease"})}),jsx(ce,{title:r("toolbar.moreNumberFormats"),disabled:!w,trigger:jsxs(Fragment,{children:[jsx("span",{children:"123"}),jsx(k,{name:"chevronDown",size:13})]}),children:Ae})]})]})},{key:"font-family",width:137,node:jsxs(Fragment,{children:[jsx($e,{}),jsx(K,{label:r("toolbar.groups.font"),children:jsx(ce,{title:r("toolbar.fontFamily"),disabled:!w,menuWidth:210,style:{width:120,justifyContent:"space-between"},trigger:jsxs(Fragment,{children:[jsx("span",{style:{overflow:"hidden",textOverflow:"ellipsis"},children:i.fontFamily??"Calibri"}),jsx(k,{name:"chevronDown",size:13})]}),children:b=>jsx(Fragment,{children:x.map(d=>jsx(te,{label:d,selected:i.fontFamily===d,disabled:!w,onClick:()=>D({type:"fontFamily",value:d}),close:b},d))})})})]})},{key:"font-size",width:116,node:jsxs(K,{label:r("toolbar.groups.font"),children:[jsx(H,{title:r("toolbar.decreaseFontSize"),disabled:!w,onClick:()=>D({type:"fontSize",value:Qt(me,_,-1)}),children:jsx(k,{name:"remove"})}),jsx(Ct,{value:String(me),options:he,label:r("toolbar.fontSize"),disabled:!w,onCommit:b=>{let d=Number.parseFloat(b);Number.isFinite(d)&&d>=1&&d<=400&&D({type:"fontSize",value:d});},width:50,inputStyle:{textAlign:"center"}}),jsx(H,{title:r("toolbar.increaseFontSize"),disabled:!w,onClick:()=>D({type:"fontSize",value:Qt(me,_,1)}),children:jsx(k,{name:"add"})})]})},{key:"text",width:98,node:jsxs(Fragment,{children:[jsx($e,{}),jsxs(K,{label:r("toolbar.groups.text"),children:[jsx(H,{title:r("toolbar.bold"),active:i.bold,disabled:!w,onClick:()=>D("bold"),children:jsx(k,{name:"bold"})}),jsx(H,{title:r("toolbar.italic"),active:i.italic,disabled:!w,onClick:()=>D("italic"),children:jsx(k,{name:"italic"})}),jsx(H,{title:r("toolbar.strikethrough"),active:i.strikethrough,disabled:!w,onClick:()=>D("strikethrough"),children:jsx(k,{name:"strikethrough"})})]})]})},{key:"colors",width:58,node:jsxs(K,{label:r("toolbar.groups.colors"),children:[jsx(xt,{mode:"text",value:i.textColor??"#000000",label:r("toolbar.textColor"),disabled:!w,onChange:b=>D({type:"textColor",value:b})}),jsx(xt,{mode:"fill",value:i.fillColor??"#ffffff",label:r("toolbar.fillColor"),disabled:!w,onChange:b=>D({type:"fillColor",value:b})})]})},{key:"borders",width:36,node:jsx(K,{label:r("toolbar.groups.borders"),children:jsx(ce,{title:r("toolbar.borders"),disabled:!w,menuWidth:240,trigger:jsxs(Fragment,{children:[jsx(jt,{preset:i.borderPreset??"all"}),jsx(k,{name:"chevronDown",size:12})]}),children:Ce})})},{key:"merge",width:58,node:jsxs(K,{label:r("toolbar.groups.merge"),children:[jsx(H,{title:r("toolbar.merge.all"),disabled:!E||!G,onClick:()=>g?.("all"),style:{borderRadius:"4px 0 0 4px"},testId:"xlsx-merge-all",children:jsx(k,{name:"merge"})}),jsx(ce,{title:r("toolbar.mergeCells"),disabled:!E||!G&&!c?.canUnmerge,menuWidth:220,style:{minWidth:20,width:20,padding:0,borderRadius:"0 4px 4px 0"},trigger:jsx(k,{name:"chevronDown",size:13}),children:Se})]})},{key:"alignment",width:118,node:jsxs(K,{label:r("toolbar.groups.alignment"),children:[jsx(ce,{title:r("toolbar.horizontalAlignment"),disabled:!w,menuWidth:180,trigger:jsxs(Fragment,{children:[jsx(qt,{value:i.horizontalAlignment??"left"}),jsx(k,{name:"chevronDown",size:12})]}),children:Xe}),jsx(ce,{title:r("toolbar.verticalAlignment"),disabled:!w,menuWidth:180,trigger:jsxs(Fragment,{children:[jsx(Jt,{value:i.verticalAlignment??"middle"}),jsx(k,{name:"chevronDown",size:12})]}),children:st}),jsx(ce,{title:r("toolbar.textWrapping"),disabled:!w,menuWidth:180,trigger:jsxs(Fragment,{children:[jsx(k,{name:"wrap"}),jsx(k,{name:"chevronDown",size:12})]}),children:L})]})}];v&&ge.push({key:"custom",width:40,node:v});let Fe=Math.max(0,S-48),ke=0,Te=ge.length;for(let b=0;b<ge.length;b++)if(ke+=ge[b].width,ke>Fe){Te=b;break}let _e=ge.slice(0,Te),ee=ge.slice(Te);return jsxs("div",{ref:Y,className:B,role:"toolbar","aria-label":r("toolbar.actionsLabel"),"data-testid":"xlsx-formatting-toolbar",style:{display:"flex",alignItems:"center",minWidth:0,minHeight:36,margin:"0 8px 5px",padding:"4px 7px",borderRadius:18,background:T.rail,color:T.text,overflow:"hidden",boxSizing:"border-box",...J},children:[_e.map(b=>jsx("span",{style:{display:"contents"},children:b.node},b.key)),jsx("span",{style:{marginLeft:"auto",flex:"0 0 auto"},children:jsx(ce,{title:r("toolbar.more"),disabled:ee.length===0,menuWidth:390,testId:"xlsx-toolbar-more",trigger:jsx(k,{name:"more"}),children:()=>jsx("div",{style:{display:"flex",alignItems:"center",flexWrap:"wrap",gap:2},children:ee.map(b=>jsx("span",{style:{display:"contents"},children:b.node},b.key))})})})]})}function rr({children:t,className:r,style:i,...c}){return jsx(De.Provider,{value:c,children:jsx("div",{className:r,"data-testid":"xlsx-editor-toolbar",style:{display:"flex",flexDirection:"column",flex:"0 0 auto",...i},children:t})})}var Ge=rr;Ge.Toolbar=nt;var to=["#7c3aed","#0891b2","#c2410c","#4d7c0f","#be185d","#1d4ed8"];function nr(t){let r=2166136261;for(let i=0;i<t.length;i++)r^=t.charCodeAt(i),r=Math.imul(r,16777619);return (r>>>0)%to.length}function oo(t){return to[nr(t)]}function ro({proposals:t,staleFor:r,onAccept:i,onReject:c,style:h}){let{t:g}=ye();return jsx("div",{"data-testid":"xlsx-proposals-panel",role:"region","aria-label":g("proposals.panelLabel"),style:{position:"absolute",top:"100%",right:0,marginTop:4,width:320,maxHeight:420,overflowY:"auto",background:"#ffffff",border:"1px solid #d0d0d0",borderRadius:10,boxShadow:"0 6px 24px rgba(0, 0, 0, 0.16)",padding:8,zIndex:10,font:"13px system-ui, sans-serif",textAlign:"left",...h},children:t.length===0?jsx("div",{style:{padding:12,color:"#707070",textAlign:"center"},children:g("proposals.empty")}):t.map(s=>{let F=oo(s.agentId),R=r[s.id];return jsxs("div",{"data-testid":"xlsx-proposal","data-proposal-id":s.id,style:{borderLeft:`3px solid ${F}`,padding:"8px 10px",marginBottom:8,background:"#fafafa",borderRadius:4},children:[jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"baseline"},children:[jsx("strong",{style:{color:F},children:s.agentId}),jsx("span",{style:{color:"#707070",fontSize:12},children:g("proposals.cellCount",{count:s.cells.length})})]}),s.note&&jsx("div",{style:{color:"#404040",margin:"4px 0"},children:s.note}),jsx("ul",{style:{listStyle:"none",margin:"6px 0",padding:0},children:s.cells.map(z=>jsxs("li",{"data-testid":"xlsx-proposal-cell",style:{fontVariantNumeric:"tabular-nums",lineHeight:1.5},children:[jsx("strong",{"data-testid":"xlsx-proposal-cell-a1",children:z.a1}),":"," ",jsx("span",{style:{color:"#909090"},children:z.oldText||"\u2205"})," ",g("proposals.changeArrow")," ",jsx("span",{"data-testid":"xlsx-proposal-cell-new",style:{color:F},children:z.newText})]},z.a1))}),R&&R.length>0&&jsx("div",{"data-testid":"xlsx-proposal-stale",role:"alert",style:{color:"#b45309",background:"#fef3c7",borderRadius:4,padding:"4px 6px",margin:"4px 0",fontSize:12},children:g("proposals.staleWarning",{cells:R.join(", ")})}),jsxs("div",{style:{display:"flex",gap:6,marginTop:4},children:[jsx("button",{"data-testid":"xlsx-proposal-accept",onClick:()=>i(s.id),style:{padding:"3px 10px",cursor:"pointer"},children:g("proposals.accept")}),R&&R.length>0&&jsx("button",{"data-testid":"xlsx-proposal-force",onClick:()=>i(s.id,true),style:{padding:"3px 10px",cursor:"pointer",color:"#b45309"},children:g("proposals.forceApply")}),jsx("button",{"data-testid":"xlsx-proposal-reject",onClick:()=>c(s.id),style:{padding:"3px 10px",cursor:"pointer"},children:g("proposals.reject")})]})]},s.id)})})}var xe=96,ve=24,it="#217346",co=87,gr="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";function yr(t,r,i){let c=[{op:"fillRect",x:0,y:0,w:t,h:r,color:"#ffffff"}],h=Math.ceil(t/xe),g=Math.ceil(r/ve);for(let s=0;s<=h;s++)c.push({op:"line",x1:s*xe,y1:0,x2:s*xe,y2:r,width:1,color:"#e0e0e0"});for(let s=0;s<=g;s++)c.push({op:"line",x1:0,y1:s*ve,x2:t,y2:s*ve,width:1,color:"#e0e0e0"});return c.push({op:"fillRect",x:0,y:0,w:t,h:ve,color:"#f3f3f3"}),c.push({op:"fillRect",x:0,y:0,w:xe,h:r,color:"#f3f3f3"}),c.push({op:"text",x:xe+8,y:ve+18,text:i,fontSize:14,color:"#202020",clip:{x:xe,y:ve,w:xe*3,h:ve},align:"left"}),{width:t,height:r,commands:c}}function io(t,r){if(!t||t.length<2)return r;let i=[];for(let h=1;h<t.length;h++)i.push(t[h]-t[h-1]);i.sort((h,g)=>h-g);let c=i[i.length>>1];return c>0?c:r}function xr(t,r,i){let c=io(t?.grid?.rowOffsets,ve),h=io(t?.grid?.colOffsets,xe),g=Math.max(1,Math.round(r.contentHeight/c))+1,s=Math.max(1,Math.round(r.contentWidth/h))+1,F=Math.max(1,Math.floor(i/c));return {rows:g,cols:s,rowsPerPage:F}}function so(t,r,i){let c=new Blob([new Uint8Array(t)],{type:i}),h=URL.createObjectURL(c),g=document.createElement("a");g.href=h,g.download=r,document.body.appendChild(g),g.click(),g.remove(),URL.revokeObjectURL(h);}function vr(t){return `${(t??"workbook.xlsx").replace(/\.xlsx$/i,"")}.png`}function Tt(t,r){return {x:t.x*r,y:t.y*r,w:t.w*r,h:t.h*r}}var Sr={position:"absolute",width:1,height:1,margin:-1,padding:0,border:0,overflow:"hidden",clip:"rect(0 0 0 0)",whiteSpace:"nowrap"},fe={shell:{flex:"0 0 auto",minHeight:co,padding:"4px 0 5px",borderBottom:"1px solid #e2e8f0",background:"#ffffff",color:"#0f172a",boxSizing:"border-box"},rail:{display:"flex",alignItems:"center",minHeight:32,margin:"0 8px",padding:"2px 8px",borderRadius:4,background:"#ffffff",boxSizing:"border-box",overflowX:"auto",overflowY:"hidden"},group:{display:"inline-flex",alignItems:"center",gap:1,padding:"0 6px",borderRight:"1px solid rgba(226, 232, 240, 0.9)",flex:"0 0 auto"},formulaGroup:{display:"flex",alignItems:"center",gap:4,flex:"1 1 320px",minWidth:240,padding:"0 6px",borderRight:"1px solid rgba(226, 232, 240, 0.9)"},nameBox:{appearance:"none",width:64,height:28,flex:"0 0 auto",boxSizing:"border-box",border:"1px solid #e2e8f0",borderRadius:6,background:"#f8fafc",color:"#0f172a",font:"600 12px ui-monospace, SFMono-Regular, Menlo, monospace",textAlign:"center",outlineColor:"#2563eb"},formulaMark:{display:"grid",placeItems:"center",width:20,height:28,flex:"0 0 auto",color:"#64748b",font:"italic 700 12px Georgia, serif",userSelect:"none"},formulaInput:{appearance:"none",flex:"1 1 260px",minWidth:140,height:28,boxSizing:"border-box",border:"1px solid #e2e8f0",borderRadius:6,padding:"0 8px",background:"#ffffff",color:"#0f172a",font:"13px ui-sans-serif, system-ui, sans-serif",outlineColor:"#2563eb"},proposals:{marginLeft:"auto",paddingLeft:6,flex:"0 0 auto"},count:{display:"inline-grid",placeItems:"center",minWidth:15,height:15,marginLeft:-3,padding:"0 4px",borderRadius:8,background:"#0f172a",color:"#ffffff",fontSize:10,fontWeight:700,lineHeight:1,boxSizing:"border-box"}};function wr({i18n:t,...r}){return jsx(rt,{i18n:t,children:jsx(Cr,{...r})})}function Cr({file:t,fileName:r,onSave:i,collaboration:c,onReady:h,className:g}){let{t:s}=ye(),F=c!==void 0,R=c?.clientId,z=c?.initialUpdate,O=c?.onReplica,q=useRef(null),U=useRef(null),ae=useRef(null),x=useRef(null),_=useRef(null),I=useRef(null),B=useRef(null),J=useRef(false),v=useRef(false),Y=useRef(h);Y.current=h;let[S,Q]=useState(null),[w,E]=useState(null),[me,Ke]=useState(null),[f,G]=useState(null),[V,he]=useState(null),[D,Ae]=useState(null),[Ce,Se]=useState(null),[Xe,st]=useState(co),[L,ge]=useState(1),[Fe,ke]=useState(0),[Te,_e]=useState(false),[ee,b]=useState({}),[d,we]=useState({canUndo:false,canRedo:false}),[ct,Ve]=useState([]),[dt,Mt]=useState(),[pt,Et]=useState(),[Me,ze]=useState(null),Ee=useRef(null),[Ze,Ye]=useState([]),[ut,Rt]=useState(false),[bt,Pt]=useState(null),[po,Ie]=useState({}),p=S?.activeSheet??0,uo=useMemo(()=>isPngExportAvailable(),[]),Lt=useMemo(()=>isProposalsAvailable(),[]);useEffect(()=>{let e=q.current;if(!e)return;let o=()=>st(e.offsetHeight);o();let n=new ResizeObserver(o);return n.observe(e),()=>n.disconnect()},[]);let ie=useCallback(()=>{let e=x.current;if(!e){Ye([]);return}try{Ye(e.listProposals());}catch{Ye([]);}ke(o=>o+1);},[]);useEffect(()=>{if(he(null),Se(null),Ye([]),Ie({}),Rt(false),Pt(null),b({}),we({canUndo:false,canRedo:false}),Ve([]),Mt(void 0),Et(void 0),ze(null),Ee.current=null,!t){x.current=null,Q(null),G(null),E(null);return}x.current=null,Q(null),G(null);let e=null,o=()=>{},n=()=>{},a=false,u=()=>{let C=n;n=()=>{};try{C();}catch{}};return initWasm().then(()=>{if(!a)try{e=openWorkbook(t,{collaborative:F,clientId:R}),z&&e.applyUpdate(z.slice()),x.current=e,o=e.onUpdate(()=>{if(!(a||!e))try{Q(e.sheetInfo()),ke(y=>y+1),Ie({}),ie(),E(null);}catch(y){E(y instanceof Error?y.message:String(y));}}),Q(e.sheetInfo()),G(selectionAt({row:0,col:0})),Pt(e),E(null),ie();let C=Y.current?.({handle:e,refreshProposals:ie});typeof C=="function"&&(n=C);}catch(C){u(),o(),o=()=>{},e?.dispose(),e=null,x.current=null,Q(null),G(null),E(C instanceof Error?C.message:String(C));}},C=>{a||(x.current=null,Q(null),G(null),E(C instanceof Error?C.message:String(C)));}),()=>{a=true,u(),o(),e?.dispose(),x.current=null;}},[t,F,R,z,ie]),useEffect(()=>{if(!(!O||!bt))return O(bt),()=>O(null)},[O,bt]);let ft=useCallback(()=>{let e=U.current,o=ae.current;if(!e||!o)return;let n=o.getContext("2d");if(!n)return;let a=window.devicePixelRatio||1,u=e.clientWidth,C=e.clientHeight;if(u===0||C===0)return;o.width=Math.round(u*a),o.height=Math.round(C*a),o.style.width=`${u}px`,o.style.height=`${C}px`;let y=u/L,ne=C/L,Le=x.current,pe;if(Le)try{pe=Le.displayList({x:e.scrollLeft/L,y:e.scrollTop/L,width:y,height:ne});}catch{return}else pe=yr(y,ne,s("editor.demoCellText"));paintDisplayList(n,pe,a*L),_.current=pe,Ke(pe);},[s,L]);useEffect(()=>{let e=U.current;if(!e)return;let o=()=>{I.current==null&&(I.current=requestAnimationFrame(()=>{I.current=null,ft();}));};ft(),e.addEventListener("scroll",o,{passive:true});let n=new ResizeObserver(o);return n.observe(e),()=>{e.removeEventListener("scroll",o),n.disconnect(),I.current!=null&&(cancelAnimationFrame(I.current),I.current=null);}},[ft,S,w,Fe]),useEffect(()=>{let e=x.current;if(!e||!f||!S){Ae(null);return}try{Ae(e.cell(p,f.focus.row,f.focus.col));}catch{Ae(null);}},[f,S,p,Fe]),useEffect(()=>{let e=()=>{J.current=false,_e(false);};return window.addEventListener("mouseup",e),()=>window.removeEventListener("mouseup",e)},[]),useEffect(()=>{let e=x.current;if(!e||!f||!S){b({}),we({canUndo:false,canRedo:false}),Ve([]);return}let o=normalizeRange(f);try{let n=e.cell(p,o.top,o.left).a1,a=e.cell(p,o.bottom,o.right).a1,u=`${n}:${a}`;b(e.selectionFormatting(p,u)),we(e.historyState()),Ve(e.mergedRanges(p,u));}catch{b({}),we({canUndo:false,canRedo:false}),Ve([]);}},[f,S,p,Fe]);let je=useMemo(()=>!me||!S?null:buildA11yGrid(me,f,S.sheetNames[p]??"",{gridLabel:s("a11y.gridLabel"),rowHeaderLabel:s("a11y.rowHeaderLabel"),columnHeaderLabel:s("a11y.columnHeaderLabel"),cellLabel:s("a11y.cellLabel"),cellLabelSelected:s("a11y.cellLabelSelected"),emptyCellLabel:s("a11y.emptyCellLabel"),emptyCellLabelSelected:s("a11y.emptyCellLabelSelected")}),[me,f,S,p,s]),X=useCallback(()=>{U.current?.focus({preventScroll:true});},[]);useEffect(()=>{V&&B.current?.focus({preventScroll:true});},[V]);let N=useCallback(e=>{Q(e.sheetInfo),ke(o=>o+1),ie();},[ie]),qe=useCallback(e=>{let o=x.current;if(!o)return null;let n=normalizeRange(e),a=o.cell(p,n.top,n.left).a1,u=o.cell(p,n.bottom,n.right).a1;return `${a}:${u}`},[p]),se=useCallback(()=>xr(_.current,S,(U.current?.clientHeight??0)/L),[S,L]),Je=useCallback((e,o)=>{let n=ae.current,a=_.current?.grid;if(!n||!a)return null;let u=n.getBoundingClientRect();return cellAtPoint(a,(e-u.left)/L,(o-u.top)/L)},[L]),Qe=useCallback(e=>{let o=x.current;if(!o||!f)return;let{row:n,col:a}=f.focus,u=e??"";if(e===void 0)try{u=o.cell(p,n,a).input;}catch{u="";}he({row:n,col:a,value:u});},[f,p]),mt=useCallback(e=>{let o=x.current;if(!o||!V)return;v.current=true;let{row:n,col:a,value:u}=V;try{N(o.editCell(p,n,a,u));}catch(y){E(y instanceof Error?y.message:String(y));}he(null);let C=selectionAt({row:n,col:a});G(e?moveFocus(C,e,{limits:se()}):C),X();},[V,p,N,se,X]),bo=useCallback(()=>{v.current=true,he(null),X();},[X]),et=useCallback(()=>{let e=x.current;if(!e||!f)return;let o=normalizeRange(f),n=[];for(let a=o.top;a<=o.bottom;a++)for(let u=o.left;u<=o.right;u++)n.push({row:a,col:u,input:""});try{N(e.editCells(p,n));}catch(a){E(a instanceof Error?a.message:String(a));}},[f,p,N]),tt=useCallback(async()=>{let e=x.current;if(!e||!f)return;let o=normalizeRange(f);try{let n=e.cell(p,o.top,o.left).a1,a=e.cell(p,o.bottom,o.right).a1,u=e.rangeCells(p,`${n}:${a}`),C=toTsv(u.map(y=>y.map(ne=>({input:ne.input,isFormula:ne.isFormula}))));await navigator.clipboard.writeText(C);}catch{}},[f,p]),Dt=useCallback(async()=>{await tt(),et();},[tt,et]),At=useCallback(async()=>{let e=x.current;if(!e||!f)return;let o;try{o=await navigator.clipboard.readText();}catch{return}let n=fromTsv(o);if(n.length===0)return;let a=normalizeRange(f),u=[],C=1;n.forEach((y,ne)=>{C=Math.max(C,y.length),y.forEach((Le,pe)=>u.push({row:a.top+ne,col:a.left+pe,input:Le}));});try{N(e.editCells(p,u));}catch(y){E(y instanceof Error?y.message:String(y));return}G({anchor:{row:a.top,col:a.left},focus:{row:a.top+n.length-1,col:a.left+C-1}});},[f,p,N]),fo=useCallback(e=>{let o=x.current;if(!o||!f)return;let n=qe(f);if(n){if(e==="paintFormat"){if(Me){ze(null),Ee.current=null;return}try{ze(o.captureFormat(p,n));let a=normalizeRange(f);Ee.current=`${p}:${a.top}:${a.left}:${a.bottom}:${a.right}`;}catch(a){E(a instanceof Error?a.message:String(a));}return}try{let a;e==="currency"?a=o.setNumberFormat(p,n,"currency"):e==="percent"?a=o.setNumberFormat(p,n,"percent"):e==="increaseDecimal"?a=o.setNumberFormat(p,n,"increaseDecimal"):e==="decreaseDecimal"?a=o.setNumberFormat(p,n,"decreaseDecimal"):e==="bold"?a=o.patchRangeStyle(p,n,{bold:!ee.bold}):e==="italic"?a=o.patchRangeStyle(p,n,{italic:!ee.italic}):e==="strikethrough"?a=o.patchRangeStyle(p,n,{strikethrough:!ee.strikethrough}):e.type==="numberFormat"?a=e.value==="custom"?o.setNumberFormat(p,n,{type:"custom",pattern:ee.numberFormatPattern??"0.00"}):o.setNumberFormat(p,n,e.value):e.type==="fontFamily"?a=o.patchRangeStyle(p,n,{fontFamily:e.value}):e.type==="fontSize"?a=o.patchRangeStyle(p,n,{fontSize:e.value}):e.type==="textColor"?a=o.patchRangeStyle(p,n,{textColor:e.value}):e.type==="fillColor"?a=o.patchRangeStyle(p,n,{fillColor:e.value}):e.type==="borderPreset"?a=o.patchRangeStyle(p,n,{border:{preset:e.value,style:dt??ee.borderStyle??"solid",color:pt??ee.borderColor??"#000000"}}):e.type==="borderStyle"?(Mt(e.value),a=o.patchRangeStyle(p,n,{border:{style:e.value}})):e.type==="borderColor"?(Et(e.value),a=o.patchRangeStyle(p,n,{border:{color:e.value}})):e.type==="horizontalAlignment"?a=o.patchRangeStyle(p,n,{horizontalAlignment:e.value}):e.type==="verticalAlignment"?a=o.patchRangeStyle(p,n,{verticalAlignment:e.value}):a=o.patchRangeStyle(p,n,{textWrapping:e.value}),N(a),X();}catch(a){E(a instanceof Error?a.message:String(a));}}},[f,qe,Me,p,ee,dt,pt,N,X]);useEffect(()=>{let e=x.current;if(!e||!f||!Me||Te)return;let o=normalizeRange(f);if(`${p}:${o.top}:${o.left}:${o.bottom}:${o.right}`===Ee.current)return;let a=qe(f);if(a)try{N(e.applyFormat(p,a,Me)),ze(null),Ee.current=null,X();}catch(u){E(u instanceof Error?u.message:String(u));}},[f,Me,Te,p,qe,N,X]);let ht=useCallback(()=>{let e=x.current;if(e)try{N(e.undo());}catch(o){E(o instanceof Error?o.message:String(o));}},[N]),ot=useCallback(()=>{let e=x.current;if(e)try{N(e.redo());}catch(o){E(o instanceof Error?o.message:String(o));}},[N]),mo=useCallback(()=>window.print(),[]),ho=useCallback(()=>{},[]),go=useCallback(e=>{let o=x.current;if(!o||!f)return;let n=normalizeRange(f),a=(y,ne)=>({row:y,col:ne}),u=(y,ne,Le,pe)=>({start:a(y,ne),end:a(Le,pe)}),C=[];if(e==="all")C.push({type:"mergeCells",sheet:p,range:u(n.top,n.left,n.bottom,n.right)});else if(e==="horizontal")for(let y=n.top;y<=n.bottom;y++)C.push({type:"mergeCells",sheet:p,range:u(y,n.left,y,n.right)});else if(e==="vertical")for(let y=n.left;y<=n.right;y++)C.push({type:"mergeCells",sheet:p,range:u(n.top,y,n.bottom,y)});else for(let y of ct)C.push({type:"unmergeCells",sheet:p,range:u(y.start.row,y.start.col,y.end.row,y.end.col)});if(C.length!==0)try{N(o.applyOps(C)),X();}catch(y){E(y instanceof Error?y.message:String(y));}},[f,p,ct,N,X]),yo=useCallback((e,o)=>{let n=x.current;if(n)try{N(n.acceptProposal(e,{force:o})),Ie(({[e]:a,...u})=>u),ie(),X();}catch(a){a instanceof StaleProposalError?Ie(u=>({...u,[e]:a.cells})):E(a instanceof Error?a.message:String(a));}},[N,ie,X]),xo=useCallback(e=>{let o=x.current;if(o)try{o.rejectProposal(e),Ie(({[e]:n,...a})=>a),ie();}catch(n){E(n instanceof Error?n.message:String(n));}},[ie]),gt=useCallback(()=>{let e=x.current;if(e)try{let o=e.save();i?i(o):so(o,r??"workbook.xlsx",gr);}catch(o){E(o instanceof Error?o.message:String(o));}},[i,r]),vo=useCallback(()=>{let e=x.current,o=U.current;if(!(!e||!o))try{let n=e.renderPng({x:o.scrollLeft/L,y:o.scrollTop/L,width:o.clientWidth/L,height:o.clientHeight/L});so(n,vr(r),"image/png");}catch(n){E(n instanceof Error?n.message:String(n));}},[r,L]),Ft=useCallback(e=>{let o=x.current;if(!o||!f||Ce==null)return;let{row:n,col:a}=f.focus;try{N(o.editCell(p,n,a,Ce));}catch(u){E(u instanceof Error?u.message:String(u));}Se(null),e&&G(u=>u&&moveFocus(u,e,{limits:se()}));},[f,Ce,p,N,se]),So=useCallback(e=>{if(!x.current||!f||!S||V)return;let n=e.metaKey||e.ctrlKey,a=e.key.toLowerCase();if(n){if(a==="c"){tt(),e.preventDefault();return}if(a==="v"){At(),e.preventDefault();return}if(a==="x"){Dt(),e.preventDefault();return}if(a==="z"){e.shiftKey?ot():ht(),e.preventDefault();return}if(a==="y"){ot(),e.preventDefault();return}if(a==="s"){gt(),e.preventDefault();return}}let u=selectionKeyReducer(f,{key:e.key,shiftKey:e.shiftKey,metaKey:e.metaKey,ctrlKey:e.ctrlKey,altKey:e.altKey},se());switch(u.type){case "move":G(u.selection),e.preventDefault();break;case "startEdit":Qe(u.initialInput),e.preventDefault();break;case "clear":et(),e.preventDefault();break;}},[f,S,V,se,tt,At,Dt,ht,ot,gt,Qe,et]),wo=useCallback(e=>{if(!f)return;let o=Je(e.clientX,e.clientY);o&&(e.shiftKey?G(n=>n&&extendTo(n,o,se())):G(selectionAt(o)),J.current=true,_e(true),X());},[f,Je,se,X]),Co=useCallback(e=>{if(!J.current)return;let o=Je(e.clientX,e.clientY);o&&G(n=>n&&extendTo(n,o,se()));},[Je,se]),ko=useCallback(()=>{f&&Qe();},[f,Qe]),Re=me?.grid,zt=Re&&f?rangeRect(Re,normalizeRange(f)):null,It=Re&&f?cellRect(Re,f.focus.row,f.focus.col):null,Bt=Re&&V?cellRect(Re,V.row,V.col):null,Be=zt?Tt(zt,L):null,He=It?Tt(It,L):null,We=Bt?Tt(Bt,L):null,To=S?S.contentWidth*L:void 0,Mo=S?S.contentHeight*L:void 0,Eo=Ce??D?.input??"",Pe=f?normalizeRange(f):null,Ro=Pe?Pe.bottom-Pe.top+1:1,Po=Pe?Pe.right-Pe.left+1:1,Lo=e=>{let o=x.current;if(o)try{o.setActiveSheet(e);let n=U.current;n&&(n.scrollLeft=0,n.scrollTop=0),G(selectionAt({row:0,col:0})),he(null),Se(null),ze(null),Ee.current=null,Q(o.sheetInfo());}catch(n){E(n instanceof Error?n.message:String(n));}};return jsxs("div",{className:g,role:"application","aria-label":s("editor.appLabel"),style:{position:"relative",display:"flex",flexDirection:"column",width:"100%",height:"100%",minWidth:0,color:"#202124",background:"#ffffff",fontFamily:"ui-sans-serif, system-ui, sans-serif"},children:[jsx("div",{ref:q,"data-testid":"xlsx-toolbar",style:fe.shell,children:jsxs(Ge,{currentFormatting:{...ee,borderStyle:dt??ee.borderStyle,borderColor:pt??ee.borderColor,paintFormat:Me!==null},selectionShape:{rows:Ro,columns:Po,canUnmerge:ct.length>0},onSearchMenus:ho,onUndo:ht,onRedo:ot,canUndo:d.canUndo,canRedo:d.canRedo,onPrint:mo,zoom:L,onZoomChange:ge,onFormat:fo,onMerge:go,children:[jsx(Ge.Toolbar,{}),jsxs("div",{style:fe.rail,role:"group","aria-label":s("toolbar.formulaBarLabel"),children:[jsxs(K,{style:{...fe.group,paddingLeft:0},label:s("toolbar.fileActionsLabel"),children:[jsx(H,{testId:"xlsx-save",onClick:gt,disabled:!S,title:s("toolbar.save"),children:jsx(k,{name:"save",size:18})}),jsx(H,{testId:"xlsx-export-png",onClick:vo,disabled:!S||!uo,title:s("toolbar.exportPng"),children:jsx(k,{name:"image",size:18})})]}),jsxs("div",{style:fe.formulaGroup,role:"group","aria-label":s("toolbar.formulaBarLabel"),children:[jsx("input",{"data-testid":"xlsx-name-box",readOnly:true,value:D?.a1??"",placeholder:s("toolbar.nameBoxPlaceholder"),"aria-label":s("toolbar.nameBoxPlaceholder"),style:fe.nameBox}),jsx("span",{style:fe.formulaMark,"aria-hidden":"true",children:"fx"}),jsx("input",{"data-testid":"xlsx-formula-input",value:Eo,placeholder:s("toolbar.formulaPlaceholder"),"aria-label":s("toolbar.formulaPlaceholder"),disabled:!S,onChange:e=>Se(e.target.value),onKeyDown:e=>{e.key==="Enter"?(Ft(e.shiftKey?"up":"down"),X(),e.preventDefault()):e.key==="Escape"&&(Se(null),X(),e.preventDefault());},onBlur:()=>Ft(),style:fe.formulaInput})]}),Lt&&jsx("div",{style:fe.proposals,children:jsxs(H,{testId:"xlsx-proposals-button",onClick:()=>Rt(e=>!e),disabled:!S,active:ut,ariaExpanded:ut,title:s("proposals.panelLabel"),style:{width:Ze.length>0?42:28},children:[jsx(k,{name:"proposals",size:18}),Ze.length>0&&jsx("span",{"data-testid":"xlsx-proposals-count",style:fe.count,children:Ze.length})]})})]})]})}),Lt&&ut&&jsx(ro,{proposals:Ze,staleFor:po,onAccept:yo,onReject:xo,style:{top:Xe+4,right:8,width:"min(320px, calc(100% - 16px))",maxHeight:`min(420px, calc(100% - ${Xe+12}px))`}}),jsxs("div",{ref:U,"data-testid":"xlsx-scroll",tabIndex:0,onKeyDown:So,onMouseDown:wo,onMouseMove:Co,onDoubleClick:ko,style:{position:"relative",flex:1,overflow:"auto",minHeight:0,outline:"none"},children:[jsx("div",{style:{position:"absolute",top:0,left:0,width:To??"100%",height:Mo??"100%"}}),jsxs("div",{style:{position:"sticky",top:0,left:0,width:0,height:0},children:[jsx("canvas",{ref:ae,style:{display:"block",position:"absolute",top:0,left:0}}),jsxs("div",{"data-testid":"xlsx-overlay-host",style:{position:"absolute",top:0,left:0,width:0,height:0,pointerEvents:"none"},children:[Be&&jsx("div",{"data-testid":"xlsx-selection",style:{position:"absolute",left:Be.x,top:Be.y,width:Be.w,height:Be.h,boxSizing:"border-box",border:`1px solid ${it}`,background:"rgba(33, 115, 70, 0.12)"}}),He&&!V&&jsx("div",{style:{position:"absolute",left:He.x,top:He.y,width:He.w,height:He.h,boxSizing:"border-box",border:`2px solid ${it}`}}),V&&We&&jsx("input",{ref:B,"data-testid":"xlsx-cell-editor",value:V.value,onChange:e=>he(o=>o&&{...o,value:e.target.value}),onKeyDown:e=>{e.stopPropagation(),e.key==="Enter"?(mt(e.shiftKey?"up":"down"),e.preventDefault()):e.key==="Tab"?(mt(e.shiftKey?"left":"right"),e.preventDefault()):e.key==="Escape"&&(bo(),e.preventDefault());},onBlur:()=>{if(v.current){v.current=false;return}mt();},style:{position:"absolute",left:We.x,top:We.y,width:We.w,height:We.h,boxSizing:"border-box",border:`2px solid ${it}`,padding:"0 3px",font:`${13*L}px system-ui, sans-serif`,background:"#ffffff",pointerEvents:"auto",outline:"none"}})]})]})]}),je&&jsxs("div",{style:Sr,role:"grid","aria-label":je.label,children:[jsxs("div",{role:"row",children:[jsx("span",{role:"columnheader"}),je.columnHeaders.map(e=>jsx("span",{role:"columnheader",children:e.label},e.col))]}),je.rows.map(e=>jsxs("div",{role:"row",children:[jsx("span",{role:"rowheader",children:e.header}),e.cells.map(o=>jsx("span",{role:"gridcell","aria-selected":o.selected,children:o.label},o.col))]},e.row))]}),w&&jsxs("div",{"data-testid":"xlsx-error",role:"alert",style:{position:"absolute",inset:0,display:"grid",placeItems:"center",padding:16,textAlign:"center",color:"#b00020"},children:[s("editor.openError"),": ",w]}),S&&S.sheetNames.length>0&&jsx("div",{"data-testid":"xlsx-sheet-tabs",role:"tablist","aria-label":s("editor.sheetTabsLabel"),style:{display:"flex",gap:2,padding:"4px 6px",borderTop:"1px solid #e0e0e0",background:"#fafafa",overflowX:"auto"},children:S.sheetNames.map((e,o)=>{let n=o===S.activeSheet;return jsx("button",{role:"tab","aria-selected":n,onClick:()=>Lo(o),style:{border:"none",padding:"4px 12px",cursor:"pointer",borderBottom:n?`2px solid ${it}`:"2px solid transparent",fontWeight:n?600:400,background:n?"#ffffff":"transparent"},children:e},o)})})]})}export{Ge as EditorToolbar,De as EditorToolbarContext,rt as LocaleProvider,nt as Toolbar,H as ToolbarButton,ce as ToolbarDropdown,K as ToolbarGroup,te as ToolbarMenuItem,Oe as ToolbarMenuSeparator,$e as ToolbarSeparator,wr as XlsxEditor,nt as XlsxToolbar,Io as useEditorToolbar,ye as useTranslation};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@betteroffice/xlsx-react",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.7",
|
|
4
4
|
"description": "Excel-faithful React XLSX spreadsheet editor and viewer — full OOXML fidelity, real-time human + AI agent collaboration.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"xlsx",
|
|
@@ -33,8 +33,8 @@
|
|
|
33
33
|
"typecheck": "tsc --noEmit -p ."
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"@betteroffice/xlsx": "0.0.
|
|
37
|
-
"@betteroffice/xlsx-i18n": "0.0.
|
|
36
|
+
"@betteroffice/xlsx": "0.0.7",
|
|
37
|
+
"@betteroffice/xlsx-i18n": "0.0.7"
|
|
38
38
|
},
|
|
39
39
|
"peerDependencies": {
|
|
40
40
|
"react": "^18.0.0 || ^19.0.0",
|