@oicl/openbridge-webcomponents 2.1.0-next.6 → 2.1.0-next.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -4379,7 +4379,7 @@ var ObcChartObjectVesselButton = class ObcChartObjectVesselButton extends i$4 {
4379
4379
  }
4380
4380
  getTurnRateIcon() {
4381
4381
  if (!["button-speed-rot", "flat-speed-rot"].includes(this.type)) return A;
4382
- const deg = this.turnRate / 100 * 12;
4382
+ const deg = (Number.isFinite(this.turnRate) ? this.turnRate : 0) / 100 * 12;
4383
4383
  const R = 24;
4384
4384
  const x = -24 * Math.cos(degToRad(deg)) + R + 3;
4385
4385
  return u$2`
@@ -21980,6 +21980,14 @@ canvas {
21980
21980
  position: relative;
21981
21981
  }
21982
21982
 
21983
+ /* Pixel mode: pin the canvas to the requested size. Chart.js writes its
21984
+ measured size back inline, so a chart created in a hidden container would
21985
+ otherwise keep the 48 px minimum it measured there. */
21986
+ :host(:not([fixedaspectratioscaling])) canvas {
21987
+ width: var(--chart-width, 100%) !important;
21988
+ height: var(--chart-height, auto) !important;
21989
+ }
21990
+
21983
21991
  /* Scale slots - absolutely positioned at edges */
21984
21992
  slot[name="top-scale"],
21985
21993
  slot[name="bottom-scale"],
@@ -33779,25 +33787,37 @@ function formatXValue(value, mode, relativeToMs) {
33779
33787
  }
33780
33788
  //#endregion
33781
33789
  //#region src/charthelpers/label-threshold.ts
33790
+ function hasSize(target) {
33791
+ const { width, height } = target.getBoundingClientRect();
33792
+ return width > 0 && height > 0;
33793
+ }
33782
33794
  /**
33783
33795
  * A chart installs its label plugins at creation time, from which side of
33784
33796
  * the label threshold the canvas is on. A resize that crosses the threshold
33785
33797
  * therefore needs a rebuild, while every other resize is an in-place
33786
33798
  * update. This owns the which-side state; the chart owns the decision.
33787
33799
  *
33800
+ * A chart created while its canvas had no size (in a hidden container) is
33801
+ * also rebuilt once, when the canvas first gets one: Chart.js keeps layout
33802
+ * state from that empty first pass, and a resize leaves the plot a pixel off
33803
+ * a chart created at its real size.
33804
+ *
33788
33805
  * @param target - The chart's canvas. A detached target is ignored: it has no size and no chart to serve.
33789
33806
  * @param isAboveThreshold - The chart's own test, read once now and after every resize.
33790
- * @param callbacks - `rebuild` on a crossing, `update` otherwise.
33807
+ * @param callbacks - `rebuild` on a crossing or a first size, `update` otherwise.
33791
33808
  * @returns The observer, for the chart to disconnect in `disconnectedCallback`.
33792
33809
  */
33793
33810
  function observeLabelThreshold(target, isAboveThreshold, callbacks) {
33794
33811
  let wasAbove = isAboveThreshold();
33812
+ let hadSize = hasSize(target);
33795
33813
  const observer = new ResizeObserver(() => {
33796
33814
  if (!target.isConnected) return;
33797
33815
  const isAbove = isAboveThreshold();
33798
33816
  const crossed = isAbove !== wasAbove;
33799
33817
  wasAbove = isAbove;
33800
- if (crossed) callbacks.rebuild();
33818
+ const gotSize = !hadSize && hasSize(target);
33819
+ hadSize = hasSize(target);
33820
+ if (crossed || gotSize) callbacks.rebuild();
33801
33821
  else callbacks.update();
33802
33822
  });
33803
33823
  observer.observe(target);
@@ -37138,14 +37158,17 @@ var ObcChartLineBase = class extends i$4 {
37138
37158
  * NOTE: For non-threshold modes (solid, semitransparent), backgroundColor is already
37139
37159
  * set correctly in buildDataset(). This method now only handles threshold gradients
37140
37160
  * which require Chart.js scales to be available.
37161
+ *
37162
+ * @returns Whether it set gradients; they reach the drawn chart on its next update.
37141
37163
  */
37142
37164
  applyFillModes() {
37143
- if (!this.chart || !this.canvasEl || !this.canvasEl.isConnected) return;
37165
+ if (!this.chart || !this.canvasEl || !this.canvasEl.isConnected) return false;
37144
37166
  const chart = this.chart;
37145
37167
  const ctx = chart.ctx;
37146
- if (!ctx) return;
37168
+ if (!ctx) return false;
37147
37169
  const fill = this.shouldApplyFill();
37148
- if (this.getFillMode() !== "threshold" || !fill) return;
37170
+ if (this.getFillMode() !== "threshold" || !fill) return false;
37171
+ let applied = false;
37149
37172
  chart.data.datasets.forEach((ds, _idx) => {
37150
37173
  const dataset = ds;
37151
37174
  if (dataset.fill === false || !fill) return;
@@ -37176,7 +37199,9 @@ var ObcChartLineBase = class extends i$4 {
37176
37199
  const borderGradient = createGradient(.8, .8);
37177
37200
  dataset.backgroundColor = fillGradient;
37178
37201
  dataset.borderColor = borderGradient;
37202
+ applied = true;
37179
37203
  });
37204
+ return applied;
37180
37205
  }
37181
37206
  updated(changed) {
37182
37207
  super.updated(changed);
@@ -37693,7 +37718,7 @@ var ObcChartLineBase = class extends i$4 {
37693
37718
  ]
37694
37719
  });
37695
37720
  requestAnimationFrame(() => this.updateLegend());
37696
- this.applyFillModes();
37721
+ if (this.applyFillModes()) this.chart.update("none");
37697
37722
  this.syncSlottedScaleRanges();
37698
37723
  }
37699
37724
  updateChart() {
@@ -196094,6 +196119,7 @@ var ObcWatchFlat = class ObcWatchFlat extends i$4 {
196094
196119
  this.rotAtZeroDeadband = ROT_ZERO_DEADBAND_PX;
196095
196120
  this.rotDotAnimationFactor = 18;
196096
196121
  this._legacyRotationsPerMinute = 0;
196122
+ this._resizeController = new h(this, {});
196097
196123
  }
196098
196124
  /**
196099
196125
  * @deprecated Use `rateOfTurnDegreesPerMinute` (and optionally
@@ -196110,6 +196136,15 @@ var ObcWatchFlat = class ObcWatchFlat extends i$4 {
196110
196136
  if (this.rateOfTurnDegreesPerMinute != null) return this.rateOfTurnDegreesPerMinute / 360 * this.rotDotAnimationFactor;
196111
196137
  return this._legacyRotationsPerMinute;
196112
196138
  }
196139
+ /**
196140
+ * Rendered px per user-space unit; the labels divide by it to keep their
196141
+ * on-screen size. 1:1 while the strip has no width yet (hidden, or not laid
196142
+ * out), until the ResizeController re-renders it.
196143
+ */
196144
+ scaleFor(viewBoxWidth) {
196145
+ const scale = measureContainerPx(this).width / viewBoxWidth;
196146
+ return Number.isFinite(scale) && scale > 0 ? scale : 1;
196147
+ }
196113
196148
  get totalHeight() {
196114
196149
  return this.bottomBar ? this.height + this.ticksHeight : this.height;
196115
196150
  }
@@ -196293,6 +196328,10 @@ var ObcWatchFlat = class ObcWatchFlat extends i$4 {
196293
196328
  </g>
196294
196329
  ` : A;
196295
196330
  }
196331
+ firstUpdated(changed) {
196332
+ super.firstUpdated(changed);
196333
+ observeInnerBox(this._resizeController, this.renderRoot);
196334
+ }
196296
196335
  updated(changed) {
196297
196336
  super.updated(changed);
196298
196337
  const el = this.rotType ? this.renderRoot.querySelector("#rot-spinner") : null;
@@ -196315,7 +196354,7 @@ var ObcWatchFlat = class ObcWatchFlat extends i$4 {
196315
196354
  const width = (this.width / 2 + this.padding) * 2;
196316
196355
  const th = this.totalHeight;
196317
196356
  const viewBox = `-${width / 2} -${th / 2} ${width} ${th}`;
196318
- const scale = this.clientWidth / width;
196357
+ const scale = this.scaleFor(width);
196319
196358
  const contentOffsetY = this.bottomBar ? -this.ticksHeight / 2 : 0;
196320
196359
  return b`
196321
196360
  <svg