@trebco/treb 29.5.1 → 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.1",
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?
@@ -296,7 +296,7 @@ export class Exporter {
296
296
  if (edge.rgba) {
297
297
  return { rgb: edge.rgba };
298
298
  }
299
- if (edge.theme) {
299
+ if (typeof edge.theme !== 'undefined') {
300
300
  return {
301
301
  theme: edge.theme,
302
302
  tint: edge.tint,
@@ -393,6 +393,8 @@ export class Exporter {
393
393
 
394
394
  };
395
395
 
396
+ // console.info({style_cache});
397
+
396
398
  const fonts: DOMContent[] = style_cache.fonts.map(font => {
397
399
 
398
400
  return {
@@ -413,7 +415,7 @@ export class Exporter {
413
415
 
414
416
  color: font.color_argb ? {
415
417
  a$: { rgb: font.color_argb },
416
- } : font.color_theme ? {
418
+ } : (typeof font.color_theme !== 'undefined') ? {
417
419
  a$: {
418
420
  theme: font.color_theme,
419
421
  tint: font.color_tint,
@@ -501,6 +503,8 @@ export class Exporter {
501
503
  };
502
504
 
503
505
  const xml = XMLDeclaration + this.xmlbuilder1.build(dom);
506
+ // console.info(xml);
507
+
504
508
  this.zip?.Set('xl/styles.xml', xml);
505
509
 
506
510
  }
@@ -607,9 +611,13 @@ export class Exporter {
607
611
 
608
612
  const list: CellStyle[] = [sheet.sheet_style];
609
613
 
614
+ /*
615
+ // should apply to rows, not cells
616
+
610
617
  if (sheet.row_pattern && sheet.row_pattern.length) {
611
618
  list.push(sheet.row_pattern[row % sheet.row_pattern.length]);
612
619
  }
620
+ */
613
621
 
614
622
  // is this backwards, vis a vis our rendering? I think it might be...
615
623
  // YES: should be row pattern -> row -> column -> cell [corrected]
@@ -274,6 +274,10 @@ export class StyleCache {
274
274
  symbolic_name: composite.number_format, // for reference later
275
275
  };
276
276
 
277
+ if (/Scientific/i.test(composite.number_format)) {
278
+ options.number_format.format = '0.00E+00'
279
+ }
280
+
277
281
  }
278
282
 
279
283
 
@@ -305,6 +309,7 @@ export class StyleCache {
305
309
  //}
306
310
 
307
311
  if (composite.text) {
312
+
308
313
  if (IsHTMLColor(composite.text)) {
309
314
  font.color_argb = composite.text.text;
310
315
  }