@bino-bi/bn-template-engine 1.0.0-alpha.6 → 1.0.0-alpha.8

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 (108) hide show
  1. package/dist/bn-template-engine/bn-template-engine.esm.js +1 -1
  2. package/dist/bn-template-engine/p-0d41c5d8.entry.js +1 -0
  3. package/dist/bn-template-engine/p-67538176.entry.js +1 -0
  4. package/dist/bn-template-engine/p-825a07a8.entry.js +1 -0
  5. package/dist/bn-template-engine/p-916296a5.entry.js +1 -0
  6. package/dist/bn-template-engine/{p-1164c0b0.entry.js → p-96006b06.entry.js} +1 -1
  7. package/dist/bn-template-engine/p-B4JfKvVT.js +1 -0
  8. package/dist/bn-template-engine/{p-JNHhIe7t.js → p-B_d-jp99.js} +1 -1
  9. package/dist/bn-template-engine/p-Ck-NYtot.js +1 -0
  10. package/dist/bn-template-engine/p-CnDq0oVa.js +1 -0
  11. package/dist/bn-template-engine/p-DSXNgKLa.js +1 -0
  12. package/dist/bn-template-engine/p-bc711fb0.entry.js +1 -0
  13. package/dist/bn-template-engine/p-e6f646b1.entry.js +1 -0
  14. package/dist/bn-template-engine/p-f41d9242.entry.js +1 -0
  15. package/dist/bn-template-engine/{p-B0lsgVuN.js → p-gFbbuhtl.js} +1 -1
  16. package/dist/cjs/{SVGVariancesStyleGroup-BqAdPYtL.js → bn-asset_20.cjs.entry.js} +21948 -6938
  17. package/dist/cjs/bn-grid.cjs.entry.js +6 -9
  18. package/dist/cjs/bn-image.cjs.entry.js +6 -9
  19. package/dist/cjs/bn-internationalization.cjs.entry.js +5 -6
  20. package/dist/cjs/bn-template-engine.cjs.js +2 -2
  21. package/dist/cjs/bn-template.cjs.entry.js +3 -4
  22. package/dist/cjs/bn-text.cjs.entry.js +7 -10
  23. package/dist/cjs/bn-tree.cjs.entry.js +6 -9
  24. package/dist/cjs/{context-protocol-DRQWrwsA.js → context-protocol-ohYzcb5F.js} +1 -1
  25. package/dist/cjs/editor-companion.cjs.entry.js +2 -2
  26. package/dist/cjs/{index-Cjw0q6gP.js → index-CDKG4xmO.js} +1 -0
  27. package/dist/cjs/loader.cjs.js +2 -2
  28. package/dist/cjs/{scaling-BidPsO53.js → scaling-CIAClQR5.js} +3 -3
  29. package/dist/cjs/{withBodyObserver-C6gLgq_e.js → withBodyObserver-D7BKWN2N.js} +2 -2
  30. package/dist/cjs/{withHasError-B8gHkfV2.js → withHasError-Cl2gTQzA.js} +106 -2
  31. package/dist/cjs/{Order-BGx39pS5.js → withStyled-qd94SSb4.js} +648 -6
  32. package/dist/collection/components/bn-chart-structure/bn-chart-structure.js +65 -13
  33. package/dist/collection/components/bn-chart-time/bn-chart-time.js +63 -11
  34. package/dist/collection/components/bn-layout-card/bn-layout-card.js +43 -6
  35. package/dist/collection/components/bn-layout-page/bn-layout-page.js +12 -7
  36. package/dist/collection/components/bn-table/bn-table.js +83 -19
  37. package/dist/collection/components/bn-table/ibcs-table.js +68 -3
  38. package/dist/collection/utils/withInheritedProps.js +152 -0
  39. package/dist/components/bn-chart-structure.js +1 -1
  40. package/dist/components/bn-chart-time.js +1 -1
  41. package/dist/components/bn-layout-card.js +1 -1
  42. package/dist/components/bn-layout-page.js +1 -1
  43. package/dist/components/bn-table.js +1 -1
  44. package/dist/components/ibcs-table2.js +1 -1
  45. package/dist/components/withInheritedProps.js +1 -0
  46. package/dist/esm/{SVGVariancesStyleGroup-DOIT-zvI.js → bn-asset_20.entry.js} +22048 -7042
  47. package/dist/esm/bn-grid.entry.js +4 -7
  48. package/dist/esm/bn-image.entry.js +4 -7
  49. package/dist/esm/bn-internationalization.entry.js +4 -5
  50. package/dist/esm/bn-template-engine.js +3 -3
  51. package/dist/esm/bn-template.entry.js +2 -3
  52. package/dist/esm/bn-text.entry.js +5 -8
  53. package/dist/esm/bn-tree.entry.js +4 -7
  54. package/dist/esm/{context-protocol-2peaD4y8.js → context-protocol-DdbSplvE.js} +2 -2
  55. package/dist/esm/editor-companion.entry.js +2 -2
  56. package/dist/esm/{index-JNHhIe7t.js → index-B_d-jp99.js} +1 -1
  57. package/dist/esm/loader.js +3 -3
  58. package/dist/esm/{scaling-BOcjT8M0.js → scaling-DGKKkuL9.js} +4 -4
  59. package/dist/esm/{withBodyObserver-DczL5ia8.js → withBodyObserver-AFk2wwHT.js} +2 -2
  60. package/dist/esm/{withHasError-B3QX2emi.js → withHasError-DW_vMDUp.js} +106 -2
  61. package/dist/esm/{Order-sRO-lj7X.js → withStyled-BIkqU2w4.js} +616 -1
  62. package/dist/types/components/bn-chart-structure/bn-chart-structure.d.ts +2 -0
  63. package/dist/types/components/bn-chart-time/bn-chart-time.d.ts +2 -0
  64. package/dist/types/components/bn-layout-card/bn-layout-card.d.ts +16 -2
  65. package/dist/types/components/bn-layout-page/bn-layout-page.d.ts +8 -3
  66. package/dist/types/components/bn-table/bn-table.d.ts +1 -0
  67. package/dist/types/components/bn-table/ibcs-table.d.ts +19 -0
  68. package/dist/types/components.d.ts +8 -8
  69. package/dist/types/utils/withInheritedProps.d.ts +38 -0
  70. package/package.json +1 -1
  71. package/dist/bn-template-engine/p-06946f44.entry.js +0 -1
  72. package/dist/bn-template-engine/p-0fabe296.entry.js +0 -1
  73. package/dist/bn-template-engine/p-355abdf0.entry.js +0 -1
  74. package/dist/bn-template-engine/p-79KuA4Ox.js +0 -1
  75. package/dist/bn-template-engine/p-859cc06d.entry.js +0 -1
  76. package/dist/bn-template-engine/p-8acec99e.entry.js +0 -1
  77. package/dist/bn-template-engine/p-8f490c45.entry.js +0 -1
  78. package/dist/bn-template-engine/p-98cf512f.entry.js +0 -1
  79. package/dist/bn-template-engine/p-9a564f8f.entry.js +0 -1
  80. package/dist/bn-template-engine/p-B7p8beYH.js +0 -1
  81. package/dist/bn-template-engine/p-BDh7GfC5.js +0 -1
  82. package/dist/bn-template-engine/p-BoMtoHJB.js +0 -1
  83. package/dist/bn-template-engine/p-Bs8BqBsb.js +0 -1
  84. package/dist/bn-template-engine/p-CYjZRKdI.js +0 -1
  85. package/dist/bn-template-engine/p-DG-1MR_T.js +0 -1
  86. package/dist/bn-template-engine/p-bdd2b243.entry.js +0 -1
  87. package/dist/bn-template-engine/p-e6b24f15.entry.js +0 -1
  88. package/dist/bn-template-engine/p-f27995c9.entry.js +0 -1
  89. package/dist/bn-template-engine/p-sRO-lj7X.js +0 -1
  90. package/dist/bn-template-engine/p-tzFCK9qn.js +0 -1
  91. package/dist/cjs/bn-asset_16.cjs.entry.js +0 -9018
  92. package/dist/cjs/bn-card.cjs.entry.js +0 -36
  93. package/dist/cjs/bn-chart-time.cjs.entry.js +0 -995
  94. package/dist/cjs/bn-layout-card.cjs.entry.js +0 -248
  95. package/dist/cjs/formatter-4XCS0d2B.js +0 -221
  96. package/dist/cjs/ibcs-chart-time.cjs.entry.js +0 -4137
  97. package/dist/cjs/withComponentStatus-_x4LQZ0N.js +0 -109
  98. package/dist/cjs/withComponentStyle-ClSJfCku.js +0 -128
  99. package/dist/cjs/withStyled-9tG024gQ.js +0 -522
  100. package/dist/esm/bn-asset_16.entry.js +0 -9001
  101. package/dist/esm/bn-card.entry.js +0 -34
  102. package/dist/esm/bn-chart-time.entry.js +0 -993
  103. package/dist/esm/bn-layout-card.entry.js +0 -246
  104. package/dist/esm/formatter-BDh7GfC5.js +0 -215
  105. package/dist/esm/ibcs-chart-time.entry.js +0 -4135
  106. package/dist/esm/withComponentStatus-DodoSXe-.js +0 -107
  107. package/dist/esm/withComponentStyle-D3VWOsto.js +0 -126
  108. package/dist/esm/withStyled-CE3_3taP.js +0 -495
@@ -1,4 +1,4 @@
1
- import { h, Host } from "@stencil/core";
1
+ import { h, Host, writeTask } from "@stencil/core";
2
2
  import { isBlankInput, isTableBarColumnWidth, isTableCategoryWidth, isValidBoolean, isValidDataFormat, isValidDirection, isValidInteger, isValidMeasureScale, isValidMeasureType, isValidNumber, isValidTableType, validateColumnThereOfJsonStr, validateOrderList, validatePartOfJsonStr, validateScenarioList, validateThereOfJsonStr, validateVariancesList, } from "../../utils/validate";
3
3
  import withDataset from "../../utils/withDataset";
4
4
  import withComponentStatus from "../../utils/withComponentStatus";
@@ -7,6 +7,7 @@ import withTranslation from "../../utils/withTranslation";
7
7
  import { withStyled } from "../../utils/styled/withStyled";
8
8
  import withComponentStyle from "../../utils/withComponentStyle";
9
9
  import withHasError from "../../utils/withHasError";
10
+ import withInheritedProps, { isInheritedValue } from "../../utils/withInheritedProps";
10
11
  import { getParentDimensions } from "../../utils/parentDimensions";
11
12
  import { parseScaling } from "../../utils/scaling";
12
13
  import { BAR_COLUMN_WIDTH_EM, DataFormat, I18nMode, MeasureType, TableBarColumnWidth, TableCategoryWidth, } from "../../utils/constants";
@@ -267,9 +268,19 @@ export class Table {
267
268
  this.datasetMeta = meta;
268
269
  });
269
270
  this.t = withTranslation(this).t;
271
+ this.resolveInherited = withInheritedProps(this, [
272
+ { propName: "scenarios", ancestorAttr: "title-scenarios" },
273
+ { propName: "variances", ancestorAttr: "title-variances" },
274
+ { propName: "order", ancestorAttr: "title-order" },
275
+ { propName: "orderDirection", ancestorAttr: "title-order-direction" },
276
+ ]);
270
277
  }
271
278
  validateScenario(newValue) {
272
279
  const errId = "ERR_scenarios";
280
+ if (isInheritedValue(newValue)) {
281
+ this.errors.remove(errId);
282
+ return;
283
+ }
273
284
  const invalidScenarios = validateScenarioList(newValue);
274
285
  if (invalidScenarios.length > 0) {
275
286
  this.errors.addOrReplace({
@@ -284,6 +295,10 @@ export class Table {
284
295
  }
285
296
  validateVariances(newValue) {
286
297
  const errId = "ERR_variances";
298
+ if (isInheritedValue(newValue)) {
299
+ this.errors.remove(errId);
300
+ return;
301
+ }
287
302
  const invalidVariances = validateVariancesList(newValue);
288
303
  if (invalidVariances.length > 0) {
289
304
  this.errors.addOrReplace({
@@ -329,7 +344,8 @@ export class Table {
329
344
  }
330
345
  validateUnitScaling(newValue) {
331
346
  const errId = "ERR_unitScaling";
332
- if (!isValidNumber(newValue) && !this.pixelPerUnitGroupMap.has(newValue)) {
347
+ const isAuto = (newValue === null || newValue === void 0 ? void 0 : newValue.toString().trim().toLowerCase()) === "auto";
348
+ if (!isAuto && !isValidNumber(newValue) && !this.pixelPerUnitGroupMap.has(newValue)) {
333
349
  this.errors.addOrReplace({
334
350
  id: errId,
335
351
  type: "warning",
@@ -342,7 +358,8 @@ export class Table {
342
358
  }
343
359
  validatePercentageScaling(newValue) {
344
360
  const errId = "ERR_percentageScaling";
345
- if (!isValidNumber(newValue) && !this.pixelPerUnitGroupMap.has(newValue)) {
361
+ const isAuto = (newValue === null || newValue === void 0 ? void 0 : newValue.toString().trim().toLowerCase()) === "auto";
362
+ if (!isAuto && !isValidNumber(newValue) && !this.pixelPerUnitGroupMap.has(newValue)) {
346
363
  this.errors.addOrReplace({
347
364
  id: errId,
348
365
  type: "warning",
@@ -461,6 +478,10 @@ export class Table {
461
478
  }
462
479
  validateOrderList(newValue) {
463
480
  const errId = "ERR_order";
481
+ if (isInheritedValue(newValue)) {
482
+ this.errors.remove(errId);
483
+ return;
484
+ }
464
485
  const invalidElements = validateOrderList(newValue);
465
486
  if (invalidElements.length > 0) {
466
487
  this.errors.addOrReplace({
@@ -475,6 +496,10 @@ export class Table {
475
496
  }
476
497
  validateOrderDirection(newValue) {
477
498
  const errId = "ERR_orderDirection";
499
+ if (isInheritedValue(newValue)) {
500
+ this.errors.remove(errId);
501
+ return;
502
+ }
478
503
  if (!isValidDirection(newValue)) {
479
504
  this.errors.addOrReplace({
480
505
  id: errId,
@@ -627,7 +652,11 @@ export class Table {
627
652
  if (this.appliedScaleFactor !== 1) {
628
653
  host.style.setProperty("--bn-font-size", `${baseFontSize}px`);
629
654
  this._autoScaleGuard = true;
630
- this.appliedScaleFactor = 1;
655
+ // Defer state change to avoid Stencil "changed during rendering" warning.
656
+ // The CSS var is already applied, so the visual update is immediate.
657
+ writeTask(() => {
658
+ this.appliedScaleFactor = 1;
659
+ });
631
660
  }
632
661
  return;
633
662
  }
@@ -646,10 +675,14 @@ export class Table {
646
675
  else {
647
676
  this.errors.remove("AUTO_scale");
648
677
  }
649
- // Update state so bar charts re-render at the new scale
678
+ // Defer state update to avoid Stencil "changed during rendering" warning.
679
+ // The CSS var is already applied, so the visual update is immediate;
680
+ // the deferred state change triggers a re-render for SVG bar charts.
650
681
  if (Math.abs(computedFactor - this.appliedScaleFactor) > 0.001) {
651
682
  this._autoScaleGuard = true;
652
- this.appliedScaleFactor = computedFactor;
683
+ writeTask(() => {
684
+ this.appliedScaleFactor = computedFactor;
685
+ });
653
686
  }
654
687
  }
655
688
  prepareDataFormat() {
@@ -682,15 +715,19 @@ export class Table {
682
715
  return JSON.parse(this.partof);
683
716
  }
684
717
  prepareOrder() {
685
- var _a, _b, _c;
686
- const isAuto = ((_a = this.order) === null || _a === void 0 ? void 0 : _a.trim().toLowerCase()) === "auto";
687
- let orderStr = this.order;
688
- if (isAuto && ((_b = this.datasetMeta) === null || _b === void 0 ? void 0 : _b.suggestedOrder)) {
718
+ var _a;
719
+ const inheritedOrder = this.resolveInherited("order", this.order);
720
+ const inheritedDirection = this.resolveInherited("orderDirection", this.orderDirection);
721
+ const effectiveOrder = inheritedOrder !== null && inheritedOrder !== void 0 ? inheritedOrder : this.order;
722
+ const effectiveDirection = inheritedDirection !== null && inheritedDirection !== void 0 ? inheritedDirection : this.orderDirection;
723
+ const isAuto = (effectiveOrder === null || effectiveOrder === void 0 ? void 0 : effectiveOrder.trim().toLowerCase()) === "auto";
724
+ let orderStr = effectiveOrder;
725
+ if (isAuto && ((_a = this.datasetMeta) === null || _a === void 0 ? void 0 : _a.suggestedOrder)) {
689
726
  orderStr = this.datasetMeta.suggestedOrder;
690
727
  }
691
728
  const tableOrder = {
692
729
  hierarchy: orderStr.split(",").map((entry) => OrderColumn[entry === null || entry === void 0 ? void 0 : entry.toUpperCase()]),
693
- direction: OrderDirection[(_c = this.orderDirection) === null || _c === void 0 ? void 0 : _c.toUpperCase()],
730
+ direction: OrderDirection[effectiveDirection === null || effectiveDirection === void 0 ? void 0 : effectiveDirection.toUpperCase()],
694
731
  };
695
732
  return tableOrder;
696
733
  }
@@ -713,10 +750,29 @@ export class Table {
713
750
  return formatDigits;
714
751
  }
715
752
  prepareScenarios() {
716
- var _a, _b, _c, _d, _e, _f, _g, _h;
717
- const isAuto = ((_a = this.scenarios) === null || _a === void 0 ? void 0 : _a.trim().toLowerCase()) === "auto";
753
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j;
754
+ const inheritedScenarios = this.resolveInherited("scenarios", this.scenarios);
755
+ const inheritedVariances = this.resolveInherited("variances", this.variances);
756
+ if (inheritedScenarios !== undefined || inheritedVariances !== undefined) {
757
+ this.errors.remove("AUTO_scenarios");
758
+ let scenarios = [];
759
+ if (inheritedScenarios !== undefined) {
760
+ scenarios = scenarios.concat(inheritedScenarios.split(","));
761
+ }
762
+ else if (!isBlankInput(this.scenarios)) {
763
+ scenarios = scenarios.concat(this.scenarios.split(","));
764
+ }
765
+ if (inheritedVariances !== undefined) {
766
+ scenarios = scenarios.concat(inheritedVariances.split(","));
767
+ }
768
+ else if (((_a = this.variances) === null || _a === void 0 ? void 0 : _a.trim().length) > 0) {
769
+ scenarios = scenarios.concat(this.variances.split(","));
770
+ }
771
+ return scenarios.map((entry) => entry.trim());
772
+ }
773
+ const isAuto = ((_b = this.scenarios) === null || _b === void 0 ? void 0 : _b.trim().toLowerCase()) === "auto";
718
774
  if ((isBlankInput(this.scenarios) || isAuto) && isBlankInput(this.variances)) {
719
- if (((_c = (_b = this.datasetMeta) === null || _b === void 0 ? void 0 : _b.availableScenarios) === null || _c === void 0 ? void 0 : _c.length) > 0) {
775
+ if (((_d = (_c = this.datasetMeta) === null || _c === void 0 ? void 0 : _c.availableScenarios) === null || _d === void 0 ? void 0 : _d.length) > 0) {
720
776
  if (!isAuto) {
721
777
  this.errors.addOrReplace({
722
778
  id: "AUTO_scenarios",
@@ -733,7 +789,7 @@ export class Table {
733
789
  }
734
790
  let scenarios = [];
735
791
  if (isAuto || isBlankInput(this.scenarios)) {
736
- if (((_e = (_d = this.datasetMeta) === null || _d === void 0 ? void 0 : _d.availableScenarios) === null || _e === void 0 ? void 0 : _e.length) > 0) {
792
+ if (((_f = (_e = this.datasetMeta) === null || _e === void 0 ? void 0 : _e.availableScenarios) === null || _f === void 0 ? void 0 : _f.length) > 0) {
737
793
  if (!isAuto) {
738
794
  this.errors.addOrReplace({
739
795
  id: "AUTO_scenarios",
@@ -749,10 +805,10 @@ export class Table {
749
805
  }
750
806
  else {
751
807
  this.errors.remove("AUTO_scenarios");
752
- scenarios = scenarios.concat((_f = this.scenarios) === null || _f === void 0 ? void 0 : _f.split(","));
808
+ scenarios = scenarios.concat((_g = this.scenarios) === null || _g === void 0 ? void 0 : _g.split(","));
753
809
  }
754
- if (((_g = this.variances) === null || _g === void 0 ? void 0 : _g.trim().length) > 0) {
755
- scenarios = scenarios.concat((_h = this.variances) === null || _h === void 0 ? void 0 : _h.split(","));
810
+ if (((_h = this.variances) === null || _h === void 0 ? void 0 : _h.trim().length) > 0) {
811
+ scenarios = scenarios.concat((_j = this.variances) === null || _j === void 0 ? void 0 : _j.split(","));
756
812
  }
757
813
  return scenarios.map((entry) => entry.trim());
758
814
  }
@@ -833,15 +889,23 @@ export class Table {
833
889
  return this.barColumns.split(",").map((col) => col.trim());
834
890
  }
835
891
  prepareUnitScaling() {
892
+ var _a;
836
893
  if (this.pixelPerUnitGroupMap.has(this.unitScaling)) {
837
894
  return this.pixelPerUnitGroupMap.get(this.unitScaling);
838
895
  }
896
+ if (((_a = this.unitScaling) === null || _a === void 0 ? void 0 : _a.toString().trim().toLowerCase()) === "auto") {
897
+ return 0;
898
+ }
839
899
  return Number(this.unitScaling);
840
900
  }
841
901
  preparePercentageScaling() {
902
+ var _a;
842
903
  if (this.pixelPerUnitGroupMap.has(this.percentageScaling)) {
843
904
  return this.pixelPerUnitGroupMap.get(this.percentageScaling);
844
905
  }
906
+ if (((_a = this.percentageScaling) === null || _a === void 0 ? void 0 : _a.toString().trim().toLowerCase()) === "auto") {
907
+ return 0;
908
+ }
845
909
  return Number(this.percentageScaling);
846
910
  }
847
911
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
@@ -905,7 +969,7 @@ export class Table {
905
969
  render() {
906
970
  const fontStyles = this.getFontStyles();
907
971
  const effectiveFactor = this.getEffectiveScaleFactor();
908
- return (h(Host, { key: '3690ce4fee5e38012a2f956035110cc3e2500b39', style: fontStyles }, h("div", { key: 'e6481956a6873beefb15ea7369a7352d2662c1a2' }, h("ibcs-table", { key: '3260517d31fa04294c8df293a6fefd88b129f7b6', data: this.data, "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 }))));
972
+ return (h(Host, { key: '95a43b9087d7d5d0be75c361795ef0a5a1cb30fe', style: fontStyles }, h("div", { key: 'a905e16727e619222b478fcc4dbe0c903306c420' }, h("ibcs-table", { key: '454d019b157c730ec0b3f7cfcf16ae0e56c4a255', data: this.data, "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 }))));
909
973
  }
910
974
  static get is() { return "bn-table"; }
911
975
  static get encapsulation() { return "shadow"; }
@@ -72,9 +72,9 @@ export class IbcsTable {
72
72
  const config = this.prepareConfig();
73
73
  const data = this.prepareData();
74
74
  this.componentDataFormatDigits = new DataFormatDigitsAdapter().adapt(this.dataFormatDigits);
75
- this.barChartStyles = this.prepareBarChartStyles();
76
75
  this.table = new Table(new IBCSRuleSet(), data, config);
77
76
  this.table.setI18n(this.i18n);
77
+ this.barChartStyles = this.prepareBarChartStyles();
78
78
  }
79
79
  prepareConfig() {
80
80
  const config = new TableComponentConfigAdapter(new TableDrillGroupAdapter(), new StringAdapter(), new OrderAdapter(new StringAdapter()), this.data).adapt({
@@ -166,12 +166,77 @@ export class IbcsTable {
166
166
  fontColor: ((_z = $["global"]) === null || _z === void 0 ? void 0 : _z["fontColor"]) || "#000000",
167
167
  fontSize: (((_0 = $["global"]) === null || _0 === void 0 ? void 0 : _0["fontSizePx"]) || 13.3333) * 0.85 * this.scaleFactor,
168
168
  fontFamily: ((_1 = $["global"]) === null || _1 === void 0 ? void 0 : _1["fontFamily"]) || "'Noto Sans', sans-serif",
169
- unitScaling: this.unitScaling,
170
- percentageScaling: this.percentageScaling,
169
+ unitScaling: this.unitScaling > 0 ? this.unitScaling : this.autoUnitScaling(),
170
+ percentageScaling: this.percentageScaling > 0 ? this.percentageScaling : this.autoPercentageScaling(),
171
171
  scaleFactor: this.scaleFactor,
172
172
  };
173
173
  });
174
174
  }
175
+ /**
176
+ * Auto-calculate unitScaling so the largest absolute variance bar
177
+ * fills ~80% of the bar column width.
178
+ */
179
+ autoUnitScaling() {
180
+ const fs = this.componentStyle(($) => { var _a; return (((_a = $["global"]) === null || _a === void 0 ? void 0 : _a["fontSizePx"]) || 13.3333) * 0.85 * this.scaleFactor; });
181
+ const maxBarWidthPx = this.barColumnMaxWidth * fs;
182
+ const targetWidth = maxBarWidthPx * 0.8;
183
+ const absMax = this.getMaxAbsValue();
184
+ if (absMax <= 0 || fs <= 0) {
185
+ return 0.01;
186
+ }
187
+ return targetWidth / (absMax * fs);
188
+ }
189
+ /**
190
+ * Auto-calculate percentageScaling so the largest relative variance pin
191
+ * fills ~80% of the pin area.
192
+ */
193
+ autoPercentageScaling() {
194
+ const fs = this.componentStyle(($) => { var _a; return (((_a = $["global"]) === null || _a === void 0 ? void 0 : _a["fontSizePx"]) || 13.3333) * 0.85 * this.scaleFactor; });
195
+ const maxPinLength = Math.round(this.barColumnMaxWidth * 0.67 * fs);
196
+ const targetLength = maxPinLength * 0.8;
197
+ const maxPct = this.getMaxRelativeValue();
198
+ if (maxPct <= 0 || fs <= 0) {
199
+ return 0.5;
200
+ }
201
+ return targetLength / (maxPct * fs);
202
+ }
203
+ /**
204
+ * Find the maximum absolute value across all absolute variance columns (d_*) in the table body.
205
+ */
206
+ getMaxAbsValue() {
207
+ if (!this.table)
208
+ return 0;
209
+ let max = 0;
210
+ for (const row of this.table.getBody()) {
211
+ if (row.type === TableRowType.SUM)
212
+ continue;
213
+ for (const cell of row.getCells()) {
214
+ if (cell.isBarChart && cell.columnStats && !cell.key.startsWith("dr")) {
215
+ max = Math.max(max, cell.columnStats.absMax);
216
+ }
217
+ }
218
+ }
219
+ return max;
220
+ }
221
+ /**
222
+ * Find the maximum percentage value across all relative variance columns (dr_*) in the table body.
223
+ * Values are stored as decimals (e.g. 0.2 = 20%), returned as percentage (20).
224
+ */
225
+ getMaxRelativeValue() {
226
+ if (!this.table)
227
+ return 0;
228
+ let max = 0;
229
+ for (const row of this.table.getBody()) {
230
+ if (row.type === TableRowType.SUM)
231
+ continue;
232
+ for (const cell of row.getCells()) {
233
+ if (cell.isBarChart && cell.columnStats && cell.key.startsWith("dr")) {
234
+ max = Math.max(max, cell.columnStats.absMax * 100);
235
+ }
236
+ }
237
+ }
238
+ return max;
239
+ }
175
240
  static get is() { return "ibcs-table"; }
176
241
  static get encapsulation() { return "shadow"; }
177
242
  static get originalStyleUrls() {
@@ -0,0 +1,152 @@
1
+ import { forceUpdate, getElement } from "@stencil/core";
2
+ import { runIfExisits } from "./utils";
3
+ /**
4
+ * Reserved prop values that activate inheritance from ancestor layout
5
+ * components (`bn-layout-card` or `bn-layout-page`).
6
+ */
7
+ export const INHERITED_CLOSEST = "inherited-closest";
8
+ export const INHERITED_PAGE = "inherited-page";
9
+ /** Tags that qualify as inheritance ancestors. */
10
+ const ANCESTOR_CARD = "bn-layout-card";
11
+ const ANCESTOR_PAGE = "bn-layout-page";
12
+ /**
13
+ * Returns `true` when `value` is one of the recognised inheritance keywords.
14
+ */
15
+ export function isInheritedValue(value) {
16
+ return value === INHERITED_CLOSEST || value === INHERITED_PAGE;
17
+ }
18
+ /**
19
+ * Walks up the DOM tree (crossing shadow boundaries) to find the nearest
20
+ * ancestor layout component.
21
+ *
22
+ * - `"inherited-closest"` matches the first `bn-layout-card` or `bn-layout-page`.
23
+ * - `"inherited-page"` skips cards and matches only `bn-layout-page`.
24
+ *
25
+ * Uses the same traversal pattern as `findContextElement` in
26
+ * `context-protocol.ts`.
27
+ */
28
+ function findAncestor(element, mode) {
29
+ let current = element.parentNode;
30
+ while (current) {
31
+ if (current instanceof HTMLElement) {
32
+ const tag = current.nodeName.toLowerCase();
33
+ if (mode === INHERITED_PAGE) {
34
+ if (tag === ANCESTOR_PAGE)
35
+ return current;
36
+ }
37
+ else {
38
+ if (tag === ANCESTOR_CARD || tag === ANCESTOR_PAGE)
39
+ return current;
40
+ }
41
+ }
42
+ if (current.parentNode) {
43
+ current = current.parentNode;
44
+ }
45
+ else if (current instanceof ShadowRoot) {
46
+ current = current.host;
47
+ }
48
+ else {
49
+ break;
50
+ }
51
+ }
52
+ return undefined;
53
+ }
54
+ /**
55
+ * Mixin that enables property inheritance from ancestor layout components.
56
+ *
57
+ * When a component sets a prop to `"inherited-closest"` or `"inherited-page"`,
58
+ * this mixin resolves the actual value by walking up the DOM to find the
59
+ * nearest `bn-layout-card` / `bn-layout-page` and reading the corresponding
60
+ * HTML attribute. A `MutationObserver` watches the ancestor for attribute
61
+ * changes, triggering a re-render when inherited values update.
62
+ *
63
+ * Follows the same decorator-style pattern as `withComponentStyle`.
64
+ *
65
+ * @param component The Stencil component instance
66
+ * @param mappings Array of prop-to-attribute mappings
67
+ * @returns A resolver function used inside `prepare*()` methods
68
+ */
69
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
70
+ const withInheritedProps = (component, mappings) => {
71
+ /** Resolved values keyed by propName. */
72
+ const resolved = new Map();
73
+ /** Observer watching the ancestor element's attributes. */
74
+ let observer = null;
75
+ /** The ancestor element currently being observed. */
76
+ let ancestorEl;
77
+ /**
78
+ * For each mapping whose prop is an inheritance keyword, walk the DOM once
79
+ * and read the corresponding attribute from the ancestor.
80
+ */
81
+ const resolveAll = () => {
82
+ const element = getElement(component);
83
+ resolved.clear();
84
+ // Determine which attrs to watch on which ancestor
85
+ const attrsToWatch = [];
86
+ for (const mapping of mappings) {
87
+ const value = component[mapping.propName];
88
+ if (typeof value !== "string" || !isInheritedValue(value))
89
+ continue;
90
+ // Find ancestor (re-use the first one found for the same mode)
91
+ if (!ancestorEl) {
92
+ ancestorEl = findAncestor(element, value);
93
+ }
94
+ if (!ancestorEl)
95
+ continue;
96
+ const attrValue = ancestorEl.getAttribute(mapping.ancestorAttr);
97
+ if (attrValue != null) {
98
+ resolved.set(mapping.propName, attrValue);
99
+ }
100
+ attrsToWatch.push(mapping.ancestorAttr);
101
+ }
102
+ // Set up MutationObserver on the ancestor
103
+ if (ancestorEl && attrsToWatch.length > 0) {
104
+ observer = new MutationObserver(() => {
105
+ // Re-read all inherited attributes from the ancestor
106
+ for (const mapping of mappings) {
107
+ if (!isInheritedValue(component[mapping.propName]))
108
+ continue;
109
+ const attrValue = ancestorEl.getAttribute(mapping.ancestorAttr);
110
+ if (attrValue != null) {
111
+ resolved.set(mapping.propName, attrValue);
112
+ }
113
+ else {
114
+ resolved.delete(mapping.propName);
115
+ }
116
+ }
117
+ forceUpdate(component);
118
+ });
119
+ observer.observe(ancestorEl, {
120
+ attributes: true,
121
+ attributeFilter: attrsToWatch,
122
+ });
123
+ }
124
+ };
125
+ const connectedCallback = component["connectedCallback"];
126
+ component["connectedCallback"] = () => {
127
+ resolveAll();
128
+ runIfExisits(connectedCallback, component);
129
+ };
130
+ const disconnectedCallback = component["disconnectedCallback"];
131
+ component["disconnectedCallback"] = () => {
132
+ if (observer) {
133
+ observer.disconnect();
134
+ observer = null;
135
+ }
136
+ ancestorEl = undefined;
137
+ resolved.clear();
138
+ runIfExisits(disconnectedCallback, component);
139
+ };
140
+ /**
141
+ * Resolver: returns the inherited value for the given prop, or `undefined`
142
+ * when the prop is not using inheritance (so the caller falls through to
143
+ * its normal logic).
144
+ */
145
+ const resolve = (propName, currentValue) => {
146
+ if (!isInheritedValue(currentValue))
147
+ return undefined;
148
+ return resolved.get(propName);
149
+ };
150
+ return resolve;
151
+ };
152
+ export default withInheritedProps;
@@ -1 +1 @@
1
- import{proxyCustomElement as e,HTMLElement as i,h as t,Host as s,transformTag as a}from"@stencil/core/internal/client";import{v as r,a as n,h as o,j as l,b as c,c as h,k as d,l as p,m as u,n as v,i as m}from"./validate.js";import{w as g,g as f,p as y}from"./scaling.js";import{w as b,a as S}from"./withHasError.js";import{w}from"./withTranslation.js";import{a as O}from"./context-protocol.js";import{w as k}from"./withStyled.js";import{w as _}from"./withComponentStyle.js";import{A as x,b as R,O as T,g as A,h as E,i as U}from"./Order.js";import{d as M}from"./ibcs-chart-structure2.js";const N=e(class extends i{validateScenario(e){const i=r(e),t="ERR_scenarios";i.length>0?this.errors.addOrReplace({id:t,type:"warning",message:"scenarios: invalid value(s) '"+JSON.stringify(i)+"' are not supported."}):this.errors.remove(t)}validateVariances(e){const i="ERR_variances",t=n(e);t.length>0?this.errors.addOrReplace({id:i,type:"warning",message:"variances: invalid value(s) '"+JSON.stringify(t)+"' are not supported."}):this.errors.remove(i)}validateUnitScaling(e){const i="ERR_unitScaling";o(e)||this.pixelPerUnitGroupMap.has(e)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"unitScaling: invalid value(s) '"+e+"' are not supported."})}validatePercentageScaling(e){const i="ERR_percentageScaling";o(e)||this.pixelPerUnitGroupMap.has(e)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"percentageScaling: invalid value(s) '"+e+"' are not supported."})}validateLevel(e){const i="ERR_level";l(e)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"level: invalid value(s) '"+e+"' are not supported."})}validateOrderList(e){const i=c(e),t="ERR_order";i.length>0?this.errors.addOrReplace({id:t,type:"warning",message:"order: invalid value(s) '"+JSON.stringify(i)+"' are not supported."}):this.errors.remove(t)}validateOrderDirection(e){const i="ERR_orderDirection";h(e)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"orderDirection: invalid value '"+(null==e?void 0:""+e)+"' is not supported."})}validateLimit(e){const i="ERR_limit";d(e)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"limit: invalid value '"+(null==e?void 0:""+e)+"' is not supported."})}validateShowCategories(e){const i="ERR_showCategories";p(e)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"showCategories: invalid value(s) '"+(null==e?void 0:""+e)+"' are not supported."})}validateMeasureScale(e){const i="ERR_measureScale";u(e)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"measureScale: invalid value '"+(null==e?void 0:""+e)+"' is not supported."})}validateShowMeasureScale(e){const i="ERR_grouped";p(e)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"showMeasureScale: invalid value(s) '"+(null==e?void 0:""+e)+"' are not supported."})}validateStack(e){const i="ERR_stack",t=v(e);t.length>0?this.errors.addOrReplace({id:i,type:"warning",message:t.join("; ")}):this.errors.remove(i)}validateScaling(e){if(null==e||""===e||"none"===e||"auto"===e)return void this.errors.remove("ERR_scale");const i=Number(e);isNaN(i)||i<=0?this.errors.addOrReplace({id:"ERR_scale",type:"warning",message:`Invalid scale value: "${e}". Use "none", "auto", or a positive number.`}):this.errors.remove("ERR_scale")}constructor(e){super(),!1!==e&&this.__registerHost(),this.__attachShadow(),this.data=[],this.datasetMeta=null,this.appliedScaleFactor=1,this.chartTitle="",this.filter="",this.limit=0,this.showCategories="true",this.measureScale="greatest",this.showMeasureScale="false",this.measureUnit="",this.stack="",this.scenariosArray=[""],this.pixelPerUnitGroupMap=new Map,this._autoScaleGuard=!1,k(this),b(this),g(this,((e,i)=>{this.data=i||[]}),((e,i)=>{this.datasetMeta=i})),this.chartTemplate=this.chartTemplate.bind(this),this.errors=S(this),this.componentStyle=_(this),this.t=w(this).t}componentWillLoad(){this.validateScenario(this.scenarios),this.validateVariances(this.variances),this.validateUnitScaling(this.unitScaling),this.validateLevel(this.level),this.validateOrderDirection(this.orderDirection),this.validateOrderList(this.order),this.validateShowCategories(this.showCategories),this.validateMeasureScale(this.measureScale),this.validateShowMeasureScale(this.showMeasureScale),this.validateStack(this.stack),this.validateScaling(this.scale)}componentDidRender(){var e,i;const{mode:t}=y(this.scale);if("auto"!==t&&"empty"!==t)return this._autoScaleGuard=!1,void this.checkWidthOverflow();if(this._autoScaleGuard)return this._autoScaleGuard=!1,void this.checkWidthOverflow();const s=this.element,{height:a}=f(s);if(a<=0)return void this.checkWidthOverflow();const r=this.componentStyle((e=>{var i;return(null===(i=e.global)||void 0===i?void 0:i.fontSizePx)||13.3333}));s.style.setProperty("--bn-font-size",r+"px");const n=null===(e=s.shadowRoot)||void 0===e?void 0:e.querySelector(".container"),o=null!==(i=null==n?void 0:n.scrollHeight)&&void 0!==i?i:s.scrollHeight;if(o<=a+1)return this.errors.remove("AUTO_scale"),1!==this.appliedScaleFactor&&(this._autoScaleGuard=!0,this.appliedScaleFactor=1),void this.checkWidthOverflow();const l=(a-1)/o;s.style.setProperty("--bn-font-size",r*l+"px"),"empty"===t?this.errors.addOrReplace({id:"AUTO_scale",type:"warning",message:"Auto-scaled chart by factor "+l.toFixed(3)}):this.errors.remove("AUTO_scale"),Math.abs(l-this.appliedScaleFactor)>.001&&(this._autoScaleGuard=!0,this.appliedScaleFactor=l),this.checkWidthOverflow()}checkWidthOverflow(){var e;const i="WARN_overflow",t=((null!==(e=this.unitScaling)&&void 0!==e?e:"")+"").trim().toLowerCase();if(""===t||"auto"===t)return void this.errors.remove(i);const s=f(this.element);s.width>0&&this.element.scrollWidth>s.width+1?this.errors.addOrReplace({id:i,type:"error",message:`Chart exceeds available width (${this.element.scrollWidth}px > ${Math.round(s.width)}px). Reduce unit-scaling or set to "auto".`}):this.errors.remove(i)}prepareDimension(){const e=f(this.element);return this.canvasWidthSegmented=e.width/this.scenariosArray.length,{width:this.canvasWidthSegmented,height:e.height}}prepareScenarios(){var e,i,t,s;const a="auto"===(null===(e=this.scenarios)||void 0===e?void 0:e.trim().toLowerCase());return m(this.scenarios)||a?(null===(t=null===(i=this.datasetMeta)||void 0===i?void 0:i.availableScenarios)||void 0===t?void 0:t.length)>0?(a?this.errors.remove("AUTO_scenarios"):this.errors.addOrReplace({id:"AUTO_scenarios",type:"warning",message:"scenarios: not set, auto-detected: "+this.datasetMeta.availableScenarios.join(",")}),this.datasetMeta.availableScenarios):[]:(this.errors.remove("AUTO_scenarios"),null===(s=this.scenarios)||void 0===s?void 0:s.split(",").map((e=>e.trim())))}prepareVariances(){var e;return m(this.variances)?[]:null===(e=this.variances)||void 0===e?void 0:e.split(",").map((e=>e.trim()))}prepareHideCategories(e){return e>=1||"true"!==this.showCategories}prepareI18n(){const e=O,i=new Map([].map((e=>[e,this.t(".".concat(e))]))),t=new Map(e.map((e=>[e,this.t("global.".concat(e))])));return new Map([...t.entries(),...i.entries()])}preparePixelPerUnit(){var e;if(this.pixelPerUnitGroupMap.has(this.unitScaling))return this.errors.remove("AUTO_unitScaling"),this.pixelPerUnitGroupMap.get(this.unitScaling);if("auto"===(null===(e=this.unitScaling)||void 0===e?void 0:(""+e).trim().toLowerCase()))return this.errors.remove("AUTO_unitScaling"),0;const i=Number(this.unitScaling);return!isNaN(i)&&i>0?(this.errors.remove("AUTO_unitScaling"),i):(this.errors.addOrReplace({id:"AUTO_unitScaling",type:"warning",message:"unit-scaling: not set, auto-calculated to fit available space."}),0)}preparePixelPerPercentage(){return this.pixelPerUnitGroupMap.has(this.percentageScaling)?this.pixelPerUnitGroupMap.get(this.percentageScaling):100*Number(this.percentageScaling)}prepareLevel(){var e,i,t;const s="auto"===(null===(e=this.level)||void 0===e?void 0:e.trim().toLowerCase());return m(this.level)||s?(null===(i=this.datasetMeta)||void 0===i?void 0:i.suggestedLevel)?(s?this.errors.remove("AUTO_level"):this.errors.addOrReplace({id:"AUTO_level",type:"warning",message:"level: not set, auto-detected: "+this.datasetMeta.suggestedLevel}),x[this.datasetMeta.suggestedLevel.toUpperCase()]):void 0:(this.errors.remove("AUTO_level"),x[null===(t=this.level)||void 0===t?void 0:t.toUpperCase()])}prepareOrder(){var e,i,t;const s="auto"===(null===(e=this.order)||void 0===e?void 0:e.trim().toLowerCase());let a;return m(this.order)||s?(null===(i=this.datasetMeta)||void 0===i?void 0:i.suggestedOrder)?(s?this.errors.remove("AUTO_order"):this.errors.addOrReplace({id:"AUTO_order",type:"warning",message:"order: not set, auto-detected: "+this.datasetMeta.suggestedOrder}),a=this.datasetMeta.suggestedOrder):a=this.order:(this.errors.remove("AUTO_order"),a=this.order),{hierarchy:null==a?void 0:a.split(",").map((e=>T[null==e?void 0:e.toUpperCase()])),direction:R[null===(t=this.orderDirection)||void 0===t?void 0:t.toUpperCase()]}}prepareStyle(){const e=this.getEffectiveScaleFactor();return this.componentStyle((i=>{const t=i.global.fontSizePx*e;return{scaleFactors:{scenarioOffset:i["bn-chart-structure"].scaleFactors.scenarioOffset,scenarioLabelToBar:i["bn-chart-structure"].scaleFactors.scenarioLabelToBar,labelToBar:i["bn-chart-structure"].scaleFactors.labelToBar,labelToAxis:i["bn-chart-structure"].scaleFactors.labelToAxis,needleWidth:i["bn-chart-structure"].scaleFactors.needleWidth,needleHeadWidth:i["bn-chart-structure"].scaleFactors.needleHeadWidth,barWidth:i["bn-chart-structure"].scaleFactors.barWidth,varianceAxisLineWidth:i["bn-chart-structure"].scaleFactors.varianceAxisLineWidth,axisLineWidth:i["bn-chart-structure"].scaleFactors.axisLineWidth,auxiliaryLineWidth:i["bn-chart-structure"].scaleFactors.auxiliaryLineWidth,scenarioLineWidth:i["bn-chart-structure"].scaleFactors.scenarioLineWidth,markerWidth:i["bn-chart-structure"].scaleFactors.markerWidth,markerOffset:i["bn-chart-structure"].scaleFactors.markerOffset,categoryWidth:i["bn-chart-structure"].scaleFactors.categoryWidth,axisTickLength:i["bn-chart-structure"].scaleFactors.axisTickLength},fontStyles:{font:`${t}px ${i.global.fontFamily}`,size:t,color:i.global.fontColor,background:i.global.fontBackgroundColor,leading:1.8},axisStyles:i["bn-chart-structure"].axisStyles,barStyles:i["bn-chart-structure"].barStyles,varianceStyles:i["bn-chart-structure"].varianceStyles,padding:i["bn-chart-structure"].padding,pattern:null}}))}prepareChartTitle(e){return e>=1?"":this.chartTitle}prepareStackConfig(){if(m(this.stack))return this.errors.remove("WARN_stack_dimensions_scenarios"),null;try{const e=JSON.parse(this.stack),i=e.by,t="WARN_stack_dimensions_scenarios";if(i===A.DIMENSIONS){const e=this.prepareScenarios();e.length>1?this.errors.addOrReplace({id:t,type:"warning",message:`stack by dimensions: only the first scenario "${e[0]}" is used, the rest (${e.slice(1).join(", ")}) are discarded.`}):this.errors.remove(t)}else this.errors.remove(t);return{by:i,mode:e.mode||U.ABSOLUTE,order:e.order||E.DATASET}}catch(e){return this.errors.remove("WARN_stack_dimensions_scenarios"),null}}prepareFilter(){return 0===this.filter.length?"":this.filter}prepareLimit(){return Math.floor(Number(this.limit)||0)}getDataStructure(){return{IStructureChartDataRow:{operation:{type:"string",isOptional:!1,description:""},rowGroup:{type:"string",isOptional:!1,description:""},rowGroupIndex:{type:"number",isOptional:!1,description:""},category:{type:"string",isOptional:!1,description:""},categoryIndex:{type:"number",isOptional:!1,description:""},subCategory:{type:"string",isOptional:!1,description:""},subCategoryIndex:{type:"number",isOptional:!1,description:""},columnGroup:{type:"string",isOptional:!1,description:""},columnGroupIndex:{type:"number",isOptional:!1,description:""},columnSubGroup:{type:"string",isOptional:!1,description:""},columnSubGroupIndex:{type:"number",isOptional:!1,description:""},ac1:{type:"number",isOptional:!1,description:""},ac2:{type:"number",isOptional:!1,description:""},ac3:{type:"number",isOptional:!1,description:""},ac4:{type:"number",isOptional:!1,description:""},pp1:{type:"number",isOptional:!1,description:""},pp2:{type:"number",isOptional:!1,description:""},pp3:{type:"number",isOptional:!1,description:""},pp4:{type:"number",isOptional:!1,description:""},fc1:{type:"number",isOptional:!1,description:""},fc2:{type:"number",isOptional:!1,description:""},fc3:{type:"number",isOptional:!1,description:""},fc4:{type:"number",isOptional:!1,description:""},pl1:{type:"number",isOptional:!1,description:""},pl2:{type:"number",isOptional:!1,description:""},pl3:{type:"number",isOptional:!1,description:""},pl4:{type:"number",isOptional:!1,description:""}}}}prepareMeasureScale(){return m(this.measureScale)?"GREATEST":["_","k","M","G","T","P","E","Z","Y","m","μ","n","p","P","f","a","z","y"].includes(this.measureScale.trim())||"LEAST"===this.measureScale.trim().toUpperCase()?this.measureScale.trim():"GREATEST"}prepareShowMeasureScale(e){return 0===e&&"true"===this.showMeasureScale}prepareMeasureUnit(){return""===this.measureUnit||null==this.measureUnit?"":this.measureUnit}chartTemplate(e,i){const s=this.getEffectiveScaleFactor(),a=this.preparePixelPerUnit(),r=this.preparePixelPerPercentage(),n=this.prepareStackConfig(),o=this.prepareScenarios(),l=(null==n?void 0:n.by)===A.DIMENSIONS?o.slice(0,1):o;return t("ibcs-chart-structure",{data:this.data,chartTitle:this.prepareChartTitle(i),scenarios:l,variances:[e],hideCategories:this.prepareHideCategories(i),pixelPerUnit:a>0?a*s:0,pixelPerPercentage:r>0?r*s:0,limit:this.prepareLimit(),styles:this.prepareStyle(),i18n:this.prepareI18n(),order:this.prepareOrder(),level:this.prepareLevel(),filter:this.prepareFilter(),"measure-scale":this.prepareMeasureScale(),"measure-unit":this.prepareMeasureUnit(),showMeasureScale:this.prepareShowMeasureScale(i),stackConfig:n,parentDimensions:this.prepareDimension()})}getEffectiveScaleFactor(){const{mode:e,factor:i}=y(this.scale);return"factor"===e?i:"auto"===e||"empty"===e?this.appliedScaleFactor:1}getFontStyles(){const e=this.getEffectiveScaleFactor();return this.componentStyle((i=>{var t,s,a,r;const n=(null===(t=i.global)||void 0===t?void 0:t.fontSizePx)||13.3333;return{"--bn-font-family":(null===(s=i.global)||void 0===s?void 0:s.fontFamily)||"'Noto Sans', sans-serif","--bn-font-size":n*e+"px","--bn-font-color":(null===(a=i.global)||void 0===a?void 0:a.fontColor)||"#000000","--bn-font-background":(null===(r=i.global)||void 0===r?void 0:r.fontBackgroundColor)||"#ffffff"}}))}render(){let e=[""];const i=this.prepareVariances();i.length>0&&(e=[...e,...i]);const a=this.getFontStyles();return t(s,{key:"570fb741ddf481be0f3055d346314ad39a455361",style:a},t("div",{key:"e84cfe2e00dd2f960f038844e00449431efa6ce0",class:"container"},e.map(this.chartTemplate)))}get element(){return this}static get watchers(){return{scenarios:[{validateScenario:0}],variances:[{validateVariances:0}],unitScaling:[{validateUnitScaling:0}],percentageScaling:[{validatePercentageScaling:0}],level:[{validateLevel:0}],order:[{validateOrderList:0}],orderDirection:[{validateOrderDirection:0}],limit:[{validateLimit:0}],showCategories:[{validateShowCategories:0}],measureScale:[{validateMeasureScale:0}],showMeasureScale:[{validateShowMeasureScale:0}],stack:[{validateStack:0}],scale:[{validateScaling:0}]}}static get style(){return':host{display:inline-block;position:relative;overflow:hidden}.container{display:flex;flex-direction:row}.background-image{display:flex;flex-wrap:wrap;justify-content:flex-end}.categories{text-align:right;font-size:var(--bn-font-size, 1em);font-family:var(--bn-font-family, "Noto Sans", "Helvetica Neue", Helvetica, sans-serif);color:var(--bn-font-color, black)}.label-bg{fill:var(--bn-font-background, white);opacity:0.7}.label-text{text-align:right;font-size:var(--bn-font-size, 1em);font-family:var(--bn-font-family, "Noto Sans", "Helvetica Neue", Helvetica, sans-serif);color:var(--bn-font-color, black)}.axis-title{text-align:center;font-family:var(--bn-font-family, "Noto Sans", "Helvetica Neue", Helvetica, sans-serif);color:var(--bn-font-color, black)}.axis-ac{stroke:black;stroke-width:0.1em}.axis-pp{stroke:grey;stroke-width:0.1em}.axis-fc{stroke:black;stroke-dasharray:2;stroke-width:0.1em}.axis-pl{stroke:white;stroke-width:0.1em;outline-offset:0em;outline:0.1em solid black}canvas{image-rendering:-moz-crisp-edges;image-rendering:-webkit-crisp-edges;image-rendering:pixelated;image-rendering:crisp-edges}.measure{font-weight:bold}span{display:inline-block}.hidePatternContainer{height:0;width:0}div{float:left}.warning{font-size:0.8em;font-style:italic}.footer{margin:0.2em;font-size:0.6em}.footer-hide{margin:0.2em;font-size:0.6em;opacity:0}'}},[1,"bn-chart-structure",{chartTitle:[1,"chart-title"],filter:[1],scenarios:[1],variances:[1],unitScaling:[8,"unit-scaling"],percentageScaling:[8,"percentage-scaling"],level:[1],order:[1],orderDirection:[1,"order-direction"],limit:[2],showCategories:[1,"show-categories"],measureScale:[1,"measure-scale"],showMeasureScale:[1,"show-measure-scale"],measureUnit:[1,"measure-unit"],stack:[1],scale:[1],data:[32],datasetMeta:[32],appliedScaleFactor:[32]},void 0,{scenarios:[{validateScenario:0}],variances:[{validateVariances:0}],unitScaling:[{validateUnitScaling:0}],percentageScaling:[{validatePercentageScaling:0}],level:[{validateLevel:0}],order:[{validateOrderList:0}],orderDirection:[{validateOrderDirection:0}],limit:[{validateLimit:0}],showCategories:[{validateShowCategories:0}],measureScale:[{validateMeasureScale:0}],showMeasureScale:[{validateShowMeasureScale:0}],stack:[{validateStack:0}],scale:[{validateScaling:0}]}]),C=N,L=function(){"undefined"!=typeof customElements&&["bn-chart-structure","ibcs-chart-structure"].forEach((e=>{switch(e){case"bn-chart-structure":customElements.get(a(e))||customElements.define(a(e),N);break;case"ibcs-chart-structure":customElements.get(a(e))||M()}}))};export{C as BnChartStructure,L as defineCustomElement}
1
+ import{proxyCustomElement as t,HTMLElement as i,writeTask as e,forceUpdate as s,h as a,Host as r,transformTag as n}from"@stencil/core/internal/client";import{v as o,a as l,h as c,j as h,b as d,c as p,k as u,l as v,m,n as g,i as f}from"./validate.js";import{w as y,g as b,p as S}from"./scaling.js";import{w,a as O}from"./withHasError.js";import{w as k}from"./withTranslation.js";import{a as _}from"./context-protocol.js";import{w as x}from"./withStyled.js";import{w as R}from"./withComponentStyle.js";import{i as A,w as T}from"./withInheritedProps.js";import{A as E,b as N,O as U,g as M,h as L,i as C}from"./Order.js";import{d as D}from"./ibcs-chart-structure2.js";const P=t(class extends i{validateScenario(t){const i="ERR_scenarios";if(A(t))return void this.errors.remove(i);const e=o(t);e.length>0?this.errors.addOrReplace({id:i,type:"warning",message:"scenarios: invalid value(s) '"+JSON.stringify(e)+"' are not supported."}):this.errors.remove(i)}validateVariances(t){const i="ERR_variances";if(A(t))return void this.errors.remove(i);const e=l(t);e.length>0?this.errors.addOrReplace({id:i,type:"warning",message:"variances: invalid value(s) '"+JSON.stringify(e)+"' are not supported."}):this.errors.remove(i)}validateUnitScaling(t){const i="ERR_unitScaling";c(t)||this.pixelPerUnitGroupMap.has(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"unitScaling: invalid value(s) '"+t+"' are not supported."})}validatePercentageScaling(t){const i="ERR_percentageScaling";c(t)||this.pixelPerUnitGroupMap.has(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"percentageScaling: invalid value(s) '"+t+"' are not supported."})}validateLevel(t){const i="ERR_level";h(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"level: invalid value(s) '"+t+"' are not supported."})}validateOrderList(t){const i="ERR_order";if(A(t))return void this.errors.remove(i);const e=d(t);e.length>0?this.errors.addOrReplace({id:i,type:"warning",message:"order: invalid value(s) '"+JSON.stringify(e)+"' are not supported."}):this.errors.remove(i)}validateOrderDirection(t){const i="ERR_orderDirection";A(t)||p(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"orderDirection: invalid value '"+(null==t?void 0:""+t)+"' is not supported."})}validateLimit(t){const i="ERR_limit";u(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"limit: invalid value '"+(null==t?void 0:""+t)+"' is not supported."})}validateShowCategories(t){const i="ERR_showCategories";v(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"showCategories: invalid value(s) '"+(null==t?void 0:""+t)+"' are not supported."})}validateMeasureScale(t){const i="ERR_measureScale";m(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"measureScale: invalid value '"+(null==t?void 0:""+t)+"' is not supported."})}validateShowMeasureScale(t){const i="ERR_grouped";v(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"showMeasureScale: invalid value(s) '"+(null==t?void 0:""+t)+"' are not supported."})}validateStack(t){const i="ERR_stack",e=g(t);e.length>0?this.errors.addOrReplace({id:i,type:"warning",message:e.join("; ")}):this.errors.remove(i)}validateScaling(t){if(null==t||""===t||"none"===t||"auto"===t)return void this.errors.remove("ERR_scale");const i=Number(t);isNaN(i)||i<=0?this.errors.addOrReplace({id:"ERR_scale",type:"warning",message:`Invalid scale value: "${t}". Use "none", "auto", or a positive number.`}):this.errors.remove("ERR_scale")}constructor(t){super(),!1!==t&&this.__registerHost(),this.__attachShadow(),this.data=[],this.datasetMeta=null,this.appliedScaleFactor=1,this.chartTitle="",this.filter="",this.limit=0,this.showCategories="true",this.measureScale="greatest",this.showMeasureScale="false",this.measureUnit="",this.stack="",this.scenariosArray=[""],this.pixelPerUnitGroupMap=new Map,this._autoScaleGuard=!1,x(this),w(this),y(this,((t,i)=>{this.data=i||[]}),((t,i)=>{this.datasetMeta=i})),this.chartTemplate=this.chartTemplate.bind(this),this.errors=O(this),this.componentStyle=R(this),this.t=k(this).t,this.resolveInherited=T(this,[{propName:"scenarios",ancestorAttr:"title-scenarios"},{propName:"variances",ancestorAttr:"title-variances"},{propName:"order",ancestorAttr:"title-order"},{propName:"orderDirection",ancestorAttr:"title-order-direction"}])}componentWillLoad(){this.validateScenario(this.scenarios),this.validateVariances(this.variances),this.validateUnitScaling(this.unitScaling),this.validateLevel(this.level),this.validateOrderDirection(this.orderDirection),this.validateOrderList(this.order),this.validateShowCategories(this.showCategories),this.validateMeasureScale(this.measureScale),this.validateShowMeasureScale(this.showMeasureScale),this.validateStack(this.stack),this.validateScaling(this.scale)}componentDidRender(){var t,i;const{mode:s}=S(this.scale);if("auto"!==s&&"empty"!==s)return this._autoScaleGuard=!1,void this.checkWidthOverflow();if(this._autoScaleGuard)return this._autoScaleGuard=!1,void this.checkWidthOverflow();const a=this.element,{height:r}=b(a);if(r<=0)return void this.checkWidthOverflow();const n=this.componentStyle((t=>{var i;return(null===(i=t.global)||void 0===i?void 0:i.fontSizePx)||13.3333}));a.style.setProperty("--bn-font-size",n+"px");const o=null===(t=a.shadowRoot)||void 0===t?void 0:t.querySelector(".container"),l=null!==(i=null==o?void 0:o.scrollHeight)&&void 0!==i?i:a.scrollHeight;if(l<=r+1)return this.errors.remove("AUTO_scale"),1!==this.appliedScaleFactor&&(this._autoScaleGuard=!0,e((()=>{this.appliedScaleFactor=1}))),void this.checkWidthOverflow();const c=(r-1)/l;a.style.setProperty("--bn-font-size",n*c+"px"),"empty"===s?this.errors.addOrReplace({id:"AUTO_scale",type:"warning",message:"Auto-scaled chart by factor "+c.toFixed(3)}):this.errors.remove("AUTO_scale"),Math.abs(c-this.appliedScaleFactor)>.001&&(this._autoScaleGuard=!0,e((()=>{this.appliedScaleFactor=c}))),this.checkWidthOverflow()}componentDidLoad(){if(this.canvasWidthSegmented<=0){const{width:t}=b(this.element);t>0&&s(this)}}checkWidthOverflow(){var t;const i="WARN_overflow",e=((null!==(t=this.unitScaling)&&void 0!==t?t:"")+"").trim().toLowerCase();if(""===e||"auto"===e)return void this.errors.remove(i);const s=b(this.element);s.width>0&&this.element.scrollWidth>s.width+1?this.errors.addOrReplace({id:i,type:"error",message:`Chart exceeds available width (${this.element.scrollWidth}px > ${Math.round(s.width)}px). Reduce unit-scaling or set to "auto".`}):this.errors.remove(i)}prepareDimension(){const t=b(this.element);return this.canvasWidthSegmented=t.width/this.scenariosArray.length,{width:this.canvasWidthSegmented,height:t.height}}prepareScenarios(){var t,i,e,s;const a=this.resolveInherited("scenarios",this.scenarios);if(void 0!==a)return this.errors.remove("AUTO_scenarios"),a.split(",").map((t=>t.trim()));const r="auto"===(null===(t=this.scenarios)||void 0===t?void 0:t.trim().toLowerCase());return f(this.scenarios)||r?(null===(e=null===(i=this.datasetMeta)||void 0===i?void 0:i.availableScenarios)||void 0===e?void 0:e.length)>0?(r?this.errors.remove("AUTO_scenarios"):this.errors.addOrReplace({id:"AUTO_scenarios",type:"warning",message:"scenarios: not set, auto-detected: "+this.datasetMeta.availableScenarios.join(",")}),this.datasetMeta.availableScenarios):[]:(this.errors.remove("AUTO_scenarios"),null===(s=this.scenarios)||void 0===s?void 0:s.split(",").map((t=>t.trim())))}prepareVariances(){var t;const i=this.resolveInherited("variances",this.variances);return void 0!==i?i.split(",").map((t=>t.trim())):f(this.variances)?[]:null===(t=this.variances)||void 0===t?void 0:t.split(",").map((t=>t.trim()))}prepareHideCategories(t){return t>=1||"true"!==this.showCategories}prepareI18n(){const t=_,i=new Map([].map((t=>[t,this.t(".".concat(t))]))),e=new Map(t.map((t=>[t,this.t("global.".concat(t))])));return new Map([...e.entries(),...i.entries()])}preparePixelPerUnit(){var t;if(this.pixelPerUnitGroupMap.has(this.unitScaling))return this.errors.remove("AUTO_unitScaling"),this.pixelPerUnitGroupMap.get(this.unitScaling);if("auto"===(null===(t=this.unitScaling)||void 0===t?void 0:(""+t).trim().toLowerCase()))return this.errors.remove("AUTO_unitScaling"),0;const i=Number(this.unitScaling);return!isNaN(i)&&i>0?(this.errors.remove("AUTO_unitScaling"),i):(this.errors.addOrReplace({id:"AUTO_unitScaling",type:"warning",message:"unit-scaling: not set, auto-calculated to fit available space."}),0)}preparePixelPerPercentage(){return this.pixelPerUnitGroupMap.has(this.percentageScaling)?this.pixelPerUnitGroupMap.get(this.percentageScaling):100*Number(this.percentageScaling)}prepareLevel(){var t,i,e;const s="auto"===(null===(t=this.level)||void 0===t?void 0:t.trim().toLowerCase());return f(this.level)||s?(null===(i=this.datasetMeta)||void 0===i?void 0:i.suggestedLevel)?(s?this.errors.remove("AUTO_level"):this.errors.addOrReplace({id:"AUTO_level",type:"warning",message:"level: not set, auto-detected: "+this.datasetMeta.suggestedLevel}),E[this.datasetMeta.suggestedLevel.toUpperCase()]):void 0:(this.errors.remove("AUTO_level"),E[null===(e=this.level)||void 0===e?void 0:e.toUpperCase()])}prepareOrder(){var t;const i=this.resolveInherited("order",this.order),e=this.resolveInherited("orderDirection",this.orderDirection),s=null!=i?i:this.order,a=null!=e?e:this.orderDirection,r="auto"===(null==s?void 0:s.trim().toLowerCase());let n;return f(s)||r?(null===(t=this.datasetMeta)||void 0===t?void 0:t.suggestedOrder)?(r?this.errors.remove("AUTO_order"):this.errors.addOrReplace({id:"AUTO_order",type:"warning",message:"order: not set, auto-detected: "+this.datasetMeta.suggestedOrder}),n=this.datasetMeta.suggestedOrder):n=s:(this.errors.remove("AUTO_order"),n=s),{hierarchy:null==n?void 0:n.split(",").map((t=>U[null==t?void 0:t.toUpperCase()])),direction:N[null==a?void 0:a.toUpperCase()]}}prepareStyle(){const t=this.getEffectiveScaleFactor();return this.componentStyle((i=>{const e=i.global.fontSizePx*t;return{scaleFactors:{scenarioOffset:i["bn-chart-structure"].scaleFactors.scenarioOffset,scenarioLabelToBar:i["bn-chart-structure"].scaleFactors.scenarioLabelToBar,labelToBar:i["bn-chart-structure"].scaleFactors.labelToBar,labelToAxis:i["bn-chart-structure"].scaleFactors.labelToAxis,needleWidth:i["bn-chart-structure"].scaleFactors.needleWidth,needleHeadWidth:i["bn-chart-structure"].scaleFactors.needleHeadWidth,barWidth:i["bn-chart-structure"].scaleFactors.barWidth,varianceAxisLineWidth:i["bn-chart-structure"].scaleFactors.varianceAxisLineWidth,axisLineWidth:i["bn-chart-structure"].scaleFactors.axisLineWidth,auxiliaryLineWidth:i["bn-chart-structure"].scaleFactors.auxiliaryLineWidth,scenarioLineWidth:i["bn-chart-structure"].scaleFactors.scenarioLineWidth,markerWidth:i["bn-chart-structure"].scaleFactors.markerWidth,markerOffset:i["bn-chart-structure"].scaleFactors.markerOffset,categoryWidth:i["bn-chart-structure"].scaleFactors.categoryWidth,axisTickLength:i["bn-chart-structure"].scaleFactors.axisTickLength},fontStyles:{font:`${e}px ${i.global.fontFamily}`,size:e,color:i.global.fontColor,background:i.global.fontBackgroundColor,leading:1.8},axisStyles:i["bn-chart-structure"].axisStyles,barStyles:i["bn-chart-structure"].barStyles,varianceStyles:i["bn-chart-structure"].varianceStyles,padding:i["bn-chart-structure"].padding,pattern:null}}))}prepareChartTitle(t){return t>=1?"":this.chartTitle}prepareStackConfig(){if(f(this.stack))return this.errors.remove("WARN_stack_dimensions_scenarios"),null;try{const t=JSON.parse(this.stack),i=t.by,e="WARN_stack_dimensions_scenarios";if(i===M.DIMENSIONS){const t=this.prepareScenarios();t.length>1?this.errors.addOrReplace({id:e,type:"warning",message:`stack by dimensions: only the first scenario "${t[0]}" is used, the rest (${t.slice(1).join(", ")}) are discarded.`}):this.errors.remove(e)}else this.errors.remove(e);return{by:i,mode:t.mode||C.ABSOLUTE,order:t.order||L.DATASET}}catch(t){return this.errors.remove("WARN_stack_dimensions_scenarios"),null}}prepareFilter(){return 0===this.filter.length?"":this.filter}prepareLimit(){return Math.floor(Number(this.limit)||0)}getDataStructure(){return{IStructureChartDataRow:{operation:{type:"string",isOptional:!1,description:""},rowGroup:{type:"string",isOptional:!1,description:""},rowGroupIndex:{type:"number",isOptional:!1,description:""},category:{type:"string",isOptional:!1,description:""},categoryIndex:{type:"number",isOptional:!1,description:""},subCategory:{type:"string",isOptional:!1,description:""},subCategoryIndex:{type:"number",isOptional:!1,description:""},columnGroup:{type:"string",isOptional:!1,description:""},columnGroupIndex:{type:"number",isOptional:!1,description:""},columnSubGroup:{type:"string",isOptional:!1,description:""},columnSubGroupIndex:{type:"number",isOptional:!1,description:""},ac1:{type:"number",isOptional:!1,description:""},ac2:{type:"number",isOptional:!1,description:""},ac3:{type:"number",isOptional:!1,description:""},ac4:{type:"number",isOptional:!1,description:""},pp1:{type:"number",isOptional:!1,description:""},pp2:{type:"number",isOptional:!1,description:""},pp3:{type:"number",isOptional:!1,description:""},pp4:{type:"number",isOptional:!1,description:""},fc1:{type:"number",isOptional:!1,description:""},fc2:{type:"number",isOptional:!1,description:""},fc3:{type:"number",isOptional:!1,description:""},fc4:{type:"number",isOptional:!1,description:""},pl1:{type:"number",isOptional:!1,description:""},pl2:{type:"number",isOptional:!1,description:""},pl3:{type:"number",isOptional:!1,description:""},pl4:{type:"number",isOptional:!1,description:""}}}}prepareMeasureScale(){return f(this.measureScale)?"GREATEST":["_","k","M","G","T","P","E","Z","Y","m","μ","n","p","P","f","a","z","y"].includes(this.measureScale.trim())||"LEAST"===this.measureScale.trim().toUpperCase()?this.measureScale.trim():"GREATEST"}prepareShowMeasureScale(t){return 0===t&&"true"===this.showMeasureScale}prepareMeasureUnit(){return""===this.measureUnit||null==this.measureUnit?"":this.measureUnit}chartTemplate(t,i){const e=this.getEffectiveScaleFactor(),s=this.preparePixelPerUnit(),r=this.preparePixelPerPercentage(),n=this.prepareStackConfig(),o=this.prepareScenarios(),l=(null==n?void 0:n.by)===M.DIMENSIONS?o.slice(0,1):o;return a("ibcs-chart-structure",{data:this.data,chartTitle:this.prepareChartTitle(i),scenarios:l,variances:[t],hideCategories:this.prepareHideCategories(i),pixelPerUnit:s>0?s*e:0,pixelPerPercentage:r>0?r*e:0,limit:this.prepareLimit(),styles:this.prepareStyle(),i18n:this.prepareI18n(),order:this.prepareOrder(),level:this.prepareLevel(),filter:this.prepareFilter(),"measure-scale":this.prepareMeasureScale(),"measure-unit":this.prepareMeasureUnit(),showMeasureScale:this.prepareShowMeasureScale(i),stackConfig:n,parentDimensions:this.prepareDimension()})}getEffectiveScaleFactor(){const{mode:t,factor:i}=S(this.scale);return"factor"===t?i:"auto"===t||"empty"===t?this.appliedScaleFactor:1}getFontStyles(){const t=this.getEffectiveScaleFactor();return this.componentStyle((i=>{var e,s,a,r;const n=(null===(e=i.global)||void 0===e?void 0:e.fontSizePx)||13.3333;return{"--bn-font-family":(null===(s=i.global)||void 0===s?void 0:s.fontFamily)||"'Noto Sans', sans-serif","--bn-font-size":n*t+"px","--bn-font-color":(null===(a=i.global)||void 0===a?void 0:a.fontColor)||"#000000","--bn-font-background":(null===(r=i.global)||void 0===r?void 0:r.fontBackgroundColor)||"#ffffff"}}))}render(){let t=[""];const i=this.prepareVariances();i.length>0&&(t=[...t,...i]);const e=this.getFontStyles();return a(r,{key:"9c71155a82140c2020a830247c62d668fb10959e",style:e},a("div",{key:"5d9402429fd36aa3b9615f13a5038bc38d825173",class:"container"},t.map(this.chartTemplate)))}get element(){return this}static get watchers(){return{scenarios:[{validateScenario:0}],variances:[{validateVariances:0}],unitScaling:[{validateUnitScaling:0}],percentageScaling:[{validatePercentageScaling:0}],level:[{validateLevel:0}],order:[{validateOrderList:0}],orderDirection:[{validateOrderDirection:0}],limit:[{validateLimit:0}],showCategories:[{validateShowCategories:0}],measureScale:[{validateMeasureScale:0}],showMeasureScale:[{validateShowMeasureScale:0}],stack:[{validateStack:0}],scale:[{validateScaling:0}]}}static get style(){return':host{display:inline-block;position:relative;overflow:hidden}.container{display:flex;flex-direction:row}.background-image{display:flex;flex-wrap:wrap;justify-content:flex-end}.categories{text-align:right;font-size:var(--bn-font-size, 1em);font-family:var(--bn-font-family, "Noto Sans", "Helvetica Neue", Helvetica, sans-serif);color:var(--bn-font-color, black)}.label-bg{fill:var(--bn-font-background, white);opacity:0.7}.label-text{text-align:right;font-size:var(--bn-font-size, 1em);font-family:var(--bn-font-family, "Noto Sans", "Helvetica Neue", Helvetica, sans-serif);color:var(--bn-font-color, black)}.axis-title{text-align:center;font-family:var(--bn-font-family, "Noto Sans", "Helvetica Neue", Helvetica, sans-serif);color:var(--bn-font-color, black)}.axis-ac{stroke:black;stroke-width:0.1em}.axis-pp{stroke:grey;stroke-width:0.1em}.axis-fc{stroke:black;stroke-dasharray:2;stroke-width:0.1em}.axis-pl{stroke:white;stroke-width:0.1em;outline-offset:0em;outline:0.1em solid black}canvas{image-rendering:-moz-crisp-edges;image-rendering:-webkit-crisp-edges;image-rendering:pixelated;image-rendering:crisp-edges}.measure{font-weight:bold}span{display:inline-block}.hidePatternContainer{height:0;width:0}div{float:left}.warning{font-size:0.8em;font-style:italic}.footer{margin:0.2em;font-size:0.6em}.footer-hide{margin:0.2em;font-size:0.6em;opacity:0}'}},[1,"bn-chart-structure",{chartTitle:[1,"chart-title"],filter:[1],scenarios:[1],variances:[1],unitScaling:[8,"unit-scaling"],percentageScaling:[8,"percentage-scaling"],level:[1],order:[1],orderDirection:[1,"order-direction"],limit:[2],showCategories:[1,"show-categories"],measureScale:[1,"measure-scale"],showMeasureScale:[1,"show-measure-scale"],measureUnit:[1,"measure-unit"],stack:[1],scale:[1],data:[32],datasetMeta:[32],appliedScaleFactor:[32]},void 0,{scenarios:[{validateScenario:0}],variances:[{validateVariances:0}],unitScaling:[{validateUnitScaling:0}],percentageScaling:[{validatePercentageScaling:0}],level:[{validateLevel:0}],order:[{validateOrderList:0}],orderDirection:[{validateOrderDirection:0}],limit:[{validateLimit:0}],showCategories:[{validateShowCategories:0}],measureScale:[{validateMeasureScale:0}],showMeasureScale:[{validateShowMeasureScale:0}],stack:[{validateStack:0}],scale:[{validateScaling:0}]}]),W=P,z=function(){"undefined"!=typeof customElements&&["bn-chart-structure","ibcs-chart-structure"].forEach((t=>{switch(t){case"bn-chart-structure":customElements.get(n(t))||customElements.define(n(t),P);break;case"ibcs-chart-structure":customElements.get(n(t))||D()}}))};export{W as BnChartStructure,z as defineCustomElement}