@nuptechs/nup-xlsx-preview 1.0.0 → 1.0.3
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/adapters/react.d.cts +41 -1
- package/dist/adapters/react.d.ts +41 -1
- package/dist/adapters/vanilla.d.cts +41 -1
- package/dist/adapters/vanilla.d.ts +41 -1
- package/dist/adapters/vue.cjs +4 -4
- package/dist/adapters/vue.cjs.map +1 -1
- package/dist/adapters/vue.d.cts +52 -1
- package/dist/adapters/vue.d.ts +52 -1
- package/dist/adapters/vue.js +4 -4
- package/dist/adapters/vue.js.map +1 -1
- package/dist/index.cjs +28 -28
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +82 -2
- package/dist/index.d.ts +82 -2
- package/dist/index.js +28 -28
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -5,11 +5,51 @@ import { CSSProperties } from 'react';
|
|
|
5
5
|
* @aspect/nup-xlsx-preview - Types
|
|
6
6
|
* Ultra-light Excel visualization component
|
|
7
7
|
*/
|
|
8
|
+
interface NupCellFont {
|
|
9
|
+
name?: string;
|
|
10
|
+
size?: number;
|
|
11
|
+
bold?: boolean;
|
|
12
|
+
italic?: boolean;
|
|
13
|
+
underline?: boolean;
|
|
14
|
+
strike?: boolean;
|
|
15
|
+
color?: string;
|
|
16
|
+
}
|
|
17
|
+
interface NupCellFill {
|
|
18
|
+
type?: 'solid' | 'pattern' | 'gradient';
|
|
19
|
+
color?: string;
|
|
20
|
+
patternColor?: string;
|
|
21
|
+
tint?: number;
|
|
22
|
+
}
|
|
23
|
+
interface NupCellBorder {
|
|
24
|
+
style?: 'thin' | 'medium' | 'thick' | 'dashed' | 'dotted' | 'double';
|
|
25
|
+
color?: string;
|
|
26
|
+
}
|
|
27
|
+
interface NupCellBorders {
|
|
28
|
+
top?: NupCellBorder;
|
|
29
|
+
right?: NupCellBorder;
|
|
30
|
+
bottom?: NupCellBorder;
|
|
31
|
+
left?: NupCellBorder;
|
|
32
|
+
}
|
|
33
|
+
interface NupCellAlignment {
|
|
34
|
+
horizontal?: 'left' | 'center' | 'right' | 'justify';
|
|
35
|
+
vertical?: 'top' | 'middle' | 'bottom';
|
|
36
|
+
wrapText?: boolean;
|
|
37
|
+
indent?: number;
|
|
38
|
+
rotation?: number;
|
|
39
|
+
}
|
|
40
|
+
interface NupCellStyle {
|
|
41
|
+
font?: NupCellFont;
|
|
42
|
+
fill?: NupCellFill;
|
|
43
|
+
border?: NupCellBorders;
|
|
44
|
+
alignment?: NupCellAlignment;
|
|
45
|
+
numberFormat?: string;
|
|
46
|
+
}
|
|
8
47
|
interface NupCell {
|
|
9
48
|
v?: string | number | boolean | null;
|
|
10
49
|
f?: string;
|
|
11
50
|
s?: number | string;
|
|
12
51
|
t?: 's' | 'n' | 'b' | 'e' | 'd';
|
|
52
|
+
style?: NupCellStyle;
|
|
13
53
|
}
|
|
14
54
|
interface NupRow {
|
|
15
55
|
h?: number;
|
|
@@ -50,7 +90,7 @@ interface NupThemeConfig {
|
|
|
50
90
|
interface NupWorkbook {
|
|
51
91
|
sheets: NupWorksheet[];
|
|
52
92
|
activeSheet: number;
|
|
53
|
-
styles?: Record<string,
|
|
93
|
+
styles?: Record<string | number, NupCellStyle>;
|
|
54
94
|
theme?: NupThemeConfig;
|
|
55
95
|
}
|
|
56
96
|
interface PreviewConfig {
|
|
@@ -766,6 +806,46 @@ declare function formatCellValue(value: unknown, type?: string): string;
|
|
|
766
806
|
*/
|
|
767
807
|
declare function isFormula(value: string): boolean;
|
|
768
808
|
|
|
809
|
+
/**
|
|
810
|
+
* Style Mapper
|
|
811
|
+
* Converts NupCellStyle to CSS properties
|
|
812
|
+
*/
|
|
813
|
+
|
|
814
|
+
interface CellCSSProperties {
|
|
815
|
+
fontFamily?: string;
|
|
816
|
+
fontSize?: string;
|
|
817
|
+
fontWeight?: string;
|
|
818
|
+
fontStyle?: string;
|
|
819
|
+
textDecoration?: string;
|
|
820
|
+
color?: string;
|
|
821
|
+
backgroundColor?: string;
|
|
822
|
+
textAlign?: string;
|
|
823
|
+
verticalAlign?: string;
|
|
824
|
+
whiteSpace?: string;
|
|
825
|
+
paddingLeft?: string;
|
|
826
|
+
borderTop?: string;
|
|
827
|
+
borderRight?: string;
|
|
828
|
+
borderBottom?: string;
|
|
829
|
+
borderLeft?: string;
|
|
830
|
+
transform?: string;
|
|
831
|
+
}
|
|
832
|
+
/**
|
|
833
|
+
* Convert NupCellStyle to CSS properties object
|
|
834
|
+
*/
|
|
835
|
+
declare function styleToCss(style?: NupCellStyle): CellCSSProperties;
|
|
836
|
+
/**
|
|
837
|
+
* Convert CSS properties object to inline style string
|
|
838
|
+
*/
|
|
839
|
+
declare function cssToStyleString(css: CellCSSProperties): string;
|
|
840
|
+
/**
|
|
841
|
+
* Resolve style from workbook styles registry
|
|
842
|
+
*/
|
|
843
|
+
declare function resolveStyle(styleRef: number | string | undefined, workbook: NupWorkbook): NupCellStyle | undefined;
|
|
844
|
+
/**
|
|
845
|
+
* Get computed style for a cell (inline style + workbook style)
|
|
846
|
+
*/
|
|
847
|
+
declare function getCellStyle(cellStyle?: NupCellStyle, styleRef?: number | string, workbook?: NupWorkbook): NupCellStyle | undefined;
|
|
848
|
+
|
|
769
849
|
interface NupSpreadsheetPreviewProps extends Omit<Partial<PreviewConfig>, 'theme'>, PreviewEvents {
|
|
770
850
|
workbook: NupWorkbook;
|
|
771
851
|
activeSheet?: number;
|
|
@@ -787,4 +867,4 @@ interface CreatePreviewOptions extends Partial<PreviewConfig>, PreviewEvents {
|
|
|
787
867
|
}
|
|
788
868
|
declare function createSpreadsheetPreview(container: HTMLElement | string, options: CreatePreviewOptions): PreviewInstance;
|
|
789
869
|
|
|
790
|
-
export { type CellClickEvent, type CellRect, type ClipboardData, ClipboardHandler, type CreatePreviewOptions, type FrozenInfo, type KeyboardAction, type KeyboardConfig, KeyboardHandler, MergeHandler, type MergeInfo, type NupCell, type NupCol, type NupRow, type NupThemeConfig, type NupWorkbook, type NupWorksheet, type PreviewConfig, type PreviewEvents, type PreviewInstance, NupSpreadsheetPreview as ReactSpreadsheetPreview, type NupSpreadsheetPreviewProps as ReactSpreadsheetPreviewProps, ResizeHandler, type ResizeState, type ScrollPosition, SearchHandler, type SearchOptions, type SearchResult, SelectionHandler, type SelectionRange, type SelectionState, type ThemeName, VirtualScroll, type VirtualScrollConfig, type VisibleRange, applyTheme, cellRefToCoords, colIndexToLetter, coordsToCellRef, createSpreadsheetPreview, createSpreadsheetPreview as default, formatCellValue, getTheme, getThemeClass, isFormula, letterToColIndex, parseRange, themes };
|
|
870
|
+
export { type CellCSSProperties, type CellClickEvent, type CellRect, type ClipboardData, ClipboardHandler, type CreatePreviewOptions, type FrozenInfo, type KeyboardAction, type KeyboardConfig, KeyboardHandler, MergeHandler, type MergeInfo, type NupCell, type NupCellAlignment, type NupCellBorder, type NupCellBorders, type NupCellFill, type NupCellFont, type NupCellStyle, type NupCol, type NupRow, type NupThemeConfig, type NupWorkbook, type NupWorksheet, type PreviewConfig, type PreviewEvents, type PreviewInstance, NupSpreadsheetPreview as ReactSpreadsheetPreview, type NupSpreadsheetPreviewProps as ReactSpreadsheetPreviewProps, ResizeHandler, type ResizeState, type ScrollPosition, SearchHandler, type SearchOptions, type SearchResult, SelectionHandler, type SelectionRange, type SelectionState, type ThemeName, VirtualScroll, type VirtualScrollConfig, type VisibleRange, applyTheme, cellRefToCoords, colIndexToLetter, coordsToCellRef, createSpreadsheetPreview, cssToStyleString, createSpreadsheetPreview as default, formatCellValue, getCellStyle, getTheme, getThemeClass, isFormula, letterToColIndex, parseRange, resolveStyle, styleToCss, themes };
|
package/dist/index.d.ts
CHANGED
|
@@ -5,11 +5,51 @@ import { CSSProperties } from 'react';
|
|
|
5
5
|
* @aspect/nup-xlsx-preview - Types
|
|
6
6
|
* Ultra-light Excel visualization component
|
|
7
7
|
*/
|
|
8
|
+
interface NupCellFont {
|
|
9
|
+
name?: string;
|
|
10
|
+
size?: number;
|
|
11
|
+
bold?: boolean;
|
|
12
|
+
italic?: boolean;
|
|
13
|
+
underline?: boolean;
|
|
14
|
+
strike?: boolean;
|
|
15
|
+
color?: string;
|
|
16
|
+
}
|
|
17
|
+
interface NupCellFill {
|
|
18
|
+
type?: 'solid' | 'pattern' | 'gradient';
|
|
19
|
+
color?: string;
|
|
20
|
+
patternColor?: string;
|
|
21
|
+
tint?: number;
|
|
22
|
+
}
|
|
23
|
+
interface NupCellBorder {
|
|
24
|
+
style?: 'thin' | 'medium' | 'thick' | 'dashed' | 'dotted' | 'double';
|
|
25
|
+
color?: string;
|
|
26
|
+
}
|
|
27
|
+
interface NupCellBorders {
|
|
28
|
+
top?: NupCellBorder;
|
|
29
|
+
right?: NupCellBorder;
|
|
30
|
+
bottom?: NupCellBorder;
|
|
31
|
+
left?: NupCellBorder;
|
|
32
|
+
}
|
|
33
|
+
interface NupCellAlignment {
|
|
34
|
+
horizontal?: 'left' | 'center' | 'right' | 'justify';
|
|
35
|
+
vertical?: 'top' | 'middle' | 'bottom';
|
|
36
|
+
wrapText?: boolean;
|
|
37
|
+
indent?: number;
|
|
38
|
+
rotation?: number;
|
|
39
|
+
}
|
|
40
|
+
interface NupCellStyle {
|
|
41
|
+
font?: NupCellFont;
|
|
42
|
+
fill?: NupCellFill;
|
|
43
|
+
border?: NupCellBorders;
|
|
44
|
+
alignment?: NupCellAlignment;
|
|
45
|
+
numberFormat?: string;
|
|
46
|
+
}
|
|
8
47
|
interface NupCell {
|
|
9
48
|
v?: string | number | boolean | null;
|
|
10
49
|
f?: string;
|
|
11
50
|
s?: number | string;
|
|
12
51
|
t?: 's' | 'n' | 'b' | 'e' | 'd';
|
|
52
|
+
style?: NupCellStyle;
|
|
13
53
|
}
|
|
14
54
|
interface NupRow {
|
|
15
55
|
h?: number;
|
|
@@ -50,7 +90,7 @@ interface NupThemeConfig {
|
|
|
50
90
|
interface NupWorkbook {
|
|
51
91
|
sheets: NupWorksheet[];
|
|
52
92
|
activeSheet: number;
|
|
53
|
-
styles?: Record<string,
|
|
93
|
+
styles?: Record<string | number, NupCellStyle>;
|
|
54
94
|
theme?: NupThemeConfig;
|
|
55
95
|
}
|
|
56
96
|
interface PreviewConfig {
|
|
@@ -766,6 +806,46 @@ declare function formatCellValue(value: unknown, type?: string): string;
|
|
|
766
806
|
*/
|
|
767
807
|
declare function isFormula(value: string): boolean;
|
|
768
808
|
|
|
809
|
+
/**
|
|
810
|
+
* Style Mapper
|
|
811
|
+
* Converts NupCellStyle to CSS properties
|
|
812
|
+
*/
|
|
813
|
+
|
|
814
|
+
interface CellCSSProperties {
|
|
815
|
+
fontFamily?: string;
|
|
816
|
+
fontSize?: string;
|
|
817
|
+
fontWeight?: string;
|
|
818
|
+
fontStyle?: string;
|
|
819
|
+
textDecoration?: string;
|
|
820
|
+
color?: string;
|
|
821
|
+
backgroundColor?: string;
|
|
822
|
+
textAlign?: string;
|
|
823
|
+
verticalAlign?: string;
|
|
824
|
+
whiteSpace?: string;
|
|
825
|
+
paddingLeft?: string;
|
|
826
|
+
borderTop?: string;
|
|
827
|
+
borderRight?: string;
|
|
828
|
+
borderBottom?: string;
|
|
829
|
+
borderLeft?: string;
|
|
830
|
+
transform?: string;
|
|
831
|
+
}
|
|
832
|
+
/**
|
|
833
|
+
* Convert NupCellStyle to CSS properties object
|
|
834
|
+
*/
|
|
835
|
+
declare function styleToCss(style?: NupCellStyle): CellCSSProperties;
|
|
836
|
+
/**
|
|
837
|
+
* Convert CSS properties object to inline style string
|
|
838
|
+
*/
|
|
839
|
+
declare function cssToStyleString(css: CellCSSProperties): string;
|
|
840
|
+
/**
|
|
841
|
+
* Resolve style from workbook styles registry
|
|
842
|
+
*/
|
|
843
|
+
declare function resolveStyle(styleRef: number | string | undefined, workbook: NupWorkbook): NupCellStyle | undefined;
|
|
844
|
+
/**
|
|
845
|
+
* Get computed style for a cell (inline style + workbook style)
|
|
846
|
+
*/
|
|
847
|
+
declare function getCellStyle(cellStyle?: NupCellStyle, styleRef?: number | string, workbook?: NupWorkbook): NupCellStyle | undefined;
|
|
848
|
+
|
|
769
849
|
interface NupSpreadsheetPreviewProps extends Omit<Partial<PreviewConfig>, 'theme'>, PreviewEvents {
|
|
770
850
|
workbook: NupWorkbook;
|
|
771
851
|
activeSheet?: number;
|
|
@@ -787,4 +867,4 @@ interface CreatePreviewOptions extends Partial<PreviewConfig>, PreviewEvents {
|
|
|
787
867
|
}
|
|
788
868
|
declare function createSpreadsheetPreview(container: HTMLElement | string, options: CreatePreviewOptions): PreviewInstance;
|
|
789
869
|
|
|
790
|
-
export { type CellClickEvent, type CellRect, type ClipboardData, ClipboardHandler, type CreatePreviewOptions, type FrozenInfo, type KeyboardAction, type KeyboardConfig, KeyboardHandler, MergeHandler, type MergeInfo, type NupCell, type NupCol, type NupRow, type NupThemeConfig, type NupWorkbook, type NupWorksheet, type PreviewConfig, type PreviewEvents, type PreviewInstance, NupSpreadsheetPreview as ReactSpreadsheetPreview, type NupSpreadsheetPreviewProps as ReactSpreadsheetPreviewProps, ResizeHandler, type ResizeState, type ScrollPosition, SearchHandler, type SearchOptions, type SearchResult, SelectionHandler, type SelectionRange, type SelectionState, type ThemeName, VirtualScroll, type VirtualScrollConfig, type VisibleRange, applyTheme, cellRefToCoords, colIndexToLetter, coordsToCellRef, createSpreadsheetPreview, createSpreadsheetPreview as default, formatCellValue, getTheme, getThemeClass, isFormula, letterToColIndex, parseRange, themes };
|
|
870
|
+
export { type CellCSSProperties, type CellClickEvent, type CellRect, type ClipboardData, ClipboardHandler, type CreatePreviewOptions, type FrozenInfo, type KeyboardAction, type KeyboardConfig, KeyboardHandler, MergeHandler, type MergeInfo, type NupCell, type NupCellAlignment, type NupCellBorder, type NupCellBorders, type NupCellFill, type NupCellFont, type NupCellStyle, type NupCol, type NupRow, type NupThemeConfig, type NupWorkbook, type NupWorksheet, type PreviewConfig, type PreviewEvents, type PreviewInstance, NupSpreadsheetPreview as ReactSpreadsheetPreview, type NupSpreadsheetPreviewProps as ReactSpreadsheetPreviewProps, ResizeHandler, type ResizeState, type ScrollPosition, SearchHandler, type SearchOptions, type SearchResult, SelectionHandler, type SelectionRange, type SelectionState, type ThemeName, VirtualScroll, type VirtualScrollConfig, type VisibleRange, applyTheme, cellRefToCoords, colIndexToLetter, coordsToCellRef, createSpreadsheetPreview, cssToStyleString, createSpreadsheetPreview as default, formatCellValue, getCellStyle, getTheme, getThemeClass, isFormula, letterToColIndex, parseRange, resolveStyle, styleToCss, themes };
|
package/dist/index.js
CHANGED
|
@@ -1,55 +1,55 @@
|
|
|
1
|
-
import {forwardRef,useRef,useState,useMemo,useLayoutEffect,useEffect,useCallback,useImperativeHandle}from'react';import {jsx,jsxs}from'react/jsx-runtime';var oe=class{rowPositions;colPositions;rowHeightCache;colWidthCache;totalHeight;totalWidth;overscan;rowCount;colCount;frozenRows;frozenCols;frozenRowsHeight;frozenColsWidth;constructor(e){let{rows:t,cols:o,rowHeights:l,colWidths:s,defaultRowHeight:h=24,defaultColWidth:g=100,overscan:f=5,frozenRows:m=0,frozenCols:y=0}=e;this.frozenRows=m,this.frozenCols=y,this.rowCount=t,this.colCount=o,this.overscan=f,this.rowPositions=new Array(t+1),this.rowHeightCache=new Array(t),this.rowPositions[0]=0;for(let v=0;v<t;v++){let T=l[v]??h;this.rowHeightCache[v]=T,this.rowPositions[v+1]=this.rowPositions[v]+T;}this.totalHeight=this.rowPositions[t],this.frozenRowsHeight=m>0?this.rowPositions[m]??0:0,this.colPositions=new Array(o+1),this.colWidthCache=new Array(o),this.colPositions[0]=0;for(let v=0;v<o;v++){let T=s[v]??g;this.colWidthCache[v]=T,this.colPositions[v+1]=this.colPositions[v]+T;}this.totalWidth=this.colPositions[o],this.frozenColsWidth=y>0?this.colPositions[y]??0:0;}getFrozenInfo(){return {rows:this.frozenRows,cols:this.frozenCols,frozenRowsHeight:this.frozenRowsHeight,frozenColsWidth:this.frozenColsWidth}}binarySearch(e,t){let o=0,l=e.length-2;for(;o<=l;){let s=o+l>>>1,h=e[s],g=e[s+1];if(t>=h&&t<g)return s;t<h?l=s-1:o=s+1;}return Math.max(0,Math.min(o,e.length-2))}getVisibleRange(e,t,o,l){let s=e+this.frozenRowsHeight,h=t+this.frozenColsWidth,g=this.binarySearch(this.rowPositions,s),f=this.binarySearch(this.rowPositions,s+Math.max(0,o)),m=this.binarySearch(this.colPositions,h),y=this.binarySearch(this.colPositions,h+Math.max(0,l)),v=Math.max(this.frozenRows,g-this.overscan),T=Math.min(this.rowCount-1,f+this.overscan),me=Math.max(this.frozenCols,m-this.overscan),ee=Math.min(this.colCount-1,y+this.overscan);return {startRow:v,endRow:T,startCol:me,endCol:ee}}getFrozenRowsRange(){return this.frozenRows===0?null:{startRow:0,endRow:this.frozenRows-1}}getFrozenColsRange(){return this.frozenCols===0?null:{startCol:0,endCol:this.frozenCols-1}}getCellRect(e,t){return {top:this.rowPositions[e]??0,left:this.colPositions[t]??0,width:this.colWidthCache[t]??100,height:this.rowHeightCache[e]??24}}getRowHeight(e){return this.rowHeightCache[e]??24}getColWidth(e){return this.colWidthCache[e]??100}setColWidth(e,t){if(e<0||e>=this.colCount)return;let o=this.colWidthCache[e],l=t-o;this.colWidthCache[e]=t;for(let s=e+1;s<=this.colCount;s++)this.colPositions[s]+=l;this.totalWidth+=l;}getIndexAtPosition(e,t){return {row:this.binarySearch(this.rowPositions,e),col:this.binarySearch(this.colPositions,t)}}getScrollToPosition(e,t,o,l){let s=this.rowPositions[e]??0,h=this.colPositions[t]??0;return {scrollTop:Math.max(0,s-o/2),scrollLeft:Math.max(0,h-l/2)}}};function fe(p){let e="",t=p;for(;t>=0;)e=String.fromCharCode(t%26+65)+e,t=Math.floor(t/26)-1;return e}function Xe(p){let e=0,t=p.toUpperCase();for(let o=0;o<t.length;o++)e=e*26+(t.charCodeAt(o)-64);return e-1}function E(p,e){return `${fe(e)}${p+1}`}function W(p){let e=p.match(/^([A-Z]+)(\d+)$/i);if(!e)return null;let t=Xe(e[1]),o=parseInt(e[2],10)-1;return o<0||t<0?null:{row:o,col:t}}function tt(p){let[e,t]=p.split(":");if(!e)return null;let o=W(e);if(!o)return null;if(!t)return {start:o,end:o};let l=W(t);return l?{start:{row:Math.min(o.row,l.row),col:Math.min(o.col,l.col)},end:{row:Math.max(o.row,l.row),col:Math.max(o.col,l.col)}}:null}function ot(p,e){return p==null?"":e==="n"&&typeof p=="number"?Number.isInteger(p)?p.toLocaleString():p.toLocaleString(void 0,{minimumFractionDigits:0,maximumFractionDigits:2}):String(p)}function rt(p){return typeof p=="string"&&p.startsWith("=")}var re=class{state;sheet;onChange;constructor(e,t){this.sheet=e,this.onChange=t??null,this.state={anchor:null,focus:null,ranges:[]};}handleClick(e,t,o){let{shiftKey:l,ctrlKey:s,metaKey:h}=o;l&&this.state.anchor?(this.state.focus={row:e,col:t},this.updateRanges()):s||h?(this.state.anchor={row:e,col:t},this.state.focus={row:e,col:t},this.state.ranges.push(this.createRange(this.state.anchor,this.state.focus))):(this.state.anchor={row:e,col:t},this.state.focus={row:e,col:t},this.state.ranges=[this.createRange(this.state.anchor,this.state.focus)]),this.notifyChange();}handleDrag(e,t){this.state.anchor&&(this.state.focus={row:e,col:t},this.updateRanges(),this.notifyChange());}selectCell(e){let t=W(e);t&&(this.state.anchor=t,this.state.focus=t,this.state.ranges=[this.createRange(t,t)],this.notifyChange());}selectRange(e,t){let o=W(e),l=W(t);!o||!l||(this.state.anchor=o,this.state.focus=l,this.state.ranges=[this.createRange(o,l)],this.notifyChange());}selectAll(){this.state.anchor={row:0,col:0},this.state.focus={row:this.sheet.rowCount-1,col:this.sheet.colCount-1},this.state.ranges=[this.createRange(this.state.anchor,this.state.focus)],this.notifyChange();}clear(){this.state.anchor=null,this.state.focus=null,this.state.ranges=[],this.notifyChange();}getSelection(){return this.state.ranges.length===0?null:this.state.ranges[0]}getAllSelections(){return [...this.state.ranges]}isCellSelected(e,t){return this.state.ranges.some(o=>e>=o.start.row&&e<=o.end.row&&t>=o.start.col&&t<=o.end.col)}isAnchor(e,t){return this.state.anchor?.row===e&&this.state.anchor?.col===t}setSheet(e){this.sheet=e,this.clear();}updateRanges(){if(!this.state.anchor||!this.state.focus)return;let e=this.createRange(this.state.anchor,this.state.focus);this.state.ranges.length>0?this.state.ranges[this.state.ranges.length-1]=e:this.state.ranges.push(e);}createRange(e,t){let o=Math.min(e.row,t.row),l=Math.max(e.row,t.row),s=Math.min(e.col,t.col),h=Math.max(e.col,t.col),g=[],f=[];for(let m=o;m<=l;m++){let y=[];for(let v=s;v<=h;v++){let T=E(m,v);f.push(T),y.push(this.sheet.cells[T]??null);}g.push(y);}return {start:{row:o,col:s},end:{row:l,col:h},cells:g,cellRefs:f}}notifyChange(){this.onChange&&this.onChange(this.getSelection());}};var ne=class{selection;virtualScroll;config;onScroll;onCopy;constructor(e,t,o,l){this.selection=e,this.virtualScroll=t,this.config=o,this.onScroll=l?.onScroll??null,this.onCopy=l?.onCopy??null;}handleKeyDown(e){if(!this.config.enabled)return false;let t=this.getAction(e);return t?(e.preventDefault(),this.executeAction(t),true):false}getAction(e){let{key:t,shiftKey:o,ctrlKey:l,metaKey:s}=e,h=l||s;if(h&&t==="c")return "copy";if(h&&t==="a")return "select-all";if(o)switch(t){case "ArrowUp":return "extend-up";case "ArrowDown":return "extend-down";case "ArrowLeft":return "extend-left";case "ArrowRight":return "extend-right"}if(h)switch(t){case "Home":return "move-ctrl-home";case "End":return "move-ctrl-end"}switch(t){case "ArrowUp":return "move-up";case "ArrowDown":return "move-down";case "ArrowLeft":return "move-left";case "ArrowRight":return "move-right";case "PageUp":return "move-page-up";case "PageDown":return "move-page-down";case "Home":return "move-home";case "End":return "move-end";case "Tab":return o?"move-left":"move-right";case "Enter":return o?"move-up":"move-down"}return null}executeAction(e){let t=this.selection.getSelection();if(!t&&!["select-all","move-ctrl-home"].includes(e)){this.selection.selectCell("A1"),this.scrollToSelection();return}let{row:o,col:l}=t?.start??{row:0,col:0},s=o,h=l;switch(e){case "move-up":s=Math.max(0,o-1);break;case "move-down":s=Math.min(this.virtualScroll.rowCount-1,o+1);break;case "move-left":h=Math.max(0,l-1);break;case "move-right":h=Math.min(this.virtualScroll.colCount-1,l+1);break;case "move-page-up":s=Math.max(0,o-20);break;case "move-page-down":s=Math.min(this.virtualScroll.rowCount-1,o+20);break;case "move-home":h=0;break;case "move-end":h=this.virtualScroll.colCount-1;break;case "move-ctrl-home":s=0,h=0;break;case "move-ctrl-end":s=this.virtualScroll.rowCount-1,h=this.virtualScroll.colCount-1;break;case "select-all":this.selection.selectAll();return;case "copy":this.onCopy?.();return;case "extend-up":case "extend-down":case "extend-left":case "extend-right":this.extendSelection(e);return}this.selection.handleClick(s,h,{shiftKey:false,ctrlKey:false,metaKey:false}),this.scrollToSelection();}extendSelection(e){let t=this.selection.getSelection();if(!t)return;let{row:o,col:l}=t.end;switch(e){case "extend-up":o=Math.max(0,o-1);break;case "extend-down":o=Math.min(this.virtualScroll.rowCount-1,o+1);break;case "extend-left":l=Math.max(0,l-1);break;case "extend-right":l=Math.min(this.virtualScroll.colCount-1,l+1);break}this.selection.handleDrag(o,l),this.scrollToSelection();}scrollToSelection(){let e=this.selection.getSelection();!e||!this.onScroll||this.onScroll(e.start.row,e.start.col);}setVirtualScroll(e){this.virtualScroll=e;}setSelection(e){this.selection=e;}};var se=class{merges;mergeMap;constructor(e=[]){this.merges=[],this.mergeMap=new Map,this.parseMerges(e);}parseMerges(e){for(let t of e){let[o,l]=t.split(":");if(!o||!l)continue;let s=W(o),h=W(l);if(!s||!h)continue;let g={startRow:Math.min(s.row,h.row),startCol:Math.min(s.col,h.col),endRow:Math.max(s.row,h.row),endCol:Math.max(s.col,h.col),cellRef:o};this.merges.push(g);for(let f=g.startRow;f<=g.endRow;f++)for(let m=g.startCol;m<=g.endCol;m++){let y=`${f},${m}`;this.mergeMap.set(y,g);}}}getMergeAt(e,t){return this.mergeMap.get(`${e},${t}`)??null}isMergeMaster(e,t){let o=this.getMergeAt(e,t);return o?o.startRow===e&&o.startCol===t:false}isMergeHidden(e,t){let o=this.getMergeAt(e,t);return o?!(o.startRow===e&&o.startCol===t):false}getMergeMaster(e,t){let o=this.getMergeAt(e,t);return o?{row:o.startRow,col:o.startCol}:null}getMergeRect(e,t,o){let l=this.getMergeAt(e,t);if(!l||!this.isMergeMaster(e,t))return null;let s=o(l.startRow,l.startCol),h=o(l.endRow,l.endCol);return {top:s.top,left:s.left,width:h.left+h.width-s.left,height:h.top+h.height-s.top}}getAllMerges(){return [...this.merges]}getVisibleMerges(e,t,o,l){return this.merges.filter(s=>s.endRow>=e&&s.startRow<=t&&s.endCol>=o&&s.startCol<=l)}update(e){this.merges=[],this.mergeMap.clear(),this.parseMerges(e);}};var le=class{async copyToClipboard(e){let t=this.formatSelection(e);try{if(navigator.clipboard&&typeof ClipboardItem<"u"){let o=new Blob([t.html],{type:"text/html"}),l=new Blob([t.text],{type:"text/plain"});await navigator.clipboard.write([new ClipboardItem({"text/html":o,"text/plain":l})]);}else await this.copyWithExecCommand(t.text);}catch{await this.copyWithExecCommand(t.text);}return t}formatSelection(e){let{cells:t}=e,o=[];for(let g of t){let f=g.map(m=>this.getCellValue(m));o.push(f.join(" "));}let l=o.join(`
|
|
2
|
-
`),
|
|
1
|
+
import {forwardRef,useRef,useState,useMemo,useLayoutEffect,useEffect,useCallback,useImperativeHandle}from'react';import {jsx,jsxs}from'react/jsx-runtime';var oe=class{rowPositions;colPositions;rowHeightCache;colWidthCache;totalHeight;totalWidth;overscan;rowCount;colCount;frozenRows;frozenCols;frozenRowsHeight;frozenColsWidth;constructor(e){let{rows:t,cols:o,rowHeights:s,colWidths:l,defaultRowHeight:h=24,defaultColWidth:g=100,overscan:f=5,frozenRows:m=0,frozenCols:S=0}=e;this.frozenRows=m,this.frozenCols=S,this.rowCount=t,this.colCount=o,this.overscan=f,this.rowPositions=new Array(t+1),this.rowHeightCache=new Array(t),this.rowPositions[0]=0;for(let v=0;v<t;v++){let T=s[v]??h;this.rowHeightCache[v]=T,this.rowPositions[v+1]=this.rowPositions[v]+T;}this.totalHeight=this.rowPositions[t],this.frozenRowsHeight=m>0?this.rowPositions[m]??0:0,this.colPositions=new Array(o+1),this.colWidthCache=new Array(o),this.colPositions[0]=0;for(let v=0;v<o;v++){let T=l[v]??g;this.colWidthCache[v]=T,this.colPositions[v+1]=this.colPositions[v]+T;}this.totalWidth=this.colPositions[o],this.frozenColsWidth=S>0?this.colPositions[S]??0:0;}getFrozenInfo(){return {rows:this.frozenRows,cols:this.frozenCols,frozenRowsHeight:this.frozenRowsHeight,frozenColsWidth:this.frozenColsWidth}}binarySearch(e,t){let o=0,s=e.length-2;for(;o<=s;){let l=o+s>>>1,h=e[l],g=e[l+1];if(t>=h&&t<g)return l;t<h?s=l-1:o=l+1;}return Math.max(0,Math.min(o,e.length-2))}getVisibleRange(e,t,o,s){let l=e+this.frozenRowsHeight,h=t+this.frozenColsWidth,g=this.binarySearch(this.rowPositions,l),f=this.binarySearch(this.rowPositions,l+Math.max(0,o)),m=this.binarySearch(this.colPositions,h),S=this.binarySearch(this.colPositions,h+Math.max(0,s)),v=Math.max(this.frozenRows,g-this.overscan),T=Math.min(this.rowCount-1,f+this.overscan),ge=Math.max(this.frozenCols,m-this.overscan),ee=Math.min(this.colCount-1,S+this.overscan);return {startRow:v,endRow:T,startCol:ge,endCol:ee}}getFrozenRowsRange(){return this.frozenRows===0?null:{startRow:0,endRow:this.frozenRows-1}}getFrozenColsRange(){return this.frozenCols===0?null:{startCol:0,endCol:this.frozenCols-1}}getCellRect(e,t){return {top:this.rowPositions[e]??0,left:this.colPositions[t]??0,width:this.colWidthCache[t]??100,height:this.rowHeightCache[e]??24}}getRowHeight(e){return this.rowHeightCache[e]??24}getColWidth(e){return this.colWidthCache[e]??100}setColWidth(e,t){if(e<0||e>=this.colCount)return;let o=this.colWidthCache[e],s=t-o;this.colWidthCache[e]=t;for(let l=e+1;l<=this.colCount;l++)this.colPositions[l]+=s;this.totalWidth+=s;}getIndexAtPosition(e,t){return {row:this.binarySearch(this.rowPositions,e),col:this.binarySearch(this.colPositions,t)}}getScrollToPosition(e,t,o,s){let l=this.rowPositions[e]??0,h=this.colPositions[t]??0;return {scrollTop:Math.max(0,l-o/2),scrollLeft:Math.max(0,h-s/2)}}};function fe(i){let e="",t=i;for(;t>=0;)e=String.fromCharCode(t%26+65)+e,t=Math.floor(t/26)-1;return e}function qe(i){let e=0,t=i.toUpperCase();for(let o=0;o<t.length;o++)e=e*26+(t.charCodeAt(o)-64);return e-1}function E(i,e){return `${fe(e)}${i+1}`}function I(i){let e=i.match(/^([A-Z]+)(\d+)$/i);if(!e)return null;let t=qe(e[1]),o=parseInt(e[2],10)-1;return o<0||t<0?null:{row:o,col:t}}function rt(i){let[e,t]=i.split(":");if(!e)return null;let o=I(e);if(!o)return null;if(!t)return {start:o,end:o};let s=I(t);return s?{start:{row:Math.min(o.row,s.row),col:Math.min(o.col,s.col)},end:{row:Math.max(o.row,s.row),col:Math.max(o.col,s.col)}}:null}function nt(i,e){return i==null?"":e==="n"&&typeof i=="number"?Number.isInteger(i)?i.toLocaleString():i.toLocaleString(void 0,{minimumFractionDigits:0,maximumFractionDigits:2}):String(i)}function st(i){return typeof i=="string"&&i.startsWith("=")}var re=class{state;sheet;onChange;constructor(e,t){this.sheet=e,this.onChange=t??null,this.state={anchor:null,focus:null,ranges:[]};}handleClick(e,t,o){let{shiftKey:s,ctrlKey:l,metaKey:h}=o;s&&this.state.anchor?(this.state.focus={row:e,col:t},this.updateRanges()):l||h?(this.state.anchor={row:e,col:t},this.state.focus={row:e,col:t},this.state.ranges.push(this.createRange(this.state.anchor,this.state.focus))):(this.state.anchor={row:e,col:t},this.state.focus={row:e,col:t},this.state.ranges=[this.createRange(this.state.anchor,this.state.focus)]),this.notifyChange();}handleDrag(e,t){this.state.anchor&&(this.state.focus={row:e,col:t},this.updateRanges(),this.notifyChange());}selectCell(e){let t=I(e);t&&(this.state.anchor=t,this.state.focus=t,this.state.ranges=[this.createRange(t,t)],this.notifyChange());}selectRange(e,t){let o=I(e),s=I(t);!o||!s||(this.state.anchor=o,this.state.focus=s,this.state.ranges=[this.createRange(o,s)],this.notifyChange());}selectAll(){this.state.anchor={row:0,col:0},this.state.focus={row:this.sheet.rowCount-1,col:this.sheet.colCount-1},this.state.ranges=[this.createRange(this.state.anchor,this.state.focus)],this.notifyChange();}clear(){this.state.anchor=null,this.state.focus=null,this.state.ranges=[],this.notifyChange();}getSelection(){return this.state.ranges.length===0?null:this.state.ranges[0]}getAllSelections(){return [...this.state.ranges]}isCellSelected(e,t){return this.state.ranges.some(o=>e>=o.start.row&&e<=o.end.row&&t>=o.start.col&&t<=o.end.col)}isAnchor(e,t){return this.state.anchor?.row===e&&this.state.anchor?.col===t}setSheet(e){this.sheet=e,this.clear();}updateRanges(){if(!this.state.anchor||!this.state.focus)return;let e=this.createRange(this.state.anchor,this.state.focus);this.state.ranges.length>0?this.state.ranges[this.state.ranges.length-1]=e:this.state.ranges.push(e);}createRange(e,t){let o=Math.min(e.row,t.row),s=Math.max(e.row,t.row),l=Math.min(e.col,t.col),h=Math.max(e.col,t.col),g=[],f=[];for(let m=o;m<=s;m++){let S=[];for(let v=l;v<=h;v++){let T=E(m,v);f.push(T),S.push(this.sheet.cells[T]??null);}g.push(S);}return {start:{row:o,col:l},end:{row:s,col:h},cells:g,cellRefs:f}}notifyChange(){this.onChange&&this.onChange(this.getSelection());}};var ne=class{selection;virtualScroll;config;onScroll;onCopy;constructor(e,t,o,s){this.selection=e,this.virtualScroll=t,this.config=o,this.onScroll=s?.onScroll??null,this.onCopy=s?.onCopy??null;}handleKeyDown(e){if(!this.config.enabled)return false;let t=this.getAction(e);return t?(e.preventDefault(),this.executeAction(t),true):false}getAction(e){let{key:t,shiftKey:o,ctrlKey:s,metaKey:l}=e,h=s||l;if(h&&t==="c")return "copy";if(h&&t==="a")return "select-all";if(o)switch(t){case "ArrowUp":return "extend-up";case "ArrowDown":return "extend-down";case "ArrowLeft":return "extend-left";case "ArrowRight":return "extend-right"}if(h)switch(t){case "Home":return "move-ctrl-home";case "End":return "move-ctrl-end"}switch(t){case "ArrowUp":return "move-up";case "ArrowDown":return "move-down";case "ArrowLeft":return "move-left";case "ArrowRight":return "move-right";case "PageUp":return "move-page-up";case "PageDown":return "move-page-down";case "Home":return "move-home";case "End":return "move-end";case "Tab":return o?"move-left":"move-right";case "Enter":return o?"move-up":"move-down"}return null}executeAction(e){let t=this.selection.getSelection();if(!t&&!["select-all","move-ctrl-home"].includes(e)){this.selection.selectCell("A1"),this.scrollToSelection();return}let{row:o,col:s}=t?.start??{row:0,col:0},l=o,h=s;switch(e){case "move-up":l=Math.max(0,o-1);break;case "move-down":l=Math.min(this.virtualScroll.rowCount-1,o+1);break;case "move-left":h=Math.max(0,s-1);break;case "move-right":h=Math.min(this.virtualScroll.colCount-1,s+1);break;case "move-page-up":l=Math.max(0,o-20);break;case "move-page-down":l=Math.min(this.virtualScroll.rowCount-1,o+20);break;case "move-home":h=0;break;case "move-end":h=this.virtualScroll.colCount-1;break;case "move-ctrl-home":l=0,h=0;break;case "move-ctrl-end":l=this.virtualScroll.rowCount-1,h=this.virtualScroll.colCount-1;break;case "select-all":this.selection.selectAll();return;case "copy":this.onCopy?.();return;case "extend-up":case "extend-down":case "extend-left":case "extend-right":this.extendSelection(e);return}this.selection.handleClick(l,h,{shiftKey:false,ctrlKey:false,metaKey:false}),this.scrollToSelection();}extendSelection(e){let t=this.selection.getSelection();if(!t)return;let{row:o,col:s}=t.end;switch(e){case "extend-up":o=Math.max(0,o-1);break;case "extend-down":o=Math.min(this.virtualScroll.rowCount-1,o+1);break;case "extend-left":s=Math.max(0,s-1);break;case "extend-right":s=Math.min(this.virtualScroll.colCount-1,s+1);break}this.selection.handleDrag(o,s),this.scrollToSelection();}scrollToSelection(){let e=this.selection.getSelection();!e||!this.onScroll||this.onScroll(e.start.row,e.start.col);}setVirtualScroll(e){this.virtualScroll=e;}setSelection(e){this.selection=e;}};var se=class{merges;mergeMap;constructor(e=[]){this.merges=[],this.mergeMap=new Map,this.parseMerges(e);}parseMerges(e){for(let t of e){let[o,s]=t.split(":");if(!o||!s)continue;let l=I(o),h=I(s);if(!l||!h)continue;let g={startRow:Math.min(l.row,h.row),startCol:Math.min(l.col,h.col),endRow:Math.max(l.row,h.row),endCol:Math.max(l.col,h.col),cellRef:o};this.merges.push(g);for(let f=g.startRow;f<=g.endRow;f++)for(let m=g.startCol;m<=g.endCol;m++){let S=`${f},${m}`;this.mergeMap.set(S,g);}}}getMergeAt(e,t){return this.mergeMap.get(`${e},${t}`)??null}isMergeMaster(e,t){let o=this.getMergeAt(e,t);return o?o.startRow===e&&o.startCol===t:false}isMergeHidden(e,t){let o=this.getMergeAt(e,t);return o?!(o.startRow===e&&o.startCol===t):false}getMergeMaster(e,t){let o=this.getMergeAt(e,t);return o?{row:o.startRow,col:o.startCol}:null}getMergeRect(e,t,o){let s=this.getMergeAt(e,t);if(!s||!this.isMergeMaster(e,t))return null;let l=o(s.startRow,s.startCol),h=o(s.endRow,s.endCol);return {top:l.top,left:l.left,width:h.left+h.width-l.left,height:h.top+h.height-l.top}}getAllMerges(){return [...this.merges]}getVisibleMerges(e,t,o,s){return this.merges.filter(l=>l.endRow>=e&&l.startRow<=t&&l.endCol>=o&&l.startCol<=s)}update(e){this.merges=[],this.mergeMap.clear(),this.parseMerges(e);}};var le=class{async copyToClipboard(e){let t=this.formatSelection(e);try{if(navigator.clipboard&&typeof ClipboardItem<"u"){let o=new Blob([t.html],{type:"text/html"}),s=new Blob([t.text],{type:"text/plain"});await navigator.clipboard.write([new ClipboardItem({"text/html":o,"text/plain":s})]);}else await this.copyWithExecCommand(t.text);}catch{await this.copyWithExecCommand(t.text);}return t}formatSelection(e){let{cells:t}=e,o=[];for(let g of t){let f=g.map(m=>this.getCellValue(m));o.push(f.join(" "));}let s=o.join(`
|
|
2
|
+
`),l=[];for(let g of t){let f=g.map(m=>{let S=this.escapeHtml(this.getCellValue(m));return `<td style="${this.getCellStyle(m)}">${S}</td>`});l.push(`<tr>${f.join("")}</tr>`);}let h=`
|
|
3
3
|
<table style="border-collapse: collapse; font-family: Arial, sans-serif; font-size: 12px;">
|
|
4
4
|
<tbody>
|
|
5
|
-
${
|
|
5
|
+
${l.join(`
|
|
6
6
|
`)}
|
|
7
7
|
</tbody>
|
|
8
8
|
</table>
|
|
9
|
-
`.trim();return {text:l,html:h,cells:t}}getCellValue(e){return !e||e.v===void 0||e.v===null?"":String(e.v)}getCellStyle(e){let t=["border: 1px solid #ccc","padding: 4px 8px"];return e?.t==="n"&&t.push("text-align: right"),t.join("; ")}escapeHtml(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}async copyWithExecCommand(e){let t=document.createElement("textarea");t.value=e,t.style.position="fixed",t.style.left="-9999px",document.body.appendChild(t),t.select();try{document.execCommand("copy");}finally{document.body.removeChild(t);}}};var ie=class{sheet;results;currentIndex;constructor(e){this.sheet=e,this.results=[],this.currentIndex=-1;}search(e,t={}){if(!e)return this.results=[],this.currentIndex=-1,[];let{caseSensitive:o=false,regex:l=false,matchWholeCell:s=false}=t,h;try{if(l)h=new RegExp(e,o?"g":"gi");else {let f=e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),m=s?`^${f}$`:f;h=new RegExp(m,o?"g":"gi");}}catch{let f=e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");h=new RegExp(f,o?"g":"gi");}let g=[];for(let[f,m]of Object.entries(this.sheet.cells)){if(m.v===void 0||m.v===null)continue;let y=String(m.v);h.lastIndex=0;let v=h.exec(y);if(v){let T=this.parseCellRef(f);T&&g.push({row:T.row,col:T.col,cellRef:f,value:y,matchStart:v.index,matchEnd:v.index+v[0].length});}}return g.sort((f,m)=>f.row!==m.row?f.row-m.row:f.col-m.col),this.results=g,this.currentIndex=g.length>0?0:-1,g}next(){return this.results.length===0?null:(this.currentIndex=(this.currentIndex+1)%this.results.length,this.results[this.currentIndex])}previous(){return this.results.length===0?null:(this.currentIndex=(this.currentIndex-1+this.results.length)%this.results.length,this.results[this.currentIndex])}current(){return this.currentIndex<0||this.currentIndex>=this.results.length?null:this.results[this.currentIndex]}getResults(){return [...this.results]}getCount(){return this.results.length}getCurrentIndex(){return this.currentIndex+1}isResult(e,t){return this.results.some(o=>o.row===e&&o.col===t)}isCurrent(e,t){let o=this.current();return o?.row===e&&o?.col===t}clear(){this.results=[],this.currentIndex=-1;}setSheet(e){this.sheet=e,this.clear();}parseCellRef(e){let t=e.match(/^([A-Z]+)(\d+)$/i);if(!t)return null;let o=t[1].toUpperCase(),l=parseInt(t[2],10)-1,s=0;for(let h=0;h<o.length;h++)s=s*26+(o.charCodeAt(h)-64);return s-=1,{row:l,col:s}}};var ae=class{state=null;virtualScroll;onChange;minWidth;maxWidth;constructor(e,t,o=30,l=500){this.virtualScroll=e,this.onChange=t??null,this.minWidth=o,this.maxWidth=l;}startResize(e,t){let o=this.virtualScroll.getColWidth(e);this.state={isResizing:true,colIndex:e,startX:t,startWidth:o},document.addEventListener("mousemove",this.handleMouseMove),document.addEventListener("mouseup",this.handleMouseUp),document.body.style.cursor="col-resize",document.body.style.userSelect="none";}handleMouseMove=e=>{if(!this.state)return;let t=e.clientX-this.state.startX,o=Math.min(this.maxWidth,Math.max(this.minWidth,this.state.startWidth+t));this.virtualScroll.setColWidth(this.state.colIndex,o),this.onChange?.(this.state.colIndex,o);};handleMouseUp=()=>{this.cleanup();};isResizing(){return this.state?.isResizing??false}getResizeColumn(){return this.state?.colIndex??null}cancel(){this.state&&(this.virtualScroll.setColWidth(this.state.colIndex,this.state.startWidth),this.onChange?.(this.state.colIndex,this.state.startWidth)),this.cleanup();}cleanup(){document.removeEventListener("mousemove",this.handleMouseMove),document.removeEventListener("mouseup",this.handleMouseUp),document.body.style.cursor="",document.body.style.userSelect="",this.state=null;}setVirtualScroll(e){this.virtualScroll=e;}destroy(){this.cleanup();}};var _={default:{name:"default",colors:{background:"#ffffff",foreground:"#202124",grid:"#e0e0e0",headerBackground:"#f8f9fa",headerForeground:"#5f6368",selectionBorder:"#1a73e8",selectionBackground:"rgba(26, 115, 232, 0.08)",frozenBorder:"#dadce0"},fonts:{family:"'Google Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif",size:"13px",headerSize:"11px"}},excel:{name:"excel",colors:{background:"#ffffff",foreground:"#000000",grid:"#d4d4d4",headerBackground:"#f0f0f0",headerForeground:"#000000",selectionBorder:"#217346",selectionBackground:"rgba(33, 115, 70, 0.1)",frozenBorder:"#9bc2e6"},fonts:{family:"'Calibri', 'Segoe UI', sans-serif",size:"11px",headerSize:"11px"}},modern:{name:"modern",colors:{background:"#fafafa",foreground:"#18181b",grid:"#e4e4e7",headerBackground:"#f4f4f5",headerForeground:"#71717a",selectionBorder:"#3b82f6",selectionBackground:"rgba(59, 130, 246, 0.08)",frozenBorder:"#a1a1aa"},fonts:{family:"'Inter', -apple-system, BlinkMacSystemFont, sans-serif",size:"13px",headerSize:"11px"}},minimal:{name:"minimal",colors:{background:"#ffffff",foreground:"#27272a",grid:"#f4f4f5",headerBackground:"#ffffff",headerForeground:"#a1a1aa",selectionBorder:"#18181b",selectionBackground:"rgba(24, 24, 27, 0.04)",frozenBorder:"#e4e4e7"},fonts:{family:"'SF Pro Display', -apple-system, BlinkMacSystemFont, sans-serif",size:"13px",headerSize:"11px"}},dark:{name:"dark",colors:{background:"#1e1e1e",foreground:"#d4d4d4",grid:"#3c3c3c",headerBackground:"#252526",headerForeground:"#858585",selectionBorder:"#0078d4",selectionBackground:"rgba(0, 120, 212, 0.2)",frozenBorder:"#4a4a4a"},fonts:{family:"-apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif",size:"13px",headerSize:"11px"}},midnight:{name:"midnight",colors:{background:"#0d1117",foreground:"#c9d1d9",grid:"#21262d",headerBackground:"#161b22",headerForeground:"#8b949e",selectionBorder:"#58a6ff",selectionBackground:"rgba(88, 166, 255, 0.15)",frozenBorder:"#30363d"},fonts:{family:"-apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif",size:"13px",headerSize:"11px"}},accessible:{name:"accessible",colors:{background:"#ffffff",foreground:"#000000",grid:"#000000",headerBackground:"#e6e6e6",headerForeground:"#000000",selectionBorder:"#0000ff",selectionBackground:"rgba(0, 0, 255, 0.15)",frozenBorder:"#000000"},fonts:{family:"Arial, Helvetica, sans-serif",size:"14px",headerSize:"12px"}}};function nt(p){return _[p]??_.default}function Re(p,e){let t=p.style;t.setProperty("--nup-background",e.colors.background),t.setProperty("--nup-foreground",e.colors.foreground),t.setProperty("--nup-grid",e.colors.grid),t.setProperty("--nup-header-bg",e.colors.headerBackground),t.setProperty("--nup-header-fg",e.colors.headerForeground),t.setProperty("--nup-selection-border",e.colors.selectionBorder),t.setProperty("--nup-selection-bg",e.colors.selectionBackground),t.setProperty("--nup-frozen-border",e.colors.frozenBorder),t.setProperty("--nup-font-family",e.fonts.family),t.setProperty("--nup-font-size",e.fonts.size);}function Se(p){return `nup-theme-${p}`}var at=forwardRef(function(e,t){let{workbook:o,activeSheet:l=0,theme:s="default",width:h="100%",height:g="400px",className:f="",style:m={},showHeaders:y=true,showGridLines:v=true,showSheetTabs:T=true,selectable:me=true,resizable:ee=true,searchable:Ve=false,copyable:De=true,keyboardNavigation:Fe=true,frozenRows:Me=0,frozenCols:Te=0,overscan:He=5,defaultRowHeight:ke=24,defaultColWidth:ze=100,ariaLabel:Oe="Spreadsheet",onCellClick:Pe,onCellDoubleClick:$e,onCellRightClick:ge,onSelectionChange:Ne,onSheetChange:Ie,onColumnResize:We,onScroll:be,onSearch:Q,onCopy:V}=e,O=useRef(null),$=useRef(null),[A,z]=useState(l),[B,q]=useState({top:0,left:0}),[H,M]=useState({width:0,height:0}),[S,he]=useState(null),[ue,te]=useState([]),[we,ve]=useState(""),[Ce,U]=useState(0),w=o.sheets[A]??o.sheets[0],Ee=useMemo(()=>typeof s=="string"?_[s]??_.default:s,[s]),R=useMemo(()=>{let r={},n={};return Object.entries(w.rows).forEach(([d,b])=>{b.h&&(r[parseInt(d)]=b.h);}),Object.entries(w.cols).forEach(([d,b])=>{b.w&&(n[parseInt(d)]=b.w);}),new oe({rows:w.rowCount,cols:w.colCount,rowHeights:r,colWidths:n,defaultRowHeight:ke,defaultColWidth:ze,overscan:He,frozenRows:Me,frozenCols:Te})},[w,ke,ze,He,Me,Te,Ce]),x=useMemo(()=>new re(w,r=>{he(r),Ne?.(r);}),[w,Ne]),G=useMemo(()=>new se(w.merges??[]),[w.merges]),P=useMemo(()=>new ie(w),[w]),D=useMemo(()=>new le,[]),Y=useMemo(()=>new ae(R,(r,n)=>{U(d=>d+1),We?.(r,n);}),[R,We]),ye=useMemo(()=>new ne(x,R,{enabled:Fe},{onScroll:(r,n)=>{let d=R.getScrollToPosition(r,n,H.height,H.width);$.current?.scrollTo({top:d.scrollTop,left:d.scrollLeft,behavior:"smooth"});},onCopy:async()=>{let r=x.getSelection();if(r&&De){let n=await D.copyToClipboard(r);V?.(n);}}}),[x,R,Fe,De,H,D,V]);useLayoutEffect(()=>{let r=$.current;if(!r)return;let n=new ResizeObserver(d=>{let b=d[0];b&&M({width:b.contentRect.width,height:b.contentRect.height});});return n.observe(r),M({width:r.clientWidth,height:r.clientHeight}),()=>n.disconnect()},[]),useEffect(()=>{O.current&&Re(O.current,Ee);},[Ee]),useEffect(()=>{z(l);},[l]);let N=useCallback(r=>{let{scrollTop:n,scrollLeft:d}=r.currentTarget;q({top:n,left:d});let b=R.getVisibleRange(n,d,H.height,H.width);be?.({scrollTop:n,scrollLeft:d,visibleRows:{start:b.startRow,end:b.endRow},visibleCols:{start:b.startCol,end:b.endCol}});},[R,H,be]),Ue=useCallback((r,n,d)=>{if(!me)return;let b=E(r,n),I=w.cells[b]??null;x.handleClick(r,n,{shiftKey:d.shiftKey,ctrlKey:d.ctrlKey,metaKey:d.metaKey}),Pe?.({cell:I,row:r,col:n,cellRef:b,originalEvent:d.nativeEvent});},[me,w,x,Pe]),i=useCallback((r,n,d)=>{let b=E(r,n),I=w.cells[b]??null;$e?.({cell:I,row:r,col:n,cellRef:b,originalEvent:d.nativeEvent});},[w,$e]),c=useCallback((r,n,d)=>{d.preventDefault();let b=E(r,n),I=w.cells[b]??null;ge?.({cell:I,row:r,col:n,cellRef:b,originalEvent:d.nativeEvent});},[w,ge]),C=useCallback(r=>{ye.handleKeyDown(r.nativeEvent);},[ye]),u=useCallback(r=>{z(r),x.clear(),Ie?.(r);},[x,Ie]),a=useCallback(r=>{ve(r);let n=P.search(r);te(n),Q?.(n);},[P,Q]),k=useCallback((r,n)=>{ee&&(n.preventDefault(),n.stopPropagation(),Y.startResize(r,n.clientX));},[ee,Y]);useImperativeHandle(t,()=>({scrollTo:(r,n)=>{let d=R.getScrollToPosition(r,n,H.height,H.width);$.current?.scrollTo({top:d.scrollTop,left:d.scrollLeft,behavior:"smooth"});},scrollToCell:r=>{let n=W(r);if(n){let d=R.getScrollToPosition(n.row,n.col,H.height,H.width);$.current?.scrollTo({top:d.scrollTop,left:d.scrollLeft,behavior:"smooth"});}},select:r=>{he(r);},selectCell:r=>{x.selectCell(r);},selectAll:()=>{x.selectAll();},clearSelection:()=>{x.clear();},getSelection:()=>S,setActiveSheet:u,getActiveSheet:()=>A,search:r=>(a(r),P.getResults()),highlightResults:r=>{te(r);},clearHighlights:()=>{te([]),ve("");},getWorkbook:()=>o,getVisibleCells:()=>{let r=R.getVisibleRange(B.top,B.left,H.height,H.width),n=[];for(let d=r.startRow;d<=r.endRow;d++){let b=[];for(let I=r.startCol;I<=r.endCol;I++)b.push(w.cells[E(d,I)]??null);n.push(b);}return n},getCellAt:(r,n)=>w.cells[E(r,n)]??null,copySelection:async()=>{let r=x.getSelection();if(r){let n=await D.copyToClipboard(r);V?.(n);}},setColumnWidth:(r,n)=>{R.setColWidth(r,n),U(d=>d+1);},autoFitColumn:()=>{},autoFitAllColumns:()=>{},refresh:()=>U(r=>r+1),destroy:()=>{Y.destroy();}}),[R,H,x,P,D,u,a,A,S,o,w,B,Y,V]);let K=y?24:0,F=y?40:0,j=R.getVisibleRange(B.top,B.left,H.height,H.width),Le=[];for(let r=j.startRow;r<=j.endRow;r++)for(let n=j.startCol;n<=j.endCol;n++){if(G.isMergeHidden(r,n))continue;let d=G.getMergeRect(r,n,(X,et)=>R.getCellRect(X,et))??R.getCellRect(r,n),b=E(r,n),I=w.cells[b],Ye=x.isCellSelected(r,n),je=x.isAnchor(r,n),Ze=ue.some(X=>X.row===r&&X.col===n),Je=P.isCurrent(r,n),pe="nup-cell";I?.t==="n"&&(pe+=" nup-cell-number"),Ye&&(pe+=" nup-cell-selected"),je&&(pe+=" nup-cell-anchor"),Ze&&(pe+=" nup-cell-search-result"),Je&&(pe+=" nup-cell-search-current"),Le.push(jsx("div",{className:pe,style:{top:d.top,left:d.left,width:d.width,height:d.height},onClick:X=>Ue(r,n,X),onDoubleClick:X=>i(r,n,X),onContextMenu:X=>c(r,n,X),"data-row":r,"data-col":n,"data-cell-ref":b,role:"gridcell","aria-rowindex":r+1,"aria-colindex":n+1,tabIndex:je?0:-1,children:I?.v!==void 0&&I?.v!==null?String(I.v):""},`${r}-${n}`));}let Ae=[];if(y)for(let r=j.startCol;r<=j.endCol;r++){let n=R.getCellRect(0,r),d=S&&r>=S.start.col&&r<=S.end.col;Ae.push(jsxs("div",{className:`nup-header nup-header-col${d?" nup-header-selected":""}`,style:{left:n.left,width:n.width,height:K},children:[fe(r),ee&&jsx("div",{className:"nup-resize-handle",onMouseDown:b=>k(r,b)})]},`ch-${r}`));}let Ke=[];if(y)for(let r=j.startRow;r<=j.endRow;r++){let n=R.getCellRect(r,0),d=S&&r>=S.start.row&&r<=S.end.row;Ke.push(jsx("div",{className:`nup-header nup-header-row${d?" nup-header-selected":""}`,style:{top:n.top,width:F,height:n.height},children:r+1},`rh-${r}`));}let Be=null;if(S){let r=R.getCellRect(S.start.row,S.start.col),n=R.getCellRect(S.end.row,S.end.col);Be=jsx("div",{className:"nup-selection-border",style:{top:r.top,left:r.left,width:n.left+n.width-r.left,height:n.top+n.height-r.top}});}let de=typeof s=="string"?Se(s):"";return jsxs("div",{ref:O,className:`nup-spreadsheet ${de} ${f} ${v?"":"nup-no-gridlines"}`,style:{width:h,height:g,...m},tabIndex:0,onKeyDown:C,role:"grid","aria-label":Oe,"aria-rowcount":w.rowCount,"aria-colcount":w.colCount,children:[Ve&&jsxs("div",{className:"nup-search-bar",children:[jsx("input",{type:"search",className:"nup-search-input",placeholder:"Search...",value:we,onChange:r=>a(r.target.value),"aria-label":"Search in spreadsheet"}),ue.length>0&&jsxs("span",{className:"nup-search-count",children:[P.getCurrentIndex()," of ",ue.length]}),jsx("button",{className:"nup-search-btn",onClick:()=>{let r=P.next();if(r){let n=R.getScrollToPosition(r.row,r.col,H.height,H.width);$.current?.scrollTo({top:n.scrollTop,left:n.scrollLeft,behavior:"smooth"});}},"aria-label":"Next result",children:"Next"})]}),y&&jsx("div",{className:"nup-corner",style:{width:F,height:K}}),y&&jsx("div",{className:"nup-header-row-container",style:{position:"absolute",top:0,left:F,right:0,height:K,overflow:"hidden"},children:jsx("div",{style:{position:"relative",width:R.totalWidth,height:K,transform:`translateX(${-B.left}px)`},children:Ae})}),y&&jsx("div",{className:"nup-header-col-container",style:{position:"absolute",top:K,left:0,bottom:T?32:0,width:F,overflow:"hidden"},children:jsx("div",{style:{position:"relative",width:F,height:R.totalHeight,transform:`translateY(${-B.top}px)`},children:Ke})}),jsx("div",{ref:$,className:"nup-scroll-container",style:{top:K,left:F,right:0,bottom:T?32:0},onScroll:N,children:jsxs("div",{className:"nup-content",style:{width:R.totalWidth,height:R.totalHeight},children:[Le,Be]})}),T&&o.sheets.length>1&&jsx("div",{className:"nup-sheet-tabs",children:o.sheets.map((r,n)=>jsx("button",{className:`nup-sheet-tab${n===A?" nup-sheet-tab-active":""}`,onClick:()=>u(n),children:r.name},r.id))})]})});function Qe(p,e){let t=typeof p=="string"?document.querySelector(p):p;if(!t)throw new Error("Container element not found");let{workbook:o,activeSheet:l=0,theme:s="default",width:h="100%",height:g="400px",showHeaders:f=true,showGridLines:m=true,showSheetTabs:y=true,selectable:v=true,resizable:T=true,searchable:me=false,copyable:ee=true,keyboardNavigation:Ve=true,frozenRows:De=0,frozenCols:Fe=0,overscan:Me=5,defaultRowHeight:Te=24,defaultColWidth:He=100,ariaLabel:ke="Spreadsheet",onCellClick:ze,onCellDoubleClick:Oe,onCellRightClick:Pe,onSelectionChange:$e,onSheetChange:ge,onColumnResize:Ne,onScroll:Ie,onSearch:We,onCopy:be}=e,Q=l,V=0,O=0,$=0,A=0,z=null,B=[],q=()=>o.sheets[Q]??o.sheets[0],H=()=>typeof s=="string"?_[s]??_.default:s,M,S,he,ue,te,we,ve,Ce=()=>{let i=q(),c={},C={};Object.entries(i.rows).forEach(([u,a])=>{a.h&&(c[parseInt(u)]=a.h);}),Object.entries(i.cols).forEach(([u,a])=>{a.w&&(C[parseInt(u)]=a.w);}),M=new oe({rows:i.rowCount,cols:i.colCount,rowHeights:c,colWidths:C,defaultRowHeight:Te,defaultColWidth:He,overscan:Me}),S=new re(i,u=>{z=u,$e?.(u),N();}),he=new se(i.merges??[]),ue=new ie(i),te=new le,we=new ae(M,(u,a)=>{Ne?.(u,a),N();}),ve=new ne(S,M,{enabled:Ve},{onScroll:(u,a)=>{let k=M.getScrollToPosition(u,a,A,$);x?.scrollTo({top:k.scrollTop,left:k.scrollLeft,behavior:"smooth"});},onCopy:async()=>{let u=S.getSelection();if(u&&ee){let a=await te.copyToClipboard(u);be?.(a);}}});},U=f?24:0,w=f?40:0,Ee=typeof s=="string"?Se(s):"";t.innerHTML=`
|
|
9
|
+
`.trim();return {text:s,html:h,cells:t}}getCellValue(e){return !e||e.v===void 0||e.v===null?"":String(e.v)}getCellStyle(e){let t=["border: 1px solid #ccc","padding: 4px 8px"];return e?.t==="n"&&t.push("text-align: right"),t.join("; ")}escapeHtml(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}async copyWithExecCommand(e){let t=document.createElement("textarea");t.value=e,t.style.position="fixed",t.style.left="-9999px",document.body.appendChild(t),t.select();try{document.execCommand("copy");}finally{document.body.removeChild(t);}}};var ie=class{sheet;results;currentIndex;constructor(e){this.sheet=e,this.results=[],this.currentIndex=-1;}search(e,t={}){if(!e)return this.results=[],this.currentIndex=-1,[];let{caseSensitive:o=false,regex:s=false,matchWholeCell:l=false}=t,h;try{if(s)h=new RegExp(e,o?"g":"gi");else {let f=e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),m=l?`^${f}$`:f;h=new RegExp(m,o?"g":"gi");}}catch{let f=e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");h=new RegExp(f,o?"g":"gi");}let g=[];for(let[f,m]of Object.entries(this.sheet.cells)){if(m.v===void 0||m.v===null)continue;let S=String(m.v);h.lastIndex=0;let v=h.exec(S);if(v){let T=this.parseCellRef(f);T&&g.push({row:T.row,col:T.col,cellRef:f,value:S,matchStart:v.index,matchEnd:v.index+v[0].length});}}return g.sort((f,m)=>f.row!==m.row?f.row-m.row:f.col-m.col),this.results=g,this.currentIndex=g.length>0?0:-1,g}next(){return this.results.length===0?null:(this.currentIndex=(this.currentIndex+1)%this.results.length,this.results[this.currentIndex])}previous(){return this.results.length===0?null:(this.currentIndex=(this.currentIndex-1+this.results.length)%this.results.length,this.results[this.currentIndex])}current(){return this.currentIndex<0||this.currentIndex>=this.results.length?null:this.results[this.currentIndex]}getResults(){return [...this.results]}getCount(){return this.results.length}getCurrentIndex(){return this.currentIndex+1}isResult(e,t){return this.results.some(o=>o.row===e&&o.col===t)}isCurrent(e,t){let o=this.current();return o?.row===e&&o?.col===t}clear(){this.results=[],this.currentIndex=-1;}setSheet(e){this.sheet=e,this.clear();}parseCellRef(e){let t=e.match(/^([A-Z]+)(\d+)$/i);if(!t)return null;let o=t[1].toUpperCase(),s=parseInt(t[2],10)-1,l=0;for(let h=0;h<o.length;h++)l=l*26+(o.charCodeAt(h)-64);return l-=1,{row:s,col:l}}};var ae=class{state=null;virtualScroll;onChange;minWidth;maxWidth;constructor(e,t,o=30,s=500){this.virtualScroll=e,this.onChange=t??null,this.minWidth=o,this.maxWidth=s;}startResize(e,t){let o=this.virtualScroll.getColWidth(e);this.state={isResizing:true,colIndex:e,startX:t,startWidth:o},document.addEventListener("mousemove",this.handleMouseMove),document.addEventListener("mouseup",this.handleMouseUp),document.body.style.cursor="col-resize",document.body.style.userSelect="none";}handleMouseMove=e=>{if(!this.state)return;let t=e.clientX-this.state.startX,o=Math.min(this.maxWidth,Math.max(this.minWidth,this.state.startWidth+t));this.virtualScroll.setColWidth(this.state.colIndex,o),this.onChange?.(this.state.colIndex,o);};handleMouseUp=()=>{this.cleanup();};isResizing(){return this.state?.isResizing??false}getResizeColumn(){return this.state?.colIndex??null}cancel(){this.state&&(this.virtualScroll.setColWidth(this.state.colIndex,this.state.startWidth),this.onChange?.(this.state.colIndex,this.state.startWidth)),this.cleanup();}cleanup(){document.removeEventListener("mousemove",this.handleMouseMove),document.removeEventListener("mouseup",this.handleMouseUp),document.body.style.cursor="",document.body.style.userSelect="",this.state=null;}setVirtualScroll(e){this.virtualScroll=e;}destroy(){this.cleanup();}};var G={default:{name:"default",colors:{background:"#ffffff",foreground:"#202124",grid:"#e0e0e0",headerBackground:"#f8f9fa",headerForeground:"#5f6368",selectionBorder:"#1a73e8",selectionBackground:"rgba(26, 115, 232, 0.08)",frozenBorder:"#dadce0"},fonts:{family:"'Google Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif",size:"13px",headerSize:"11px"}},excel:{name:"excel",colors:{background:"#ffffff",foreground:"#000000",grid:"#d4d4d4",headerBackground:"#f0f0f0",headerForeground:"#000000",selectionBorder:"#217346",selectionBackground:"rgba(33, 115, 70, 0.1)",frozenBorder:"#9bc2e6"},fonts:{family:"'Calibri', 'Segoe UI', sans-serif",size:"11px",headerSize:"11px"}},modern:{name:"modern",colors:{background:"#fafafa",foreground:"#18181b",grid:"#e4e4e7",headerBackground:"#f4f4f5",headerForeground:"#71717a",selectionBorder:"#3b82f6",selectionBackground:"rgba(59, 130, 246, 0.08)",frozenBorder:"#a1a1aa"},fonts:{family:"'Inter', -apple-system, BlinkMacSystemFont, sans-serif",size:"13px",headerSize:"11px"}},minimal:{name:"minimal",colors:{background:"#ffffff",foreground:"#27272a",grid:"#f4f4f5",headerBackground:"#ffffff",headerForeground:"#a1a1aa",selectionBorder:"#18181b",selectionBackground:"rgba(24, 24, 27, 0.04)",frozenBorder:"#e4e4e7"},fonts:{family:"'SF Pro Display', -apple-system, BlinkMacSystemFont, sans-serif",size:"13px",headerSize:"11px"}},dark:{name:"dark",colors:{background:"#1e1e1e",foreground:"#d4d4d4",grid:"#3c3c3c",headerBackground:"#252526",headerForeground:"#858585",selectionBorder:"#0078d4",selectionBackground:"rgba(0, 120, 212, 0.2)",frozenBorder:"#4a4a4a"},fonts:{family:"-apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif",size:"13px",headerSize:"11px"}},midnight:{name:"midnight",colors:{background:"#0d1117",foreground:"#c9d1d9",grid:"#21262d",headerBackground:"#161b22",headerForeground:"#8b949e",selectionBorder:"#58a6ff",selectionBackground:"rgba(88, 166, 255, 0.15)",frozenBorder:"#30363d"},fonts:{family:"-apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif",size:"13px",headerSize:"11px"}},accessible:{name:"accessible",colors:{background:"#ffffff",foreground:"#000000",grid:"#000000",headerBackground:"#e6e6e6",headerForeground:"#000000",selectionBorder:"#0000ff",selectionBackground:"rgba(0, 0, 255, 0.15)",frozenBorder:"#000000"},fonts:{family:"Arial, Helvetica, sans-serif",size:"14px",headerSize:"12px"}}};function lt(i){return G[i]??G.default}function ye(i,e){let t=i.style;t.setProperty("--nup-background",e.colors.background),t.setProperty("--nup-foreground",e.colors.foreground),t.setProperty("--nup-grid",e.colors.grid),t.setProperty("--nup-header-bg",e.colors.headerBackground),t.setProperty("--nup-header-fg",e.colors.headerForeground),t.setProperty("--nup-selection-border",e.colors.selectionBorder),t.setProperty("--nup-selection-bg",e.colors.selectionBackground),t.setProperty("--nup-frozen-border",e.colors.frozenBorder),t.setProperty("--nup-font-family",e.fonts.family),t.setProperty("--nup-font-size",e.fonts.size);}function Re(i){return `nup-theme-${i}`}var it={thin:"1px solid",medium:"2px solid",thick:"3px solid",dashed:"1px dashed",dotted:"1px dotted",double:"3px double"};function Ve(i){if(!i||!i.style)return;let e=it[i.style]||"1px solid",t=i.color||"#000000";return `${e} ${t}`}function at(i,e){let t=i.replace("#",""),o=parseInt(t.substring(0,2),16),s=parseInt(t.substring(2,4),16),l=parseInt(t.substring(4,6),16),h,g,f;return e<0?(h=Math.round(o*(1+e)),g=Math.round(s*(1+e)),f=Math.round(l*(1+e))):(h=Math.round(o+(255-o)*e),g=Math.round(s+(255-s)*e),f=Math.round(l+(255-l)*e)),`#${h.toString(16).padStart(2,"0")}${g.toString(16).padStart(2,"0")}${f.toString(16).padStart(2,"0")}`}function ct(i){if(!i)return {};let e={};if(i.font){let t=i.font;t.name&&(e.fontFamily=t.name),t.size&&(e.fontSize=`${t.size}pt`),t.bold&&(e.fontWeight="bold"),t.italic&&(e.fontStyle="italic"),t.color&&(e.color=t.color);let o=[];t.underline&&o.push("underline"),t.strike&&o.push("line-through"),o.length>0&&(e.textDecoration=o.join(" "));}if(i.fill){let t=i.fill;if(t.color){let o=t.color;t.tint!==void 0&&t.tint!==0&&(o=at(o,t.tint)),e.backgroundColor=o;}}if(i.alignment){let t=i.alignment;t.horizontal&&(e.textAlign=t.horizontal),t.vertical&&(e.verticalAlign=t.vertical==="middle"?"middle":t.vertical),t.wrapText&&(e.whiteSpace="pre-wrap"),t.indent&&(e.paddingLeft=`${t.indent*8}px`),t.rotation&&(e.transform=`rotate(${t.rotation}deg)`);}if(i.border){let t=i.border;e.borderTop=Ve(t.top),e.borderRight=Ve(t.right),e.borderBottom=Ve(t.bottom),e.borderLeft=Ve(t.left);}return e}function ht(i){let e=Object.entries(i).filter(([,t])=>t!==void 0);return e.length===0?"":e.map(([t,o])=>`${t.replace(/([A-Z])/g,"-$1").toLowerCase()}: ${o}`).join("; ")}function _e(i,e){if(i!==void 0&&e.styles)return e.styles[i]??e.styles[String(i)]}function ut(i,e,t){let o=t?_e(e,t):void 0;if(!(!i&&!o))return i?o?{...o,...i,font:{...o.font,...i.font},fill:{...o.fill,...i.fill},border:{...o.border,...i.border},alignment:{...o.alignment,...i.alignment}}:i:o}var gt=forwardRef(function(e,t){let{workbook:o,activeSheet:s=0,theme:l="default",width:h="100%",height:g="400px",className:f="",style:m={},showHeaders:S=true,showGridLines:v=true,showSheetTabs:T=true,selectable:ge=true,resizable:ee=true,searchable:Fe=false,copyable:De=true,keyboardNavigation:Oe=true,frozenRows:Me=0,frozenCols:Te=0,overscan:ke=5,defaultRowHeight:He=24,defaultColWidth:ze=100,ariaLabel:Ue="Spreadsheet",onCellClick:Pe,onCellDoubleClick:Ne,onCellRightClick:me,onSelectionChange:$e,onSheetChange:We,onColumnResize:Ie,onScroll:be,onSearch:Y,onCopy:V}=e,O=useRef(null),N=useRef(null),[A,z]=useState(s),[K,q]=useState({top:0,left:0}),[k,M]=useState({width:0,height:0}),[R,he]=useState(null),[ue,te]=useState([]),[we,ve]=useState(""),[Ce,U]=useState(0),w=o.sheets[A]??o.sheets[0],Ee=useMemo(()=>typeof l=="string"?G[l]??G.default:l,[l]),y=useMemo(()=>{let r={},n={};return Object.entries(w.rows).forEach(([p,b])=>{b.h&&(r[parseInt(p)]=b.h);}),Object.entries(w.cols).forEach(([p,b])=>{b.w&&(n[parseInt(p)]=b.w);}),new oe({rows:w.rowCount,cols:w.colCount,rowHeights:r,colWidths:n,defaultRowHeight:He,defaultColWidth:ze,overscan:ke,frozenRows:Me,frozenCols:Te})},[w,He,ze,ke,Me,Te,Ce]),x=useMemo(()=>new re(w,r=>{he(r),$e?.(r);}),[w,$e]),_=useMemo(()=>new se(w.merges??[]),[w.merges]),P=useMemo(()=>new ie(w),[w]),F=useMemo(()=>new le,[]),Z=useMemo(()=>new ae(y,(r,n)=>{U(p=>p+1),Ie?.(r,n);}),[y,Ie]),Se=useMemo(()=>new ne(x,y,{enabled:Oe},{onScroll:(r,n)=>{let p=y.getScrollToPosition(r,n,k.height,k.width);N.current?.scrollTo({top:p.scrollTop,left:p.scrollLeft,behavior:"smooth"});},onCopy:async()=>{let r=x.getSelection();if(r&&De){let n=await F.copyToClipboard(r);V?.(n);}}}),[x,y,Oe,De,k,F,V]);useLayoutEffect(()=>{let r=N.current;if(!r)return;let n=new ResizeObserver(p=>{let b=p[0];b&&M({width:b.contentRect.width,height:b.contentRect.height});});return n.observe(r),M({width:r.clientWidth,height:r.clientHeight}),()=>n.disconnect()},[]),useEffect(()=>{O.current&&ye(O.current,Ee);},[Ee]),useEffect(()=>{z(s);},[s]);let $=useCallback(r=>{let{scrollTop:n,scrollLeft:p}=r.currentTarget;q({top:n,left:p});let b=y.getVisibleRange(n,p,k.height,k.width);be?.({scrollTop:n,scrollLeft:p,visibleRows:{start:b.startRow,end:b.endRow},visibleCols:{start:b.startCol,end:b.endCol}});},[y,k,be]),je=useCallback((r,n,p)=>{if(!ge)return;let b=E(r,n),W=w.cells[b]??null;x.handleClick(r,n,{shiftKey:p.shiftKey,ctrlKey:p.ctrlKey,metaKey:p.metaKey}),Pe?.({cell:W,row:r,col:n,cellRef:b,originalEvent:p.nativeEvent});},[ge,w,x,Pe]),a=useCallback((r,n,p)=>{let b=E(r,n),W=w.cells[b]??null;Ne?.({cell:W,row:r,col:n,cellRef:b,originalEvent:p.nativeEvent});},[w,Ne]),u=useCallback((r,n,p)=>{p.preventDefault();let b=E(r,n),W=w.cells[b]??null;me?.({cell:W,row:r,col:n,cellRef:b,originalEvent:p.nativeEvent});},[w,me]),C=useCallback(r=>{Se.handleKeyDown(r.nativeEvent);},[Se]),d=useCallback(r=>{z(r),x.clear(),We?.(r);},[x,We]),c=useCallback(r=>{ve(r);let n=P.search(r);te(n),Y?.(n);},[P,Y]),H=useCallback((r,n)=>{ee&&(n.preventDefault(),n.stopPropagation(),Z.startResize(r,n.clientX));},[ee,Z]);useImperativeHandle(t,()=>({scrollTo:(r,n)=>{let p=y.getScrollToPosition(r,n,k.height,k.width);N.current?.scrollTo({top:p.scrollTop,left:p.scrollLeft,behavior:"smooth"});},scrollToCell:r=>{let n=I(r);if(n){let p=y.getScrollToPosition(n.row,n.col,k.height,k.width);N.current?.scrollTo({top:p.scrollTop,left:p.scrollLeft,behavior:"smooth"});}},select:r=>{he(r);},selectCell:r=>{x.selectCell(r);},selectAll:()=>{x.selectAll();},clearSelection:()=>{x.clear();},getSelection:()=>R,setActiveSheet:d,getActiveSheet:()=>A,search:r=>(c(r),P.getResults()),highlightResults:r=>{te(r);},clearHighlights:()=>{te([]),ve("");},getWorkbook:()=>o,getVisibleCells:()=>{let r=y.getVisibleRange(K.top,K.left,k.height,k.width),n=[];for(let p=r.startRow;p<=r.endRow;p++){let b=[];for(let W=r.startCol;W<=r.endCol;W++)b.push(w.cells[E(p,W)]??null);n.push(b);}return n},getCellAt:(r,n)=>w.cells[E(r,n)]??null,copySelection:async()=>{let r=x.getSelection();if(r){let n=await F.copyToClipboard(r);V?.(n);}},setColumnWidth:(r,n)=>{y.setColWidth(r,n),U(p=>p+1);},autoFitColumn:()=>{},autoFitAllColumns:()=>{},refresh:()=>U(r=>r+1),destroy:()=>{Z.destroy();}}),[y,k,x,P,F,d,c,A,R,o,w,K,Z,V]);let B=S?24:0,D=S?40:0,j=y.getVisibleRange(K.top,K.left,k.height,k.width),Le=[];for(let r=j.startRow;r<=j.endRow;r++)for(let n=j.startCol;n<=j.endCol;n++){if(_.isMergeHidden(r,n))continue;let p=_.getMergeRect(r,n,(X,ot)=>y.getCellRect(X,ot))??y.getCellRect(r,n),b=E(r,n),W=w.cells[b],Je=x.isCellSelected(r,n),Xe=x.isAnchor(r,n),et=ue.some(X=>X.row===r&&X.col===n),tt=P.isCurrent(r,n),pe="nup-cell";W?.t==="n"&&(pe+=" nup-cell-number"),Je&&(pe+=" nup-cell-selected"),Xe&&(pe+=" nup-cell-anchor"),et&&(pe+=" nup-cell-search-result"),tt&&(pe+=" nup-cell-search-current"),Le.push(jsx("div",{className:pe,style:{top:p.top,left:p.left,width:p.width,height:p.height},onClick:X=>je(r,n,X),onDoubleClick:X=>a(r,n,X),onContextMenu:X=>u(r,n,X),"data-row":r,"data-col":n,"data-cell-ref":b,role:"gridcell","aria-rowindex":r+1,"aria-colindex":n+1,tabIndex:Xe?0:-1,children:W?.v!==void 0&&W?.v!==null?String(W.v):""},`${r}-${n}`));}let Ae=[];if(S)for(let r=j.startCol;r<=j.endCol;r++){let n=y.getCellRect(0,r),p=R&&r>=R.start.col&&r<=R.end.col;Ae.push(jsxs("div",{className:`nup-header nup-header-col${p?" nup-header-selected":""}`,style:{left:n.left,width:n.width,height:B},children:[fe(r),ee&&jsx("div",{className:"nup-resize-handle",onMouseDown:b=>H(r,b)})]},`ch-${r}`));}let Be=[];if(S)for(let r=j.startRow;r<=j.endRow;r++){let n=y.getCellRect(r,0),p=R&&r>=R.start.row&&r<=R.end.row;Be.push(jsx("div",{className:`nup-header nup-header-row${p?" nup-header-selected":""}`,style:{top:n.top,width:D,height:n.height},children:r+1},`rh-${r}`));}let Ke=null;if(R){let r=y.getCellRect(R.start.row,R.start.col),n=y.getCellRect(R.end.row,R.end.col);Ke=jsx("div",{className:"nup-selection-border",style:{top:r.top,left:r.left,width:n.left+n.width-r.left,height:n.top+n.height-r.top}});}let de=typeof l=="string"?Re(l):"";return jsxs("div",{ref:O,className:`nup-spreadsheet ${de} ${f} ${v?"":"nup-no-gridlines"}`,style:{width:h,height:g,...m},tabIndex:0,onKeyDown:C,role:"grid","aria-label":Ue,"aria-rowcount":w.rowCount,"aria-colcount":w.colCount,children:[Fe&&jsxs("div",{className:"nup-search-bar",children:[jsx("input",{type:"search",className:"nup-search-input",placeholder:"Search...",value:we,onChange:r=>c(r.target.value),"aria-label":"Search in spreadsheet"}),ue.length>0&&jsxs("span",{className:"nup-search-count",children:[P.getCurrentIndex()," of ",ue.length]}),jsx("button",{className:"nup-search-btn",onClick:()=>{let r=P.next();if(r){let n=y.getScrollToPosition(r.row,r.col,k.height,k.width);N.current?.scrollTo({top:n.scrollTop,left:n.scrollLeft,behavior:"smooth"});}},"aria-label":"Next result",children:"Next"})]}),S&&jsx("div",{className:"nup-corner",style:{width:D,height:B}}),S&&jsx("div",{className:"nup-header-row-container",style:{position:"absolute",top:0,left:D,right:0,height:B,overflow:"hidden"},children:jsx("div",{style:{position:"relative",width:y.totalWidth,height:B,transform:`translateX(${-K.left}px)`},children:Ae})}),S&&jsx("div",{className:"nup-header-col-container",style:{position:"absolute",top:B,left:0,bottom:T?32:0,width:D,overflow:"hidden"},children:jsx("div",{style:{position:"relative",width:D,height:y.totalHeight,transform:`translateY(${-K.top}px)`},children:Be})}),jsx("div",{ref:N,className:"nup-scroll-container",style:{top:B,left:D,right:0,bottom:T?32:0},onScroll:$,children:jsxs("div",{className:"nup-content",style:{width:y.totalWidth,height:y.totalHeight},children:[Le,Ke]})}),T&&o.sheets.length>1&&jsx("div",{className:"nup-sheet-tabs",children:o.sheets.map((r,n)=>jsx("button",{className:`nup-sheet-tab${n===A?" nup-sheet-tab-active":""}`,onClick:()=>d(n),children:r.name},r.id))})]})});function Qe(i,e){let t=typeof i=="string"?document.querySelector(i):i;if(!t)throw new Error("Container element not found");let{workbook:o,activeSheet:s=0,theme:l="default",width:h="100%",height:g="400px",showHeaders:f=true,showGridLines:m=true,showSheetTabs:S=true,selectable:v=true,resizable:T=true,searchable:ge=false,copyable:ee=true,keyboardNavigation:Fe=true,frozenRows:De=0,frozenCols:Oe=0,overscan:Me=5,defaultRowHeight:Te=24,defaultColWidth:ke=100,ariaLabel:He="Spreadsheet",onCellClick:ze,onCellDoubleClick:Ue,onCellRightClick:Pe,onSelectionChange:Ne,onSheetChange:me,onColumnResize:$e,onScroll:We,onSearch:Ie,onCopy:be}=e,Y=s,V=0,O=0,N=0,A=0,z=null,K=[],q=()=>o.sheets[Y]??o.sheets[0],k=()=>typeof l=="string"?G[l]??G.default:l,M,R,he,ue,te,we,ve,Ce=()=>{let a=q(),u={},C={};Object.entries(a.rows).forEach(([d,c])=>{c.h&&(u[parseInt(d)]=c.h);}),Object.entries(a.cols).forEach(([d,c])=>{c.w&&(C[parseInt(d)]=c.w);}),M=new oe({rows:a.rowCount,cols:a.colCount,rowHeights:u,colWidths:C,defaultRowHeight:Te,defaultColWidth:ke,overscan:Me}),R=new re(a,d=>{z=d,Ne?.(d),$();}),he=new se(a.merges??[]),ue=new ie(a),te=new le,we=new ae(M,(d,c)=>{$e?.(d,c),$();}),ve=new ne(R,M,{enabled:Fe},{onScroll:(d,c)=>{let H=M.getScrollToPosition(d,c,A,N);x?.scrollTo({top:H.scrollTop,left:H.scrollLeft,behavior:"smooth"});},onCopy:async()=>{let d=R.getSelection();if(d&&ee){let c=await te.copyToClipboard(d);be?.(c);}}});},U=f?24:0,w=f?40:0,Ee=typeof l=="string"?Re(l):"";t.innerHTML=`
|
|
10
10
|
<div class="nup-spreadsheet ${Ee} ${m?"":"nup-no-gridlines"}"
|
|
11
11
|
style="width: ${typeof h=="number"?h+"px":h}; height: ${typeof g=="number"?g+"px":g};"
|
|
12
12
|
tabindex="0"
|
|
13
13
|
role="grid"
|
|
14
|
-
aria-label="${
|
|
14
|
+
aria-label="${He}">
|
|
15
15
|
${f?`<div class="nup-corner" style="width: ${w}px; height: ${U}px;"></div>`:""}
|
|
16
16
|
${f?`
|
|
17
17
|
<div class="nup-header-row-container" style="position: absolute; top: 0; left: ${w}px; right: 0; height: ${U}px; overflow: hidden;">
|
|
18
18
|
<div class="nup-header-row-inner" style="position: relative; height: ${U}px;"></div>
|
|
19
19
|
</div>
|
|
20
|
-
<div class="nup-header-col-container" style="position: absolute; top: ${U}px; left: 0; bottom: ${
|
|
20
|
+
<div class="nup-header-col-container" style="position: absolute; top: ${U}px; left: 0; bottom: ${S?"32px":"0"}; width: ${w}px; overflow: hidden;">
|
|
21
21
|
<div class="nup-header-col-inner" style="position: relative; width: ${w}px;"></div>
|
|
22
22
|
</div>
|
|
23
23
|
`:""}
|
|
24
|
-
<div class="nup-scroll-container" style="top: ${U}px; left: ${w}px; right: 0; bottom: ${
|
|
24
|
+
<div class="nup-scroll-container" style="top: ${U}px; left: ${w}px; right: 0; bottom: ${S?"32px":"0"};">
|
|
25
25
|
<div class="nup-content"></div>
|
|
26
26
|
</div>
|
|
27
|
-
${
|
|
27
|
+
${S&&o.sheets.length>1?'<div class="nup-sheet-tabs"></div>':""}
|
|
28
28
|
</div>
|
|
29
|
-
`;let
|
|
30
|
-
<div class="${
|
|
31
|
-
style="top: ${
|
|
32
|
-
data-row="${
|
|
33
|
-
${
|
|
29
|
+
`;let y=t.querySelector(".nup-spreadsheet"),x=t.querySelector(".nup-scroll-container"),_=t.querySelector(".nup-content"),P=t.querySelector(".nup-header-row-inner"),F=t.querySelector(".nup-header-col-inner"),Z=t.querySelector(".nup-sheet-tabs");ye(y,k()),Ce();let Se=new ResizeObserver(a=>{let u=a[0];u&&(N=u.contentRect.width,A=u.contentRect.height,$());});Se.observe(x),N=x.clientWidth,A=x.clientHeight,x.addEventListener("scroll",()=>{V=x.scrollTop,O=x.scrollLeft,P&&(P.style.transform=`translateX(${-O}px)`),F&&(F.style.transform=`translateY(${-V}px)`);let a=M.getVisibleRange(V,O,A,N);We?.({scrollTop:V,scrollLeft:O,visibleRows:{start:a.startRow,end:a.endRow},visibleCols:{start:a.startCol,end:a.endCol}}),$();}),y.addEventListener("keydown",a=>{ve.handleKeyDown(a);});let $=()=>{let a=q(),u=M.getVisibleRange(V,O,A,N);_.style.width=`${M.totalWidth}px`,_.style.height=`${M.totalHeight}px`,P&&(P.style.width=`${M.totalWidth}px`),F&&(F.style.height=`${M.totalHeight}px`);let C="";for(let d=u.startRow;d<=u.endRow;d++)for(let c=u.startCol;c<=u.endCol;c++){if(he.isMergeHidden(d,c))continue;let H=he.getMergeRect(d,c,(de,r)=>M.getCellRect(de,r))??M.getCellRect(d,c),B=E(d,c),D=a.cells[B],j=R.isCellSelected(d,c),Le=R.isAnchor(d,c),Ae=K.some(de=>de.row===d&&de.col===c),Be=["nup-cell",D?.t==="n"?"nup-cell-number":"",j?"nup-cell-selected":"",Le?"nup-cell-anchor":"",Ae?"nup-cell-search-result":""].filter(Boolean).join(" "),Ke=D?.v!==void 0&&D?.v!==null?String(D.v):"";C+=`
|
|
30
|
+
<div class="${Be}"
|
|
31
|
+
style="top: ${H.top}px; left: ${H.left}px; width: ${H.width}px; height: ${H.height}px;"
|
|
32
|
+
data-row="${d}" data-col="${c}" data-cell-ref="${B}">
|
|
33
|
+
${Ze(Ke)}
|
|
34
34
|
</div>
|
|
35
|
-
`;}if(z){let
|
|
35
|
+
`;}if(z){let d=M.getCellRect(z.start.row,z.start.col),c=M.getCellRect(z.end.row,z.end.col);C+=`
|
|
36
36
|
<div class="nup-selection-border"
|
|
37
|
-
style="top: ${
|
|
37
|
+
style="top: ${d.top}px; left: ${d.left}px; width: ${c.left+c.width-d.left}px; height: ${c.top+c.height-d.top}px;">
|
|
38
38
|
</div>
|
|
39
|
-
`;}if(
|
|
40
|
-
<div class="nup-header nup-header-col ${
|
|
41
|
-
style="left: ${
|
|
42
|
-
${fe(
|
|
43
|
-
${T?'<div class="nup-resize-handle" data-col="'+
|
|
39
|
+
`;}if(_.innerHTML=C,f&&P){let d="";for(let c=u.startCol;c<=u.endCol;c++){let H=M.getCellRect(0,c),B=z&&c>=z.start.col&&c<=z.end.col;d+=`
|
|
40
|
+
<div class="nup-header nup-header-col ${B?"nup-header-selected":""}"
|
|
41
|
+
style="left: ${H.left}px; width: ${H.width}px; height: ${U}px;">
|
|
42
|
+
${fe(c)}
|
|
43
|
+
${T?'<div class="nup-resize-handle" data-col="'+c+'"></div>':""}
|
|
44
44
|
</div>
|
|
45
|
-
`;}P.innerHTML=
|
|
46
|
-
<div class="nup-header nup-header-row ${
|
|
47
|
-
style="top: ${
|
|
48
|
-
${
|
|
45
|
+
`;}P.innerHTML=d;}if(f&&F){let d="";for(let c=u.startRow;c<=u.endRow;c++){let H=M.getCellRect(c,0),B=z&&c>=z.start.row&&c<=z.end.row;d+=`
|
|
46
|
+
<div class="nup-header nup-header-row ${B?"nup-header-selected":""}"
|
|
47
|
+
style="top: ${H.top}px; width: ${w}px; height: ${H.height}px;">
|
|
48
|
+
${c+1}
|
|
49
49
|
</div>
|
|
50
|
-
`;}
|
|
51
|
-
<button class="nup-sheet-tab ${
|
|
52
|
-
${
|
|
50
|
+
`;}F.innerHTML=d;}Z&&o.sheets.length>1&&(Z.innerHTML=o.sheets.map((d,c)=>`
|
|
51
|
+
<button class="nup-sheet-tab ${c===Y?"nup-sheet-tab-active":""}" data-sheet="${c}">
|
|
52
|
+
${Ze(d.name)}
|
|
53
53
|
</button>
|
|
54
|
-
`).join(""));};return
|
|
54
|
+
`).join(""));};return _.addEventListener("click",a=>{if(!v)return;let u=a.target.closest(".nup-cell");if(!u)return;let C=parseInt(u.dataset.row??"0"),d=parseInt(u.dataset.col??"0"),c=u.dataset.cellRef??"";R.handleClick(C,d,{shiftKey:a.shiftKey,ctrlKey:a.ctrlKey,metaKey:a.metaKey}),ze?.({cell:q().cells[c]??null,row:C,col:d,cellRef:c,originalEvent:a});}),_.addEventListener("dblclick",a=>{let u=a.target.closest(".nup-cell");if(!u)return;let C=parseInt(u.dataset.row??"0"),d=parseInt(u.dataset.col??"0"),c=u.dataset.cellRef??"";Ue?.({cell:q().cells[c]??null,row:C,col:d,cellRef:c,originalEvent:a});}),_.addEventListener("contextmenu",a=>{let u=a.target.closest(".nup-cell");if(!u)return;a.preventDefault();let C=parseInt(u.dataset.row??"0"),d=parseInt(u.dataset.col??"0"),c=u.dataset.cellRef??"";Pe?.({cell:q().cells[c]??null,row:C,col:d,cellRef:c,originalEvent:a});}),Z?.addEventListener("click",a=>{let u=a.target.closest(".nup-sheet-tab");if(!u)return;let C=parseInt(u.dataset.sheet??"0");Y=C,Ce(),me?.(C),$();}),T&&P&&P.addEventListener("mousedown",a=>{let u=a.target.closest(".nup-resize-handle");if(!u)return;let C=parseInt(u.dataset.col??"0");we.startResize(C,a.clientX);}),$(),{scrollTo:(a,u)=>{let C=M.getScrollToPosition(a,u,A,N);x.scrollTo({top:C.scrollTop,left:C.scrollLeft,behavior:"smooth"});},scrollToCell:a=>{let u=I(a);if(u){let C=M.getScrollToPosition(u.row,u.col,A,N);x.scrollTo({top:C.scrollTop,left:C.scrollLeft,behavior:"smooth"});}},select:a=>{z=a,$();},selectCell:a=>{R.selectCell(a);},selectAll:()=>{R.selectAll();},clearSelection:()=>{R.clear();},getSelection:()=>z,setActiveSheet:a=>{Y=a,Ce(),me?.(a),$();},getActiveSheet:()=>Y,search:a=>{let u=ue.search(a);return K=u,Ie?.(u),$(),u},highlightResults:a=>{K=a,$();},clearHighlights:()=>{K=[],$();},getWorkbook:()=>o,getVisibleCells:()=>{let a=q(),u=M.getVisibleRange(V,O,A,N),C=[];for(let d=u.startRow;d<=u.endRow;d++){let c=[];for(let H=u.startCol;H<=u.endCol;H++)c.push(a.cells[E(d,H)]??null);C.push(c);}return C},getCellAt:(a,u)=>q().cells[E(a,u)]??null,copySelection:async()=>{let a=R.getSelection();if(a){let u=await te.copyToClipboard(a);be?.(u);}},setColumnWidth:(a,u)=>{M.setColWidth(a,u),$();},autoFitColumn:()=>{},autoFitAllColumns:()=>{},refresh:()=>$(),destroy:()=>{Se.disconnect(),we.destroy(),t.innerHTML="";}}}function Ze(i){return i.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}export{le as ClipboardHandler,ne as KeyboardHandler,se as MergeHandler,gt as ReactSpreadsheetPreview,ae as ResizeHandler,ie as SearchHandler,re as SelectionHandler,oe as VirtualScroll,ye as applyTheme,I as cellRefToCoords,fe as colIndexToLetter,E as coordsToCellRef,Qe as createSpreadsheetPreview,ht as cssToStyleString,Qe as default,nt as formatCellValue,ut as getCellStyle,lt as getTheme,Re as getThemeClass,st as isFormula,qe as letterToColIndex,rt as parseRange,_e as resolveStyle,ct as styleToCss,G as themes};//# sourceMappingURL=index.js.map
|
|
55
55
|
//# sourceMappingURL=index.js.map
|