@trebco/treb 28.2.0 → 28.2.2

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": "28.2.0",
3
+ "version": "28.2.2",
4
4
  "license": "LGPL-3.0-or-later",
5
5
  "homepage": "https://treb.app",
6
6
  "repository": {
@@ -569,7 +569,7 @@ export class Editor<E = FormulaEditorEvent> extends EventSource<E|FormulaEditorE
569
569
  */
570
570
  protected UpdateColors(force_event = false) {
571
571
 
572
- const view = this.active_editor?.node.ownerDocument.defaultView as (Window & typeof globalThis);
572
+ // const view = this.active_editor?.node.ownerDocument.defaultView as (Window & typeof globalThis);
573
573
 
574
574
  // create a map of canonical label -> area
575
575
 
@@ -597,7 +597,8 @@ export class Editor<E = FormulaEditorEvent> extends EventSource<E|FormulaEditorE
597
597
 
598
598
  for (const entry of this.nodes) {
599
599
  for (const node of Array.from(entry.node.childNodes)) {
600
- if (node instanceof view.HTMLElement && node.dataset.reference) {
600
+ const view = node.ownerDocument?.defaultView as (Window & typeof globalThis);
601
+ if (view && node instanceof view.HTMLElement && node.dataset.reference) {
601
602
  const index = indexes.get(node.dataset.reference);
602
603
  node.dataset.highlightIndex = (typeof index === 'number') ? (index % 5 + 1).toString() : '?';
603
604
  }
@@ -6252,6 +6252,17 @@ export class Grid extends GridBase {
6252
6252
  }
6253
6253
  }
6254
6254
 
6255
+ const SelectFormat = (value: number) => {
6256
+ const log = Math.floor(Math.log10(value));
6257
+ if (log < -6 || log > 10) {
6258
+ return NumberFormatCache.Get('Exponential');
6259
+ }
6260
+ if (log <= -1) {
6261
+ return NumberFormatCache.Get('General');
6262
+ }
6263
+ return NumberFormatCache.Get('Number');
6264
+ };
6265
+
6255
6266
  if (count > 1) {
6256
6267
  if (numbers > 0) {
6257
6268
  const general = NumberFormatCache.Get('General')
@@ -6264,28 +6275,13 @@ export class Grid extends GridBase {
6264
6275
  { label: 'Average', value: NumberFormat.FormatPartsAsText(general.FormatComplex(average)) },
6265
6276
  ];
6266
6277
 
6267
- /*
6268
- return `Count: ${count} Sum: ${
6269
- NumberFormat.FormatPartsAsText(general.FormatComplex(sum))
6270
- } Average: ${
6271
- NumberFormat.FormatPartsAsText(general.FormatComplex(average))
6272
- }`;
6273
- */
6274
6278
  }
6275
6279
  else {
6276
6280
  return [
6277
6281
  { label: 'Count', value: count.toString() },
6278
- { label: 'Sum', value: general.Format(sum.real) },
6279
- { label: 'Average', value: general.Format(sum.real/numbers) },
6282
+ { label: 'Sum', value: (SelectFormat(sum.real)).Format(sum.real) },
6283
+ { label: 'Average', value: (SelectFormat(sum.real/numbers)).Format(sum.real/numbers) },
6280
6284
  ];
6281
-
6282
- /*
6283
- return `Count: ${count} Sum: ${
6284
- general.Format(sum.real)
6285
- } Average: ${
6286
- general.Format(sum.real/numbers)
6287
- }`;
6288
- */
6289
6285
  }
6290
6286
  }
6291
6287
  else {