@oicl/openbridge-webcomponents-full-bundle 2.2.0-next.16 → 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.
Files changed (68) hide show
  1. package/bundle/openbridge-webcomponents.bundle.js +442 -87
  2. package/bundle/openbridge-webcomponents.bundle.js.map +1 -1
  3. package/custom-elements.json +1970 -28
  4. package/dist/automation/analog-threeway-valve/analog-threeway-valve.d.ts +4 -4
  5. package/dist/automation/analog-threeway-valve/analog-threeway-valve.js.map +1 -1
  6. package/dist/automation/automation-button/abstract-automation-button-storybook-helpers.d.ts +20 -0
  7. package/dist/automation/automation-button/abstract-automation-button-storybook-helpers.d.ts.map +1 -1
  8. package/dist/automation/automation-button/abstract-automation-button-storybook-helpers.js +1 -0
  9. package/dist/automation/automation-button/abstract-automation-button-storybook-helpers.js.map +1 -1
  10. package/dist/automation/automation-button/abstract-automation-button.d.ts +11 -2
  11. package/dist/automation/automation-button/abstract-automation-button.d.ts.map +1 -1
  12. package/dist/automation/automation-button/abstract-automation-button.js +40 -20
  13. package/dist/automation/automation-button/abstract-automation-button.js.map +1 -1
  14. package/dist/automation/automation-button/badge-layout.d.ts +34 -0
  15. package/dist/automation/automation-button/badge-layout.d.ts.map +1 -0
  16. package/dist/automation/automation-button/badge-layout.js +64 -0
  17. package/dist/automation/automation-button/badge-layout.js.map +1 -0
  18. package/dist/automation/digital-threeway-valve/digital-threeway-valve.d.ts +4 -4
  19. package/dist/automation/digital-threeway-valve/digital-threeway-valve.js.map +1 -1
  20. package/dist/automation/electricity-battery/electricity-battery.d.ts +4 -4
  21. package/dist/automation/electricity-battery/electricity-battery.js.map +1 -1
  22. package/dist/building-blocks/bar-horizontal/bar-horizontal.d.ts +4 -0
  23. package/dist/building-blocks/bar-horizontal/bar-horizontal.d.ts.map +1 -1
  24. package/dist/building-blocks/bar-horizontal/bar-horizontal.js +26 -23
  25. package/dist/building-blocks/bar-horizontal/bar-horizontal.js.map +1 -1
  26. package/dist/building-blocks/bar-vertical/bar-vertical.d.ts +4 -0
  27. package/dist/building-blocks/bar-vertical/bar-vertical.d.ts.map +1 -1
  28. package/dist/building-blocks/bar-vertical/bar-vertical.js +26 -23
  29. package/dist/building-blocks/bar-vertical/bar-vertical.js.map +1 -1
  30. package/dist/building-blocks/external-scale/external-scale.d.ts +28 -1
  31. package/dist/building-blocks/external-scale/external-scale.d.ts.map +1 -1
  32. package/dist/building-blocks/external-scale/external-scale.js +30 -4
  33. package/dist/building-blocks/external-scale/external-scale.js.map +1 -1
  34. package/dist/internal/global-setting.d.ts +55 -0
  35. package/dist/internal/global-setting.d.ts.map +1 -0
  36. package/dist/internal/global-setting.js +86 -0
  37. package/dist/internal/global-setting.js.map +1 -0
  38. package/dist/navigation-instruments/gauge-horizontal/gauge-horizontal.d.ts +28 -17
  39. package/dist/navigation-instruments/gauge-horizontal/gauge-horizontal.d.ts.map +1 -1
  40. package/dist/navigation-instruments/gauge-horizontal/gauge-horizontal.js +91 -11
  41. package/dist/navigation-instruments/gauge-horizontal/gauge-horizontal.js.map +1 -1
  42. package/dist/navigation-instruments/gauge-vertical/gauge-vertical.d.ts +28 -17
  43. package/dist/navigation-instruments/gauge-vertical/gauge-vertical.d.ts.map +1 -1
  44. package/dist/navigation-instruments/gauge-vertical/gauge-vertical.js +91 -11
  45. package/dist/navigation-instruments/gauge-vertical/gauge-vertical.js.map +1 -1
  46. package/package.json +1 -1
  47. package/src/automation/analog-threeway-valve/analog-threeway-valve.ts +4 -4
  48. package/src/automation/automation-button/abstract-automation-button-storybook-helpers.ts +3 -0
  49. package/src/automation/automation-button/abstract-automation-button.ts +57 -23
  50. package/src/automation/automation-button/badge-layout.spec.ts +138 -0
  51. package/src/automation/automation-button/badge-layout.ts +120 -0
  52. package/src/automation/digital-threeway-valve/digital-threeway-valve.ts +4 -4
  53. package/src/automation/electricity-battery/electricity-battery.ts +4 -4
  54. package/src/automation/pump/pump.stories.ts +59 -0
  55. package/src/building-blocks/bar-horizontal/bar-horizontal-fixed-aspect.spec.ts +102 -0
  56. package/src/building-blocks/bar-horizontal/bar-horizontal.ts +28 -23
  57. package/src/building-blocks/bar-vertical/bar-vertical-fixed-aspect.spec.ts +101 -0
  58. package/src/building-blocks/bar-vertical/bar-vertical.ts +28 -23
  59. package/src/building-blocks/external-scale/external-scale.ts +72 -3
  60. package/src/internal/global-setting.spec.ts +119 -0
  61. package/src/internal/global-setting.ts +105 -0
  62. package/src/navigation-instruments/gauge-horizontal/gauge-horizontal.spec.ts +288 -0
  63. package/src/navigation-instruments/gauge-horizontal/gauge-horizontal.stories.ts +114 -4
  64. package/src/navigation-instruments/gauge-horizontal/gauge-horizontal.ts +129 -41
  65. package/src/navigation-instruments/gauge-trend/gauge-trend.stories.ts +8 -0
  66. package/src/navigation-instruments/gauge-vertical/gauge-vertical.spec.ts +284 -0
  67. package/src/navigation-instruments/gauge-vertical/gauge-vertical.stories.ts +117 -4
  68. package/src/navigation-instruments/gauge-vertical/gauge-vertical.ts +129 -41
@@ -17,7 +17,7 @@ declare const ObcGaugeVertical_base: (new (...args: any[]) => import('../../svgh
17
17
  * ---
18
18
  *
19
19
  * ### Features
20
- * - **Fixed Layout:** Height (384px), padding (32px), bar/tick/label thicknesses, and border radius are fixed for consistent gauge appearance.
20
+ * - **Fixed Layout:** Height (384px), padding (32px), bar/tick/label thicknesses, and border radius are fixed for consistent gauge appearance. 384 px is the length the design is drawn at, not a layout limit: see `fixedAspectRatio`.
21
21
  * - **Scale Configuration:**
22
22
  * - Configurable `minValue` and `maxValue` for the value range.
23
23
  * - Optional main, primary, secondary, and tertiary tickmarks at specified intervals.
@@ -31,7 +31,7 @@ declare const ObcGaugeVertical_base: (new (...args: any[]) => import('../../svgh
31
31
  * - Optional `setpoint` value displays a marker.
32
32
  * - Automatic at-setpoint detection with configurable deadband.
33
33
  * - **Advice Overlays:** Render advice ranges with different types and hinted states.
34
- * - **Fixed Aspect Ratio:** When enabled, scales the component proportionally while keeping label font-size constant.
34
+ * - **Fixed Aspect Ratio:** `fixedAspectRatio` scales the whole gauge to its container like a vector image while the label font size stays put; `scaleReferenceSize` is the container height at which it draws 1:1.
35
35
  * - **Dimension Reporting:** Dispatches `scale-dimensions-changed` events for parent chart integration.
36
36
  *
37
37
  * ---
@@ -48,7 +48,6 @@ declare const ObcGaugeVertical_base: (new (...args: any[]) => import('../../svgh
48
48
  * - `hasBar`: true
49
49
  * - `hasScale`: true
50
50
  * - `scaleBackground`: true
51
- * - `fixedAspectRatio`: true (always scales proportionally)
52
51
  *
53
52
  * ---
54
53
  *
@@ -90,6 +89,9 @@ declare const ObcGaugeVertical_base: (new (...args: any[]) => import('../../svgh
90
89
  * @property maxValue - Maximum scale value
91
90
  * @property reverse - Plot `minValue` at the top so values grow downward.
92
91
  * @property side - Which side of the chart area this scale lives on (left or right)
92
+ * @property fixedAspectRatio - Scale the whole gauge to its container like a vector image, keeping the label font size: the SVG fills the host, so size the host. Off, the gauge draws at its 384 px reference height.
93
+ * @property scaleReferenceSize - Container height at which a `fixedAspectRatio` gauge draws 1:1 with the design. A taller container enlarges the drawing proportionally, a shorter one shrinks it.
94
+ * @availableWhen scaleReferenceSize fixedAspectRatio==true
93
95
  * @property showLabels - Show numerical value labels at primary tickmarks
94
96
  * @property mainTickmarks - Array of values for main tickmarks. When undefined, no main tickmarks shown. When empty array [], defaults to [minValue, 0, maxValue].
95
97
  * @property primaryTickmarkInterval - Interval for primary (longest) tickmarks with labels
@@ -122,23 +124,17 @@ export declare class ObcGaugeVertical extends ObcGaugeVertical_base {
122
124
  private readonly paddingBottom;
123
125
  /** Which side of the chart area this scale lives on (left or right) */
124
126
  side: ExternalScaleSide;
125
- /**
126
- * When true, freezes all internal calculations and scales the entire component
127
- * proportionally (like CSS transform:scale), except label font-size remains constant.
128
- * When false (default), dimensions react to component properties.
129
- *
130
- * This property is intentionally not exposed as a public API or Storybook control.
131
- * It can be set programmatically by parent components (e.g., GaugeTrend).
132
- */
127
+ /** Scale the whole gauge to its container like a vector image, keeping the label font size: the SVG fills the host, so size the host. Off, the gauge draws at its 384 px reference height. */
133
128
  fixedAspectRatio: boolean;
134
129
  /**
135
- * Reference size for proportional scaling when fixedAspectRatio is true.
136
- * At this height, the scale renders at native 1:1 (matches Figma design).
137
- * Above this height, the scale grows proportionally; below, it shrinks.
138
- * @default 384
130
+ * Container height at which a `fixedAspectRatio` gauge draws 1:1 with the design. A taller container enlarges the drawing proportionally, a shorter one shrinks it.
131
+ *
132
+ * Available when `fixedAspectRatio==true`.
139
133
  */
140
134
  scaleReferenceSize: number;
141
135
  private _scale;
136
+ /** The drawing's width in viewBox units, kept from the last render for the scale measurement. */
137
+ private _viewBoxThickness;
142
138
  private _resizeController;
143
139
  /** Show numerical value labels at primary tickmarks */
144
140
  showLabels: boolean;
@@ -187,11 +183,26 @@ export declare class ObcGaugeVertical extends ObcGaugeVertical_base {
187
183
  updated(changed: PropertyValues): void;
188
184
  /**
189
185
  * Report scale dimensions to parent chart component.
190
- * Always reports unscaled/reference dimensions so the parent chart can apply
191
- * consistent proportional scaling in fixedAspectRatioScaling mode.
186
+ * When fixedAspectRatio=true, reports the actual visual (scaled) thickness
187
+ * so the chart can correctly reserve space for the scale.
188
+ * When fixedAspectRatio=false, reports the base/unscaled thickness.
192
189
  */
193
190
  private reportDimensions;
194
191
  protected createRenderRoot(): this;
192
+ connectedCallback(): void;
193
+ /** The inline sizing, value and priority, the consumer had before fixedAspectRatio took the host. */
194
+ private _consumerSizing?;
195
+ /**
196
+ * A custom element is inline by default, which gives the percentage-sized
197
+ * SVG nothing to fill; in fixedAspectRatio mode the host is a block that
198
+ * takes its container's height.
199
+ */
200
+ private _applyFixedAspectRatioStyles;
201
+ private _removeFixedAspectRatioStyles;
202
+ /** Reads the host's content box into the scale; false while the host has no size yet. */
203
+ private _measureScale;
204
+ /** Measures once layout has settled, then reports. */
205
+ private _updateScaleFromCurrentSize;
195
206
  }
196
207
  declare global {
197
208
  interface HTMLElementTagNameMap {
@@ -1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D,oBAAoB,CAAC,EAAE,oBAAoB,CACJ;IAEvC,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAK;IAElC,OAAO,KAAK,MAAM,GAEjB;IAED,OAAO,KAAK,eAAe,GAE1B;IAED,OAAO,KAAK,QAAQ,GAEnB;IAEyB,QAAQ,EAAE,QAAQ,CAAoB;IACtC,QAAQ,EAAE,QAAQ,CAAiB;IACnC,OAAO,CAAC,EAAE,MAAM,CAAa;IAC7B,OAAO,CAAC,EAAE,MAAM,CAAa;IAC7B,KAAK,CAAC,EAAE,MAAM,CAAa;IAE3B,KAAK,EAAE,eAAe,CAA0B;IAE1E;;;OAGG;IACwB,OAAO,UAAS;IAE3C,OAAO,CAAC,QAAQ,CAAC,cAAc,CAAwC;IAEvE,OAAO,CAAC,QAAQ,CAAC,iBAAiB,CAA6B;IAEpC,qBAAqB,UAAS;IAEhD,MAAM;IA4FN,UAAU,CAAC,OAAO,EAAE,cAAc,GAAG,IAAI;IAUzC,OAAO,CAAC,OAAO,EAAE,cAAc;IAoCxC;;;;;OAKG;IACH,OAAO,CAAC,gBAAgB;cA2CL,gBAAgB;IAI1B,iBAAiB,IAAI,IAAI;IAOlC,qGAAqG;IACrG,OAAO,CAAC,eAAe,CAAC,CAGtB;IAEF;;;;OAIG;IACH,OAAO,CAAC,4BAA4B;IAiBpC,OAAO,CAAC,6BAA6B;IASrC,yFAAyF;IACzF,OAAO,CAAC,aAAa;IAarB,sDAAsD;IACtD,OAAO,CAAC,2BAA2B;CAQpC;AAED,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,qBAAqB;QAC7B,oBAAoB,EAAE,gBAAgB,CAAC;KACxC;CACF"}
@@ -1,7 +1,7 @@
1
1
  import { customElement } from "../../decorator.js";
2
2
  import { CHART_DIMENSIONS } from "../../charthelpers/constants.js";
3
3
  import { BorderRadiusPosition, FrameStyle, InstrumentState, Priority } from "../types.js";
4
- import { AdvicePosition, ExternalScaleOrientation, ExternalScaleSide, FillMode, ScaleType, computeExternalScaleEffectiveBarThickness, computeExternalScaleLayout, computeExternalScaleViewBox, computeFixedAspectRatioScale, computeScaleDimensionsForReport, renderExternalScale, toExternalScaleLayoutConfig } from "../../building-blocks/external-scale/external-scale.js";
4
+ import { AdvicePosition, ExternalScaleOrientation, ExternalScaleSide, FillMode, ScaleType, computeExternalScaleEffectiveBarThickness, computeExternalScaleLayout, computeExternalScaleViewBox, computeFixedAspectRatioScale, computeScaleDimensionsForReport, readContentBox, renderExternalScale, toExternalScaleLayoutConfig } from "../../building-blocks/external-scale/external-scale.js";
5
5
  import { SetpointMixin } from "../../svghelpers/setpoint-mixin.js";
6
6
  import { AdviceMixin } from "../../svghelpers/advice-mixin.js";
7
7
  import { nextAdviceMaskId } from "../../svghelpers/advice.js";
@@ -23,15 +23,17 @@ var ObcGaugeVertical = class ObcGaugeVertical extends AdviceMixin(SetpointMixin(
23
23
  this.fixedAspectRatio = false;
24
24
  this.scaleReferenceSize = 384;
25
25
  this._scale = 1;
26
+ this._viewBoxThickness = 0;
26
27
  this._resizeController = new ResizeController(this, { callback: (entries) => {
27
28
  if (!this.fixedAspectRatio) return;
28
29
  const entry = entries[0];
29
30
  if (!entry) return;
30
- const containerMainAxisSize = entry.contentRect.height;
31
31
  const scale = computeFixedAspectRatioScale({
32
32
  orientation: ExternalScaleOrientation.vertical,
33
- containerMainAxisSize,
34
- scaleReferenceSize: this.scaleReferenceSize
33
+ containerMainAxisSize: entry.contentRect.height,
34
+ containerCrossAxisSize: entry.contentRect.width,
35
+ scaleReferenceSize: this.scaleReferenceSize,
36
+ viewBoxThickness: this._viewBoxThickness
35
37
  });
36
38
  this._scale = scale > 0 ? scale : 1;
37
39
  this.reportDimensions();
@@ -69,10 +71,11 @@ var ObcGaugeVertical = class ObcGaugeVertical extends AdviceMixin(SetpointMixin(
69
71
  return true;
70
72
  }
71
73
  render() {
74
+ const effectiveLength = this.fixedAspectRatio ? this.scaleReferenceSize : this.height;
72
75
  const config = {
73
76
  orientation: ExternalScaleOrientation.vertical,
74
77
  side: this.side,
75
- length: this.height,
78
+ length: effectiveLength,
76
79
  paddingStart: this.paddingTop,
77
80
  paddingEnd: this.paddingBottom,
78
81
  minValue: this.minValue,
@@ -119,10 +122,11 @@ var ObcGaugeVertical = class ObcGaugeVertical extends AdviceMixin(SetpointMixin(
119
122
  highlightCurrentValue: this.highlightCurrentValue
120
123
  };
121
124
  const layout = computeExternalScaleLayout(toExternalScaleLayoutConfig(config));
125
+ this._viewBoxThickness = layout.thickness;
122
126
  const parts = renderExternalScale(config);
123
127
  const viewBox = computeExternalScaleViewBox({
124
128
  orientation: config.orientation,
125
- length: this.height
129
+ length: effectiveLength
126
130
  }, layout);
127
131
  const preserveAspectRatio = this.fixedAspectRatio ? "xMidYMid meet" : "none";
128
132
  return html`
@@ -146,12 +150,26 @@ var ObcGaugeVertical = class ObcGaugeVertical extends AdviceMixin(SetpointMixin(
146
150
  }
147
151
  updated(changed) {
148
152
  super.updated(changed);
149
- if (!this.fixedAspectRatio && (changed.has("side") || changed.has("showLabels")) || this.setpointPresenceChanged(changed)) this.reportDimensions();
153
+ if (changed.has("fixedAspectRatio")) {
154
+ if (this.fixedAspectRatio) {
155
+ this._applyFixedAspectRatioStyles();
156
+ this._updateScaleFromCurrentSize();
157
+ } else if (changed.get("fixedAspectRatio") === true) {
158
+ this._removeFixedAspectRatioStyles();
159
+ this._scale = 1;
160
+ }
161
+ }
162
+ if (changed.has("scaleReferenceSize") && this.fixedAspectRatio) this._updateScaleFromCurrentSize();
163
+ if (changed.has("fixedAspectRatio") || changed.has("side") || changed.has("showLabels") || changed.has("advices") || this.setpointPresenceChanged(changed)) {
164
+ if (this.fixedAspectRatio) this._measureScale();
165
+ this.reportDimensions();
166
+ }
150
167
  }
151
168
  /**
152
169
  * Report scale dimensions to parent chart component.
153
- * Always reports unscaled/reference dimensions so the parent chart can apply
154
- * consistent proportional scaling in fixedAspectRatioScaling mode.
170
+ * When fixedAspectRatio=true, reports the actual visual (scaled) thickness
171
+ * so the chart can correctly reserve space for the scale.
172
+ * When fixedAspectRatio=false, reports the base/unscaled thickness.
155
173
  */
156
174
  reportDimensions() {
157
175
  const effectiveBarThickness = computeExternalScaleEffectiveBarThickness({
@@ -160,7 +178,7 @@ var ObcGaugeVertical = class ObcGaugeVertical extends AdviceMixin(SetpointMixin(
160
178
  borderRadius: this.borderRadius,
161
179
  scaleType: this.scaleType
162
180
  });
163
- const dimensions = computeScaleDimensionsForReport({
181
+ const baseDimensions = computeScaleDimensionsForReport({
164
182
  orientation: ExternalScaleOrientation.vertical,
165
183
  side: this.side,
166
184
  hasBar: this.hasBar,
@@ -169,11 +187,15 @@ var ObcGaugeVertical = class ObcGaugeVertical extends AdviceMixin(SetpointMixin(
169
187
  barThickness: effectiveBarThickness,
170
188
  tickThickness: this.tickThickness,
171
189
  labelThickness: this.labelThickness,
172
- length: this.height,
190
+ length: this.fixedAspectRatio ? this.scaleReferenceSize : this.height,
173
191
  scaleType: this.scaleType,
174
192
  hasAdviceIcon: !!this.advices?.some((a) => a.showIcon),
175
193
  hasSetpoint: this.setpoint !== void 0 || this.newSetpoint !== void 0 || this.departingNewSetpoint !== void 0
176
194
  });
195
+ const dimensions = this.fixedAspectRatio ? {
196
+ ...baseDimensions,
197
+ thickness: Math.round(baseDimensions.thickness * this._scale)
198
+ } : baseDimensions;
177
199
  this.dispatchEvent(new CustomEvent("scale-dimensions-changed", {
178
200
  detail: dimensions,
179
201
  bubbles: true
@@ -182,11 +204,69 @@ var ObcGaugeVertical = class ObcGaugeVertical extends AdviceMixin(SetpointMixin(
182
204
  createRenderRoot() {
183
205
  return this;
184
206
  }
207
+ connectedCallback() {
208
+ super.connectedCallback();
209
+ if (this.fixedAspectRatio) this._applyFixedAspectRatioStyles();
210
+ }
211
+ /**
212
+ * A custom element is inline by default, which gives the percentage-sized
213
+ * SVG nothing to fill; in fixedAspectRatio mode the host is a block that
214
+ * takes its container's height.
215
+ */
216
+ _applyFixedAspectRatioStyles() {
217
+ if (!this._consumerSizing) {
218
+ const snapshot = (name) => [this.style.getPropertyValue(name), this.style.getPropertyPriority(name)];
219
+ this._consumerSizing = {
220
+ display: snapshot("display"),
221
+ height: snapshot("height"),
222
+ width: snapshot("width")
223
+ };
224
+ }
225
+ this.style.display = "block";
226
+ this.style.height = "100%";
227
+ this.style.width = "auto";
228
+ }
229
+ _removeFixedAspectRatioStyles() {
230
+ const saved = this._consumerSizing;
231
+ this._consumerSizing = void 0;
232
+ for (const name of [
233
+ "display",
234
+ "height",
235
+ "width"
236
+ ]) {
237
+ const [value, priority] = saved?.[name] ?? ["", ""];
238
+ this.style.setProperty(name, value, priority);
239
+ }
240
+ }
241
+ /** Reads the host's content box into the scale; false while the host has no size yet. */
242
+ _measureScale() {
243
+ const { width, height } = readContentBox(this);
244
+ if (height <= 0) return false;
245
+ this._scale = computeFixedAspectRatioScale({
246
+ orientation: ExternalScaleOrientation.vertical,
247
+ containerMainAxisSize: height,
248
+ containerCrossAxisSize: width,
249
+ scaleReferenceSize: this.scaleReferenceSize,
250
+ viewBoxThickness: this._viewBoxThickness
251
+ });
252
+ return true;
253
+ }
254
+ /** Measures once layout has settled, then reports. */
255
+ _updateScaleFromCurrentSize() {
256
+ requestAnimationFrame(() => {
257
+ if (this._measureScale()) {
258
+ this.requestUpdate();
259
+ this.reportDimensions();
260
+ }
261
+ });
262
+ }
185
263
  };
186
264
  __decorate([property({ type: Number })], ObcGaugeVertical.prototype, "minValue", void 0);
187
265
  __decorate([property({ type: Number })], ObcGaugeVertical.prototype, "maxValue", void 0);
188
266
  __decorate([property({ type: Boolean })], ObcGaugeVertical.prototype, "reverse", void 0);
189
267
  __decorate([property({ type: String })], ObcGaugeVertical.prototype, "side", void 0);
268
+ __decorate([property({ type: Boolean })], ObcGaugeVertical.prototype, "fixedAspectRatio", void 0);
269
+ __decorate([property({ type: Number })], ObcGaugeVertical.prototype, "scaleReferenceSize", void 0);
190
270
  __decorate([state()], ObcGaugeVertical.prototype, "_scale", void 0);
191
271
  __decorate([property({
192
272
  type: Boolean,
@@ -1 +1 @@
1
- {"version":3,"file":"gauge-vertical.js","names":["_decorate"],"sources":["../../../src/navigation-instruments/gauge-vertical/gauge-vertical.ts"],"sourcesContent":["import {LitElement, html} from 'lit';\nimport {property, state} from 'lit/decorators.js';\nimport type {PropertyValues} from 'lit';\nimport {customElement} from '../../decorator.js';\nimport {ResizeController} from '@lit-labs/observers/resize-controller.js';\nimport {CHART_DIMENSIONS} from '../../charthelpers/constants.js';\nimport {\n InstrumentState,\n FrameStyle,\n BorderRadiusPosition,\n Priority,\n} from '../types.js';\nimport type {ExternalScaleConfig} from '../../building-blocks/external-scale/external-scale.js';\nimport {\n computeExternalScaleViewBox,\n computeFixedAspectRatioScale,\n computeExternalScaleLayout,\n renderExternalScale,\n toExternalScaleLayoutConfig,\n computeScaleDimensionsForReport,\n computeExternalScaleEffectiveBarThickness,\n ScaleType,\n FillMode,\n AdvicePosition,\n ExternalScaleOrientation,\n ExternalScaleSide,\n} from '../../building-blocks/external-scale/external-scale.js';\nimport {SetpointMixin} from '../../svghelpers/setpoint-mixin.js';\nimport {AdviceMixin} from '../../svghelpers/advice-mixin.js';\nimport {nextAdviceMaskId} from '../../svghelpers/advice.js';\n\n// Re-export shared enums for convenience\nexport {\n ScaleType,\n FillMode,\n AdvicePosition,\n FrameStyle,\n BorderRadiusPosition,\n InstrumentState,\n ExternalScaleSide,\n};\n\n/**\n * `<obc-gauge-vertical>` – A vertical gauge component with bar and scale background.\n *\n * Use `obc-gauge-vertical` when you need a standalone vertical gauge with a visible scale\n * and bar. This is ideal for displaying single values like tank levels, pressure, or\n * temperature where the scale context is always needed.\n *\n * This is the same as `obc-bar-vertical` (both use `external-scale.ts`)\n * but with several properties fixed for consistent gauge appearance.\n * Unlike `obc-bar-vertical`, this component always shows the bar and scale background.\n *\n * ---\n *\n * ### Features\n * - **Fixed Layout:** Height (384px), padding (32px), bar/tick/label thicknesses, and border radius are fixed for consistent gauge appearance.\n * - **Scale Configuration:**\n * - Configurable `minValue` and `maxValue` for the value range.\n * - Optional main, primary, secondary, and tertiary tickmarks at specified intervals.\n * - Labels shown at primary tickmark intervals (controlled via `showLabels`).\n * - **Side Positioning:** Can be placed on the `left` or `right` side via the `side` property.\n * - **Value Display:**\n * - `value` property drives the bar fill.\n * - `fillMode` controls visualization: `fill` shows bar from `fillMin` to `fillMax`; `tint` adds a marker at the `value` position.\n * - Set `priority` to `Priority.enhanced` to use the blue/enhanced color palette for bar fill and setpoint (default: `Priority.regular`).\n * - **Setpoint Marker:**\n * - Optional `setpoint` value displays a marker.\n * - Automatic at-setpoint detection with configurable deadband.\n * - **Advice Overlays:** Render advice ranges with different types and hinted states.\n * - **Fixed Aspect Ratio:** When enabled, scales the component proportionally while keeping label font-size constant.\n * - **Dimension Reporting:** Dispatches `scale-dimensions-changed` events for parent chart integration.\n *\n * ---\n *\n * ### Fixed Properties (not configurable)\n * - `height`: 384px\n * - `paddingTop`/`paddingBottom`: 32px (`CHART_DIMENSIONS.CANVAS_PADDING`)\n * - `barThickness`: 48px\n * - `tickThickness`: 24px\n * - `labelThickness`: 60px\n * - `borderRadius`: 8px (matches obc-component-size-medium)\n * - `scaleType`: regular\n * - `frameStyle`: regular\n * - `hasBar`: true\n * - `hasScale`: true\n * - `scaleBackground`: true\n * - `fixedAspectRatio`: true (always scales proportionally)\n *\n * ---\n *\n * ### Implementation\n * This is a higher fidelity implementation of the concept shown in `instrument-linear.ts`,\n * providing a complete gauge with container, scale background, tickmarks, labels, advice overlays, and setpoint marker.\n *\n * This is a thin web-component wrapper around the pure SVG building-block renderer in `external-scale.ts`.\n * It sets up the outer `<svg>`/`viewBox` for a vertical scale and delegates rendering/layout to:\n * - `computeExternalScaleLayout(...)`\n * - `renderExternalScale(config)`\n *\n * For renderer documentation see: **Building Blocks/External Scale**.\n *\n * For a version where these properties are user-configurable, see **Bars and Graphs/Bar Vertical**.\n *\n * ---\n *\n * ### Events\n * - `scale-dimensions-changed` – Fired when layout-affecting properties (`side`, `showLabels`) change, reporting dimensions to parent chart components.\n *\n * ---\n *\n * ### Example\n *\n * ```html\n * <obc-gauge-vertical\n * min-value=\"0\"\n * max-value=\"100\"\n * value=\"75\"\n * primary-tickmark-interval=\"20\"\n * secondary-tickmark-interval=\"10\"\n * setpoint=\"80\"\n * side=\"right\"\n * ></obc-gauge-vertical>\n * ```\n *\n * @property minValue - Minimum scale value\n * @property maxValue - Maximum scale value\n * @property reverse - Plot `minValue` at the top so values grow downward.\n * @property side - Which side of the chart area this scale lives on (left or right)\n * @property showLabels - Show numerical value labels at primary tickmarks\n * @property mainTickmarks - Array of values for main tickmarks. When undefined, no main tickmarks shown. When empty array [], defaults to [minValue, 0, maxValue].\n * @property primaryTickmarkInterval - Interval for primary (longest) tickmarks with labels\n * @property secondaryTickmarkInterval - Interval for secondary (medium) tickmarks\n * @property tertiaryTickmarkInterval - Interval for tertiary (shortest) tickmarks\n * @property borderRadiusPosition - Border radius position based on component layout\n * @property priority - Color priority: enhanced uses blue instrument colors for bar fill and setpoint\n * @property fillMode - Fill visualization mode: 'fill' shows bar from fillMin to fillMax; 'tint' adds a marker at the value position\n * @property fillMin - Minimum fill value (defaults to 0)\n * @property fillMax - Maximum fill value (defaults to value)\n * @property value - Current value (bar fill level)\n * @property state - Instrument state: active, loading, or off\n * @property advices - Advice/alert overlays with min, max, type, and hinted state. When undefined or empty, no advice shown.\n * @property highlightCurrentValue - When true, displays a dot indicator at the current value position.\n * The dot is rendered in the scale band, touching its inner edge (towards the chart).\n * This provides an alternative to bar fill for highlighting the current value.\n * @property focused - Earlier name for `touching`: a change to it sets `touching`, unless `touching` changes in the same update, which then wins. It is not updated from `touching`, so it does not read back the current value.\n * @fires {CustomEvent} scale-dimensions-changed - Fired when layout-affecting properties change, providing dimension info for parent chart integration. It bubbles to the chart slot the gauge sits in and does not leave the shadow root around it.\n * @stable\n */\n@customElement('obc-gauge-vertical')\nexport class ObcGaugeVertical extends AdviceMixin(\n SetpointMixin(LitElement, {\n defaultDeadband: 1,\n })\n) {\n @property({type: Number}) minValue = 0;\n @property({type: Number}) maxValue = 100;\n @property({type: Boolean}) reverse = false;\n\n private readonly height = 384;\n private readonly paddingTop = CHART_DIMENSIONS.CANVAS_PADDING;\n private readonly paddingBottom = CHART_DIMENSIONS.CANVAS_PADDING;\n\n @property({type: String}) side: ExternalScaleSide = ExternalScaleSide.right;\n\n /**\n * When true, freezes all internal calculations and scales the entire component\n * proportionally (like CSS transform:scale), except label font-size remains constant.\n * When false (default), dimensions react to component properties.\n *\n * This property is intentionally not exposed as a public API or Storybook control.\n * It can be set programmatically by parent components (e.g., GaugeTrend).\n */\n fixedAspectRatio = false;\n\n /**\n * Reference size for proportional scaling when fixedAspectRatio is true.\n * At this height, the scale renders at native 1:1 (matches Figma design).\n * Above this height, the scale grows proportionally; below, it shrinks.\n * @default 384\n */\n scaleReferenceSize = 384;\n\n @state()\n private _scale = 1;\n\n // ResizeController automatically subscribes/unsubscribes based on component lifecycle\n // @ts-expect-error - Controller is used for side effects, not accessed directly\n private _resizeController = new ResizeController(this, {\n callback: (entries) => {\n if (!this.fixedAspectRatio) return;\n\n const entry = entries[0];\n if (!entry) return;\n\n // Use the centralized function that computes scale based on reference size\n // For vertical scales, compare container height to reference size\n const containerMainAxisSize = entry.contentRect.height;\n\n const scale = computeFixedAspectRatioScale({\n orientation: ExternalScaleOrientation.vertical,\n containerMainAxisSize,\n scaleReferenceSize: this.scaleReferenceSize,\n });\n // Guard against zero-sized containers, but allow fractional scales < 1\n this._scale = scale > 0 ? scale : 1;\n\n // Report scaled dimensions to parent chart\n this.reportDimensions();\n },\n });\n\n @property({type: Boolean, attribute: false}) showLabels = true;\n private readonly barThickness = 48;\n private readonly tickThickness = 24;\n private readonly labelThickness = 60;\n\n @property({type: Array, attribute: false}) mainTickmarks?: number[] = [];\n @property({type: Number}) primaryTickmarkInterval?: number = undefined;\n @property({type: Number}) secondaryTickmarkInterval?: number = undefined;\n @property({type: Number}) tertiaryTickmarkInterval?: number = undefined;\n private readonly scaleType: ScaleType = ScaleType.regular;\n private readonly frameStyle: FrameStyle = FrameStyle.regular;\n @property({type: String, attribute: false})\n borderRadiusPosition?: BorderRadiusPosition =\n BorderRadiusPosition.innerFirstChild;\n\n private readonly borderRadius = 8;\n\n private get hasBar(): boolean {\n return true;\n }\n\n private get scaleBackground(): boolean {\n return true;\n }\n\n private get hasScale(): boolean {\n return true;\n }\n\n @property({type: String}) priority: Priority = Priority.regular;\n @property({type: String}) fillMode: FillMode = FillMode.fill;\n @property({type: Number}) fillMin?: number = undefined;\n @property({type: Number}) fillMax?: number = undefined;\n @property({type: Number}) value?: number = undefined;\n\n @property({type: String}) state: InstrumentState = InstrumentState.active;\n\n /**\n * @deprecated Use `touching` (from SetpointMixin) instead.\n * Kept for backward compatibility. Synced to `touching` in `willUpdate()`.\n */\n @property({type: Boolean}) focused = false;\n\n private readonly advicePosition: AdvicePosition = AdvicePosition.inner;\n // Mask ids are document-scoped, so each gauge names its own.\n private readonly _adviceMaskPrefix = nextAdviceMaskId('gauge');\n\n @property({type: Boolean}) highlightCurrentValue = false;\n\n override render() {\n const config: ExternalScaleConfig = {\n orientation: ExternalScaleOrientation.vertical,\n side: this.side,\n length: this.height,\n paddingStart: this.paddingTop,\n paddingEnd: this.paddingBottom,\n minValue: this.minValue,\n maxValue: this.maxValue,\n reverse: this.reverse,\n hasScale: this.hasScale,\n labels: this.showLabels,\n hasBar: this.hasBar,\n scaleBackground: this.scaleBackground,\n barThickness: this.barThickness,\n tickThickness: this.tickThickness,\n labelThickness: this.labelThickness,\n mainTickmarks: this.mainTickmarks,\n primaryTickmarkInterval: this.primaryTickmarkInterval,\n secondaryTickmarkInterval: this.secondaryTickmarkInterval,\n tertiaryTickmarkInterval: this.tertiaryTickmarkInterval,\n scaleType: this.scaleType,\n frameStyle: this.frameStyle,\n borderRadiusPosition: this.borderRadiusPosition,\n borderRadius: this.borderRadius,\n priority: this.priority,\n fillMode: this.fillMode,\n fillMin: this.fillMin,\n fillMax: this.fillMax,\n value: this.value,\n setpoint: this.setpoint,\n newSetpoint: this.newSetpoint,\n atSetpoint: this.atSetpoint,\n autoAtSetpoint: this.autoAtSetpoint,\n autoAtSetpointDeadband: this.autoAtSetpointDeadband,\n setpointAtZeroDeadband: this.setpointAtZeroDeadband,\n animateSetpoint: this.animateSetpoint,\n departingNewSetpoint: this.departingNewSetpoint,\n state: this.state,\n touching: this.touching,\n setpointOverride: this.setpointOverride,\n advicePosition: this.advicePosition,\n advices: this.advices,\n adviceTrigger: this.adviceTrigger,\n adviceEmphasis: this.adviceEmphasis,\n adviceMaskPrefix: this._adviceMaskPrefix,\n fixedAspectRatio: this.fixedAspectRatio,\n // Gauges are always in instrument mode - they use fixed borderRadius (8px)\n // and don't respond to .obc-component-size-* CSS classes for border radius\n instrumentMode: true,\n highlightCurrentValue: this.highlightCurrentValue,\n };\n\n const layout = computeExternalScaleLayout(\n toExternalScaleLayoutConfig(config)\n );\n\n const parts = renderExternalScale(config);\n\n const viewBox = computeExternalScaleViewBox(\n {orientation: config.orientation, length: this.height},\n layout\n );\n const preserveAspectRatio = this.fixedAspectRatio\n ? 'xMidYMid meet'\n : 'none';\n\n return html`\n <svg\n width=${this.fixedAspectRatio ? '100%' : `${viewBox.width}px`}\n height=${this.fixedAspectRatio ? '100%' : `${this.height}px`}\n viewBox=\"${viewBox.x} ${viewBox.y} ${viewBox.width} ${viewBox.height}\"\n preserveAspectRatio=\"${preserveAspectRatio}\"\n style=\"--scale: ${\n this.fixedAspectRatio ? this._scale : 1\n }; display: block;\"\n part=\"svg\"\n >\n ${parts.barContainer} ${parts.barFill} ${parts.scaleBackground}\n ${parts.tickmarks} ${parts.labels} ${parts.adviceOverlays}\n ${parts.currentValueDot} ${parts.setpoint}\n </svg>\n `;\n }\n\n override willUpdate(changed: PropertyValues): void {\n super.willUpdate(changed);\n\n // Sync deprecated alias to mixin property\n // Only sync if the alias was set and the mixin property was NOT also set.\n if (changed.has('focused') && !changed.has('touching')) {\n this.touching = this.focused;\n }\n }\n\n override updated(changed: PropertyValues) {\n super.updated(changed);\n\n // Report dimensions to parent chart\n // In fixedAspectRatio mode, we report after resize events trigger _scale updates\n // In regular mode, only emit when layout-affecting properties change\n // Setpoint presence changes the reported thickness (reserved marker band),\n // so it must re-report in both aspect-ratio modes.\n if (\n (!this.fixedAspectRatio &&\n (changed.has('side') || changed.has('showLabels'))) ||\n this.setpointPresenceChanged(changed)\n ) {\n this.reportDimensions();\n }\n }\n\n /**\n * Report scale dimensions to parent chart component.\n * Always reports unscaled/reference dimensions so the parent chart can apply\n * consistent proportional scaling in fixedAspectRatioScaling mode.\n */\n private reportDimensions() {\n const effectiveBarThickness = computeExternalScaleEffectiveBarThickness({\n hasBar: this.hasBar,\n barThickness: this.barThickness,\n borderRadius: this.borderRadius,\n scaleType: this.scaleType,\n });\n\n const baseDimensions = computeScaleDimensionsForReport({\n orientation: ExternalScaleOrientation.vertical,\n side: this.side,\n hasBar: this.hasBar,\n hasScale: this.hasScale,\n labels: this.showLabels,\n barThickness: effectiveBarThickness,\n tickThickness: this.tickThickness,\n labelThickness: this.labelThickness,\n length: this.height,\n scaleType: this.scaleType,\n hasAdviceIcon: !!this.advices?.some((a) => a.showIcon),\n hasSetpoint:\n this.setpoint !== undefined ||\n this.newSetpoint !== undefined ||\n this.departingNewSetpoint !== undefined,\n });\n\n // Always report unscaled/reference dimensions.\n // The parent chart component handles proportional scaling consistently\n // for both external scales and chart padding in fixedAspectRatioScaling mode.\n const dimensions = baseDimensions;\n\n this.dispatchEvent(\n new CustomEvent('scale-dimensions-changed', {\n detail: dimensions,\n bubbles: true,\n })\n );\n }\n\n protected override createRenderRoot() {\n return this;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'obc-gauge-vertical': ObcGaugeVertical;\n }\n}\n"],"mappings":";;;;;;;;;;;;AAsJO,IAAM,mBAAN,MAAM,yBAAyB,YACpC,cAAc,YAAY,EACxB,iBAAiB,EACnB,CAAC,CACH,CAAC,CAAC;;;EACqC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GAAA,iBAAA,WAAA,WAAA,KAAA,CAAA;AACvBA,WAAA,CAAA,SAAS,EAAC,MAAM,OAAM,CAAC,CAAA,GAAA,iBAAA,WAAA,WAAA,KAAA,CAAA;AACvBA,WAAA,CAAA,SAAS,EAAC,MAAM,OAAM,CAAC,CAAA,GAAA,iBAAA,WAAA,SAAA,KAAA,CAAA;AAEvBA,WAAA,CAAA,SAAS,EAAC,MAAM,OAAM,CAAC,CAAA,GAAA,iBAAA,WAAA,SAAA,KAAA,CAAA;AAMvBA,WAAA,CAAA,SAAS,EAAC,MAAM,QAAO,CAAC,CAAA,GAAA,iBAAA,WAAA,WAAA,KAAA,CAAA;AAMxBA,WAAA,CAAA,SAAS,EAAC,MAAM,QAAO,CAAC,CAAA,GAAA,iBAAA,WAAA,yBAAA,KAAA,CAAA;AA9G1B,mBAAAA,WAAA,CAAA,cAAc,oBAAoB,CAAA,GAAA,gBAAA"}
1
+ {"version":3,"file":"gauge-vertical.js","names":["_decorate"],"sources":["../../../src/navigation-instruments/gauge-vertical/gauge-vertical.ts"],"sourcesContent":["import {LitElement, html} from 'lit';\nimport {property, state} from 'lit/decorators.js';\nimport type {PropertyValues} from 'lit';\nimport {customElement} from '../../decorator.js';\nimport {ResizeController} from '@lit-labs/observers/resize-controller.js';\nimport {CHART_DIMENSIONS} from '../../charthelpers/constants.js';\nimport {\n InstrumentState,\n FrameStyle,\n BorderRadiusPosition,\n Priority,\n} from '../types.js';\nimport type {ExternalScaleConfig} from '../../building-blocks/external-scale/external-scale.js';\nimport {\n computeExternalScaleViewBox,\n computeFixedAspectRatioScale,\n computeExternalScaleLayout,\n renderExternalScale,\n toExternalScaleLayoutConfig,\n computeScaleDimensionsForReport,\n computeExternalScaleEffectiveBarThickness,\n readContentBox,\n ScaleType,\n FillMode,\n AdvicePosition,\n ExternalScaleOrientation,\n ExternalScaleSide,\n} from '../../building-blocks/external-scale/external-scale.js';\nimport {SetpointMixin} from '../../svghelpers/setpoint-mixin.js';\nimport {AdviceMixin} from '../../svghelpers/advice-mixin.js';\nimport {nextAdviceMaskId} from '../../svghelpers/advice.js';\n\n// Re-export shared enums for convenience\nexport {\n ScaleType,\n FillMode,\n AdvicePosition,\n FrameStyle,\n BorderRadiusPosition,\n InstrumentState,\n ExternalScaleSide,\n};\n\n/**\n * `<obc-gauge-vertical>` – A vertical gauge component with bar and scale background.\n *\n * Use `obc-gauge-vertical` when you need a standalone vertical gauge with a visible scale\n * and bar. This is ideal for displaying single values like tank levels, pressure, or\n * temperature where the scale context is always needed.\n *\n * This is the same as `obc-bar-vertical` (both use `external-scale.ts`)\n * but with several properties fixed for consistent gauge appearance.\n * Unlike `obc-bar-vertical`, this component always shows the bar and scale background.\n *\n * ---\n *\n * ### Features\n * - **Fixed Layout:** Height (384px), padding (32px), bar/tick/label thicknesses, and border radius are fixed for consistent gauge appearance. 384 px is the length the design is drawn at, not a layout limit: see `fixedAspectRatio`.\n * - **Scale Configuration:**\n * - Configurable `minValue` and `maxValue` for the value range.\n * - Optional main, primary, secondary, and tertiary tickmarks at specified intervals.\n * - Labels shown at primary tickmark intervals (controlled via `showLabels`).\n * - **Side Positioning:** Can be placed on the `left` or `right` side via the `side` property.\n * - **Value Display:**\n * - `value` property drives the bar fill.\n * - `fillMode` controls visualization: `fill` shows bar from `fillMin` to `fillMax`; `tint` adds a marker at the `value` position.\n * - Set `priority` to `Priority.enhanced` to use the blue/enhanced color palette for bar fill and setpoint (default: `Priority.regular`).\n * - **Setpoint Marker:**\n * - Optional `setpoint` value displays a marker.\n * - Automatic at-setpoint detection with configurable deadband.\n * - **Advice Overlays:** Render advice ranges with different types and hinted states.\n * - **Fixed Aspect Ratio:** `fixedAspectRatio` scales the whole gauge to its container like a vector image while the label font size stays put; `scaleReferenceSize` is the container height at which it draws 1:1.\n * - **Dimension Reporting:** Dispatches `scale-dimensions-changed` events for parent chart integration.\n *\n * ---\n *\n * ### Fixed Properties (not configurable)\n * - `height`: 384px\n * - `paddingTop`/`paddingBottom`: 32px (`CHART_DIMENSIONS.CANVAS_PADDING`)\n * - `barThickness`: 48px\n * - `tickThickness`: 24px\n * - `labelThickness`: 60px\n * - `borderRadius`: 8px (matches obc-component-size-medium)\n * - `scaleType`: regular\n * - `frameStyle`: regular\n * - `hasBar`: true\n * - `hasScale`: true\n * - `scaleBackground`: true\n *\n * ---\n *\n * ### Implementation\n * This is a higher fidelity implementation of the concept shown in `instrument-linear.ts`,\n * providing a complete gauge with container, scale background, tickmarks, labels, advice overlays, and setpoint marker.\n *\n * This is a thin web-component wrapper around the pure SVG building-block renderer in `external-scale.ts`.\n * It sets up the outer `<svg>`/`viewBox` for a vertical scale and delegates rendering/layout to:\n * - `computeExternalScaleLayout(...)`\n * - `renderExternalScale(config)`\n *\n * For renderer documentation see: **Building Blocks/External Scale**.\n *\n * For a version where these properties are user-configurable, see **Bars and Graphs/Bar Vertical**.\n *\n * ---\n *\n * ### Events\n * - `scale-dimensions-changed` – Fired when layout-affecting properties (`side`, `showLabels`) change, reporting dimensions to parent chart components.\n *\n * ---\n *\n * ### Example\n *\n * ```html\n * <obc-gauge-vertical\n * min-value=\"0\"\n * max-value=\"100\"\n * value=\"75\"\n * primary-tickmark-interval=\"20\"\n * secondary-tickmark-interval=\"10\"\n * setpoint=\"80\"\n * side=\"right\"\n * ></obc-gauge-vertical>\n * ```\n *\n * @property minValue - Minimum scale value\n * @property maxValue - Maximum scale value\n * @property reverse - Plot `minValue` at the top so values grow downward.\n * @property side - Which side of the chart area this scale lives on (left or right)\n * @property fixedAspectRatio - Scale the whole gauge to its container like a vector image, keeping the label font size: the SVG fills the host, so size the host. Off, the gauge draws at its 384 px reference height.\n * @property scaleReferenceSize - Container height at which a `fixedAspectRatio` gauge draws 1:1 with the design. A taller container enlarges the drawing proportionally, a shorter one shrinks it.\n * @availableWhen scaleReferenceSize fixedAspectRatio==true\n * @property showLabels - Show numerical value labels at primary tickmarks\n * @property mainTickmarks - Array of values for main tickmarks. When undefined, no main tickmarks shown. When empty array [], defaults to [minValue, 0, maxValue].\n * @property primaryTickmarkInterval - Interval for primary (longest) tickmarks with labels\n * @property secondaryTickmarkInterval - Interval for secondary (medium) tickmarks\n * @property tertiaryTickmarkInterval - Interval for tertiary (shortest) tickmarks\n * @property borderRadiusPosition - Border radius position based on component layout\n * @property priority - Color priority: enhanced uses blue instrument colors for bar fill and setpoint\n * @property fillMode - Fill visualization mode: 'fill' shows bar from fillMin to fillMax; 'tint' adds a marker at the value position\n * @property fillMin - Minimum fill value (defaults to 0)\n * @property fillMax - Maximum fill value (defaults to value)\n * @property value - Current value (bar fill level)\n * @property state - Instrument state: active, loading, or off\n * @property advices - Advice/alert overlays with min, max, type, and hinted state. When undefined or empty, no advice shown.\n * @property highlightCurrentValue - When true, displays a dot indicator at the current value position.\n * The dot is rendered in the scale band, touching its inner edge (towards the chart).\n * This provides an alternative to bar fill for highlighting the current value.\n * @property focused - Earlier name for `touching`: a change to it sets `touching`, unless `touching` changes in the same update, which then wins. It is not updated from `touching`, so it does not read back the current value.\n * @fires {CustomEvent} scale-dimensions-changed - Fired when layout-affecting properties change, providing dimension info for parent chart integration. It bubbles to the chart slot the gauge sits in and does not leave the shadow root around it.\n * @stable\n */\n@customElement('obc-gauge-vertical')\nexport class ObcGaugeVertical extends AdviceMixin(\n SetpointMixin(LitElement, {\n defaultDeadband: 1,\n })\n) {\n @property({type: Number}) minValue = 0;\n @property({type: Number}) maxValue = 100;\n @property({type: Boolean}) reverse = false;\n\n private readonly height = 384;\n private readonly paddingTop = CHART_DIMENSIONS.CANVAS_PADDING;\n private readonly paddingBottom = CHART_DIMENSIONS.CANVAS_PADDING;\n\n @property({type: String}) side: ExternalScaleSide = ExternalScaleSide.right;\n\n @property({type: Boolean}) fixedAspectRatio = false;\n @property({type: Number}) scaleReferenceSize = 384;\n\n @state()\n private _scale = 1;\n\n /** The drawing's width in viewBox units, kept from the last render for the scale measurement. */\n private _viewBoxThickness = 0;\n\n // ResizeController automatically subscribes/unsubscribes based on component lifecycle\n // @ts-expect-error - Controller is used for side effects, not accessed directly\n private _resizeController = new ResizeController(this, {\n callback: (entries) => {\n if (!this.fixedAspectRatio) return;\n\n const entry = entries[0];\n if (!entry) return;\n\n const scale = computeFixedAspectRatioScale({\n orientation: ExternalScaleOrientation.vertical,\n containerMainAxisSize: entry.contentRect.height,\n containerCrossAxisSize: entry.contentRect.width,\n scaleReferenceSize: this.scaleReferenceSize,\n viewBoxThickness: this._viewBoxThickness,\n });\n // Guard against zero-sized containers, but allow fractional scales < 1\n this._scale = scale > 0 ? scale : 1;\n\n // Report scaled dimensions to parent chart\n this.reportDimensions();\n },\n });\n\n @property({type: Boolean, attribute: false}) showLabels = true;\n private readonly barThickness = 48;\n private readonly tickThickness = 24;\n private readonly labelThickness = 60;\n\n @property({type: Array, attribute: false}) mainTickmarks?: number[] = [];\n @property({type: Number}) primaryTickmarkInterval?: number = undefined;\n @property({type: Number}) secondaryTickmarkInterval?: number = undefined;\n @property({type: Number}) tertiaryTickmarkInterval?: number = undefined;\n private readonly scaleType: ScaleType = ScaleType.regular;\n private readonly frameStyle: FrameStyle = FrameStyle.regular;\n @property({type: String, attribute: false})\n borderRadiusPosition?: BorderRadiusPosition =\n BorderRadiusPosition.innerFirstChild;\n\n private readonly borderRadius = 8;\n\n private get hasBar(): boolean {\n return true;\n }\n\n private get scaleBackground(): boolean {\n return true;\n }\n\n private get hasScale(): boolean {\n return true;\n }\n\n @property({type: String}) priority: Priority = Priority.regular;\n @property({type: String}) fillMode: FillMode = FillMode.fill;\n @property({type: Number}) fillMin?: number = undefined;\n @property({type: Number}) fillMax?: number = undefined;\n @property({type: Number}) value?: number = undefined;\n\n @property({type: String}) state: InstrumentState = InstrumentState.active;\n\n /**\n * @deprecated Use `touching` (from SetpointMixin) instead.\n * Kept for backward compatibility. Synced to `touching` in `willUpdate()`.\n */\n @property({type: Boolean}) focused = false;\n\n private readonly advicePosition: AdvicePosition = AdvicePosition.inner;\n // Mask ids are document-scoped, so each gauge names its own.\n private readonly _adviceMaskPrefix = nextAdviceMaskId('gauge');\n\n @property({type: Boolean}) highlightCurrentValue = false;\n\n override render() {\n // A chart pushes its own height to a slotted scale; in fixedAspectRatio\n // mode the drawing keeps its reference length and the SVG scales it.\n const effectiveLength = this.fixedAspectRatio\n ? this.scaleReferenceSize\n : this.height;\n\n const config: ExternalScaleConfig = {\n orientation: ExternalScaleOrientation.vertical,\n side: this.side,\n length: effectiveLength,\n paddingStart: this.paddingTop,\n paddingEnd: this.paddingBottom,\n minValue: this.minValue,\n maxValue: this.maxValue,\n reverse: this.reverse,\n hasScale: this.hasScale,\n labels: this.showLabels,\n hasBar: this.hasBar,\n scaleBackground: this.scaleBackground,\n barThickness: this.barThickness,\n tickThickness: this.tickThickness,\n labelThickness: this.labelThickness,\n mainTickmarks: this.mainTickmarks,\n primaryTickmarkInterval: this.primaryTickmarkInterval,\n secondaryTickmarkInterval: this.secondaryTickmarkInterval,\n tertiaryTickmarkInterval: this.tertiaryTickmarkInterval,\n scaleType: this.scaleType,\n frameStyle: this.frameStyle,\n borderRadiusPosition: this.borderRadiusPosition,\n borderRadius: this.borderRadius,\n priority: this.priority,\n fillMode: this.fillMode,\n fillMin: this.fillMin,\n fillMax: this.fillMax,\n value: this.value,\n setpoint: this.setpoint,\n newSetpoint: this.newSetpoint,\n atSetpoint: this.atSetpoint,\n autoAtSetpoint: this.autoAtSetpoint,\n autoAtSetpointDeadband: this.autoAtSetpointDeadband,\n setpointAtZeroDeadband: this.setpointAtZeroDeadband,\n animateSetpoint: this.animateSetpoint,\n departingNewSetpoint: this.departingNewSetpoint,\n state: this.state,\n touching: this.touching,\n setpointOverride: this.setpointOverride,\n advicePosition: this.advicePosition,\n advices: this.advices,\n adviceTrigger: this.adviceTrigger,\n adviceEmphasis: this.adviceEmphasis,\n adviceMaskPrefix: this._adviceMaskPrefix,\n fixedAspectRatio: this.fixedAspectRatio,\n // Gauges are always in instrument mode - they use fixed borderRadius (8px)\n // and don't respond to .obc-component-size-* CSS classes for border radius\n instrumentMode: true,\n highlightCurrentValue: this.highlightCurrentValue,\n };\n\n const layout = computeExternalScaleLayout(\n toExternalScaleLayoutConfig(config)\n );\n this._viewBoxThickness = layout.thickness;\n\n const parts = renderExternalScale(config);\n\n const viewBox = computeExternalScaleViewBox(\n {orientation: config.orientation, length: effectiveLength},\n layout\n );\n const preserveAspectRatio = this.fixedAspectRatio\n ? 'xMidYMid meet'\n : 'none';\n\n return html`\n <svg\n width=${this.fixedAspectRatio ? '100%' : `${viewBox.width}px`}\n height=${this.fixedAspectRatio ? '100%' : `${this.height}px`}\n viewBox=\"${viewBox.x} ${viewBox.y} ${viewBox.width} ${viewBox.height}\"\n preserveAspectRatio=\"${preserveAspectRatio}\"\n style=\"--scale: ${\n this.fixedAspectRatio ? this._scale : 1\n }; display: block;\"\n part=\"svg\"\n >\n ${parts.barContainer} ${parts.barFill} ${parts.scaleBackground}\n ${parts.tickmarks} ${parts.labels} ${parts.adviceOverlays}\n ${parts.currentValueDot} ${parts.setpoint}\n </svg>\n `;\n }\n\n override willUpdate(changed: PropertyValues): void {\n super.willUpdate(changed);\n\n // Sync deprecated alias to mixin property\n // Only sync if the alias was set and the mixin property was NOT also set.\n if (changed.has('focused') && !changed.has('touching')) {\n this.touching = this.focused;\n }\n }\n\n override updated(changed: PropertyValues) {\n super.updated(changed);\n\n // Only the styles this element applied are removed: the first update\n // lists every property, and a consumer's inline style is theirs.\n if (changed.has('fixedAspectRatio')) {\n if (this.fixedAspectRatio) {\n this._applyFixedAspectRatioStyles();\n this._updateScaleFromCurrentSize();\n } else if (changed.get('fixedAspectRatio') === true) {\n this._removeFixedAspectRatioStyles();\n this._scale = 1;\n }\n }\n\n if (changed.has('scaleReferenceSize') && this.fixedAspectRatio) {\n this._updateScaleFromCurrentSize();\n }\n\n // The reported thickness follows the bands, the advice icons, the\n // setpoint marker band and the mode, whichever mode is on; a resize\n // re-reports through the ResizeController.\n if (\n changed.has('fixedAspectRatio') ||\n changed.has('side') ||\n changed.has('showLabels') ||\n changed.has('advices') ||\n this.setpointPresenceChanged(changed)\n ) {\n // A thinner or thicker drawing under the same box changes the painted\n // scale without a resize event.\n if (this.fixedAspectRatio) this._measureScale();\n this.reportDimensions();\n }\n }\n\n /**\n * Report scale dimensions to parent chart component.\n * When fixedAspectRatio=true, reports the actual visual (scaled) thickness\n * so the chart can correctly reserve space for the scale.\n * When fixedAspectRatio=false, reports the base/unscaled thickness.\n */\n private reportDimensions() {\n const effectiveBarThickness = computeExternalScaleEffectiveBarThickness({\n hasBar: this.hasBar,\n barThickness: this.barThickness,\n borderRadius: this.borderRadius,\n scaleType: this.scaleType,\n });\n\n const baseDimensions = computeScaleDimensionsForReport({\n orientation: ExternalScaleOrientation.vertical,\n side: this.side,\n hasBar: this.hasBar,\n hasScale: this.hasScale,\n labels: this.showLabels,\n barThickness: effectiveBarThickness,\n tickThickness: this.tickThickness,\n labelThickness: this.labelThickness,\n length: this.fixedAspectRatio ? this.scaleReferenceSize : this.height,\n scaleType: this.scaleType,\n hasAdviceIcon: !!this.advices?.some((a) => a.showIcon),\n hasSetpoint:\n this.setpoint !== undefined ||\n this.newSetpoint !== undefined ||\n this.departingNewSetpoint !== undefined,\n });\n\n // The chart lays out in visual pixels, so a scaled drawing reports its\n // scaled thickness.\n const dimensions = this.fixedAspectRatio\n ? {\n ...baseDimensions,\n thickness: Math.round(baseDimensions.thickness * this._scale),\n }\n : baseDimensions;\n\n this.dispatchEvent(\n new CustomEvent('scale-dimensions-changed', {\n detail: dimensions,\n bubbles: true,\n })\n );\n }\n\n protected override createRenderRoot() {\n return this;\n }\n\n override connectedCallback(): void {\n super.connectedCallback();\n if (this.fixedAspectRatio) {\n this._applyFixedAspectRatioStyles();\n }\n }\n\n /** The inline sizing, value and priority, the consumer had before fixedAspectRatio took the host. */\n private _consumerSizing?: Record<\n 'display' | 'height' | 'width',\n [value: string, priority: string]\n >;\n\n /**\n * A custom element is inline by default, which gives the percentage-sized\n * SVG nothing to fill; in fixedAspectRatio mode the host is a block that\n * takes its container's height.\n */\n private _applyFixedAspectRatioStyles(): void {\n if (!this._consumerSizing) {\n const snapshot = (name: string): [string, string] => [\n this.style.getPropertyValue(name),\n this.style.getPropertyPriority(name),\n ];\n this._consumerSizing = {\n display: snapshot('display'),\n height: snapshot('height'),\n width: snapshot('width'),\n };\n }\n this.style.display = 'block';\n this.style.height = '100%';\n this.style.width = 'auto';\n }\n\n private _removeFixedAspectRatioStyles(): void {\n const saved = this._consumerSizing;\n this._consumerSizing = undefined;\n for (const name of ['display', 'height', 'width'] as const) {\n const [value, priority] = saved?.[name] ?? ['', ''];\n this.style.setProperty(name, value, priority);\n }\n }\n\n /** Reads the host's content box into the scale; false while the host has no size yet. */\n private _measureScale(): boolean {\n const {width, height} = readContentBox(this);\n if (height <= 0) return false;\n this._scale = computeFixedAspectRatioScale({\n orientation: ExternalScaleOrientation.vertical,\n containerMainAxisSize: height,\n containerCrossAxisSize: width,\n scaleReferenceSize: this.scaleReferenceSize,\n viewBoxThickness: this._viewBoxThickness,\n });\n return true;\n }\n\n /** Measures once layout has settled, then reports. */\n private _updateScaleFromCurrentSize(): void {\n requestAnimationFrame(() => {\n if (this._measureScale()) {\n this.requestUpdate();\n this.reportDimensions();\n }\n });\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'obc-gauge-vertical': ObcGaugeVertical;\n }\n}\n"],"mappings":";;;;;;;;;;;;AAyJO,IAAM,mBAAN,MAAM,yBAAyB,YACpC,cAAc,YAAY,EACxB,iBAAiB,EACnB,CAAC,CACH,CAAC,CAAC;;;EACqC,KAAA,WAAA;EACA,KAAA,WAAA;EACA,KAAA,UAAA;EAEX,KAAA,SAAA;EACI,KAAA,aAAA,iBAAiB;EACd,KAAA,gBAAA,iBAAiB;EAEE,KAAA,OAAA,kBAAkB;EAExB,KAAA,mBAAA;EACC,KAAA,qBAAA;EAG9B,KAAA,SAAA;EAGW,KAAA,oBAAA;EAIA,KAAA,oBAAA,IAAI,iBAAiB,MAAM,EACrD,WAAW,YA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AAW;AAAK,CAAC,CAAA,GAAA,iBAAA,WAAA,wBAAA,KAAA,CAAA;AAkBzCA,WAAA,CAAA,SAAS,EAAC,MAAM,OAAM,CAAC,CAAA,GAAA,iBAAA,WAAA,YAAA,KAAA,CAAA;AACvBA,WAAA,CAAA,SAAS,EAAC,MAAM,OAAM,CAAC,CAAA,GAAA,iBAAA,WAAA,YAAA,KAAA,CAAA;AACvBA,WAAA,CAAA,SAAS,EAAC,MAAM,OAAM,CAAC,CAAA,GAAA,iBAAA,WAAA,WAAA,KAAA,CAAA;AACvBA,WAAA,CAAA,SAAS,EAAC,MAAM,OAAM,CAAC,CAAA,GAAA,iBAAA,WAAA,WAAA,KAAA,CAAA;AACvBA,WAAA,CAAA,SAAS,EAAC,MAAM,OAAM,CAAC,CAAA,GAAA,iBAAA,WAAA,SAAA,KAAA,CAAA;AAEvBA,WAAA,CAAA,SAAS,EAAC,MAAM,OAAM,CAAC,CAAA,GAAA,iBAAA,WAAA,SAAA,KAAA,CAAA;AAMvBA,WAAA,CAAA,SAAS,EAAC,MAAM,QAAO,CAAC,CAAA,GAAA,iBAAA,WAAA,WAAA,KAAA,CAAA;AAMxBA,WAAA,CAAA,SAAS,EAAC,MAAM,QAAO,CAAC,CAAA,GAAA,iBAAA,WAAA,yBAAA,KAAA,CAAA;AAhG1B,mBAAAA,WAAA,CAAA,cAAc,oBAAoB,CAAA,GAAA,gBAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@oicl/openbridge-webcomponents-full-bundle",
3
- "version": "2.2.0-next.16",
3
+ "version": "2.2.0-next.18",
4
4
  "type": "module",
5
5
  "repository": {
6
6
  "type": "git",
@@ -54,10 +54,10 @@ export enum AnalogThreewayValveVariant {
54
54
  * @property orientation - Side the stem points to.
55
55
  * @property flows - Readout rows, one per flow: an optional arrow direction with either a value and optional unit (default `%`) or `open` for an `Open`/`Closed` state.
56
56
  * @property variant - Visual style of the button surround.
57
- * @slot badge-top-right - Content projected into the top-right badge position; overrides `badgeAlert`.
58
- * @slot badge-top-left - Content projected into the top-left badge position; overrides `badgeControl`.
59
- * @slot badge-bottom-left - Content projected into the bottom-left badge position; overrides `badgeInterlock`.
60
- * @slot badge-bottom-right - Content projected into the bottom-right badge position; overrides `badgeCommandLocked`.
57
+ * @slot badge-top-right - Content projected into the top-right badge position; overrides the badge `badgeLayout` puts in that corner.
58
+ * @slot badge-top-left - Content projected into the top-left badge position; overrides the badge `badgeLayout` puts in that corner.
59
+ * @slot badge-bottom-left - Content projected into the bottom-left badge position; overrides the badge `badgeLayout` puts in that corner.
60
+ * @slot badge-bottom-right - Content projected into the bottom-right badge position; overrides the badge `badgeLayout` puts in that corner.
61
61
  * @fires click - Fired when the valve is clicked.
62
62
  * @experimental
63
63
  */
@@ -47,6 +47,9 @@ export const argTypesAbstractAutomationButton = {
47
47
  options: Object.values(AutomationButtonBadgeAlert),
48
48
  control: {type: 'select'},
49
49
  },
50
+ badgeLayout: {
51
+ control: {type: 'object'},
52
+ },
50
53
  progressMode: {
51
54
  options: Object.values(CircularProgressMode),
52
55
  control: {type: 'select'},
@@ -36,6 +36,11 @@ import {AlertType} from '../../types.js';
36
36
  import '../automation-badge/automation-badge.js';
37
37
  import {ObcAutomationBadgeType} from '../automation-badge/automation-badge.js';
38
38
  import {CircularProgressMode} from '../../building-blocks/circular-progress/circular-progress.js';
39
+ import {
40
+ AutomationButtonBadgeKind,
41
+ AutomationButtonBadgeLayout,
42
+ BadgeLayoutController,
43
+ } from './badge-layout.js';
39
44
 
40
45
  export enum AutomationButtonBadgeAlert {
41
46
  None = 'none',
@@ -73,13 +78,18 @@ export enum AutomationButtonBadgeCommandLocked {
73
78
  Simulation = 'simulation',
74
79
  }
75
80
 
81
+ type BadgeCorner = keyof AutomationButtonBadgeLayout;
82
+
76
83
  /**
77
84
  * Base class for the automation device buttons.
78
85
  *
79
86
  * Renders an `<obc-automation-button>` with the shared surface every device
80
87
  * button needs: the readout stack and its status row, the alert frame, the
81
- * circular progress indicator, and the four badge corners (control, alert,
82
- * interlock, command-locked) with their slots and enum-driven fallbacks.
88
+ * circular progress indicator, and the four badge corners with their slots and
89
+ * enum-driven fallbacks. Which badge goes in which corner follows the badge
90
+ * layout (`badge-layout.ts`): control top-left, alert top-right, interlock
91
+ * bottom-left and command-locked bottom-right unless the app or `badgeLayout`
92
+ * moves them.
83
93
  *
84
94
  * ## Usage Guidelines
85
95
  *
@@ -101,6 +111,7 @@ export enum AutomationButtonBadgeCommandLocked {
101
111
  * @availableWhen alertFrameMode alert==true
102
112
  * @availableWhen showAlertCategoryIcon alert==true && alertFrameType in [SmallSideFlip, LargeSideFlip, BottomFlip, TopFlip]
103
113
  * @availableWhen showAlertIcon alert==true && alertFrameType in [LargeSideFlip, BottomFlip, TopFlip]
114
+ * @property badgeLayout - Which badge kind each corner shows, on top of the app-wide layout set with `setAutomationBadgeLayout()`. A corner left out keeps the app-wide badge, `null` leaves it empty, and a badge moved here leaves the corner it came from.
104
115
  * @property progress - Shows a progress indicator, used to indicate that an user action is in progress
105
116
  * @availableWhen progressMode progress==true
106
117
  * @availableWhen progressValue progress==true && progressMode in [determinate, progressiveIndeterminate]
@@ -144,6 +155,10 @@ export class ObcAbstractAutomationButton extends LitElement {
144
155
  AutomationButtonBadgeInterlock.None;
145
156
  @property({type: String}) badgeAlert: AutomationButtonBadgeAlert =
146
157
  AutomationButtonBadgeAlert.None;
158
+ @property({attribute: false}) badgeLayout:
159
+ AutomationButtonBadgeLayout | undefined = undefined;
160
+
161
+ private readonly _badgeLayout = new BadgeLayoutController(this);
147
162
 
148
163
  get icon(): TemplateResult {
149
164
  throw new Error('Method "icon" must be implemented in subclass');
@@ -236,20 +251,19 @@ export class ObcAbstractAutomationButton extends LitElement {
236
251
  );
237
252
  }
238
253
 
239
- private getBadgeSpacer(): boolean {
254
+ private getBadgeSpacer(
255
+ badges: Record<BadgeCorner, ObcAutomationBadgeType | null>
256
+ ): boolean {
240
257
  if (!this.showReadoutStack) {
241
258
  return false;
242
259
  }
243
260
 
244
- const topLeft =
245
- this.badgeTopLeft.length > 0 || this.getBadgeControlType() !== null;
246
- const topRight =
247
- this.badgeTopRight.length > 0 || this.getBadgeAlertType() !== null;
261
+ const topLeft = this.badgeTopLeft.length > 0 || badges.topLeft !== null;
262
+ const topRight = this.badgeTopRight.length > 0 || badges.topRight !== null;
248
263
  const bottomLeft =
249
- this.badgeBottomLeft.length > 0 || this.getBadgeInterlockType() !== null;
264
+ this.badgeBottomLeft.length > 0 || badges.bottomLeft !== null;
250
265
  const bottomRight =
251
- this.badgeBottomRight.length > 0 ||
252
- this.getBadgeCommandLockedType() !== null;
266
+ this.badgeBottomRight.length > 0 || badges.bottomRight !== null;
253
267
  if (this._readoutPosition === AutomationButtonReadoutPosition.top) {
254
268
  return topRight || topLeft;
255
269
  } else if (
@@ -270,6 +284,23 @@ export class ObcAbstractAutomationButton extends LitElement {
270
284
  this.requestUpdate();
271
285
  }
272
286
 
287
+ private getBadgeType(
288
+ kind: AutomationButtonBadgeKind | null
289
+ ): ObcAutomationBadgeType | null {
290
+ switch (kind) {
291
+ case AutomationButtonBadgeKind.Control:
292
+ return this.getBadgeControlType();
293
+ case AutomationButtonBadgeKind.Alert:
294
+ return this.getBadgeAlertType();
295
+ case AutomationButtonBadgeKind.Interlock:
296
+ return this.getBadgeInterlockType();
297
+ case AutomationButtonBadgeKind.CommandLocked:
298
+ return this.getBadgeCommandLockedType();
299
+ default:
300
+ return null;
301
+ }
302
+ }
303
+
273
304
  private getBadgeAlertType(): ObcAutomationBadgeType | null {
274
305
  if (this.badgeAlert === AutomationButtonBadgeAlert.Silence) {
275
306
  return ObcAutomationBadgeType.AlertSilenced;
@@ -341,10 +372,13 @@ export class ObcAbstractAutomationButton extends LitElement {
341
372
 
342
373
  override render() {
343
374
  const readouts: AutomationButtonReadoutStack[] = [...this.extraReadouts];
344
- const badgeAlertType = this.getBadgeAlertType();
345
- const badgeControlType = this.getBadgeControlType();
346
- const badgeInterlockType = this.getBadgeInterlockType();
347
- const badgeCommandLockedType = this.getBadgeCommandLockedType();
375
+ const layout = this._badgeLayout.resolve(this.badgeLayout);
376
+ const badges = {
377
+ topLeft: this.getBadgeType(layout.topLeft),
378
+ topRight: this.getBadgeType(layout.topRight),
379
+ bottomLeft: this.getBadgeType(layout.bottomLeft),
380
+ bottomRight: this.getBadgeType(layout.bottomRight),
381
+ };
348
382
 
349
383
  return html`<obc-automation-button
350
384
  .state=${
@@ -369,7 +403,7 @@ export class ObcAbstractAutomationButton extends LitElement {
369
403
  .variant=${this._variant}
370
404
  .direction=${this._direction}
371
405
  .orientation=${this._orientation}
372
- .hasBadgeSpacer=${this.getBadgeSpacer()}
406
+ .hasBadgeSpacer=${this.getBadgeSpacer(badges)}
373
407
  .handlePosition=${this._handlePosition}
374
408
  .static=${this.static}
375
409
  .handleSize=${this._handleSize}
@@ -384,9 +418,9 @@ export class ObcAbstractAutomationButton extends LitElement {
384
418
  @slotchange=${this.handleBadgeSlotChange}
385
419
  >
386
420
  ${
387
- badgeAlertType
421
+ badges.topRight
388
422
  ? html`<obc-automation-badge
389
- .type=${badgeAlertType}
423
+ .type=${badges.topRight}
390
424
  ></obc-automation-badge>`
391
425
  : nothing
392
426
  }
@@ -397,9 +431,9 @@ export class ObcAbstractAutomationButton extends LitElement {
397
431
  @slotchange=${this.handleBadgeSlotChange}
398
432
  >
399
433
  ${
400
- badgeControlType
434
+ badges.topLeft
401
435
  ? html`<obc-automation-badge
402
- .type=${badgeControlType}
436
+ .type=${badges.topLeft}
403
437
  ></obc-automation-badge>`
404
438
  : nothing
405
439
  }
@@ -410,9 +444,9 @@ export class ObcAbstractAutomationButton extends LitElement {
410
444
  @slotchange=${this.handleBadgeSlotChange}
411
445
  >
412
446
  ${
413
- badgeInterlockType
447
+ badges.bottomLeft
414
448
  ? html`<obc-automation-badge
415
- .type=${badgeInterlockType}
449
+ .type=${badges.bottomLeft}
416
450
  ></obc-automation-badge>`
417
451
  : nothing
418
452
  }
@@ -423,9 +457,9 @@ export class ObcAbstractAutomationButton extends LitElement {
423
457
  @slotchange=${this.handleBadgeSlotChange}
424
458
  >
425
459
  ${
426
- badgeCommandLockedType
460
+ badges.bottomRight
427
461
  ? html`<obc-automation-badge
428
- .type=${badgeCommandLockedType}
462
+ .type=${badges.bottomRight}
429
463
  ></obc-automation-badge>`
430
464
  : nothing
431
465
  }