@silurus/ooxml 0.42.0 → 0.44.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.
@@ -124,7 +124,12 @@ export declare type DocRun = {
124
124
  type: 'field';
125
125
  } & FieldRun | {
126
126
  type: 'shape';
127
- } & ShapeRun;
127
+ } & ShapeRun | {
128
+ type: 'math';
129
+ nodes: MathNode[];
130
+ display: boolean;
131
+ fontSize: number;
132
+ };
128
133
 
129
134
  declare interface DocTable {
130
135
  colWidths: number[];
@@ -134,6 +139,8 @@ declare interface DocTable {
134
139
  cellMarginBottom: number;
135
140
  cellMarginLeft: number;
136
141
  cellMarginRight: number;
142
+ /** table horizontal alignment on the page: 'left' | 'center' | 'right'. */
143
+ jc: string;
137
144
  }
138
145
 
139
146
  declare interface DocTableCell {
@@ -379,6 +386,109 @@ declare interface LoadOptions_2 {
379
386
  useGoogleFonts?: boolean;
380
387
  }
381
388
 
389
+ /** Accent (`m:acc`), e.g. hat, bar, vector arrow over the base. */
390
+ declare interface MathAccent {
391
+ kind: 'accent';
392
+ char: string;
393
+ base: MathNode[];
394
+ }
395
+
396
+ /** Matrix (`m:m`) or aligned equation array (`m:eqArr`). rows → cells → nodes. */
397
+ declare interface MathArray {
398
+ kind: 'array';
399
+ rows: MathNode[][][];
400
+ /** 'eq' = alternating right/left (eqArr); 'center' = matrix; 'left'. */
401
+ align: 'eq' | 'center' | 'left';
402
+ }
403
+
404
+ /** Over/under bar (`m:bar`). */
405
+ declare interface MathBar {
406
+ kind: 'bar';
407
+ pos: 'top' | 'bot';
408
+ base: MathNode[];
409
+ }
410
+
411
+ declare interface MathDelimiter {
412
+ kind: 'delimiter';
413
+ /** opening char (default '('). */
414
+ begChar: string;
415
+ /** closing char (default ')'). */
416
+ endChar: string;
417
+ /** separated groups (e.g. for cases / multiple args). */
418
+ items: MathNode[][];
419
+ }
420
+
421
+ declare interface MathFraction {
422
+ kind: 'fraction';
423
+ num: MathNode[];
424
+ den: MathNode[];
425
+ /** false = no rule (e.g. binomial); defaults to true. */
426
+ bar?: boolean;
427
+ }
428
+
429
+ declare interface MathFunc {
430
+ kind: 'func';
431
+ name: MathNode[];
432
+ arg: MathNode[];
433
+ }
434
+
435
+ declare interface MathGroup {
436
+ kind: 'group';
437
+ items: MathNode[];
438
+ }
439
+
440
+ /** Group character (`m:groupChr`), e.g. under/over brace. */
441
+ declare interface MathGroupChr {
442
+ kind: 'groupChr';
443
+ char: string;
444
+ pos: 'top' | 'bot';
445
+ base: MathNode[];
446
+ }
447
+
448
+ /** Lower/upper limit (`m:limLow` / `m:limUpp`), e.g. lim under n→∞. */
449
+ declare interface MathLimit {
450
+ kind: 'limit';
451
+ base: MathNode[];
452
+ lower?: MathNode[];
453
+ upper?: MathNode[];
454
+ }
455
+
456
+ declare interface MathNary {
457
+ kind: 'nary';
458
+ /** operator char, e.g. '∑', '∫', '∏'. */
459
+ op: string;
460
+ /** limit location (`m:limLoc`): 'subSup' = beside the op, 'undOvr' = above/below.
461
+ * Empty/omitted = default by operator class (integrals → subSup, others → undOvr). */
462
+ limLoc?: string;
463
+ sub?: MathNode[];
464
+ sup?: MathNode[];
465
+ body: MathNode[];
466
+ }
467
+
468
+ declare type MathNode = MathRun | MathFraction | MathScript | MathNary | MathDelimiter | MathRadical | MathLimit | MathArray | MathGroupChr | MathBar | MathAccent | MathFunc | MathGroup;
469
+
470
+ declare interface MathRadical {
471
+ kind: 'radical';
472
+ /** optional index (e.g. cube root); empty/omitted = square root. */
473
+ index?: MathNode[];
474
+ radicand: MathNode[];
475
+ }
476
+
477
+ declare interface MathRun {
478
+ kind: 'run';
479
+ text: string;
480
+ style: MathStyle;
481
+ }
482
+
483
+ declare interface MathScript {
484
+ kind: 'sup' | 'sub' | 'subSup';
485
+ base: MathNode[];
486
+ sup?: MathNode[];
487
+ sub?: MathNode[];
488
+ }
489
+
490
+ declare type MathStyle = 'roman' | 'italic' | 'bold' | 'boldItalic';
491
+
382
492
  declare interface NumberingInfo {
383
493
  numId: number;
384
494
  level: number;
@@ -421,6 +421,18 @@ declare interface ChartElement {
421
421
  catAxisFontSizeHpt: number | null;
422
422
  /** `<c:valAx><c:txPr>` font size (hpt). null = proportional default. */
423
423
  valAxisFontSizeHpt: number | null;
424
+ /** `<c:catAx><c:txPr>…<a:solidFill>` tick-label color (hex without '#'). */
425
+ catAxisFontColor?: string | null;
426
+ /** `<c:valAx><c:txPr>…<a:solidFill>` tick-label color (hex without '#'). */
427
+ valAxisFontColor?: string | null;
428
+ /** `<c:catAx><c:spPr><a:ln><a:solidFill>` axis-line color (hex without '#'). */
429
+ catAxisLineColor?: string | null;
430
+ /** `<c:catAx><c:spPr><a:ln w>` axis-line width in EMU. */
431
+ catAxisLineWidthEmu?: number | null;
432
+ /** `<c:valAx><c:spPr><a:ln><a:solidFill>` axis-line color (hex without '#'). */
433
+ valAxisLineColor?: string | null;
434
+ /** `<c:valAx><c:spPr><a:ln w>` axis-line width in EMU. */
435
+ valAxisLineWidthEmu?: number | null;
424
436
  /** `<c:dLbls><c:txPr>` font size (hpt) for data-point value labels. */
425
437
  dataLabelFontSizeHpt: number | null;
426
438
  /** `<c:legend><c:legendPos val>` — "r" (default) | "l" | "t" | "b" | "tr". */
@@ -693,7 +705,12 @@ declare type DocRun = {
693
705
  type: 'field';
694
706
  } & FieldRun | {
695
707
  type: 'shape';
696
- } & ShapeRun;
708
+ } & ShapeRun | {
709
+ type: 'math';
710
+ nodes: MathNode[];
711
+ display: boolean;
712
+ fontSize: number;
713
+ };
697
714
 
698
715
  declare interface DocTable {
699
716
  colWidths: number[];
@@ -703,6 +720,8 @@ declare interface DocTable {
703
720
  cellMarginBottom: number;
704
721
  cellMarginLeft: number;
705
722
  cellMarginRight: number;
723
+ /** table horizontal alignment on the page: 'left' | 'center' | 'right'. */
724
+ jc: string;
706
725
  }
707
726
 
708
727
  declare interface DocTableCell {
@@ -1138,6 +1157,109 @@ declare interface ManualLayout {
1138
1157
  h?: number;
1139
1158
  }
1140
1159
 
1160
+ /** Accent (`m:acc`), e.g. hat, bar, vector arrow over the base. */
1161
+ declare interface MathAccent {
1162
+ kind: 'accent';
1163
+ char: string;
1164
+ base: MathNode[];
1165
+ }
1166
+
1167
+ /** Matrix (`m:m`) or aligned equation array (`m:eqArr`). rows → cells → nodes. */
1168
+ declare interface MathArray {
1169
+ kind: 'array';
1170
+ rows: MathNode[][][];
1171
+ /** 'eq' = alternating right/left (eqArr); 'center' = matrix; 'left'. */
1172
+ align: 'eq' | 'center' | 'left';
1173
+ }
1174
+
1175
+ /** Over/under bar (`m:bar`). */
1176
+ declare interface MathBar {
1177
+ kind: 'bar';
1178
+ pos: 'top' | 'bot';
1179
+ base: MathNode[];
1180
+ }
1181
+
1182
+ declare interface MathDelimiter {
1183
+ kind: 'delimiter';
1184
+ /** opening char (default '('). */
1185
+ begChar: string;
1186
+ /** closing char (default ')'). */
1187
+ endChar: string;
1188
+ /** separated groups (e.g. for cases / multiple args). */
1189
+ items: MathNode[][];
1190
+ }
1191
+
1192
+ declare interface MathFraction {
1193
+ kind: 'fraction';
1194
+ num: MathNode[];
1195
+ den: MathNode[];
1196
+ /** false = no rule (e.g. binomial); defaults to true. */
1197
+ bar?: boolean;
1198
+ }
1199
+
1200
+ declare interface MathFunc {
1201
+ kind: 'func';
1202
+ name: MathNode[];
1203
+ arg: MathNode[];
1204
+ }
1205
+
1206
+ declare interface MathGroup {
1207
+ kind: 'group';
1208
+ items: MathNode[];
1209
+ }
1210
+
1211
+ /** Group character (`m:groupChr`), e.g. under/over brace. */
1212
+ declare interface MathGroupChr {
1213
+ kind: 'groupChr';
1214
+ char: string;
1215
+ pos: 'top' | 'bot';
1216
+ base: MathNode[];
1217
+ }
1218
+
1219
+ /** Lower/upper limit (`m:limLow` / `m:limUpp`), e.g. lim under n→∞. */
1220
+ declare interface MathLimit {
1221
+ kind: 'limit';
1222
+ base: MathNode[];
1223
+ lower?: MathNode[];
1224
+ upper?: MathNode[];
1225
+ }
1226
+
1227
+ declare interface MathNary {
1228
+ kind: 'nary';
1229
+ /** operator char, e.g. '∑', '∫', '∏'. */
1230
+ op: string;
1231
+ /** limit location (`m:limLoc`): 'subSup' = beside the op, 'undOvr' = above/below.
1232
+ * Empty/omitted = default by operator class (integrals → subSup, others → undOvr). */
1233
+ limLoc?: string;
1234
+ sub?: MathNode[];
1235
+ sup?: MathNode[];
1236
+ body: MathNode[];
1237
+ }
1238
+
1239
+ declare type MathNode = MathRun | MathFraction | MathScript | MathNary | MathDelimiter | MathRadical | MathLimit | MathArray | MathGroupChr | MathBar | MathAccent | MathFunc | MathGroup;
1240
+
1241
+ declare interface MathRadical {
1242
+ kind: 'radical';
1243
+ /** optional index (e.g. cube root); empty/omitted = square root. */
1244
+ index?: MathNode[];
1245
+ radicand: MathNode[];
1246
+ }
1247
+
1248
+ declare interface MathRun {
1249
+ kind: 'run';
1250
+ text: string;
1251
+ style: MathStyle;
1252
+ }
1253
+
1254
+ declare interface MathScript {
1255
+ kind: 'sup' | 'sub' | 'subSup';
1256
+ base: MathNode[];
1257
+ sup?: MathNode[];
1258
+ sub?: MathNode[];
1259
+ }
1260
+
1261
+ declare type MathStyle = 'roman' | 'italic' | 'bold' | 'boldItalic';
1262
+
1141
1263
  declare interface MediaElement {
1142
1264
  type: 'media';
1143
1265
  x: number;
@@ -1986,6 +2108,10 @@ declare interface SheetMeta {
1986
2108
  name: string;
1987
2109
  sheetId: number;
1988
2110
  rId: string;
2111
+ /** Sheet tab color (`<sheetPr><tabColor>`, ECMA-376 §18.3.1.93) resolved to
2112
+ * `#RRGGBB`. Surfaced at workbook-list time so tabs can be painted up front.
2113
+ * Absent when the sheet declares no tab color. */
2114
+ tabColor?: string | null;
1989
2115
  }
1990
2116
 
1991
2117
  declare interface SlicerAnchor {
@@ -2568,7 +2694,12 @@ declare class XlsxViewer {
2568
2694
  private tabStrip;
2569
2695
  private navPrev;
2570
2696
  private navNext;
2697
+ private navGroup;
2571
2698
  private tabs;
2699
+ /** Per-tab colors parallel to `tabs`, from `<sheetPr><tabColor>`. */
2700
+ private tabColors;
2701
+ private zoomSlider;
2702
+ private zoomLabel;
2572
2703
  private currentSheet;
2573
2704
  private currentWorksheet;
2574
2705
  private opts;
@@ -2611,6 +2742,18 @@ declare class XlsxViewer {
2611
2742
  private updateNavButtons;
2612
2743
  private updateTabActive;
2613
2744
  private tabStyle;
2745
+ /** Excel-style zoom control pinned to the right end of the tab bar:
2746
+ * `− [────slider────] + 100%`. Live-updates the cell scale on input. */
2747
+ private buildZoomControl;
2748
+ /** Map a slider position [0,100] to a scale factor. 50 → 1.0 (100%), with a
2749
+ * separate linear segment on each side so the center is always 100%. */
2750
+ private zoomPosToScale;
2751
+ /** Inverse of {@link zoomPosToScale}: scale factor → slider position [0,100]. */
2752
+ private zoomScaleToPos;
2753
+ /** Set the cell/header scale and re-lay-out the current sheet. Clamped to the
2754
+ * zoom bounds; keeps the slider thumb, percentage label and the row-header-
2755
+ * aligned tab-nav width in sync. */
2756
+ setScale(scale: number): void;
2614
2757
  private updateSpacerSize;
2615
2758
  private renderCurrentSheet;
2616
2759
  private computeHeaderHighlight;
@@ -2621,6 +2764,14 @@ declare class XlsxViewer {
2621
2764
  declare interface XlsxViewerOptions {
2622
2765
  /** Scale factor for cell/header dimensions (default 1). 0.5 = half size. */
2623
2766
  cellScale?: number;
2767
+ /** Show the Excel-style zoom slider at the right end of the sheet-tab bar.
2768
+ * Default `true`. Set `false` to hide it (e.g. when the host supplies its
2769
+ * own zoom control). */
2770
+ showZoomSlider?: boolean;
2771
+ /** Lower/upper bounds for the zoom slider as scale factors. Default 0.1–4
2772
+ * (10%–400%, matching Excel's zoom range). */
2773
+ zoomMin?: number;
2774
+ zoomMax?: number;
2624
2775
  onReady?: (sheetNames: string[]) => void;
2625
2776
  onSheetChange?: (index: number, name: string) => void;
2626
2777
  onError?: (err: Error) => void;
@@ -2654,6 +2805,9 @@ declare class XlsxWorkbook {
2654
2805
  load(source: string | ArrayBuffer, opts?: LoadOptions_3): Promise<void>;
2655
2806
  get sheetNames(): string[];
2656
2807
  get sheetCount(): number;
2808
+ /** Per-sheet tab colors (`#RRGGBB`) parallel to {@link sheetNames}.
2809
+ * `null` for sheets that declare no tab color. */
2810
+ get tabColors(): (string | null)[];
2657
2811
  getWorksheet(sheetIndex: number): Promise<Worksheet>;
2658
2812
  renderViewport(target: HTMLCanvasElement | OffscreenCanvas, sheetIndex: number, viewport: ViewportRange, opts?: RenderViewportOptions): Promise<void>;
2659
2813
  destroy(): void;
@@ -116,6 +116,18 @@ declare interface ChartElement {
116
116
  catAxisFontSizeHpt: number | null;
117
117
  /** `<c:valAx><c:txPr>` font size (hpt). null = proportional default. */
118
118
  valAxisFontSizeHpt: number | null;
119
+ /** `<c:catAx><c:txPr>…<a:solidFill>` tick-label color (hex without '#'). */
120
+ catAxisFontColor?: string | null;
121
+ /** `<c:valAx><c:txPr>…<a:solidFill>` tick-label color (hex without '#'). */
122
+ valAxisFontColor?: string | null;
123
+ /** `<c:catAx><c:spPr><a:ln><a:solidFill>` axis-line color (hex without '#'). */
124
+ catAxisLineColor?: string | null;
125
+ /** `<c:catAx><c:spPr><a:ln w>` axis-line width in EMU. */
126
+ catAxisLineWidthEmu?: number | null;
127
+ /** `<c:valAx><c:spPr><a:ln><a:solidFill>` axis-line color (hex without '#'). */
128
+ valAxisLineColor?: string | null;
129
+ /** `<c:valAx><c:spPr><a:ln w>` axis-line width in EMU. */
130
+ valAxisLineWidthEmu?: number | null;
119
131
  /** `<c:dLbls><c:txPr>` font size (hpt) for data-point value labels. */
120
132
  dataLabelFontSizeHpt: number | null;
121
133
  /** `<c:legend><c:legendPos val>` — "r" (default) | "l" | "t" | "b" | "tr". */
@@ -703,6 +703,10 @@ export declare interface SheetMeta {
703
703
  name: string;
704
704
  sheetId: number;
705
705
  rId: string;
706
+ /** Sheet tab color (`<sheetPr><tabColor>`, ECMA-376 §18.3.1.93) resolved to
707
+ * `#RRGGBB`. Surfaced at workbook-list time so tabs can be painted up front.
708
+ * Absent when the sheet declares no tab color. */
709
+ tabColor?: string | null;
706
710
  }
707
711
 
708
712
  declare interface SlicerAnchor {
@@ -952,7 +956,12 @@ export declare class XlsxViewer {
952
956
  private tabStrip;
953
957
  private navPrev;
954
958
  private navNext;
959
+ private navGroup;
955
960
  private tabs;
961
+ /** Per-tab colors parallel to `tabs`, from `<sheetPr><tabColor>`. */
962
+ private tabColors;
963
+ private zoomSlider;
964
+ private zoomLabel;
956
965
  private currentSheet;
957
966
  private currentWorksheet;
958
967
  private opts;
@@ -995,6 +1004,18 @@ export declare class XlsxViewer {
995
1004
  private updateNavButtons;
996
1005
  private updateTabActive;
997
1006
  private tabStyle;
1007
+ /** Excel-style zoom control pinned to the right end of the tab bar:
1008
+ * `− [────slider────] + 100%`. Live-updates the cell scale on input. */
1009
+ private buildZoomControl;
1010
+ /** Map a slider position [0,100] to a scale factor. 50 → 1.0 (100%), with a
1011
+ * separate linear segment on each side so the center is always 100%. */
1012
+ private zoomPosToScale;
1013
+ /** Inverse of {@link zoomPosToScale}: scale factor → slider position [0,100]. */
1014
+ private zoomScaleToPos;
1015
+ /** Set the cell/header scale and re-lay-out the current sheet. Clamped to the
1016
+ * zoom bounds; keeps the slider thumb, percentage label and the row-header-
1017
+ * aligned tab-nav width in sync. */
1018
+ setScale(scale: number): void;
998
1019
  private updateSpacerSize;
999
1020
  private renderCurrentSheet;
1000
1021
  private computeHeaderHighlight;
@@ -1005,6 +1026,14 @@ export declare class XlsxViewer {
1005
1026
  export declare interface XlsxViewerOptions {
1006
1027
  /** Scale factor for cell/header dimensions (default 1). 0.5 = half size. */
1007
1028
  cellScale?: number;
1029
+ /** Show the Excel-style zoom slider at the right end of the sheet-tab bar.
1030
+ * Default `true`. Set `false` to hide it (e.g. when the host supplies its
1031
+ * own zoom control). */
1032
+ showZoomSlider?: boolean;
1033
+ /** Lower/upper bounds for the zoom slider as scale factors. Default 0.1–4
1034
+ * (10%–400%, matching Excel's zoom range). */
1035
+ zoomMin?: number;
1036
+ zoomMax?: number;
1008
1037
  onReady?: (sheetNames: string[]) => void;
1009
1038
  onSheetChange?: (index: number, name: string) => void;
1010
1039
  onError?: (err: Error) => void;
@@ -1038,6 +1067,9 @@ export declare class XlsxWorkbook {
1038
1067
  load(source: string | ArrayBuffer, opts?: LoadOptions): Promise<void>;
1039
1068
  get sheetNames(): string[];
1040
1069
  get sheetCount(): number;
1070
+ /** Per-sheet tab colors (`#RRGGBB`) parallel to {@link sheetNames}.
1071
+ * `null` for sheets that declare no tab color. */
1072
+ get tabColors(): (string | null)[];
1041
1073
  getWorksheet(sheetIndex: number): Promise<Worksheet>;
1042
1074
  renderViewport(target: HTMLCanvasElement | OffscreenCanvas, sheetIndex: number, viewport: ViewportRange, opts?: RenderViewportOptions): Promise<void>;
1043
1075
  destroy(): void;