@extend-ai/react-xlsx 0.8.1 → 0.8.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/index.cjs +193 -40
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +213 -0
- package/dist/index.d.ts +213 -0
- package/dist/index.js +193 -40
- package/dist/index.js.map +1 -1
- package/dist/xlsx-worker.js +85 -8
- package/dist/xlsx-worker.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -499,42 +499,128 @@ interface XlsxImageRect {
|
|
|
499
499
|
}
|
|
500
500
|
type XlsxImageResizeHandlePosition = "n" | "s" | "e" | "w" | "ne" | "nw" | "se" | "sw";
|
|
501
501
|
interface XlsxImageRenderProps {
|
|
502
|
+
/** The built-in image element that react-xlsx would render without customization. */
|
|
502
503
|
defaultNode: React.ReactNode;
|
|
504
|
+
/** Workbook image metadata, including source, anchor, name, alt text, and editability. */
|
|
503
505
|
image: XlsxImage;
|
|
506
|
+
/** The image rectangle in viewer pixels, including the current zoom level. */
|
|
504
507
|
rect: XlsxImageRect;
|
|
508
|
+
/** Absolute positioning styles to apply when rendering a replacement image node. */
|
|
505
509
|
style: React.CSSProperties;
|
|
506
510
|
}
|
|
507
511
|
interface XlsxImageSelectionRenderProps {
|
|
512
|
+
/** The built-in selected-image outline and resize handles. */
|
|
508
513
|
defaultNode: React.ReactNode;
|
|
514
|
+
/** Returns pointer handlers and styles for a custom resize handle. */
|
|
509
515
|
getHandleProps: (position: XlsxImageResizeHandlePosition) => {
|
|
510
516
|
onPointerDown: (event: React.PointerEvent<HTMLElement>) => void;
|
|
511
517
|
style: React.CSSProperties;
|
|
512
518
|
};
|
|
519
|
+
/** The currently selected image. */
|
|
513
520
|
image: XlsxImage;
|
|
521
|
+
/** The selected image rectangle in viewer pixels, including the current zoom level. */
|
|
514
522
|
rect: XlsxImageRect;
|
|
515
523
|
}
|
|
516
524
|
interface XlsxChartLoadingRenderProps {
|
|
525
|
+
/** The chart that is waiting for its renderer or data. */
|
|
517
526
|
chart: XlsxChart;
|
|
527
|
+
/** The built-in chart loading placeholder. */
|
|
518
528
|
defaultNode: React.ReactNode;
|
|
529
|
+
/** The chart rectangle in viewer pixels, including the current zoom level. */
|
|
519
530
|
rect: XlsxImageRect;
|
|
520
531
|
}
|
|
521
532
|
interface XlsxFileTooLargeRenderProps {
|
|
533
|
+
/** The built-in file-too-large message. */
|
|
522
534
|
defaultNode: React.ReactNode;
|
|
535
|
+
/** File name displayed in the viewer UI. */
|
|
523
536
|
displayFileName: string;
|
|
537
|
+
/** Actual file size in bytes. */
|
|
524
538
|
fileSizeBytes: number;
|
|
539
|
+
/** Configured maximum file size in bytes. */
|
|
525
540
|
maxFileSizeBytes: number;
|
|
526
541
|
}
|
|
527
542
|
interface UseXlsxViewerControllerOptions {
|
|
543
|
+
/**
|
|
544
|
+
* Allows row and column resizing even while editing is disabled by `readOnly`.
|
|
545
|
+
*
|
|
546
|
+
* @default false
|
|
547
|
+
*/
|
|
528
548
|
allowResizeInReadOnly?: boolean;
|
|
549
|
+
/**
|
|
550
|
+
* Defers loading until `continueDeferredLoad()` is called when the file is larger than this byte threshold.
|
|
551
|
+
* Set to `0` to parse immediately.
|
|
552
|
+
*
|
|
553
|
+
* @default 0
|
|
554
|
+
* @example
|
|
555
|
+
* ```tsx
|
|
556
|
+
* useXlsxViewerController({ file, deferLoadingAboveBytes: 10 * 1024 * 1024 })
|
|
557
|
+
* ```
|
|
558
|
+
*/
|
|
529
559
|
deferLoadingAboveBytes?: number;
|
|
560
|
+
/**
|
|
561
|
+
* Local workbook bytes to load. Use either `file` or `src`.
|
|
562
|
+
*
|
|
563
|
+
* @example
|
|
564
|
+
* ```tsx
|
|
565
|
+
* <XlsxViewer file={await uploadedFile.arrayBuffer()} fileName={uploadedFile.name} />
|
|
566
|
+
* ```
|
|
567
|
+
*/
|
|
530
568
|
file?: ArrayBuffer;
|
|
569
|
+
/**
|
|
570
|
+
* Optional display and download name for the workbook.
|
|
571
|
+
*
|
|
572
|
+
* @example
|
|
573
|
+
* ```tsx
|
|
574
|
+
* <XlsxViewer file={buffer} fileName="forecast.xlsx" />
|
|
575
|
+
* ```
|
|
576
|
+
*/
|
|
531
577
|
fileName?: string;
|
|
578
|
+
/**
|
|
579
|
+
* Rejects files larger than this byte limit and renders `fileTooLargeState`.
|
|
580
|
+
*
|
|
581
|
+
* @default 25 * 1024 * 1024
|
|
582
|
+
*/
|
|
532
583
|
maxFileSizeBytes?: number;
|
|
584
|
+
/**
|
|
585
|
+
* Disables workbook edits, paste, fill, undo/redo, and other mutation actions.
|
|
586
|
+
*
|
|
587
|
+
* @default false
|
|
588
|
+
*/
|
|
533
589
|
readOnly?: boolean;
|
|
590
|
+
/**
|
|
591
|
+
* Automatically enables read-only mode for files larger than this byte threshold.
|
|
592
|
+
* Set to `0` to disable the automatic switch.
|
|
593
|
+
*
|
|
594
|
+
* @default 0
|
|
595
|
+
*/
|
|
534
596
|
readOnlyAboveBytes?: number;
|
|
597
|
+
/**
|
|
598
|
+
* Includes hidden and very hidden workbook sheets in the sheet tabs and controller state.
|
|
599
|
+
*
|
|
600
|
+
* @default false
|
|
601
|
+
*/
|
|
535
602
|
showHiddenSheets?: boolean;
|
|
603
|
+
/**
|
|
604
|
+
* Skips OOXML ZIP/XML parsing and relies on `@dukelib/sheets-wasm` metadata only.
|
|
605
|
+
* This is automatically used for legacy `.xls` files.
|
|
606
|
+
*
|
|
607
|
+
* @default false
|
|
608
|
+
*/
|
|
536
609
|
skipXmlParsing?: boolean;
|
|
610
|
+
/**
|
|
611
|
+
* Remote workbook URL to fetch and load. Use either `src` or `file`.
|
|
612
|
+
*
|
|
613
|
+
* @example
|
|
614
|
+
* ```tsx
|
|
615
|
+
* <XlsxViewer src="/workbooks/report.xlsx" />
|
|
616
|
+
* ```
|
|
617
|
+
*/
|
|
537
618
|
src?: string;
|
|
619
|
+
/**
|
|
620
|
+
* Parses supported workbook data in a Web Worker so large files do not block React rendering.
|
|
621
|
+
*
|
|
622
|
+
* @default true
|
|
623
|
+
*/
|
|
538
624
|
useWorker?: boolean;
|
|
539
625
|
}
|
|
540
626
|
interface XlsxViewerController {
|
|
@@ -774,45 +860,172 @@ interface XlsxViewerThumbnails {
|
|
|
774
860
|
thumbnails: XlsxSheetThumbnail[];
|
|
775
861
|
}
|
|
776
862
|
interface XlsxTableHeaderMenuRenderProps {
|
|
863
|
+
/** Address of the table header cell that owns this menu. */
|
|
777
864
|
cell: XlsxCellAddress;
|
|
865
|
+
/** Table column metadata for the active header. */
|
|
778
866
|
column: XlsxTableColumn;
|
|
867
|
+
/** Current sort direction for this column, or `null` when unsorted. */
|
|
779
868
|
direction: XlsxTableSortDirection | null;
|
|
869
|
+
/** Sorts the table by this column in ascending order. */
|
|
780
870
|
sortAscending: () => void;
|
|
871
|
+
/** Sorts the table by this column in descending order. */
|
|
781
872
|
sortDescending: () => void;
|
|
873
|
+
/** Table metadata for the active header. */
|
|
782
874
|
table: XlsxTable;
|
|
875
|
+
/** Built-in trigger text/icon. Useful when composing your own trigger button. */
|
|
783
876
|
triggerIcon: string;
|
|
877
|
+
/** Props that must be applied to your menu trigger button so grid selection does not receive the click. */
|
|
784
878
|
triggerProps: React.ButtonHTMLAttributes<HTMLButtonElement>;
|
|
785
879
|
}
|
|
786
880
|
interface XlsxViewerProviderProps extends UseXlsxViewerControllerOptions {
|
|
881
|
+
/** Viewer UI and hooks that should share this provider's workbook controller. */
|
|
787
882
|
children: React.ReactNode;
|
|
883
|
+
/**
|
|
884
|
+
* Existing controller to provide instead of creating one from `file`, `src`, or other controller options.
|
|
885
|
+
*
|
|
886
|
+
* @example
|
|
887
|
+
* ```tsx
|
|
888
|
+
* const controller = useXlsxViewerController({ src: "/report.xlsx" });
|
|
889
|
+
* return <XlsxViewerProvider controller={controller}><XlsxViewer /></XlsxViewerProvider>;
|
|
890
|
+
* ```
|
|
891
|
+
*/
|
|
788
892
|
controller?: XlsxViewerController;
|
|
893
|
+
/**
|
|
894
|
+
* Uses the built-in dark worksheet/viewer palette.
|
|
895
|
+
*
|
|
896
|
+
* @default false
|
|
897
|
+
*/
|
|
789
898
|
isDark?: boolean;
|
|
790
899
|
}
|
|
791
900
|
interface XlsxViewerProps extends UseXlsxViewerControllerOptions {
|
|
901
|
+
/**
|
|
902
|
+
* Allows row and column resizing even while editing is disabled by `readOnly`.
|
|
903
|
+
*
|
|
904
|
+
* @default false
|
|
905
|
+
*/
|
|
792
906
|
allowResizeInReadOnly?: boolean;
|
|
907
|
+
/** Class name applied to the root viewer shell. */
|
|
793
908
|
className?: string;
|
|
909
|
+
/**
|
|
910
|
+
* Existing controller to render. Takes precedence over provider context and source props on this viewer.
|
|
911
|
+
*
|
|
912
|
+
* @example
|
|
913
|
+
* ```tsx
|
|
914
|
+
* const controller = useXlsxViewerController({ file, fileName: "model.xlsx" });
|
|
915
|
+
* return <XlsxViewer controller={controller} />;
|
|
916
|
+
* ```
|
|
917
|
+
*/
|
|
794
918
|
controller?: XlsxViewerController;
|
|
919
|
+
/** Content shown when no workbook has been loaded. */
|
|
795
920
|
emptyState?: React.ReactNode;
|
|
921
|
+
/**
|
|
922
|
+
* Animates the selection rectangle in canvas mode.
|
|
923
|
+
*
|
|
924
|
+
* @default true
|
|
925
|
+
*/
|
|
796
926
|
enableCanvasSelectionAnimation?: boolean;
|
|
927
|
+
/**
|
|
928
|
+
* Enables pinch zoom and modifier-key wheel zoom inside the viewer.
|
|
929
|
+
*
|
|
930
|
+
* @default true
|
|
931
|
+
*/
|
|
797
932
|
enableGestureZoom?: boolean;
|
|
933
|
+
/**
|
|
934
|
+
* Renders worksheets with the canvas renderer. Set to `false` to use the DOM table renderer.
|
|
935
|
+
*
|
|
936
|
+
* @default true
|
|
937
|
+
* @example
|
|
938
|
+
* ```tsx
|
|
939
|
+
* <XlsxViewer experimentalCanvas={false} />
|
|
940
|
+
* ```
|
|
941
|
+
*/
|
|
798
942
|
experimentalCanvas?: boolean;
|
|
943
|
+
/** Content shown for non-size load errors, or a function that receives the thrown error. */
|
|
799
944
|
errorState?: React.ReactNode | ((error: Error) => React.ReactNode);
|
|
945
|
+
/** Content shown when `maxFileSizeBytes` rejects a file. */
|
|
800
946
|
fileTooLargeState?: React.ReactNode | ((props: XlsxFileTooLargeRenderProps) => React.ReactNode);
|
|
947
|
+
/**
|
|
948
|
+
* CSS height for the viewer container.
|
|
949
|
+
*
|
|
950
|
+
* @example
|
|
951
|
+
* ```tsx
|
|
952
|
+
* <XlsxViewer height="70vh" />
|
|
953
|
+
* ```
|
|
954
|
+
*/
|
|
801
955
|
height?: React.CSSProperties["height"];
|
|
956
|
+
/**
|
|
957
|
+
* Uses the built-in dark worksheet/viewer palette.
|
|
958
|
+
*
|
|
959
|
+
* @default false
|
|
960
|
+
*/
|
|
802
961
|
isDark?: boolean;
|
|
962
|
+
/** Legacy loading element rendered while the workbook is being parsed. Prefer `loadingState` for new code. */
|
|
803
963
|
loadingComponent?: React.ReactElement;
|
|
964
|
+
/** Content shown while the workbook is being parsed. */
|
|
804
965
|
loadingState?: React.ReactNode;
|
|
966
|
+
/** Replaces the chart loading placeholder. */
|
|
805
967
|
renderChartLoading?: (props: XlsxChartLoadingRenderProps) => React.ReactNode;
|
|
968
|
+
/**
|
|
969
|
+
* Replaces worksheet images while preserving their calculated rect and style.
|
|
970
|
+
*
|
|
971
|
+
* @example
|
|
972
|
+
* ```tsx
|
|
973
|
+
* <XlsxViewer renderImage={({ image, style }) => <img src={image.src} style={style} alt={image.description ?? ""} />} />
|
|
974
|
+
* ```
|
|
975
|
+
*/
|
|
806
976
|
renderImage?: (props: XlsxImageRenderProps) => React.ReactNode;
|
|
977
|
+
/** Replaces the selected-image outline and resize handles. */
|
|
807
978
|
renderImageSelection?: (props: XlsxImageSelectionRenderProps) => React.ReactNode;
|
|
979
|
+
/**
|
|
980
|
+
* Toggles the default rounded outer shell.
|
|
981
|
+
*
|
|
982
|
+
* @default true
|
|
983
|
+
*/
|
|
808
984
|
rounded?: boolean;
|
|
985
|
+
/**
|
|
986
|
+
* Disables workbook edits, paste, fill, undo/redo, and other mutation actions.
|
|
987
|
+
*
|
|
988
|
+
* @default false
|
|
989
|
+
*/
|
|
809
990
|
readOnly?: boolean;
|
|
991
|
+
/**
|
|
992
|
+
* Border and accent color for the current selection.
|
|
993
|
+
*
|
|
994
|
+
* @example
|
|
995
|
+
* ```tsx
|
|
996
|
+
* <XlsxViewer selectionColor="#2563eb" />
|
|
997
|
+
* ```
|
|
998
|
+
*/
|
|
810
999
|
selectionColor?: string;
|
|
1000
|
+
/** Fill color used for the translucent selection overlay. */
|
|
811
1001
|
selectionFillColor?: string;
|
|
1002
|
+
/** Accent color used for selected row and column headers. */
|
|
812
1003
|
selectionHeaderColor?: string;
|
|
1004
|
+
/**
|
|
1005
|
+
* Replaces the table header sort/filter trigger menu.
|
|
1006
|
+
* Apply `triggerProps` to your actual trigger button so clicks do not leak into grid selection.
|
|
1007
|
+
*/
|
|
813
1008
|
renderTableHeaderMenu?: (props: XlsxTableHeaderMenuRenderProps) => React.ReactNode;
|
|
1009
|
+
/**
|
|
1010
|
+
* Shows worksheet images, charts, shapes, and form controls.
|
|
1011
|
+
*
|
|
1012
|
+
* @default true
|
|
1013
|
+
*/
|
|
814
1014
|
showImages?: boolean;
|
|
1015
|
+
/**
|
|
1016
|
+
* Shows the built-in toolbar above the workbook grid.
|
|
1017
|
+
*
|
|
1018
|
+
* @default true
|
|
1019
|
+
*/
|
|
815
1020
|
showDefaultToolbar?: boolean;
|
|
1021
|
+
/**
|
|
1022
|
+
* Replaces the toolbar area with a node or render function.
|
|
1023
|
+
*
|
|
1024
|
+
* @example
|
|
1025
|
+
* ```tsx
|
|
1026
|
+
* <XlsxViewer toolbar={(controller) => <button onClick={controller.download}>Download</button>} />
|
|
1027
|
+
* ```
|
|
1028
|
+
*/
|
|
816
1029
|
toolbar?: React.ReactNode | ((controller: XlsxViewerController) => React.ReactNode);
|
|
817
1030
|
}
|
|
818
1031
|
|
package/dist/index.d.ts
CHANGED
|
@@ -499,42 +499,128 @@ interface XlsxImageRect {
|
|
|
499
499
|
}
|
|
500
500
|
type XlsxImageResizeHandlePosition = "n" | "s" | "e" | "w" | "ne" | "nw" | "se" | "sw";
|
|
501
501
|
interface XlsxImageRenderProps {
|
|
502
|
+
/** The built-in image element that react-xlsx would render without customization. */
|
|
502
503
|
defaultNode: React.ReactNode;
|
|
504
|
+
/** Workbook image metadata, including source, anchor, name, alt text, and editability. */
|
|
503
505
|
image: XlsxImage;
|
|
506
|
+
/** The image rectangle in viewer pixels, including the current zoom level. */
|
|
504
507
|
rect: XlsxImageRect;
|
|
508
|
+
/** Absolute positioning styles to apply when rendering a replacement image node. */
|
|
505
509
|
style: React.CSSProperties;
|
|
506
510
|
}
|
|
507
511
|
interface XlsxImageSelectionRenderProps {
|
|
512
|
+
/** The built-in selected-image outline and resize handles. */
|
|
508
513
|
defaultNode: React.ReactNode;
|
|
514
|
+
/** Returns pointer handlers and styles for a custom resize handle. */
|
|
509
515
|
getHandleProps: (position: XlsxImageResizeHandlePosition) => {
|
|
510
516
|
onPointerDown: (event: React.PointerEvent<HTMLElement>) => void;
|
|
511
517
|
style: React.CSSProperties;
|
|
512
518
|
};
|
|
519
|
+
/** The currently selected image. */
|
|
513
520
|
image: XlsxImage;
|
|
521
|
+
/** The selected image rectangle in viewer pixels, including the current zoom level. */
|
|
514
522
|
rect: XlsxImageRect;
|
|
515
523
|
}
|
|
516
524
|
interface XlsxChartLoadingRenderProps {
|
|
525
|
+
/** The chart that is waiting for its renderer or data. */
|
|
517
526
|
chart: XlsxChart;
|
|
527
|
+
/** The built-in chart loading placeholder. */
|
|
518
528
|
defaultNode: React.ReactNode;
|
|
529
|
+
/** The chart rectangle in viewer pixels, including the current zoom level. */
|
|
519
530
|
rect: XlsxImageRect;
|
|
520
531
|
}
|
|
521
532
|
interface XlsxFileTooLargeRenderProps {
|
|
533
|
+
/** The built-in file-too-large message. */
|
|
522
534
|
defaultNode: React.ReactNode;
|
|
535
|
+
/** File name displayed in the viewer UI. */
|
|
523
536
|
displayFileName: string;
|
|
537
|
+
/** Actual file size in bytes. */
|
|
524
538
|
fileSizeBytes: number;
|
|
539
|
+
/** Configured maximum file size in bytes. */
|
|
525
540
|
maxFileSizeBytes: number;
|
|
526
541
|
}
|
|
527
542
|
interface UseXlsxViewerControllerOptions {
|
|
543
|
+
/**
|
|
544
|
+
* Allows row and column resizing even while editing is disabled by `readOnly`.
|
|
545
|
+
*
|
|
546
|
+
* @default false
|
|
547
|
+
*/
|
|
528
548
|
allowResizeInReadOnly?: boolean;
|
|
549
|
+
/**
|
|
550
|
+
* Defers loading until `continueDeferredLoad()` is called when the file is larger than this byte threshold.
|
|
551
|
+
* Set to `0` to parse immediately.
|
|
552
|
+
*
|
|
553
|
+
* @default 0
|
|
554
|
+
* @example
|
|
555
|
+
* ```tsx
|
|
556
|
+
* useXlsxViewerController({ file, deferLoadingAboveBytes: 10 * 1024 * 1024 })
|
|
557
|
+
* ```
|
|
558
|
+
*/
|
|
529
559
|
deferLoadingAboveBytes?: number;
|
|
560
|
+
/**
|
|
561
|
+
* Local workbook bytes to load. Use either `file` or `src`.
|
|
562
|
+
*
|
|
563
|
+
* @example
|
|
564
|
+
* ```tsx
|
|
565
|
+
* <XlsxViewer file={await uploadedFile.arrayBuffer()} fileName={uploadedFile.name} />
|
|
566
|
+
* ```
|
|
567
|
+
*/
|
|
530
568
|
file?: ArrayBuffer;
|
|
569
|
+
/**
|
|
570
|
+
* Optional display and download name for the workbook.
|
|
571
|
+
*
|
|
572
|
+
* @example
|
|
573
|
+
* ```tsx
|
|
574
|
+
* <XlsxViewer file={buffer} fileName="forecast.xlsx" />
|
|
575
|
+
* ```
|
|
576
|
+
*/
|
|
531
577
|
fileName?: string;
|
|
578
|
+
/**
|
|
579
|
+
* Rejects files larger than this byte limit and renders `fileTooLargeState`.
|
|
580
|
+
*
|
|
581
|
+
* @default 25 * 1024 * 1024
|
|
582
|
+
*/
|
|
532
583
|
maxFileSizeBytes?: number;
|
|
584
|
+
/**
|
|
585
|
+
* Disables workbook edits, paste, fill, undo/redo, and other mutation actions.
|
|
586
|
+
*
|
|
587
|
+
* @default false
|
|
588
|
+
*/
|
|
533
589
|
readOnly?: boolean;
|
|
590
|
+
/**
|
|
591
|
+
* Automatically enables read-only mode for files larger than this byte threshold.
|
|
592
|
+
* Set to `0` to disable the automatic switch.
|
|
593
|
+
*
|
|
594
|
+
* @default 0
|
|
595
|
+
*/
|
|
534
596
|
readOnlyAboveBytes?: number;
|
|
597
|
+
/**
|
|
598
|
+
* Includes hidden and very hidden workbook sheets in the sheet tabs and controller state.
|
|
599
|
+
*
|
|
600
|
+
* @default false
|
|
601
|
+
*/
|
|
535
602
|
showHiddenSheets?: boolean;
|
|
603
|
+
/**
|
|
604
|
+
* Skips OOXML ZIP/XML parsing and relies on `@dukelib/sheets-wasm` metadata only.
|
|
605
|
+
* This is automatically used for legacy `.xls` files.
|
|
606
|
+
*
|
|
607
|
+
* @default false
|
|
608
|
+
*/
|
|
536
609
|
skipXmlParsing?: boolean;
|
|
610
|
+
/**
|
|
611
|
+
* Remote workbook URL to fetch and load. Use either `src` or `file`.
|
|
612
|
+
*
|
|
613
|
+
* @example
|
|
614
|
+
* ```tsx
|
|
615
|
+
* <XlsxViewer src="/workbooks/report.xlsx" />
|
|
616
|
+
* ```
|
|
617
|
+
*/
|
|
537
618
|
src?: string;
|
|
619
|
+
/**
|
|
620
|
+
* Parses supported workbook data in a Web Worker so large files do not block React rendering.
|
|
621
|
+
*
|
|
622
|
+
* @default true
|
|
623
|
+
*/
|
|
538
624
|
useWorker?: boolean;
|
|
539
625
|
}
|
|
540
626
|
interface XlsxViewerController {
|
|
@@ -774,45 +860,172 @@ interface XlsxViewerThumbnails {
|
|
|
774
860
|
thumbnails: XlsxSheetThumbnail[];
|
|
775
861
|
}
|
|
776
862
|
interface XlsxTableHeaderMenuRenderProps {
|
|
863
|
+
/** Address of the table header cell that owns this menu. */
|
|
777
864
|
cell: XlsxCellAddress;
|
|
865
|
+
/** Table column metadata for the active header. */
|
|
778
866
|
column: XlsxTableColumn;
|
|
867
|
+
/** Current sort direction for this column, or `null` when unsorted. */
|
|
779
868
|
direction: XlsxTableSortDirection | null;
|
|
869
|
+
/** Sorts the table by this column in ascending order. */
|
|
780
870
|
sortAscending: () => void;
|
|
871
|
+
/** Sorts the table by this column in descending order. */
|
|
781
872
|
sortDescending: () => void;
|
|
873
|
+
/** Table metadata for the active header. */
|
|
782
874
|
table: XlsxTable;
|
|
875
|
+
/** Built-in trigger text/icon. Useful when composing your own trigger button. */
|
|
783
876
|
triggerIcon: string;
|
|
877
|
+
/** Props that must be applied to your menu trigger button so grid selection does not receive the click. */
|
|
784
878
|
triggerProps: React.ButtonHTMLAttributes<HTMLButtonElement>;
|
|
785
879
|
}
|
|
786
880
|
interface XlsxViewerProviderProps extends UseXlsxViewerControllerOptions {
|
|
881
|
+
/** Viewer UI and hooks that should share this provider's workbook controller. */
|
|
787
882
|
children: React.ReactNode;
|
|
883
|
+
/**
|
|
884
|
+
* Existing controller to provide instead of creating one from `file`, `src`, or other controller options.
|
|
885
|
+
*
|
|
886
|
+
* @example
|
|
887
|
+
* ```tsx
|
|
888
|
+
* const controller = useXlsxViewerController({ src: "/report.xlsx" });
|
|
889
|
+
* return <XlsxViewerProvider controller={controller}><XlsxViewer /></XlsxViewerProvider>;
|
|
890
|
+
* ```
|
|
891
|
+
*/
|
|
788
892
|
controller?: XlsxViewerController;
|
|
893
|
+
/**
|
|
894
|
+
* Uses the built-in dark worksheet/viewer palette.
|
|
895
|
+
*
|
|
896
|
+
* @default false
|
|
897
|
+
*/
|
|
789
898
|
isDark?: boolean;
|
|
790
899
|
}
|
|
791
900
|
interface XlsxViewerProps extends UseXlsxViewerControllerOptions {
|
|
901
|
+
/**
|
|
902
|
+
* Allows row and column resizing even while editing is disabled by `readOnly`.
|
|
903
|
+
*
|
|
904
|
+
* @default false
|
|
905
|
+
*/
|
|
792
906
|
allowResizeInReadOnly?: boolean;
|
|
907
|
+
/** Class name applied to the root viewer shell. */
|
|
793
908
|
className?: string;
|
|
909
|
+
/**
|
|
910
|
+
* Existing controller to render. Takes precedence over provider context and source props on this viewer.
|
|
911
|
+
*
|
|
912
|
+
* @example
|
|
913
|
+
* ```tsx
|
|
914
|
+
* const controller = useXlsxViewerController({ file, fileName: "model.xlsx" });
|
|
915
|
+
* return <XlsxViewer controller={controller} />;
|
|
916
|
+
* ```
|
|
917
|
+
*/
|
|
794
918
|
controller?: XlsxViewerController;
|
|
919
|
+
/** Content shown when no workbook has been loaded. */
|
|
795
920
|
emptyState?: React.ReactNode;
|
|
921
|
+
/**
|
|
922
|
+
* Animates the selection rectangle in canvas mode.
|
|
923
|
+
*
|
|
924
|
+
* @default true
|
|
925
|
+
*/
|
|
796
926
|
enableCanvasSelectionAnimation?: boolean;
|
|
927
|
+
/**
|
|
928
|
+
* Enables pinch zoom and modifier-key wheel zoom inside the viewer.
|
|
929
|
+
*
|
|
930
|
+
* @default true
|
|
931
|
+
*/
|
|
797
932
|
enableGestureZoom?: boolean;
|
|
933
|
+
/**
|
|
934
|
+
* Renders worksheets with the canvas renderer. Set to `false` to use the DOM table renderer.
|
|
935
|
+
*
|
|
936
|
+
* @default true
|
|
937
|
+
* @example
|
|
938
|
+
* ```tsx
|
|
939
|
+
* <XlsxViewer experimentalCanvas={false} />
|
|
940
|
+
* ```
|
|
941
|
+
*/
|
|
798
942
|
experimentalCanvas?: boolean;
|
|
943
|
+
/** Content shown for non-size load errors, or a function that receives the thrown error. */
|
|
799
944
|
errorState?: React.ReactNode | ((error: Error) => React.ReactNode);
|
|
945
|
+
/** Content shown when `maxFileSizeBytes` rejects a file. */
|
|
800
946
|
fileTooLargeState?: React.ReactNode | ((props: XlsxFileTooLargeRenderProps) => React.ReactNode);
|
|
947
|
+
/**
|
|
948
|
+
* CSS height for the viewer container.
|
|
949
|
+
*
|
|
950
|
+
* @example
|
|
951
|
+
* ```tsx
|
|
952
|
+
* <XlsxViewer height="70vh" />
|
|
953
|
+
* ```
|
|
954
|
+
*/
|
|
801
955
|
height?: React.CSSProperties["height"];
|
|
956
|
+
/**
|
|
957
|
+
* Uses the built-in dark worksheet/viewer palette.
|
|
958
|
+
*
|
|
959
|
+
* @default false
|
|
960
|
+
*/
|
|
802
961
|
isDark?: boolean;
|
|
962
|
+
/** Legacy loading element rendered while the workbook is being parsed. Prefer `loadingState` for new code. */
|
|
803
963
|
loadingComponent?: React.ReactElement;
|
|
964
|
+
/** Content shown while the workbook is being parsed. */
|
|
804
965
|
loadingState?: React.ReactNode;
|
|
966
|
+
/** Replaces the chart loading placeholder. */
|
|
805
967
|
renderChartLoading?: (props: XlsxChartLoadingRenderProps) => React.ReactNode;
|
|
968
|
+
/**
|
|
969
|
+
* Replaces worksheet images while preserving their calculated rect and style.
|
|
970
|
+
*
|
|
971
|
+
* @example
|
|
972
|
+
* ```tsx
|
|
973
|
+
* <XlsxViewer renderImage={({ image, style }) => <img src={image.src} style={style} alt={image.description ?? ""} />} />
|
|
974
|
+
* ```
|
|
975
|
+
*/
|
|
806
976
|
renderImage?: (props: XlsxImageRenderProps) => React.ReactNode;
|
|
977
|
+
/** Replaces the selected-image outline and resize handles. */
|
|
807
978
|
renderImageSelection?: (props: XlsxImageSelectionRenderProps) => React.ReactNode;
|
|
979
|
+
/**
|
|
980
|
+
* Toggles the default rounded outer shell.
|
|
981
|
+
*
|
|
982
|
+
* @default true
|
|
983
|
+
*/
|
|
808
984
|
rounded?: boolean;
|
|
985
|
+
/**
|
|
986
|
+
* Disables workbook edits, paste, fill, undo/redo, and other mutation actions.
|
|
987
|
+
*
|
|
988
|
+
* @default false
|
|
989
|
+
*/
|
|
809
990
|
readOnly?: boolean;
|
|
991
|
+
/**
|
|
992
|
+
* Border and accent color for the current selection.
|
|
993
|
+
*
|
|
994
|
+
* @example
|
|
995
|
+
* ```tsx
|
|
996
|
+
* <XlsxViewer selectionColor="#2563eb" />
|
|
997
|
+
* ```
|
|
998
|
+
*/
|
|
810
999
|
selectionColor?: string;
|
|
1000
|
+
/** Fill color used for the translucent selection overlay. */
|
|
811
1001
|
selectionFillColor?: string;
|
|
1002
|
+
/** Accent color used for selected row and column headers. */
|
|
812
1003
|
selectionHeaderColor?: string;
|
|
1004
|
+
/**
|
|
1005
|
+
* Replaces the table header sort/filter trigger menu.
|
|
1006
|
+
* Apply `triggerProps` to your actual trigger button so clicks do not leak into grid selection.
|
|
1007
|
+
*/
|
|
813
1008
|
renderTableHeaderMenu?: (props: XlsxTableHeaderMenuRenderProps) => React.ReactNode;
|
|
1009
|
+
/**
|
|
1010
|
+
* Shows worksheet images, charts, shapes, and form controls.
|
|
1011
|
+
*
|
|
1012
|
+
* @default true
|
|
1013
|
+
*/
|
|
814
1014
|
showImages?: boolean;
|
|
1015
|
+
/**
|
|
1016
|
+
* Shows the built-in toolbar above the workbook grid.
|
|
1017
|
+
*
|
|
1018
|
+
* @default true
|
|
1019
|
+
*/
|
|
815
1020
|
showDefaultToolbar?: boolean;
|
|
1021
|
+
/**
|
|
1022
|
+
* Replaces the toolbar area with a node or render function.
|
|
1023
|
+
*
|
|
1024
|
+
* @example
|
|
1025
|
+
* ```tsx
|
|
1026
|
+
* <XlsxViewer toolbar={(controller) => <button onClick={controller.download}>Download</button>} />
|
|
1027
|
+
* ```
|
|
1028
|
+
*/
|
|
816
1029
|
toolbar?: React.ReactNode | ((controller: XlsxViewerController) => React.ReactNode);
|
|
817
1030
|
}
|
|
818
1031
|
|