@bino-bi/bn-template-engine 1.0.0-alpha.13 → 1.0.0-alpha.15

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.
Files changed (93) hide show
  1. package/dist/bn-template-engine/bn-template-engine.esm.js +1 -1
  2. package/dist/bn-template-engine/{p-637e3b8f.entry.js → p-19f49fbc.entry.js} +1 -1
  3. package/dist/bn-template-engine/p-209b3fd9.entry.js +1 -0
  4. package/dist/bn-template-engine/{p-67eae33e.entry.js → p-3465fcdc.entry.js} +1 -1
  5. package/dist/bn-template-engine/{p-82023539.entry.js → p-67746414.entry.js} +1 -1
  6. package/dist/bn-template-engine/p-BPDZcex5.js +1 -0
  7. package/dist/bn-template-engine/{p-DHheVOfP.js → p-Tx6omDWp.js} +1 -1
  8. package/dist/bn-template-engine/{p-52097456.entry.js → p-d724ab88.entry.js} +1 -1
  9. package/dist/bn-template-engine/p-efd3b67a.entry.js +1 -0
  10. package/dist/bn-template-engine/{p-46699464.entry.js → p-ff659485.entry.js} +1 -1
  11. package/dist/bn-template-engine/p-z9bPNFYF.js +1 -0
  12. package/dist/cjs/bn-asset_21.cjs.entry.js +348 -75
  13. package/dist/cjs/bn-grid.cjs.entry.js +2 -2
  14. package/dist/cjs/bn-image.cjs.entry.js +2 -2
  15. package/dist/cjs/bn-internationalization.cjs.entry.js +1 -1
  16. package/dist/cjs/bn-template-engine.cjs.js +1 -1
  17. package/dist/cjs/bn-text.cjs.entry.js +3 -3
  18. package/dist/cjs/bn-tree.cjs.entry.js +2 -2
  19. package/dist/cjs/{context-protocol-Op7uUwN3.js → context-protocol-Cn5PL928.js} +14 -0
  20. package/dist/cjs/editor-companion.cjs.entry.js +1 -1
  21. package/dist/cjs/loader.cjs.js +1 -1
  22. package/dist/cjs/{scaling-57N4Cxb_.js → scaling-DM2UILdF.js} +58 -17
  23. package/dist/cjs/{withStyled-C2kmGAK3.js → withStyled-Dx3uRw9g.js} +72 -1
  24. package/dist/collection/components/bn-chart-structure/utils/StructureChart.js +28 -10
  25. package/dist/collection/components/bn-chart-structure/utils/helper/ElementPositions.js +46 -4
  26. package/dist/collection/components/bn-chart-time/bn-chart-time.js +39 -1
  27. package/dist/collection/components/bn-chart-time/utils/TimeChart.js +40 -10
  28. package/dist/collection/components/bn-dataset/bn-dataset.js +25 -13
  29. package/dist/collection/components/bn-datasource/bn-datasource.js +23 -12
  30. package/dist/collection/components/bn-layout-card/bn-layout-card.css +5 -0
  31. package/dist/collection/components/bn-layout-card/bn-layout-card.js +6 -3
  32. package/dist/collection/components/bn-layout-page/bn-layout-page.css +5 -0
  33. package/dist/collection/components/bn-layout-page/bn-layout-page.js +6 -3
  34. package/dist/collection/components/bn-table/bn-table.js +75 -7
  35. package/dist/collection/components/bn-table/ibcs-table.js +27 -0
  36. package/dist/collection/components/bn-table/utils/Table.js +2 -2
  37. package/dist/collection/components/bn-table/utils/factories/tableDataSetFactory.js +28 -5
  38. package/dist/collection/components/bn-table/utils/helper/DataQuery.js +46 -6
  39. package/dist/collection/components/bn-table/utils/model/TableAttribute.js +46 -0
  40. package/dist/collection/components/bn-table/utils/model/TableComponentConfig.js +5 -0
  41. package/dist/collection/context/scopedDb.js +14 -0
  42. package/dist/collection/utils/parentDimensions.js +57 -16
  43. package/dist/collection/utils/validate.js +23 -0
  44. package/dist/components/DateStringFactory.js +1 -1
  45. package/dist/components/Order.js +1 -1
  46. package/dist/components/bn-chart-structure.js +1 -1
  47. package/dist/components/bn-chart-time.js +1 -1
  48. package/dist/components/bn-dataset.js +1 -1
  49. package/dist/components/bn-datasource.js +1 -1
  50. package/dist/components/bn-layout-card.js +1 -1
  51. package/dist/components/bn-layout-page.js +1 -1
  52. package/dist/components/bn-table.js +1 -1
  53. package/dist/components/bn-title2.js +1 -1
  54. package/dist/components/context-protocol.js +1 -1
  55. package/dist/components/ibcs-chart-structure2.js +1 -1
  56. package/dist/components/ibcs-chart-time2.js +1 -1
  57. package/dist/components/ibcs-table2.js +1 -1
  58. package/dist/components/ibcs-title2.js +1 -1
  59. package/dist/components/scaling.js +1 -1
  60. package/dist/components/validate.js +1 -1
  61. package/dist/esm/bn-asset_21.entry.js +348 -75
  62. package/dist/esm/bn-grid.entry.js +2 -2
  63. package/dist/esm/bn-image.entry.js +2 -2
  64. package/dist/esm/bn-internationalization.entry.js +1 -1
  65. package/dist/esm/bn-template-engine.js +1 -1
  66. package/dist/esm/bn-text.entry.js +3 -3
  67. package/dist/esm/bn-tree.entry.js +2 -2
  68. package/dist/esm/{context-protocol-BDhzNbeD.js → context-protocol-BB-4Onmw.js} +14 -0
  69. package/dist/esm/editor-companion.entry.js +1 -1
  70. package/dist/esm/loader.js +1 -1
  71. package/dist/esm/{scaling-La1Ow72h.js → scaling-h4KcBet3.js} +58 -17
  72. package/dist/esm/{withStyled-Bl9cSoRW.js → withStyled-BBvU2f-A.js} +71 -2
  73. package/dist/types/components/bn-chart-structure/utils/StructureChart.d.ts +4 -0
  74. package/dist/types/components/bn-chart-structure/utils/helper/ElementPositions.d.ts +16 -1
  75. package/dist/types/components/bn-chart-time/bn-chart-time.d.ts +13 -0
  76. package/dist/types/components/bn-chart-time/utils/TimeChart.d.ts +4 -0
  77. package/dist/types/components/bn-dataset/bn-dataset.d.ts +15 -7
  78. package/dist/types/components/bn-datasource/bn-datasource.d.ts +13 -6
  79. package/dist/types/components/bn-layout-card/bn-layout-card.d.ts +1 -0
  80. package/dist/types/components/bn-layout-page/bn-layout-page.d.ts +1 -0
  81. package/dist/types/components/bn-table/bn-table.d.ts +13 -0
  82. package/dist/types/components/bn-table/ibcs-table.d.ts +2 -0
  83. package/dist/types/components/bn-table/utils/factories/tableDataSetFactory.d.ts +3 -1
  84. package/dist/types/components/bn-table/utils/helper/DataQuery.d.ts +11 -0
  85. package/dist/types/components/bn-table/utils/model/TableAttribute.d.ts +22 -0
  86. package/dist/types/components/bn-table/utils/model/TableComponentConfig.d.ts +3 -0
  87. package/dist/types/components.d.ts +45 -20
  88. package/dist/types/utils/validate.d.ts +6 -0
  89. package/package.json +1 -1
  90. package/dist/bn-template-engine/p-3c827826.entry.js +0 -1
  91. package/dist/bn-template-engine/p-BVFHvEXF.js +0 -1
  92. package/dist/bn-template-engine/p-CQnZV3JG.js +0 -1
  93. package/dist/bn-template-engine/p-ab3ea8cf.entry.js +0 -1
@@ -1,9 +1,9 @@
1
1
  import { r as registerInstance, h, H as Host, g as getElement, f as forceUpdate, d as writeTask, e as getAssetPath, F as Fragment$1 } from './index-B_d-jp99.js';
2
2
  import { w as withComponentStatus, a as withHasError, r as runIfExisits } from './withHasError-DW_vMDUp.js';
3
- import { g as getStores, c as clearStoresCache, a as globalLabelKeys, b as getDefaultExportFromCjs, d as getOrCreateStores, D as DateTime, e as buildFromExpr } from './context-protocol-BDhzNbeD.js';
3
+ import { g as getStores, c as clearStoresCache, a as globalLabelKeys, b as getDefaultExportFromCjs, d as getOrCreateStores, D as DateTime, e as buildFromExpr } from './context-protocol-BB-4Onmw.js';
4
4
  import { w as withBodyObserver } from './withBodyObserver-IokS6fHD.js';
5
- import { a as withComponentStyle, v as validateScenarioList, c as validateVariancesList, b as isValidNumber, d as isValidLevel, e as validateOrderList, f as isValidDirection, g as isValidInteger, i as isValidBoolean, h as isValidMeasureScale, j as validateStackConfig, w as withStyled, k as isBlankInput, A as AggregationLevel$1, O as OrderDirection$1, l as OrderColumn, S as StackBy, m as StackOrder, n as StackMode, o as isValidDateFormat, p as isValidAxisLabelsMode, D as DateDistance, q as AxisLabelsMode, C as ChartMode, r as murmur2, s as isTableBarColumnWidth, t as isValidDataFormat, u as isValidTableType, x as validateThereOfJsonStr, y as validatePartOfJsonStr, z as isValidMeasureType, B as isTableCategoryWidth, E as validateColumnThereOfJsonStr, F as DataFormat, I as I18nMode, T as TableCategoryWidth, M as MeasureType, G as BAR_COLUMN_WIDTH_EM, H as TableBarColumnWidth, J as validateMeasureList, K as isValidDate, L as isValidDateLink, N as DateLink, P as AdapterUtils, Q as CompareUtil, R as OrderAdapter, U as DateStringFactory } from './withStyled-Bl9cSoRW.js';
6
- import { a as withDataset, w as withTranslation, g as getParentDimensions, p as parseScaling } from './scaling-La1Ow72h.js';
5
+ import { a as withComponentStyle, v as validateScenarioList, c as validateVariancesList, b as isValidNumber, d as isValidLevel, e as validateOrderList, f as isValidDirection, g as isValidInteger, i as isValidBoolean, h as isValidMeasureScale, j as validateStackConfig, w as withStyled, k as isBlankInput, A as AggregationLevel$1, O as OrderDirection$1, l as OrderColumn, S as StackBy, m as StackOrder, n as StackMode, o as isValidDateFormat, p as isValidAxisLabelsMode, D as DateDistance, q as AxisLabelsMode, C as ChartMode, r as murmur2, s as isTableBarColumnWidth, t as isValidDataFormat, u as isValidTableType, x as validateThereOfJsonStr, y as validatePartOfJsonStr, z as isValidMeasureType, B as isTableCategoryWidth, E as validateColumnThereOfJsonStr, F as validateAttributesJsonStr, G as DataFormat, I as I18nMode, T as TableCategoryWidth, M as MeasureType, H as parseTableAttributeExpression, J as BAR_COLUMN_WIDTH_EM, K as TableBarColumnWidth, L as validateMeasureList, N as isValidDate, P as isValidDateLink, Q as DateLink, R as AdapterUtils, U as CompareUtil, V as OrderAdapter, W as DateStringFactory } from './withStyled-BBvU2f-A.js';
6
+ import { a as withDataset, w as withTranslation, g as getParentDimensions, p as parseScaling } from './scaling-h4KcBet3.js';
7
7
 
8
8
  const bnAssetCss = () => `:host{display:none}`;
9
9
 
@@ -1912,6 +1912,8 @@ const Chart = class {
1912
1912
  this.pixelPerUnitGroupMap = new Map();
1913
1913
  this._autoScaleGuard = false;
1914
1914
  this._lastObservedWidth = 0;
1915
+ this._settleTimer = null;
1916
+ this._lastAppliedHeight = 0;
1915
1917
  withStyled(this);
1916
1918
  withComponentStatus(this);
1917
1919
  withDataset(this, (name, _data) => {
@@ -2041,17 +2043,53 @@ const Chart = class {
2041
2043
  forceUpdate(this);
2042
2044
  });
2043
2045
  });
2046
+ this.settleParentHeight();
2047
+ }
2048
+ /**
2049
+ * The initial renders can measure mid-hydration, before ancestor CSS
2050
+ * (fixed page height, overflow) is applied, so the height used for
2051
+ * auto-fit may be a transient value — and the resize observer above
2052
+ * deliberately ignores height changes. Re-measure on a short backoff
2053
+ * schedule and re-render when the measurement no longer matches the
2054
+ * height the last render actually used (_lastAppliedHeight, recorded
2055
+ * in prepareDimension). The schedule is finite, so this cannot feed a
2056
+ * render loop.
2057
+ */
2058
+ settleParentHeight() {
2059
+ const delays = [150, 400, 1000, 2500];
2060
+ const check = () => {
2061
+ this._settleTimer = null;
2062
+ if (!this.element.isConnected)
2063
+ return;
2064
+ const { height } = getParentDimensions(this.element);
2065
+ // 8px threshold: hydration corrections are large (hundreds of px);
2066
+ // small jitter must not cause re-renders, because every re-render
2067
+ // gives the width-overflow font scaler a chance to ratchet down.
2068
+ if (height > 0 && Math.abs(height - this._lastAppliedHeight) > 8 && !this._autoScaleGuard) {
2069
+ forceUpdate(this);
2070
+ }
2071
+ const next = delays.shift();
2072
+ if (next !== undefined) {
2073
+ this._settleTimer = setTimeout(check, next);
2074
+ }
2075
+ };
2076
+ this._settleTimer = setTimeout(check, delays.shift());
2044
2077
  }
2045
2078
  disconnectedCallback() {
2046
2079
  var _a;
2047
2080
  (_a = this.layoutObserver) === null || _a === void 0 ? void 0 : _a.disconnect();
2048
2081
  this.layoutObserver = null;
2082
+ if (this._settleTimer != null) {
2083
+ clearTimeout(this._settleTimer);
2084
+ this._settleTimer = null;
2085
+ }
2049
2086
  }
2050
2087
  prepareDimension() {
2051
2088
  const parent = getParentDimensions(this.element);
2052
2089
  const scenariosList = this.prepareScenarios();
2053
2090
  const variancesList = this.prepareVariances();
2054
2091
  this.canvasWidthSegmented = parent.width / (scenariosList.length + variancesList.length || 1);
2092
+ this._lastAppliedHeight = parent.height;
2055
2093
  return { width: this.canvasWidthSegmented, height: parent.height };
2056
2094
  }
2057
2095
  prepareScenarios() {
@@ -2455,7 +2493,7 @@ const Chart = class {
2455
2493
  scenariosArray = [...scenariosArray, ...variancesArray];
2456
2494
  }
2457
2495
  const fontStyles = this.getFontStyles();
2458
- return (h(Host, { key: 'fbef96ebdfa241564095c6def748082bfec0e6a4', style: fontStyles }, h("div", { key: '77d3168f126a779db1e0fbeed2f8a220a2f36792', class: "container" }, scenariosArray.map(this.chartTemplate))));
2496
+ return (h(Host, { key: '8c90dcaacd6b4e1b64b1fb4a8aefe1345086e7e6', style: fontStyles }, h("div", { key: 'c0209d2fd9fcf5ee60c3f17697c7bcbf1b445fec', class: "container" }, scenariosArray.map(this.chartTemplate))));
2459
2497
  }
2460
2498
  get element() { return getElement(this); }
2461
2499
  static get watchers() { return {
@@ -3297,7 +3335,7 @@ const Dataset = class {
3297
3335
  }
3298
3336
  // --- Leaving URL mode → clean up ---
3299
3337
  if (this.currentUrl !== null) {
3300
- this.clearPolling();
3338
+ this.cancelInFlight();
3301
3339
  this.currentUrl = null;
3302
3340
  }
3303
3341
  let contentHash;
@@ -3415,7 +3453,7 @@ const Dataset = class {
3415
3453
  }
3416
3454
  disconnectedCallback() {
3417
3455
  var _a, _b;
3418
- this.clearPolling();
3456
+ this.cancelInFlight();
3419
3457
  if (((_b = (_a = this.stores) === null || _a === void 0 ? void 0 : _a.db) === null || _b === void 0 ? void 0 : _b.db) && this.name) {
3420
3458
  const db = this.stores.db.db;
3421
3459
  try {
@@ -3436,10 +3474,14 @@ const Dataset = class {
3436
3474
  }
3437
3475
  }
3438
3476
  /**
3439
- * Returns `true` if the text starts with `http://` or `https://`.
3477
+ * Returns `true` if the text is a fetchable URL: an absolute `http(s)://`
3478
+ * URL, or a same-origin path starting with `/` (but not `//`, which is a
3479
+ * protocol-relative URL we treat as inline-mode escape).
3440
3480
  */
3441
3481
  isUrl(text) {
3442
- return text.startsWith("http://") || text.startsWith("https://");
3482
+ if (text.startsWith("http://") || text.startsWith("https://"))
3483
+ return true;
3484
+ return text.startsWith("/") && !text.startsWith("//");
3443
3485
  }
3444
3486
  /**
3445
3487
  * Fetches JSON from the given URL and stores the result as the dataset.
@@ -3469,19 +3511,26 @@ const Dataset = class {
3469
3511
  this.publish([]);
3470
3512
  }
3471
3513
  }
3472
- /** Stops the polling timer and cancels any in-flight fetch. */
3473
- clearPolling() {
3474
- var _a;
3514
+ /** Stops the polling timer (does NOT touch any in-flight fetch). */
3515
+ clearPollTimer() {
3475
3516
  if (this.pollTimerId !== null) {
3476
3517
  clearInterval(this.pollTimerId);
3477
3518
  this.pollTimerId = null;
3478
3519
  }
3520
+ }
3521
+ /** Stops the polling timer AND cancels any in-flight fetch. Use only when
3522
+ * leaving URL mode entirely (disconnect or body changed to inline). */
3523
+ cancelInFlight() {
3524
+ var _a;
3525
+ this.clearPollTimer();
3479
3526
  (_a = this.abortController) === null || _a === void 0 ? void 0 : _a.abort();
3480
3527
  this.abortController = null;
3481
3528
  }
3482
- /** Starts (or restarts) the polling timer if in URL mode with a positive interval. */
3529
+ /** Starts (or restarts) the polling timer if in URL mode with a positive
3530
+ * interval. Does NOT abort the kick-off fetch issued by the caller — it
3531
+ * only resets the interval timer. */
3483
3532
  startPolling() {
3484
- this.clearPolling();
3533
+ this.clearPollTimer();
3485
3534
  if (this.currentUrl && this.interval > 0) {
3486
3535
  this.pollTimerId = setInterval(() => {
3487
3536
  if (this.currentUrl) {
@@ -3491,7 +3540,7 @@ const Dataset = class {
3491
3540
  }
3492
3541
  }
3493
3542
  render() {
3494
- return h(Host, { key: 'fa02248ff99fc299f0ed7c7feae63063d071685a' });
3543
+ return h(Host, { key: 'a02f22a7f78c3bd2512e013ff729487c471ba9bf' });
3495
3544
  }
3496
3545
  get element() { return getElement(this); }
3497
3546
  static get watchers() { return {
@@ -3548,7 +3597,7 @@ const Datasource = class {
3548
3597
  }
3549
3598
  // --- Leaving URL mode → clean up ---
3550
3599
  if (this.currentUrl !== null) {
3551
- this.clearPolling();
3600
+ this.cancelInFlight();
3552
3601
  this.currentUrl = null;
3553
3602
  }
3554
3603
  // --- Inline JSON / compressed mode ---
@@ -3592,7 +3641,7 @@ const Datasource = class {
3592
3641
  }
3593
3642
  disconnectedCallback() {
3594
3643
  var _a, _b;
3595
- this.clearPolling();
3644
+ this.cancelInFlight();
3596
3645
  const db = (_b = (_a = this.stores) === null || _a === void 0 ? void 0 : _a.db) === null || _b === void 0 ? void 0 : _b.db;
3597
3646
  if (db && this.name) {
3598
3647
  if (db.tables[this.name] != null) {
@@ -3607,10 +3656,14 @@ const Datasource = class {
3607
3656
  }
3608
3657
  }
3609
3658
  /**
3610
- * Returns `true` if the text starts with `http://` or `https://`.
3659
+ * Returns `true` if the text is a fetchable URL: an absolute `http(s)://`
3660
+ * URL, or a same-origin path starting with `/` (but not `//`, which is a
3661
+ * protocol-relative URL we treat as inline-mode escape).
3611
3662
  */
3612
3663
  isUrl(text) {
3613
- return text.startsWith("http://") || text.startsWith("https://");
3664
+ if (text.startsWith("http://") || text.startsWith("https://"))
3665
+ return true;
3666
+ return text.startsWith("/") && !text.startsWith("//");
3614
3667
  }
3615
3668
  /**
3616
3669
  * Fetches JSON from the given URL and stores the result.
@@ -3634,19 +3687,26 @@ const Datasource = class {
3634
3687
  this.publish([]);
3635
3688
  }
3636
3689
  }
3637
- /** Stops the polling timer and cancels any in-flight fetch. */
3638
- clearPolling() {
3639
- var _a;
3690
+ /** Stops the polling timer (does NOT touch any in-flight fetch). */
3691
+ clearPollTimer() {
3640
3692
  if (this.pollTimerId !== null) {
3641
3693
  clearInterval(this.pollTimerId);
3642
3694
  this.pollTimerId = null;
3643
3695
  }
3696
+ }
3697
+ /** Stops the polling timer AND cancels any in-flight fetch. Use only when
3698
+ * leaving URL mode entirely (disconnect or body changed to inline). */
3699
+ cancelInFlight() {
3700
+ var _a;
3701
+ this.clearPollTimer();
3644
3702
  (_a = this.abortController) === null || _a === void 0 ? void 0 : _a.abort();
3645
3703
  this.abortController = null;
3646
3704
  }
3647
- /** Starts (or restarts) the polling timer if in URL mode with a positive interval. */
3705
+ /** Starts (or restarts) the polling timer if in URL mode with a positive
3706
+ * interval. Does NOT abort the kick-off fetch issued by the caller — it
3707
+ * only resets the interval timer. */
3648
3708
  startPolling() {
3649
- this.clearPolling();
3709
+ this.clearPollTimer();
3650
3710
  if (this.currentUrl && this.interval > 0) {
3651
3711
  this.pollTimerId = setInterval(() => {
3652
3712
  if (this.currentUrl) {
@@ -3656,7 +3716,7 @@ const Datasource = class {
3656
3716
  }
3657
3717
  }
3658
3718
  render() {
3659
- return h(Host, { key: '4c79b32d893865fe7c62118d4186b8175294636f' });
3719
+ return h(Host, { key: '2af6ade861fa900974deeb1b6bcc4520997a4180' });
3660
3720
  }
3661
3721
  get element() { return getElement(this); }
3662
3722
  static get watchers() { return {
@@ -3720,7 +3780,7 @@ const Footer$1 = class Footer {
3720
3780
  };
3721
3781
  Footer$1.style = bnFooterCss();
3722
3782
 
3723
- const bnLayoutCardCss = () => `:host{background:var(--bn-font-background, white);color:var(--bn-font-color, black);font-family:var(--bn-font-family, "Noto Sans", sans-serif);font-size:var(--bn-font-size, 13.3333px);display:flex;flex-direction:column;width:100%;height:100%;overflow:hidden}.cardtitle{display:inline-flex}.image{margin-right:0.5em;margin-top:0.5em;z-index:2;background-color:transparent;border:transparent;height:4em;width:auto;display:inline}`;
3783
+ const bnLayoutCardCss = () => `:host{background:var(--bn-font-background, white);color:var(--bn-font-color, black);font-family:var(--bn-font-family, "Noto Sans", sans-serif);font-size:var(--bn-font-size, 13.3333px);display:flex;flex-direction:column;width:100%;height:100%;overflow:hidden}.cardtitle{display:inline-flex}::slotted(*){flex:1 1 auto;min-width:0}.image{margin-right:0.5em;margin-top:0.5em;z-index:2;background-color:transparent;border:transparent;height:4em;width:auto;display:inline}`;
3724
3784
 
3725
3785
  const LayoutCard = class {
3726
3786
  constructor(hostRef) {
@@ -3896,11 +3956,14 @@ const LayoutCard = class {
3896
3956
  return "minmax(0, 1fr)";
3897
3957
  return this.calculateFractions(matches[0]);
3898
3958
  }
3899
- getGridTemplateRows(name) {
3959
+ getRowCount(name) {
3900
3960
  const template = this.getTemplatePattern(name);
3901
3961
  const pattern = /"[\w\d\s.]+"/g;
3902
3962
  const matches = template.match(pattern);
3903
- const rowCount = matches ? matches.length : 1;
3963
+ return matches ? matches.length : 1;
3964
+ }
3965
+ getGridTemplateRows(name) {
3966
+ const rowCount = this.getRowCount(name);
3904
3967
  if (this.cardFitToContent) {
3905
3968
  return Array(rowCount).fill("auto").join(" ");
3906
3969
  }
@@ -3994,13 +4057,13 @@ const LayoutCard = class {
3994
4057
  const arrOfSlots = this.extractSlotNames(style["grid-template-areas"]);
3995
4058
  return (
3996
4059
  // @ts-ignore
3997
- h("bn-card", { key: 'c39b6a8cf843b7b8d9b380215a3553288acd3647', styles: this.styles, class: this.setCardClass() }, h("div", { key: '3206bff73cb01fad7223e3fd889e015992e535c6', class: "cardtitle" }, h("bn-title", { key: 'd410c817dd185a26bb7623dd3649c999516f706a', namespace: this.titleNamespace, "business-unit": this.titleBusinessUnit, scenarios: (_a = this.resolveInherited("titleScenarios", this.titleScenarios)) !== null && _a !== void 0 ? _a : this.titleScenarios, variances: (_b = this.resolveInherited("titleVariances", this.titleVariances)) !== null && _b !== void 0 ? _b : this.titleVariances, order: (_c = this.resolveInherited("titleOrder", this.titleOrder)) !== null && _c !== void 0 ? _c : this.titleOrder, "order-direction": (_d = this.resolveInherited("titleOrderDirection", this.titleOrderDirection)) !== null && _d !== void 0 ? _d : this.titleOrderDirection, measures: this.titleMeasures, "date-start": this.titleDateStart, "date-end": this.titleDateEnd, "date-format": this.titleDateFormat, "date-link": this.titleDateLink }), this.titleImage != null && this.titleImage !== "" ? (h("img", { class: "image", src: this.prepareTitleImage(this.titleImage) })) : ("")), h("bn-body", { key: 'f56b1b70127cd2173e425cf723dbea2b62037d88' }, h("div", { key: 'e5766b5b28dd1d14fdbaf721baf72668502fcbec', style: style }, this.getSlots(arrOfSlots))), h("bn-footer", { key: 'bafb89f89c89aaf0e31fa754f0e834330b031627', text: this.footerText, "page-number": 0, "display-page-number": "false" })));
4060
+ h("bn-card", { key: '513dd28a363a379adda77f55ea1de0f144589096', styles: this.styles, class: this.setCardClass() }, h("div", { key: '3d354cd83db250d243cfaf8de4abe4c7bfd2ec5b', class: "cardtitle" }, h("bn-title", { key: 'b8dfc27dfe59b8344139e09611bbbe80ab5d5cd1', namespace: this.titleNamespace, "business-unit": this.titleBusinessUnit, scenarios: (_a = this.resolveInherited("titleScenarios", this.titleScenarios)) !== null && _a !== void 0 ? _a : this.titleScenarios, variances: (_b = this.resolveInherited("titleVariances", this.titleVariances)) !== null && _b !== void 0 ? _b : this.titleVariances, order: (_c = this.resolveInherited("titleOrder", this.titleOrder)) !== null && _c !== void 0 ? _c : this.titleOrder, "order-direction": (_d = this.resolveInherited("titleOrderDirection", this.titleOrderDirection)) !== null && _d !== void 0 ? _d : this.titleOrderDirection, measures: this.titleMeasures, "date-start": this.titleDateStart, "date-end": this.titleDateEnd, "date-format": this.titleDateFormat, "date-link": this.titleDateLink }), this.titleImage != null && this.titleImage !== "" ? (h("img", { class: "image", src: this.prepareTitleImage(this.titleImage) })) : ("")), h("bn-body", { key: '69179e29f6ee21589352af938d7fe508a42d26ce' }, h("div", { key: '15c232a8887f01c86b0d977cb2f4fa1fb7b5fd53', style: style, "data-bn-fit-content": this.cardFitToContent ? String(this.getRowCount(this.cardLayout)) : null }, this.getSlots(arrOfSlots))), h("bn-footer", { key: '9f04fc230ea3a419c308a36ab03cb77b58d950f1', text: this.footerText, "page-number": 0, "display-page-number": "false" })));
3998
4061
  }
3999
4062
  get element() { return getElement(this); }
4000
4063
  };
4001
4064
  LayoutCard.style = bnLayoutCardCss();
4002
4065
 
4003
- const bnLayoutPageCss = () => `:host{background:var(--bn-font-background, white);color:var(--bn-font-color, black);font-family:var(--bn-font-family, "Noto Sans", sans-serif);font-size:var(--bn-font-size, 13.3333px);display:block;overflow:hidden}`;
4066
+ const bnLayoutPageCss = () => `:host{background:var(--bn-font-background, white);color:var(--bn-font-color, black);font-family:var(--bn-font-family, "Noto Sans", sans-serif);font-size:var(--bn-font-size, 13.3333px);display:block;overflow:hidden}::slotted(*){flex:1 1 auto;min-width:0}`;
4004
4067
 
4005
4068
  const LayoutPage = class {
4006
4069
  constructor(hostRef) {
@@ -4146,11 +4209,14 @@ const LayoutPage = class {
4146
4209
  gap: this.pageGridGap + "px",
4147
4210
  };
4148
4211
  }
4149
- getGridTemplateRows(name) {
4212
+ getRowCount(name) {
4150
4213
  const template = this.getTemplateAreas(name);
4151
4214
  const pattern = /"[\w\d\s.]+"/g;
4152
4215
  const matches = template.match(pattern);
4153
- const rowCount = matches ? matches.length : 1;
4216
+ return matches ? matches.length : 1;
4217
+ }
4218
+ getGridTemplateRows(name) {
4219
+ const rowCount = this.getRowCount(name);
4154
4220
  if (this.pageFitToContent) {
4155
4221
  return Array(rowCount).fill("auto").join(" ");
4156
4222
  }
@@ -4244,7 +4310,7 @@ const LayoutPage = class {
4244
4310
  const arrOfSlots = this.extractSlotNames(style["grid-template-areas"]);
4245
4311
  return (
4246
4312
  // @ts-ignore
4247
- h("bn-page", { key: '958dbce3b000c62d287f6263fed495523786e28d', styles: this.styles, format: this.pageFormat, orientation: this.pageOrientation }, h("bn-message", { key: 'cdb559c63a0466ccaa1cd807d027dd127e3b3efe', text: this.messageText, image: this.messageImage }), h("bn-title", { key: '48fafd3fc8be7d49df4939bd5db63908b36e523f', namespace: this.titleNamespace, "business-unit": this.titleBusinessUnit, scenarios: this.titleScenarios, variances: this.titleVariances, order: this.titleOrder, "order-direction": this.titleOrderDirection, measures: this.titleMeasures, "date-start": this.titleDateStart, "date-end": this.titleDateEnd, "date-format": this.titleDateFormat, "date-link": this.titleDateLink }), h("bn-body", { key: '93c9f7b2c345c8bc6fdb20d35fa406ee919379eb' }, h("div", { key: '64e4db5a7b6265bcd73b700227b5f033c99facdc', style: style }, this.getSlots(arrOfSlots))), h("bn-footer", { key: 'f7b69e9fcfbdde742a2d547f81c50dd78a3ed02f', text: this.footerText, "page-number": this.pageNumber, "display-page-number": this.footerDisplayPageNumber })));
4313
+ h("bn-page", { key: 'ff44575cdb898cb284bd5cd2cefbe3fa30557ad7', styles: this.styles, format: this.pageFormat, orientation: this.pageOrientation }, h("bn-message", { key: '76282ce0765669b72a96135f5bbd08296b267c99', text: this.messageText, image: this.messageImage }), h("bn-title", { key: '2493351a6d031f0a015197c83e876969a99647c3', namespace: this.titleNamespace, "business-unit": this.titleBusinessUnit, scenarios: this.titleScenarios, variances: this.titleVariances, order: this.titleOrder, "order-direction": this.titleOrderDirection, measures: this.titleMeasures, "date-start": this.titleDateStart, "date-end": this.titleDateEnd, "date-format": this.titleDateFormat, "date-link": this.titleDateLink }), h("bn-body", { key: 'f85e7bd896773f867d32d8cfeb6ab71e534db5b2' }, h("div", { key: '8ed820659c9482129670c6d00690ab8d7560dbfc', style: style, "data-bn-fit-content": this.pageFitToContent ? String(this.getRowCount(this.pageLayout)) : null }, this.getSlots(arrOfSlots))), h("bn-footer", { key: 'd796066a1c561d5966882ee3642ebe1ee591e0be', text: this.footerText, "page-number": this.pageNumber, "display-page-number": this.footerDisplayPageNumber })));
4248
4314
  }
4249
4315
  get element() { return getElement(this); }
4250
4316
  };
@@ -4737,6 +4803,17 @@ const Table$1 = class Table {
4737
4803
  * ```
4738
4804
  */
4739
4805
  this.columnthereof = null;
4806
+ /**
4807
+ * Stringified JSON object defining custom columns computed from dataset fields.<br />
4808
+ * Keys are column labels, values are aggregate expressions over the rows that
4809
+ * make up each table row.<br /><br />
4810
+ * Functions: ```set // first // last // min // max // avg // sum // lit```<br />
4811
+ * Fields can be standard dataset fields (e.g. ```ac1```) or custom fields
4812
+ * prefixed with ```_``` (e.g. ```_leiter```); ```lit``` takes a constant value.<br /><br />
4813
+ * example:<br />
4814
+ * ```{"Verkaufsleiter": "set(_leiter)", "Umsatz gesamt": "sum(ac1)"}```
4815
+ */
4816
+ this.tableAttributes = "";
4740
4817
  this._autoScaleGuard = false;
4741
4818
  withStyled(this);
4742
4819
  withComponentStatus(this);
@@ -5075,6 +5152,20 @@ const Table$1 = class Table {
5075
5152
  this.errors.remove(errId);
5076
5153
  }
5077
5154
  }
5155
+ validateTableAttributes(newValue) {
5156
+ const errId = "ERR_attributes";
5157
+ const invalidElements = validateAttributesJsonStr(newValue);
5158
+ if (invalidElements.length > 0) {
5159
+ this.errors.addOrReplace({
5160
+ id: errId,
5161
+ type: "warning",
5162
+ message: "attributes: invalid value(s) '" + JSON.stringify(invalidElements) + "' are not supported.",
5163
+ });
5164
+ }
5165
+ else {
5166
+ this.errors.remove(errId);
5167
+ }
5168
+ }
5078
5169
  componentWillLoad() {
5079
5170
  this.validateScenario(this.scenarios);
5080
5171
  this.validateVariances(this.variances);
@@ -5093,6 +5184,7 @@ const Table$1 = class Table {
5093
5184
  this.validateMeasureType(this.measureType);
5094
5185
  this.validateMeasureScale(this.measureScale);
5095
5186
  this.validateColumnThereOf(this.columnthereof);
5187
+ this.validateTableAttributes(this.tableAttributes);
5096
5188
  this.validateShowMeasureScale(this.showMeasureScale);
5097
5189
  this.validateBarColumns(this.barColumns);
5098
5190
  this.validateBarColumnWidth(this.barColumnWidth);
@@ -5241,7 +5333,7 @@ const Table$1 = class Table {
5241
5333
  return formatDigits;
5242
5334
  }
5243
5335
  prepareScenarios() {
5244
- var _a, _b, _c, _d, _e, _f, _g, _h, _j;
5336
+ var _a, _b, _c, _d, _f, _g, _h, _j, _k;
5245
5337
  const inheritedScenarios = this.resolveInherited("scenarios", this.scenarios);
5246
5338
  const inheritedVariances = this.resolveInherited("variances", this.variances);
5247
5339
  if (inheritedScenarios !== undefined || inheritedVariances !== undefined) {
@@ -5280,7 +5372,7 @@ const Table$1 = class Table {
5280
5372
  }
5281
5373
  let scenarios = [];
5282
5374
  if (isAuto || isBlankInput(this.scenarios)) {
5283
- if (((_f = (_e = this.datasetMeta) === null || _e === void 0 ? void 0 : _e.availableScenarios) === null || _f === void 0 ? void 0 : _f.length) > 0) {
5375
+ if (((_g = (_f = this.datasetMeta) === null || _f === void 0 ? void 0 : _f.availableScenarios) === null || _g === void 0 ? void 0 : _g.length) > 0) {
5284
5376
  if (!isAuto) {
5285
5377
  this.errors.addOrReplace({
5286
5378
  id: "AUTO_scenarios",
@@ -5296,10 +5388,10 @@ const Table$1 = class Table {
5296
5388
  }
5297
5389
  else {
5298
5390
  this.errors.remove("AUTO_scenarios");
5299
- scenarios = scenarios.concat((_g = this.scenarios) === null || _g === void 0 ? void 0 : _g.split(","));
5391
+ scenarios = scenarios.concat((_h = this.scenarios) === null || _h === void 0 ? void 0 : _h.split(","));
5300
5392
  }
5301
- if (((_h = this.variances) === null || _h === void 0 ? void 0 : _h.trim().length) > 0) {
5302
- scenarios = scenarios.concat((_j = this.variances) === null || _j === void 0 ? void 0 : _j.split(","));
5393
+ if (((_j = this.variances) === null || _j === void 0 ? void 0 : _j.trim().length) > 0) {
5394
+ scenarios = scenarios.concat((_k = this.variances) === null || _k === void 0 ? void 0 : _k.split(","));
5303
5395
  }
5304
5396
  return scenarios.map((entry) => entry.trim());
5305
5397
  }
@@ -5343,6 +5435,24 @@ const Table$1 = class Table {
5343
5435
  }
5344
5436
  return map;
5345
5437
  }
5438
+ prepareAttributes() {
5439
+ if (this.tableAttributes == null || this.tableAttributes.trim() === "") {
5440
+ return [];
5441
+ }
5442
+ try {
5443
+ const parsedString = JSON.parse(this.tableAttributes);
5444
+ if (parsedString === null || typeof parsedString !== "object" || parsedString instanceof Array) {
5445
+ return [];
5446
+ }
5447
+ return Object.entries(parsedString)
5448
+ .map(([label, expression], index) => typeof expression === "string" ? parseTableAttributeExpression(label, `attr_${index}`, expression) : null)
5449
+ .filter((attribute) => attribute !== null);
5450
+ }
5451
+ catch (_e) {
5452
+ // invalid JSON already reported by validateTableAttributes
5453
+ return [];
5454
+ }
5455
+ }
5346
5456
  prepareTableTitle() {
5347
5457
  if (this.tableTitle === "" || this.tableTitle == null) {
5348
5458
  return "SUM_TOTAL";
@@ -5460,7 +5570,7 @@ const Table$1 = class Table {
5460
5570
  render() {
5461
5571
  const fontStyles = this.getFontStyles();
5462
5572
  const effectiveFactor = this.getEffectiveScaleFactor();
5463
- return (h(Host, { key: '469aa0d5b00e111af96d33764640fa92eb5ed5cc', style: fontStyles }, h("div", { key: 'f02443601b7e644c243b48ad09af411a8460b659' }, h("ibcs-table", { key: '242ee74a5715c83a267e3f02daab09b9baca0c57', tableName: this.datasetName, dataVersion: this.dataVersion, "table-title": this.prepareTableTitle(), scenarios: this.prepareScenarios(), "scenarios-data-format": this.prepareDataFormat(), grouped: this.prepareGrouped(), limit: this.prepareLimit(), showGroupTitle: this.prepareShowGroupTitle(), thereof: this.prepareThereOf(), partof: this.preparePartOf(), order: this.prepareOrder(), categorythereof: this.prepareColumnThereOf(), type: this.prepareTableType(), "category-width": this.prepareCategoryWidth(), dataFormatDigits: this.prepareDataFormatDigits(), i18n: this.prepareI18n(), "i18n-mode": this.prepareI18nMode(), "measure-scale": this.prepareMeasureScale(), "measure-type": this.prepareMeasureType(), "measure-unit": this.prepareMeasureUnit(), showMeasureScale: this.prepareShowMeasureScale(), filter: this.prepareFilter(), barColumns: this.prepareBarColumns(), barColumnMaxWidth: this.prepareBarColumnWidth(), unitScaling: this.prepareUnitScaling(), percentageScaling: this.preparePercentageScaling(), scaleFactor: effectiveFactor }))));
5573
+ return (h(Host, { key: 'ed9804ea731fbaa0ec730c0392bcd18bb0ac278a', style: fontStyles }, h("div", { key: '011a543cca60ec8c871db6a6280999047437ce98' }, h("ibcs-table", { key: '4b7d717c3a7c9ed4c44b90dc66b4b8e6c9359cb0', tableName: this.datasetName, dataVersion: this.dataVersion, "table-title": this.prepareTableTitle(), scenarios: this.prepareScenarios(), "scenarios-data-format": this.prepareDataFormat(), grouped: this.prepareGrouped(), limit: this.prepareLimit(), showGroupTitle: this.prepareShowGroupTitle(), thereof: this.prepareThereOf(), partof: this.preparePartOf(), order: this.prepareOrder(), categorythereof: this.prepareColumnThereOf(), attributeColumns: this.prepareAttributes(), type: this.prepareTableType(), "category-width": this.prepareCategoryWidth(), dataFormatDigits: this.prepareDataFormatDigits(), i18n: this.prepareI18n(), "i18n-mode": this.prepareI18nMode(), "measure-scale": this.prepareMeasureScale(), "measure-type": this.prepareMeasureType(), "measure-unit": this.prepareMeasureUnit(), showMeasureScale: this.prepareShowMeasureScale(), filter: this.prepareFilter(), barColumns: this.prepareBarColumns(), barColumnMaxWidth: this.prepareBarColumnWidth(), unitScaling: this.prepareUnitScaling(), percentageScaling: this.preparePercentageScaling(), scaleFactor: effectiveFactor }))));
5464
5574
  }
5465
5575
  get element() { return getElement(this); }
5466
5576
  static get watchers() { return {
@@ -5532,6 +5642,9 @@ const Table$1 = class Table {
5532
5642
  }],
5533
5643
  "columnthereof": [{
5534
5644
  "validateColumnThereOf": 0
5645
+ }],
5646
+ "tableAttributes": [{
5647
+ "validateTableAttributes": 0
5535
5648
  }]
5536
5649
  }; }
5537
5650
  };
@@ -13583,7 +13696,7 @@ makeMorphable();
13583
13696
  */
13584
13697
  let ElementPositions$1 = class ElementPositions {
13585
13698
  // private smallestDataPoint: DataPoint;
13586
- constructor(padding, scaleFactors, fontSize, numberOfColumns, leftSideLengthSync, titleLength, leftSideWidth, categoryWidth) {
13699
+ constructor(padding, scaleFactors, fontSize, numberOfColumns, leftSideLengthSync, titleLength, leftSideWidth, categoryWidth, hasStackedHeaders = false) {
13587
13700
  this.categoryPosition = { x: 0, y: 0 };
13588
13701
  this.spacings = {
13589
13702
  scenarioOffset: 0,
@@ -13613,6 +13726,7 @@ let ElementPositions$1 = class ElementPositions {
13613
13726
  this.numberOfColumns = numberOfColumns;
13614
13727
  this.leftSideLengthSync = leftSideLengthSync;
13615
13728
  this.topSideLabelHeight = titleLength > 0 ? this.fontSize : 0;
13729
+ this.hasStackedHeaders = hasStackedHeaders;
13616
13730
  this.leftSideLabelLength = this.calculateSideLabelLength(titleLength, leftSideWidth, categoryWidth);
13617
13731
  this.calculateSpacings();
13618
13732
  this.calculateCategoryPosition();
@@ -13641,7 +13755,10 @@ let ElementPositions$1 = class ElementPositions {
13641
13755
  return this.axisPosition.x;
13642
13756
  }
13643
13757
  getAxisTitlePositionY() {
13644
- return this.axisPosition.y - this.spacings.labelToAxis;
13758
+ return this.axisPosition.y - this.spacings.labelToAxis - this.getTopLabelOverhang();
13759
+ }
13760
+ getStackedHeaderPositionY() {
13761
+ return this.getBarCenterPositionY(0) - this.spacings.barWidth * 0.5 - this.spacings.scenarioLabelToBar;
13645
13762
  }
13646
13763
  getNeedleWidth() {
13647
13764
  return this.spacings.needleWidth;
@@ -13697,7 +13814,12 @@ let ElementPositions$1 = class ElementPositions {
13697
13814
  }
13698
13815
  getScenarioLabelPositionOffsetY(isPrimaryBar) {
13699
13816
  if (isPrimaryBar) {
13700
- return this.getBarWidth() * 0.5 + this.spacings.scenarioLabelToBar;
13817
+ // The label belongs to the last bar, but the axis line runs past that bar's
13818
+ // center by (categoryWidth - scenarioOffset); place the label below the axis
13819
+ // end so the line does not strike through it.
13820
+ const belowBar = this.getBarWidth() * 0.5 + this.spacings.scenarioLabelToBar;
13821
+ const belowAxisEnd = this.spacings.categoryWidth - this.spacings.scenarioOffset + this.spacings.labelToAxis;
13822
+ return Math.max(belowBar, belowAxisEnd);
13701
13823
  }
13702
13824
  return -(this.getBarWidth() * 0.5 + this.spacings.scenarioLabelToBar);
13703
13825
  }
@@ -13759,7 +13881,40 @@ let ElementPositions$1 = class ElementPositions {
13759
13881
  this.calculateAxisPosition();
13760
13882
  }
13761
13883
  getAxisTitleOffset() {
13762
- return this.topSideLabelHeight;
13884
+ // Title height plus the gap to the labels that can stick out above the first bar
13885
+ return this.topSideLabelHeight + this.spacings.labelToAxis + this.getTopLabelOverhang();
13886
+ }
13887
+ getTopLabelOverhang() {
13888
+ return this.hasStackedHeaders ? this.getStackedHeaderOverhang() : this.getTopScenarioLabelOverhang();
13889
+ }
13890
+ /**
13891
+ * How far the stacked-segment header row (anchored just above the first bar)
13892
+ * reaches above the axis start. The title is moved up by this amount so the
13893
+ * header row sits between title and bars without overlapping either.
13894
+ */
13895
+ getStackedHeaderOverhang() {
13896
+ return Math.max(0, this.fontSize +
13897
+ this.spacings.scenarioLabelToBar +
13898
+ this.spacings.barWidth * 0.5 -
13899
+ (this.spacings.categoryWidth * 0.5 + this.spacings.scenarioOffset));
13900
+ }
13901
+ /**
13902
+ * How far the scenario labels above the first bar (secondary bar label) or
13903
+ * above the first marker (primary marker label) reach above the axis start.
13904
+ * The title is moved up by this amount so it does not overlap them.
13905
+ */
13906
+ getTopScenarioLabelOverhang() {
13907
+ const barLabelOverhang = this.fontSize +
13908
+ this.spacings.barWidth * 0.5 +
13909
+ this.spacings.scenarioLabelToBar -
13910
+ this.spacings.categoryWidth * 0.5;
13911
+ const markerLabelOverhang = this.fontSize +
13912
+ this.spacings.markerWidth * 0.5 +
13913
+ this.spacings.scenarioLabelToBar +
13914
+ this.spacings.markerOffset +
13915
+ this.spacings.barWidth * 0.5 -
13916
+ (this.spacings.categoryWidth * 0.5 + this.spacings.scenarioOffset);
13917
+ return Math.max(0, barLabelOverhang, markerLabelOverhang);
13763
13918
  }
13764
13919
  calculateSideLabelLength(titleLength, leftSideWidth, categoryWidth) {
13765
13920
  if (this.leftSideLengthSync) {
@@ -15678,6 +15833,7 @@ class StructureChart {
15678
15833
  this.measureUnit = "";
15679
15834
  this.dataFormatDigits = { percent: 2, decimal: 1 };
15680
15835
  this.stackConfig = null;
15836
+ this.scenarioPropOrder = [];
15681
15837
  this.overflowConfig = null;
15682
15838
  this.highestStackedTotal = 0;
15683
15839
  this.fromExpr = "";
@@ -15700,7 +15856,7 @@ class StructureChart {
15700
15856
  if (this.titleLength > leftSideWidth) {
15701
15857
  leftSideWidth = this.titleLength;
15702
15858
  }
15703
- return new ElementPositions$1(new Padding$2(this.styles.padding), this.styles.scaleFactors, this.styles.fontStyles.size, this.dataModel.length, this.leftSideOffsetForHorizontalSync, this.titleLength, leftSideWidth, categoryWidth);
15859
+ return new ElementPositions$1(new Padding$2(this.styles.padding), this.styles.scaleFactors, this.styles.fontStyles.size, this.dataModel.length, this.leftSideOffsetForHorizontalSync, this.titleLength, leftSideWidth, categoryWidth, !!this.stackConfig && this.variancesDataModel.length === 0);
15704
15860
  }
15705
15861
  setStyles(newStyle) {
15706
15862
  this.styles = newStyle;
@@ -15708,16 +15864,17 @@ class StructureChart {
15708
15864
  setConfig(config) {
15709
15865
  var _a;
15710
15866
  this.state = FactoryState$2.DIRTY;
15711
- this.sortScenariosbyVisualisationRules(config);
15867
+ this.scenarioPropOrder = [...config.scenarios];
15868
+ const scenarios = this.sortScenariosbyVisualisationRules(config.scenarios);
15712
15869
  this.hideCategories = config.hideCategories || false;
15713
15870
  this.limit = config.limit;
15714
15871
  this.pixelPerUnit = config.pixelPerUnit || 1;
15715
15872
  this.pixelPerPercentage = config.pixelPerPercentage || 100;
15716
15873
  this.setSource(config.filter);
15717
- this.dataModel = this.populateModel(config.scenarios, config.level, config.sortOrder);
15874
+ this.dataModel = this.populateModel(scenarios, config.level, config.sortOrder);
15718
15875
  // Populate per-dimension stack segments when stacking by a data dimension
15719
15876
  if (config.stackConfig && config.stackConfig.by !== StackBy.SCENARIOS) {
15720
- this.populateDimensionStackSegments(config.scenarios, config.stackConfig, config.level);
15877
+ this.populateDimensionStackSegments(scenarios, config.stackConfig, config.level);
15721
15878
  }
15722
15879
  this.variancesDataModel = this.populateVarianceModel(config.variances, this.dataModel);
15723
15880
  this.title = config.title || Formatter.translateScenarioLabel((_a = config === null || config === void 0 ? void 0 : config.variances) === null || _a === void 0 ? void 0 : _a.toString(), this.i18n);
@@ -15733,9 +15890,10 @@ class StructureChart {
15733
15890
  this.highestStackedTotal = this.findHighestStackedRowTotal(this.dataModel);
15734
15891
  this.updatePosition();
15735
15892
  }
15736
- sortScenariosbyVisualisationRules(config) {
15893
+ /** Returns a new array; the input keeps the `scenarios` prop order (the config is reused across rebuilds). */
15894
+ sortScenariosbyVisualisationRules(scenarios) {
15737
15895
  const self = this;
15738
- config.scenarios
15896
+ return [...scenarios]
15739
15897
  .sort((n1, n2) => {
15740
15898
  return self.ruleSet.getScenarioSorIndex(n1) - self.ruleSet.getScenarioSorIndex(n2);
15741
15899
  })
@@ -15852,8 +16010,10 @@ class StructureChart {
15852
16010
  return width;
15853
16011
  }
15854
16012
  getAllocatedCanvasHeight() {
15855
- return ((this.dataModel.length + 1) * this.position.spacings.categoryWidth +
15856
- this.styles.padding.top +
16013
+ // Axis end plus the scenario label hanging below it (see getScenarioLabelPositionOffsetY)
16014
+ return (this.position.getAxisEndPositionY() +
16015
+ this.position.spacings.labelToAxis +
16016
+ this.position.fontSize +
15857
16017
  this.styles.padding.bottom);
15858
16018
  }
15859
16019
  patternToString() {
@@ -16273,6 +16433,17 @@ class StructureChart {
16273
16433
  });
16274
16434
  return barsGroup;
16275
16435
  }
16436
+ /** Restore the original `scenarios` prop order for stacked segments (IBCS sort reorders the slots). */
16437
+ sortSegmentsByPropOrder(segments) {
16438
+ if (this.scenarioPropOrder.length === 0)
16439
+ return;
16440
+ const order = this.scenarioPropOrder;
16441
+ segments.sort((a, b) => {
16442
+ const ia = order.indexOf(a.scenario);
16443
+ const ib = order.indexOf(b.scenario);
16444
+ return (ia === -1 ? order.length : ia) - (ib === -1 ? order.length : ib);
16445
+ });
16446
+ }
16276
16447
  /**
16277
16448
  * Draw stacked horizontal bars. Supports stacking by scenario or by data dimension.
16278
16449
  * When stacking by scenario with multiple scenario types (e.g. ac+pl),
@@ -16294,6 +16465,7 @@ class StructureChart {
16294
16465
  segments.push({ value: dp.value, scenario: dp.scenario, dataPoint: dp });
16295
16466
  }
16296
16467
  }
16468
+ this.sortSegmentsByPropOrder(segments);
16297
16469
  }
16298
16470
  else {
16299
16471
  const dp = elements["scenario1"];
@@ -16399,7 +16571,7 @@ class StructureChart {
16399
16571
  orderedSegs.sort((a, b) => b.value - a.value);
16400
16572
  const total = orderedSegs.reduce((sum, s) => sum + Math.abs(s.value), 0);
16401
16573
  const axisX = this.position.getBarPositionX();
16402
- const headerY = this.position.getAxisTitlePositionY();
16574
+ const headerY = this.position.getStackedHeaderPositionY();
16403
16575
  let cumulativePixels = 0;
16404
16576
  orderedSegs.forEach((seg) => {
16405
16577
  const pixelPerUnit = seg.dataPoint.pixelPerUnit;
@@ -16428,9 +16600,10 @@ class StructureChart {
16428
16600
  }
16429
16601
  if (segments.length === 0)
16430
16602
  return;
16603
+ this.sortSegmentsByPropOrder(segments);
16431
16604
  const prefixes = new Set(segments.map((s) => getScenarioPrefix(s.scenario)));
16432
16605
  const axisX = this.position.getBarPositionX();
16433
- const headerY = this.position.getAxisTitlePositionY();
16606
+ const headerY = this.position.getStackedHeaderPositionY();
16434
16607
  if (prefixes.size > 1) {
16435
16608
  // Overlay mode: one header per group, centered on group's bar extent
16436
16609
  const groupMap = new Map();
@@ -19610,6 +19783,7 @@ class TimeChart {
19610
19783
  this.chartMode = ChartMode.BAR;
19611
19784
  this.maxBars = 28;
19612
19785
  this.stackConfig = null;
19786
+ this.scenarioPropOrder = [];
19613
19787
  this.lineFullWidth = true;
19614
19788
  this.availableWidth = 0;
19615
19789
  this.overflowConfig = null;
@@ -19621,7 +19795,7 @@ class TimeChart {
19621
19795
  this.styles = styles;
19622
19796
  this.availableWidth = availableWidth;
19623
19797
  this.setConfig(config);
19624
- this.position = this.createElementPosition(config.scenarios);
19798
+ this.position = this.createElementPosition(this.lastScenarios);
19625
19799
  }
19626
19800
  updatePosition(scenarios) {
19627
19801
  this.position = this.createElementPosition(scenarios);
@@ -19691,7 +19865,8 @@ class TimeChart {
19691
19865
  setConfig(config) {
19692
19866
  var _a;
19693
19867
  this.state = FactoryState$1.DIRTY;
19694
- this.sortScenariosbyVisualisationRules(config);
19868
+ this.scenarioPropOrder = [...config.scenarios];
19869
+ const scenarios = this.sortScenariosbyVisualisationRules(config.scenarios);
19695
19870
  this.setSource(config.filter);
19696
19871
  this.hideAxisLabels = config.hideAxisLabels || false;
19697
19872
  this.pixelPerUnit = config.pixelPerUnit;
@@ -19699,7 +19874,7 @@ class TimeChart {
19699
19874
  this.axisLabelsMode = config.axisLabelsMode;
19700
19875
  this.intervalSpanLimit = config.intervalSpanLimit;
19701
19876
  this.dateInterval = this.findDateInterval(config.dateInterval);
19702
- this.dataModel = this.populateModel(config.scenarios, this.dateInterval, config.level, config.sortOrder);
19877
+ this.dataModel = this.populateModel(scenarios, this.dateInterval, config.level, config.sortOrder);
19703
19878
  this.variancesDataModel = this.populateVarianceModel(config.variances, this.dataModel);
19704
19879
  this.title = config.title || Formatter.translateScenarioLabel((_a = config === null || config === void 0 ? void 0 : config.variances) === null || _a === void 0 ? void 0 : _a.toString(), this.i18n);
19705
19880
  this.smallestDataPointValue = this.findSmallestDataPointValue(this.dataModel);
@@ -19717,8 +19892,8 @@ class TimeChart {
19717
19892
  this.maxBars = config.maxBars;
19718
19893
  this.stackConfig = config.stackConfig;
19719
19894
  this.lineFullWidth = config.lineFullWidth;
19720
- this.lastScenarios = config.scenarios;
19721
- this.updatePosition(config.scenarios);
19895
+ this.lastScenarios = scenarios;
19896
+ this.updatePosition(scenarios);
19722
19897
  }
19723
19898
  getFooter() {
19724
19899
  if (this.measureScale.value === 1 && this.measureUnit === "") {
@@ -19726,9 +19901,10 @@ class TimeChart {
19726
19901
  }
19727
19902
  return Formatter.translateScenarioLabel("in", this.i18n) + " " + this.measureScale.prefix + this.measureUnit;
19728
19903
  }
19729
- sortScenariosbyVisualisationRules(config) {
19904
+ /** Returns a new array; the input keeps the `scenarios` prop order (the config is reused across rebuilds). */
19905
+ sortScenariosbyVisualisationRules(scenarios) {
19730
19906
  const self = this;
19731
- config.scenarios
19907
+ return [...scenarios]
19732
19908
  .sort((n1, n2) => {
19733
19909
  return self.ruleSet.getScenarioSorIndex(n1) - self.ruleSet.getScenarioSorIndex(n2);
19734
19910
  })
@@ -20532,6 +20708,17 @@ class TimeChart {
20532
20708
  };
20533
20709
  return columnGroup;
20534
20710
  }
20711
+ /** Restore the original `scenarios` prop order for stacked segments (IBCS sort reorders the slots). */
20712
+ sortSegmentsByPropOrder(segments) {
20713
+ if (this.scenarioPropOrder.length === 0)
20714
+ return;
20715
+ const order = this.scenarioPropOrder;
20716
+ segments.sort((a, b) => {
20717
+ const ia = order.indexOf(a.scenario);
20718
+ const ib = order.indexOf(b.scenario);
20719
+ return (ia === -1 ? order.length : ia) - (ib === -1 ? order.length : ib);
20720
+ });
20721
+ }
20535
20722
  /**
20536
20723
  * Draw stacked bar columns. Supports stacking by scenario or by data dimension.
20537
20724
  * When stacking by scenario with multiple scenario types (e.g. ac+pl),
@@ -20553,6 +20740,7 @@ class TimeChart {
20553
20740
  segments.push({ value: dp.value, scenario: dp.scenario, dataPoint: dp });
20554
20741
  }
20555
20742
  }
20743
+ this.sortSegmentsByPropOrder(segments);
20556
20744
  }
20557
20745
  else {
20558
20746
  const dp = elements["scenario1"];
@@ -20652,12 +20840,14 @@ class TimeChart {
20652
20840
  }
20653
20841
  if (segments.length === 0)
20654
20842
  return;
20843
+ this.sortSegmentsByPropOrder(segments);
20655
20844
  const prefixes = new Set(segments.map((s) => getScenarioPrefix(s.scenario)));
20656
20845
  const axisY = this.position.getColumnPositionY();
20657
20846
  const xBase = this.position.getColumnCenterPositionX(0) - this.position.getColumnWidth() / 2;
20658
20847
  const labelX = xBase - this.position.spacings.labelToColumn;
20659
20848
  if (prefixes.size > 1) {
20660
- // Overlay mode: one header per group, centered vertically on group's column height
20849
+ // Overlay mode: one header per group — front group centered on its bar,
20850
+ // back groups aligned with their bar's top edge
20661
20851
  const groupMap = new Map();
20662
20852
  for (const seg of segments) {
20663
20853
  const prefix = getScenarioPrefix(seg.scenario);
@@ -20675,11 +20865,15 @@ class TimeChart {
20675
20865
  for (const [prefix, segs] of groupMap) {
20676
20866
  groups.push({ prefix, segments: segs });
20677
20867
  }
20678
- groups.forEach((group) => {
20868
+ groups.forEach((group, groupIdx) => {
20679
20869
  const groupTotal = group.segments.reduce((sum, s) => sum + Math.abs(s.value), 0);
20680
20870
  const pixelPerUnit = group.segments[0].dataPoint.pixelPerUnit;
20681
20871
  const groupPixelHeight = this.stackConfig.mode === StackMode.RELATIVE ? pixelPerUnit : groupTotal * pixelPerUnit;
20682
- const centerY = axisY - groupPixelHeight / 2;
20872
+ // The front-most group (drawn last, e.g. AC) is fully visible, so its
20873
+ // label is centered on the bar. Back groups are mostly hidden behind it
20874
+ // and only peek out at the top, so their labels align with the bar's top edge.
20875
+ const isFrontGroup = groupIdx === groups.length - 1;
20876
+ const centerY = isFrontGroup ? axisY - groupPixelHeight / 2 : axisY - groupPixelHeight;
20683
20877
  const labelText = this.i18n.get(group.prefix + "1") || group.prefix.toUpperCase();
20684
20878
  new Label(headerGroup, labelX, centerY, "STACK_HEADER", labelText, this.styles, HookLocation.Center, HookLocation.Right).forceStringTypeDraw();
20685
20879
  });
@@ -20738,6 +20932,15 @@ class TimeChart {
20738
20932
  activeLayers.push(key);
20739
20933
  }
20740
20934
  }
20935
+ if (isScenarioStack && this.scenarioPropOrder.length > 0) {
20936
+ const order = this.scenarioPropOrder;
20937
+ activeLayers.sort((a, b) => {
20938
+ var _a, _b, _c, _d;
20939
+ const ia = order.indexOf((_b = (_a = dataModel[0][a]) === null || _a === void 0 ? void 0 : _a.scenario) !== null && _b !== void 0 ? _b : "");
20940
+ const ib = order.indexOf((_d = (_c = dataModel[0][b]) === null || _c === void 0 ? void 0 : _c.scenario) !== null && _d !== void 0 ? _d : "");
20941
+ return (ia === -1 ? order.length : ia) - (ib === -1 ? order.length : ib);
20942
+ });
20943
+ }
20741
20944
  // Compute cumulative values
20742
20945
  for (let layerIdx = 0; layerIdx < activeLayers.length; layerIdx++) {
20743
20946
  const key = activeLayers[layerIdx];
@@ -21793,6 +21996,7 @@ class DataQuery {
21793
21996
  .map((s) => this.translateScenarioSQL(s, true, this.config.type))
21794
21997
  .toString();
21795
21998
  const relativeScenarios = this.getRelativeScenarios();
21999
+ const attributesSQL = this.config.attributes.map((attribute) => this.translateAttributeSQL(attribute)).toString();
21796
22000
  const groups = new QueryGroups(this.config);
21797
22001
  const groupsAggregated = this.config.grouped ? [QueryColumnNames.ROWGROUP, QueryColumnNames.ROWGROUPINDEX] : [];
21798
22002
  let order = ["", ""];
@@ -21829,7 +22033,7 @@ class DataQuery {
21829
22033
  queryLimitSection = `LIMIT ${this.config.limit}`;
21830
22034
  }
21831
22035
  this.createGroupHeaderRow(rowGroupEntry, queries);
21832
- this.createDataRow(queries, rowGroupEntry, groups, scenarios, queryWhereSection, order, queryLimitSection);
22036
+ this.createDataRow(queries, rowGroupEntry, groups, scenarios, attributesSQL, queryWhereSection, order, queryLimitSection);
21833
22037
  this.createRestRow(rowGroupEntry, queries, groups, scenarios, queryWhereSection, order);
21834
22038
  this.createGroupSumRow(queries, sumGroupQueries, rowGroupEntry, scenariosSUMQuery, order);
21835
22039
  });
@@ -21844,7 +22048,7 @@ class DataQuery {
21844
22048
  }
21845
22049
  });
21846
22050
  this.detectNaNCells(this.config.scenarios, res);
21847
- this.createThereOfDrillRows(scenarios, order, res);
22051
+ this.createThereOfDrillRows(scenarios, attributesSQL, order, res);
21848
22052
  this.createPartOfDrillRows(scenarios, order, sumGroupQueries, res);
21849
22053
  this.createThereOfDrillColumns(this.config.categoryThereOf, res);
21850
22054
  this.calculateColumnGroupRest(res, this.config.categoryThereOf);
@@ -21932,14 +22136,14 @@ class DataQuery {
21932
22136
  }
21933
22137
  }
21934
22138
  /** Generates the main data rows for a single row group, applying GROUP BY, ORDER, and LIMIT. */
21935
- createDataRow(querys, rowGroupEntry, groups, scenarios, queryWhereSection, order, queryLimitSection) {
22139
+ createDataRow(querys, rowGroupEntry, groups, scenarios, attributes, queryWhereSection, order, queryLimitSection) {
21936
22140
  // Generates DataRows
21937
22141
  querys.push(`SELECT ROWNUM() AS ${QueryColumnNames.ROWNR},
21938
22142
  ${querys.length} as ${QueryColumnNames.ROWGROUPINDEX},
21939
22143
  'ENTRY' as ${QueryColumnNames.TYPE},
21940
22144
  '${rowGroupEntry.rowGroup || "NO_GROUP"}' as ${QueryColumnNames.ROWGROUP},
21941
22145
  '${QueryColumnNames.CATEGORYINDEX}',
21942
- ${groups} ${scenarios.length > 0 ? ",".concat(scenarios) : ""}
22146
+ ${groups} ${scenarios.length > 0 ? ",".concat(scenarios) : ""} ${attributes.length > 0 ? ",".concat(attributes) : ""}
21943
22147
  FROM ${this.fromExpr} ${queryWhereSection}
21944
22148
  GROUP BY ${groups}
21945
22149
  ORDER BY ${order[0]} ${queryLimitSection}`);
@@ -22085,7 +22289,7 @@ class DataQuery {
22085
22289
  * beneath their parent category row. Each thereof config entry produces a
22086
22290
  * filtered/grouped SQL query whose results are spliced into the result set.
22087
22291
  */
22088
- createThereOfDrillRows(scenarios, order, res) {
22292
+ createThereOfDrillRows(scenarios, attributes, order, res) {
22089
22293
  // adds drill rows if setup in config
22090
22294
  // if there of is set drilldown row is displayed with absolute numbers,
22091
22295
  // if part of is also not null a relative percenatage based of the selected basis is displayed
@@ -22120,7 +22324,7 @@ class DataQuery {
22120
22324
  ${QueryColumnNames.CATEGORY},
22121
22325
  ${QueryColumnNames.SUBCATEGORY},
22122
22326
  ${QueryColumnNames.ROWGROUP} as ${QueryColumnNames.ROWGROUP},
22123
- ${scenarios}
22327
+ ${scenarios} ${attributes.length > 0 ? ",".concat(attributes) : ""}
22124
22328
  FROM ${this.fromExpr}
22125
22329
  WHERE ${fromString}
22126
22330
  GROUP BY ${QueryColumnNames.ROWGROUP}, ${QueryColumnNames.CATEGORY}, ${QueryColumnNames.SUBCATEGORY}
@@ -22246,6 +22450,45 @@ class DataQuery {
22246
22450
  }
22247
22451
  return `SUM(${scenario} * transformOperator(operation)) as ${scenario}, COUNT(ISNULL(${scenario})) as ${scenario}_cnt`;
22248
22452
  }
22453
+ /**
22454
+ * Translates an attribute definition into a SQL aggregate expression aliased
22455
+ * to the attribute's safe column alias (`attr_N`).
22456
+ *
22457
+ * `sum`/`avg` on scenario fields respect the row operation sign via
22458
+ * `transformOperator`, consistent with {@link translateScenarioSQL}; for
22459
+ * OPT/OPTNOTOTAL types the sign is already baked into the data.
22460
+ */
22461
+ translateAttributeSQL(attribute) {
22462
+ const field = `[${attribute.arg}]`;
22463
+ const isScenarioField = /^(ac|pp|fc|pl)[1-4]$/.test(attribute.arg);
22464
+ const useOperator = isScenarioField && this.config.type !== TableType$2.OPT && this.config.type !== TableType$2.OPTNOTOTAL;
22465
+ switch (attribute.fn) {
22466
+ case "set":
22467
+ return `SETAGG(${field}) as ${attribute.alias}`;
22468
+ case "first":
22469
+ return `FIRST(${field}) as ${attribute.alias}`;
22470
+ case "last":
22471
+ return `LAST(${field}) as ${attribute.alias}`;
22472
+ case "min":
22473
+ return `MIN(${field}) as ${attribute.alias}`;
22474
+ case "max":
22475
+ return `MAX(${field}) as ${attribute.alias}`;
22476
+ case "avg":
22477
+ return useOperator
22478
+ ? `AVG(${field} * transformOperator(operation)) as ${attribute.alias}`
22479
+ : `AVG(${field}) as ${attribute.alias}`;
22480
+ case "sum":
22481
+ return useOperator
22482
+ ? `SUM(${field} * transformOperator(operation)) as ${attribute.alias}`
22483
+ : `SUM(${field}) as ${attribute.alias}`;
22484
+ case "lit":
22485
+ return `${this.sqlLiteral(attribute.arg)} as ${attribute.alias}`;
22486
+ }
22487
+ }
22488
+ /** Emits a raw lit() argument as a SQL literal: numeric when parseable, quoted string otherwise. */
22489
+ sqlLiteral(raw) {
22490
+ return raw !== "" && !Number.isNaN(Number(raw)) ? raw : `'${raw.replace(/'/g, "''")}'`;
22491
+ }
22249
22492
  /**
22250
22493
  * generates Tuple
22251
22494
  * [0] orderby string example: category asc
@@ -22518,6 +22761,7 @@ class DataQuery {
22518
22761
  class TableDataSetFactory {
22519
22762
  constructor() {
22520
22763
  this.normalizedHeader = [];
22764
+ this.attributesByAlias = new Map();
22521
22765
  }
22522
22766
  /**
22523
22767
  * Creates Tableheader based on the configured scenarios (in config)
@@ -22527,13 +22771,17 @@ class TableDataSetFactory {
22527
22771
  * visualise grouping.
22528
22772
  * finally a seperator header row is created for the header underlining (border)
22529
22773
  */
22530
- createHeader(type, scenarios, i18n, measureScale, measureUnit, showMeasureScale) {
22774
+ createHeader(type, scenarios, i18n, measureScale, measureUnit, showMeasureScale, attributes = []) {
22531
22775
  const header = [];
22532
- this.normalizedHeader = this.normalizeHeader(type, scenarios);
22776
+ this.attributesByAlias = new Map(attributes.map((attribute) => [attribute.alias, attribute]));
22777
+ this.normalizedHeader = this.normalizeHeader(type, scenarios, attributes);
22533
22778
  const headerRow = new TableRow(0, 0, TableRowType.HEADER);
22534
22779
  const separatorRow = new TableRow(1, 0, TableRowType.SEPERATORLINE);
22535
22780
  for (const scenario of this.normalizedHeader) {
22536
- headerRow.createElement(Formatter.translateScenarioLabel(scenario.name, i18n), scenario.type, this.createColumnType(scenario), null, this.setHeaderPrefix(scenario, i18n, measureScale, measureUnit, showMeasureScale), null, null, null, null);
22781
+ const attribute = this.attributesByAlias.get(scenario.name);
22782
+ headerRow.createElement(attribute
22783
+ ? i18n.get(attribute.label) || attribute.label
22784
+ : Formatter.translateScenarioLabel(scenario.name, i18n), scenario.type, this.createColumnType(scenario), null, this.setHeaderPrefix(scenario, i18n, measureScale, measureUnit, showMeasureScale), null, null, null, null);
22537
22785
  separatorRow.createElement(null, scenario.type, this.createColumnType(scenario), null, null, null, null, null, null);
22538
22786
  }
22539
22787
  header.push(headerRow);
@@ -22558,7 +22806,7 @@ class TableDataSetFactory {
22558
22806
  * depending of table type operation column is used (OPT) or not (SUM | LIST)
22559
22807
  * in addition the headers are sorted based on the ruleset and duplicates are removed
22560
22808
  */
22561
- normalizeHeader(type, scenarios) {
22809
+ normalizeHeader(type, scenarios, attributes) {
22562
22810
  let header = [
22563
22811
  {
22564
22812
  name: QueryColumnNames.CATEGORY,
@@ -22583,8 +22831,15 @@ class TableDataSetFactory {
22583
22831
  },
22584
22832
  ];
22585
22833
  }
22834
+ // attribute columns sit between the category column and the scenario columns
22835
+ const attributeColumns = attributes.map((attribute) => ({
22836
+ name: attribute.alias,
22837
+ group: attribute.alias,
22838
+ type: attribute.alias,
22839
+ order: undefined,
22840
+ }));
22586
22841
  // NOTE: scenarios are already sorted in setConfig
22587
- return [...header, ...scenarios];
22842
+ return [...header, ...attributeColumns, ...scenarios];
22588
22843
  }
22589
22844
  /**
22590
22845
  * Creates table data colelction,
@@ -22756,6 +23011,10 @@ class TableDataSetFactory {
22756
23011
  * @param subCategory
22757
23012
  */
22758
23013
  translateSumCellLabel(i18nMode, i18n, value, rowGroup, subCategory, type, scenario) {
23014
+ if (this.attributesByAlias.has(scenario)) {
23015
+ // attribute values render verbatim; rows without the column (e.g. SUM) stay blank
23016
+ return value;
23017
+ }
22759
23018
  if (Number.isNaN(Number(value)) === false) {
22760
23019
  return value;
22761
23020
  }
@@ -22813,6 +23072,9 @@ class TableDataSetFactory {
22813
23072
  * @param value
22814
23073
  */
22815
23074
  translateScenarioCSS(scenario, value) {
23075
+ if (this.attributesByAlias.has(scenario)) {
23076
+ return "attribute";
23077
+ }
22816
23078
  const scenarios = new VarianceScenario(scenario);
22817
23079
  let prefix = "pos";
22818
23080
  if (value < 0) {
@@ -22827,6 +23089,10 @@ class TableDataSetFactory {
22827
23089
  if (scenario === "category") {
22828
23090
  return "";
22829
23091
  }
23092
+ const attribute = this.attributesByAlias.get(scenario);
23093
+ if (attribute) {
23094
+ return attribute.isNumeric ? "decimal" : "";
23095
+ }
22830
23096
  let unitType;
22831
23097
  const scenarios = new VarianceScenario(scenario);
22832
23098
  if (scenariosUnitType === DataFormat.PERCENT) {
@@ -23008,14 +23274,14 @@ class Table {
23008
23274
  this.rowCount = 0;
23009
23275
  }
23010
23276
  const normalizedScenarios = this.normalizeScenarios(this.config.scenarios, this.config.categoryThereOf, this.config.sortOrder);
23011
- this.headerRows = this.dataSetFactory.createHeader(this.config.type, normalizedScenarios, this.i18n, this.config.measureScale, this.config.measureUnit, this.config.showMeasureScale);
23277
+ this.headerRows = this.dataSetFactory.createHeader(this.config.type, normalizedScenarios, this.i18n, this.config.measureScale, this.config.measureUnit, this.config.showMeasureScale, this.config.attributes);
23012
23278
  this.bodyRows =
23013
23279
  this.rowCount === 0 ? [] : this.dataSetFactory.createBodyRows(this.config, this.i18n, this.db, this.fromExpr);
23014
23280
  this.state = FactoryState$3.UP_TO_DATE;
23015
23281
  }
23016
23282
  update() {
23017
23283
  const normalizedScenarios = this.normalizeScenarios(this.config.scenarios, this.config.categoryThereOf, this.config.sortOrder);
23018
- this.headerRows = this.dataSetFactory.createHeader(this.config.type, normalizedScenarios, this.i18n, this.config.measureScale, this.config.measureUnit, this.config.showMeasureScale);
23284
+ this.headerRows = this.dataSetFactory.createHeader(this.config.type, normalizedScenarios, this.i18n, this.config.measureScale, this.config.measureUnit, this.config.showMeasureScale, this.config.attributes);
23019
23285
  this.bodyRows =
23020
23286
  this.rowCount === 0 || !this.fromExpr
23021
23287
  ? []
@@ -23101,6 +23367,8 @@ class TableComponentConfig {
23101
23367
  this.categoryThereOf = new Map();
23102
23368
  /** Percentage-of-total sub-row definitions. */
23103
23369
  this.partOf = [];
23370
+ /** Custom columns computed from dataset fields via aggregate expressions (see bn-table `attributes` prop). */
23371
+ this.attributes = [];
23104
23372
  this.sortOrder = new OrderAdapter(new StringAdapter()).default();
23105
23373
  /** Table aggregation mode: LIST (flat), SUM (with totals), OPT (with optional totals), etc. */
23106
23374
  this.type = TableType$2.LIST;
@@ -23164,6 +23432,9 @@ class TableComponentConfigAdapter {
23164
23432
  if (CompareUtil.isArray(data.partOf)) {
23165
23433
  config.partOf = AdapterUtils.adaptArray(data.partOf, this.tableDrillGroupAdapter);
23166
23434
  }
23435
+ if (CompareUtil.isArray(data.attributes)) {
23436
+ config.attributes = data.attributes;
23437
+ }
23167
23438
  if (CompareUtil.isExisting(data.order)) {
23168
23439
  config.sortOrder = this.orderAdapter.adapt(data.order);
23169
23440
  }
@@ -23271,6 +23542,7 @@ const IbcsTable = class {
23271
23542
  direction: OrderDirection.ASC,
23272
23543
  };
23273
23544
  this.categorythereof = new Map();
23545
+ this.attributeColumns = [];
23274
23546
  this.type = TableType$2.LIST;
23275
23547
  this.categoryWidth = TableCategoryWidth.INF;
23276
23548
  this.dataFormatDigits = { percent: 2, decimal: 1 };
@@ -23327,6 +23599,7 @@ const IbcsTable = class {
23327
23599
  thereOf: this.thereof,
23328
23600
  partOf: this.partof,
23329
23601
  categoryThereOf: this.categorythereof,
23602
+ attributes: this.attributeColumns,
23330
23603
  order: this.order,
23331
23604
  type: this.type,
23332
23605
  limit: this.limit,