@extend-ai/react-xlsx 0.16.5 → 0.17.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.cts CHANGED
@@ -117,6 +117,7 @@ interface XlsxSheetData {
117
117
  hasVerticalMerges: boolean;
118
118
  maxHorizontalMergeEndCol: number;
119
119
  maxVerticalMergeEndRow: number;
120
+ mergedRanges?: XlsxCellRange[];
120
121
  minUsedCol: number;
121
122
  minUsedRow: number;
122
123
  maxUsedCol: number;
@@ -146,6 +147,23 @@ interface XlsxCellRange {
146
147
  end: XlsxCellAddress;
147
148
  start: XlsxCellAddress;
148
149
  }
150
+ interface XlsxParsedRange {
151
+ kind: "cells" | "rows" | "columns";
152
+ range: XlsxCellRange;
153
+ sheetName: string | null;
154
+ }
155
+ interface XlsxHighlightRangeOptions {
156
+ /** Navigates to the worksheet and reveals the first range. Defaults to true. */
157
+ autoScroll?: boolean;
158
+ /** Visible worksheet index for an unqualified reference. Defaults to the active worksheet. */
159
+ sheetIndex?: number;
160
+ }
161
+ interface XlsxRangeHighlight extends XlsxParsedRange {
162
+ /** Whether this entry is the navigation target for the current highlight update. */
163
+ autoScroll: boolean;
164
+ sheetName: string;
165
+ workbookSheetIndex: number;
166
+ }
149
167
  /**
150
168
  * Color value accepted by persisted workbook style mutation APIs.
151
169
  *
@@ -1037,6 +1055,11 @@ interface XlsxViewerController {
1037
1055
  addFormControl: (input: XlsxFormControlInput, sheetIndex?: number) => number | null;
1038
1056
  clearSelectedCells: () => void;
1039
1057
  clearSelection: () => void;
1058
+ /** Removes all render-only range highlights. */
1059
+ clearHighlightedRanges: () => void;
1060
+ /** Replaces the highlights with validated A1 ranges. Returns false without changing state if any reference cannot be resolved. */
1061
+ highlightRanges: (references: string | readonly string[], options?: XlsxHighlightRangeOptions) => boolean;
1062
+ highlightedRanges: XlsxRangeHighlight[];
1040
1063
  continueDeferredLoad: () => void;
1041
1064
  copySelectionToClipboard: () => Promise<boolean>;
1042
1065
  defaultZoomScale: number;
@@ -1397,6 +1420,15 @@ interface XlsxTableHeaderMenuRenderProps {
1397
1420
  /** Props that must be applied to your menu trigger button so grid selection does not receive the click. */
1398
1421
  triggerProps: React.ButtonHTMLAttributes<HTMLButtonElement>;
1399
1422
  }
1423
+ interface XlsxActiveCellOverlayRenderProps {
1424
+ /** Address of the active cell. For merged cells this is the merge anchor. */
1425
+ cell: XlsxCellAddress;
1426
+ /**
1427
+ * Pixel rect of the active cell (spanning the full merge) within the grid's scroll content,
1428
+ * at the current zoom. The rendered node is already positioned to fill this rect.
1429
+ */
1430
+ rect: XlsxImageRect;
1431
+ }
1400
1432
  interface XlsxCellStyleContext {
1401
1433
  /** Address of the cell being styled. */
1402
1434
  cell: XlsxCellAddress;
@@ -1446,6 +1478,12 @@ interface XlsxViewerProviderProps extends UseXlsxViewerControllerOptions {
1446
1478
  isDark?: boolean;
1447
1479
  }
1448
1480
  interface XlsxViewerProps extends UseXlsxViewerControllerOptions {
1481
+ /** Render-only A1 ranges to highlight. Null or an empty array clears them; undefined leaves controller state alone. */
1482
+ highlightedRanges?: string | readonly string[] | null;
1483
+ /** Reveals the first newly highlighted range, including switching worksheets. Defaults to true. */
1484
+ autoScrollToHighlightedRanges?: boolean;
1485
+ /** Additional CSS class applied to the range highlight in both renderers. */
1486
+ highlightClassName?: string;
1449
1487
  /**
1450
1488
  * Allows row and column resizing even while editing is disabled by `readOnly`.
1451
1489
  *
@@ -1612,6 +1650,24 @@ interface XlsxViewerProps extends UseXlsxViewerControllerOptions {
1612
1650
  * Apply `triggerProps` to your actual trigger button so clicks do not leak into grid selection.
1613
1651
  */
1614
1652
  renderTableHeaderMenu?: (props: XlsxTableHeaderMenuRenderProps) => React.ReactNode;
1653
+ /**
1654
+ * Renders custom content positioned over the active cell. The returned node is placed in a
1655
+ * container that exactly covers the cell, so it can carry classes, data attributes, or refs
1656
+ * for measuring the cell with `getBoundingClientRect()`.
1657
+ *
1658
+ * The container ignores pointer events so grid interaction is unaffected; set
1659
+ * `pointerEvents: "auto"` on your own elements to make them interactive.
1660
+ *
1661
+ * @example
1662
+ * ```tsx
1663
+ * <XlsxViewer
1664
+ * renderActiveCellOverlay={({ cell }) => (
1665
+ * <div data-active-cell={`${cell.row}:${cell.col}`} style={{ height: "100%", width: "100%" }} />
1666
+ * )}
1667
+ * />
1668
+ * ```
1669
+ */
1670
+ renderActiveCellOverlay?: (props: XlsxActiveCellOverlayRenderProps) => React.ReactNode;
1615
1671
  /**
1616
1672
  * Shows worksheet images, charts, shapes, and form controls.
1617
1673
  *
@@ -1642,6 +1698,9 @@ declare class XlsxFileSizeLimitExceededError extends Error {
1642
1698
  }
1643
1699
  declare function useXlsxViewerController(options: UseXlsxViewerControllerOptions): XlsxViewerController;
1644
1700
 
1701
+ /** Parses one rectangular A1 reference into normalized, zero-based coordinates. */
1702
+ declare function parseXlsxRange(reference: string): XlsxParsedRange | null;
1703
+
1645
1704
  type XlsxWasmSource = string | URL | Request | Response | BufferSource | WebAssembly.Module;
1646
1705
  declare function setWasmSource(source: XlsxWasmSource): void;
1647
1706
  declare function initWasm(source?: XlsxWasmSource): Promise<typeof _dukelib_sheets_wasm>;
@@ -1658,4 +1717,4 @@ declare function useXlsxViewerThumbnails(options?: UseXlsxViewerThumbnailsOption
1658
1717
  declare function XlsxViewer(props: XlsxViewerProps): react_jsx_runtime.JSX.Element;
1659
1718
  declare function DefaultXlsxToolbar(): react_jsx_runtime.JSX.Element;
1660
1719
 
1661
- export { DefaultXlsxToolbar, type UseXlsxViewerControllerOptions, type UseXlsxViewerThumbnailsOptions, type XlsxCellAddress, type XlsxCellAlignmentInput, type XlsxCellBorderEdgeInput, type XlsxCellBorderStyleInput, type XlsxCellFillStyleInput, type XlsxCellFontStyleInput, type XlsxCellGradientStopInput, type XlsxCellNumberFormatInput, type XlsxCellProtectionInput, type XlsxCellRange, type XlsxCellStyleColorInput, type XlsxCellStyleContext, type XlsxCellStyleInput, type XlsxChart, type XlsxChartAxis, type XlsxChartDataLabels, type XlsxChartElementSelection, type XlsxChartLoadingRenderProps, type XlsxChartReference, type XlsxChartSeries, type XlsxChartsheet, type XlsxDrawingLayout, XlsxFileSizeLimitExceededError, type XlsxFileTooLargeRenderProps, type XlsxFormControl, type XlsxFormControlActionEvent, type XlsxFormControlCaption, type XlsxFormControlCaptionInput, type XlsxFormControlCaptionRun, type XlsxFormControlChangeEvent, type XlsxFormControlInput, type XlsxFormControlKind, type XlsxFormControlKindInput, type XlsxFormControlPatch, type XlsxFormControlRenderProps, type XlsxFormControlSelectionMode, type XlsxFormControlState, type XlsxFormulaTarget, type XlsxImage, type XlsxImageAnchor, type XlsxImageRect, type XlsxImageRenderProps, type XlsxImageResizeHandlePosition, type XlsxImageSelectionRenderProps, type XlsxScrollerRenderProps, type XlsxShape, type XlsxShapeFill, type XlsxShapeParagraph, type XlsxShapeStroke, type XlsxShapeTextBox, type XlsxShapeTextRun, type XlsxSheetData, type XlsxSheetThumbnail, type XlsxSheetThumbnailResolution, type XlsxSheetVisibility, type XlsxTable, type XlsxTableColumn, type XlsxTableHeaderMenuRenderProps, type XlsxTableSortDirection, type XlsxTableSortState, type XlsxThemePalette, XlsxViewer, type XlsxViewerCharts, type XlsxViewerController, type XlsxViewerEditing, type XlsxViewerImages, type XlsxViewerProps, XlsxViewerProvider, type XlsxViewerProviderProps, type XlsxViewerSelection, type XlsxViewerTables, type XlsxViewerThumbnails, type XlsxViewerZoom, type XlsxWasmSource, type XlsxWorkbookTab, initWasm, setWasmSource, useXlsxViewer, useXlsxViewerCharts, useXlsxViewerController, useXlsxViewerEditing, useXlsxViewerImages, useXlsxViewerSelection, useXlsxViewerTables, useXlsxViewerThumbnails, useXlsxViewerZoom };
1720
+ export { DefaultXlsxToolbar, type UseXlsxViewerControllerOptions, type UseXlsxViewerThumbnailsOptions, type XlsxActiveCellOverlayRenderProps, type XlsxCellAddress, type XlsxCellAlignmentInput, type XlsxCellBorderEdgeInput, type XlsxCellBorderStyleInput, type XlsxCellFillStyleInput, type XlsxCellFontStyleInput, type XlsxCellGradientStopInput, type XlsxCellNumberFormatInput, type XlsxCellProtectionInput, type XlsxCellRange, type XlsxCellStyleColorInput, type XlsxCellStyleContext, type XlsxCellStyleInput, type XlsxChart, type XlsxChartAxis, type XlsxChartDataLabels, type XlsxChartElementSelection, type XlsxChartLoadingRenderProps, type XlsxChartReference, type XlsxChartSeries, type XlsxChartsheet, type XlsxDrawingLayout, XlsxFileSizeLimitExceededError, type XlsxFileTooLargeRenderProps, type XlsxFormControl, type XlsxFormControlActionEvent, type XlsxFormControlCaption, type XlsxFormControlCaptionInput, type XlsxFormControlCaptionRun, type XlsxFormControlChangeEvent, type XlsxFormControlInput, type XlsxFormControlKind, type XlsxFormControlKindInput, type XlsxFormControlPatch, type XlsxFormControlRenderProps, type XlsxFormControlSelectionMode, type XlsxFormControlState, type XlsxFormulaTarget, type XlsxHighlightRangeOptions, type XlsxImage, type XlsxImageAnchor, type XlsxImageRect, type XlsxImageRenderProps, type XlsxImageResizeHandlePosition, type XlsxImageSelectionRenderProps, type XlsxParsedRange, type XlsxRangeHighlight, type XlsxScrollerRenderProps, type XlsxShape, type XlsxShapeFill, type XlsxShapeParagraph, type XlsxShapeStroke, type XlsxShapeTextBox, type XlsxShapeTextRun, type XlsxSheetData, type XlsxSheetThumbnail, type XlsxSheetThumbnailResolution, type XlsxSheetVisibility, type XlsxTable, type XlsxTableColumn, type XlsxTableHeaderMenuRenderProps, type XlsxTableSortDirection, type XlsxTableSortState, type XlsxThemePalette, XlsxViewer, type XlsxViewerCharts, type XlsxViewerController, type XlsxViewerEditing, type XlsxViewerImages, type XlsxViewerProps, XlsxViewerProvider, type XlsxViewerProviderProps, type XlsxViewerSelection, type XlsxViewerTables, type XlsxViewerThumbnails, type XlsxViewerZoom, type XlsxWasmSource, type XlsxWorkbookTab, initWasm, parseXlsxRange, setWasmSource, useXlsxViewer, useXlsxViewerCharts, useXlsxViewerController, useXlsxViewerEditing, useXlsxViewerImages, useXlsxViewerSelection, useXlsxViewerTables, useXlsxViewerThumbnails, useXlsxViewerZoom };
package/dist/index.d.ts CHANGED
@@ -117,6 +117,7 @@ interface XlsxSheetData {
117
117
  hasVerticalMerges: boolean;
118
118
  maxHorizontalMergeEndCol: number;
119
119
  maxVerticalMergeEndRow: number;
120
+ mergedRanges?: XlsxCellRange[];
120
121
  minUsedCol: number;
121
122
  minUsedRow: number;
122
123
  maxUsedCol: number;
@@ -146,6 +147,23 @@ interface XlsxCellRange {
146
147
  end: XlsxCellAddress;
147
148
  start: XlsxCellAddress;
148
149
  }
150
+ interface XlsxParsedRange {
151
+ kind: "cells" | "rows" | "columns";
152
+ range: XlsxCellRange;
153
+ sheetName: string | null;
154
+ }
155
+ interface XlsxHighlightRangeOptions {
156
+ /** Navigates to the worksheet and reveals the first range. Defaults to true. */
157
+ autoScroll?: boolean;
158
+ /** Visible worksheet index for an unqualified reference. Defaults to the active worksheet. */
159
+ sheetIndex?: number;
160
+ }
161
+ interface XlsxRangeHighlight extends XlsxParsedRange {
162
+ /** Whether this entry is the navigation target for the current highlight update. */
163
+ autoScroll: boolean;
164
+ sheetName: string;
165
+ workbookSheetIndex: number;
166
+ }
149
167
  /**
150
168
  * Color value accepted by persisted workbook style mutation APIs.
151
169
  *
@@ -1037,6 +1055,11 @@ interface XlsxViewerController {
1037
1055
  addFormControl: (input: XlsxFormControlInput, sheetIndex?: number) => number | null;
1038
1056
  clearSelectedCells: () => void;
1039
1057
  clearSelection: () => void;
1058
+ /** Removes all render-only range highlights. */
1059
+ clearHighlightedRanges: () => void;
1060
+ /** Replaces the highlights with validated A1 ranges. Returns false without changing state if any reference cannot be resolved. */
1061
+ highlightRanges: (references: string | readonly string[], options?: XlsxHighlightRangeOptions) => boolean;
1062
+ highlightedRanges: XlsxRangeHighlight[];
1040
1063
  continueDeferredLoad: () => void;
1041
1064
  copySelectionToClipboard: () => Promise<boolean>;
1042
1065
  defaultZoomScale: number;
@@ -1397,6 +1420,15 @@ interface XlsxTableHeaderMenuRenderProps {
1397
1420
  /** Props that must be applied to your menu trigger button so grid selection does not receive the click. */
1398
1421
  triggerProps: React.ButtonHTMLAttributes<HTMLButtonElement>;
1399
1422
  }
1423
+ interface XlsxActiveCellOverlayRenderProps {
1424
+ /** Address of the active cell. For merged cells this is the merge anchor. */
1425
+ cell: XlsxCellAddress;
1426
+ /**
1427
+ * Pixel rect of the active cell (spanning the full merge) within the grid's scroll content,
1428
+ * at the current zoom. The rendered node is already positioned to fill this rect.
1429
+ */
1430
+ rect: XlsxImageRect;
1431
+ }
1400
1432
  interface XlsxCellStyleContext {
1401
1433
  /** Address of the cell being styled. */
1402
1434
  cell: XlsxCellAddress;
@@ -1446,6 +1478,12 @@ interface XlsxViewerProviderProps extends UseXlsxViewerControllerOptions {
1446
1478
  isDark?: boolean;
1447
1479
  }
1448
1480
  interface XlsxViewerProps extends UseXlsxViewerControllerOptions {
1481
+ /** Render-only A1 ranges to highlight. Null or an empty array clears them; undefined leaves controller state alone. */
1482
+ highlightedRanges?: string | readonly string[] | null;
1483
+ /** Reveals the first newly highlighted range, including switching worksheets. Defaults to true. */
1484
+ autoScrollToHighlightedRanges?: boolean;
1485
+ /** Additional CSS class applied to the range highlight in both renderers. */
1486
+ highlightClassName?: string;
1449
1487
  /**
1450
1488
  * Allows row and column resizing even while editing is disabled by `readOnly`.
1451
1489
  *
@@ -1612,6 +1650,24 @@ interface XlsxViewerProps extends UseXlsxViewerControllerOptions {
1612
1650
  * Apply `triggerProps` to your actual trigger button so clicks do not leak into grid selection.
1613
1651
  */
1614
1652
  renderTableHeaderMenu?: (props: XlsxTableHeaderMenuRenderProps) => React.ReactNode;
1653
+ /**
1654
+ * Renders custom content positioned over the active cell. The returned node is placed in a
1655
+ * container that exactly covers the cell, so it can carry classes, data attributes, or refs
1656
+ * for measuring the cell with `getBoundingClientRect()`.
1657
+ *
1658
+ * The container ignores pointer events so grid interaction is unaffected; set
1659
+ * `pointerEvents: "auto"` on your own elements to make them interactive.
1660
+ *
1661
+ * @example
1662
+ * ```tsx
1663
+ * <XlsxViewer
1664
+ * renderActiveCellOverlay={({ cell }) => (
1665
+ * <div data-active-cell={`${cell.row}:${cell.col}`} style={{ height: "100%", width: "100%" }} />
1666
+ * )}
1667
+ * />
1668
+ * ```
1669
+ */
1670
+ renderActiveCellOverlay?: (props: XlsxActiveCellOverlayRenderProps) => React.ReactNode;
1615
1671
  /**
1616
1672
  * Shows worksheet images, charts, shapes, and form controls.
1617
1673
  *
@@ -1642,6 +1698,9 @@ declare class XlsxFileSizeLimitExceededError extends Error {
1642
1698
  }
1643
1699
  declare function useXlsxViewerController(options: UseXlsxViewerControllerOptions): XlsxViewerController;
1644
1700
 
1701
+ /** Parses one rectangular A1 reference into normalized, zero-based coordinates. */
1702
+ declare function parseXlsxRange(reference: string): XlsxParsedRange | null;
1703
+
1645
1704
  type XlsxWasmSource = string | URL | Request | Response | BufferSource | WebAssembly.Module;
1646
1705
  declare function setWasmSource(source: XlsxWasmSource): void;
1647
1706
  declare function initWasm(source?: XlsxWasmSource): Promise<typeof _dukelib_sheets_wasm>;
@@ -1658,4 +1717,4 @@ declare function useXlsxViewerThumbnails(options?: UseXlsxViewerThumbnailsOption
1658
1717
  declare function XlsxViewer(props: XlsxViewerProps): react_jsx_runtime.JSX.Element;
1659
1718
  declare function DefaultXlsxToolbar(): react_jsx_runtime.JSX.Element;
1660
1719
 
1661
- export { DefaultXlsxToolbar, type UseXlsxViewerControllerOptions, type UseXlsxViewerThumbnailsOptions, type XlsxCellAddress, type XlsxCellAlignmentInput, type XlsxCellBorderEdgeInput, type XlsxCellBorderStyleInput, type XlsxCellFillStyleInput, type XlsxCellFontStyleInput, type XlsxCellGradientStopInput, type XlsxCellNumberFormatInput, type XlsxCellProtectionInput, type XlsxCellRange, type XlsxCellStyleColorInput, type XlsxCellStyleContext, type XlsxCellStyleInput, type XlsxChart, type XlsxChartAxis, type XlsxChartDataLabels, type XlsxChartElementSelection, type XlsxChartLoadingRenderProps, type XlsxChartReference, type XlsxChartSeries, type XlsxChartsheet, type XlsxDrawingLayout, XlsxFileSizeLimitExceededError, type XlsxFileTooLargeRenderProps, type XlsxFormControl, type XlsxFormControlActionEvent, type XlsxFormControlCaption, type XlsxFormControlCaptionInput, type XlsxFormControlCaptionRun, type XlsxFormControlChangeEvent, type XlsxFormControlInput, type XlsxFormControlKind, type XlsxFormControlKindInput, type XlsxFormControlPatch, type XlsxFormControlRenderProps, type XlsxFormControlSelectionMode, type XlsxFormControlState, type XlsxFormulaTarget, type XlsxImage, type XlsxImageAnchor, type XlsxImageRect, type XlsxImageRenderProps, type XlsxImageResizeHandlePosition, type XlsxImageSelectionRenderProps, type XlsxScrollerRenderProps, type XlsxShape, type XlsxShapeFill, type XlsxShapeParagraph, type XlsxShapeStroke, type XlsxShapeTextBox, type XlsxShapeTextRun, type XlsxSheetData, type XlsxSheetThumbnail, type XlsxSheetThumbnailResolution, type XlsxSheetVisibility, type XlsxTable, type XlsxTableColumn, type XlsxTableHeaderMenuRenderProps, type XlsxTableSortDirection, type XlsxTableSortState, type XlsxThemePalette, XlsxViewer, type XlsxViewerCharts, type XlsxViewerController, type XlsxViewerEditing, type XlsxViewerImages, type XlsxViewerProps, XlsxViewerProvider, type XlsxViewerProviderProps, type XlsxViewerSelection, type XlsxViewerTables, type XlsxViewerThumbnails, type XlsxViewerZoom, type XlsxWasmSource, type XlsxWorkbookTab, initWasm, setWasmSource, useXlsxViewer, useXlsxViewerCharts, useXlsxViewerController, useXlsxViewerEditing, useXlsxViewerImages, useXlsxViewerSelection, useXlsxViewerTables, useXlsxViewerThumbnails, useXlsxViewerZoom };
1720
+ export { DefaultXlsxToolbar, type UseXlsxViewerControllerOptions, type UseXlsxViewerThumbnailsOptions, type XlsxActiveCellOverlayRenderProps, type XlsxCellAddress, type XlsxCellAlignmentInput, type XlsxCellBorderEdgeInput, type XlsxCellBorderStyleInput, type XlsxCellFillStyleInput, type XlsxCellFontStyleInput, type XlsxCellGradientStopInput, type XlsxCellNumberFormatInput, type XlsxCellProtectionInput, type XlsxCellRange, type XlsxCellStyleColorInput, type XlsxCellStyleContext, type XlsxCellStyleInput, type XlsxChart, type XlsxChartAxis, type XlsxChartDataLabels, type XlsxChartElementSelection, type XlsxChartLoadingRenderProps, type XlsxChartReference, type XlsxChartSeries, type XlsxChartsheet, type XlsxDrawingLayout, XlsxFileSizeLimitExceededError, type XlsxFileTooLargeRenderProps, type XlsxFormControl, type XlsxFormControlActionEvent, type XlsxFormControlCaption, type XlsxFormControlCaptionInput, type XlsxFormControlCaptionRun, type XlsxFormControlChangeEvent, type XlsxFormControlInput, type XlsxFormControlKind, type XlsxFormControlKindInput, type XlsxFormControlPatch, type XlsxFormControlRenderProps, type XlsxFormControlSelectionMode, type XlsxFormControlState, type XlsxFormulaTarget, type XlsxHighlightRangeOptions, type XlsxImage, type XlsxImageAnchor, type XlsxImageRect, type XlsxImageRenderProps, type XlsxImageResizeHandlePosition, type XlsxImageSelectionRenderProps, type XlsxParsedRange, type XlsxRangeHighlight, type XlsxScrollerRenderProps, type XlsxShape, type XlsxShapeFill, type XlsxShapeParagraph, type XlsxShapeStroke, type XlsxShapeTextBox, type XlsxShapeTextRun, type XlsxSheetData, type XlsxSheetThumbnail, type XlsxSheetThumbnailResolution, type XlsxSheetVisibility, type XlsxTable, type XlsxTableColumn, type XlsxTableHeaderMenuRenderProps, type XlsxTableSortDirection, type XlsxTableSortState, type XlsxThemePalette, XlsxViewer, type XlsxViewerCharts, type XlsxViewerController, type XlsxViewerEditing, type XlsxViewerImages, type XlsxViewerProps, XlsxViewerProvider, type XlsxViewerProviderProps, type XlsxViewerSelection, type XlsxViewerTables, type XlsxViewerThumbnails, type XlsxViewerZoom, type XlsxWasmSource, type XlsxWorkbookTab, initWasm, parseXlsxRange, setWasmSource, useXlsxViewer, useXlsxViewerCharts, useXlsxViewerController, useXlsxViewerEditing, useXlsxViewerImages, useXlsxViewerSelection, useXlsxViewerTables, useXlsxViewerThumbnails, useXlsxViewerZoom };