@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
@@ -20165,6 +20165,139 @@ var ObcAutomationBadge = class ObcAutomationBadge extends i$4 {
20165
20165
  __decorate([n$4({ type: String })], ObcAutomationBadge.prototype, "mode", void 0);
20166
20166
  __decorate([n$4({ type: String })], ObcAutomationBadge.prototype, "type", void 0);
20167
20167
  ObcAutomationBadge = __decorate([customElement("obc-automation-badge")], ObcAutomationBadge);
20168
+ // src/internal/global-setting.ts
20169
+ /**
20170
+ * One app-wide setting the components render from.
20171
+ *
20172
+ * The application sets it once through a module setter such as
20173
+ * `setAutomationBadgeLayout()` or `setAlertStandard()`. Every connected host
20174
+ * that holds a controller for it re-renders on each change; a host detached
20175
+ * while the value changed catches up on its next connect, and one reattached
20176
+ * unchanged renders nothing extra. Setting the same value again is a no-op.
20177
+ *
20178
+ * It is a plain subscriber set rather than a signal: the value rarely changes
20179
+ * and derives nothing, and the library stays off a pre-standard polyfill. A
20180
+ * setter built on it can move to a signal later without changing its signature.
20181
+ *
20182
+ * ```ts
20183
+ * const alertStandard = new GlobalSetting<AlertStandard | undefined>(undefined);
20184
+ * export const setAlertStandard = (s?: AlertStandard) => alertStandard.set(s);
20185
+ *
20186
+ * class ObcAlertIcon extends LitElement {
20187
+ * private readonly standard = alertStandard.controller(this);
20188
+ * render() { return draw(this.standard.value); }
20189
+ * }
20190
+ * ```
20191
+ */
20192
+ var GlobalSetting = class {
20193
+ constructor(value) {
20194
+ this.value = value;
20195
+ this.currentVersion = 0;
20196
+ this.hosts = /* @__PURE__ */ new Set();
20197
+ }
20198
+ get() {
20199
+ return this.value;
20200
+ }
20201
+ /** Stores the value and re-renders every connected host. */
20202
+ set(value) {
20203
+ if (Object.is(value, this.value)) return;
20204
+ this.value = value;
20205
+ this.currentVersion++;
20206
+ for (const host of this.hosts) host.requestUpdate();
20207
+ }
20208
+ /** Re-renders `host` whenever the value changes; create it once, in the host's constructor. */
20209
+ controller(host) {
20210
+ return new GlobalSettingController(host, this);
20211
+ }
20212
+ /** Counts the changes, so a controller can tell whether its host rendered the current value. */
20213
+ get version() {
20214
+ return this.currentVersion;
20215
+ }
20216
+ attach(host) {
20217
+ this.hosts.add(host);
20218
+ }
20219
+ detach(host) {
20220
+ this.hosts.delete(host);
20221
+ }
20222
+ };
20223
+ /** Keeps one host rendered with the current value of a `GlobalSetting`. */
20224
+ var GlobalSettingController = class {
20225
+ constructor(host, setting) {
20226
+ this.host = host;
20227
+ this.setting = setting;
20228
+ this.renderedVersion = setting.version;
20229
+ this.renderingVersion = setting.version;
20230
+ host.addController(this);
20231
+ }
20232
+ get value() {
20233
+ return this.setting.get();
20234
+ }
20235
+ /** A value set while the host was detached never reached it. */
20236
+ hostConnected() {
20237
+ this.setting.attach(this.host);
20238
+ if (this.renderedVersion !== this.setting.version) this.host.requestUpdate();
20239
+ }
20240
+ hostDisconnected() {
20241
+ this.setting.detach(this.host);
20242
+ }
20243
+ /** The version a render starts from; a change while it runs detached must not count as rendered. */
20244
+ hostUpdate() {
20245
+ this.renderingVersion = this.setting.version;
20246
+ }
20247
+ hostUpdated() {
20248
+ this.renderedVersion = this.renderingVersion;
20249
+ }
20250
+ };
20251
+ // src/automation/automation-button/badge-layout.ts
20252
+ var AutomationButtonBadgeKind = /* @__PURE__ */ function(AutomationButtonBadgeKind) {
20253
+ AutomationButtonBadgeKind["Control"] = "control";
20254
+ AutomationButtonBadgeKind["Alert"] = "alert";
20255
+ AutomationButtonBadgeKind["Interlock"] = "interlock";
20256
+ AutomationButtonBadgeKind["CommandLocked"] = "command-locked";
20257
+ return AutomationButtonBadgeKind;
20258
+ }({});
20259
+ var corners = [
20260
+ "topLeft",
20261
+ "topRight",
20262
+ "bottomLeft",
20263
+ "bottomRight"
20264
+ ];
20265
+ var defaultAutomationButtonBadgeLayout = Object.freeze({
20266
+ topLeft: "control",
20267
+ topRight: "alert",
20268
+ bottomLeft: "interlock",
20269
+ bottomRight: "command-locked"
20270
+ });
20271
+ /**
20272
+ * The `base` layout with the corners `override` names put on top of it.
20273
+ * A kind `override` names twice stays in the first corner, in reading order.
20274
+ */
20275
+ function resolveBadgeLayout(base, override) {
20276
+ const result = { ...base };
20277
+ if (!override) return result;
20278
+ const placed = /* @__PURE__ */ new Set();
20279
+ for (const corner of corners) {
20280
+ const kind = override[corner];
20281
+ if (kind === void 0) continue;
20282
+ result[corner] = kind !== null && placed.has(kind) ? null : kind;
20283
+ if (kind !== null) placed.add(kind);
20284
+ }
20285
+ for (const corner of corners) {
20286
+ const kind = result[corner];
20287
+ if (override[corner] === void 0 && kind !== null && placed.has(kind)) result[corner] = null;
20288
+ }
20289
+ return result;
20290
+ }
20291
+ var globalLayout = new GlobalSetting({ ...defaultAutomationButtonBadgeLayout });
20292
+ /** Re-renders its host when the global badge layout changes, and puts the host's own corners on top of it. */
20293
+ var BadgeLayoutController = class extends GlobalSettingController {
20294
+ constructor(host) {
20295
+ super(host, globalLayout);
20296
+ }
20297
+ resolve(local) {
20298
+ return resolveBadgeLayout(this.value, local);
20299
+ }
20300
+ };
20168
20301
  // src/automation/automation-button/abstract-automation-button.ts
20169
20302
  var AutomationButtonBadgeAlert = /* @__PURE__ */ function(AutomationButtonBadgeAlert) {
20170
20303
  AutomationButtonBadgeAlert["None"] = "none";
@@ -20207,8 +20340,11 @@ var AutomationButtonBadgeCommandLocked = /* @__PURE__ */ function(AutomationButt
20207
20340
  *
20208
20341
  * Renders an `<obc-automation-button>` with the shared surface every device
20209
20342
  * button needs: the readout stack and its status row, the alert frame, the
20210
- * circular progress indicator, and the four badge corners (control, alert,
20211
- * interlock, command-locked) with their slots and enum-driven fallbacks.
20343
+ * circular progress indicator, and the four badge corners with their slots and
20344
+ * enum-driven fallbacks. Which badge goes in which corner follows the badge
20345
+ * layout (`badge-layout.ts`): control top-left, alert top-right, interlock
20346
+ * bottom-left and command-locked bottom-right unless the app or `badgeLayout`
20347
+ * moves them.
20212
20348
  *
20213
20349
  * ## Usage Guidelines
20214
20350
  *
@@ -20230,6 +20366,7 @@ var AutomationButtonBadgeCommandLocked = /* @__PURE__ */ function(AutomationButt
20230
20366
  * @availableWhen alertFrameMode alert==true
20231
20367
  * @availableWhen showAlertCategoryIcon alert==true && alertFrameType in [SmallSideFlip, LargeSideFlip, BottomFlip, TopFlip]
20232
20368
  * @availableWhen showAlertIcon alert==true && alertFrameType in [LargeSideFlip, BottomFlip, TopFlip]
20369
+ * @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.
20233
20370
  * @property progress - Shows a progress indicator, used to indicate that an user action is in progress
20234
20371
  * @availableWhen progressMode progress==true
20235
20372
  * @availableWhen progressValue progress==true && progressMode in [determinate, progressiveIndeterminate]
@@ -20260,6 +20397,8 @@ var ObcAbstractAutomationButton = class extends i$4 {
20260
20397
  this.badgeCommandLocked = "none";
20261
20398
  this.badgeInterlock = "none";
20262
20399
  this.badgeAlert = "none";
20400
+ this.badgeLayout = void 0;
20401
+ this._badgeLayout = new BadgeLayoutController(this);
20263
20402
  }
20264
20403
  get icon() {
20265
20404
  throw new Error("Method \"icon\" must be implemented in subclass");
@@ -20310,12 +20449,12 @@ var ObcAbstractAutomationButton = class extends i$4 {
20310
20449
  get _isVertical() {
20311
20450
  return this._orientation !== AutomationButtonOrientation.horizontal || "vertical" in this && Boolean(this.vertical);
20312
20451
  }
20313
- getBadgeSpacer() {
20452
+ getBadgeSpacer(badges) {
20314
20453
  if (!this.showReadoutStack) return false;
20315
- const topLeft = this.badgeTopLeft.length > 0 || this.getBadgeControlType() !== null;
20316
- const topRight = this.badgeTopRight.length > 0 || this.getBadgeAlertType() !== null;
20317
- const bottomLeft = this.badgeBottomLeft.length > 0 || this.getBadgeInterlockType() !== null;
20318
- const bottomRight = this.badgeBottomRight.length > 0 || this.getBadgeCommandLockedType() !== null;
20454
+ const topLeft = this.badgeTopLeft.length > 0 || badges.topLeft !== null;
20455
+ const topRight = this.badgeTopRight.length > 0 || badges.topRight !== null;
20456
+ const bottomLeft = this.badgeBottomLeft.length > 0 || badges.bottomLeft !== null;
20457
+ const bottomRight = this.badgeBottomRight.length > 0 || badges.bottomRight !== null;
20319
20458
  if (this._readoutPosition === AutomationButtonReadoutPosition.top) return topRight || topLeft;
20320
20459
  else if (this._readoutPosition === AutomationButtonReadoutPosition.bottom) return bottomLeft || bottomRight;
20321
20460
  else if (this._readoutPosition === AutomationButtonReadoutPosition.left) return topLeft || bottomLeft;
@@ -20325,6 +20464,15 @@ var ObcAbstractAutomationButton = class extends i$4 {
20325
20464
  handleBadgeSlotChange() {
20326
20465
  this.requestUpdate();
20327
20466
  }
20467
+ getBadgeType(kind) {
20468
+ switch (kind) {
20469
+ case AutomationButtonBadgeKind.Control: return this.getBadgeControlType();
20470
+ case AutomationButtonBadgeKind.Alert: return this.getBadgeAlertType();
20471
+ case AutomationButtonBadgeKind.Interlock: return this.getBadgeInterlockType();
20472
+ case AutomationButtonBadgeKind.CommandLocked: return this.getBadgeCommandLockedType();
20473
+ default: return null;
20474
+ }
20475
+ }
20328
20476
  getBadgeAlertType() {
20329
20477
  if (this.badgeAlert === "silence") return ObcAutomationBadgeType.AlertSilenced;
20330
20478
  else if (this.badgeAlert === "shelved") return ObcAutomationBadgeType.AlertShelved;
@@ -20359,10 +20507,13 @@ var ObcAbstractAutomationButton = class extends i$4 {
20359
20507
  }
20360
20508
  render() {
20361
20509
  const readouts = [...this.extraReadouts];
20362
- const badgeAlertType = this.getBadgeAlertType();
20363
- const badgeControlType = this.getBadgeControlType();
20364
- const badgeInterlockType = this.getBadgeInterlockType();
20365
- const badgeCommandLockedType = this.getBadgeCommandLockedType();
20510
+ const layout = this._badgeLayout.resolve(this.badgeLayout);
20511
+ const badges = {
20512
+ topLeft: this.getBadgeType(layout.topLeft),
20513
+ topRight: this.getBadgeType(layout.topRight),
20514
+ bottomLeft: this.getBadgeType(layout.bottomLeft),
20515
+ bottomRight: this.getBadgeType(layout.bottomRight)
20516
+ };
20366
20517
  return b`<obc-automation-button
20367
20518
  .state=${this._on ? AutomationButtonState.open : AutomationButtonState.closed}
20368
20519
  .readouts=${readouts}
@@ -20384,7 +20535,7 @@ var ObcAbstractAutomationButton = class extends i$4 {
20384
20535
  .variant=${this._variant}
20385
20536
  .direction=${this._direction}
20386
20537
  .orientation=${this._orientation}
20387
- .hasBadgeSpacer=${this.getBadgeSpacer()}
20538
+ .hasBadgeSpacer=${this.getBadgeSpacer(badges)}
20388
20539
  .handlePosition=${this._handlePosition}
20389
20540
  .static=${this.static}
20390
20541
  .handleSize=${this._handleSize}
@@ -20398,8 +20549,8 @@ var ObcAbstractAutomationButton = class extends i$4 {
20398
20549
  slot="badge-top-right"
20399
20550
  @slotchange=${this.handleBadgeSlotChange}
20400
20551
  >
20401
- ${badgeAlertType ? b`<obc-automation-badge
20402
- .type=${badgeAlertType}
20552
+ ${badges.topRight ? b`<obc-automation-badge
20553
+ .type=${badges.topRight}
20403
20554
  ></obc-automation-badge>` : A}
20404
20555
  </slot>
20405
20556
  <slot
@@ -20407,8 +20558,8 @@ var ObcAbstractAutomationButton = class extends i$4 {
20407
20558
  slot="badge-top-left"
20408
20559
  @slotchange=${this.handleBadgeSlotChange}
20409
20560
  >
20410
- ${badgeControlType ? b`<obc-automation-badge
20411
- .type=${badgeControlType}
20561
+ ${badges.topLeft ? b`<obc-automation-badge
20562
+ .type=${badges.topLeft}
20412
20563
  ></obc-automation-badge>` : A}
20413
20564
  </slot>
20414
20565
  <slot
@@ -20416,8 +20567,8 @@ var ObcAbstractAutomationButton = class extends i$4 {
20416
20567
  slot="badge-bottom-left"
20417
20568
  @slotchange=${this.handleBadgeSlotChange}
20418
20569
  >
20419
- ${badgeInterlockType ? b`<obc-automation-badge
20420
- .type=${badgeInterlockType}
20570
+ ${badges.bottomLeft ? b`<obc-automation-badge
20571
+ .type=${badges.bottomLeft}
20421
20572
  ></obc-automation-badge>` : A}
20422
20573
  </slot>
20423
20574
  <slot
@@ -20425,8 +20576,8 @@ var ObcAbstractAutomationButton = class extends i$4 {
20425
20576
  slot="badge-bottom-right"
20426
20577
  @slotchange=${this.handleBadgeSlotChange}
20427
20578
  >
20428
- ${badgeCommandLockedType ? b`<obc-automation-badge
20429
- .type=${badgeCommandLockedType}
20579
+ ${badges.bottomRight ? b`<obc-automation-badge
20580
+ .type=${badges.bottomRight}
20430
20581
  ></obc-automation-badge>` : A}
20431
20582
  </slot>
20432
20583
  ${this._handle !== false ? this._handle : A}
@@ -20468,6 +20619,7 @@ __decorate([n$4({ type: String })], ObcAbstractAutomationButton.prototype, "badg
20468
20619
  __decorate([n$4({ type: String })], ObcAbstractAutomationButton.prototype, "badgeCommandLocked", void 0);
20469
20620
  __decorate([n$4({ type: String })], ObcAbstractAutomationButton.prototype, "badgeInterlock", void 0);
20470
20621
  __decorate([n$4({ type: String })], ObcAbstractAutomationButton.prototype, "badgeAlert", void 0);
20622
+ __decorate([n$4({ attribute: false })], ObcAbstractAutomationButton.prototype, "badgeLayout", void 0);
20471
20623
  __decorate([o$7({ slot: "badge-top-right" })], ObcAbstractAutomationButton.prototype, "badgeTopRight", void 0);
20472
20624
  __decorate([o$7({ slot: "badge-top-left" })], ObcAbstractAutomationButton.prototype, "badgeTopLeft", void 0);
20473
20625
  __decorate([o$7({ slot: "badge-bottom-left" })], ObcAbstractAutomationButton.prototype, "badgeBottomLeft", void 0);
@@ -20916,6 +21068,7 @@ var argTypesAbstractAutomationButton = {
20916
21068
  options: Object.values(AutomationButtonBadgeAlert),
20917
21069
  control: { type: "select" }
20918
21070
  },
21071
+ badgeLayout: { control: { type: "object" } },
20919
21072
  progressMode: {
20920
21073
  options: Object.values(CircularProgressMode),
20921
21074
  control: { type: "select" },
@@ -35901,6 +36054,16 @@ function computeExternalScaleViewBox(config, layout) {
35901
36054
  };
35902
36055
  }
35903
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
+ /**
35904
36067
  * Compute the scale factor for fixed aspect ratio mode.
35905
36068
  *
35906
36069
  * In fixed aspect ratio mode, the scale component determines its zoom level based on
@@ -35912,17 +36075,43 @@ function computeExternalScaleViewBox(config, layout) {
35912
36075
  * This scale factor is applied to SVG rendering while keeping text labels at constant size
35913
36076
  * by using the CSS variable `--scale` to counter-scale font sizes.
35914
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
+ *
35915
36084
  * Works for all orientations and sides:
35916
36085
  * - Vertical scales (left/right): compare container height vs reference
35917
36086
  * - Horizontal scales (top/bottom): compare container width vs reference
35918
36087
  *
35919
- * @param config Configuration with orientation, container size, and reference size
36088
+ * @param config Configuration with orientation, container sizes, reference size and drawing thickness
35920
36089
  * @returns Scale factor (> 0), defaults to 1 if container size is invalid
35921
36090
  */
35922
36091
  function computeFixedAspectRatioScale(config) {
35923
- const { containerMainAxisSize, scaleReferenceSize } = config;
36092
+ const { containerMainAxisSize, scaleReferenceSize, containerCrossAxisSize, viewBoxThickness } = config;
35924
36093
  if (containerMainAxisSize <= 0 || scaleReferenceSize <= 0) return 1;
35925
- return containerMainAxisSize / scaleReferenceSize;
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
+ };
35926
36115
  }
35927
36116
  /**
35928
36117
  * Compute a minimal viewBox layout for an external scale.
@@ -39559,15 +39748,17 @@ var ObcBarVertical = class ObcBarVertical extends AdviceMixin(SetpointMixin(i$4,
39559
39748
  this.fixedAspectRatio = false;
39560
39749
  this.scaleReferenceSize = 384;
39561
39750
  this._scale = 1;
39751
+ this._viewBoxThickness = 0;
39562
39752
  this._resizeController = new h(this, { callback: (entries) => {
39563
39753
  if (!this.fixedAspectRatio) return;
39564
39754
  const entry = entries[0];
39565
39755
  if (!entry) return;
39566
- const containerMainAxisSize = entry.contentRect.height;
39567
39756
  this._scale = computeFixedAspectRatioScale({
39568
39757
  orientation: ExternalScaleOrientation.vertical,
39569
- containerMainAxisSize,
39570
- scaleReferenceSize: this.scaleReferenceSize
39758
+ containerMainAxisSize: entry.contentRect.height,
39759
+ containerCrossAxisSize: entry.contentRect.width,
39760
+ scaleReferenceSize: this.scaleReferenceSize,
39761
+ viewBoxThickness: this._viewBoxThickness
39571
39762
  });
39572
39763
  this.reportDimensions();
39573
39764
  } });
@@ -39656,6 +39847,7 @@ var ObcBarVertical = class ObcBarVertical extends AdviceMixin(SetpointMixin(i$4,
39656
39847
  highlightCurrentValue: this.highlightCurrentValue
39657
39848
  };
39658
39849
  const layout = computeExternalScaleLayout(toExternalScaleLayoutConfig(config));
39850
+ this._viewBoxThickness = layout.thickness;
39659
39851
  const parts = renderExternalScale(config);
39660
39852
  const viewBox = computeExternalScaleViewBox({
39661
39853
  orientation: config.orientation,
@@ -39691,7 +39883,10 @@ var ObcBarVertical = class ObcBarVertical extends AdviceMixin(SetpointMixin(i$4,
39691
39883
  }
39692
39884
  if (changed.has("scaleReferenceSize") && this.fixedAspectRatio) this._updateScaleFromCurrentSize();
39693
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);
39694
- if (!this.fixedAspectRatio || layoutChanged) this.reportDimensions();
39886
+ if (!this.fixedAspectRatio || layoutChanged) {
39887
+ if (this.fixedAspectRatio) this._measureScale();
39888
+ this.reportDimensions();
39889
+ }
39695
39890
  }
39696
39891
  /**
39697
39892
  * Report scale dimensions to parent chart component.
@@ -39770,19 +39965,26 @@ var ObcBarVertical = class ObcBarVertical extends AdviceMixin(SetpointMixin(i$4,
39770
39965
  this.style.height = "";
39771
39966
  this.style.width = "";
39772
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
+ }
39773
39981
  /**
39774
39982
  * Calculate scale based on current element size.
39775
39983
  * Called when fixedAspectRatio is enabled or scaleReferenceSize changes.
39776
39984
  */
39777
39985
  _updateScaleFromCurrentSize() {
39778
39986
  requestAnimationFrame(() => {
39779
- const containerHeight = this.clientHeight;
39780
- if (containerHeight > 0) {
39781
- this._scale = computeFixedAspectRatioScale({
39782
- orientation: ExternalScaleOrientation.vertical,
39783
- containerMainAxisSize: containerHeight,
39784
- scaleReferenceSize: this.scaleReferenceSize
39785
- });
39987
+ if (this._measureScale()) {
39786
39988
  this.requestUpdate();
39787
39989
  this.reportDimensions();
39788
39990
  }
@@ -39792,17 +39994,7 @@ var ObcBarVertical = class ObcBarVertical extends AdviceMixin(SetpointMixin(i$4,
39792
39994
  if (this.instrumentMode) return;
39793
39995
  const next = readExternalScaleBorderRadiusPx(this, this.scaleType);
39794
39996
  if (this._computedBorderRadius !== next) this._computedBorderRadius = next;
39795
- if (this.fixedAspectRatio) {
39796
- const rect = this.getBoundingClientRect();
39797
- if (rect.height > 0) {
39798
- this._scale = computeFixedAspectRatioScale({
39799
- orientation: ExternalScaleOrientation.vertical,
39800
- containerMainAxisSize: rect.height,
39801
- scaleReferenceSize: this.scaleReferenceSize
39802
- });
39803
- this.reportDimensions();
39804
- }
39805
- }
39997
+ if (this.fixedAspectRatio && this._measureScale()) this.reportDimensions();
39806
39998
  }
39807
39999
  /**
39808
40000
  * Get the effective border radius to use.
@@ -73790,15 +73982,17 @@ var ObcBarHorizontal = class ObcBarHorizontal extends AdviceMixin(SetpointMixin(
73790
73982
  this.fixedAspectRatio = false;
73791
73983
  this.scaleReferenceSize = 384;
73792
73984
  this._scale = 1;
73985
+ this._viewBoxThickness = 0;
73793
73986
  this._resizeController = new h(this, { callback: (entries) => {
73794
73987
  if (!this.fixedAspectRatio) return;
73795
73988
  const entry = entries[0];
73796
73989
  if (!entry) return;
73797
- const containerMainAxisSize = entry.contentRect.width;
73798
73990
  this._scale = computeFixedAspectRatioScale({
73799
73991
  orientation: ExternalScaleOrientation.horizontal,
73800
- containerMainAxisSize,
73801
- scaleReferenceSize: this.scaleReferenceSize
73992
+ containerMainAxisSize: entry.contentRect.width,
73993
+ containerCrossAxisSize: entry.contentRect.height,
73994
+ scaleReferenceSize: this.scaleReferenceSize,
73995
+ viewBoxThickness: this._viewBoxThickness
73802
73996
  });
73803
73997
  this.reportDimensions();
73804
73998
  } });
@@ -73887,6 +74081,7 @@ var ObcBarHorizontal = class ObcBarHorizontal extends AdviceMixin(SetpointMixin(
73887
74081
  highlightCurrentValue: this.highlightCurrentValue
73888
74082
  };
73889
74083
  const layout = computeExternalScaleLayout(toExternalScaleLayoutConfig(config));
74084
+ this._viewBoxThickness = layout.thickness;
73890
74085
  const parts = renderExternalScale(config);
73891
74086
  const viewBox = computeExternalScaleViewBox({
73892
74087
  orientation: config.orientation,
@@ -73922,7 +74117,10 @@ var ObcBarHorizontal = class ObcBarHorizontal extends AdviceMixin(SetpointMixin(
73922
74117
  }
73923
74118
  if (changed.has("scaleReferenceSize") && this.fixedAspectRatio) this._updateScaleFromCurrentSize();
73924
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);
73925
- if (!this.fixedAspectRatio || layoutChanged) this.reportDimensions();
74120
+ if (!this.fixedAspectRatio || layoutChanged) {
74121
+ if (this.fixedAspectRatio) this._measureScale();
74122
+ this.reportDimensions();
74123
+ }
73926
74124
  }
73927
74125
  /**
73928
74126
  * Report scale dimensions to parent chart component.
@@ -74001,19 +74199,26 @@ var ObcBarHorizontal = class ObcBarHorizontal extends AdviceMixin(SetpointMixin(
74001
74199
  this.style.width = "";
74002
74200
  this.style.height = "";
74003
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
+ }
74004
74215
  /**
74005
74216
  * Calculate scale based on current element size.
74006
74217
  * Called when fixedAspectRatio is enabled or scaleReferenceSize changes.
74007
74218
  */
74008
74219
  _updateScaleFromCurrentSize() {
74009
74220
  requestAnimationFrame(() => {
74010
- const containerWidth = this.clientWidth;
74011
- if (containerWidth > 0) {
74012
- this._scale = computeFixedAspectRatioScale({
74013
- orientation: ExternalScaleOrientation.horizontal,
74014
- containerMainAxisSize: containerWidth,
74015
- scaleReferenceSize: this.scaleReferenceSize
74016
- });
74221
+ if (this._measureScale()) {
74017
74222
  this.requestUpdate();
74018
74223
  this.reportDimensions();
74019
74224
  }
@@ -74023,17 +74228,7 @@ var ObcBarHorizontal = class ObcBarHorizontal extends AdviceMixin(SetpointMixin(
74023
74228
  if (this.instrumentMode) return;
74024
74229
  const next = readExternalScaleBorderRadiusPx(this, this.scaleType);
74025
74230
  if (this._computedBorderRadius !== next) this._computedBorderRadius = next;
74026
- if (this.fixedAspectRatio) {
74027
- const rect = this.getBoundingClientRect();
74028
- if (rect.width > 0) {
74029
- this._scale = computeFixedAspectRatioScale({
74030
- orientation: ExternalScaleOrientation.horizontal,
74031
- containerMainAxisSize: rect.width,
74032
- scaleReferenceSize: this.scaleReferenceSize
74033
- });
74034
- this.reportDimensions();
74035
- }
74036
- }
74231
+ if (this.fixedAspectRatio && this._measureScale()) this.reportDimensions();
74037
74232
  }
74038
74233
  /**
74039
74234
  * Get the effective border radius to use.
@@ -203798,15 +203993,17 @@ var ObcGaugeHorizontal = class ObcGaugeHorizontal extends AdviceMixin(SetpointMi
203798
203993
  this.fixedAspectRatio = false;
203799
203994
  this.scaleReferenceSize = 384;
203800
203995
  this._scale = 1;
203996
+ this._viewBoxThickness = 0;
203801
203997
  this._resizeController = new h(this, { callback: (entries) => {
203802
203998
  if (!this.fixedAspectRatio) return;
203803
203999
  const entry = entries[0];
203804
204000
  if (!entry) return;
203805
- const containerMainAxisSize = entry.contentRect.width;
203806
204001
  const scale = computeFixedAspectRatioScale({
203807
204002
  orientation: ExternalScaleOrientation.horizontal,
203808
- containerMainAxisSize,
203809
- scaleReferenceSize: this.scaleReferenceSize
204003
+ containerMainAxisSize: entry.contentRect.width,
204004
+ containerCrossAxisSize: entry.contentRect.height,
204005
+ scaleReferenceSize: this.scaleReferenceSize,
204006
+ viewBoxThickness: this._viewBoxThickness
203810
204007
  });
203811
204008
  this._scale = scale > 0 ? scale : 1;
203812
204009
  this.reportDimensions();
@@ -203844,10 +204041,11 @@ var ObcGaugeHorizontal = class ObcGaugeHorizontal extends AdviceMixin(SetpointMi
203844
204041
  return true;
203845
204042
  }
203846
204043
  render() {
204044
+ const effectiveLength = this.fixedAspectRatio ? this.scaleReferenceSize : this.width;
203847
204045
  const config = {
203848
204046
  orientation: ExternalScaleOrientation.horizontal,
203849
204047
  side: this.side,
203850
- length: this.width,
204048
+ length: effectiveLength,
203851
204049
  paddingStart: this.paddingLeft,
203852
204050
  paddingEnd: this.paddingRight,
203853
204051
  minValue: this.minValue,
@@ -203894,10 +204092,11 @@ var ObcGaugeHorizontal = class ObcGaugeHorizontal extends AdviceMixin(SetpointMi
203894
204092
  highlightCurrentValue: this.highlightCurrentValue
203895
204093
  };
203896
204094
  const layout = computeExternalScaleLayout(toExternalScaleLayoutConfig(config));
204095
+ this._viewBoxThickness = layout.thickness;
203897
204096
  const parts = renderExternalScale(config);
203898
204097
  const viewBox = computeExternalScaleViewBox({
203899
204098
  orientation: config.orientation,
203900
- length: this.width
204099
+ length: effectiveLength
203901
204100
  }, layout);
203902
204101
  const preserveAspectRatio = this.fixedAspectRatio ? "xMidYMid meet" : "none";
203903
204102
  return b`
@@ -203921,12 +204120,26 @@ var ObcGaugeHorizontal = class ObcGaugeHorizontal extends AdviceMixin(SetpointMi
203921
204120
  }
203922
204121
  updated(changed) {
203923
204122
  super.updated(changed);
203924
- if (!this.fixedAspectRatio && (changed.has("side") || changed.has("showLabels")) || this.setpointPresenceChanged(changed)) this.reportDimensions();
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
+ }
203925
204137
  }
203926
204138
  /**
203927
204139
  * Report scale dimensions to parent chart component.
203928
- * Always reports unscaled/reference dimensions so the parent chart can apply
203929
- * consistent proportional scaling in fixedAspectRatioScaling mode.
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.
203930
204143
  */
203931
204144
  reportDimensions() {
203932
204145
  const effectiveBarThickness = computeExternalScaleEffectiveBarThickness({
@@ -203935,7 +204148,7 @@ var ObcGaugeHorizontal = class ObcGaugeHorizontal extends AdviceMixin(SetpointMi
203935
204148
  borderRadius: this.borderRadius,
203936
204149
  scaleType: this.scaleType
203937
204150
  });
203938
- const dimensions = computeScaleDimensionsForReport({
204151
+ const baseDimensions = computeScaleDimensionsForReport({
203939
204152
  orientation: ExternalScaleOrientation.horizontal,
203940
204153
  side: this.side,
203941
204154
  hasBar: this.hasBar,
@@ -203944,11 +204157,15 @@ var ObcGaugeHorizontal = class ObcGaugeHorizontal extends AdviceMixin(SetpointMi
203944
204157
  barThickness: effectiveBarThickness,
203945
204158
  tickThickness: this.tickThickness,
203946
204159
  labelThickness: this.labelThickness,
203947
- length: this.width,
204160
+ length: this.fixedAspectRatio ? this.scaleReferenceSize : this.width,
203948
204161
  scaleType: this.scaleType,
203949
204162
  hasAdviceIcon: !!this.advices?.some((a) => a.showIcon),
203950
204163
  hasSetpoint: this.setpoint !== void 0 || this.newSetpoint !== void 0 || this.departingNewSetpoint !== void 0
203951
204164
  });
204165
+ const dimensions = this.fixedAspectRatio ? {
204166
+ ...baseDimensions,
204167
+ thickness: Math.round(baseDimensions.thickness * this._scale)
204168
+ } : baseDimensions;
203952
204169
  this.dispatchEvent(new CustomEvent("scale-dimensions-changed", {
203953
204170
  detail: dimensions,
203954
204171
  bubbles: true
@@ -203957,11 +204174,69 @@ var ObcGaugeHorizontal = class ObcGaugeHorizontal extends AdviceMixin(SetpointMi
203957
204174
  createRenderRoot() {
203958
204175
  return this;
203959
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
+ }
203960
204233
  };
203961
204234
  __decorate([n$4({ type: Number })], ObcGaugeHorizontal.prototype, "minValue", void 0);
203962
204235
  __decorate([n$4({ type: Number })], ObcGaugeHorizontal.prototype, "maxValue", void 0);
203963
204236
  __decorate([n$4({ type: Boolean })], ObcGaugeHorizontal.prototype, "reverse", void 0);
203964
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);
203965
204240
  __decorate([r$3()], ObcGaugeHorizontal.prototype, "_scale", void 0);
203966
204241
  __decorate([n$4({
203967
204242
  type: Boolean,
@@ -205404,15 +205679,17 @@ var ObcGaugeVertical = class ObcGaugeVertical extends AdviceMixin(SetpointMixin(
205404
205679
  this.fixedAspectRatio = false;
205405
205680
  this.scaleReferenceSize = 384;
205406
205681
  this._scale = 1;
205682
+ this._viewBoxThickness = 0;
205407
205683
  this._resizeController = new h(this, { callback: (entries) => {
205408
205684
  if (!this.fixedAspectRatio) return;
205409
205685
  const entry = entries[0];
205410
205686
  if (!entry) return;
205411
- const containerMainAxisSize = entry.contentRect.height;
205412
205687
  const scale = computeFixedAspectRatioScale({
205413
205688
  orientation: ExternalScaleOrientation.vertical,
205414
- containerMainAxisSize,
205415
- scaleReferenceSize: this.scaleReferenceSize
205689
+ containerMainAxisSize: entry.contentRect.height,
205690
+ containerCrossAxisSize: entry.contentRect.width,
205691
+ scaleReferenceSize: this.scaleReferenceSize,
205692
+ viewBoxThickness: this._viewBoxThickness
205416
205693
  });
205417
205694
  this._scale = scale > 0 ? scale : 1;
205418
205695
  this.reportDimensions();
@@ -205450,10 +205727,11 @@ var ObcGaugeVertical = class ObcGaugeVertical extends AdviceMixin(SetpointMixin(
205450
205727
  return true;
205451
205728
  }
205452
205729
  render() {
205730
+ const effectiveLength = this.fixedAspectRatio ? this.scaleReferenceSize : this.height;
205453
205731
  const config = {
205454
205732
  orientation: ExternalScaleOrientation.vertical,
205455
205733
  side: this.side,
205456
- length: this.height,
205734
+ length: effectiveLength,
205457
205735
  paddingStart: this.paddingTop,
205458
205736
  paddingEnd: this.paddingBottom,
205459
205737
  minValue: this.minValue,
@@ -205500,10 +205778,11 @@ var ObcGaugeVertical = class ObcGaugeVertical extends AdviceMixin(SetpointMixin(
205500
205778
  highlightCurrentValue: this.highlightCurrentValue
205501
205779
  };
205502
205780
  const layout = computeExternalScaleLayout(toExternalScaleLayoutConfig(config));
205781
+ this._viewBoxThickness = layout.thickness;
205503
205782
  const parts = renderExternalScale(config);
205504
205783
  const viewBox = computeExternalScaleViewBox({
205505
205784
  orientation: config.orientation,
205506
- length: this.height
205785
+ length: effectiveLength
205507
205786
  }, layout);
205508
205787
  const preserveAspectRatio = this.fixedAspectRatio ? "xMidYMid meet" : "none";
205509
205788
  return b`
@@ -205527,12 +205806,26 @@ var ObcGaugeVertical = class ObcGaugeVertical extends AdviceMixin(SetpointMixin(
205527
205806
  }
205528
205807
  updated(changed) {
205529
205808
  super.updated(changed);
205530
- if (!this.fixedAspectRatio && (changed.has("side") || changed.has("showLabels")) || this.setpointPresenceChanged(changed)) this.reportDimensions();
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
+ }
205531
205823
  }
205532
205824
  /**
205533
205825
  * Report scale dimensions to parent chart component.
205534
- * Always reports unscaled/reference dimensions so the parent chart can apply
205535
- * consistent proportional scaling in fixedAspectRatioScaling mode.
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.
205536
205829
  */
205537
205830
  reportDimensions() {
205538
205831
  const effectiveBarThickness = computeExternalScaleEffectiveBarThickness({
@@ -205541,7 +205834,7 @@ var ObcGaugeVertical = class ObcGaugeVertical extends AdviceMixin(SetpointMixin(
205541
205834
  borderRadius: this.borderRadius,
205542
205835
  scaleType: this.scaleType
205543
205836
  });
205544
- const dimensions = computeScaleDimensionsForReport({
205837
+ const baseDimensions = computeScaleDimensionsForReport({
205545
205838
  orientation: ExternalScaleOrientation.vertical,
205546
205839
  side: this.side,
205547
205840
  hasBar: this.hasBar,
@@ -205550,11 +205843,15 @@ var ObcGaugeVertical = class ObcGaugeVertical extends AdviceMixin(SetpointMixin(
205550
205843
  barThickness: effectiveBarThickness,
205551
205844
  tickThickness: this.tickThickness,
205552
205845
  labelThickness: this.labelThickness,
205553
- length: this.height,
205846
+ length: this.fixedAspectRatio ? this.scaleReferenceSize : this.height,
205554
205847
  scaleType: this.scaleType,
205555
205848
  hasAdviceIcon: !!this.advices?.some((a) => a.showIcon),
205556
205849
  hasSetpoint: this.setpoint !== void 0 || this.newSetpoint !== void 0 || this.departingNewSetpoint !== void 0
205557
205850
  });
205851
+ const dimensions = this.fixedAspectRatio ? {
205852
+ ...baseDimensions,
205853
+ thickness: Math.round(baseDimensions.thickness * this._scale)
205854
+ } : baseDimensions;
205558
205855
  this.dispatchEvent(new CustomEvent("scale-dimensions-changed", {
205559
205856
  detail: dimensions,
205560
205857
  bubbles: true
@@ -205563,11 +205860,69 @@ var ObcGaugeVertical = class ObcGaugeVertical extends AdviceMixin(SetpointMixin(
205563
205860
  createRenderRoot() {
205564
205861
  return this;
205565
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
+ }
205566
205919
  };
205567
205920
  __decorate([n$4({ type: Number })], ObcGaugeVertical.prototype, "minValue", void 0);
205568
205921
  __decorate([n$4({ type: Number })], ObcGaugeVertical.prototype, "maxValue", void 0);
205569
205922
  __decorate([n$4({ type: Boolean })], ObcGaugeVertical.prototype, "reverse", void 0);
205570
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);
205571
205926
  __decorate([r$3()], ObcGaugeVertical.prototype, "_scale", void 0);
205572
205927
  __decorate([n$4({
205573
205928
  type: Boolean,