@bino-bi/bn-template-engine 1.0.0-next.52 → 1.0.0-next.53
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-0d8eade3.entry.js +1 -0
- package/dist/cjs/bn-annotation-layer_30.cjs.entry.js +90 -40
- package/dist/cjs/bn-template-engine.cjs.js +1 -1
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/collection/components/bn-chart-structure/bn-chart-structure-renderer/bn-chart-structure-renderer.js +26 -0
- package/dist/collection/components/bn-chart-structure/bn-chart-structure.js +3 -2
- package/dist/collection/components/bn-chart-structure/utils/StructureChart.js +12 -2
- package/dist/collection/components/bn-chart-structure/utils/elements/Bar.js +16 -2
- package/dist/collection/components/bn-chart-structure/utils/elements/Label.js +2 -5
- package/dist/collection/components/bn-chart-structure/utils/helper/ElementPositions.js +5 -0
- package/dist/collection/components/bn-chart-structure/utils/model/StructureChartComponentConfig.js +5 -0
- package/dist/collection/components/bn-context/bn-context.js +45 -30
- package/dist/components/bn-chart-structure-renderer.js +1 -1
- package/dist/components/bn-chart-structure.js +1 -1
- package/dist/components/bn-context.js +1 -1
- package/dist/components/p-9a9XB5Y8.js +1 -0
- package/dist/esm/bn-annotation-layer_30.entry.js +90 -40
- package/dist/esm/bn-template-engine.js +1 -1
- package/dist/esm/loader.js +1 -1
- package/dist/types/components/bn-chart-structure/bn-chart-structure-renderer/bn-chart-structure-renderer.d.ts +2 -0
- package/dist/types/components/bn-chart-structure/utils/StructureChart.d.ts +3 -0
- package/dist/types/components/bn-chart-structure/utils/elements/Bar.d.ts +2 -0
- package/dist/types/components/bn-chart-structure/utils/helper/ElementPositions.d.ts +2 -0
- package/dist/types/components/bn-chart-structure/utils/model/StructureChartComponentConfig.d.ts +2 -0
- package/dist/types/components/bn-context/bn-context.d.ts +4 -4
- package/dist/types/components.d.ts +6 -2
- package/package.json +1 -1
- package/dist/bn-template-engine/p-4d99f1bb.entry.js +0 -1
- package/dist/components/p-iJP2X4dc.js +0 -1
|
@@ -82,6 +82,8 @@ export class BnChartStructureRenderer {
|
|
|
82
82
|
/** @internal */
|
|
83
83
|
this.scenarioLabelTop = false;
|
|
84
84
|
/** @internal */
|
|
85
|
+
this.hideScenarioName = false;
|
|
86
|
+
/** @internal */
|
|
85
87
|
this.referenceLine = null;
|
|
86
88
|
/** @internal */
|
|
87
89
|
this.italicCategories = [];
|
|
@@ -326,6 +328,7 @@ export class BnChartStructureRenderer {
|
|
|
326
328
|
sums: this.sums,
|
|
327
329
|
sumTitle: this.sumTitle,
|
|
328
330
|
scenarioLabelTop: this.scenarioLabelTop,
|
|
331
|
+
hideScenarioName: this.hideScenarioName,
|
|
329
332
|
referenceLine: this.referenceLine,
|
|
330
333
|
italicCategories: this.italicCategories,
|
|
331
334
|
});
|
|
@@ -935,6 +938,29 @@ export class BnChartStructureRenderer {
|
|
|
935
938
|
"attribute": "scenario-label-top",
|
|
936
939
|
"defaultValue": "false"
|
|
937
940
|
},
|
|
941
|
+
"hideScenarioName": {
|
|
942
|
+
"type": "boolean",
|
|
943
|
+
"mutable": false,
|
|
944
|
+
"complexType": {
|
|
945
|
+
"original": "boolean",
|
|
946
|
+
"resolved": "boolean",
|
|
947
|
+
"references": {}
|
|
948
|
+
},
|
|
949
|
+
"required": false,
|
|
950
|
+
"optional": false,
|
|
951
|
+
"docs": {
|
|
952
|
+
"tags": [{
|
|
953
|
+
"name": "internal",
|
|
954
|
+
"text": undefined
|
|
955
|
+
}],
|
|
956
|
+
"text": ""
|
|
957
|
+
},
|
|
958
|
+
"getter": false,
|
|
959
|
+
"setter": false,
|
|
960
|
+
"reflect": false,
|
|
961
|
+
"attribute": "hide-scenario-name",
|
|
962
|
+
"defaultValue": "false"
|
|
963
|
+
},
|
|
938
964
|
"referenceLine": {
|
|
939
965
|
"type": "unknown",
|
|
940
966
|
"mutable": false,
|
|
@@ -968,6 +968,7 @@ export class Chart {
|
|
|
968
968
|
}
|
|
969
969
|
catch (_a) {
|
|
970
970
|
this.errors.remove("WARN_stack_dimensions_scenarios");
|
|
971
|
+
this.errors.remove("WARN_stack_thickness_variances");
|
|
971
972
|
return null;
|
|
972
973
|
}
|
|
973
974
|
}
|
|
@@ -1045,7 +1046,7 @@ export class Chart {
|
|
|
1045
1046
|
const scenarios = this.hidesScenarios() ? variancesScenarios([localScenarioString]) : this.prepareScenarios();
|
|
1046
1047
|
// Dimension stacking uses only the first scenario. Only the base chart draws a stack, a variance needs both of its scenarios
|
|
1047
1048
|
const effectiveScenarios = isBase && (stackConfig === null || stackConfig === void 0 ? void 0 : stackConfig.by) === StackBy.DIMENSIONS ? scenarios.slice(0, 1) : scenarios;
|
|
1048
|
-
return (h("bn-chart-structure-renderer", { tableName: this.datasetName, dataVersion: this.dataVersion, chartTitle: this.prepareChartTitle(idx), scenarios: effectiveScenarios, variances: [localScenarioString], hideCategories: this.prepareHideCategories(idx), pixelPerUnit: ppu, pixelPerPercentage: ppp, reportAutoScaling: this.handleAutoScalingReport, errors: this.errors, 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(idx), stackConfig: stackConfig, sums: ["groups", "total", "all"].includes(this.sums) ? this.sums : "none", sumTitle: this.sumTitle, scenarioLabelTop: this.scenarioLabelPosition === "top", referenceLine: isBase ? this.prepareReferenceLine() : null, italicCategories: (_a = this.prepareItalicCategories()) !== null && _a !== void 0 ? _a : [], dataFormatDigits: { percent: this.dataFormatDigitsPercent, decimal: this.dataFormatDigitsDecimal }, parentDimensions: this.prepareDimension(), ruleSetConfig: this.ruleSetConfig() }));
|
|
1049
|
+
return (h("bn-chart-structure-renderer", { tableName: this.datasetName, dataVersion: this.dataVersion, chartTitle: this.prepareChartTitle(idx), scenarios: effectiveScenarios, variances: [localScenarioString], hideCategories: this.prepareHideCategories(idx), pixelPerUnit: ppu, pixelPerPercentage: ppp, reportAutoScaling: this.handleAutoScalingReport, errors: this.errors, 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(idx), stackConfig: stackConfig, sums: ["groups", "total", "all"].includes(this.sums) ? this.sums : "none", sumTitle: this.sumTitle, scenarioLabelTop: this.scenarioLabelPosition === "top", hideScenarioName: this.hidesScenarios(), referenceLine: isBase ? this.prepareReferenceLine() : null, italicCategories: (_a = this.prepareItalicCategories()) !== null && _a !== void 0 ? _a : [], dataFormatDigits: { percent: this.dataFormatDigitsPercent, decimal: this.dataFormatDigitsDecimal }, parentDimensions: this.prepareDimension(), ruleSetConfig: this.ruleSetConfig() }));
|
|
1049
1050
|
}
|
|
1050
1051
|
/**
|
|
1051
1052
|
* The line this chart wants to be aligned on, in CSS px from the host's
|
|
@@ -1175,7 +1176,7 @@ export class Chart {
|
|
|
1175
1176
|
this.errors.remove("WARN_scenarios_none");
|
|
1176
1177
|
}
|
|
1177
1178
|
const fontStyles = this.getFontStyles();
|
|
1178
|
-
return (h(Host, { key: '
|
|
1179
|
+
return (h(Host, { key: '02236359d67ec2095ac560152cc6feaa8661834a', style: fontStyles }, h("div", { key: '5eb4e74f27fb0c4c5ffd286ee266ceb51eae68bf', class: "container" }, scenariosArray.map(this.chartTemplate))));
|
|
1179
1180
|
}
|
|
1180
1181
|
static get is() { return "bn-chart-structure"; }
|
|
1181
1182
|
static get encapsulation() { return "shadow"; }
|
|
@@ -80,6 +80,7 @@ export class StructureChart {
|
|
|
80
80
|
this.sums = "none";
|
|
81
81
|
this.sumTitle = "";
|
|
82
82
|
this.scenarioLabelTop = false;
|
|
83
|
+
this.hideScenarioName = false;
|
|
83
84
|
this.referenceLine = null;
|
|
84
85
|
this.italicCategories = [];
|
|
85
86
|
this.db = db;
|
|
@@ -122,6 +123,7 @@ export class StructureChart {
|
|
|
122
123
|
this.sums = config.sums;
|
|
123
124
|
this.sumTitle = config.sumTitle;
|
|
124
125
|
this.scenarioLabelTop = config.scenarioLabelTop;
|
|
126
|
+
this.hideScenarioName = config.hideScenarioName;
|
|
125
127
|
this.referenceLine = config.referenceLine;
|
|
126
128
|
this.italicCategories = config.italicCategories;
|
|
127
129
|
this.dataModel = this.populateModel(scenarios, config.level, config.sortOrder);
|
|
@@ -826,7 +828,7 @@ export class StructureChart {
|
|
|
826
828
|
isPositive = !side.flipped;
|
|
827
829
|
clearance = side.clearance * this.pixelPerUnit * (side.flipped ? 1 : -1);
|
|
828
830
|
}
|
|
829
|
-
else if (elements["scenario1"].value < 0) {
|
|
831
|
+
else if (elements["scenario1"].value < 0 && !this.hasSumNumbers(this.dataModel[index])) {
|
|
830
832
|
isPositive = false;
|
|
831
833
|
}
|
|
832
834
|
if (!isPositive) {
|
|
@@ -898,6 +900,10 @@ export class StructureChart {
|
|
|
898
900
|
};
|
|
899
901
|
return points.sort((a, b) => place(a) - place(b));
|
|
900
902
|
}
|
|
903
|
+
/** A sum row of the base chart that prints several numbers right of the axis: its title stays left of it. */
|
|
904
|
+
hasSumNumbers(row) {
|
|
905
|
+
return !!(row === null || row === void 0 ? void 0 : row.sum) && this.variancesDataModel.length === 0 && !this.stackConfig && this.sumPoints(row).length > 1;
|
|
906
|
+
}
|
|
901
907
|
/** How wide the numbers of a sum row of a chart with plain bars are, from the axis on. */
|
|
902
908
|
sumValuesWidth(row) {
|
|
903
909
|
const font = this.styles.fontStyles.size;
|
|
@@ -1365,7 +1371,11 @@ export class StructureChart {
|
|
|
1365
1371
|
const byTotal = ((_a = this.stackConfig) === null || _a === void 0 ? void 0 : _a.thickness) === "total";
|
|
1366
1372
|
// the name of the scenario stands below the last bar: it needs room when a sum row follows
|
|
1367
1373
|
const lastBar = rows.reduce((last, row, index) => (row.sum ? last : index), -1);
|
|
1368
|
-
const nameBelow = !this.stackConfig &&
|
|
1374
|
+
const nameBelow = !this.stackConfig &&
|
|
1375
|
+
!this.scenarioLabelTop &&
|
|
1376
|
+
!this.hideScenarioName &&
|
|
1377
|
+
lastBar >= 0 &&
|
|
1378
|
+
lastBar < rows.length - 1;
|
|
1369
1379
|
if (!byTotal && !nameBelow && !rows.some((row) => row.gapAfter))
|
|
1370
1380
|
return null;
|
|
1371
1381
|
const totals = rows.map((row) => {
|
|
@@ -284,9 +284,19 @@ export class Bar {
|
|
|
284
284
|
}
|
|
285
285
|
drawScenarioLabel() {
|
|
286
286
|
if (this.scenarioLabel != null && !this.scenarioLabel.isEmpty() && !this.isVarianceBar) {
|
|
287
|
-
this.
|
|
287
|
+
let x = this.dimensions.scenarioLabelXPos;
|
|
288
|
+
if (this.nameBesideAxis()) {
|
|
289
|
+
// a short bar would put the name on the axis line, which runs on to the sum row
|
|
290
|
+
const side = this.dataPoint.getScaledUnit() < 0 ? -1 : 1;
|
|
291
|
+
x = this.position.getBarPositionX() + side * this.position.spacings.labelToAxis;
|
|
292
|
+
}
|
|
293
|
+
this.scenarioLabel.setPos(x, this.dimensions.scenarioLabelYPos).draw();
|
|
288
294
|
}
|
|
289
295
|
}
|
|
296
|
+
/** The name of the scenario starts at the axis and is not centred on the bar. */
|
|
297
|
+
nameBesideAxis() {
|
|
298
|
+
return this.isPrimaryBar && this.position.isNameBelowBar();
|
|
299
|
+
}
|
|
290
300
|
drawBarDataLabel(dataFormatDigits, measureScale = new SiPrefix()) {
|
|
291
301
|
var _a;
|
|
292
302
|
if (this.isPrimaryBar) {
|
|
@@ -298,7 +308,11 @@ export class Bar {
|
|
|
298
308
|
}
|
|
299
309
|
getScenarioLabel(barLabel) {
|
|
300
310
|
if (this.isPrimaryBar) {
|
|
301
|
-
|
|
311
|
+
let hook = HookLocation.Center;
|
|
312
|
+
if (this.nameBesideAxis()) {
|
|
313
|
+
hook = this.dataPoint.getScaledUnit() < 0 ? HookLocation.Right : HookLocation.Left;
|
|
314
|
+
}
|
|
315
|
+
return new Label(this.scenarioGroup, -1, -1, this.ID_SCENARIO_PREFIX, barLabel, this.styles, HookLocation.Top, hook);
|
|
302
316
|
}
|
|
303
317
|
return new Label(this.scenarioGroup, -1, -1, this.ID_SCENARIO_PREFIX, barLabel, this.styles, HookLocation.Bottom, HookLocation.Center);
|
|
304
318
|
}
|
|
@@ -94,7 +94,6 @@ export class Label {
|
|
|
94
94
|
let valueStr;
|
|
95
95
|
const background = this.styles.fontStyles.background || "#ffffff";
|
|
96
96
|
let prefix = "";
|
|
97
|
-
let labelAnchor = "start";
|
|
98
97
|
if (Number.isNaN(Number(this.value)) === false) {
|
|
99
98
|
let digits = dataFormatDigits.percent;
|
|
100
99
|
let digitsMin = dataFormatDigits.percent;
|
|
@@ -108,9 +107,6 @@ export class Label {
|
|
|
108
107
|
type = "decimal";
|
|
109
108
|
}
|
|
110
109
|
valueStr = Formatter.number(Number(value), type, digits, digitsMin, scale, this.styles.locale);
|
|
111
|
-
if (Number(this.value) < 0) {
|
|
112
|
-
labelAnchor = "end";
|
|
113
|
-
}
|
|
114
110
|
// a value that rounds to zero prints without a sign
|
|
115
111
|
const zeroStr = Formatter.number(0, type, digits, digitsMin, scale, this.styles.locale);
|
|
116
112
|
if (this.isVarianceLabel && Number(this.value) > 0 && valueStr !== zeroStr) {
|
|
@@ -119,7 +115,6 @@ export class Label {
|
|
|
119
115
|
}
|
|
120
116
|
else {
|
|
121
117
|
valueStr = "" + this.value;
|
|
122
|
-
labelAnchor = "start";
|
|
123
118
|
}
|
|
124
119
|
// @ts-ignore
|
|
125
120
|
const text = label.text(prefix + valueStr);
|
|
@@ -138,6 +133,8 @@ export class Label {
|
|
|
138
133
|
this.group = null;
|
|
139
134
|
return this;
|
|
140
135
|
}
|
|
136
|
+
// the hook says where the text is anchored: at its right, its middle or its left
|
|
137
|
+
let labelAnchor = "start";
|
|
141
138
|
if (this.horizontalHookLocation === HookLocation.Right) {
|
|
142
139
|
labelAnchor = "end";
|
|
143
140
|
text.move(text.x() - text.length(), text.y());
|
|
@@ -62,6 +62,11 @@ export class ElementPositions {
|
|
|
62
62
|
}
|
|
63
63
|
return this.categoryPosition.y + this.spacings.scenarioOffset + index * this.spacings.categoryWidth;
|
|
64
64
|
}
|
|
65
|
+
/** A sum row follows the last bar, so the name of the scenario stands right below that bar. */
|
|
66
|
+
isNameBelowBar() {
|
|
67
|
+
var _a;
|
|
68
|
+
return !!((_a = this.rows) === null || _a === void 0 ? void 0 : _a.nameBelowBar);
|
|
69
|
+
}
|
|
65
70
|
/** Upper edge of the room of a row. */
|
|
66
71
|
getRowTopPositionY(index) {
|
|
67
72
|
const start = this.rows && index < this.rows.start.length ? this.rows.start[index] : index;
|
package/dist/collection/components/bn-chart-structure/utils/model/StructureChartComponentConfig.js
CHANGED
|
@@ -41,6 +41,8 @@ export class StructureChartComponentConfig {
|
|
|
41
41
|
this.sumTitle = "";
|
|
42
42
|
/** The name of the scenario stands above the first bar and not below the last one. */
|
|
43
43
|
this.scenarioLabelTop = false;
|
|
44
|
+
/** No chart draws the name of the scenario: the component shows variances only. */
|
|
45
|
+
this.hideScenarioName = false;
|
|
44
46
|
this.referenceLine = null;
|
|
45
47
|
/** Values of the level column whose row is printed in italics. */
|
|
46
48
|
this.italicCategories = [];
|
|
@@ -117,6 +119,9 @@ export class StructureChartComponentConfigAdapter {
|
|
|
117
119
|
if (CompareUtil.isBoolean(data.scenarioLabelTop)) {
|
|
118
120
|
config.scenarioLabelTop = data.scenarioLabelTop;
|
|
119
121
|
}
|
|
122
|
+
if (CompareUtil.isBoolean(data.hideScenarioName)) {
|
|
123
|
+
config.hideScenarioName = data.hideScenarioName;
|
|
124
|
+
}
|
|
120
125
|
if (CompareUtil.isExisting(data.referenceLine)) {
|
|
121
126
|
config.referenceLine = data.referenceLine;
|
|
122
127
|
}
|
|
@@ -9,6 +9,29 @@ import withHasError from "../../utils/withHasError";
|
|
|
9
9
|
import { pageRule } from "../bn-page/pageFormats";
|
|
10
10
|
/** The elements that write what `getNotation()` reads. */
|
|
11
11
|
const NOTATION_SOURCE_SELECTOR = "bn-component-style, bn-scaling-group";
|
|
12
|
+
/** The contexts on the page, in the order they connected. */
|
|
13
|
+
const separatorSources = new Map();
|
|
14
|
+
const NAMED_SEPARATORS = { "thin-space": "\u2009", space: "\u00a0", none: "" };
|
|
15
|
+
/**
|
|
16
|
+
* Sets the group separator of the page: the one of the last connected context that
|
|
17
|
+
* declares one, else the one of the locale. The numbers on the page are drawn with
|
|
18
|
+
* the old separator, so every context draws again, but `connecting`: it has drawn nothing yet.
|
|
19
|
+
*/
|
|
20
|
+
function syncGroupSeparator(connecting) {
|
|
21
|
+
var _a;
|
|
22
|
+
let declared = "";
|
|
23
|
+
for (const source of separatorSources.values()) {
|
|
24
|
+
declared = source.separator() || declared;
|
|
25
|
+
}
|
|
26
|
+
const separator = declared ? ((_a = NAMED_SEPARATORS[declared]) !== null && _a !== void 0 ? _a : declared) : null;
|
|
27
|
+
if (separator === Formatter.groupSeparator)
|
|
28
|
+
return;
|
|
29
|
+
Formatter.groupSeparator = separator;
|
|
30
|
+
for (const [context, source] of separatorSources) {
|
|
31
|
+
if (context !== connecting)
|
|
32
|
+
source.redraw();
|
|
33
|
+
}
|
|
34
|
+
}
|
|
12
35
|
/** Attributes that change the paper size, the orientation or the number of a page. */
|
|
13
36
|
const PAGE_ATTRIBUTES = [
|
|
14
37
|
"format",
|
|
@@ -41,37 +64,22 @@ export class Context {
|
|
|
41
64
|
/**
|
|
42
65
|
* Group separator of every number in the document, in place of the one of
|
|
43
66
|
* the locale: `thin-space`, `space`, `none`, or the separator itself. It
|
|
44
|
-
* holds for the whole page, also for a context that does not set it.
|
|
67
|
+
* holds for the whole page, also for a context that does not set it. With
|
|
68
|
+
* several contexts the last one that declares a separator wins.
|
|
45
69
|
*
|
|
46
70
|
* @default "" (the separator of the locale)
|
|
47
71
|
* @example group-separator="thin-space"
|
|
48
72
|
*/
|
|
49
73
|
this.groupSeparator = "";
|
|
50
|
-
this.
|
|
74
|
+
this.wasConnected = false;
|
|
51
75
|
/** The page numbers this context wrote. A number that is not in here was set by the author and is left alone. */
|
|
52
76
|
this.assignedPageNumbers = new WeakMap();
|
|
53
77
|
this.notationSubscriptions = [];
|
|
54
78
|
withComponentStatus(this);
|
|
55
79
|
this.errors = withHasError(this);
|
|
56
80
|
}
|
|
57
|
-
watchGroupSeparator(
|
|
58
|
-
|
|
59
|
-
const before = Formatter.groupSeparator;
|
|
60
|
-
this.setGroupSeparator(newValue);
|
|
61
|
-
// the numbers are drawn with the old separator: what follows the locale draws again
|
|
62
|
-
const state = (_a = this.stores) === null || _a === void 0 ? void 0 : _a.context.state;
|
|
63
|
-
if (state && Formatter.groupSeparator !== before) {
|
|
64
|
-
const locale = state.locale;
|
|
65
|
-
state.locale = "";
|
|
66
|
-
state.locale = locale;
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
setGroupSeparator(newValue) {
|
|
70
|
-
var _a;
|
|
71
|
-
const named = { "thin-space": "\u2009", space: "\u00a0", none: "" };
|
|
72
|
-
// no value: the separator of the locale
|
|
73
|
-
Formatter.groupSeparator = newValue ? ((_a = named[newValue]) !== null && _a !== void 0 ? _a : newValue) : null;
|
|
74
|
-
this.setsGroupSeparator = !!newValue;
|
|
81
|
+
watchGroupSeparator() {
|
|
82
|
+
syncGroupSeparator();
|
|
75
83
|
}
|
|
76
84
|
setLocale(newValue) {
|
|
77
85
|
this.stores.context.state.locale = newValue;
|
|
@@ -84,9 +92,18 @@ export class Context {
|
|
|
84
92
|
if (this.locale) {
|
|
85
93
|
this.stores.context.state.locale = this.locale;
|
|
86
94
|
}
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
95
|
+
separatorSources.set(this, {
|
|
96
|
+
separator: () => { var _a; return (_a = this.groupSeparator) !== null && _a !== void 0 ? _a : ""; },
|
|
97
|
+
redraw: () => {
|
|
98
|
+
const state = this.stores.context.state;
|
|
99
|
+
const locale = state.locale;
|
|
100
|
+
state.locale = "";
|
|
101
|
+
state.locale = locale;
|
|
102
|
+
},
|
|
103
|
+
});
|
|
104
|
+
// a context that comes back to the page has drawn its numbers before
|
|
105
|
+
syncGroupSeparator(this.wasConnected ? undefined : this);
|
|
106
|
+
this.wasConnected = true;
|
|
90
107
|
// a removed scaling group is a "set" too: its entry is set to undefined
|
|
91
108
|
const notify = () => this.bnNotationChange.emit();
|
|
92
109
|
this.notationSubscriptions = [
|
|
@@ -105,11 +122,9 @@ export class Context {
|
|
|
105
122
|
}
|
|
106
123
|
disconnectedCallback() {
|
|
107
124
|
var _a, _b;
|
|
108
|
-
//
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
this.setsGroupSeparator = false;
|
|
112
|
-
}
|
|
125
|
+
// the separator of this context no longer holds, the one of another context may
|
|
126
|
+
separatorSources.delete(this);
|
|
127
|
+
syncGroupSeparator();
|
|
113
128
|
this.notationSubscriptions.forEach((unsubscribe) => unsubscribe());
|
|
114
129
|
this.notationSubscriptions = [];
|
|
115
130
|
(_a = this.pageObserver) === null || _a === void 0 ? void 0 : _a.disconnect();
|
|
@@ -262,7 +277,7 @@ export class Context {
|
|
|
262
277
|
componentWillUpdate() { }
|
|
263
278
|
componentDidUpdate() { }
|
|
264
279
|
render() {
|
|
265
|
-
return (h(Host, { key: '
|
|
280
|
+
return (h(Host, { key: '835bf8fe0cf78440c000ce996495c5c5c0cbbd07' }, h("slot", { key: '395cbc8fdbb4f6e765d36a93a7547272e5ec7def' })));
|
|
266
281
|
}
|
|
267
282
|
static get is() { return "bn-context"; }
|
|
268
283
|
static get encapsulation() { return "shadow"; }
|
|
@@ -353,7 +368,7 @@ export class Context {
|
|
|
353
368
|
"name": "example",
|
|
354
369
|
"text": "group-separator=\"thin-space\""
|
|
355
370
|
}],
|
|
356
|
-
"text": "Group separator of every number in the document, in place of the one of\nthe locale: `thin-space`, `space`, `none`, or the separator itself. It\nholds for the whole page, also for a context that does not set it."
|
|
371
|
+
"text": "Group separator of every number in the document, in place of the one of\nthe locale: `thin-space`, `space`, `none`, or the separator itself. It\nholds for the whole page, also for a context that does not set it. With\nseveral contexts the last one that declares a separator wins."
|
|
357
372
|
},
|
|
358
373
|
"getter": false,
|
|
359
374
|
"setter": false,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{B as o,d as s}from"./p-
|
|
1
|
+
import{B as o,d as s}from"./p-9a9XB5Y8.js";const a=o,p=s;export{a as BnChartStructureRenderer,p as defineCustomElement}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{p as t,H as i,w as e,f as s,h as a,d as r,t as n}from"./p-BnmylmXF.js";import{h as o,a as l}from"./p-6242qMx1.js";import{k as c,v as h,a as d,i as p,l as u,b as v,c as m,h as g,m as f,n as b}from"./p-CcfvGlBq.js";import{v as y}from"./p-Zz3fAPcH.js";import{w as S}from"./p-CZzlLTQc.js";import{w}from"./p-BrQCbmG0.js";import{i as O,w as k,a as A}from"./p-D65TnLS9.js";import{w as _}from"./p-Bp5Xj4-s.js";import{w as D}from"./p-CU9CdEBF.js";import{w as x}from"./p-JG4Sx1lE.js";import{r as N}from"./p-D0v9GMIf.js";import{w as T}from"./p-Bs5V6Ibu.js";import{w as L,r as R}from"./p-D32TsLzd.js";import{g as W}from"./p-Dsvjkuy3.js";import{r as C,f as P,p as U}from"./p-Xb6Ilq8u.js";import{o as M}from"./p-B6kka9sT.js";import{A as j,e as F,f as z,g as $}from"./p-DguYWLBj.js";import{a as I,O as E}from"./p-BBdzTx8V.js";import{L as B}from"./p-DY5fMUX8.js";import{o as G,m as H}from"./p-DdvG1D18.js";import{r as J,a as V}from"./p-CckAR27O.js";import{a as X}from"./p-BXP6aagM.js";import{a as q}from"./p-JofGXz75.js";import{s as Y}from"./p-DakXa7Dp.js";import{d as Z}from"./p-iJP2X4dc.js";const Q=t(class t extends i{validateFilter(t){const i="ERR_filter";o(t)?this.errors.addOrReplace({id:i,type:"error",message:"filter: double backticks are not allowed."}):this.errors.remove(i)}validateScenario(t){const i="WARN_scenarios";if(O(t)||c(t))return void this.errors.remove(i);const e=h(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="WARN_variances";if(O(t))return void this.errors.remove(i);const e=d(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="WARN_unitScaling";p(t)?this.errors.remove(i):"invalid"===C(t,this.pixelPerUnitGroupMap).kind?this.errors.addOrReplace({id:i,type:"warning",message:"unitScaling: invalid value(s) '"+t+"' are not supported."}):this.errors.remove(i)}validatePercentageScaling(t){const i="WARN_percentageScaling";p(t)?this.errors.remove(i):"invalid"===C(t,this.pixelPerUnitGroupMap).kind?this.errors.addOrReplace({id:i,type:"warning",message:"percentageScaling: invalid value(s) '"+t+"' are not supported."}):this.errors.remove(i)}validateLevel(t){const i="WARN_level";p(t)||u(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="WARN_order";if(O(t))return void this.errors.remove(i);const e=v(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="WARN_orderDirection";O(t)||p(t)||m(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="WARN_limit";g(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"limit: invalid value '"+(null==t?void 0:""+t)+"' is not supported."})}validateMeasureScale(t){const i="WARN_measureScale";f(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"measureScale: invalid value '"+(null==t?void 0:""+t)+"' is not supported."})}validateDataFormatDigitsDecimal(t){this.validateDigits("dataFormatDigitsDecimal",t)}validateDataFormatDigitsPercent(t){this.validateDigits("dataFormatDigitsPercent",t)}validateDigits(t,i){const e="WARN_"+t;!g(i)||Number(i)<0||Number(i)>100?this.errors.addOrReplace({id:e,type:"warning",message:t+": invalid value '"+i+"' is not supported."}):this.errors.remove(e)}validateSums(t){this.warnUnless("sums",["none","groups","total","all"].includes(t),t)}validateScenarioLabelPosition(t){this.warnUnless("scenarioLabelPosition",["bottom","top"].includes(t),t)}validateReferenceLine(t){this.warnUnless("referenceLine",p(t)||null!==this.prepareReferenceLine(),t)}validateItalicCategories(t){this.warnUnless("italicCategories",p(t)||null!==this.prepareItalicCategories(),t)}warnUnless(t,i,e){const s="WARN_"+t;i?this.errors.remove(s):this.errors.addOrReplace({id:s,type:"warning",message:t+": invalid value '"+e+"' is not supported."})}prepareReferenceLine(){if(p(this.referenceLine))return null;try{const t=JSON.parse(this.referenceLine);return"number"==typeof(null==t?void 0:t.value)&&Number.isFinite(t.value)?{value:t.value,label:"string"==typeof t.label?t.label:void 0}:null}catch(t){return null}}prepareItalicCategories(){if(p(this.italicCategories))return[];try{const t=JSON.parse(this.italicCategories);return Array.isArray(t)&&t.every((t=>"string"==typeof t))?t:null}catch(t){return null}}validateStack(t){const i="WARN_stack",e=b(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("WARN_scale");const i=Number(t);isNaN(i)||i<=0?this.errors.addOrReplace({id:"WARN_scale",type:"warning",message:`Invalid scale value: "${t}". Use "none", "auto", or a positive number.`}):this.errors.remove("WARN_scale")}constructor(i){super(),!1!==i&&this.__registerHost(),this.__attachShadow(),this.datasetName="",this.dataVersion=0,this.datasetMeta=null,this.appliedScaleFactor=1,this.layoutObserver=null,this._lastScaledParentHeight=0,this.chartTitle="",this.filter="",this.limit=0,this.showCategories=!0,this.measureScale="greatest",this.showMeasureScale=!1,this.measureUnit="",this.dataFormatDigitsDecimal=1,this.dataFormatDigitsPercent=2,this.sums="none",this.sumTitle="",this.scenarioLabelPosition="bottom",this.referenceLine="",this.italicCategories="",this.stack="",this.pixelPerUnitGroupMap=new Map,this._autoScaleGuard=!1,this.autoUnitWarningActive=!1,this.autoPctWarningActive=!1,this.handleAutoScalingReport=i=>{var e,s,a,r,n,o;this.lastAutoScalingReport={unit:null!==(e=i.unit)&&void 0!==e?e:null===(s=this.lastAutoScalingReport)||void 0===s?void 0:s.unit,percentage:null!==(a=i.percentage)&&void 0!==a?a:null===(r=this.lastAutoScalingReport)||void 0===r?void 0:r.percentage};const l=(t,i)=>void 0===i||Math.abs(t-i)>.001*Math.abs(t),c=this.getEffectiveFontPx();if(void 0!==i.unit&&i.unit>0&&this.autoUnitWarningActive){const e=c/i.unit;l(e,this.lastReportedUnitsPerEm)&&(this.lastReportedUnitsPerEm=e,this.errors.addOrReplace({id:"AUTO_unitScaling",type:"warning",message:`unit-scaling: ${t.describeScalingInput(((null!==(n=this.unitScaling)&&void 0!==n?n:"")+"").trim())}, auto-fitted to 1 em ≈ ${P(e)} units.`}))}if(void 0!==i.percentage&&i.percentage>0&&this.autoPctWarningActive){const e=100*c/i.percentage;l(e,this.lastReportedPpPerEm)&&(this.lastReportedPpPerEm=e,this.errors.addOrReplace({id:"AUTO_percentageScaling",type:"warning",message:`percentage-scaling: ${t.describeScalingInput(((null!==(o=this.percentageScaling)&&void 0!==o?o:"")+"").trim())}, auto-fitted to 1 em ≈ ${P(e)} percentage points.`}))}},D(this),w(this),S(this,(t=>{this.datasetName=(null==t?void 0:t.startsWith("$"))?t.substring(1):t||"",this.dataVersion=this.dataVersion+1}),((t,i)=>{this.datasetMeta=i})),this.chartTemplate=this.chartTemplate.bind(this),this.errors=L(this),_(this),this.componentStyle=x(this),this.ruleSetConfig=T(this),this.t=k(this).t,this.resolveInherited=A(this,[{propName:"scenarios",ancestorAttr:"title-scenarios"},{propName:"variances",ancestorAttr:"title-variances"},{propName:"order",ancestorAttr:"title-order"},{propName:"orderDirection",ancestorAttr:"title-order-direction"}],this.errors)}componentWillLoad(){this.validateFilter(this.filter),this.validateScenario(this.scenarios),this.validateDataFormatDigitsDecimal(this.dataFormatDigitsDecimal),this.validateDataFormatDigitsPercent(this.dataFormatDigitsPercent),this.validateVariances(this.variances),this.validateUnitScaling(this.unitScaling),this.validateLevel(this.level),this.validateOrderDirection(this.orderDirection),this.validateOrderList(this.order),this.validateMeasureScale(this.measureScale),this.validateStack(this.stack),this.validateSums(this.sums),this.validateScenarioLabelPosition(this.scenarioLabelPosition),this.validateReferenceLine(this.referenceLine),this.validateItalicCategories(this.italicCategories),this.validateScaling(this.scale)}componentDidRender(){Y(this.element,"bn-chart-structure-renderer");const{mode:t}=U(this.scale);if("auto"!==t&&"empty"!==t)return this._autoScaleGuard=!1,void this.checkOverflow();if(this._autoScaleGuard)return this._autoScaleGuard=!1,void this.checkOverflow();const i=this.element,{height:s}=W(i);if(s<=0)return void this.checkOverflow();this._lastScaledParentHeight=s;const a=this.componentStyle((t=>{var i;return(null===(i=t.global)||void 0===i?void 0:i.fontSizePx)||13.3333})),r=i.scrollHeight,n=this.appliedScaleFactor;if(r<=s+1)return this.errors.remove("AUTO_scale"),void this.checkOverflow();const o=Math.max(.3,n*(s-1)/r);Math.abs(o-n)<.01||(i.style.setProperty("--bn-font-size",a*o+"px"),"empty"===t?this.errors.addOrReplace({id:"AUTO_scale",type:"warning",message:"Auto-scaled chart by factor "+o.toFixed(3)}):this.errors.remove("AUTO_scale"),this._autoScaleGuard=!0,e((()=>{this.appliedScaleFactor=o}))),this.checkOverflow()}componentDidLoad(){this.layoutObserver=M(this.element,(()=>{if(this._autoScaleGuard)return;const{height:t}=W(this.element);t>0&&Math.abs(t-this._lastScaledParentHeight)>2&&(this._lastScaledParentHeight=t,s(this))})),requestAnimationFrame((()=>{requestAnimationFrame((()=>{if(this._autoScaleGuard)return;const{height:t}=W(this.element);this._lastScaledParentHeight=t,s(this)}))}))}disconnectedCallback(){var t;null===(t=this.layoutObserver)||void 0===t||t.disconnect(),this.layoutObserver=null}measureContentWidth(){var t;const i=null===(t=this.element.shadowRoot)||void 0===t?void 0:t.querySelectorAll("bn-chart-structure-renderer");let e=0,s=!1;return null==i||i.forEach((t=>{var i,a,r;const n=parseFloat(null!==(r=null===(a=null===(i=t.shadowRoot)||void 0===i?void 0:i.querySelector("svg#drawCanvas"))||void 0===a?void 0:a.getAttribute("width"))&&void 0!==r?r:"");Number.isNaN(n)||(e+=n,s=!0)})),s?Math.max(Math.floor(e),this.element.scrollWidth):this.element.scrollWidth}checkOverflow(){const t=W(this.element),i=this.measureContentWidth(),e=this.element.scrollHeight,s=t.width>0&&i>t.width+1,a=t.height>0&&e>t.height+1;if(!s&&!a)return void R(this.errors,null);const r=this.prepareVariances().some((t=>t.startsWith("dr"))),n="value"===C(this.unitScaling,this.pixelPerUnitGroupMap).kind,o=r&&"value"===C(this.percentageScaling,this.pixelPerUnitGroupMap).kind,{mode:l}=U(this.scale),c="auto"!==l&&"empty"!==l,h=[];s&&n&&h.push("unit-scaling"),s&&o&&h.push("percentage-scaling"),a&&c&&h.push("scale");const d=[];s&&d.push(`width (${Math.round(i)}px > ${Math.round(t.width)}px)`),a&&d.push(`height (${Math.round(e)}px > ${Math.round(t.height)}px)`),R(this.errors,`Chart exceeds available ${d.join(" and ")}. `+(h.length>0?`Adjust ${h.join(" / ")} or set to "auto".`:"Content does not fit even at minimum auto scaling; enlarge the container."),h.length>0)}prepareDimension(){const t=W(this.element),i=Math.max(1,this.prepareSegments().length);return this.canvasWidthSegmented=t.width/i,{width:this.canvasWidthSegmented,height:t.height}}prepareScenarios(){var t,i,e,s;const a=this.resolveInherited("scenarios",this.scenarios);if(a.inherited)return this.errors.remove("AUTO_scenarios"),a.value.split(",").map((t=>t.trim()));if(c(a.value))return this.errors.remove("AUTO_scenarios"),[];const r="auto"===(null===(t=a.value)||void 0===t?void 0:t.trim().toLowerCase());return p(a.value)||r?(null===(e=null===(i=this.datasetMeta)||void 0===i?void 0:i.availableScenarios)||void 0===e?void 0:e.length)>0?(r||a.unresolved?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=a.value)||void 0===s?void 0:s.split(",").map((t=>t.trim())))}prepareVariances(){const t=this.resolveInherited("variances",this.variances).value;return p(t)?[]:null==t?void 0:t.split(",").map((t=>t.trim()))}hidesScenarios(){const t=this.resolveInherited("scenarios",this.scenarios);return!t.inherited&&c(t.value)}prepareSegments(){return this.hidesScenarios()?this.prepareVariances():["",...this.prepareVariances()]}prepareHideCategories(t){return t>=1||!this.showCategories}prepareI18n(){const t=l,i=new Map(["no-data","REST"].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(),...N(this.ruleSetConfig("user"))])}static describeScalingInput(t){return""===t?"not set":`invalid value "${t}"`}preparePixelPerUnit(){const i=C(this.unitScaling,this.pixelPerUnitGroupMap);return"value"===i.kind?(this.errors.remove("AUTO_unitScaling"),this.autoUnitWarningActive=!1,this.lastReportedUnitsPerEm=void 0,this.getEffectiveFontPx()/i.value):"auto"===i.kind?(this.errors.remove("AUTO_unitScaling"),this.autoUnitWarningActive=!1,this.lastReportedUnitsPerEm=void 0,0):(this.autoUnitWarningActive=!0,this.errors.addOrReplace({id:"AUTO_unitScaling",type:"warning",message:`unit-scaling: ${t.describeScalingInput(i.raw)}, auto-calculated to fit available space.`}),0)}preparePixelPerPercentage(){const i=C(this.percentageScaling,this.pixelPerUnitGroupMap);return"value"===i.kind?(this.errors.remove("AUTO_percentageScaling"),this.autoPctWarningActive=!1,this.lastReportedPpPerEm=void 0,100*this.getEffectiveFontPx()/i.value):"auto"===i.kind?(this.errors.remove("AUTO_percentageScaling"),this.autoPctWarningActive=!1,this.lastReportedPpPerEm=void 0,0):(this.autoPctWarningActive=!0,this.errors.addOrReplace({id:"AUTO_percentageScaling",type:"warning",message:`percentage-scaling: ${t.describeScalingInput(i.raw)}, auto-calculated to fit available space.`}),0)}prepareLevel(){var t,i,e;const s="auto"===(null===(t=this.level)||void 0===t?void 0:t.trim().toLowerCase());return p(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}),j[this.datasetMeta.suggestedLevel.toUpperCase()]):void 0:(this.errors.remove("AUTO_level"),j[null===(e=this.level)||void 0===e?void 0:e.toUpperCase()])}prepareOrder(){var t;const i=this.resolveInherited("order",this.order),e=i.value,s=this.resolveInherited("orderDirection",this.orderDirection).value,a="auto"===(null==e?void 0:e.trim().toLowerCase());let r;return p(e)||a?(null===(t=this.datasetMeta)||void 0===t?void 0:t.suggestedOrder)?(a||i.unresolved?this.errors.remove("AUTO_order"):this.errors.addOrReplace({id:"AUTO_order",type:"warning",message:"order: not set, auto-detected: "+this.datasetMeta.suggestedOrder}),r=this.datasetMeta.suggestedOrder):r=e:(this.errors.remove("AUTO_order"),r=e),{hierarchy:null==r?void 0:r.split(",").map((t=>E[null==t?void 0:t.toUpperCase()])),direction:I[null==s?void 0:s.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}`,family: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,stackColors:i["bn-chart-structure"].stackColors,padding:i["bn-chart-structure"].padding,pattern:null}}))}prepareChartTitle(t){return t>=1||this.hidesScenarios()?"":this.chartTitle}prepareStackConfig(){if(p(this.stack))return this.errors.remove("WARN_stack_dimensions_scenarios"),this.errors.remove("WARN_stack_thickness_variances"),null;try{const t=JSON.parse(this.stack),i=t.by,e="WARN_stack_dimensions_scenarios";if(i===F.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);const s="total"===t.thickness,a=s&&this.prepareVariances().length>0;return a?this.errors.addOrReplace({id:"WARN_stack_thickness_variances",type:"warning",message:"stack thickness total: not used together with variances, the rows keep one height."}):this.errors.remove("WARN_stack_thickness_variances"),{by:i,mode:t.mode||$.ABSOLUTE,order:t.order||z.DATASET,percentMark:!0===t.percentMark,labels:"value"===t.labels?"value":"share",thickness:s&&!a?"total":"equal",totalTitle:"string"==typeof t.totalTitle?t.totalTitle:void 0}}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 p(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&&this.showMeasureScale}prepareMeasureUnit(){return""===this.measureUnit||null==this.measureUnit?"":this.measureUnit}chartTemplate(t,i){var e;const s=this.preparePixelPerUnit(),r=this.preparePixelPerPercentage(),n=this.prepareStackConfig(),o=""===t,l=this.hidesScenarios()?y([t]):this.prepareScenarios(),c=o&&(null==n?void 0:n.by)===F.DIMENSIONS?l.slice(0,1):l;return a("bn-chart-structure-renderer",{tableName:this.datasetName,dataVersion:this.dataVersion,chartTitle:this.prepareChartTitle(i),scenarios:c,variances:[t],hideCategories:this.prepareHideCategories(i),pixelPerUnit:s,pixelPerPercentage:r,reportAutoScaling:this.handleAutoScalingReport,errors:this.errors,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,sums:["groups","total","all"].includes(this.sums)?this.sums:"none",sumTitle:this.sumTitle,scenarioLabelTop:"top"===this.scenarioLabelPosition,referenceLine:o?this.prepareReferenceLine():null,italicCategories:null!==(e=this.prepareItalicCategories())&&void 0!==e?e:[],dataFormatDigits:{percent:this.dataFormatDigitsPercent,decimal:this.dataFormatDigitsDecimal},parentDimensions:this.prepareDimension(),ruleSetConfig:this.ruleSetConfig()})}async getBaseline(){return q(this.element,"bn-chart-structure-renderer")}async getLayoutState(t){var i,e,s,a;const r=null!==(i=null==t?void 0:t.detail)&&void 0!==i?i:"summary",n=G(this.element),o=this.getEffectiveScaleFactor(),l=Number.isFinite(o)&&o>0?o:1,c=this.componentStyle((t=>{var i;return(null===(i=t.global)||void 0===i?void 0:i.fontSizePx)||13.3333}))*l,h=this.prepareVariances(),d=X(this.element,"bn-chart-structure-renderer",this.prepareSegments().map((t=>t||"base")),n,r),p=null===(e=this.element.shadowRoot)||void 0===e?void 0:e.querySelector("bn-chart-structure-renderer"),u={version:B,tag:this.element.localName,id:V(this.element),slot:null!==(s=this.element.getAttribute("slot"))&&void 0!==s?s:void 0,rect:H(this.element,n),em:{fontSizePx:c,appliedScaleFactor:l},regions:d.regions,metadata:{title:this.chartTitle||void 0,scenarios:null!==(a=null==p?void 0:p.scenarios)&&void 0!==a?a:[],variances:h,barCount:d.barCount,hasNoData:0===d.barCount},diagnostics:J(this.element),scaling:this.resolveScalingInfo(c),baseline:d.baseline};return d.elements&&(u.elements=d.elements),u}resolveScalingInfo(t){var i,e;const s={},a=C(this.unitScaling,this.pixelPerUnitGroupMap);if("value"===a.kind)s.unitMode="fixed",s.unitsPerEm=a.value,s.unitPxPerUnit=t/a.value;else{s.unitMode="auto";const e=null===(i=this.lastAutoScalingReport)||void 0===i?void 0:i.unit;void 0!==e&&e>0&&(s.unitPxPerUnit=e,s.unitsPerEm=t/e)}const r=C(this.percentageScaling,this.pixelPerUnitGroupMap);if("value"===r.kind)s.percentageMode="fixed",s.percentagePointsPerEm=r.value,s.percentagePxPerPoint=t/r.value;else{s.percentageMode="auto";const i=null===(e=this.lastAutoScalingReport)||void 0===e?void 0:e.percentage;void 0!==i&&i>0&&(s.percentagePxPerPoint=i/100,s.percentagePointsPerEm=100*t/i)}return s}getEffectiveScaleFactor(){const{mode:t,factor:i}=U(this.scale);return"factor"===t?i:"auto"===t||"empty"===t?this.appliedScaleFactor:1}getEffectiveFontPx(){return this.componentStyle((t=>{var i;return(null===(i=t.global)||void 0===i?void 0:i.fontSizePx)||13.3333}))*this.getEffectiveScaleFactor()}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(){const t=this.prepareSegments();0===t.length?this.errors.addOrReplace({id:"WARN_scenarios_none",type:"warning",message:"scenarios: none needs at least one variance, the chart is empty."}):this.errors.remove("WARN_scenarios_none");const i=this.getFontStyles();return a(r,{key:"eb0b081632a3d8e9475f280357c0b22b17b23df3",style:i},a("div",{key:"8ecaea33bcd96b312e39868f008aa630e12077c2",class:"container"},t.map(this.chartTemplate)))}get element(){return this}static get watchers(){return{filter:[{validateFilter: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}],measureScale:[{validateMeasureScale:0}],dataFormatDigitsDecimal:[{validateDataFormatDigitsDecimal:0}],dataFormatDigitsPercent:[{validateDataFormatDigitsPercent:0}],sums:[{validateSums:0}],scenarioLabelPosition:[{validateScenarioLabelPosition:0}],referenceLine:[{validateReferenceLine:0}],italicCategories:[{validateItalicCategories:0}],stack:[{validateStack:0}],scale:[{validateScaling:0}]}}static get style(){return':host(.no-data){display:block;box-sizing:border-box;width:100%;height:100%}:host(.no-data)>div{float:none;width:100%;height:100%}:host(.no-data) .no-data~.no-data{display:none}.empty-state{box-sizing:border-box;display:flex;align-items:center;justify-content:center;float:none;width:100%;height:100%;min-height:3em;margin:0;padding:0.5em;overflow:hidden;border:0.1em dashed #ddd;color:#808080;font-family:var(--bn-font-family, "Noto Sans", sans-serif);font-size:var(--bn-font-size, 13.3333px);font-style:normal;text-align:center}:host{display:inline-block;position:relative;overflow:hidden;font-family:var(--bn-font-family, "Noto Sans", sans-serif);font-size:var(--bn-font-size, 13.3333px);color:var(--bn-font-color, #000000)}.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}svg#drawCanvas{display:block}.footer{margin:0.2em;font-size:0.6em}.footer-hide{margin:0.2em;font-size:0.6em;opacity:0}'}},[1,"bn-chart-structure",{datasets:[513],selectedStyle:[513,"selected-style"],i18nNamespace:[513,"i18n-namespace"],chartTitle:[1,"chart-title"],ruleset:[513],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:[4,"show-categories"],measureScale:[1,"measure-scale"],showMeasureScale:[4,"show-measure-scale"],measureUnit:[1,"measure-unit"],dataFormatDigitsDecimal:[2,"data-format-digits-decimal"],dataFormatDigitsPercent:[2,"data-format-digits-percent"],sums:[1],sumTitle:[1,"sum-title"],scenarioLabelPosition:[1,"scenario-label-position"],referenceLine:[1,"reference-line"],italicCategories:[1,"italic-categories"],stack:[1],scale:[1],datasetName:[32],dataVersion:[32],datasetMeta:[32],appliedScaleFactor:[32],getBaseline:[64],getLayoutState:[64]},void 0,{filter:[{validateFilter: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}],measureScale:[{validateMeasureScale:0}],dataFormatDigitsDecimal:[{validateDataFormatDigitsDecimal:0}],dataFormatDigitsPercent:[{validateDataFormatDigitsPercent:0}],sums:[{validateSums:0}],scenarioLabelPosition:[{validateScenarioLabelPosition:0}],referenceLine:[{validateReferenceLine:0}],italicCategories:[{validateItalicCategories:0}],stack:[{validateStack:0}],scale:[{validateScaling:0}]}]),K=Q,tt=function(){"undefined"!=typeof customElements&&["bn-chart-structure","bn-chart-structure-renderer"].forEach((t=>{switch(t){case"bn-chart-structure":customElements.get(n(t))||customElements.define(n(t),Q);break;case"bn-chart-structure-renderer":customElements.get(n(t))||Z()}}))};export{K as BnChartStructure,tt as defineCustomElement}
|
|
1
|
+
import{p as t,H as i,w as e,f as s,h as a,d as r,t as n}from"./p-BnmylmXF.js";import{h as o,a as l}from"./p-6242qMx1.js";import{k as c,v as h,a as d,i as p,l as u,b as v,c as m,h as g,m as f,n as b}from"./p-CcfvGlBq.js";import{v as y}from"./p-Zz3fAPcH.js";import{w as S}from"./p-CZzlLTQc.js";import{w}from"./p-BrQCbmG0.js";import{i as k,w as O,a as A}from"./p-D65TnLS9.js";import{w as _}from"./p-Bp5Xj4-s.js";import{w as N}from"./p-CU9CdEBF.js";import{w as D}from"./p-JG4Sx1lE.js";import{r as x}from"./p-D0v9GMIf.js";import{w as T}from"./p-Bs5V6Ibu.js";import{w as L,r as R}from"./p-D32TsLzd.js";import{g as W}from"./p-Dsvjkuy3.js";import{r as C,f as U,p as M}from"./p-Xb6Ilq8u.js";import{o as P}from"./p-B6kka9sT.js";import{A as j,e as F,f as z,g as $}from"./p-DguYWLBj.js";import{a as I,O as B}from"./p-BBdzTx8V.js";import{L as E}from"./p-DY5fMUX8.js";import{o as G,m as H}from"./p-DdvG1D18.js";import{r as J,a as V}from"./p-CckAR27O.js";import{a as X}from"./p-BXP6aagM.js";import{a as q}from"./p-JofGXz75.js";import{s as Y}from"./p-DakXa7Dp.js";import{d as Z}from"./p-9a9XB5Y8.js";const Q=t(class t extends i{validateFilter(t){const i="ERR_filter";o(t)?this.errors.addOrReplace({id:i,type:"error",message:"filter: double backticks are not allowed."}):this.errors.remove(i)}validateScenario(t){const i="WARN_scenarios";if(k(t)||c(t))return void this.errors.remove(i);const e=h(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="WARN_variances";if(k(t))return void this.errors.remove(i);const e=d(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="WARN_unitScaling";p(t)?this.errors.remove(i):"invalid"===C(t,this.pixelPerUnitGroupMap).kind?this.errors.addOrReplace({id:i,type:"warning",message:"unitScaling: invalid value(s) '"+t+"' are not supported."}):this.errors.remove(i)}validatePercentageScaling(t){const i="WARN_percentageScaling";p(t)?this.errors.remove(i):"invalid"===C(t,this.pixelPerUnitGroupMap).kind?this.errors.addOrReplace({id:i,type:"warning",message:"percentageScaling: invalid value(s) '"+t+"' are not supported."}):this.errors.remove(i)}validateLevel(t){const i="WARN_level";p(t)||u(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="WARN_order";if(k(t))return void this.errors.remove(i);const e=v(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="WARN_orderDirection";k(t)||p(t)||m(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="WARN_limit";g(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"limit: invalid value '"+(null==t?void 0:""+t)+"' is not supported."})}validateMeasureScale(t){const i="WARN_measureScale";f(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"measureScale: invalid value '"+(null==t?void 0:""+t)+"' is not supported."})}validateDataFormatDigitsDecimal(t){this.validateDigits("dataFormatDigitsDecimal",t)}validateDataFormatDigitsPercent(t){this.validateDigits("dataFormatDigitsPercent",t)}validateDigits(t,i){const e="WARN_"+t;!g(i)||Number(i)<0||Number(i)>100?this.errors.addOrReplace({id:e,type:"warning",message:t+": invalid value '"+i+"' is not supported."}):this.errors.remove(e)}validateSums(t){this.warnUnless("sums",["none","groups","total","all"].includes(t),t)}validateScenarioLabelPosition(t){this.warnUnless("scenarioLabelPosition",["bottom","top"].includes(t),t)}validateReferenceLine(t){this.warnUnless("referenceLine",p(t)||null!==this.prepareReferenceLine(),t)}validateItalicCategories(t){this.warnUnless("italicCategories",p(t)||null!==this.prepareItalicCategories(),t)}warnUnless(t,i,e){const s="WARN_"+t;i?this.errors.remove(s):this.errors.addOrReplace({id:s,type:"warning",message:t+": invalid value '"+e+"' is not supported."})}prepareReferenceLine(){if(p(this.referenceLine))return null;try{const t=JSON.parse(this.referenceLine);return"number"==typeof(null==t?void 0:t.value)&&Number.isFinite(t.value)?{value:t.value,label:"string"==typeof t.label?t.label:void 0}:null}catch(t){return null}}prepareItalicCategories(){if(p(this.italicCategories))return[];try{const t=JSON.parse(this.italicCategories);return Array.isArray(t)&&t.every((t=>"string"==typeof t))?t:null}catch(t){return null}}validateStack(t){const i="WARN_stack",e=b(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("WARN_scale");const i=Number(t);isNaN(i)||i<=0?this.errors.addOrReplace({id:"WARN_scale",type:"warning",message:`Invalid scale value: "${t}". Use "none", "auto", or a positive number.`}):this.errors.remove("WARN_scale")}constructor(i){super(),!1!==i&&this.__registerHost(),this.__attachShadow(),this.datasetName="",this.dataVersion=0,this.datasetMeta=null,this.appliedScaleFactor=1,this.layoutObserver=null,this._lastScaledParentHeight=0,this.chartTitle="",this.filter="",this.limit=0,this.showCategories=!0,this.measureScale="greatest",this.showMeasureScale=!1,this.measureUnit="",this.dataFormatDigitsDecimal=1,this.dataFormatDigitsPercent=2,this.sums="none",this.sumTitle="",this.scenarioLabelPosition="bottom",this.referenceLine="",this.italicCategories="",this.stack="",this.pixelPerUnitGroupMap=new Map,this._autoScaleGuard=!1,this.autoUnitWarningActive=!1,this.autoPctWarningActive=!1,this.handleAutoScalingReport=i=>{var e,s,a,r,n,o;this.lastAutoScalingReport={unit:null!==(e=i.unit)&&void 0!==e?e:null===(s=this.lastAutoScalingReport)||void 0===s?void 0:s.unit,percentage:null!==(a=i.percentage)&&void 0!==a?a:null===(r=this.lastAutoScalingReport)||void 0===r?void 0:r.percentage};const l=(t,i)=>void 0===i||Math.abs(t-i)>.001*Math.abs(t),c=this.getEffectiveFontPx();if(void 0!==i.unit&&i.unit>0&&this.autoUnitWarningActive){const e=c/i.unit;l(e,this.lastReportedUnitsPerEm)&&(this.lastReportedUnitsPerEm=e,this.errors.addOrReplace({id:"AUTO_unitScaling",type:"warning",message:`unit-scaling: ${t.describeScalingInput(((null!==(n=this.unitScaling)&&void 0!==n?n:"")+"").trim())}, auto-fitted to 1 em ≈ ${U(e)} units.`}))}if(void 0!==i.percentage&&i.percentage>0&&this.autoPctWarningActive){const e=100*c/i.percentage;l(e,this.lastReportedPpPerEm)&&(this.lastReportedPpPerEm=e,this.errors.addOrReplace({id:"AUTO_percentageScaling",type:"warning",message:`percentage-scaling: ${t.describeScalingInput(((null!==(o=this.percentageScaling)&&void 0!==o?o:"")+"").trim())}, auto-fitted to 1 em ≈ ${U(e)} percentage points.`}))}},N(this),w(this),S(this,(t=>{this.datasetName=(null==t?void 0:t.startsWith("$"))?t.substring(1):t||"",this.dataVersion=this.dataVersion+1}),((t,i)=>{this.datasetMeta=i})),this.chartTemplate=this.chartTemplate.bind(this),this.errors=L(this),_(this),this.componentStyle=D(this),this.ruleSetConfig=T(this),this.t=O(this).t,this.resolveInherited=A(this,[{propName:"scenarios",ancestorAttr:"title-scenarios"},{propName:"variances",ancestorAttr:"title-variances"},{propName:"order",ancestorAttr:"title-order"},{propName:"orderDirection",ancestorAttr:"title-order-direction"}],this.errors)}componentWillLoad(){this.validateFilter(this.filter),this.validateScenario(this.scenarios),this.validateDataFormatDigitsDecimal(this.dataFormatDigitsDecimal),this.validateDataFormatDigitsPercent(this.dataFormatDigitsPercent),this.validateVariances(this.variances),this.validateUnitScaling(this.unitScaling),this.validateLevel(this.level),this.validateOrderDirection(this.orderDirection),this.validateOrderList(this.order),this.validateMeasureScale(this.measureScale),this.validateStack(this.stack),this.validateSums(this.sums),this.validateScenarioLabelPosition(this.scenarioLabelPosition),this.validateReferenceLine(this.referenceLine),this.validateItalicCategories(this.italicCategories),this.validateScaling(this.scale)}componentDidRender(){Y(this.element,"bn-chart-structure-renderer");const{mode:t}=M(this.scale);if("auto"!==t&&"empty"!==t)return this._autoScaleGuard=!1,void this.checkOverflow();if(this._autoScaleGuard)return this._autoScaleGuard=!1,void this.checkOverflow();const i=this.element,{height:s}=W(i);if(s<=0)return void this.checkOverflow();this._lastScaledParentHeight=s;const a=this.componentStyle((t=>{var i;return(null===(i=t.global)||void 0===i?void 0:i.fontSizePx)||13.3333})),r=i.scrollHeight,n=this.appliedScaleFactor;if(r<=s+1)return this.errors.remove("AUTO_scale"),void this.checkOverflow();const o=Math.max(.3,n*(s-1)/r);Math.abs(o-n)<.01||(i.style.setProperty("--bn-font-size",a*o+"px"),"empty"===t?this.errors.addOrReplace({id:"AUTO_scale",type:"warning",message:"Auto-scaled chart by factor "+o.toFixed(3)}):this.errors.remove("AUTO_scale"),this._autoScaleGuard=!0,e((()=>{this.appliedScaleFactor=o}))),this.checkOverflow()}componentDidLoad(){this.layoutObserver=P(this.element,(()=>{if(this._autoScaleGuard)return;const{height:t}=W(this.element);t>0&&Math.abs(t-this._lastScaledParentHeight)>2&&(this._lastScaledParentHeight=t,s(this))})),requestAnimationFrame((()=>{requestAnimationFrame((()=>{if(this._autoScaleGuard)return;const{height:t}=W(this.element);this._lastScaledParentHeight=t,s(this)}))}))}disconnectedCallback(){var t;null===(t=this.layoutObserver)||void 0===t||t.disconnect(),this.layoutObserver=null}measureContentWidth(){var t;const i=null===(t=this.element.shadowRoot)||void 0===t?void 0:t.querySelectorAll("bn-chart-structure-renderer");let e=0,s=!1;return null==i||i.forEach((t=>{var i,a,r;const n=parseFloat(null!==(r=null===(a=null===(i=t.shadowRoot)||void 0===i?void 0:i.querySelector("svg#drawCanvas"))||void 0===a?void 0:a.getAttribute("width"))&&void 0!==r?r:"");Number.isNaN(n)||(e+=n,s=!0)})),s?Math.max(Math.floor(e),this.element.scrollWidth):this.element.scrollWidth}checkOverflow(){const t=W(this.element),i=this.measureContentWidth(),e=this.element.scrollHeight,s=t.width>0&&i>t.width+1,a=t.height>0&&e>t.height+1;if(!s&&!a)return void R(this.errors,null);const r=this.prepareVariances().some((t=>t.startsWith("dr"))),n="value"===C(this.unitScaling,this.pixelPerUnitGroupMap).kind,o=r&&"value"===C(this.percentageScaling,this.pixelPerUnitGroupMap).kind,{mode:l}=M(this.scale),c="auto"!==l&&"empty"!==l,h=[];s&&n&&h.push("unit-scaling"),s&&o&&h.push("percentage-scaling"),a&&c&&h.push("scale");const d=[];s&&d.push(`width (${Math.round(i)}px > ${Math.round(t.width)}px)`),a&&d.push(`height (${Math.round(e)}px > ${Math.round(t.height)}px)`),R(this.errors,`Chart exceeds available ${d.join(" and ")}. `+(h.length>0?`Adjust ${h.join(" / ")} or set to "auto".`:"Content does not fit even at minimum auto scaling; enlarge the container."),h.length>0)}prepareDimension(){const t=W(this.element),i=Math.max(1,this.prepareSegments().length);return this.canvasWidthSegmented=t.width/i,{width:this.canvasWidthSegmented,height:t.height}}prepareScenarios(){var t,i,e,s;const a=this.resolveInherited("scenarios",this.scenarios);if(a.inherited)return this.errors.remove("AUTO_scenarios"),a.value.split(",").map((t=>t.trim()));if(c(a.value))return this.errors.remove("AUTO_scenarios"),[];const r="auto"===(null===(t=a.value)||void 0===t?void 0:t.trim().toLowerCase());return p(a.value)||r?(null===(e=null===(i=this.datasetMeta)||void 0===i?void 0:i.availableScenarios)||void 0===e?void 0:e.length)>0?(r||a.unresolved?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=a.value)||void 0===s?void 0:s.split(",").map((t=>t.trim())))}prepareVariances(){const t=this.resolveInherited("variances",this.variances).value;return p(t)?[]:null==t?void 0:t.split(",").map((t=>t.trim()))}hidesScenarios(){const t=this.resolveInherited("scenarios",this.scenarios);return!t.inherited&&c(t.value)}prepareSegments(){return this.hidesScenarios()?this.prepareVariances():["",...this.prepareVariances()]}prepareHideCategories(t){return t>=1||!this.showCategories}prepareI18n(){const t=l,i=new Map(["no-data","REST"].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(),...x(this.ruleSetConfig("user"))])}static describeScalingInput(t){return""===t?"not set":`invalid value "${t}"`}preparePixelPerUnit(){const i=C(this.unitScaling,this.pixelPerUnitGroupMap);return"value"===i.kind?(this.errors.remove("AUTO_unitScaling"),this.autoUnitWarningActive=!1,this.lastReportedUnitsPerEm=void 0,this.getEffectiveFontPx()/i.value):"auto"===i.kind?(this.errors.remove("AUTO_unitScaling"),this.autoUnitWarningActive=!1,this.lastReportedUnitsPerEm=void 0,0):(this.autoUnitWarningActive=!0,this.errors.addOrReplace({id:"AUTO_unitScaling",type:"warning",message:`unit-scaling: ${t.describeScalingInput(i.raw)}, auto-calculated to fit available space.`}),0)}preparePixelPerPercentage(){const i=C(this.percentageScaling,this.pixelPerUnitGroupMap);return"value"===i.kind?(this.errors.remove("AUTO_percentageScaling"),this.autoPctWarningActive=!1,this.lastReportedPpPerEm=void 0,100*this.getEffectiveFontPx()/i.value):"auto"===i.kind?(this.errors.remove("AUTO_percentageScaling"),this.autoPctWarningActive=!1,this.lastReportedPpPerEm=void 0,0):(this.autoPctWarningActive=!0,this.errors.addOrReplace({id:"AUTO_percentageScaling",type:"warning",message:`percentage-scaling: ${t.describeScalingInput(i.raw)}, auto-calculated to fit available space.`}),0)}prepareLevel(){var t,i,e;const s="auto"===(null===(t=this.level)||void 0===t?void 0:t.trim().toLowerCase());return p(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}),j[this.datasetMeta.suggestedLevel.toUpperCase()]):void 0:(this.errors.remove("AUTO_level"),j[null===(e=this.level)||void 0===e?void 0:e.toUpperCase()])}prepareOrder(){var t;const i=this.resolveInherited("order",this.order),e=i.value,s=this.resolveInherited("orderDirection",this.orderDirection).value,a="auto"===(null==e?void 0:e.trim().toLowerCase());let r;return p(e)||a?(null===(t=this.datasetMeta)||void 0===t?void 0:t.suggestedOrder)?(a||i.unresolved?this.errors.remove("AUTO_order"):this.errors.addOrReplace({id:"AUTO_order",type:"warning",message:"order: not set, auto-detected: "+this.datasetMeta.suggestedOrder}),r=this.datasetMeta.suggestedOrder):r=e:(this.errors.remove("AUTO_order"),r=e),{hierarchy:null==r?void 0:r.split(",").map((t=>B[null==t?void 0:t.toUpperCase()])),direction:I[null==s?void 0:s.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}`,family: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,stackColors:i["bn-chart-structure"].stackColors,padding:i["bn-chart-structure"].padding,pattern:null}}))}prepareChartTitle(t){return t>=1||this.hidesScenarios()?"":this.chartTitle}prepareStackConfig(){if(p(this.stack))return this.errors.remove("WARN_stack_dimensions_scenarios"),this.errors.remove("WARN_stack_thickness_variances"),null;try{const t=JSON.parse(this.stack),i=t.by,e="WARN_stack_dimensions_scenarios";if(i===F.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);const s="total"===t.thickness,a=s&&this.prepareVariances().length>0;return a?this.errors.addOrReplace({id:"WARN_stack_thickness_variances",type:"warning",message:"stack thickness total: not used together with variances, the rows keep one height."}):this.errors.remove("WARN_stack_thickness_variances"),{by:i,mode:t.mode||$.ABSOLUTE,order:t.order||z.DATASET,percentMark:!0===t.percentMark,labels:"value"===t.labels?"value":"share",thickness:s&&!a?"total":"equal",totalTitle:"string"==typeof t.totalTitle?t.totalTitle:void 0}}catch(t){return this.errors.remove("WARN_stack_dimensions_scenarios"),this.errors.remove("WARN_stack_thickness_variances"),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 p(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&&this.showMeasureScale}prepareMeasureUnit(){return""===this.measureUnit||null==this.measureUnit?"":this.measureUnit}chartTemplate(t,i){var e;const s=this.preparePixelPerUnit(),r=this.preparePixelPerPercentage(),n=this.prepareStackConfig(),o=""===t,l=this.hidesScenarios()?y([t]):this.prepareScenarios(),c=o&&(null==n?void 0:n.by)===F.DIMENSIONS?l.slice(0,1):l;return a("bn-chart-structure-renderer",{tableName:this.datasetName,dataVersion:this.dataVersion,chartTitle:this.prepareChartTitle(i),scenarios:c,variances:[t],hideCategories:this.prepareHideCategories(i),pixelPerUnit:s,pixelPerPercentage:r,reportAutoScaling:this.handleAutoScalingReport,errors:this.errors,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,sums:["groups","total","all"].includes(this.sums)?this.sums:"none",sumTitle:this.sumTitle,scenarioLabelTop:"top"===this.scenarioLabelPosition,hideScenarioName:this.hidesScenarios(),referenceLine:o?this.prepareReferenceLine():null,italicCategories:null!==(e=this.prepareItalicCategories())&&void 0!==e?e:[],dataFormatDigits:{percent:this.dataFormatDigitsPercent,decimal:this.dataFormatDigitsDecimal},parentDimensions:this.prepareDimension(),ruleSetConfig:this.ruleSetConfig()})}async getBaseline(){return q(this.element,"bn-chart-structure-renderer")}async getLayoutState(t){var i,e,s,a;const r=null!==(i=null==t?void 0:t.detail)&&void 0!==i?i:"summary",n=G(this.element),o=this.getEffectiveScaleFactor(),l=Number.isFinite(o)&&o>0?o:1,c=this.componentStyle((t=>{var i;return(null===(i=t.global)||void 0===i?void 0:i.fontSizePx)||13.3333}))*l,h=this.prepareVariances(),d=X(this.element,"bn-chart-structure-renderer",this.prepareSegments().map((t=>t||"base")),n,r),p=null===(e=this.element.shadowRoot)||void 0===e?void 0:e.querySelector("bn-chart-structure-renderer"),u={version:E,tag:this.element.localName,id:V(this.element),slot:null!==(s=this.element.getAttribute("slot"))&&void 0!==s?s:void 0,rect:H(this.element,n),em:{fontSizePx:c,appliedScaleFactor:l},regions:d.regions,metadata:{title:this.chartTitle||void 0,scenarios:null!==(a=null==p?void 0:p.scenarios)&&void 0!==a?a:[],variances:h,barCount:d.barCount,hasNoData:0===d.barCount},diagnostics:J(this.element),scaling:this.resolveScalingInfo(c),baseline:d.baseline};return d.elements&&(u.elements=d.elements),u}resolveScalingInfo(t){var i,e;const s={},a=C(this.unitScaling,this.pixelPerUnitGroupMap);if("value"===a.kind)s.unitMode="fixed",s.unitsPerEm=a.value,s.unitPxPerUnit=t/a.value;else{s.unitMode="auto";const e=null===(i=this.lastAutoScalingReport)||void 0===i?void 0:i.unit;void 0!==e&&e>0&&(s.unitPxPerUnit=e,s.unitsPerEm=t/e)}const r=C(this.percentageScaling,this.pixelPerUnitGroupMap);if("value"===r.kind)s.percentageMode="fixed",s.percentagePointsPerEm=r.value,s.percentagePxPerPoint=t/r.value;else{s.percentageMode="auto";const i=null===(e=this.lastAutoScalingReport)||void 0===e?void 0:e.percentage;void 0!==i&&i>0&&(s.percentagePxPerPoint=i/100,s.percentagePointsPerEm=100*t/i)}return s}getEffectiveScaleFactor(){const{mode:t,factor:i}=M(this.scale);return"factor"===t?i:"auto"===t||"empty"===t?this.appliedScaleFactor:1}getEffectiveFontPx(){return this.componentStyle((t=>{var i;return(null===(i=t.global)||void 0===i?void 0:i.fontSizePx)||13.3333}))*this.getEffectiveScaleFactor()}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(){const t=this.prepareSegments();0===t.length?this.errors.addOrReplace({id:"WARN_scenarios_none",type:"warning",message:"scenarios: none needs at least one variance, the chart is empty."}):this.errors.remove("WARN_scenarios_none");const i=this.getFontStyles();return a(r,{key:"02236359d67ec2095ac560152cc6feaa8661834a",style:i},a("div",{key:"5eb4e74f27fb0c4c5ffd286ee266ceb51eae68bf",class:"container"},t.map(this.chartTemplate)))}get element(){return this}static get watchers(){return{filter:[{validateFilter: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}],measureScale:[{validateMeasureScale:0}],dataFormatDigitsDecimal:[{validateDataFormatDigitsDecimal:0}],dataFormatDigitsPercent:[{validateDataFormatDigitsPercent:0}],sums:[{validateSums:0}],scenarioLabelPosition:[{validateScenarioLabelPosition:0}],referenceLine:[{validateReferenceLine:0}],italicCategories:[{validateItalicCategories:0}],stack:[{validateStack:0}],scale:[{validateScaling:0}]}}static get style(){return':host(.no-data){display:block;box-sizing:border-box;width:100%;height:100%}:host(.no-data)>div{float:none;width:100%;height:100%}:host(.no-data) .no-data~.no-data{display:none}.empty-state{box-sizing:border-box;display:flex;align-items:center;justify-content:center;float:none;width:100%;height:100%;min-height:3em;margin:0;padding:0.5em;overflow:hidden;border:0.1em dashed #ddd;color:#808080;font-family:var(--bn-font-family, "Noto Sans", sans-serif);font-size:var(--bn-font-size, 13.3333px);font-style:normal;text-align:center}:host{display:inline-block;position:relative;overflow:hidden;font-family:var(--bn-font-family, "Noto Sans", sans-serif);font-size:var(--bn-font-size, 13.3333px);color:var(--bn-font-color, #000000)}.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}svg#drawCanvas{display:block}.footer{margin:0.2em;font-size:0.6em}.footer-hide{margin:0.2em;font-size:0.6em;opacity:0}'}},[1,"bn-chart-structure",{datasets:[513],selectedStyle:[513,"selected-style"],i18nNamespace:[513,"i18n-namespace"],chartTitle:[1,"chart-title"],ruleset:[513],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:[4,"show-categories"],measureScale:[1,"measure-scale"],showMeasureScale:[4,"show-measure-scale"],measureUnit:[1,"measure-unit"],dataFormatDigitsDecimal:[2,"data-format-digits-decimal"],dataFormatDigitsPercent:[2,"data-format-digits-percent"],sums:[1],sumTitle:[1,"sum-title"],scenarioLabelPosition:[1,"scenario-label-position"],referenceLine:[1,"reference-line"],italicCategories:[1,"italic-categories"],stack:[1],scale:[1],datasetName:[32],dataVersion:[32],datasetMeta:[32],appliedScaleFactor:[32],getBaseline:[64],getLayoutState:[64]},void 0,{filter:[{validateFilter: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}],measureScale:[{validateMeasureScale:0}],dataFormatDigitsDecimal:[{validateDataFormatDigitsDecimal:0}],dataFormatDigitsPercent:[{validateDataFormatDigitsPercent:0}],sums:[{validateSums:0}],scenarioLabelPosition:[{validateScenarioLabelPosition:0}],referenceLine:[{validateReferenceLine:0}],italicCategories:[{validateItalicCategories:0}],stack:[{validateStack:0}],scale:[{validateScaling:0}]}]),K=Q,tt=function(){"undefined"!=typeof customElements&&["bn-chart-structure","bn-chart-structure-renderer"].forEach((t=>{switch(t){case"bn-chart-structure":customElements.get(n(t))||customElements.define(n(t),Q);break;case"bn-chart-structure-renderer":customElements.get(n(t))||Z()}}))};export{K as BnChartStructure,tt as defineCustomElement}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{p as t,H as e,e as o,f as n,h as
|
|
1
|
+
import{p as t,H as e,e as o,f as n,h as i,d as a,t as r}from"./p-BnmylmXF.js";import{F as s}from"./p-Zz3fAPcH.js";import{S as c,e as l}from"./p-6242qMx1.js";import{L as p}from"./p-DY5fMUX8.js";import{m as u,t as h}from"./p-DdvG1D18.js";import{r as d,a as m,b,c as f}from"./p-CckAR27O.js";import{b as g}from"./p-VtNvNyZK.js";import{w as v}from"./p-BrQCbmG0.js";import{m as y}from"./p-JG4Sx1lE.js";import{w}from"./p-D32TsLzd.js";import{b as x}from"./p-DM7fwmH4.js";function S(t){if("function"==typeof getComputedStyle){const e=parseFloat(getComputedStyle(t).fontSize);if(Number.isFinite(e)&&e>0)return e}return c.global.fontSizePx}function j(t,e){var o;return{version:p,tag:t.localName,id:m(t),slot:null!==(o=t.getAttribute("slot"))&&void 0!==o?o:void 0,rect:u(t,e),em:{fontSizePx:S(t),appliedScaleFactor:1},regions:[],metadata:{},diagnostics:d(t)}}const L=new Map,P={"thin-space":" ",space:" ",none:""};function D(t){var e;let o="";for(const t of L.values())o=t.separator()||o;const n=o?null!==(e=P[o])&&void 0!==e?e:o:null;if(n!==s.groupSeparator){s.groupSeparator=n;for(const[e,o]of L)e!==t&&o.redraw()}}const N=["format","orientation","page-format","page-orientation","render-orientation","page-number"],k=(t,e,o)=>{const n=t[e];return"string"==typeof n?n:e in t?null:t.getAttribute(o)},C=t(class extends e{constructor(t){super(),!1!==t&&this.__registerHost(),this.__attachShadow(),this.bnNotationChange=o(this,"bnNotationChange",7),this.groupSeparator="",this.wasConnected=!1,this.assignedPageNumbers=new WeakMap,this.notationSubscriptions=[],v(this),this.errors=w(this)}watchGroupSeparator(){D()}setLocale(t){this.stores.context.state.locale=t}connectedCallback(){this.stores=l(this.element),this.locale&&(this.stores.context.state.locale=this.locale),L.set(this,{separator:()=>{var t;return null!==(t=this.groupSeparator)&&void 0!==t?t:""},redraw:()=>{const t=this.stores.context.state,e=t.locale;t.locale="",t.locale=e}}),D(this.wasConnected?void 0:this),this.wasConnected=!0;const t=()=>this.bnNotationChange.emit();this.notationSubscriptions=[this.stores.scalingGroups.on("set",t),this.stores.componentStyles.on("set",t)],this.syncPages(),this.pageObserver=new MutationObserver((()=>this.syncPages())),this.pageObserver.observe(this.element,{childList:!0,subtree:!0,attributes:!0,attributeFilter:N})}disconnectedCallback(){var t,e;L.delete(this),D(),this.notationSubscriptions.forEach((t=>t())),this.notationSubscriptions=[],null===(t=this.pageObserver)||void 0===t||t.disconnect(),null===(e=this.pageSizeStyle)||void 0===e||e.remove(),this.pageSizeStyle=void 0}syncPages(){const t=Array.from(this.element.querySelectorAll("bn-page, bn-layout-page"));t.forEach(((t,e)=>{const o="bn-layout-page"===t.localName?t:t.querySelector("bn-footer");if(!o)return;const n=k(o,"pageNumber","page-number");if(null!==n&&n!==this.assignedPageNumbers.get(o))return;const i=""+(e+1);this.assignedPageNumbers.set(o,i),n!==i&&o.setAttribute("page-number",i)}));const e=this.element.getAttribute("render-orientation");void 0!==this.lastRenderOrientation&&this.lastRenderOrientation!==e&&t.filter((t=>"bn-layout-page"===t.localName)).forEach((t=>n(t))),this.lastRenderOrientation=e,this.writePageSize(t[0],e)}writePageSize(t,e){var o;if(!t||document.querySelector("bn-context")!==this.element)return null===(o=this.pageSizeStyle)||void 0===o||o.remove(),void(this.pageSizeStyle=void 0);const n="bn-layout-page"===t.localName?x(k(t,"pageFormat","page-format"),k(t,"pageOrientation","page-orientation"),e):x(k(t,"format","format"),k(t,"orientation","orientation"));this.pageSizeStyle||(this.pageSizeStyle=document.createElement("style"),this.pageSizeStyle.setAttribute("data-bn-page-size",""),document.head.append(this.pageSizeStyle)),this.pageSizeStyle.textContent!==n&&(this.pageSizeStyle.textContent=n)}async getLayoutState(t){var e,o;const n=null!==(e=null==t?void 0:t.detail)&&void 0!==e?e:"summary",i=Array.from(this.element.querySelectorAll("bn-annotation-layer, bn-annotation-list, bn-body, bn-card, bn-chart-bubble, bn-chart-bullet, bn-chart-scatter, bn-chart-structure, bn-chart-time, bn-footer, bn-grid, bn-image, bn-layout-card, bn-layout-page, bn-message, bn-page, bn-table, bn-text, bn-title, bn-tree"));await Promise.all(i.map((t=>{var e,o,n;return null!==(n=null===(o=(e=t).componentOnReady)||void 0===o?void 0:o.call(e))&&void 0!==n?n:Promise.resolve()})));const a=this.element.getBoundingClientRect(),r={x:a.left,y:a.top},s=await Promise.all(i.map((async t=>{const e=t.getBoundingClientRect(),o={context:r,component:{x:e.left,y:e.top}};try{const e=t;return"function"==typeof e.getLayoutState?await e.getLayoutState({detail:n}):j(t,o)}catch(e){let n;try{n=j(t,o)}catch(e){const o={x:0,y:0,width:0,height:0};n={version:p,tag:t.localName,id:t.localName,rect:{context:Object.assign({},o),component:Object.assign({},o)},em:{fontSizePx:0,appliedScaleFactor:1},regions:[],metadata:{},diagnostics:[]}}return n.error=(e instanceof Error?e.message:e)+"",n}}))),c=b(i.map((t=>({tag:t.localName,explicitId:f(t)}))));return s.forEach(((t,e)=>{t.id=c[e]})),{version:p,generatedAt:(new Date).toISOString(),detail:n,context:{viewport:h(a),locale:null===(o=this.stores)||void 0===o?void 0:o.context.state.locale},components:s}}async getNotation(t){const e=Array.from(this.element.querySelectorAll("bn-component-style, bn-scaling-group"));return await Promise.all(e.map((t=>{var e,o;return null!==(o=null===(e=t.componentOnReady)||void 0===e?void 0:e.call(t))&&void 0!==o?o:Promise.resolve()}))),g(y(this.stores.componentStyles.state,t),this.stores.scalingGroups.state)}componentWillLoad(){}componentDidLoad(){}componentShouldUpdate(){}componentWillRender(){}componentDidRender(){}componentWillUpdate(){}componentDidUpdate(){}render(){return i(a,{key:"835bf8fe0cf78440c000ce996495c5c5c0cbbd07"},i("slot",{key:"395cbc8fdbb4f6e765d36a93a7547272e5ec7def"}))}get element(){return this}static get watchers(){return{groupSeparator:[{watchGroupSeparator:0}],locale:[{setLocale:0}]}}static get style(){return":host{display:block}"}},[257,"bn-context",{locale:[1],i18nNamespace:[513,"i18n-namespace"],renderOrientation:[513,"render-orientation"],groupSeparator:[1,"group-separator"],getLayoutState:[64],getNotation:[64]},void 0,{groupSeparator:[{watchGroupSeparator:0}],locale:[{setLocale:0}]}]),F=C,z=function(){"undefined"!=typeof customElements&&["bn-context"].forEach((t=>{"bn-context"===t&&(customElements.get(r(t))||customElements.define(r(t),C))}))};export{F as BnContext,z as defineCustomElement}
|