@bino-bi/bn-template-engine 1.0.0-alpha.6 → 1.0.0-alpha.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bn-template-engine/bn-template-engine.esm.js +1 -1
- package/dist/bn-template-engine/p-9721a5bb.entry.js +1 -0
- package/dist/bn-template-engine/p-9cee22fa.entry.js +1 -0
- package/dist/bn-template-engine/p-Dnkv5rt8.js +1 -0
- package/dist/bn-template-engine/p-f6ecb265.entry.js +1 -0
- package/dist/cjs/bn-asset_16.cjs.entry.js +104 -23
- package/dist/cjs/bn-chart-time.cjs.entry.js +44 -8
- package/dist/cjs/bn-layout-card.cjs.entry.js +32 -1
- package/dist/cjs/withInheritedProps-BH2KNER3.js +157 -0
- package/dist/collection/components/bn-chart-structure/bn-chart-structure.js +46 -10
- package/dist/collection/components/bn-chart-time/bn-chart-time.js +44 -8
- package/dist/collection/components/bn-layout-card/bn-layout-card.js +32 -1
- package/dist/collection/components/bn-table/bn-table.js +59 -13
- package/dist/collection/utils/withInheritedProps.js +152 -0
- package/dist/components/bn-chart-structure.js +1 -1
- package/dist/components/bn-chart-time.js +1 -1
- package/dist/components/bn-layout-card.js +1 -1
- package/dist/components/bn-table.js +1 -1
- package/dist/components/withInheritedProps.js +1 -0
- package/dist/esm/bn-asset_16.entry.js +104 -23
- package/dist/esm/bn-chart-time.entry.js +44 -8
- package/dist/esm/bn-layout-card.entry.js +32 -1
- package/dist/esm/withInheritedProps-BlXDxhHK.js +154 -0
- package/dist/types/components/bn-chart-structure/bn-chart-structure.d.ts +1 -0
- package/dist/types/components/bn-chart-time/bn-chart-time.d.ts +1 -0
- package/dist/types/components/bn-layout-card/bn-layout-card.d.ts +8 -0
- package/dist/types/components/bn-table/bn-table.d.ts +1 -0
- package/dist/types/utils/withInheritedProps.d.ts +38 -0
- package/package.json +1 -1
- package/dist/bn-template-engine/p-06946f44.entry.js +0 -1
- package/dist/bn-template-engine/p-98cf512f.entry.js +0 -1
- package/dist/bn-template-engine/p-e6b24f15.entry.js +0 -1
|
@@ -7,6 +7,7 @@ import { globalLabelKeys } from "../../stores/internationalization";
|
|
|
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 { AggregationLevel, StackBy, StackMode, StackOrder } from "../../utils/constants";
|
|
@@ -23,8 +24,12 @@ import { OrderColumn, OrderDirection } from "../../utils/model/Order";
|
|
|
23
24
|
*/
|
|
24
25
|
export class Chart {
|
|
25
26
|
validateScenario(newValue) {
|
|
26
|
-
const invalidScenarios = validateScenarioList(newValue);
|
|
27
27
|
const errId = "ERR_scenarios";
|
|
28
|
+
if (isInheritedValue(newValue)) {
|
|
29
|
+
this.errors.remove(errId);
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
const invalidScenarios = validateScenarioList(newValue);
|
|
28
33
|
if (invalidScenarios.length > 0) {
|
|
29
34
|
this.errors.addOrReplace({
|
|
30
35
|
id: errId,
|
|
@@ -38,6 +43,10 @@ export class Chart {
|
|
|
38
43
|
}
|
|
39
44
|
validateVariances(newValue) {
|
|
40
45
|
const errIdVar = "ERR_variances";
|
|
46
|
+
if (isInheritedValue(newValue)) {
|
|
47
|
+
this.errors.remove(errIdVar);
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
41
50
|
const invalidVariances = validateVariancesList(newValue);
|
|
42
51
|
if (invalidVariances.length > 0) {
|
|
43
52
|
this.errors.addOrReplace({
|
|
@@ -90,8 +99,12 @@ export class Chart {
|
|
|
90
99
|
}
|
|
91
100
|
}
|
|
92
101
|
validateOrderList(newValue) {
|
|
93
|
-
const invalidElements = validateOrderList(newValue);
|
|
94
102
|
const errId = "ERR_order";
|
|
103
|
+
if (isInheritedValue(newValue)) {
|
|
104
|
+
this.errors.remove(errId);
|
|
105
|
+
return;
|
|
106
|
+
}
|
|
107
|
+
const invalidElements = validateOrderList(newValue);
|
|
95
108
|
if (invalidElements.length > 0) {
|
|
96
109
|
this.errors.addOrReplace({
|
|
97
110
|
id: errId,
|
|
@@ -105,6 +118,10 @@ export class Chart {
|
|
|
105
118
|
}
|
|
106
119
|
validateOrderDirection(newValue) {
|
|
107
120
|
const errId = "ERR_orderDirection";
|
|
121
|
+
if (isInheritedValue(newValue)) {
|
|
122
|
+
this.errors.remove(errId);
|
|
123
|
+
return;
|
|
124
|
+
}
|
|
108
125
|
if (!isValidDirection(newValue)) {
|
|
109
126
|
this.errors.addOrReplace({
|
|
110
127
|
id: errId,
|
|
@@ -310,6 +327,12 @@ export class Chart {
|
|
|
310
327
|
this.errors = withHasError(this);
|
|
311
328
|
this.componentStyle = withComponentStyle(this);
|
|
312
329
|
this.t = withTranslation(this).t;
|
|
330
|
+
this.resolveInherited = withInheritedProps(this, [
|
|
331
|
+
{ propName: "scenarios", ancestorAttr: "title-scenarios" },
|
|
332
|
+
{ propName: "variances", ancestorAttr: "title-variances" },
|
|
333
|
+
{ propName: "order", ancestorAttr: "title-order" },
|
|
334
|
+
{ propName: "orderDirection", ancestorAttr: "title-order-direction" },
|
|
335
|
+
]);
|
|
313
336
|
}
|
|
314
337
|
componentWillLoad() {
|
|
315
338
|
this.validateScenario(this.scenarios);
|
|
@@ -410,6 +433,11 @@ export class Chart {
|
|
|
410
433
|
}
|
|
411
434
|
prepareScenarios() {
|
|
412
435
|
var _a, _b, _c, _d;
|
|
436
|
+
const inherited = this.resolveInherited("scenarios", this.scenarios);
|
|
437
|
+
if (inherited !== undefined) {
|
|
438
|
+
this.errors.remove("AUTO_scenarios");
|
|
439
|
+
return inherited.split(",").map((entry) => entry.trim());
|
|
440
|
+
}
|
|
413
441
|
const isAuto = ((_a = this.scenarios) === null || _a === void 0 ? void 0 : _a.trim().toLowerCase()) === "auto";
|
|
414
442
|
if (isBlankInput(this.scenarios) || isAuto) {
|
|
415
443
|
if (((_c = (_b = this.datasetMeta) === null || _b === void 0 ? void 0 : _b.availableScenarios) === null || _c === void 0 ? void 0 : _c.length) > 0) {
|
|
@@ -432,6 +460,10 @@ export class Chart {
|
|
|
432
460
|
}
|
|
433
461
|
prepareVariances() {
|
|
434
462
|
var _a;
|
|
463
|
+
const inherited = this.resolveInherited("variances", this.variances);
|
|
464
|
+
if (inherited !== undefined) {
|
|
465
|
+
return inherited.split(",").map((entry) => entry.trim());
|
|
466
|
+
}
|
|
435
467
|
if (isBlankInput(this.variances)) {
|
|
436
468
|
return [];
|
|
437
469
|
}
|
|
@@ -500,11 +532,15 @@ export class Chart {
|
|
|
500
532
|
return AggregationLevel[(_c = this.level) === null || _c === void 0 ? void 0 : _c.toUpperCase()];
|
|
501
533
|
}
|
|
502
534
|
prepareOrder() {
|
|
503
|
-
var _a
|
|
504
|
-
const
|
|
535
|
+
var _a;
|
|
536
|
+
const inheritedOrder = this.resolveInherited("order", this.order);
|
|
537
|
+
const inheritedDirection = this.resolveInherited("orderDirection", this.orderDirection);
|
|
538
|
+
const effectiveOrder = inheritedOrder !== null && inheritedOrder !== void 0 ? inheritedOrder : this.order;
|
|
539
|
+
const effectiveDirection = inheritedDirection !== null && inheritedDirection !== void 0 ? inheritedDirection : this.orderDirection;
|
|
540
|
+
const isAuto = (effectiveOrder === null || effectiveOrder === void 0 ? void 0 : effectiveOrder.trim().toLowerCase()) === "auto";
|
|
505
541
|
let orderStr;
|
|
506
|
-
if (isBlankInput(
|
|
507
|
-
if ((
|
|
542
|
+
if (isBlankInput(effectiveOrder) || isAuto) {
|
|
543
|
+
if ((_a = this.datasetMeta) === null || _a === void 0 ? void 0 : _a.suggestedOrder) {
|
|
508
544
|
if (!isAuto) {
|
|
509
545
|
this.errors.addOrReplace({
|
|
510
546
|
id: "AUTO_order",
|
|
@@ -518,16 +554,16 @@ export class Chart {
|
|
|
518
554
|
orderStr = this.datasetMeta.suggestedOrder;
|
|
519
555
|
}
|
|
520
556
|
else {
|
|
521
|
-
orderStr =
|
|
557
|
+
orderStr = effectiveOrder;
|
|
522
558
|
}
|
|
523
559
|
}
|
|
524
560
|
else {
|
|
525
561
|
this.errors.remove("AUTO_order");
|
|
526
|
-
orderStr =
|
|
562
|
+
orderStr = effectiveOrder;
|
|
527
563
|
}
|
|
528
564
|
const tableOrder = {
|
|
529
565
|
hierarchy: orderStr === null || orderStr === void 0 ? void 0 : orderStr.split(",").map((entry) => OrderColumn[entry === null || entry === void 0 ? void 0 : entry.toUpperCase()]),
|
|
530
|
-
direction: OrderDirection[
|
|
566
|
+
direction: OrderDirection[effectiveDirection === null || effectiveDirection === void 0 ? void 0 : effectiveDirection.toUpperCase()],
|
|
531
567
|
};
|
|
532
568
|
return tableOrder;
|
|
533
569
|
}
|
|
@@ -715,7 +751,7 @@ export class Chart {
|
|
|
715
751
|
scenariosArray = [...scenariosArray, ...variancesArray];
|
|
716
752
|
}
|
|
717
753
|
const fontStyles = this.getFontStyles();
|
|
718
|
-
return (h(Host, { key: '
|
|
754
|
+
return (h(Host, { key: '528b1d9607de916cb2ed06a2f2bac2acdc85da30', style: fontStyles }, h("div", { key: 'e5454756d03fc081e843dee241c52695212da4e3', class: "container" }, scenariosArray.map(this.chartTemplate))));
|
|
719
755
|
}
|
|
720
756
|
static get is() { return "bn-chart-structure"; }
|
|
721
757
|
static get encapsulation() { return "shadow"; }
|
|
@@ -7,6 +7,7 @@ import { globalLabelKeys } from "../../stores/internationalization";
|
|
|
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 { OrderColumn, OrderDirection } from "../../utils/model/Order";
|
|
@@ -34,8 +35,12 @@ var AggregationLevel;
|
|
|
34
35
|
*/
|
|
35
36
|
export class Chart {
|
|
36
37
|
validateScenario(newValue) {
|
|
37
|
-
const invalidScenarios = validateScenarioList(newValue);
|
|
38
38
|
const errId = "ERR_scenarios";
|
|
39
|
+
if (isInheritedValue(newValue)) {
|
|
40
|
+
this.errors.remove(errId);
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
const invalidScenarios = validateScenarioList(newValue);
|
|
39
44
|
if (invalidScenarios.length > 0) {
|
|
40
45
|
this.errors.addOrReplace({
|
|
41
46
|
id: errId,
|
|
@@ -49,6 +54,10 @@ export class Chart {
|
|
|
49
54
|
}
|
|
50
55
|
validateVariances(newValue) {
|
|
51
56
|
const errIdVar = "ERR_variances";
|
|
57
|
+
if (isInheritedValue(newValue)) {
|
|
58
|
+
this.errors.remove(errIdVar);
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
52
61
|
const invalidVariances = validateVariancesList(newValue);
|
|
53
62
|
if (invalidVariances.length > 0) {
|
|
54
63
|
this.errors.addOrReplace({
|
|
@@ -128,6 +137,10 @@ export class Chart {
|
|
|
128
137
|
}
|
|
129
138
|
validateOrderList(newValue) {
|
|
130
139
|
const errId = "ERR_order";
|
|
140
|
+
if (isInheritedValue(newValue)) {
|
|
141
|
+
this.errors.remove(errId);
|
|
142
|
+
return;
|
|
143
|
+
}
|
|
131
144
|
const invalidElements = validateOrderList(newValue);
|
|
132
145
|
if (invalidElements.length > 0) {
|
|
133
146
|
this.errors.addOrReplace({
|
|
@@ -142,6 +155,10 @@ export class Chart {
|
|
|
142
155
|
}
|
|
143
156
|
validateOrderDirection(newValue) {
|
|
144
157
|
const errId = "ERR_orderDirection";
|
|
158
|
+
if (isInheritedValue(newValue)) {
|
|
159
|
+
this.errors.remove(errId);
|
|
160
|
+
return;
|
|
161
|
+
}
|
|
145
162
|
if (!isValidDirection(newValue)) {
|
|
146
163
|
this.errors.addOrReplace({
|
|
147
164
|
id: errId,
|
|
@@ -468,6 +485,12 @@ export class Chart {
|
|
|
468
485
|
this.errors = withHasError(this);
|
|
469
486
|
this.componentStyle = withComponentStyle(this);
|
|
470
487
|
this.t = withTranslation(this).t;
|
|
488
|
+
this.resolveInherited = withInheritedProps(this, [
|
|
489
|
+
{ propName: "scenarios", ancestorAttr: "title-scenarios" },
|
|
490
|
+
{ propName: "variances", ancestorAttr: "title-variances" },
|
|
491
|
+
{ propName: "order", ancestorAttr: "title-order" },
|
|
492
|
+
{ propName: "orderDirection", ancestorAttr: "title-order-direction" },
|
|
493
|
+
]);
|
|
471
494
|
}
|
|
472
495
|
componentWillLoad() {
|
|
473
496
|
this.validateScenario(this.scenarios);
|
|
@@ -560,6 +583,11 @@ export class Chart {
|
|
|
560
583
|
}
|
|
561
584
|
prepareScenarios() {
|
|
562
585
|
var _a, _b, _c, _d;
|
|
586
|
+
const inherited = this.resolveInherited("scenarios", this.scenarios);
|
|
587
|
+
if (inherited !== undefined) {
|
|
588
|
+
this.errors.remove("AUTO_scenarios");
|
|
589
|
+
return inherited.split(",").map((entry) => entry.trim());
|
|
590
|
+
}
|
|
563
591
|
const isAuto = ((_a = this.scenarios) === null || _a === void 0 ? void 0 : _a.trim().toLowerCase()) === "auto";
|
|
564
592
|
if (isBlankInput(this.scenarios) || isAuto) {
|
|
565
593
|
if (((_c = (_b = this.datasetMeta) === null || _b === void 0 ? void 0 : _b.availableScenarios) === null || _c === void 0 ? void 0 : _c.length) > 0) {
|
|
@@ -588,6 +616,10 @@ export class Chart {
|
|
|
588
616
|
}
|
|
589
617
|
prepareVariances() {
|
|
590
618
|
var _a;
|
|
619
|
+
const inherited = this.resolveInherited("variances", this.variances);
|
|
620
|
+
if (inherited !== undefined) {
|
|
621
|
+
return inherited.split(",").map((entry) => entry.trim());
|
|
622
|
+
}
|
|
591
623
|
if (isBlankInput(this.variances)) {
|
|
592
624
|
return [];
|
|
593
625
|
}
|
|
@@ -656,12 +688,16 @@ export class Chart {
|
|
|
656
688
|
return AggregationLevel[(_c = this.level) === null || _c === void 0 ? void 0 : _c.toUpperCase()];
|
|
657
689
|
}
|
|
658
690
|
prepareOrder() {
|
|
659
|
-
var _a, _b, _c
|
|
691
|
+
var _a, _b, _c;
|
|
692
|
+
const inheritedOrder = this.resolveInherited("order", this.order);
|
|
693
|
+
const inheritedDirection = this.resolveInherited("orderDirection", this.orderDirection);
|
|
694
|
+
const effectiveOrder = inheritedOrder !== null && inheritedOrder !== void 0 ? inheritedOrder : this.order;
|
|
695
|
+
const effectiveDirection = inheritedDirection !== null && inheritedDirection !== void 0 ? inheritedDirection : this.orderDirection;
|
|
660
696
|
const isLevelAuto = isBlankInput(this.level) || ((_a = this.level) === null || _a === void 0 ? void 0 : _a.trim().toLowerCase()) === "auto";
|
|
661
697
|
let entryValue = isLevelAuto && ((_b = this.datasetMeta) === null || _b === void 0 ? void 0 : _b.suggestedLevel) ? this.datasetMeta.suggestedLevel : this.level;
|
|
662
|
-
const isOrderAuto = (
|
|
663
|
-
if (isBlankInput(
|
|
664
|
-
if ((
|
|
698
|
+
const isOrderAuto = (effectiveOrder === null || effectiveOrder === void 0 ? void 0 : effectiveOrder.trim().toLowerCase()) === "auto";
|
|
699
|
+
if (isBlankInput(effectiveOrder) || isOrderAuto) {
|
|
700
|
+
if ((_c = this.datasetMeta) === null || _c === void 0 ? void 0 : _c.suggestedLevel) {
|
|
665
701
|
if (!isOrderAuto) {
|
|
666
702
|
this.errors.addOrReplace({
|
|
667
703
|
id: "AUTO_order",
|
|
@@ -676,13 +712,13 @@ export class Chart {
|
|
|
676
712
|
}
|
|
677
713
|
else {
|
|
678
714
|
this.errors.remove("AUTO_order");
|
|
679
|
-
if ((
|
|
715
|
+
if ((effectiveOrder === null || effectiveOrder === void 0 ? void 0 : effectiveOrder.toLocaleLowerCase()) === "levelindex") {
|
|
680
716
|
entryValue += "Index";
|
|
681
717
|
}
|
|
682
718
|
}
|
|
683
719
|
const tableOrder = {
|
|
684
720
|
hierarchy: [OrderColumn[entryValue === null || entryValue === void 0 ? void 0 : entryValue.toUpperCase()]],
|
|
685
|
-
direction: OrderDirection[
|
|
721
|
+
direction: OrderDirection[effectiveDirection === null || effectiveDirection === void 0 ? void 0 : effectiveDirection.toUpperCase()],
|
|
686
722
|
};
|
|
687
723
|
return tableOrder;
|
|
688
724
|
}
|
|
@@ -931,7 +967,7 @@ export class Chart {
|
|
|
931
967
|
scenariosArray = [...scenariosArray, ...variancesArray];
|
|
932
968
|
}
|
|
933
969
|
const fontStyles = this.getFontStyles();
|
|
934
|
-
return (h(Host, { key: '
|
|
970
|
+
return (h(Host, { key: 'd0625657fc6ddbacf7ad5c4cede189cc321109e1', style: fontStyles }, h("div", { key: '393a0c8b00028b3edd08d6e199ffe55014251a5d', class: "container" }, scenariosArray.map(this.chartTemplate))));
|
|
935
971
|
}
|
|
936
972
|
static get is() { return "bn-chart-time"; }
|
|
937
973
|
static get encapsulation() { return "shadow"; }
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { h, Fragment } from "@stencil/core";
|
|
2
2
|
import { getStores } from "../../context/context-protocol";
|
|
3
3
|
import withHasError from "../../utils/withHasError";
|
|
4
|
+
import withInheritedProps from "../../utils/withInheritedProps";
|
|
4
5
|
export class LayoutCard {
|
|
5
6
|
constructor() {
|
|
6
7
|
/**
|
|
@@ -124,9 +125,18 @@ export class LayoutCard {
|
|
|
124
125
|
["gold4", '"a b c c" "d d c c"'],
|
|
125
126
|
]);
|
|
126
127
|
this.errors = withHasError(this);
|
|
128
|
+
this.resolveInherited = withInheritedProps(this, [
|
|
129
|
+
{ propName: "titleScenarios", ancestorAttr: "title-scenarios" },
|
|
130
|
+
{ propName: "titleVariances", ancestorAttr: "title-variances" },
|
|
131
|
+
{ propName: "titleOrder", ancestorAttr: "title-order" },
|
|
132
|
+
{ propName: "titleOrderDirection", ancestorAttr: "title-order-direction" },
|
|
133
|
+
]);
|
|
127
134
|
}
|
|
128
135
|
connectedCallback() {
|
|
129
136
|
this.stores = getStores(this.element);
|
|
137
|
+
// Reflect resolved inherited values to host attributes so child vis
|
|
138
|
+
// components can read them during their own DOM traversal.
|
|
139
|
+
this.reflectInheritedAttrs();
|
|
130
140
|
}
|
|
131
141
|
getCommonStyles() {
|
|
132
142
|
let height = "100%";
|
|
@@ -217,6 +227,26 @@ export class LayoutCard {
|
|
|
217
227
|
}
|
|
218
228
|
return "card_box";
|
|
219
229
|
}
|
|
230
|
+
/**
|
|
231
|
+
* When the card itself inherits a title prop from a page, write the
|
|
232
|
+
* resolved value back to the host element's attribute so that child
|
|
233
|
+
* vis components (bn-table, bn-chart-*) performing their own DOM walk
|
|
234
|
+
* read the actual value instead of the literal "inherited-page" keyword.
|
|
235
|
+
*/
|
|
236
|
+
reflectInheritedAttrs() {
|
|
237
|
+
const mappings = [
|
|
238
|
+
{ prop: "titleScenarios", attr: "title-scenarios" },
|
|
239
|
+
{ prop: "titleVariances", attr: "title-variances" },
|
|
240
|
+
{ prop: "titleOrder", attr: "title-order" },
|
|
241
|
+
{ prop: "titleOrderDirection", attr: "title-order-direction" },
|
|
242
|
+
];
|
|
243
|
+
for (const { prop, attr } of mappings) {
|
|
244
|
+
const resolved = this.resolveInherited(prop, this[prop]);
|
|
245
|
+
if (resolved !== undefined) {
|
|
246
|
+
this.element.setAttribute(attr, resolved);
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
}
|
|
220
250
|
prepareTitleImage(value) {
|
|
221
251
|
if (value == null || value === "") {
|
|
222
252
|
return "";
|
|
@@ -229,11 +259,12 @@ export class LayoutCard {
|
|
|
229
259
|
return assetsState[value] || value;
|
|
230
260
|
}
|
|
231
261
|
render() {
|
|
262
|
+
var _a, _b, _c, _d;
|
|
232
263
|
const style = this.getLayoutStyle();
|
|
233
264
|
const arrOfSlots = this.extractSlotNames(style["grid-template-areas"]);
|
|
234
265
|
return (
|
|
235
266
|
// @ts-ignore
|
|
236
|
-
h("bn-card", { key: '
|
|
267
|
+
h("bn-card", { key: '1dfcca605e2780bdfbb0108a5f34ff1259ecd666', styles: this.styles, class: this.setCardClass() }, h("div", { key: '7bdf2d4d7ddc82af78fe932a2af866b3b17d8b4d', class: "cardtitle" }, h("bn-title", { key: '799fa36d7368bbc2bc446f01fa3a46c8e363dcd0', 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: '9743d34c350907dfe0561444cd548d5884224f3a' }, h("div", { key: 'a622ae652dfefaac4a86d1f71a05fe776a811430', style: style }, this.getSlots(arrOfSlots))), h("bn-footer", { key: 'ebffcd673c94d7666fe6b46216792784f3dfb988', text: this.footerText, "page-number": 0, "display-page-number": "false" })));
|
|
237
268
|
}
|
|
238
269
|
static get is() { return "bn-layout-card"; }
|
|
239
270
|
static get encapsulation() { return "shadow"; }
|
|
@@ -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({
|
|
@@ -461,6 +476,10 @@ export class Table {
|
|
|
461
476
|
}
|
|
462
477
|
validateOrderList(newValue) {
|
|
463
478
|
const errId = "ERR_order";
|
|
479
|
+
if (isInheritedValue(newValue)) {
|
|
480
|
+
this.errors.remove(errId);
|
|
481
|
+
return;
|
|
482
|
+
}
|
|
464
483
|
const invalidElements = validateOrderList(newValue);
|
|
465
484
|
if (invalidElements.length > 0) {
|
|
466
485
|
this.errors.addOrReplace({
|
|
@@ -475,6 +494,10 @@ export class Table {
|
|
|
475
494
|
}
|
|
476
495
|
validateOrderDirection(newValue) {
|
|
477
496
|
const errId = "ERR_orderDirection";
|
|
497
|
+
if (isInheritedValue(newValue)) {
|
|
498
|
+
this.errors.remove(errId);
|
|
499
|
+
return;
|
|
500
|
+
}
|
|
478
501
|
if (!isValidDirection(newValue)) {
|
|
479
502
|
this.errors.addOrReplace({
|
|
480
503
|
id: errId,
|
|
@@ -682,15 +705,19 @@ export class Table {
|
|
|
682
705
|
return JSON.parse(this.partof);
|
|
683
706
|
}
|
|
684
707
|
prepareOrder() {
|
|
685
|
-
var _a
|
|
686
|
-
const
|
|
687
|
-
|
|
688
|
-
|
|
708
|
+
var _a;
|
|
709
|
+
const inheritedOrder = this.resolveInherited("order", this.order);
|
|
710
|
+
const inheritedDirection = this.resolveInherited("orderDirection", this.orderDirection);
|
|
711
|
+
const effectiveOrder = inheritedOrder !== null && inheritedOrder !== void 0 ? inheritedOrder : this.order;
|
|
712
|
+
const effectiveDirection = inheritedDirection !== null && inheritedDirection !== void 0 ? inheritedDirection : this.orderDirection;
|
|
713
|
+
const isAuto = (effectiveOrder === null || effectiveOrder === void 0 ? void 0 : effectiveOrder.trim().toLowerCase()) === "auto";
|
|
714
|
+
let orderStr = effectiveOrder;
|
|
715
|
+
if (isAuto && ((_a = this.datasetMeta) === null || _a === void 0 ? void 0 : _a.suggestedOrder)) {
|
|
689
716
|
orderStr = this.datasetMeta.suggestedOrder;
|
|
690
717
|
}
|
|
691
718
|
const tableOrder = {
|
|
692
719
|
hierarchy: orderStr.split(",").map((entry) => OrderColumn[entry === null || entry === void 0 ? void 0 : entry.toUpperCase()]),
|
|
693
|
-
direction: OrderDirection[
|
|
720
|
+
direction: OrderDirection[effectiveDirection === null || effectiveDirection === void 0 ? void 0 : effectiveDirection.toUpperCase()],
|
|
694
721
|
};
|
|
695
722
|
return tableOrder;
|
|
696
723
|
}
|
|
@@ -713,10 +740,29 @@ export class Table {
|
|
|
713
740
|
return formatDigits;
|
|
714
741
|
}
|
|
715
742
|
prepareScenarios() {
|
|
716
|
-
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
717
|
-
const
|
|
743
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
744
|
+
const inheritedScenarios = this.resolveInherited("scenarios", this.scenarios);
|
|
745
|
+
const inheritedVariances = this.resolveInherited("variances", this.variances);
|
|
746
|
+
if (inheritedScenarios !== undefined || inheritedVariances !== undefined) {
|
|
747
|
+
this.errors.remove("AUTO_scenarios");
|
|
748
|
+
let scenarios = [];
|
|
749
|
+
if (inheritedScenarios !== undefined) {
|
|
750
|
+
scenarios = scenarios.concat(inheritedScenarios.split(","));
|
|
751
|
+
}
|
|
752
|
+
else if (!isBlankInput(this.scenarios)) {
|
|
753
|
+
scenarios = scenarios.concat(this.scenarios.split(","));
|
|
754
|
+
}
|
|
755
|
+
if (inheritedVariances !== undefined) {
|
|
756
|
+
scenarios = scenarios.concat(inheritedVariances.split(","));
|
|
757
|
+
}
|
|
758
|
+
else if (((_a = this.variances) === null || _a === void 0 ? void 0 : _a.trim().length) > 0) {
|
|
759
|
+
scenarios = scenarios.concat(this.variances.split(","));
|
|
760
|
+
}
|
|
761
|
+
return scenarios.map((entry) => entry.trim());
|
|
762
|
+
}
|
|
763
|
+
const isAuto = ((_b = this.scenarios) === null || _b === void 0 ? void 0 : _b.trim().toLowerCase()) === "auto";
|
|
718
764
|
if ((isBlankInput(this.scenarios) || isAuto) && isBlankInput(this.variances)) {
|
|
719
|
-
if (((
|
|
765
|
+
if (((_d = (_c = this.datasetMeta) === null || _c === void 0 ? void 0 : _c.availableScenarios) === null || _d === void 0 ? void 0 : _d.length) > 0) {
|
|
720
766
|
if (!isAuto) {
|
|
721
767
|
this.errors.addOrReplace({
|
|
722
768
|
id: "AUTO_scenarios",
|
|
@@ -733,7 +779,7 @@ export class Table {
|
|
|
733
779
|
}
|
|
734
780
|
let scenarios = [];
|
|
735
781
|
if (isAuto || isBlankInput(this.scenarios)) {
|
|
736
|
-
if (((
|
|
782
|
+
if (((_f = (_e = this.datasetMeta) === null || _e === void 0 ? void 0 : _e.availableScenarios) === null || _f === void 0 ? void 0 : _f.length) > 0) {
|
|
737
783
|
if (!isAuto) {
|
|
738
784
|
this.errors.addOrReplace({
|
|
739
785
|
id: "AUTO_scenarios",
|
|
@@ -749,10 +795,10 @@ export class Table {
|
|
|
749
795
|
}
|
|
750
796
|
else {
|
|
751
797
|
this.errors.remove("AUTO_scenarios");
|
|
752
|
-
scenarios = scenarios.concat((
|
|
798
|
+
scenarios = scenarios.concat((_g = this.scenarios) === null || _g === void 0 ? void 0 : _g.split(","));
|
|
753
799
|
}
|
|
754
|
-
if (((
|
|
755
|
-
scenarios = scenarios.concat((
|
|
800
|
+
if (((_h = this.variances) === null || _h === void 0 ? void 0 : _h.trim().length) > 0) {
|
|
801
|
+
scenarios = scenarios.concat((_j = this.variances) === null || _j === void 0 ? void 0 : _j.split(","));
|
|
756
802
|
}
|
|
757
803
|
return scenarios.map((entry) => entry.trim());
|
|
758
804
|
}
|
|
@@ -905,7 +951,7 @@ export class Table {
|
|
|
905
951
|
render() {
|
|
906
952
|
const fontStyles = this.getFontStyles();
|
|
907
953
|
const effectiveFactor = this.getEffectiveScaleFactor();
|
|
908
|
-
return (h(Host, { key: '
|
|
954
|
+
return (h(Host, { key: '90572dbaa427d46b526c5a04fd04b94882fcb519', style: fontStyles }, h("div", { key: '947d9a31764fd0def10d902901f300c2a526dc55' }, h("ibcs-table", { key: 'ef57aa654318568eb5a8356a5257a0b75bf55e3a', 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
955
|
}
|
|
910
956
|
static get is() { return "bn-table"; }
|
|
911
957
|
static get encapsulation() { return "shadow"; }
|
|
@@ -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;
|