@trebco/treb 29.5.2 → 29.5.4

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@trebco/treb",
3
- "version": "29.5.2",
3
+ "version": "29.5.4",
4
4
  "license": "LGPL-3.0-or-later",
5
5
  "homepage": "https://treb.app",
6
6
  "repository": {
@@ -74,4 +74,9 @@ export interface SerializeOptions {
74
74
  */
75
75
  export_functions?: boolean;
76
76
 
77
+ /**
78
+ * @internal
79
+ */
80
+ apply_row_pattern?: boolean;
81
+
77
82
  }
@@ -2519,8 +2519,6 @@ export class Sheet {
2519
2519
 
2520
2520
  // same here (note broken naming)
2521
2521
  const sheet_style = JSON.parse(JSON.stringify(this.sheet_style));
2522
- // const row_style = JSON.parse(JSON.stringify(this.row_styles));
2523
- // const column_style = JSON.parse(JSON.stringify(this.column_styles));
2524
2522
  const row_pattern = JSON.parse(JSON.stringify(this.row_pattern));
2525
2523
 
2526
2524
  // row and column styles are Record<number, props> and not arrays.
@@ -2545,13 +2543,36 @@ export class Sheet {
2545
2543
  }
2546
2544
  }
2547
2545
 
2548
- for (const key of Object.keys(this.row_styles)) {
2549
- const index = Number(key);
2550
- const style = this.row_styles[index];
2551
- if (style) {
2552
- const reference = StyleToRef(style);
2546
+ if (this.row_pattern && this.row_pattern.length && options.apply_row_pattern) {
2547
+
2548
+ let count = this.rows + 1;
2549
+
2550
+ for (const key of Object.keys(this.row_styles)) {
2551
+ const index = Number(key);
2552
+ if (!isNaN(index) && index >= count) { count = index + 1; }
2553
+ }
2554
+
2555
+ for (let i = 0; i< count; i++) {
2556
+ const pattern = this.row_pattern[i % this.row_pattern.length];
2557
+ const style = this.row_styles[i] || {};
2558
+ const composite = Style.Composite([pattern, style]);
2559
+ const reference = StyleToRef(composite);
2560
+
2553
2561
  if (reference) {
2554
- row_style[index] = reference;
2562
+ row_style[i] = reference;
2563
+ }
2564
+ }
2565
+
2566
+ }
2567
+ else {
2568
+ for (const key of Object.keys(this.row_styles)) {
2569
+ const index = Number(key);
2570
+ const style = this.row_styles[index];
2571
+ if (style) {
2572
+ const reference = StyleToRef(style);
2573
+ if (reference) {
2574
+ row_style[index] = reference;
2575
+ }
2555
2576
  }
2556
2577
  }
2557
2578
  }
@@ -2822,6 +2822,7 @@ export class EmbeddedSpreadsheet<USER_DATA_TYPE = unknown> {
2822
2822
  tables: true,
2823
2823
  share_resources: false,
2824
2824
  export_functions: true,
2825
+ apply_row_pattern: true, // if there's a row pattern, set it on rows so they export properly
2825
2826
  });
2826
2827
 
2827
2828
  // why do _we_ put this in, instead of the grid method?
@@ -611,9 +611,13 @@ export class Exporter {
611
611
 
612
612
  const list: CellStyle[] = [sheet.sheet_style];
613
613
 
614
+ /*
615
+ // should apply to rows, not cells
616
+
614
617
  if (sheet.row_pattern && sheet.row_pattern.length) {
615
618
  list.push(sheet.row_pattern[row % sheet.row_pattern.length]);
616
619
  }
620
+ */
617
621
 
618
622
  // is this backwards, vis a vis our rendering? I think it might be...
619
623
  // YES: should be row pattern -> row -> column -> cell [corrected]