@silurus/ooxml 0.55.0 → 0.57.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.
@@ -131,12 +131,12 @@ export declare interface CellXf {
131
131
  readingOrder?: number;
132
132
  }
133
133
 
134
- declare interface CfIcon {
134
+ export declare interface CfIcon {
135
135
  iconSet: string;
136
136
  iconId: number;
137
137
  }
138
138
 
139
- declare type CfRule = {
139
+ export declare type CfRule = {
140
140
  type: 'cellIs';
141
141
  operator: string;
142
142
  formulas: string[];
@@ -184,18 +184,18 @@ declare type CfRule = {
184
184
  priority: number;
185
185
  };
186
186
 
187
- declare interface CfStop {
187
+ export declare interface CfStop {
188
188
  kind: string;
189
189
  value: string | null;
190
190
  color: string;
191
191
  }
192
192
 
193
- declare interface CfValue {
193
+ export declare interface CfValue {
194
194
  kind: string;
195
195
  value: string | null;
196
196
  }
197
197
 
198
- declare interface ChartAnchor {
198
+ export declare interface ChartAnchor {
199
199
  fromCol: number;
200
200
  fromColOff: number;
201
201
  fromRow: number;
@@ -212,7 +212,7 @@ declare interface ChartAnchor {
212
212
  * which the renderer combines into a canonical `ChartModel.chartType` (e.g.
213
213
  * `clusteredBarH`, `stackedBarPct`) at render time.
214
214
  */
215
- declare interface ChartData {
215
+ export declare interface ChartData {
216
216
  /** Primary chart type: "bar"|"line"|"area"|"pie"|"doughnut"|"radar"|"scatter" */
217
217
  chartType: string;
218
218
  /** "col" (vertical bars) | "row" (horizontal bars) */
@@ -321,12 +321,12 @@ declare interface ChartData {
321
321
  plotAreaManualLayout?: ManualLayout;
322
322
  }
323
323
 
324
- declare interface ConditionalFormat {
324
+ export declare interface ConditionalFormat {
325
325
  sqref: CellRange_2[];
326
326
  rules: CfRule[];
327
327
  }
328
328
 
329
- declare interface DataLabelOverride {
329
+ export declare interface DataLabelOverride {
330
330
  idx: number;
331
331
  text: string;
332
332
  /** "l"|"r"|"t"|"b"|"ctr"|"outEnd"|"bestFit" or undefined → inherit. */
@@ -336,7 +336,7 @@ declare interface DataLabelOverride {
336
336
  fontBold?: boolean;
337
337
  }
338
338
 
339
- declare interface DataPointOverride {
339
+ export declare interface DataPointOverride {
340
340
  idx: number;
341
341
  color?: string;
342
342
  markerSymbol?: string;
@@ -345,12 +345,12 @@ declare interface DataPointOverride {
345
345
  markerLine?: string;
346
346
  }
347
347
 
348
- declare interface DefinedName {
348
+ export declare interface DefinedName {
349
349
  name: string;
350
350
  formula: string;
351
351
  }
352
352
 
353
- declare interface Dxf {
353
+ export declare interface Dxf {
354
354
  font: CellFont | null;
355
355
  fill: CellFill | null;
356
356
  border: Border | null;
@@ -361,7 +361,7 @@ declare interface Dxf {
361
361
  numFmt?: NumFmt | null;
362
362
  }
363
363
 
364
- declare interface ErrBars {
364
+ export declare interface ErrBars {
365
365
  /** "x" | "y". */
366
366
  dir: string;
367
367
  /** "plus" | "minus" | "both". */
@@ -375,7 +375,7 @@ declare interface ErrBars {
375
375
  dash?: string;
376
376
  }
377
377
 
378
- declare interface GradientFillSpec {
378
+ export declare interface GradientFillSpec {
379
379
  /** "linear" (default) or "path". */
380
380
  gradientType: string;
381
381
  /** Rotation in degrees for linear gradients (0 = left→right). */
@@ -391,7 +391,7 @@ declare interface GradientFillSpec {
391
391
  }[];
392
392
  }
393
393
 
394
- declare interface Hyperlink {
394
+ export declare interface Hyperlink {
395
395
  col: number;
396
396
  row: number;
397
397
  url: string | null;
@@ -401,7 +401,7 @@ declare interface Hyperlink {
401
401
  * Image anchored to a rectangle of cells (EMU offsets within the anchor cells).
402
402
  * 914400 EMU = 1 inch, 9525 EMU = 1 px @ 96 DPI.
403
403
  */
404
- declare interface ImageAnchor {
404
+ export declare interface ImageAnchor {
405
405
  fromCol: number;
406
406
  fromColOff: number;
407
407
  fromRow: number;
@@ -423,7 +423,7 @@ declare interface ImageAnchor {
423
423
  dataUrl: string;
424
424
  }
425
425
 
426
- declare interface LegendManualLayout {
426
+ export declare interface LegendManualLayout {
427
427
  xMode: string;
428
428
  yMode: string;
429
429
  x: number;
@@ -476,7 +476,7 @@ declare interface LoadOptions_2 {
476
476
  math?: MathRenderer;
477
477
  }
478
478
 
479
- declare interface ManualLayout {
479
+ export declare interface ManualLayout {
480
480
  xMode: string;
481
481
  yMode: string;
482
482
  layoutTarget?: string;
@@ -637,7 +637,7 @@ export declare interface ParsedWorkbook {
637
637
  sharedStrings: SharedString[];
638
638
  }
639
639
 
640
- declare type PathCmd = {
640
+ export declare type PathCmd = {
641
641
  op: 'moveTo';
642
642
  x: number;
643
643
  y: number;
@@ -672,7 +672,7 @@ declare type PathCmd = {
672
672
  op: 'close';
673
673
  };
674
674
 
675
- declare interface PathInfo {
675
+ export declare interface PathInfo {
676
676
  w: number;
677
677
  h: number;
678
678
  commands: PathCmd[];
@@ -716,12 +716,12 @@ export declare interface Row {
716
716
  cells: Cell[];
717
717
  }
718
718
 
719
- declare interface Run {
719
+ export declare interface Run {
720
720
  text: string;
721
721
  font?: RunFont;
722
722
  }
723
723
 
724
- declare interface RunFont {
724
+ export declare interface RunFont {
725
725
  bold: boolean;
726
726
  italic: boolean;
727
727
  underline: boolean;
@@ -745,7 +745,7 @@ declare interface RunFont {
745
745
  declare type SelectionMode_2 = 'cells' | 'rows' | 'cols' | 'all';
746
746
  export { SelectionMode_2 as SelectionMode }
747
747
 
748
- declare interface SeriesDataLabels {
748
+ export declare interface SeriesDataLabels {
749
749
  showVal: boolean;
750
750
  showCatName: boolean;
751
751
  showSerName: boolean;
@@ -757,7 +757,7 @@ declare interface SeriesDataLabels {
757
757
  fontSizeHpt?: number;
758
758
  }
759
759
 
760
- declare interface ShapeAnchor {
760
+ export declare interface ShapeAnchor {
761
761
  fromCol: number;
762
762
  fromColOff: number;
763
763
  fromRow: number;
@@ -778,9 +778,14 @@ declare interface ShapeAnchor {
778
778
  shapes: ShapeInfo[];
779
779
  }
780
780
 
781
- declare type ShapeGeom = {
781
+ export declare type ShapeGeom = {
782
782
  type: 'preset';
783
783
  name: string;
784
+ /** Adjust handles from `<a:avLst><a:gd>` in `adj1..adj8` order
785
+ * (ECMA-376 §19.5.31.3 / §20.1.9.5). `null` entries mean "use the
786
+ * preset's declared default". Omitted entirely when the shape has no
787
+ * `<a:avLst>`. Consumed by the shared `renderPresetShape` engine. */
788
+ adj?: (number | null)[];
784
789
  } | {
785
790
  type: 'custom';
786
791
  paths: PathInfo[];
@@ -793,7 +798,7 @@ declare type ShapeGeom = {
793
798
  dataUrl: string;
794
799
  };
795
800
 
796
- declare interface ShapeInfo {
801
+ export declare interface ShapeInfo {
797
802
  /** Normalized [0,1] position/size relative to the anchor rect. */
798
803
  x: number;
799
804
  y: number;
@@ -811,13 +816,16 @@ declare interface ShapeInfo {
811
816
  text?: ShapeText;
812
817
  }
813
818
 
814
- declare interface ShapeParagraph {
819
+ export declare interface ShapeParagraph {
815
820
  /** `<a:pPr@algn>` — `l` (default) | `ctr` | `r` | `just` | `dist`. */
816
821
  align: string;
822
+ /** `<a:pPr@rtl>` — whether the paragraph reads right-to-left
823
+ * (ECMA-376 §21.1.2.2.7). Omitted (undefined) when false. */
824
+ rtl?: boolean;
817
825
  runs: ShapeTextRun[];
818
826
  }
819
827
 
820
- declare interface ShapeText {
828
+ export declare interface ShapeText {
821
829
  /** `<a:bodyPr@anchor>` — vertical alignment of the text block within the
822
830
  * shape rect. `t` (top, default), `ctr` (middle), `b` (bottom). */
823
831
  anchor: string;
@@ -830,7 +838,7 @@ declare interface ShapeText {
830
838
  * (matches the pptx `TextRun` shape): styled text, a soft line break, or an
831
839
  * OMML equation. Excel stores "Insert > Equation" as OMML inside the shared
832
840
  * DrawingML `<xdr:txBody>` grammar (ECMA-376 §22.1), like PowerPoint. */
833
- declare type ShapeTextRun = {
841
+ export declare type ShapeTextRun = {
834
842
  type: 'text';
835
843
  text: string;
836
844
  bold: boolean;
@@ -853,7 +861,7 @@ declare type ShapeTextRun = {
853
861
  color?: string;
854
862
  };
855
863
 
856
- declare interface SharedString {
864
+ export declare interface SharedString {
857
865
  text: string;
858
866
  runs?: Run[];
859
867
  }
@@ -868,7 +876,7 @@ export declare interface SheetMeta {
868
876
  tabColor?: string | null;
869
877
  }
870
878
 
871
- declare interface SlicerAnchor {
879
+ export declare interface SlicerAnchor {
872
880
  fromCol: number;
873
881
  fromColOff: number;
874
882
  fromRow: number;
@@ -881,12 +889,12 @@ declare interface SlicerAnchor {
881
889
  items: SlicerItem[];
882
890
  }
883
891
 
884
- declare interface SlicerItem {
892
+ export declare interface SlicerItem {
885
893
  name: string;
886
894
  selected: boolean;
887
895
  }
888
896
 
889
- declare interface Sparkline {
897
+ export declare interface Sparkline {
890
898
  /** 1-based row of the destination cell (`<xm:sqref>`). */
891
899
  row: number;
892
900
  /** 1-based column of the destination cell. */
@@ -896,7 +904,7 @@ declare interface Sparkline {
896
904
  values: (number | null)[];
897
905
  }
898
906
 
899
- declare interface SparklineGroup {
907
+ export declare interface SparklineGroup {
900
908
  /** `line` (default) | `column` | `stem` (win-loss). */
901
909
  kind: 'line' | 'column' | 'stem';
902
910
  markers: boolean;
@@ -939,7 +947,7 @@ export declare interface Styles {
939
947
 
940
948
  /** Per-column DXF references inside a `<table>` element
941
949
  * (ECMA-376 §18.5.1.3 `tableColumn`). */
942
- declare interface TableColumnInfo {
950
+ export declare interface TableColumnInfo {
943
951
  /** `<tableColumn dataDxfId>` — applied to data cells in this column. */
944
952
  dataDxfId?: number;
945
953
  /** `<tableColumn headerRowDxfId>` — applied to the header cell of this column. */
@@ -948,7 +956,7 @@ declare interface TableColumnInfo {
948
956
  totalsRowDxfId?: number;
949
957
  }
950
958
 
951
- declare interface TableInfo {
959
+ export declare interface TableInfo {
952
960
  range: CellRange_2;
953
961
  styleName: string;
954
962
  headerRowCount: number;
@@ -960,13 +968,29 @@ declare interface TableInfo {
960
968
  /** Accent color resolved by the parser from the built-in style name against
961
969
  * the file's theme accents (e.g. `TableStyleLight18` → accent3). */
962
970
  accentColor: string;
971
+ /** `true` when `styleName` is defined in the file's `<tableStyles>` block,
972
+ * i.e. a *custom* style (ECMA-376 §18.5.1.2). The renderer draws such tables
973
+ * strictly from their declared element dxfs and must NOT apply the accent
974
+ * approximation (banding / synthesized rules / header) reserved for built-in
975
+ * style names whose definitions are absent from the file. */
976
+ isCustom?: boolean;
963
977
  /** Dxf index for the `wholeTable` element of a custom `<tableStyle>`
964
- * (ECMA-376 §18.8.40). When set, its border/fill apply to every cell of
978
+ * (ECMA-376 §18.8.83). When set, its border/fill apply to every cell of
965
979
  * the table as a base layer. Undefined for built-in style names. */
966
980
  wholeTableDxf?: number;
967
981
  /** Dxf index for the `headerRow` element of a custom `<tableStyle>` —
968
982
  * provides header background, font color/weight, and vertical separators. */
969
983
  headerRowDxf?: number;
984
+ /** Dxf index for the `totalRow` element (ECMA-376 §18.18.93). */
985
+ totalRowDxf?: number;
986
+ /** Dxf index for the `firstColumn` element. */
987
+ firstColumnDxf?: number;
988
+ /** Dxf index for the `lastColumn` element. */
989
+ lastColumnDxf?: number;
990
+ /** Dxf index for `firstRowStripe` (band1 horizontal) — odd banded-row stripe. */
991
+ band1HorizontalDxf?: number;
992
+ /** Dxf index for `secondRowStripe` (band2 horizontal) — even banded-row stripe. */
993
+ band2HorizontalDxf?: number;
970
994
  /** Per-column DXF references (ECMA-376 §18.5.1.3 `tableColumn`). Index by
971
995
  * `cellCol - range.left`. The renderer can use these to apply column-level
972
996
  * overlays for named-style tables; for files where Excel pre-bakes the
@@ -1009,6 +1033,10 @@ export declare interface Worksheet {
1009
1033
  * `<sheetView showGridLines>`). Mirrors the Excel "View → Gridlines"
1010
1034
  * checkbox. Defaults to true. */
1011
1035
  showGridlines?: boolean;
1036
+ /** Whether the sheet grid is laid out right-to-left, mirroring the entire
1037
+ * grid so column A sits on the right (ECMA-376 §18.3.1.87
1038
+ * `<sheetView rightToLeft>`). Defaults to false. */
1039
+ rightToLeft?: boolean;
1012
1040
  /** Sheet tab color (ECMA-376 §18.3.1.79). */
1013
1041
  tabColor?: string | null;
1014
1042
  /** AutoFilter header range (ECMA-376 §18.3.1.2). */
@@ -1047,7 +1075,7 @@ export declare interface Worksheet {
1047
1075
  * XLSX parser's raw chart series (includes XLSX-only `seriesType` for mixed
1048
1076
  * charts). Adapted to `ChartSeries` from @silurus/ooxml-core before rendering.
1049
1077
  */
1050
- declare interface XlsxChartSeries {
1078
+ export declare interface XlsxChartSeries {
1051
1079
  name: string;
1052
1080
  /** Chart sub-type for this series (allows mixed charts). */
1053
1081
  seriesType: string;
@@ -1125,6 +1153,17 @@ export declare class XlsxViewer {
1125
1153
  private currentWorksheet;
1126
1154
  private opts;
1127
1155
  private resizeObserver;
1156
+ /**
1157
+ * Start-anchored horizontal scroll position (the {@link effectiveScrollLeft}
1158
+ * value last produced by a real user scroll or a programmatic reset), kept
1159
+ * as the source of truth across container size changes. The native
1160
+ * `scrollLeft` cannot serve that role for RTL sheets (ECMA-376 §18.3.1.87):
1161
+ * it is the *inverse* of the start-anchored offset, and the browser clamps
1162
+ * any assignment to 0 while the host is unlaid-out (`display:none` mount —
1163
+ * e.g. a host revealed only after `load()` resolves), which would otherwise
1164
+ * strand the view at the sheet's far end once the host gains its real size.
1165
+ */
1166
+ private effectiveH;
1128
1167
  private anchorCell;
1129
1168
  private activeCell;
1130
1169
  private selectionMode;
@@ -1144,6 +1183,45 @@ export declare class XlsxViewer {
1144
1183
  /** The loaded workbook, or throws if {@link load} has not completed. */
1145
1184
  private get workbook();
1146
1185
  showSheet(index: number): Promise<void>;
1186
+ /** True when the current sheet's grid is laid out right-to-left. */
1187
+ private get isRtl();
1188
+ /** Maximum horizontal scroll offset the native scroll host allows (≥ 0). */
1189
+ private get maxScrollLeft();
1190
+ /**
1191
+ * The logical horizontal scroll position used to find the start-of-sheet
1192
+ * (col A) edge, in *scaled* CSS pixels — the same unit as
1193
+ * `scrollHost.scrollLeft`. The renderer always lays the grid out LTR and then
1194
+ * mirrors it (ECMA-376 §18.3.1.87), so the viewer must hand it a position
1195
+ * where 0 = the START of the sheet (col A) and increasing values reveal later
1196
+ * columns.
1197
+ *
1198
+ * For LTR that is exactly the native `scrollLeft`. For RTL the sheet starts at
1199
+ * the RIGHT, so the native scrollbar runs the opposite way: thumb fully right
1200
+ * (`scrollLeft = maxScrollLeft`) is the start, thumb left is the far columns.
1201
+ * Inverting here makes wheel/trackpad follow the finger and aligns the
1202
+ * thumb↔page mapping with Excel, without depending on browser-specific RTL
1203
+ * `scrollLeft` sign conventions.
1204
+ */
1205
+ private get effectiveScrollLeft();
1206
+ /**
1207
+ * Map between the logical-LTR x used by all the cell-geometry math and the
1208
+ * on-screen (canvasArea CSS-pixel) x, applying the RTL mirror (ECMA-376
1209
+ * §18.3.1.87) via the same {@link rtlMirrorX} the renderer uses. For LTR this
1210
+ * is the identity. The mirror is an involution, so this one method serves
1211
+ * both cell→px (overlay draw, `w` = cell width) and px→cell (pointer
1212
+ * hit-testing, `w` = 0 for a point) — guaranteeing the overlay sits exactly
1213
+ * where the cell is drawn and a click resolves to that same cell at every
1214
+ * scroll offset. `canvasArea.clientWidth` equals the renderer's `canvasW`.
1215
+ */
1216
+ private screenX;
1217
+ /** Park the scrollbar at the sheet's natural start: scrollLeft=0 for LTR,
1218
+ * the right end for RTL (so col A shows first). */
1219
+ private resetHorizontalScroll;
1220
+ /** Re-derive the native scrollLeft from the tracked start-anchored
1221
+ * position after the scroll host's size changes. Only RTL needs this:
1222
+ * for LTR the native scrollLeft *is* start-anchored and the browser
1223
+ * already clamps it sensibly on resize. */
1224
+ private reanchorHorizontalScroll;
1147
1225
  /** 0-based index of the currently displayed sheet. */
1148
1226
  get sheetIndex(): number;
1149
1227
  /** Total number of sheets in the loaded workbook. */
@@ -1217,7 +1295,15 @@ export declare interface XlsxViewerOptions {
1217
1295
  zoomMin?: number;
1218
1296
  zoomMax?: number;
1219
1297
  onReady?: (sheetNames: string[]) => void;
1220
- onSheetChange?: (index: number, name: string) => void;
1298
+ /**
1299
+ * Called when the active sheet changes, with the new sheet's zero-based
1300
+ * `index` and the `total` number of sheets in the workbook. This mirrors the
1301
+ * docx `onPageChange` and pptx `onSlideChange` contracts so all three viewers
1302
+ * share one callback shape. To get the sheet *name*, look it up by index from
1303
+ * `viewer.sheetNames[index]` (or the `sheetNames` array delivered to
1304
+ * `onReady`).
1305
+ */
1306
+ onSheetChange?: (index: number, total: number) => void;
1221
1307
  onError?: (err: Error) => void;
1222
1308
  /** Called when the selected cell range changes. null means no selection. */
1223
1309
  onSelectionChange?: (selection: CellRange | null) => void;