@oicl/openbridge-webcomponents-full-bundle 2.0.0-next.170 → 2.0.0-next.171

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 (78) hide show
  1. package/bundle/openbridge-webcomponents.bundle.js +870 -441
  2. package/bundle/openbridge-webcomponents.bundle.js.map +1 -1
  3. package/custom-elements.json +1110 -383
  4. package/dist/ar/poi/poi-aton.d.ts +1 -0
  5. package/dist/ar/poi/poi-aton.d.ts.map +1 -1
  6. package/dist/ar/poi/poi-aton.js +1 -0
  7. package/dist/ar/poi/poi-aton.js.map +1 -1
  8. package/dist/ar/poi/poi-base.d.ts +39 -5
  9. package/dist/ar/poi/poi-base.d.ts.map +1 -1
  10. package/dist/ar/poi/poi-base.js +108 -37
  11. package/dist/ar/poi/poi-base.js.map +1 -1
  12. package/dist/ar/poi/poi-data.d.ts +1 -0
  13. package/dist/ar/poi/poi-data.d.ts.map +1 -1
  14. package/dist/ar/poi/poi-data.js +1 -0
  15. package/dist/ar/poi/poi-data.js.map +1 -1
  16. package/dist/ar/poi/poi-vessel.d.ts +1 -0
  17. package/dist/ar/poi/poi-vessel.d.ts.map +1 -1
  18. package/dist/ar/poi/poi-vessel.js +1 -0
  19. package/dist/ar/poi/poi-vessel.js.map +1 -1
  20. package/dist/ar/poi/poi.d.ts +4 -12
  21. package/dist/ar/poi/poi.d.ts.map +1 -1
  22. package/dist/ar/poi/poi.js +6 -72
  23. package/dist/ar/poi/poi.js.map +1 -1
  24. package/dist/ar/poi-button/poi-button.d.ts +6 -2
  25. package/dist/ar/poi-button/poi-button.d.ts.map +1 -1
  26. package/dist/ar/poi-button/poi-button.js +10 -1
  27. package/dist/ar/poi-button/poi-button.js.map +1 -1
  28. package/dist/ar/poi-card/poi-card.d.ts +12 -1
  29. package/dist/ar/poi-card/poi-card.d.ts.map +1 -1
  30. package/dist/ar/poi-card/poi-card.js +4 -1
  31. package/dist/ar/poi-card/poi-card.js.map +1 -1
  32. package/dist/ar/poi-controller/poi-controller.d.ts +45 -1
  33. package/dist/ar/poi-controller/poi-controller.d.ts.map +1 -1
  34. package/dist/ar/poi-controller/poi-controller.js +72 -14
  35. package/dist/ar/poi-controller/poi-controller.js.map +1 -1
  36. package/dist/ar/poi-group/poi-group.d.ts +28 -5
  37. package/dist/ar/poi-group/poi-group.d.ts.map +1 -1
  38. package/dist/ar/poi-group/poi-group.js +50 -7
  39. package/dist/ar/poi-group/poi-group.js.map +1 -1
  40. package/dist/ar/poi-layer/poi-layer.css.js +69 -18
  41. package/dist/ar/poi-layer/poi-layer.css.js.map +1 -1
  42. package/dist/ar/poi-layer/poi-layer.d.ts +64 -5
  43. package/dist/ar/poi-layer/poi-layer.d.ts.map +1 -1
  44. package/dist/ar/poi-layer/poi-layer.js +173 -39
  45. package/dist/ar/poi-layer/poi-layer.js.map +1 -1
  46. package/dist/ar/poi-layer-stack/poi-layer-stack.d.ts +82 -7
  47. package/dist/ar/poi-layer-stack/poi-layer-stack.d.ts.map +1 -1
  48. package/dist/ar/poi-layer-stack/poi-layer-stack.js +172 -100
  49. package/dist/ar/poi-layer-stack/poi-layer-stack.js.map +1 -1
  50. package/dist/ar/poi-projection/poi-projection.d.ts +88 -0
  51. package/dist/ar/poi-projection/poi-projection.d.ts.map +1 -0
  52. package/dist/ar/poi-projection/poi-projection.js +90 -0
  53. package/dist/ar/poi-projection/poi-projection.js.map +1 -0
  54. package/docs/MigrationGuide.mdx +61 -5
  55. package/docs/migration-guide/a11y-labels.md +8 -0
  56. package/docs/migration-guide/api-automation.md +1 -0
  57. package/package.json +2 -2
  58. package/src/ar/_test-utils.ts +18 -6
  59. package/src/ar/poi/poi-aton.ts +2 -0
  60. package/src/ar/poi/poi-base.ts +159 -70
  61. package/src/ar/poi/poi-data.ts +2 -0
  62. package/src/ar/poi/poi-dom-ownership.spec.ts +393 -0
  63. package/src/ar/poi/poi-vessel.ts +2 -0
  64. package/src/ar/poi/poi.ts +12 -113
  65. package/src/ar/poi-button/poi-button.ts +25 -3
  66. package/src/ar/poi-card/poi-card.ts +16 -2
  67. package/src/ar/poi-controller/poi-controller.spec.ts +54 -0
  68. package/src/ar/poi-controller/poi-controller.stories.ts +76 -24
  69. package/src/ar/poi-controller/poi-controller.ts +111 -41
  70. package/src/ar/poi-group/poi-group.stories.ts +18 -5
  71. package/src/ar/poi-group/poi-group.ts +87 -12
  72. package/src/ar/poi-layer/poi-layer.css +69 -18
  73. package/src/ar/poi-layer/poi-layer.stories.ts +30 -16
  74. package/src/ar/poi-layer/poi-layer.ts +289 -64
  75. package/src/ar/poi-layer-stack/poi-layer-stack.stories.ts +56 -23
  76. package/src/ar/poi-layer-stack/poi-layer-stack.ts +342 -247
  77. package/src/ar/poi-projection/poi-projection.stories.ts +100 -0
  78. package/src/ar/poi-projection/poi-projection.ts +147 -0
@@ -6,8 +6,12 @@ import {
6
6
  ObcPoiButtonType,
7
7
  ObcPoiButtonDataItem,
8
8
  } from '../poi-button/poi-button.js';
9
- import {ObcPoiHeaderState} from '../building-blocks/poi-header/poi-header.js';
10
- import {ObcPoiState, ObcPoiType, ObcPoiValue} from './poi.js';
9
+ import {
10
+ DEFAULT_LINE_LENGTH_PX,
11
+ ObcPoiState,
12
+ ObcPoiType,
13
+ ObcPoiValue,
14
+ } from './poi.js';
11
15
  import {
12
16
  ObcPoiPointerState,
13
17
  ObcPoiPointerType,
@@ -34,7 +38,8 @@ function stripWhitespaceTextNodes(el: Element): void {
34
38
  }
35
39
  }
36
40
 
37
- const X_FILTER_CUTOFF_HZ = 16;
41
+ export const X_FILTER_CUTOFF_HZ = 16;
42
+ export const Y_FILTER_CUTOFF_HZ = 16;
38
43
  const X_FILTER_DEADBAND_PX = 0.1;
39
44
  const X_MOVING_HINT_MS = 120;
40
45
  const VALID_POI_TYPES = new Set(Object.values(ObcPoiType));
@@ -48,12 +53,29 @@ const VALID_POI_STATES = new Set(Object.values(ObcPoiState));
48
53
  * layout-change dispatch, and visual-query logic so that each variant
49
54
  * only needs to override `renderContent()` and `getVisualNodes()`.
50
55
  *
56
+ * ### Coordinate Model
57
+ * - `x` is the horizontal center position in px within the layer.
58
+ * - Targets are anchored at the layer's bottom edge; `y` is the connector
59
+ * line length in px extending downward from that anchor to the target
60
+ * point (default `192`, the shared `DEFAULT_LINE_LENGTH_PX`). The button
61
+ * renders at the top of the connector, inside the layer.
62
+ * - `buttonY` positions the button; its interaction with `fixedTarget` is
63
+ * described in the `obc-poi` documentation.
64
+ * - `x` and `y` updates pass through built-in low-pass filters (see
65
+ * `xFilterCutoffHz` and `yFilterCutoffHz`).
66
+ *
51
67
  * The `@fires` tag below documents the dispatch site, which lives here rather
52
68
  * than in the variants. It is deliberately duplicated on each concrete
53
69
  * subclass — that is where `custom-elements.json` and the framework wrappers
54
70
  * pick the event up, since this class is not registered. Do not remove it from
55
71
  * the subclasses. `@ignore` keeps this class out of the generated docs.
56
72
  *
73
+ * @property xFilterCutoffHz - Cutoff frequency (Hz) of the built-in low-pass filter applied to `x`.
74
+ * Lower values smooth noisy input more aggressively; `0` or a negative
75
+ * value disables filtering so `x` is applied directly.
76
+ * @property yFilterCutoffHz - Cutoff frequency (Hz) of the built-in low-pass filter applied to `y`.
77
+ * Lower values smooth noisy input more aggressively; `0` or a negative
78
+ * value disables filtering so `y` is applied directly.
57
79
  * @fires {CustomEvent<void>} obc-poi-data-layout-change - Fired when layout-driving properties change. Bubbles and is composed.
58
80
  * @ignore
59
81
  */
@@ -93,8 +115,12 @@ export class PoiBase extends LitElement implements Poi {
93
115
  /* ---------- Poi — position ---------- */
94
116
 
95
117
  @property({type: Number}) x = 0;
96
- @property({type: Number}) y = 192;
118
+ @property({type: Number}) y = DEFAULT_LINE_LENGTH_PX;
97
119
  @property({type: Number, attribute: 'button-y'}) buttonY: number | null = 0;
120
+ @property({type: Number, attribute: 'x-filter-cutoff-hz'})
121
+ xFilterCutoffHz = X_FILTER_CUTOFF_HZ;
122
+ @property({type: Number, attribute: 'y-filter-cutoff-hz'})
123
+ yFilterCutoffHz = Y_FILTER_CUTOFF_HZ;
98
124
  @property({type: Boolean, attribute: 'fixed-target'}) fixedTarget = false;
99
125
  @property({type: Number, attribute: 'box-width'}) boxWidth: number | null =
100
126
  null;
@@ -145,6 +171,26 @@ export class PoiBase extends LitElement implements Poi {
145
171
  private xFilterRaf = 0;
146
172
  private xMovingHintTimeout: number | null = null;
147
173
 
174
+ private get resolvedXFilterCutoffHz(): number {
175
+ return Number.isFinite(this.xFilterCutoffHz)
176
+ ? this.xFilterCutoffHz
177
+ : X_FILTER_CUTOFF_HZ;
178
+ }
179
+
180
+ /* ---------- Y-filter state ---------- */
181
+
182
+ private filteredY = 0;
183
+ private yFilterTarget = 0;
184
+ private yFilterInitialized = false;
185
+ private lastYFilterTimestampMs = 0;
186
+ private yFilterRaf = 0;
187
+
188
+ private get resolvedYFilterCutoffHz(): number {
189
+ return Number.isFinite(this.yFilterCutoffHz)
190
+ ? this.yFilterCutoffHz
191
+ : Y_FILTER_CUTOFF_HZ;
192
+ }
193
+
148
194
  /* ---------- Layout change ---------- */
149
195
 
150
196
  private dispatchLayoutChange() {
@@ -170,7 +216,9 @@ export class PoiBase extends LitElement implements Poi {
170
216
  : 1 / 60;
171
217
  this.lastXFilterTimestampMs = nowMs;
172
218
 
173
- const alpha = 1 - Math.exp(-2 * Math.PI * X_FILTER_CUTOFF_HZ * dtSeconds);
219
+ const cutoffHz = this.resolvedXFilterCutoffHz;
220
+ const alpha =
221
+ cutoffHz <= 0 ? 1 : 1 - Math.exp(-2 * Math.PI * cutoffHz * dtSeconds);
174
222
  const delta = this.xFilterTarget - this.filteredX;
175
223
  const nextX =
176
224
  Math.abs(delta) <= X_FILTER_DEADBAND_PX
@@ -209,7 +257,10 @@ export class PoiBase extends LitElement implements Poi {
209
257
  return;
210
258
  }
211
259
 
212
- if (Math.abs(nextX - this.filteredX) <= X_FILTER_DEADBAND_PX) {
260
+ if (
261
+ this.resolvedXFilterCutoffHz <= 0 ||
262
+ Math.abs(nextX - this.filteredX) <= X_FILTER_DEADBAND_PX
263
+ ) {
213
264
  this.filteredX = this.xFilterTarget;
214
265
  this.style.setProperty('--obc-poi-data-x', `${this.filteredX}px`);
215
266
  if (this.xFilterRaf) {
@@ -228,6 +279,82 @@ export class PoiBase extends LitElement implements Poi {
228
279
  }
229
280
  }
230
281
 
282
+ /* ---------- Y filter (low-pass) ---------- */
283
+
284
+ private stepYFilter = (nowMs: number) => {
285
+ this.yFilterRaf = 0;
286
+ if (!this.isConnected || !this.yFilterInitialized) {
287
+ return;
288
+ }
289
+
290
+ const dtSeconds =
291
+ this.lastYFilterTimestampMs > 0
292
+ ? clamp((nowMs - this.lastYFilterTimestampMs) / 1000, 1 / 120, 0.25)
293
+ : 1 / 60;
294
+ this.lastYFilterTimestampMs = nowMs;
295
+
296
+ const cutoffHz = this.resolvedYFilterCutoffHz;
297
+ const alpha =
298
+ cutoffHz <= 0 ? 1 : 1 - Math.exp(-2 * Math.PI * cutoffHz * dtSeconds);
299
+ const delta = this.yFilterTarget - this.filteredY;
300
+ const nextY =
301
+ Math.abs(delta) <= X_FILTER_DEADBAND_PX
302
+ ? this.yFilterTarget
303
+ : this.filteredY + delta * alpha;
304
+ const changed = Math.abs(nextY - this.filteredY) > 1e-6;
305
+ this.filteredY = nextY;
306
+ if (changed) {
307
+ this.applyFilteredY();
308
+ }
309
+
310
+ const settled =
311
+ Math.abs(this.yFilterTarget - this.filteredY) <= X_FILTER_DEADBAND_PX;
312
+
313
+ if (settled) {
314
+ this.filteredY = this.yFilterTarget;
315
+ this.applyFilteredY();
316
+ this.lastYFilterTimestampMs = 0;
317
+ return;
318
+ }
319
+
320
+ this.yFilterRaf = requestAnimationFrame(this.stepYFilter);
321
+ };
322
+
323
+ private applyFilteredY() {
324
+ this.requestUpdate();
325
+ this.updatePosition();
326
+ this.dispatchLayoutChange();
327
+ }
328
+
329
+ private syncYFilterTarget(nextY: number) {
330
+ this.yFilterTarget = nextY;
331
+
332
+ if (!this.yFilterInitialized) {
333
+ this.yFilterInitialized = true;
334
+ this.filteredY = nextY;
335
+ return;
336
+ }
337
+
338
+ if (
339
+ this.resolvedYFilterCutoffHz <= 0 ||
340
+ Math.abs(nextY - this.filteredY) <= X_FILTER_DEADBAND_PX
341
+ ) {
342
+ this.filteredY = this.yFilterTarget;
343
+ this.applyFilteredY();
344
+ if (this.yFilterRaf) {
345
+ cancelAnimationFrame(this.yFilterRaf);
346
+ this.yFilterRaf = 0;
347
+ }
348
+ this.lastYFilterTimestampMs = 0;
349
+ return;
350
+ }
351
+
352
+ if (!this.yFilterRaf) {
353
+ this.lastYFilterTimestampMs = 0;
354
+ this.yFilterRaf = requestAnimationFrame(this.stepYFilter);
355
+ }
356
+ }
357
+
231
358
  private markXMoving() {
232
359
  this.setAttribute('data-x-moving', 'true');
233
360
  if (this.xMovingHintTimeout !== null) {
@@ -250,6 +377,11 @@ export class PoiBase extends LitElement implements Poi {
250
377
  this.xFilterRaf = 0;
251
378
  }
252
379
  this.lastXFilterTimestampMs = 0;
380
+ if (this.yFilterRaf) {
381
+ cancelAnimationFrame(this.yFilterRaf);
382
+ this.yFilterRaf = 0;
383
+ }
384
+ this.lastYFilterTimestampMs = 0;
253
385
  if (this.xMovingHintTimeout !== null) {
254
386
  window.clearTimeout(this.xMovingHintTimeout);
255
387
  this.xMovingHintTimeout = null;
@@ -262,7 +394,6 @@ export class PoiBase extends LitElement implements Poi {
262
394
  for (const mutation of mutations) {
263
395
  if (mutation.type === 'childList') {
264
396
  this.syncHeaderContent();
265
- this.syncHeaderState();
266
397
  return;
267
398
  }
268
399
  if (
@@ -271,7 +402,6 @@ export class PoiBase extends LitElement implements Poi {
271
402
  mutation.target.getAttribute('slot') === 'header'
272
403
  ) {
273
404
  this.syncHeaderContent();
274
- this.syncHeaderState();
275
405
  return;
276
406
  }
277
407
  }
@@ -287,6 +417,9 @@ export class PoiBase extends LitElement implements Poi {
287
417
  if (changedProperties.has('x')) {
288
418
  this.syncXFilterTarget(Number.isFinite(this.x) ? this.x : 0);
289
419
  }
420
+ if (changedProperties.has('y')) {
421
+ this.syncYFilterTarget(Number.isFinite(this.y) ? this.y : 0);
422
+ }
290
423
  if (
291
424
  changedProperties.has('buttonY') ||
292
425
  changedProperties.has('y') ||
@@ -310,12 +443,10 @@ export class PoiBase extends LitElement implements Poi {
310
443
  this.dispatchLayoutChange();
311
444
  }
312
445
  this.syncHeaderContent();
313
- this.syncHeaderState();
314
446
  }
315
447
 
316
448
  protected override firstUpdated(_changedProperties: Map<string, unknown>) {
317
449
  this.syncHeaderContent();
318
- this.syncHeaderState();
319
450
  }
320
451
 
321
452
  /* ---------- Vertical positioning ---------- */
@@ -541,8 +672,11 @@ export class PoiBase extends LitElement implements Poi {
541
672
 
542
673
  /* ---------- Render helpers ---------- */
543
674
 
544
- /** Public `y` normalized as the target Y input. */
675
+ /** Public `y` normalized as the target Y input, after the y filter. */
545
676
  protected get resolvedTargetY(): number {
677
+ if (this.yFilterInitialized) {
678
+ return this.filteredY;
679
+ }
546
680
  return Number.isFinite(this.y) ? this.y : 0;
547
681
  }
548
682
 
@@ -579,74 +713,29 @@ export class PoiBase extends LitElement implements Poi {
579
713
  .data=${this.data}
580
714
  >
581
715
  <slot></slot>
716
+ <slot name="header" slot="header"></slot>
582
717
  </obc-poi-button>
583
718
  `;
584
719
  }
585
720
 
586
- protected get resolvedHeaderState(): ObcPoiHeaderState {
587
- switch (this.resolvedPoiState) {
588
- case ObcPoiState.Caution:
589
- return ObcPoiHeaderState.Caution;
590
- case ObcPoiState.Warning:
591
- return ObcPoiHeaderState.Warning;
592
- case ObcPoiState.Alarm:
593
- return ObcPoiHeaderState.Alarm;
594
- case ObcPoiState.Enabled:
595
- default:
596
- return this.selected
597
- ? ObcPoiHeaderState.Selected
598
- : ObcPoiHeaderState.Enabled;
599
- }
600
- }
601
-
721
+ /**
722
+ * Auto-enable `hasHeader` when the consumer slots header content directly
723
+ * (outside a stack, which manages `hasHeader` itself). Header elements stay
724
+ * in the consumer's light DOM and reach the inner button through the
725
+ * `<slot name="header">` forwarding chain; their `state` is synced by
726
+ * `obc-poi-button`.
727
+ */
602
728
  private syncHeaderContent() {
603
- const headerChildren = Array.from(this.children).filter(
604
- (child): child is HTMLElement =>
605
- child instanceof HTMLElement && child.getAttribute('slot') === 'header'
606
- );
607
-
608
- if (headerChildren.length === 0 && !this.hasHeader) {
729
+ if (this.hasHeader) {
609
730
  return;
610
731
  }
611
-
612
- if (
613
- headerChildren.length > 0 &&
614
- !this.hasHeader &&
615
- this.closest('obc-poi-layer-stack') === null
616
- ) {
732
+ const hasHeaderChildren = Array.from(this.children).some(
733
+ (child) =>
734
+ child instanceof HTMLElement && child.getAttribute('slot') === 'header'
735
+ );
736
+ if (hasHeaderChildren && this.closest('obc-poi-layer-stack') === null) {
617
737
  this.hasHeader = true;
618
738
  }
619
-
620
- const target = (this.shadowRoot?.querySelector('[slot="button"]') ??
621
- this.shadowRoot?.querySelector('obc-poi')) as HTMLElement | null;
622
- if (!target) {
623
- return;
624
- }
625
-
626
- for (const child of headerChildren) {
627
- if (child.parentElement !== target) {
628
- target.appendChild(child);
629
- }
630
- this.applyHeaderState(child);
631
- }
632
- }
633
-
634
- private applyHeaderState(root: ParentNode) {
635
- const headers = [
636
- ...(root instanceof Element && root.matches('obc-poi-header')
637
- ? [root]
638
- : []),
639
- ...root.querySelectorAll('obc-poi-header'),
640
- ] as HTMLElement[];
641
-
642
- for (const header of headers) {
643
- (header as {state?: ObcPoiHeaderState}).state = this.resolvedHeaderState;
644
- header.setAttribute('state', this.resolvedHeaderState);
645
- }
646
- }
647
-
648
- private syncHeaderState() {
649
- this.applyHeaderState(this.renderRoot);
650
739
  }
651
740
 
652
741
  override render() {
@@ -19,6 +19,7 @@ export {ObcPoiObjectState as PoiDataObjectState};
19
19
  *
20
20
  * Extends `PoiBase` to provide the "data" variant of the POI system.
21
21
  * Renders `<obc-poi>` with a slotted `<obc-poi-button-data>`.
22
+ * See the "Coordinate Model" section in `PoiBase` (poi-base.ts) for how `x`, `y`, and `buttonY` position the marker.
22
23
  *
23
24
  * @slot - Icon content forwarded to the inner POI object. Defaults to a vessel icon.
24
25
  * @slot header - Optional custom header content forwarded into `obc-poi`.
@@ -60,6 +61,7 @@ export class ObcPoiData extends PoiBase {
60
61
  <slot
61
62
  ><obi-vessel-generic-default-filled></obi-vessel-generic-default-filled
62
63
  ></slot>
64
+ <slot name="header" slot="header"></slot>
63
65
  </obc-poi-button-data>
64
66
  `;
65
67
  }