@oicl/openbridge-webcomponents 0.0.15-dev-20240925080218 → 0.0.15-dev-20241104120701

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.
@@ -44665,22 +44665,13 @@
44665
44665
  "default": "180",
44666
44666
  "attribute": "maxFOV"
44667
44667
  },
44668
- {
44669
- "kind": "field",
44670
- "name": "labels",
44671
- "type": {
44672
- "text": "Label[]"
44673
- },
44674
- "default": "[]"
44675
- },
44676
44668
  {
44677
44669
  "kind": "field",
44678
44670
  "name": "containerWidth",
44679
44671
  "type": {
44680
44672
  "text": "number"
44681
44673
  },
44682
- "default": "0",
44683
- "attribute": "containerWidth"
44674
+ "default": "0"
44684
44675
  },
44685
44676
  {
44686
44677
  "kind": "field",
@@ -44689,12 +44680,11 @@
44689
44680
  "text": "ResizeObserver"
44690
44681
  },
44691
44682
  "privacy": "private",
44692
- "default": "new ResizeObserver((entries) => {\n for (const entry of entries) {\n this.containerWidth = entry.contentRect.width;\n this.updateLabels();\n }\n })"
44683
+ "default": "new ResizeObserver((entries) => {\n for (const entry of entries) {\n this.containerWidth = entry.contentRect.width;\n }\n })"
44693
44684
  },
44694
44685
  {
44695
44686
  "kind": "method",
44696
- "name": "updateLabels",
44697
- "privacy": "private"
44687
+ "name": "generateLabels"
44698
44688
  },
44699
44689
  {
44700
44690
  "kind": "method",
@@ -44729,6 +44719,12 @@
44729
44719
  "type": {
44730
44720
  "text": "number"
44731
44721
  }
44722
+ },
44723
+ {
44724
+ "name": "labels",
44725
+ "type": {
44726
+ "text": "Label[]"
44727
+ }
44732
44728
  }
44733
44729
  ]
44734
44730
  },
@@ -44747,6 +44743,12 @@
44747
44743
  "type": {
44748
44744
  "text": "number"
44749
44745
  }
44746
+ },
44747
+ {
44748
+ "name": "labels",
44749
+ "type": {
44750
+ "text": "Label[]"
44751
+ }
44750
44752
  }
44751
44753
  ]
44752
44754
  },
@@ -44860,14 +44862,6 @@
44860
44862
  },
44861
44863
  "default": "180",
44862
44864
  "fieldName": "maxFOV"
44863
- },
44864
- {
44865
- "name": "containerWidth",
44866
- "type": {
44867
- "text": "number"
44868
- },
44869
- "default": "0",
44870
- "fieldName": "containerWidth"
44871
44865
  }
44872
44866
  ],
44873
44867
  "superclass": {
@@ -22,12 +22,15 @@ export declare class ObcCompassFlat extends LitElement {
22
22
  FOV: number;
23
23
  minFOV: number;
24
24
  maxFOV: number;
25
- labels: Label[];
26
25
  containerWidth: number;
27
26
  private resizeObserver;
28
27
  connectedCallback(): void;
29
28
  disconnectedCallback(): void;
30
- private updateLabels;
29
+ generateLabels(): {
30
+ x: number;
31
+ y: LabelPosition;
32
+ text: string;
33
+ }[];
31
34
  private generateIntervalTickmarks;
32
35
  private generateCardinalTickmarks;
33
36
  private generateTickmarks;
@@ -1 +1 @@
1
- {"version":3,"file":"compass-flat.d.ts","sourceRoot":"","sources":["../../../src/navigation-instruments/compass-flat/compass-flat.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,UAAU,EAAoC,MAAM,KAAK,CAAC;AAIlE,OAAO,0BAA0B,CAAC;AAElC,oBAAY,aAAa;IACvB,GAAG,MAAM;IACT,MAAM,KAAK;CACZ;AAED,oBAAY,UAAU;IACpB,OAAO,gDAAgD;CACxD;AAED,MAAM,WAAW,KAAK;IACpB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,aAAa,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;CACd;AAED,qBACa,cAAe,SAAQ,UAAU;IACjB,SAAS,EAAE,OAAO,CAAQ;IAC1B,YAAY,EAAE,OAAO,CAAS;IAC/B,OAAO,EAAE,MAAM,CAAM;IACrB,OAAO,SAAK;IACZ,gBAAgB,SAAK;IACrB,YAAY,SAAK;IACjB,GAAG,SAAM;IACT,MAAM,SAAM;IACZ,MAAM,SAAO;IACvC,MAAM,EAAE,KAAK,EAAE,CAAM;IAEK,cAAc,SAAK;IAE7C,OAAO,CAAC,cAAc,CAKnB;IAEM,iBAAiB;IAKjB,oBAAoB;IAK7B,OAAO,CAAC,YAAY;IAsCpB,OAAO,CAAC,yBAAyB;IAwBjC,OAAO,CAAC,yBAAyB;IAUjC,OAAO,CAAC,iBAAiB;IAOzB,OAAO,CAAC,kBAAkB;IAmC1B,OAAO,KAAK,MAAM,GAIjB;IAED,OAAO,CAAC,MAAM;IAQL,MAAM;IAgCf,OAAgB,MAAM,0BAA6B;CACpD;AAED,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,qBAAqB;QAC7B,kBAAkB,EAAE,cAAc,CAAC;KACpC;CACF"}
1
+ {"version":3,"file":"compass-flat.d.ts","sourceRoot":"","sources":["../../../src/navigation-instruments/compass-flat/compass-flat.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,UAAU,EAAoC,MAAM,KAAK,CAAC;AAIlE,OAAO,0BAA0B,CAAC;AAElC,oBAAY,aAAa;IACvB,GAAG,MAAM;IACT,MAAM,KAAK;CACZ;AAED,oBAAY,UAAU;IACpB,OAAO,gDAAgD;CACxD;AAED,MAAM,WAAW,KAAK;IACpB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,aAAa,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;CACd;AAED,qBACa,cAAe,SAAQ,UAAU;IACjB,SAAS,EAAE,OAAO,CAAQ;IAC1B,YAAY,EAAE,OAAO,CAAS;IAC/B,OAAO,EAAE,MAAM,CAAM;IACrB,OAAO,SAAK;IACZ,gBAAgB,SAAK;IACrB,YAAY,SAAK;IACjB,GAAG,SAAM;IACT,MAAM,SAAM;IACZ,MAAM,SAAO;IAE9B,cAAc,SAAK;IAE5B,OAAO,CAAC,cAAc,CAInB;IAEM,iBAAiB;IAKjB,oBAAoB;IAK7B,cAAc;;;;;IAsCd,OAAO,CAAC,yBAAyB;IAwBjC,OAAO,CAAC,yBAAyB;IAajC,OAAO,CAAC,iBAAiB;IAOzB,OAAO,CAAC,kBAAkB;IAmC1B,OAAO,KAAK,MAAM,GAIjB;IAED,OAAO,CAAC,MAAM;IAQL,MAAM;IAiCf,OAAgB,MAAM,0BAA6B;CACpD;AAED,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,qBAAqB;QAC7B,kBAAkB,EAAE,cAAc,CAAC;KACpC;CACF"}
@@ -1,6 +1,6 @@
1
1
  import { unsafeCSS, LitElement, svg } from "lit";
2
2
  import componentStyle from "./compass-flat.css.js";
3
- import { property, customElement } from "lit/decorators.js";
3
+ import { property, state, customElement } from "lit/decorators.js";
4
4
  import { TickmarkType } from "../watch-flat/tickmark-flat.js";
5
5
  import "../watch-flat/watch-flat.js";
6
6
  var __defProp = Object.defineProperty;
@@ -35,12 +35,10 @@ let ObcCompassFlat = class extends LitElement {
35
35
  this.FOV = 45;
36
36
  this.minFOV = 45;
37
37
  this.maxFOV = 180;
38
- this.labels = [];
39
38
  this.containerWidth = 0;
40
39
  this.resizeObserver = new ResizeObserver((entries) => {
41
40
  for (const entry of entries) {
42
41
  this.containerWidth = entry.contentRect.width;
43
- this.updateLabels();
44
42
  }
45
43
  });
46
44
  }
@@ -52,11 +50,11 @@ let ObcCompassFlat = class extends LitElement {
52
50
  super.disconnectedCallback();
53
51
  this.resizeObserver.unobserve(this);
54
52
  }
55
- updateLabels() {
53
+ generateLabels() {
56
54
  if (this.containerWidth < 192) {
57
- this.labels = [];
55
+ return [];
58
56
  } else if (this.containerWidth <= 300) {
59
- this.labels = [
57
+ return [
60
58
  { x: -180, y: -45, text: "S" },
61
59
  { x: -90, y: -45, text: "W" },
62
60
  { x: 0, y: -45, text: "N" },
@@ -68,7 +66,7 @@ let ObcCompassFlat = class extends LitElement {
68
66
  { x: 540, y: -45, text: "S" }
69
67
  ];
70
68
  } else {
71
- this.labels = [
69
+ return [
72
70
  { x: -180, y: -45, text: "S" },
73
71
  { x: -135, y: -45, text: "SW" },
74
72
  { x: -90, y: -45, text: "W" },
@@ -105,16 +103,16 @@ let ObcCompassFlat = class extends LitElement {
105
103
  }
106
104
  return tickmarks;
107
105
  }
108
- generateCardinalTickmarks(scale) {
106
+ generateCardinalTickmarks(scale, labels) {
109
107
  const tickmarks = [];
110
- for (const label of this.labels) {
108
+ for (const label of labels) {
111
109
  tickmarks.push({ angle: label.x * scale, type: TickmarkType.main });
112
110
  }
113
111
  return tickmarks;
114
112
  }
115
- generateTickmarks(scale) {
113
+ generateTickmarks(scale, labels) {
116
114
  return [
117
- ...this.generateCardinalTickmarks(scale),
115
+ ...this.generateCardinalTickmarks(scale, labels),
118
116
  ...this.generateIntervalTickmarks(scale)
119
117
  ];
120
118
  }
@@ -167,14 +165,16 @@ let ObcCompassFlat = class extends LitElement {
167
165
  const baseOffset = 5;
168
166
  const translationScale = baseOffset * 35 / this.FOV;
169
167
  const translation = angleDiff * translationScale;
170
- const tickmarks = this.generateTickmarks(translationScale);
171
- this.labels.map((l) => {
172
- l.x = l.x * translationScale;
173
- });
168
+ const labels = this.generateLabels();
169
+ const tickmarks = this.generateTickmarks(translationScale, labels);
170
+ const scaledLabels = labels.map((l) => ({
171
+ ...l,
172
+ x: l.x * translationScale
173
+ }));
174
174
  const viewBox = this.noPadding ? "-192 -128 384 128" : "-200 -144 400 144";
175
175
  return svg`
176
176
  <div class="container">
177
- <obc-watch-flat .noPadding=${this.noPadding} .FOVIndicator=${this.FOVIndicator ? this.renderFOVIndicator() : []} .labels=${this.labels} .rotation=${this.heading} .tickmarks=${tickmarks} .tickmarkSpacing=${translationScale}></obc-watch-flat>
177
+ <obc-watch-flat .noPadding=${this.noPadding} .FOVIndicator=${this.FOVIndicator ? this.renderFOVIndicator() : []} .labels=${scaledLabels} .rotation=${this.heading} .tickmarks=${tickmarks} .tickmarkSpacing=${translationScale}></obc-watch-flat>
178
178
  <svg viewBox=${viewBox} xmlns="http://www.w3.org/2000/svg">
179
179
  ${this.HDGSvg}${this.COGSvg(translation)}
180
180
  </div>
@@ -210,7 +210,7 @@ __decorateClass([
210
210
  property({ type: Number })
211
211
  ], ObcCompassFlat.prototype, "maxFOV", 2);
212
212
  __decorateClass([
213
- property({ type: Number })
213
+ state()
214
214
  ], ObcCompassFlat.prototype, "containerWidth", 2);
215
215
  ObcCompassFlat = __decorateClass([
216
216
  customElement("obc-compass-flat")
@@ -1 +1 @@
1
- {"version":3,"file":"compass-flat.js","sources":["../../../src/navigation-instruments/compass-flat/compass-flat.ts"],"sourcesContent":["import {LitElement, svg, SVGTemplateResult, unsafeCSS} from 'lit';\nimport componentStyle from './compass-flat.css?inline';\nimport {customElement, property} from 'lit/decorators.js';\nimport {Tickmark, TickmarkType} from '../watch-flat/tickmark-flat';\nimport '../watch-flat/watch-flat';\n\nexport enum LabelPosition {\n top = -45,\n bottom = 50,\n}\n\nexport enum LabelStyle {\n regular = 'var(--instrument-tick-mark-secondary-color)',\n}\n\nexport interface Label {\n x: number;\n y: LabelPosition;\n text: string;\n}\n\n@customElement('obc-compass-flat')\nexport class ObcCompassFlat extends LitElement {\n @property({type: Boolean}) noPadding: boolean = true;\n @property({type: Boolean}) FOVIndicator: boolean = false;\n @property({type: Number}) padding: number = 16;\n @property({type: Number}) heading = 0;\n @property({type: Number}) courseOverGround = 0;\n @property({type: Number}) tickInterval = 5;\n @property({type: Number}) FOV = 45;\n @property({type: Number}) minFOV = 45;\n @property({type: Number}) maxFOV = 180;\n labels: Label[] = [];\n\n @property({type: Number}) containerWidth = 0;\n\n private resizeObserver: ResizeObserver = new ResizeObserver((entries) => {\n for (const entry of entries) {\n this.containerWidth = entry.contentRect.width;\n this.updateLabels();\n }\n });\n\n override connectedCallback() {\n super.connectedCallback();\n this.resizeObserver.observe(this);\n }\n\n override disconnectedCallback() {\n super.disconnectedCallback();\n this.resizeObserver.unobserve(this);\n }\n\n private updateLabels() {\n if (this.containerWidth < 192) {\n this.labels = [];\n } else if (this.containerWidth <= 300) {\n this.labels = [\n {x: -180, y: LabelPosition.top, text: 'S'},\n {x: -90, y: LabelPosition.top, text: 'W'},\n {x: 0, y: LabelPosition.top, text: 'N'},\n {x: 90, y: LabelPosition.top, text: 'E'},\n {x: 180, y: LabelPosition.top, text: 'S'},\n {x: 270, y: LabelPosition.top, text: 'W'},\n {x: 360, y: LabelPosition.top, text: 'N'},\n {x: 450, y: LabelPosition.top, text: 'E'},\n {x: 540, y: LabelPosition.top, text: 'S'},\n ];\n } else {\n this.labels = [\n {x: -180, y: LabelPosition.top, text: 'S'},\n {x: -135, y: LabelPosition.top, text: 'SW'},\n {x: -90, y: LabelPosition.top, text: 'W'},\n {x: -45, y: LabelPosition.top, text: 'NW'},\n {x: 0, y: LabelPosition.top, text: 'N'},\n {x: 45, y: LabelPosition.top, text: 'NE'},\n {x: 90, y: LabelPosition.top, text: 'E'},\n {x: 135, y: LabelPosition.top, text: 'SE'},\n {x: 180, y: LabelPosition.top, text: 'S'},\n {x: 225, y: LabelPosition.top, text: 'SW'},\n {x: 270, y: LabelPosition.top, text: 'W'},\n {x: 315, y: LabelPosition.top, text: 'NW'},\n {x: 360, y: LabelPosition.top, text: 'N'},\n {x: 405, y: LabelPosition.top, text: 'NE'},\n {x: 450, y: LabelPosition.top, text: 'E'},\n {x: 495, y: LabelPosition.top, text: 'SE'},\n {x: 540, y: LabelPosition.top, text: 'S'},\n ];\n }\n }\n\n private generateIntervalTickmarks(scale: number): Tickmark[] {\n const tickmarks: Tickmark[] = [];\n let cardinalInterval = 90;\n\n if (this.containerWidth > 300) {\n cardinalInterval = 45;\n } else if (this.containerWidth < 192) {\n cardinalInterval = 0;\n }\n\n for (\n let angle = -180;\n angle < this.maxFOV * 3;\n angle += this.tickInterval\n ) {\n if (cardinalInterval !== 0 && angle % cardinalInterval === 0) {\n continue;\n }\n tickmarks.push({angle: angle * scale, type: TickmarkType.secondary});\n }\n\n return tickmarks;\n }\n\n private generateCardinalTickmarks(scale: number): Tickmark[] {\n const tickmarks: Tickmark[] = [];\n\n for (const label of this.labels) {\n tickmarks.push({angle: label.x * scale, type: TickmarkType.main});\n }\n\n return tickmarks;\n }\n\n private generateTickmarks(scale: number): Tickmark[] {\n return [\n ...this.generateCardinalTickmarks(scale),\n ...this.generateIntervalTickmarks(scale),\n ];\n }\n\n private renderFOVIndicator(): SVGTemplateResult[] {\n const indicators: SVGTemplateResult[] = [];\n\n const maxAdjustment = 10;\n const minContainerWidth = 300;\n const maxContainerWidth = 512;\n\n let yAdjustment = 0;\n if (this.containerWidth < maxContainerWidth) {\n const widthRange = maxContainerWidth - minContainerWidth;\n const scaleFactor =\n (maxContainerWidth - this.containerWidth) / widthRange;\n yAdjustment = scaleFactor * maxAdjustment;\n }\n\n const y = LabelPosition.bottom + yAdjustment;\n\n indicators.push(svg`\n <text x=\"-175\" y=${y} class=\"label left\" fill=${LabelStyle.regular}>\n ${-this.FOV}\\u00B0\n </text>`);\n\n indicators.push(svg`\n <text x=\"0\" y=${y} class=\"label\" fill=${LabelStyle.regular}>\n ${this.heading}\\u00B0\n </text>`);\n\n indicators.push(svg`\n <text x=\"175\" y=${y} class=\"label right\" fill=${LabelStyle.regular}>\n ${this.FOV}\\u00B0\n </text>`);\n\n return indicators;\n }\n\n private get HDGSvg(): SVGTemplateResult {\n return svg`<g transform=\"translate(-24, -74)\">\n <path d=\"M36.7011 44.1445L36.6898 44.1379L36.6781 44.1318L24.2301 37.6823L24.0001 37.5631L23.7701 37.6823L11.3221 44.1318L11.3104 44.1379L11.2991 44.1445C9.25497 45.3438 6.78661 43.308 7.68828 41.0919L22.6036 4.43285C23.1096 3.18905 24.8906 3.18905 25.3967 4.43284L40.3119 41.0919C41.2136 43.308 38.7452 45.3438 36.7011 44.1445Z\" fill=\"var(--instrument-enhanced-secondary-color)\" stroke=\"var(--border-silhouette-color)\"/>\n </g>`;\n }\n\n private COGSvg(translation: number): SVGTemplateResult {\n return svg`\n <g transform=\"translate(${-24 + translation}, -74)\">\n <path d=\"M31.9025 36.0262L33.1068 36.6502L32.5956 35.3938L24.4632 15.406L24.0001 14.2677L23.537 15.406L15.4046 35.3938L14.8935 36.6502L16.0978 36.0262L24.0001 31.9319L31.9025 36.0262ZM36.7011 44.1445L36.6898 44.1379L36.6781 44.1318L24.2301 37.6823L24.0001 37.5631L23.7701 37.6823L11.3221 44.1318L11.3104 44.1379L11.2991 44.1445C9.25497 45.3438 6.78661 43.308 7.68828 41.0919L22.6036 4.43285C23.1096 3.18905 24.8906 3.18905 25.3967 4.43284L40.3119 41.0919C41.2136 43.308 38.7452 45.3438 36.7011 44.1445Z\" fill=\"var(--instrument-enhanced-secondary-color)\" stroke=\"var(--border-silhouette-color)\"/>\n </g>\n `;\n }\n\n override render() {\n let angleDiff = this.courseOverGround - this.heading;\n\n if (angleDiff > this.maxFOV) {\n angleDiff -= 360;\n } else if (angleDiff < -this.maxFOV) {\n angleDiff += 360;\n }\n\n this.FOV = Math.max(this.minFOV, Math.abs(angleDiff));\n\n const baseOffset = 5;\n const translationScale = (baseOffset * 35) / this.FOV;\n\n const translation = angleDiff * translationScale;\n\n const tickmarks = this.generateTickmarks(translationScale);\n this.labels.map((l) => {\n l.x = l.x * translationScale;\n });\n\n const viewBox = this.noPadding ? '-192 -128 384 128' : '-200 -144 400 144';\n\n return svg`\n <div class=\"container\">\n <obc-watch-flat .noPadding=${this.noPadding} .FOVIndicator=${this.FOVIndicator ? this.renderFOVIndicator() : []} .labels=${this.labels} .rotation=${this.heading} .tickmarks=${tickmarks} .tickmarkSpacing=${translationScale}></obc-watch-flat>\n <svg viewBox=${viewBox} xmlns=\"http://www.w3.org/2000/svg\"> \n ${this.HDGSvg}${this.COGSvg(translation)}\n </div>\n `;\n }\n\n static override styles = unsafeCSS(componentStyle);\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'obc-compass-flat': ObcCompassFlat;\n }\n}\n"],"names":["LabelPosition","LabelStyle"],"mappings":";;;;;;;;;;;;;;;;AAMY,IAAA,kCAAAA,mBAAL;AACLA,iBAAAA,eAAA,SAAM,GAAN,IAAA;AACAA,iBAAAA,eAAA,YAAS,EAAT,IAAA;AAFUA,SAAAA;AAAA,GAAA,iBAAA,CAAA,CAAA;AAKA,IAAA,+BAAAC,gBAA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AAA,WAAA,CAAA;AACA,gBAAA;AAAA,EAAzB,SAAS,EAAC,MAAM,QAAO;AAAA,GALb,eAKe,WAAA,oBAAA,CAAA;AACA,gBAAA;AAAA,EAAzB,SAAS,EAAC,MAAM,QAAO;AAAA,GANb,eAMe,WAAA,gBAAA,CAAA;AACA,gBAAA;AAAA,EAAzB,SAAS,EAAC,MAAM,QAAO;AAAA,GAPb,eAOe,WAAA,OAAA,CAAA;AACA,gBAAA;AAAA,EAAzB,SAAS,EAAC,MAAM,QAAO;AAAA,GARb,eAQe,WAAA,UAAA,CAAA;AACA,gBAAA;AAAA,EAAzB,SAAS,EAAC,MAAM,QAAO;AAAA,GATb,eASe,WAAA,UAAA,CAAA;AAGA,gBAAA;AAAA,EAAzB,SAAS,EAAC,MAAM,QAAO;AAAA,GAZb,eAYe,WAAA,kBAAA,CAAA;AAZf,iBAAN,gBAAA;AAAA,EADN,cAAc,kBAAkB;AAAA,GACpB,cAAA;"}
1
+ {"version":3,"file":"compass-flat.js","sources":["../../../src/navigation-instruments/compass-flat/compass-flat.ts"],"sourcesContent":["import {LitElement, svg, SVGTemplateResult, unsafeCSS} from 'lit';\nimport componentStyle from './compass-flat.css?inline';\nimport {customElement, property, state} from 'lit/decorators.js';\nimport {Tickmark, TickmarkType} from '../watch-flat/tickmark-flat';\nimport '../watch-flat/watch-flat';\n\nexport enum LabelPosition {\n top = -45,\n bottom = 50,\n}\n\nexport enum LabelStyle {\n regular = 'var(--instrument-tick-mark-secondary-color)',\n}\n\nexport interface Label {\n x: number;\n y: LabelPosition;\n text: string;\n}\n\n@customElement('obc-compass-flat')\nexport class ObcCompassFlat extends LitElement {\n @property({type: Boolean}) noPadding: boolean = true;\n @property({type: Boolean}) FOVIndicator: boolean = false;\n @property({type: Number}) padding: number = 16;\n @property({type: Number}) heading = 0;\n @property({type: Number}) courseOverGround = 0;\n @property({type: Number}) tickInterval = 5;\n @property({type: Number}) FOV = 45;\n @property({type: Number}) minFOV = 45;\n @property({type: Number}) maxFOV = 180;\n\n @state() containerWidth = 0;\n\n private resizeObserver: ResizeObserver = new ResizeObserver((entries) => {\n for (const entry of entries) {\n this.containerWidth = entry.contentRect.width;\n }\n });\n\n override connectedCallback() {\n super.connectedCallback();\n this.resizeObserver.observe(this);\n }\n\n override disconnectedCallback() {\n super.disconnectedCallback();\n this.resizeObserver.unobserve(this);\n }\n\n generateLabels() {\n if (this.containerWidth < 192) {\n return [];\n } else if (this.containerWidth <= 300) {\n return [\n {x: -180, y: LabelPosition.top, text: 'S'},\n {x: -90, y: LabelPosition.top, text: 'W'},\n {x: 0, y: LabelPosition.top, text: 'N'},\n {x: 90, y: LabelPosition.top, text: 'E'},\n {x: 180, y: LabelPosition.top, text: 'S'},\n {x: 270, y: LabelPosition.top, text: 'W'},\n {x: 360, y: LabelPosition.top, text: 'N'},\n {x: 450, y: LabelPosition.top, text: 'E'},\n {x: 540, y: LabelPosition.top, text: 'S'},\n ];\n } else {\n return [\n {x: -180, y: LabelPosition.top, text: 'S'},\n {x: -135, y: LabelPosition.top, text: 'SW'},\n {x: -90, y: LabelPosition.top, text: 'W'},\n {x: -45, y: LabelPosition.top, text: 'NW'},\n {x: 0, y: LabelPosition.top, text: 'N'},\n {x: 45, y: LabelPosition.top, text: 'NE'},\n {x: 90, y: LabelPosition.top, text: 'E'},\n {x: 135, y: LabelPosition.top, text: 'SE'},\n {x: 180, y: LabelPosition.top, text: 'S'},\n {x: 225, y: LabelPosition.top, text: 'SW'},\n {x: 270, y: LabelPosition.top, text: 'W'},\n {x: 315, y: LabelPosition.top, text: 'NW'},\n {x: 360, y: LabelPosition.top, text: 'N'},\n {x: 405, y: LabelPosition.top, text: 'NE'},\n {x: 450, y: LabelPosition.top, text: 'E'},\n {x: 495, y: LabelPosition.top, text: 'SE'},\n {x: 540, y: LabelPosition.top, text: 'S'},\n ];\n }\n }\n\n private generateIntervalTickmarks(scale: number): Tickmark[] {\n const tickmarks: Tickmark[] = [];\n let cardinalInterval = 90;\n\n if (this.containerWidth > 300) {\n cardinalInterval = 45;\n } else if (this.containerWidth < 192) {\n cardinalInterval = 0;\n }\n\n for (\n let angle = -180;\n angle < this.maxFOV * 3;\n angle += this.tickInterval\n ) {\n if (cardinalInterval !== 0 && angle % cardinalInterval === 0) {\n continue;\n }\n tickmarks.push({angle: angle * scale, type: TickmarkType.secondary});\n }\n\n return tickmarks;\n }\n\n private generateCardinalTickmarks(\n scale: number,\n labels: Label[]\n ): Tickmark[] {\n const tickmarks: Tickmark[] = [];\n\n for (const label of labels) {\n tickmarks.push({angle: label.x * scale, type: TickmarkType.main});\n }\n\n return tickmarks;\n }\n\n private generateTickmarks(scale: number, labels: Label[]): Tickmark[] {\n return [\n ...this.generateCardinalTickmarks(scale, labels),\n ...this.generateIntervalTickmarks(scale),\n ];\n }\n\n private renderFOVIndicator(): SVGTemplateResult[] {\n const indicators: SVGTemplateResult[] = [];\n\n const maxAdjustment = 10;\n const minContainerWidth = 300;\n const maxContainerWidth = 512;\n\n let yAdjustment = 0;\n if (this.containerWidth < maxContainerWidth) {\n const widthRange = maxContainerWidth - minContainerWidth;\n const scaleFactor =\n (maxContainerWidth - this.containerWidth) / widthRange;\n yAdjustment = scaleFactor * maxAdjustment;\n }\n\n const y = LabelPosition.bottom + yAdjustment;\n\n indicators.push(svg`\n <text x=\"-175\" y=${y} class=\"label left\" fill=${LabelStyle.regular}>\n ${-this.FOV}\\u00B0\n </text>`);\n\n indicators.push(svg`\n <text x=\"0\" y=${y} class=\"label\" fill=${LabelStyle.regular}>\n ${this.heading}\\u00B0\n </text>`);\n\n indicators.push(svg`\n <text x=\"175\" y=${y} class=\"label right\" fill=${LabelStyle.regular}>\n ${this.FOV}\\u00B0\n </text>`);\n\n return indicators;\n }\n\n private get HDGSvg(): SVGTemplateResult {\n return svg`<g transform=\"translate(-24, -74)\">\n <path d=\"M36.7011 44.1445L36.6898 44.1379L36.6781 44.1318L24.2301 37.6823L24.0001 37.5631L23.7701 37.6823L11.3221 44.1318L11.3104 44.1379L11.2991 44.1445C9.25497 45.3438 6.78661 43.308 7.68828 41.0919L22.6036 4.43285C23.1096 3.18905 24.8906 3.18905 25.3967 4.43284L40.3119 41.0919C41.2136 43.308 38.7452 45.3438 36.7011 44.1445Z\" fill=\"var(--instrument-enhanced-secondary-color)\" stroke=\"var(--border-silhouette-color)\"/>\n </g>`;\n }\n\n private COGSvg(translation: number): SVGTemplateResult {\n return svg`\n <g transform=\"translate(${-24 + translation}, -74)\">\n <path d=\"M31.9025 36.0262L33.1068 36.6502L32.5956 35.3938L24.4632 15.406L24.0001 14.2677L23.537 15.406L15.4046 35.3938L14.8935 36.6502L16.0978 36.0262L24.0001 31.9319L31.9025 36.0262ZM36.7011 44.1445L36.6898 44.1379L36.6781 44.1318L24.2301 37.6823L24.0001 37.5631L23.7701 37.6823L11.3221 44.1318L11.3104 44.1379L11.2991 44.1445C9.25497 45.3438 6.78661 43.308 7.68828 41.0919L22.6036 4.43285C23.1096 3.18905 24.8906 3.18905 25.3967 4.43284L40.3119 41.0919C41.2136 43.308 38.7452 45.3438 36.7011 44.1445Z\" fill=\"var(--instrument-enhanced-secondary-color)\" stroke=\"var(--border-silhouette-color)\"/>\n </g>\n `;\n }\n\n override render() {\n let angleDiff = this.courseOverGround - this.heading;\n\n if (angleDiff > this.maxFOV) {\n angleDiff -= 360;\n } else if (angleDiff < -this.maxFOV) {\n angleDiff += 360;\n }\n\n this.FOV = Math.max(this.minFOV, Math.abs(angleDiff));\n\n const baseOffset = 5;\n const translationScale = (baseOffset * 35) / this.FOV;\n\n const translation = angleDiff * translationScale;\n const labels = this.generateLabels();\n const tickmarks = this.generateTickmarks(translationScale, labels);\n const scaledLabels = labels.map((l) => ({\n ...l,\n x: l.x * translationScale,\n }));\n\n const viewBox = this.noPadding ? '-192 -128 384 128' : '-200 -144 400 144';\n\n return svg`\n <div class=\"container\">\n <obc-watch-flat .noPadding=${this.noPadding} .FOVIndicator=${this.FOVIndicator ? this.renderFOVIndicator() : []} .labels=${scaledLabels} .rotation=${this.heading} .tickmarks=${tickmarks} .tickmarkSpacing=${translationScale}></obc-watch-flat>\n <svg viewBox=${viewBox} xmlns=\"http://www.w3.org/2000/svg\"> \n ${this.HDGSvg}${this.COGSvg(translation)}\n </div>\n `;\n }\n\n static override styles = unsafeCSS(componentStyle);\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'obc-compass-flat': ObcCompassFlat;\n }\n}\n"],"names":["LabelPosition","LabelStyle"],"mappings":";;;;;;;;;;;;;;;;AAMY,IAAA,kCAAAA,mBAAL;AACLA,iBAAAA,eAAA,SAAM,GAAN,IAAA;AACAA,iBAAAA,eAAA,YAAS,EAAT,IAAA;AAFUA,SAAAA;AAAA,GAAA,iBAAA,CAAA,CAAA;AAKA,IAAA,+BAAAC,gBAAL;AACLA,cAAA,SAAU,IAAA;AADAA,SAAAA;AAAA,GAAA,cAAA,CAAA,CAAA;AAWC,IAAA,iBAAN,cAA6B,WAAW;AAAA,EAAxC,cAAA;AAAA,UAAA,GAAA,SAAA;AAC2C,SAAA,YAAA;AACG,SAAA,eAAA;AACP,SAAA,UAAA;AACR,SAAA,UAAA;AACS,SAAA,mBAAA;AACJ,SAAA,eAAA;AACT,SAAA,MAAA;AACG,SAAA,SAAA;AACA,SAAA,SAAA;AAET,SAAA,iBAAA;AAE1B,SAAQ,iBAAiC,IAAI,eAAe,CAAC,YAAY;AACvE,iBAAW,SAAS,SAAS;AACtB,aAAA,iBAAiB,MAAM,YAAY;AAAA,MAC1C;AAAA,IAAA,CACD;AAAA,EAAA;AAAA,EAEQ,oBAAoB;AAC3B,UAAM,kBAAkB;AACnB,SAAA,eAAe,QAAQ,IAAI;AAAA,EAClC;AAAA,EAES,uBAAuB;AAC9B,UAAM,qBAAqB;AACtB,SAAA,eAAe,UAAU,IAAI;AAAA,EACpC;AAAA,EAEA,iBAAiB;AACX,QAAA,KAAK,iBAAiB,KAAK;AAC7B,aAAO;IAAC,WACC,KAAK,kBAAkB,KAAK;AAC9B,aAAA;AA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gBAAgB;AAAA,uBAC/M,OAAO;AAAA,UACpB,KAAK,MAAM,GAAG,KAAK,OAAO,WAAW,CAAC;AAAA;AAAA;AAAA,EAG9C;AAGF;AAlMa,eAiMK,SAAS,UAAU,cAAc;AAhMtB,gBAAA;AAAA,EAA1B,SAAS,EAAC,MAAM,SAAQ;AAAA,GADd,eACgB,WAAA,aAAA,CAAA;AACA,gBAAA;AAAA,EAA1B,SAAS,EAAC,MAAM,SAAQ;AAAA,GAFd,eAEgB,WAAA,gBAAA,CAAA;AACD,gBAAA;AAAA,EAAzB,SAAS,EAAC,MAAM,QAAO;AAAA,GAHb,eAGe,WAAA,WAAA,CAAA;AACA,gBAAA;AAAA,EAAzB,SAAS,EAAC,MAAM,QAAO;AAAA,GAJb,eAIe,WAAA,WAAA,CAAA;AACA,gBAAA;AAAA,EAAzB,SAAS,EAAC,MAAM,QAAO;AAAA,GALb,eAKe,WAAA,oBAAA,CAAA;AACA,gBAAA;AAAA,EAAzB,SAAS,EAAC,MAAM,QAAO;AAAA,GANb,eAMe,WAAA,gBAAA,CAAA;AACA,gBAAA;AAAA,EAAzB,SAAS,EAAC,MAAM,QAAO;AAAA,GAPb,eAOe,WAAA,OAAA,CAAA;AACA,gBAAA;AAAA,EAAzB,SAAS,EAAC,MAAM,QAAO;AAAA,GARb,eAQe,WAAA,UAAA,CAAA;AACA,gBAAA;AAAA,EAAzB,SAAS,EAAC,MAAM,QAAO;AAAA,GATb,eASe,WAAA,UAAA,CAAA;AAEjB,gBAAA;AAAA,EAAR,MAAM;AAAA,GAXI,eAWF,WAAA,kBAAA,CAAA;AAXE,iBAAN,gBAAA;AAAA,EADN,cAAc,kBAAkB;AAAA,GACpB,cAAA;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@oicl/openbridge-webcomponents",
3
- "version": "0.0.15-dev-20240925080218",
3
+ "version": "0.0.15-dev-20241104120701",
4
4
  "type": "module",
5
5
  "repository": {
6
6
  "type": "git",
@@ -1,6 +1,6 @@
1
1
  import {LitElement, svg, SVGTemplateResult, unsafeCSS} from 'lit';
2
2
  import componentStyle from './compass-flat.css?inline';
3
- import {customElement, property} from 'lit/decorators.js';
3
+ import {customElement, property, state} from 'lit/decorators.js';
4
4
  import {Tickmark, TickmarkType} from '../watch-flat/tickmark-flat';
5
5
  import '../watch-flat/watch-flat';
6
6
 
@@ -30,14 +30,12 @@ export class ObcCompassFlat extends LitElement {
30
30
  @property({type: Number}) FOV = 45;
31
31
  @property({type: Number}) minFOV = 45;
32
32
  @property({type: Number}) maxFOV = 180;
33
- labels: Label[] = [];
34
33
 
35
- @property({type: Number}) containerWidth = 0;
34
+ @state() containerWidth = 0;
36
35
 
37
36
  private resizeObserver: ResizeObserver = new ResizeObserver((entries) => {
38
37
  for (const entry of entries) {
39
38
  this.containerWidth = entry.contentRect.width;
40
- this.updateLabels();
41
39
  }
42
40
  });
43
41
 
@@ -51,11 +49,11 @@ export class ObcCompassFlat extends LitElement {
51
49
  this.resizeObserver.unobserve(this);
52
50
  }
53
51
 
54
- private updateLabels() {
52
+ generateLabels() {
55
53
  if (this.containerWidth < 192) {
56
- this.labels = [];
54
+ return [];
57
55
  } else if (this.containerWidth <= 300) {
58
- this.labels = [
56
+ return [
59
57
  {x: -180, y: LabelPosition.top, text: 'S'},
60
58
  {x: -90, y: LabelPosition.top, text: 'W'},
61
59
  {x: 0, y: LabelPosition.top, text: 'N'},
@@ -67,7 +65,7 @@ export class ObcCompassFlat extends LitElement {
67
65
  {x: 540, y: LabelPosition.top, text: 'S'},
68
66
  ];
69
67
  } else {
70
- this.labels = [
68
+ return [
71
69
  {x: -180, y: LabelPosition.top, text: 'S'},
72
70
  {x: -135, y: LabelPosition.top, text: 'SW'},
73
71
  {x: -90, y: LabelPosition.top, text: 'W'},
@@ -113,19 +111,22 @@ export class ObcCompassFlat extends LitElement {
113
111
  return tickmarks;
114
112
  }
115
113
 
116
- private generateCardinalTickmarks(scale: number): Tickmark[] {
114
+ private generateCardinalTickmarks(
115
+ scale: number,
116
+ labels: Label[]
117
+ ): Tickmark[] {
117
118
  const tickmarks: Tickmark[] = [];
118
119
 
119
- for (const label of this.labels) {
120
+ for (const label of labels) {
120
121
  tickmarks.push({angle: label.x * scale, type: TickmarkType.main});
121
122
  }
122
123
 
123
124
  return tickmarks;
124
125
  }
125
126
 
126
- private generateTickmarks(scale: number): Tickmark[] {
127
+ private generateTickmarks(scale: number, labels: Label[]): Tickmark[] {
127
128
  return [
128
- ...this.generateCardinalTickmarks(scale),
129
+ ...this.generateCardinalTickmarks(scale, labels),
129
130
  ...this.generateIntervalTickmarks(scale),
130
131
  ];
131
132
  }
@@ -194,17 +195,18 @@ export class ObcCompassFlat extends LitElement {
194
195
  const translationScale = (baseOffset * 35) / this.FOV;
195
196
 
196
197
  const translation = angleDiff * translationScale;
197
-
198
- const tickmarks = this.generateTickmarks(translationScale);
199
- this.labels.map((l) => {
200
- l.x = l.x * translationScale;
201
- });
198
+ const labels = this.generateLabels();
199
+ const tickmarks = this.generateTickmarks(translationScale, labels);
200
+ const scaledLabels = labels.map((l) => ({
201
+ ...l,
202
+ x: l.x * translationScale,
203
+ }));
202
204
 
203
205
  const viewBox = this.noPadding ? '-192 -128 384 128' : '-200 -144 400 144';
204
206
 
205
207
  return svg`
206
208
  <div class="container">
207
- <obc-watch-flat .noPadding=${this.noPadding} .FOVIndicator=${this.FOVIndicator ? this.renderFOVIndicator() : []} .labels=${this.labels} .rotation=${this.heading} .tickmarks=${tickmarks} .tickmarkSpacing=${translationScale}></obc-watch-flat>
209
+ <obc-watch-flat .noPadding=${this.noPadding} .FOVIndicator=${this.FOVIndicator ? this.renderFOVIndicator() : []} .labels=${scaledLabels} .rotation=${this.heading} .tickmarks=${tickmarks} .tickmarkSpacing=${translationScale}></obc-watch-flat>
208
210
  <svg viewBox=${viewBox} xmlns="http://www.w3.org/2000/svg">
209
211
  ${this.HDGSvg}${this.COGSvg(translation)}
210
212
  </div>