@oicl/openbridge-webcomponents-full-bundle 2.2.0-next.17 → 2.2.0-next.18
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/bundle/openbridge-webcomponents.bundle.js +269 -67
- package/bundle/openbridge-webcomponents.bundle.js.map +1 -1
- package/custom-elements.json +257 -14
- package/dist/building-blocks/bar-horizontal/bar-horizontal.d.ts +4 -0
- package/dist/building-blocks/bar-horizontal/bar-horizontal.d.ts.map +1 -1
- package/dist/building-blocks/bar-horizontal/bar-horizontal.js +26 -23
- package/dist/building-blocks/bar-horizontal/bar-horizontal.js.map +1 -1
- package/dist/building-blocks/bar-vertical/bar-vertical.d.ts +4 -0
- package/dist/building-blocks/bar-vertical/bar-vertical.d.ts.map +1 -1
- package/dist/building-blocks/bar-vertical/bar-vertical.js +26 -23
- package/dist/building-blocks/bar-vertical/bar-vertical.js.map +1 -1
- package/dist/building-blocks/external-scale/external-scale.d.ts +28 -1
- package/dist/building-blocks/external-scale/external-scale.d.ts.map +1 -1
- package/dist/building-blocks/external-scale/external-scale.js +30 -4
- package/dist/building-blocks/external-scale/external-scale.js.map +1 -1
- package/dist/navigation-instruments/gauge-horizontal/gauge-horizontal.d.ts +28 -17
- package/dist/navigation-instruments/gauge-horizontal/gauge-horizontal.d.ts.map +1 -1
- package/dist/navigation-instruments/gauge-horizontal/gauge-horizontal.js +91 -11
- package/dist/navigation-instruments/gauge-horizontal/gauge-horizontal.js.map +1 -1
- package/dist/navigation-instruments/gauge-vertical/gauge-vertical.d.ts +28 -17
- package/dist/navigation-instruments/gauge-vertical/gauge-vertical.d.ts.map +1 -1
- package/dist/navigation-instruments/gauge-vertical/gauge-vertical.js +91 -11
- package/dist/navigation-instruments/gauge-vertical/gauge-vertical.js.map +1 -1
- package/package.json +1 -1
- package/src/building-blocks/bar-horizontal/bar-horizontal-fixed-aspect.spec.ts +102 -0
- package/src/building-blocks/bar-horizontal/bar-horizontal.ts +28 -23
- package/src/building-blocks/bar-vertical/bar-vertical-fixed-aspect.spec.ts +101 -0
- package/src/building-blocks/bar-vertical/bar-vertical.ts +28 -23
- package/src/building-blocks/external-scale/external-scale.ts +72 -3
- package/src/navigation-instruments/gauge-horizontal/gauge-horizontal.spec.ts +288 -0
- package/src/navigation-instruments/gauge-horizontal/gauge-horizontal.stories.ts +114 -4
- package/src/navigation-instruments/gauge-horizontal/gauge-horizontal.ts +129 -41
- package/src/navigation-instruments/gauge-trend/gauge-trend.stories.ts +8 -0
- package/src/navigation-instruments/gauge-vertical/gauge-vertical.spec.ts +284 -0
- package/src/navigation-instruments/gauge-vertical/gauge-vertical.stories.ts +117 -4
- package/src/navigation-instruments/gauge-vertical/gauge-vertical.ts +129 -41
|
@@ -36054,6 +36054,16 @@ function computeExternalScaleViewBox(config, layout) {
|
|
|
36054
36054
|
};
|
|
36055
36055
|
}
|
|
36056
36056
|
/**
|
|
36057
|
+
* Compute the effective `preserveAspectRatio="xMidYMid meet"` uniform scale factor.
|
|
36058
|
+
*
|
|
36059
|
+
* Returns 1 when inputs are invalid (e.g. 0-sized viewBox).
|
|
36060
|
+
*/
|
|
36061
|
+
function computeMeetScale(viewBoxWidth, viewBoxHeight, containerWidth, containerHeight) {
|
|
36062
|
+
const widthScale = viewBoxWidth > 0 ? containerWidth / viewBoxWidth : 1;
|
|
36063
|
+
const heightScale = viewBoxHeight > 0 ? containerHeight / viewBoxHeight : 1;
|
|
36064
|
+
return Math.min(widthScale, heightScale);
|
|
36065
|
+
}
|
|
36066
|
+
/**
|
|
36057
36067
|
* Compute the scale factor for fixed aspect ratio mode.
|
|
36058
36068
|
*
|
|
36059
36069
|
* In fixed aspect ratio mode, the scale component determines its zoom level based on
|
|
@@ -36065,17 +36075,43 @@ function computeExternalScaleViewBox(config, layout) {
|
|
|
36065
36075
|
* This scale factor is applied to SVG rendering while keeping text labels at constant size
|
|
36066
36076
|
* by using the CSS variable `--scale` to counter-scale font sizes.
|
|
36067
36077
|
*
|
|
36078
|
+
* The SVG is painted with `xMidYMid meet`, which takes the smaller of the two
|
|
36079
|
+
* axes' ratios. Pass the container's cross-axis size and the drawing's
|
|
36080
|
+
* thickness so the factor follows the paint when the cross axis is the limit;
|
|
36081
|
+
* without them the main axis alone decides, as it does whenever the cross axis
|
|
36082
|
+
* has room.
|
|
36083
|
+
*
|
|
36068
36084
|
* Works for all orientations and sides:
|
|
36069
36085
|
* - Vertical scales (left/right): compare container height vs reference
|
|
36070
36086
|
* - Horizontal scales (top/bottom): compare container width vs reference
|
|
36071
36087
|
*
|
|
36072
|
-
* @param config Configuration with orientation, container
|
|
36088
|
+
* @param config Configuration with orientation, container sizes, reference size and drawing thickness
|
|
36073
36089
|
* @returns Scale factor (> 0), defaults to 1 if container size is invalid
|
|
36074
36090
|
*/
|
|
36075
36091
|
function computeFixedAspectRatioScale(config) {
|
|
36076
|
-
const { containerMainAxisSize, scaleReferenceSize } = config;
|
|
36092
|
+
const { containerMainAxisSize, scaleReferenceSize, containerCrossAxisSize, viewBoxThickness } = config;
|
|
36077
36093
|
if (containerMainAxisSize <= 0 || scaleReferenceSize <= 0) return 1;
|
|
36078
|
-
|
|
36094
|
+
const mainScale = containerMainAxisSize / scaleReferenceSize;
|
|
36095
|
+
if (containerCrossAxisSize === void 0 || containerCrossAxisSize <= 0 || viewBoxThickness === void 0 || viewBoxThickness <= 0) return mainScale;
|
|
36096
|
+
if (containerCrossAxisSize + 1 >= viewBoxThickness * mainScale) return mainScale;
|
|
36097
|
+
return config.orientation === "vertical" ? computeMeetScale(viewBoxThickness, scaleReferenceSize, containerCrossAxisSize, containerMainAxisSize) : computeMeetScale(scaleReferenceSize, viewBoxThickness, containerMainAxisSize, containerCrossAxisSize);
|
|
36098
|
+
}
|
|
36099
|
+
/**
|
|
36100
|
+
* The element's content box in CSS px: the box a `100%` × `100%` SVG child
|
|
36101
|
+
* fills, and what a ResizeObserver's `contentRect` reports. `clientWidth` /
|
|
36102
|
+
* `clientHeight` include the padding, and `getBoundingClientRect()` is scaled
|
|
36103
|
+
* by any ancestor CSS `zoom`, so neither is the box the drawing is painted in.
|
|
36104
|
+
*
|
|
36105
|
+
* @param el The host element
|
|
36106
|
+
* @returns Content width and height in CSS px, 0 × 0 while the element has no layout box
|
|
36107
|
+
*/
|
|
36108
|
+
function readContentBox(el) {
|
|
36109
|
+
const style = getComputedStyle(el);
|
|
36110
|
+
const px = (value) => parseFloat(value) || 0;
|
|
36111
|
+
return {
|
|
36112
|
+
width: el.clientWidth - px(style.paddingLeft) - px(style.paddingRight),
|
|
36113
|
+
height: el.clientHeight - px(style.paddingTop) - px(style.paddingBottom)
|
|
36114
|
+
};
|
|
36079
36115
|
}
|
|
36080
36116
|
/**
|
|
36081
36117
|
* Compute a minimal viewBox layout for an external scale.
|
|
@@ -39712,15 +39748,17 @@ var ObcBarVertical = class ObcBarVertical extends AdviceMixin(SetpointMixin(i$4,
|
|
|
39712
39748
|
this.fixedAspectRatio = false;
|
|
39713
39749
|
this.scaleReferenceSize = 384;
|
|
39714
39750
|
this._scale = 1;
|
|
39751
|
+
this._viewBoxThickness = 0;
|
|
39715
39752
|
this._resizeController = new h(this, { callback: (entries) => {
|
|
39716
39753
|
if (!this.fixedAspectRatio) return;
|
|
39717
39754
|
const entry = entries[0];
|
|
39718
39755
|
if (!entry) return;
|
|
39719
|
-
const containerMainAxisSize = entry.contentRect.height;
|
|
39720
39756
|
this._scale = computeFixedAspectRatioScale({
|
|
39721
39757
|
orientation: ExternalScaleOrientation.vertical,
|
|
39722
|
-
containerMainAxisSize,
|
|
39723
|
-
|
|
39758
|
+
containerMainAxisSize: entry.contentRect.height,
|
|
39759
|
+
containerCrossAxisSize: entry.contentRect.width,
|
|
39760
|
+
scaleReferenceSize: this.scaleReferenceSize,
|
|
39761
|
+
viewBoxThickness: this._viewBoxThickness
|
|
39724
39762
|
});
|
|
39725
39763
|
this.reportDimensions();
|
|
39726
39764
|
} });
|
|
@@ -39809,6 +39847,7 @@ var ObcBarVertical = class ObcBarVertical extends AdviceMixin(SetpointMixin(i$4,
|
|
|
39809
39847
|
highlightCurrentValue: this.highlightCurrentValue
|
|
39810
39848
|
};
|
|
39811
39849
|
const layout = computeExternalScaleLayout(toExternalScaleLayoutConfig(config));
|
|
39850
|
+
this._viewBoxThickness = layout.thickness;
|
|
39812
39851
|
const parts = renderExternalScale(config);
|
|
39813
39852
|
const viewBox = computeExternalScaleViewBox({
|
|
39814
39853
|
orientation: config.orientation,
|
|
@@ -39844,7 +39883,10 @@ var ObcBarVertical = class ObcBarVertical extends AdviceMixin(SetpointMixin(i$4,
|
|
|
39844
39883
|
}
|
|
39845
39884
|
if (changed.has("scaleReferenceSize") && this.fixedAspectRatio) this._updateScaleFromCurrentSize();
|
|
39846
39885
|
const layoutChanged = changed.has("side") || changed.has("showLabels") || changed.has("showMainTickmarkLabels") || changed.has("hasScale") || changed.has("hasBar") || changed.has("barThickness") || changed.has("tickThickness") || changed.has("labelThickness") || changed.has("scaleType") || changed.has("borderRadiusPosition") || changed.has("borderRadius") || changed.has("advices") || changed.has("advicePosition") || this.setpointPresenceChanged(changed);
|
|
39847
|
-
if (!this.fixedAspectRatio || layoutChanged)
|
|
39886
|
+
if (!this.fixedAspectRatio || layoutChanged) {
|
|
39887
|
+
if (this.fixedAspectRatio) this._measureScale();
|
|
39888
|
+
this.reportDimensions();
|
|
39889
|
+
}
|
|
39848
39890
|
}
|
|
39849
39891
|
/**
|
|
39850
39892
|
* Report scale dimensions to parent chart component.
|
|
@@ -39923,19 +39965,26 @@ var ObcBarVertical = class ObcBarVertical extends AdviceMixin(SetpointMixin(i$4,
|
|
|
39923
39965
|
this.style.height = "";
|
|
39924
39966
|
this.style.width = "";
|
|
39925
39967
|
}
|
|
39968
|
+
/** Reads the host's content box into the scale; false while the host has no size yet. */
|
|
39969
|
+
_measureScale() {
|
|
39970
|
+
const { width, height } = readContentBox(this);
|
|
39971
|
+
if (height <= 0) return false;
|
|
39972
|
+
this._scale = computeFixedAspectRatioScale({
|
|
39973
|
+
orientation: ExternalScaleOrientation.vertical,
|
|
39974
|
+
containerMainAxisSize: height,
|
|
39975
|
+
containerCrossAxisSize: width,
|
|
39976
|
+
scaleReferenceSize: this.scaleReferenceSize,
|
|
39977
|
+
viewBoxThickness: this._viewBoxThickness
|
|
39978
|
+
});
|
|
39979
|
+
return true;
|
|
39980
|
+
}
|
|
39926
39981
|
/**
|
|
39927
39982
|
* Calculate scale based on current element size.
|
|
39928
39983
|
* Called when fixedAspectRatio is enabled or scaleReferenceSize changes.
|
|
39929
39984
|
*/
|
|
39930
39985
|
_updateScaleFromCurrentSize() {
|
|
39931
39986
|
requestAnimationFrame(() => {
|
|
39932
|
-
|
|
39933
|
-
if (containerHeight > 0) {
|
|
39934
|
-
this._scale = computeFixedAspectRatioScale({
|
|
39935
|
-
orientation: ExternalScaleOrientation.vertical,
|
|
39936
|
-
containerMainAxisSize: containerHeight,
|
|
39937
|
-
scaleReferenceSize: this.scaleReferenceSize
|
|
39938
|
-
});
|
|
39987
|
+
if (this._measureScale()) {
|
|
39939
39988
|
this.requestUpdate();
|
|
39940
39989
|
this.reportDimensions();
|
|
39941
39990
|
}
|
|
@@ -39945,17 +39994,7 @@ var ObcBarVertical = class ObcBarVertical extends AdviceMixin(SetpointMixin(i$4,
|
|
|
39945
39994
|
if (this.instrumentMode) return;
|
|
39946
39995
|
const next = readExternalScaleBorderRadiusPx(this, this.scaleType);
|
|
39947
39996
|
if (this._computedBorderRadius !== next) this._computedBorderRadius = next;
|
|
39948
|
-
if (this.fixedAspectRatio)
|
|
39949
|
-
const rect = this.getBoundingClientRect();
|
|
39950
|
-
if (rect.height > 0) {
|
|
39951
|
-
this._scale = computeFixedAspectRatioScale({
|
|
39952
|
-
orientation: ExternalScaleOrientation.vertical,
|
|
39953
|
-
containerMainAxisSize: rect.height,
|
|
39954
|
-
scaleReferenceSize: this.scaleReferenceSize
|
|
39955
|
-
});
|
|
39956
|
-
this.reportDimensions();
|
|
39957
|
-
}
|
|
39958
|
-
}
|
|
39997
|
+
if (this.fixedAspectRatio && this._measureScale()) this.reportDimensions();
|
|
39959
39998
|
}
|
|
39960
39999
|
/**
|
|
39961
40000
|
* Get the effective border radius to use.
|
|
@@ -73943,15 +73982,17 @@ var ObcBarHorizontal = class ObcBarHorizontal extends AdviceMixin(SetpointMixin(
|
|
|
73943
73982
|
this.fixedAspectRatio = false;
|
|
73944
73983
|
this.scaleReferenceSize = 384;
|
|
73945
73984
|
this._scale = 1;
|
|
73985
|
+
this._viewBoxThickness = 0;
|
|
73946
73986
|
this._resizeController = new h(this, { callback: (entries) => {
|
|
73947
73987
|
if (!this.fixedAspectRatio) return;
|
|
73948
73988
|
const entry = entries[0];
|
|
73949
73989
|
if (!entry) return;
|
|
73950
|
-
const containerMainAxisSize = entry.contentRect.width;
|
|
73951
73990
|
this._scale = computeFixedAspectRatioScale({
|
|
73952
73991
|
orientation: ExternalScaleOrientation.horizontal,
|
|
73953
|
-
containerMainAxisSize,
|
|
73954
|
-
|
|
73992
|
+
containerMainAxisSize: entry.contentRect.width,
|
|
73993
|
+
containerCrossAxisSize: entry.contentRect.height,
|
|
73994
|
+
scaleReferenceSize: this.scaleReferenceSize,
|
|
73995
|
+
viewBoxThickness: this._viewBoxThickness
|
|
73955
73996
|
});
|
|
73956
73997
|
this.reportDimensions();
|
|
73957
73998
|
} });
|
|
@@ -74040,6 +74081,7 @@ var ObcBarHorizontal = class ObcBarHorizontal extends AdviceMixin(SetpointMixin(
|
|
|
74040
74081
|
highlightCurrentValue: this.highlightCurrentValue
|
|
74041
74082
|
};
|
|
74042
74083
|
const layout = computeExternalScaleLayout(toExternalScaleLayoutConfig(config));
|
|
74084
|
+
this._viewBoxThickness = layout.thickness;
|
|
74043
74085
|
const parts = renderExternalScale(config);
|
|
74044
74086
|
const viewBox = computeExternalScaleViewBox({
|
|
74045
74087
|
orientation: config.orientation,
|
|
@@ -74075,7 +74117,10 @@ var ObcBarHorizontal = class ObcBarHorizontal extends AdviceMixin(SetpointMixin(
|
|
|
74075
74117
|
}
|
|
74076
74118
|
if (changed.has("scaleReferenceSize") && this.fixedAspectRatio) this._updateScaleFromCurrentSize();
|
|
74077
74119
|
const layoutChanged = changed.has("side") || changed.has("showLabels") || changed.has("showMainTickmarkLabels") || changed.has("hasScale") || changed.has("hasBar") || changed.has("barThickness") || changed.has("tickThickness") || changed.has("labelThickness") || changed.has("scaleType") || changed.has("borderRadiusPosition") || changed.has("borderRadius") || changed.has("advices") || changed.has("advicePosition") || this.setpointPresenceChanged(changed);
|
|
74078
|
-
if (!this.fixedAspectRatio || layoutChanged)
|
|
74120
|
+
if (!this.fixedAspectRatio || layoutChanged) {
|
|
74121
|
+
if (this.fixedAspectRatio) this._measureScale();
|
|
74122
|
+
this.reportDimensions();
|
|
74123
|
+
}
|
|
74079
74124
|
}
|
|
74080
74125
|
/**
|
|
74081
74126
|
* Report scale dimensions to parent chart component.
|
|
@@ -74154,19 +74199,26 @@ var ObcBarHorizontal = class ObcBarHorizontal extends AdviceMixin(SetpointMixin(
|
|
|
74154
74199
|
this.style.width = "";
|
|
74155
74200
|
this.style.height = "";
|
|
74156
74201
|
}
|
|
74202
|
+
/** Reads the host's content box into the scale; false while the host has no size yet. */
|
|
74203
|
+
_measureScale() {
|
|
74204
|
+
const { width, height } = readContentBox(this);
|
|
74205
|
+
if (width <= 0) return false;
|
|
74206
|
+
this._scale = computeFixedAspectRatioScale({
|
|
74207
|
+
orientation: ExternalScaleOrientation.horizontal,
|
|
74208
|
+
containerMainAxisSize: width,
|
|
74209
|
+
containerCrossAxisSize: height,
|
|
74210
|
+
scaleReferenceSize: this.scaleReferenceSize,
|
|
74211
|
+
viewBoxThickness: this._viewBoxThickness
|
|
74212
|
+
});
|
|
74213
|
+
return true;
|
|
74214
|
+
}
|
|
74157
74215
|
/**
|
|
74158
74216
|
* Calculate scale based on current element size.
|
|
74159
74217
|
* Called when fixedAspectRatio is enabled or scaleReferenceSize changes.
|
|
74160
74218
|
*/
|
|
74161
74219
|
_updateScaleFromCurrentSize() {
|
|
74162
74220
|
requestAnimationFrame(() => {
|
|
74163
|
-
|
|
74164
|
-
if (containerWidth > 0) {
|
|
74165
|
-
this._scale = computeFixedAspectRatioScale({
|
|
74166
|
-
orientation: ExternalScaleOrientation.horizontal,
|
|
74167
|
-
containerMainAxisSize: containerWidth,
|
|
74168
|
-
scaleReferenceSize: this.scaleReferenceSize
|
|
74169
|
-
});
|
|
74221
|
+
if (this._measureScale()) {
|
|
74170
74222
|
this.requestUpdate();
|
|
74171
74223
|
this.reportDimensions();
|
|
74172
74224
|
}
|
|
@@ -74176,17 +74228,7 @@ var ObcBarHorizontal = class ObcBarHorizontal extends AdviceMixin(SetpointMixin(
|
|
|
74176
74228
|
if (this.instrumentMode) return;
|
|
74177
74229
|
const next = readExternalScaleBorderRadiusPx(this, this.scaleType);
|
|
74178
74230
|
if (this._computedBorderRadius !== next) this._computedBorderRadius = next;
|
|
74179
|
-
if (this.fixedAspectRatio)
|
|
74180
|
-
const rect = this.getBoundingClientRect();
|
|
74181
|
-
if (rect.width > 0) {
|
|
74182
|
-
this._scale = computeFixedAspectRatioScale({
|
|
74183
|
-
orientation: ExternalScaleOrientation.horizontal,
|
|
74184
|
-
containerMainAxisSize: rect.width,
|
|
74185
|
-
scaleReferenceSize: this.scaleReferenceSize
|
|
74186
|
-
});
|
|
74187
|
-
this.reportDimensions();
|
|
74188
|
-
}
|
|
74189
|
-
}
|
|
74231
|
+
if (this.fixedAspectRatio && this._measureScale()) this.reportDimensions();
|
|
74190
74232
|
}
|
|
74191
74233
|
/**
|
|
74192
74234
|
* Get the effective border radius to use.
|
|
@@ -203951,15 +203993,17 @@ var ObcGaugeHorizontal = class ObcGaugeHorizontal extends AdviceMixin(SetpointMi
|
|
|
203951
203993
|
this.fixedAspectRatio = false;
|
|
203952
203994
|
this.scaleReferenceSize = 384;
|
|
203953
203995
|
this._scale = 1;
|
|
203996
|
+
this._viewBoxThickness = 0;
|
|
203954
203997
|
this._resizeController = new h(this, { callback: (entries) => {
|
|
203955
203998
|
if (!this.fixedAspectRatio) return;
|
|
203956
203999
|
const entry = entries[0];
|
|
203957
204000
|
if (!entry) return;
|
|
203958
|
-
const containerMainAxisSize = entry.contentRect.width;
|
|
203959
204001
|
const scale = computeFixedAspectRatioScale({
|
|
203960
204002
|
orientation: ExternalScaleOrientation.horizontal,
|
|
203961
|
-
containerMainAxisSize,
|
|
203962
|
-
|
|
204003
|
+
containerMainAxisSize: entry.contentRect.width,
|
|
204004
|
+
containerCrossAxisSize: entry.contentRect.height,
|
|
204005
|
+
scaleReferenceSize: this.scaleReferenceSize,
|
|
204006
|
+
viewBoxThickness: this._viewBoxThickness
|
|
203963
204007
|
});
|
|
203964
204008
|
this._scale = scale > 0 ? scale : 1;
|
|
203965
204009
|
this.reportDimensions();
|
|
@@ -203997,10 +204041,11 @@ var ObcGaugeHorizontal = class ObcGaugeHorizontal extends AdviceMixin(SetpointMi
|
|
|
203997
204041
|
return true;
|
|
203998
204042
|
}
|
|
203999
204043
|
render() {
|
|
204044
|
+
const effectiveLength = this.fixedAspectRatio ? this.scaleReferenceSize : this.width;
|
|
204000
204045
|
const config = {
|
|
204001
204046
|
orientation: ExternalScaleOrientation.horizontal,
|
|
204002
204047
|
side: this.side,
|
|
204003
|
-
length:
|
|
204048
|
+
length: effectiveLength,
|
|
204004
204049
|
paddingStart: this.paddingLeft,
|
|
204005
204050
|
paddingEnd: this.paddingRight,
|
|
204006
204051
|
minValue: this.minValue,
|
|
@@ -204047,10 +204092,11 @@ var ObcGaugeHorizontal = class ObcGaugeHorizontal extends AdviceMixin(SetpointMi
|
|
|
204047
204092
|
highlightCurrentValue: this.highlightCurrentValue
|
|
204048
204093
|
};
|
|
204049
204094
|
const layout = computeExternalScaleLayout(toExternalScaleLayoutConfig(config));
|
|
204095
|
+
this._viewBoxThickness = layout.thickness;
|
|
204050
204096
|
const parts = renderExternalScale(config);
|
|
204051
204097
|
const viewBox = computeExternalScaleViewBox({
|
|
204052
204098
|
orientation: config.orientation,
|
|
204053
|
-
length:
|
|
204099
|
+
length: effectiveLength
|
|
204054
204100
|
}, layout);
|
|
204055
204101
|
const preserveAspectRatio = this.fixedAspectRatio ? "xMidYMid meet" : "none";
|
|
204056
204102
|
return b`
|
|
@@ -204074,12 +204120,26 @@ var ObcGaugeHorizontal = class ObcGaugeHorizontal extends AdviceMixin(SetpointMi
|
|
|
204074
204120
|
}
|
|
204075
204121
|
updated(changed) {
|
|
204076
204122
|
super.updated(changed);
|
|
204077
|
-
if (
|
|
204123
|
+
if (changed.has("fixedAspectRatio")) {
|
|
204124
|
+
if (this.fixedAspectRatio) {
|
|
204125
|
+
this._applyFixedAspectRatioStyles();
|
|
204126
|
+
this._updateScaleFromCurrentSize();
|
|
204127
|
+
} else if (changed.get("fixedAspectRatio") === true) {
|
|
204128
|
+
this._removeFixedAspectRatioStyles();
|
|
204129
|
+
this._scale = 1;
|
|
204130
|
+
}
|
|
204131
|
+
}
|
|
204132
|
+
if (changed.has("scaleReferenceSize") && this.fixedAspectRatio) this._updateScaleFromCurrentSize();
|
|
204133
|
+
if (changed.has("fixedAspectRatio") || changed.has("side") || changed.has("showLabels") || changed.has("advices") || this.setpointPresenceChanged(changed)) {
|
|
204134
|
+
if (this.fixedAspectRatio) this._measureScale();
|
|
204135
|
+
this.reportDimensions();
|
|
204136
|
+
}
|
|
204078
204137
|
}
|
|
204079
204138
|
/**
|
|
204080
204139
|
* Report scale dimensions to parent chart component.
|
|
204081
|
-
*
|
|
204082
|
-
*
|
|
204140
|
+
* When fixedAspectRatio=true, reports the actual visual (scaled) thickness
|
|
204141
|
+
* so the chart can correctly reserve space for the scale.
|
|
204142
|
+
* When fixedAspectRatio=false, reports the base/unscaled thickness.
|
|
204083
204143
|
*/
|
|
204084
204144
|
reportDimensions() {
|
|
204085
204145
|
const effectiveBarThickness = computeExternalScaleEffectiveBarThickness({
|
|
@@ -204088,7 +204148,7 @@ var ObcGaugeHorizontal = class ObcGaugeHorizontal extends AdviceMixin(SetpointMi
|
|
|
204088
204148
|
borderRadius: this.borderRadius,
|
|
204089
204149
|
scaleType: this.scaleType
|
|
204090
204150
|
});
|
|
204091
|
-
const
|
|
204151
|
+
const baseDimensions = computeScaleDimensionsForReport({
|
|
204092
204152
|
orientation: ExternalScaleOrientation.horizontal,
|
|
204093
204153
|
side: this.side,
|
|
204094
204154
|
hasBar: this.hasBar,
|
|
@@ -204097,11 +204157,15 @@ var ObcGaugeHorizontal = class ObcGaugeHorizontal extends AdviceMixin(SetpointMi
|
|
|
204097
204157
|
barThickness: effectiveBarThickness,
|
|
204098
204158
|
tickThickness: this.tickThickness,
|
|
204099
204159
|
labelThickness: this.labelThickness,
|
|
204100
|
-
length: this.width,
|
|
204160
|
+
length: this.fixedAspectRatio ? this.scaleReferenceSize : this.width,
|
|
204101
204161
|
scaleType: this.scaleType,
|
|
204102
204162
|
hasAdviceIcon: !!this.advices?.some((a) => a.showIcon),
|
|
204103
204163
|
hasSetpoint: this.setpoint !== void 0 || this.newSetpoint !== void 0 || this.departingNewSetpoint !== void 0
|
|
204104
204164
|
});
|
|
204165
|
+
const dimensions = this.fixedAspectRatio ? {
|
|
204166
|
+
...baseDimensions,
|
|
204167
|
+
thickness: Math.round(baseDimensions.thickness * this._scale)
|
|
204168
|
+
} : baseDimensions;
|
|
204105
204169
|
this.dispatchEvent(new CustomEvent("scale-dimensions-changed", {
|
|
204106
204170
|
detail: dimensions,
|
|
204107
204171
|
bubbles: true
|
|
@@ -204110,11 +204174,69 @@ var ObcGaugeHorizontal = class ObcGaugeHorizontal extends AdviceMixin(SetpointMi
|
|
|
204110
204174
|
createRenderRoot() {
|
|
204111
204175
|
return this;
|
|
204112
204176
|
}
|
|
204177
|
+
connectedCallback() {
|
|
204178
|
+
super.connectedCallback();
|
|
204179
|
+
if (this.fixedAspectRatio) this._applyFixedAspectRatioStyles();
|
|
204180
|
+
}
|
|
204181
|
+
/**
|
|
204182
|
+
* A custom element is inline by default, which gives the percentage-sized
|
|
204183
|
+
* SVG nothing to fill; in fixedAspectRatio mode the host is a block that
|
|
204184
|
+
* takes its container's width.
|
|
204185
|
+
*/
|
|
204186
|
+
_applyFixedAspectRatioStyles() {
|
|
204187
|
+
if (!this._consumerSizing) {
|
|
204188
|
+
const snapshot = (name) => [this.style.getPropertyValue(name), this.style.getPropertyPriority(name)];
|
|
204189
|
+
this._consumerSizing = {
|
|
204190
|
+
display: snapshot("display"),
|
|
204191
|
+
width: snapshot("width"),
|
|
204192
|
+
height: snapshot("height")
|
|
204193
|
+
};
|
|
204194
|
+
}
|
|
204195
|
+
this.style.display = "block";
|
|
204196
|
+
this.style.width = "100%";
|
|
204197
|
+
this.style.height = "auto";
|
|
204198
|
+
}
|
|
204199
|
+
_removeFixedAspectRatioStyles() {
|
|
204200
|
+
const saved = this._consumerSizing;
|
|
204201
|
+
this._consumerSizing = void 0;
|
|
204202
|
+
for (const name of [
|
|
204203
|
+
"display",
|
|
204204
|
+
"width",
|
|
204205
|
+
"height"
|
|
204206
|
+
]) {
|
|
204207
|
+
const [value, priority] = saved?.[name] ?? ["", ""];
|
|
204208
|
+
this.style.setProperty(name, value, priority);
|
|
204209
|
+
}
|
|
204210
|
+
}
|
|
204211
|
+
/** Reads the host's content box into the scale; false while the host has no size yet. */
|
|
204212
|
+
_measureScale() {
|
|
204213
|
+
const { width, height } = readContentBox(this);
|
|
204214
|
+
if (width <= 0) return false;
|
|
204215
|
+
this._scale = computeFixedAspectRatioScale({
|
|
204216
|
+
orientation: ExternalScaleOrientation.horizontal,
|
|
204217
|
+
containerMainAxisSize: width,
|
|
204218
|
+
containerCrossAxisSize: height,
|
|
204219
|
+
scaleReferenceSize: this.scaleReferenceSize,
|
|
204220
|
+
viewBoxThickness: this._viewBoxThickness
|
|
204221
|
+
});
|
|
204222
|
+
return true;
|
|
204223
|
+
}
|
|
204224
|
+
/** Measures once layout has settled, then reports. */
|
|
204225
|
+
_updateScaleFromCurrentSize() {
|
|
204226
|
+
requestAnimationFrame(() => {
|
|
204227
|
+
if (this._measureScale()) {
|
|
204228
|
+
this.requestUpdate();
|
|
204229
|
+
this.reportDimensions();
|
|
204230
|
+
}
|
|
204231
|
+
});
|
|
204232
|
+
}
|
|
204113
204233
|
};
|
|
204114
204234
|
__decorate([n$4({ type: Number })], ObcGaugeHorizontal.prototype, "minValue", void 0);
|
|
204115
204235
|
__decorate([n$4({ type: Number })], ObcGaugeHorizontal.prototype, "maxValue", void 0);
|
|
204116
204236
|
__decorate([n$4({ type: Boolean })], ObcGaugeHorizontal.prototype, "reverse", void 0);
|
|
204117
204237
|
__decorate([n$4({ type: String })], ObcGaugeHorizontal.prototype, "side", void 0);
|
|
204238
|
+
__decorate([n$4({ type: Boolean })], ObcGaugeHorizontal.prototype, "fixedAspectRatio", void 0);
|
|
204239
|
+
__decorate([n$4({ type: Number })], ObcGaugeHorizontal.prototype, "scaleReferenceSize", void 0);
|
|
204118
204240
|
__decorate([r$3()], ObcGaugeHorizontal.prototype, "_scale", void 0);
|
|
204119
204241
|
__decorate([n$4({
|
|
204120
204242
|
type: Boolean,
|
|
@@ -205557,15 +205679,17 @@ var ObcGaugeVertical = class ObcGaugeVertical extends AdviceMixin(SetpointMixin(
|
|
|
205557
205679
|
this.fixedAspectRatio = false;
|
|
205558
205680
|
this.scaleReferenceSize = 384;
|
|
205559
205681
|
this._scale = 1;
|
|
205682
|
+
this._viewBoxThickness = 0;
|
|
205560
205683
|
this._resizeController = new h(this, { callback: (entries) => {
|
|
205561
205684
|
if (!this.fixedAspectRatio) return;
|
|
205562
205685
|
const entry = entries[0];
|
|
205563
205686
|
if (!entry) return;
|
|
205564
|
-
const containerMainAxisSize = entry.contentRect.height;
|
|
205565
205687
|
const scale = computeFixedAspectRatioScale({
|
|
205566
205688
|
orientation: ExternalScaleOrientation.vertical,
|
|
205567
|
-
containerMainAxisSize,
|
|
205568
|
-
|
|
205689
|
+
containerMainAxisSize: entry.contentRect.height,
|
|
205690
|
+
containerCrossAxisSize: entry.contentRect.width,
|
|
205691
|
+
scaleReferenceSize: this.scaleReferenceSize,
|
|
205692
|
+
viewBoxThickness: this._viewBoxThickness
|
|
205569
205693
|
});
|
|
205570
205694
|
this._scale = scale > 0 ? scale : 1;
|
|
205571
205695
|
this.reportDimensions();
|
|
@@ -205603,10 +205727,11 @@ var ObcGaugeVertical = class ObcGaugeVertical extends AdviceMixin(SetpointMixin(
|
|
|
205603
205727
|
return true;
|
|
205604
205728
|
}
|
|
205605
205729
|
render() {
|
|
205730
|
+
const effectiveLength = this.fixedAspectRatio ? this.scaleReferenceSize : this.height;
|
|
205606
205731
|
const config = {
|
|
205607
205732
|
orientation: ExternalScaleOrientation.vertical,
|
|
205608
205733
|
side: this.side,
|
|
205609
|
-
length:
|
|
205734
|
+
length: effectiveLength,
|
|
205610
205735
|
paddingStart: this.paddingTop,
|
|
205611
205736
|
paddingEnd: this.paddingBottom,
|
|
205612
205737
|
minValue: this.minValue,
|
|
@@ -205653,10 +205778,11 @@ var ObcGaugeVertical = class ObcGaugeVertical extends AdviceMixin(SetpointMixin(
|
|
|
205653
205778
|
highlightCurrentValue: this.highlightCurrentValue
|
|
205654
205779
|
};
|
|
205655
205780
|
const layout = computeExternalScaleLayout(toExternalScaleLayoutConfig(config));
|
|
205781
|
+
this._viewBoxThickness = layout.thickness;
|
|
205656
205782
|
const parts = renderExternalScale(config);
|
|
205657
205783
|
const viewBox = computeExternalScaleViewBox({
|
|
205658
205784
|
orientation: config.orientation,
|
|
205659
|
-
length:
|
|
205785
|
+
length: effectiveLength
|
|
205660
205786
|
}, layout);
|
|
205661
205787
|
const preserveAspectRatio = this.fixedAspectRatio ? "xMidYMid meet" : "none";
|
|
205662
205788
|
return b`
|
|
@@ -205680,12 +205806,26 @@ var ObcGaugeVertical = class ObcGaugeVertical extends AdviceMixin(SetpointMixin(
|
|
|
205680
205806
|
}
|
|
205681
205807
|
updated(changed) {
|
|
205682
205808
|
super.updated(changed);
|
|
205683
|
-
if (
|
|
205809
|
+
if (changed.has("fixedAspectRatio")) {
|
|
205810
|
+
if (this.fixedAspectRatio) {
|
|
205811
|
+
this._applyFixedAspectRatioStyles();
|
|
205812
|
+
this._updateScaleFromCurrentSize();
|
|
205813
|
+
} else if (changed.get("fixedAspectRatio") === true) {
|
|
205814
|
+
this._removeFixedAspectRatioStyles();
|
|
205815
|
+
this._scale = 1;
|
|
205816
|
+
}
|
|
205817
|
+
}
|
|
205818
|
+
if (changed.has("scaleReferenceSize") && this.fixedAspectRatio) this._updateScaleFromCurrentSize();
|
|
205819
|
+
if (changed.has("fixedAspectRatio") || changed.has("side") || changed.has("showLabels") || changed.has("advices") || this.setpointPresenceChanged(changed)) {
|
|
205820
|
+
if (this.fixedAspectRatio) this._measureScale();
|
|
205821
|
+
this.reportDimensions();
|
|
205822
|
+
}
|
|
205684
205823
|
}
|
|
205685
205824
|
/**
|
|
205686
205825
|
* Report scale dimensions to parent chart component.
|
|
205687
|
-
*
|
|
205688
|
-
*
|
|
205826
|
+
* When fixedAspectRatio=true, reports the actual visual (scaled) thickness
|
|
205827
|
+
* so the chart can correctly reserve space for the scale.
|
|
205828
|
+
* When fixedAspectRatio=false, reports the base/unscaled thickness.
|
|
205689
205829
|
*/
|
|
205690
205830
|
reportDimensions() {
|
|
205691
205831
|
const effectiveBarThickness = computeExternalScaleEffectiveBarThickness({
|
|
@@ -205694,7 +205834,7 @@ var ObcGaugeVertical = class ObcGaugeVertical extends AdviceMixin(SetpointMixin(
|
|
|
205694
205834
|
borderRadius: this.borderRadius,
|
|
205695
205835
|
scaleType: this.scaleType
|
|
205696
205836
|
});
|
|
205697
|
-
const
|
|
205837
|
+
const baseDimensions = computeScaleDimensionsForReport({
|
|
205698
205838
|
orientation: ExternalScaleOrientation.vertical,
|
|
205699
205839
|
side: this.side,
|
|
205700
205840
|
hasBar: this.hasBar,
|
|
@@ -205703,11 +205843,15 @@ var ObcGaugeVertical = class ObcGaugeVertical extends AdviceMixin(SetpointMixin(
|
|
|
205703
205843
|
barThickness: effectiveBarThickness,
|
|
205704
205844
|
tickThickness: this.tickThickness,
|
|
205705
205845
|
labelThickness: this.labelThickness,
|
|
205706
|
-
length: this.height,
|
|
205846
|
+
length: this.fixedAspectRatio ? this.scaleReferenceSize : this.height,
|
|
205707
205847
|
scaleType: this.scaleType,
|
|
205708
205848
|
hasAdviceIcon: !!this.advices?.some((a) => a.showIcon),
|
|
205709
205849
|
hasSetpoint: this.setpoint !== void 0 || this.newSetpoint !== void 0 || this.departingNewSetpoint !== void 0
|
|
205710
205850
|
});
|
|
205851
|
+
const dimensions = this.fixedAspectRatio ? {
|
|
205852
|
+
...baseDimensions,
|
|
205853
|
+
thickness: Math.round(baseDimensions.thickness * this._scale)
|
|
205854
|
+
} : baseDimensions;
|
|
205711
205855
|
this.dispatchEvent(new CustomEvent("scale-dimensions-changed", {
|
|
205712
205856
|
detail: dimensions,
|
|
205713
205857
|
bubbles: true
|
|
@@ -205716,11 +205860,69 @@ var ObcGaugeVertical = class ObcGaugeVertical extends AdviceMixin(SetpointMixin(
|
|
|
205716
205860
|
createRenderRoot() {
|
|
205717
205861
|
return this;
|
|
205718
205862
|
}
|
|
205863
|
+
connectedCallback() {
|
|
205864
|
+
super.connectedCallback();
|
|
205865
|
+
if (this.fixedAspectRatio) this._applyFixedAspectRatioStyles();
|
|
205866
|
+
}
|
|
205867
|
+
/**
|
|
205868
|
+
* A custom element is inline by default, which gives the percentage-sized
|
|
205869
|
+
* SVG nothing to fill; in fixedAspectRatio mode the host is a block that
|
|
205870
|
+
* takes its container's height.
|
|
205871
|
+
*/
|
|
205872
|
+
_applyFixedAspectRatioStyles() {
|
|
205873
|
+
if (!this._consumerSizing) {
|
|
205874
|
+
const snapshot = (name) => [this.style.getPropertyValue(name), this.style.getPropertyPriority(name)];
|
|
205875
|
+
this._consumerSizing = {
|
|
205876
|
+
display: snapshot("display"),
|
|
205877
|
+
height: snapshot("height"),
|
|
205878
|
+
width: snapshot("width")
|
|
205879
|
+
};
|
|
205880
|
+
}
|
|
205881
|
+
this.style.display = "block";
|
|
205882
|
+
this.style.height = "100%";
|
|
205883
|
+
this.style.width = "auto";
|
|
205884
|
+
}
|
|
205885
|
+
_removeFixedAspectRatioStyles() {
|
|
205886
|
+
const saved = this._consumerSizing;
|
|
205887
|
+
this._consumerSizing = void 0;
|
|
205888
|
+
for (const name of [
|
|
205889
|
+
"display",
|
|
205890
|
+
"height",
|
|
205891
|
+
"width"
|
|
205892
|
+
]) {
|
|
205893
|
+
const [value, priority] = saved?.[name] ?? ["", ""];
|
|
205894
|
+
this.style.setProperty(name, value, priority);
|
|
205895
|
+
}
|
|
205896
|
+
}
|
|
205897
|
+
/** Reads the host's content box into the scale; false while the host has no size yet. */
|
|
205898
|
+
_measureScale() {
|
|
205899
|
+
const { width, height } = readContentBox(this);
|
|
205900
|
+
if (height <= 0) return false;
|
|
205901
|
+
this._scale = computeFixedAspectRatioScale({
|
|
205902
|
+
orientation: ExternalScaleOrientation.vertical,
|
|
205903
|
+
containerMainAxisSize: height,
|
|
205904
|
+
containerCrossAxisSize: width,
|
|
205905
|
+
scaleReferenceSize: this.scaleReferenceSize,
|
|
205906
|
+
viewBoxThickness: this._viewBoxThickness
|
|
205907
|
+
});
|
|
205908
|
+
return true;
|
|
205909
|
+
}
|
|
205910
|
+
/** Measures once layout has settled, then reports. */
|
|
205911
|
+
_updateScaleFromCurrentSize() {
|
|
205912
|
+
requestAnimationFrame(() => {
|
|
205913
|
+
if (this._measureScale()) {
|
|
205914
|
+
this.requestUpdate();
|
|
205915
|
+
this.reportDimensions();
|
|
205916
|
+
}
|
|
205917
|
+
});
|
|
205918
|
+
}
|
|
205719
205919
|
};
|
|
205720
205920
|
__decorate([n$4({ type: Number })], ObcGaugeVertical.prototype, "minValue", void 0);
|
|
205721
205921
|
__decorate([n$4({ type: Number })], ObcGaugeVertical.prototype, "maxValue", void 0);
|
|
205722
205922
|
__decorate([n$4({ type: Boolean })], ObcGaugeVertical.prototype, "reverse", void 0);
|
|
205723
205923
|
__decorate([n$4({ type: String })], ObcGaugeVertical.prototype, "side", void 0);
|
|
205924
|
+
__decorate([n$4({ type: Boolean })], ObcGaugeVertical.prototype, "fixedAspectRatio", void 0);
|
|
205925
|
+
__decorate([n$4({ type: Number })], ObcGaugeVertical.prototype, "scaleReferenceSize", void 0);
|
|
205724
205926
|
__decorate([r$3()], ObcGaugeVertical.prototype, "_scale", void 0);
|
|
205725
205927
|
__decorate([n$4({
|
|
205726
205928
|
type: Boolean,
|