@oicl/openbridge-webcomponents-full-bundle 2.1.0-next.5 → 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.
- package/.storybook/vitest.hidden-mount.setup.ts +96 -0
- package/bundle/openbridge-webcomponents.bundle.js +47 -8
- package/bundle/openbridge-webcomponents.bundle.js.map +1 -1
- package/custom-elements.json +65 -3
- package/dist/ar/chart-object-vessel-button/chart-object-vessel-button.d.ts.map +1 -1
- package/dist/ar/chart-object-vessel-button/chart-object-vessel-button.js +1 -1
- package/dist/ar/chart-object-vessel-button/chart-object-vessel-button.js.map +1 -1
- package/dist/building-blocks/chart-line/chart-line-base.css.js +8 -0
- package/dist/building-blocks/chart-line/chart-line-base.css.js.map +1 -1
- package/dist/building-blocks/chart-line/chart-line-base.d.ts +3 -1
- package/dist/building-blocks/chart-line/chart-line-base.d.ts.map +1 -1
- package/dist/building-blocks/chart-line/chart-line-base.js +9 -4
- package/dist/building-blocks/chart-line/chart-line-base.js.map +1 -1
- package/dist/charthelpers/label-threshold.d.ts +7 -2
- package/dist/charthelpers/label-threshold.d.ts.map +1 -1
- package/dist/charthelpers/label-threshold.js +14 -2
- package/dist/charthelpers/label-threshold.js.map +1 -1
- package/dist/navigation-instruments/watch-flat/watch-flat.d.ts +8 -0
- package/dist/navigation-instruments/watch-flat/watch-flat.d.ts.map +1 -1
- package/dist/navigation-instruments/watch-flat/watch-flat.js +17 -1
- package/dist/navigation-instruments/watch-flat/watch-flat.js.map +1 -1
- package/package.json +2 -1
- package/script/compact-ng-exports.d.mts +8 -0
- package/script/compact-ng-exports.mjs +109 -0
- package/script/compact-ng-exports.test.ts +66 -0
- package/src/ar/chart-object-vessel-button/chart-object-vessel-button.ts +3 -1
- package/src/building-blocks/chart-line/chart-line-base.css +8 -0
- package/src/building-blocks/chart-line/chart-line-base.ts +16 -5
- package/src/charthelpers/label-threshold.spec.ts +28 -0
- package/src/charthelpers/label-threshold.ts +16 -3
- package/src/navigation-instruments/rot-linear/rot-linear.spec.ts +36 -0
- package/src/navigation-instruments/watch-flat/watch-flat.spec.ts +76 -0
- package/src/navigation-instruments/watch-flat/watch-flat.ts +22 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/** What a chart does when its canvas is resized. */
|
|
2
2
|
export interface LabelThresholdCallbacks {
|
|
3
|
-
/** The resize crossed the threshold. */
|
|
3
|
+
/** The resize crossed the threshold, or gave the canvas its first size. */
|
|
4
4
|
rebuild(): void;
|
|
5
5
|
/** The resize stayed on one side of it. */
|
|
6
6
|
update(): void;
|
|
@@ -11,9 +11,14 @@ export interface LabelThresholdCallbacks {
|
|
|
11
11
|
* therefore needs a rebuild, while every other resize is an in-place
|
|
12
12
|
* update. This owns the which-side state; the chart owns the decision.
|
|
13
13
|
*
|
|
14
|
+
* A chart created while its canvas had no size (in a hidden container) is
|
|
15
|
+
* also rebuilt once, when the canvas first gets one: Chart.js keeps layout
|
|
16
|
+
* state from that empty first pass, and a resize leaves the plot a pixel off
|
|
17
|
+
* a chart created at its real size.
|
|
18
|
+
*
|
|
14
19
|
* @param target - The chart's canvas. A detached target is ignored: it has no size and no chart to serve.
|
|
15
20
|
* @param isAboveThreshold - The chart's own test, read once now and after every resize.
|
|
16
|
-
* @param callbacks - `rebuild` on a crossing, `update` otherwise.
|
|
21
|
+
* @param callbacks - `rebuild` on a crossing or a first size, `update` otherwise.
|
|
17
22
|
* @returns The observer, for the chart to disconnect in `disconnectedCallback`.
|
|
18
23
|
*/
|
|
19
24
|
export declare function observeLabelThreshold(target: Element, isAboveThreshold: () => boolean, callbacks: LabelThresholdCallbacks): ResizeObserver;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"label-threshold.d.ts","sourceRoot":"","sources":["../../src/charthelpers/label-threshold.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"label-threshold.d.ts","sourceRoot":"","sources":["../../src/charthelpers/label-threshold.ts"],"names":[],"mappings":"AAKA,oDAAoD;AACpD,MAAM,WAAW,uBAAuB;IACtC,2EAA2E;IAC3E,OAAO,IAAI,IAAI,CAAC;IAChB,2CAA2C;IAC3C,MAAM,IAAI,IAAI,CAAC;CAChB;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,qBAAqB,CACnC,MAAM,EAAE,OAAO,EACf,gBAAgB,EAAE,MAAM,OAAO,EAC/B,SAAS,EAAE,uBAAuB,GACjC,cAAc,CAkBhB"}
|
|
@@ -1,23 +1,35 @@
|
|
|
1
1
|
//#region src/charthelpers/label-threshold.ts
|
|
2
|
+
function hasSize(target) {
|
|
3
|
+
const { width, height } = target.getBoundingClientRect();
|
|
4
|
+
return width > 0 && height > 0;
|
|
5
|
+
}
|
|
2
6
|
/**
|
|
3
7
|
* A chart installs its label plugins at creation time, from which side of
|
|
4
8
|
* the label threshold the canvas is on. A resize that crosses the threshold
|
|
5
9
|
* therefore needs a rebuild, while every other resize is an in-place
|
|
6
10
|
* update. This owns the which-side state; the chart owns the decision.
|
|
7
11
|
*
|
|
12
|
+
* A chart created while its canvas had no size (in a hidden container) is
|
|
13
|
+
* also rebuilt once, when the canvas first gets one: Chart.js keeps layout
|
|
14
|
+
* state from that empty first pass, and a resize leaves the plot a pixel off
|
|
15
|
+
* a chart created at its real size.
|
|
16
|
+
*
|
|
8
17
|
* @param target - The chart's canvas. A detached target is ignored: it has no size and no chart to serve.
|
|
9
18
|
* @param isAboveThreshold - The chart's own test, read once now and after every resize.
|
|
10
|
-
* @param callbacks - `rebuild` on a crossing, `update` otherwise.
|
|
19
|
+
* @param callbacks - `rebuild` on a crossing or a first size, `update` otherwise.
|
|
11
20
|
* @returns The observer, for the chart to disconnect in `disconnectedCallback`.
|
|
12
21
|
*/
|
|
13
22
|
function observeLabelThreshold(target, isAboveThreshold, callbacks) {
|
|
14
23
|
let wasAbove = isAboveThreshold();
|
|
24
|
+
let hadSize = hasSize(target);
|
|
15
25
|
const observer = new ResizeObserver(() => {
|
|
16
26
|
if (!target.isConnected) return;
|
|
17
27
|
const isAbove = isAboveThreshold();
|
|
18
28
|
const crossed = isAbove !== wasAbove;
|
|
19
29
|
wasAbove = isAbove;
|
|
20
|
-
|
|
30
|
+
const gotSize = !hadSize && hasSize(target);
|
|
31
|
+
hadSize = hasSize(target);
|
|
32
|
+
if (crossed || gotSize) callbacks.rebuild();
|
|
21
33
|
else callbacks.update();
|
|
22
34
|
});
|
|
23
35
|
observer.observe(target);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"label-threshold.js","names":[],"sources":["../../src/charthelpers/label-threshold.ts"],"sourcesContent":["/** What a chart does when its canvas is resized. */\nexport interface LabelThresholdCallbacks {\n /** The resize crossed the threshold. */\n rebuild(): void;\n /** The resize stayed on one side of it. */\n update(): void;\n}\n\n/**\n * A chart installs its label plugins at creation time, from which side of\n * the label threshold the canvas is on. A resize that crosses the threshold\n * therefore needs a rebuild, while every other resize is an in-place\n * update. This owns the which-side state; the chart owns the decision.\n *\n * @param target - The chart's canvas. A detached target is ignored: it has no size and no chart to serve.\n * @param isAboveThreshold - The chart's own test, read once now and after every resize.\n * @param callbacks - `rebuild` on a crossing, `update` otherwise.\n * @returns The observer, for the chart to disconnect in `disconnectedCallback`.\n */\nexport function observeLabelThreshold(\n target: Element,\n isAboveThreshold: () => boolean,\n callbacks: LabelThresholdCallbacks\n): ResizeObserver {\n let wasAbove = isAboveThreshold();\n const observer = new ResizeObserver(() => {\n if (!target.isConnected) return;\n const isAbove = isAboveThreshold();\n const crossed = isAbove !== wasAbove;\n wasAbove = isAbove;\n if (crossed) {\n callbacks.rebuild();\n } else {\n callbacks.update();\n }\n });\n observer.observe(target);\n return observer;\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"label-threshold.js","names":[],"sources":["../../src/charthelpers/label-threshold.ts"],"sourcesContent":["function hasSize(target: Element): boolean {\n const {width, height} = target.getBoundingClientRect();\n return width > 0 && height > 0;\n}\n\n/** What a chart does when its canvas is resized. */\nexport interface LabelThresholdCallbacks {\n /** The resize crossed the threshold, or gave the canvas its first size. */\n rebuild(): void;\n /** The resize stayed on one side of it. */\n update(): void;\n}\n\n/**\n * A chart installs its label plugins at creation time, from which side of\n * the label threshold the canvas is on. A resize that crosses the threshold\n * therefore needs a rebuild, while every other resize is an in-place\n * update. This owns the which-side state; the chart owns the decision.\n *\n * A chart created while its canvas had no size (in a hidden container) is\n * also rebuilt once, when the canvas first gets one: Chart.js keeps layout\n * state from that empty first pass, and a resize leaves the plot a pixel off\n * a chart created at its real size.\n *\n * @param target - The chart's canvas. A detached target is ignored: it has no size and no chart to serve.\n * @param isAboveThreshold - The chart's own test, read once now and after every resize.\n * @param callbacks - `rebuild` on a crossing or a first size, `update` otherwise.\n * @returns The observer, for the chart to disconnect in `disconnectedCallback`.\n */\nexport function observeLabelThreshold(\n target: Element,\n isAboveThreshold: () => boolean,\n callbacks: LabelThresholdCallbacks\n): ResizeObserver {\n let wasAbove = isAboveThreshold();\n let hadSize = hasSize(target);\n const observer = new ResizeObserver(() => {\n if (!target.isConnected) return;\n const isAbove = isAboveThreshold();\n const crossed = isAbove !== wasAbove;\n wasAbove = isAbove;\n const gotSize = !hadSize && hasSize(target);\n hadSize = hasSize(target);\n if (crossed || gotSize) {\n callbacks.rebuild();\n } else {\n callbacks.update();\n }\n });\n observer.observe(target);\n return observer;\n}\n"],"mappings":";AAAA,SAAS,QAAQ,QAA0B;CACzC,MAAM,EAAC,OAAO,WAAU,OAAO,sBAAsB;CACrD,OAAO,QAAQ,KAAK,SAAS;AAC/B;;;;;;;;;;;;;;;;;AA0BA,SAAgB,sBACd,QACA,kBACA,WACgB;CAChB,IAAI,WAAW,iBAAiB;CAChC,IAAI,UAAU,QAAQ,MAAM;CAC5B,MAAM,WAAW,IAAI,qBAAqB;EACxC,IAAI,CAAC,OAAO,aAAa;EACzB,MAAM,UAAU,iBAAiB;EACjC,MAAM,UAAU,YAAY;EAC5B,WAAW;EACX,MAAM,UAAU,CAAC,WAAW,QAAQ,MAAM;EAC1C,UAAU,QAAQ,MAAM;EACxB,IAAI,WAAW,SACb,UAAU,QAAQ;OAElB,UAAU,OAAO;CAErB,CAAC;CACD,SAAS,QAAQ,MAAM;CACvB,OAAO;AACT"}
|
|
@@ -76,7 +76,14 @@ export declare class ObcWatchFlat extends LitElement {
|
|
|
76
76
|
get rotationsPerMinute(): number;
|
|
77
77
|
private _legacyRotationsPerMinute;
|
|
78
78
|
private _rotController?;
|
|
79
|
+
private _resizeController;
|
|
79
80
|
private get _effectiveRpm();
|
|
81
|
+
/**
|
|
82
|
+
* Rendered px per user-space unit; the labels divide by it to keep their
|
|
83
|
+
* on-screen size. 1:1 while the strip has no width yet (hidden, or not laid
|
|
84
|
+
* out), until the ResizeController re-renders it.
|
|
85
|
+
*/
|
|
86
|
+
private scaleFor;
|
|
80
87
|
private get totalHeight();
|
|
81
88
|
private renderClipPath;
|
|
82
89
|
private renderLabelMask;
|
|
@@ -89,6 +96,7 @@ export declare class ObcWatchFlat extends LitElement {
|
|
|
89
96
|
private getRotTrackY;
|
|
90
97
|
private getRotColors;
|
|
91
98
|
private renderRot;
|
|
99
|
+
firstUpdated(changed: PropertyValues): void;
|
|
92
100
|
updated(changed: PropertyValues): void;
|
|
93
101
|
disconnectedCallback(): void;
|
|
94
102
|
render(): import('lit-html').TemplateResult<1>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"watch-flat.d.ts","sourceRoot":"","sources":["../../../src/navigation-instruments/watch-flat/watch-flat.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,UAAU,EACV,cAAc,EACd,iBAAiB,EAKlB,MAAM,KAAK,CAAC;
|
|
1
|
+
{"version":3,"file":"watch-flat.d.ts","sourceRoot":"","sources":["../../../src/navigation-instruments/watch-flat/watch-flat.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,UAAU,EACV,cAAc,EACd,iBAAiB,EAKlB,MAAM,KAAK,CAAC;AAIb,OAAO,EAAC,QAAQ,EAA0B,M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B;IAEjD,0BAA0B,EAAE,MAAM,GAAG,SAAS,CAAC;IAC/C,qBAAqB,EAAE,MAAM,CAAM;IAE7D;;;;OAIG;IACH,IACI,kBAAkB,CAAC,KAAK,EAAE,MAAM,EAEnC;IACD,IAAI,kBAAkB,IAHQ,MAAM,CAKnC;IAED,OAAO,CAAC,yBAAyB,CAAK;IACtC,OAAO,CAAC,cAAc,CAAC,CAAuB;IAC9C,OAAO,CAAC,iBAAiB,CAAkC;IAE3D,OAAO,KAAK,aAAa,GAOxB;IAED;;;;OAIG;IACH,OAAO,CAAC,QAAQ;IAKhB,OAAO,KAAK,WAAW,GAEtB;IAED,OAAO,CAAC,cAAc;IAUtB,OAAO,CAAC,eAAe;IAqBvB,OAAO,CAAC,YAAY;IAgBpB,OAAO,CAAC,SAAS;IAyDjB,oDAAoD;IACpD,OAAO,KAAK,UAAU,GAMrB;IAED,OAAO,CAAC,cAAc;IAiBtB,OAAO,CAAC,iBAAiB;IA0BzB,OAAO,CAAC,YAAY;IAWpB,OAAO,CAAC,YAAY;IAsCpB,OAAO,CAAC,SAAS;IA0DR,YAAY,CAAC,OAAO,EAAE,cAAc,GAAG,IAAI;IAK3C,OAAO,CAAC,OAAO,EAAE,cAAc,GAAG,IAAI;IAkCtC,oBAAoB,IAAI,IAAI;IAK5B,MAAM;IAgDf,OAAgB,MAAM,0BAA2B;CAClD;AAED,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,qBAAqB;QAC7B,gBAAgB,EAAE,YAAY,CAAC;KAChC;CACF"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { customElement } from "../../decorator.js";
|
|
2
2
|
import __decorate from "../../_virtual/_@oxc-project_runtime@0.150.0/helpers/esm/decorate.js";
|
|
3
3
|
import { Priority } from "../types.js";
|
|
4
|
+
import { measureContainerPx, observeInnerBox } from "../../svghelpers/radial-frame.js";
|
|
4
5
|
import { rect } from "../../svghelpers/rectangular.js";
|
|
5
6
|
import { LinearRotPosition, ROT_ZERO_DEADBAND_PX, RotType, renderLinearRotBarDots, renderLinearRotBarStatic, renderLinearRotDots, renderLinearRotZeroPill } from "../rate-of-turn/rot-renderer.js";
|
|
6
7
|
import { RateOfTurnController, disposeRotController } from "../rate-of-turn/rate-of-turn.controller.js";
|
|
@@ -8,6 +9,7 @@ import { TickmarkStyle, tickmark } from "./tickmark-flat.js";
|
|
|
8
9
|
import watch_flat_default from "./watch-flat.css.js";
|
|
9
10
|
import { LitElement, html, nothing, svg, unsafeCSS } from "lit";
|
|
10
11
|
import { property } from "lit/decorators.js";
|
|
12
|
+
import { ResizeController } from "@lit-labs/observers/resize-controller.js";
|
|
11
13
|
//#region src/navigation-instruments/watch-flat/watch-flat.ts
|
|
12
14
|
var ObcWatchFlat = class ObcWatchFlat extends LitElement {
|
|
13
15
|
constructor(..._args) {
|
|
@@ -35,6 +37,7 @@ var ObcWatchFlat = class ObcWatchFlat extends LitElement {
|
|
|
35
37
|
this.rotAtZeroDeadband = ROT_ZERO_DEADBAND_PX;
|
|
36
38
|
this.rotDotAnimationFactor = 18;
|
|
37
39
|
this._legacyRotationsPerMinute = 0;
|
|
40
|
+
this._resizeController = new ResizeController(this, {});
|
|
38
41
|
}
|
|
39
42
|
/**
|
|
40
43
|
* @deprecated Use `rateOfTurnDegreesPerMinute` (and optionally
|
|
@@ -51,6 +54,15 @@ var ObcWatchFlat = class ObcWatchFlat extends LitElement {
|
|
|
51
54
|
if (this.rateOfTurnDegreesPerMinute != null) return this.rateOfTurnDegreesPerMinute / 360 * this.rotDotAnimationFactor;
|
|
52
55
|
return this._legacyRotationsPerMinute;
|
|
53
56
|
}
|
|
57
|
+
/**
|
|
58
|
+
* Rendered px per user-space unit; the labels divide by it to keep their
|
|
59
|
+
* on-screen size. 1:1 while the strip has no width yet (hidden, or not laid
|
|
60
|
+
* out), until the ResizeController re-renders it.
|
|
61
|
+
*/
|
|
62
|
+
scaleFor(viewBoxWidth) {
|
|
63
|
+
const scale = measureContainerPx(this).width / viewBoxWidth;
|
|
64
|
+
return Number.isFinite(scale) && scale > 0 ? scale : 1;
|
|
65
|
+
}
|
|
54
66
|
get totalHeight() {
|
|
55
67
|
return this.bottomBar ? this.height + this.ticksHeight : this.height;
|
|
56
68
|
}
|
|
@@ -234,6 +246,10 @@ var ObcWatchFlat = class ObcWatchFlat extends LitElement {
|
|
|
234
246
|
</g>
|
|
235
247
|
` : nothing;
|
|
236
248
|
}
|
|
249
|
+
firstUpdated(changed) {
|
|
250
|
+
super.firstUpdated(changed);
|
|
251
|
+
observeInnerBox(this._resizeController, this.renderRoot);
|
|
252
|
+
}
|
|
237
253
|
updated(changed) {
|
|
238
254
|
super.updated(changed);
|
|
239
255
|
const el = this.rotType ? this.renderRoot.querySelector("#rot-spinner") : null;
|
|
@@ -256,7 +272,7 @@ var ObcWatchFlat = class ObcWatchFlat extends LitElement {
|
|
|
256
272
|
const width = (this.width / 2 + this.padding) * 2;
|
|
257
273
|
const th = this.totalHeight;
|
|
258
274
|
const viewBox = `-${width / 2} -${th / 2} ${width} ${th}`;
|
|
259
|
-
const scale = this.
|
|
275
|
+
const scale = this.scaleFor(width);
|
|
260
276
|
const contentOffsetY = this.bottomBar ? -this.ticksHeight / 2 : 0;
|
|
261
277
|
return html`
|
|
262
278
|
<svg
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"watch-flat.js","names":[],"sources":["../../../src/navigation-instruments/watch-flat/watch-flat.ts"],"sourcesContent":["import {\n LitElement,\n PropertyValues,\n SVGTemplateResult,\n html,\n nothing,\n svg,\n unsafeCSS,\n} from 'lit';\nimport {property} from 'lit/decorators.js';\nimport compentStyle from './watch-flat.css?inline';\nimport {Tickmark, TickmarkStyle, tickmark} from './tickmark-flat.js';\nimport {rect} from '../../svghelpers/rectangular.js';\nimport {Label} from '../compass-flat/compass-flat.js';\nimport {customElement} from '../../decorator.js';\nimport {Priority} from '../types.js';\nimport {\n RotType,\n LinearRotPosition,\n renderLinearRotDots,\n renderLinearRotBarStatic,\n renderLinearRotBarDots,\n LINEAR_DOT_ANGLE_SPACING,\n renderLinearRotZeroPill,\n BAR_HALF_THICKNESS,\n ROT_ZERO_DEADBAND_PX,\n} from '../rate-of-turn/rot-renderer.js';\nimport {\n RateOfTurnController,\n disposeRotController,\n} from '../rate-of-turn/rate-of-turn.controller.js';\n\nexport {RotType, LinearRotPosition};\n\n/** Filled segment of the track band, in SVG user-space x-coordinates (center-origin). */\nexport interface WatchFlatBarArea {\n startX: number;\n endX: number;\n fillColor: string;\n}\n\n/** Needle marker spanning the track band at `x` (center-origin). */\nexport interface WatchFlatNeedle {\n x: number;\n fillColor: string;\n strokeColor: string;\n}\n\n/**\n * @property barAreas - Filled segments rendered inside the track band (the linear counterpart of the radial bar areas).\n * @property needles - Needle markers spanning the track band (the linear counterpart of the radial needles).\n * @availableWhen rotPosition rotType!=undefined\n * @property rotStartX - Bar start position in SVG user-space x-coordinates (center-origin). Computed by the parent instrument.\n * @availableWhen rotStartX rotType!=undefined\n * @property rotEndX - Bar end position in SVG user-space x-coordinates (center-origin). Computed by the parent instrument.\n * @availableWhen rotEndX rotType!=undefined\n * @property rotDotSpacing - Pixel spacing between adjacent dots in the linear ROT strip.\n * Must be > 0 to enable animation; the default `0` intentionally disables\n * the spinning dots so the parent instrument must supply a meaningful value\n * derived from the current scale (e.g. `LINEAR_DOT_ANGLE_SPACING * translationScale`).\n * @availableWhen rotDotSpacing rotType!=undefined\n * @availableWhen rotPriority rotType!=undefined\n * @availableWhen rotPortStarboard rotType!=undefined\n * @availableWhen rotAtZeroDeadband rotType==bar\n * @availableWhen rateOfTurnDegreesPerMinute rotType!=undefined\n * @availableWhen rotDotAnimationFactor rotType!=undefined\n * @experimental\n */\n@customElement('obc-watch-flat')\nexport class ObcWatchFlat extends LitElement {\n @property({type: Number}) width = 352;\n @property({type: Number}) height = 72;\n @property({type: Number}) padding = 0;\n @property({type: Number}) rotation = 0;\n @property({type: Number}) tickmarkSpacing = 0;\n @property({type: Number}) angleSetpoint: number | undefined;\n @property({type: Array, attribute: false}) tickmarks: Tickmark[] = [];\n @property({type: Array, attribute: false}) labels: Label[] = [];\n @property({type: Array, attribute: false}) FOVIndicator: SVGTemplateResult[] =\n [];\n @property({type: Number}) trackHeight = (2 / 3) * this.height;\n @property({type: Number}) ticksHeight = this.height - this.trackHeight;\n @property({type: Number}) borderRadius = 8;\n @property({type: Boolean}) bottomBar = false;\n @property({type: Array, attribute: false}) barAreas: WatchFlatBarArea[] = [];\n @property({type: Array, attribute: false}) needles: WatchFlatNeedle[] = [];\n\n @property({type: String}) rotType: RotType | undefined;\n @property({type: String}) rotPosition: LinearRotPosition =\n LinearRotPosition.track;\n @property({type: Number}) rotStartX: number = 0;\n @property({type: Number}) rotEndX: number = 0;\n @property({type: Number}) rotDotSpacing: number = 0;\n @property({type: String}) rotPriority: Priority = Priority.regular;\n @property({type: Boolean}) rotPortStarboard: boolean = false;\n @property({type: Number}) rotAtZeroDeadband: number = ROT_ZERO_DEADBAND_PX;\n\n @property({type: Number}) rateOfTurnDegreesPerMinute: number | undefined;\n @property({type: Number}) rotDotAnimationFactor: number = 18;\n\n /**\n * @deprecated Use `rateOfTurnDegreesPerMinute` (and optionally\n * `rotDotAnimationFactor`) instead. Takes effect only when\n * `rateOfTurnDegreesPerMinute` is `undefined`.\n */\n @property({type: Number})\n set rotationsPerMinute(value: number) {\n this._legacyRotationsPerMinute = value;\n }\n get rotationsPerMinute() {\n return this._legacyRotationsPerMinute;\n }\n\n private _legacyRotationsPerMinute = 0;\n private _rotController?: RateOfTurnController;\n\n private get _effectiveRpm(): number {\n if (this.rateOfTurnDegreesPerMinute != null) {\n return (\n (this.rateOfTurnDegreesPerMinute / 360) * this.rotDotAnimationFactor\n );\n }\n return this._legacyRotationsPerMinute;\n }\n\n private get totalHeight(): number {\n return this.bottomBar ? this.height + this.ticksHeight : this.height;\n }\n\n private renderClipPath(offsetY: number = 0): SVGTemplateResult {\n return svg`\n <clipPath id=\"frameClipPath${offsetY === 0 ? '' : 'Tickmarks'}\">\n <rect x=\"${-this.width / 2}\" y=\"${-this.totalHeight / 2 + offsetY}\" \n width=\"${this.width}\" height=\"${this.totalHeight}\" \n rx=\"${this.borderRadius}\" />\n </clipPath>\n `;\n }\n\n private renderLabelMask(): SVGTemplateResult {\n return svg`\n <mask id=\"labelMask\">\n <rect x=\"${-this.width / 2}\" y=\"${-70}\" \n width=\"${this.width}\" height=\"${32}\"\n />\n <linearGradient id=\"fadeGradient\" gradientUnits=\"userSpaceOnUse\"\n x1=\"${-this.width / 2}\" y1=\"0\" x2=\"${this.width / 2}\" y2=\"0\">\n <stop offset=\"0%\" style=\"stop-color:black; stop-opacity:1;\" />\n <stop offset=\"10%\" style=\"stop-color:white; stop-opacity:1;\" />\n <stop offset=\"50%\" style=\"stop-color:white; stop-opacity:1;\" />\n <stop offset=\"90%\" style=\"stop-color:white; stop-opacity:1;\" />\n <stop offset=\"100%\" style=\"stop-color:black; stop-opacity:1;\" />\n </linearGradient>\n <rect x=\"${-this.width / 2}\" y=\"${-70}\" \n width=\"${this.width}\" height=\"${32}\"\n fill=\"url(#fadeGradient)\" />\n </mask>\n `;\n }\n\n private renderLabels(scale: number): SVGTemplateResult[] {\n const labels: SVGTemplateResult[] = [];\n\n for (const l of this.labels) {\n labels.push(\n svg`<g transform=\"translate(${-this.rotation * this.tickmarkSpacing}, ${-6 / scale})\">\n <text x=${l.x} y=${l.y} class=\"label\" fill=${'var(--instrument-tick-mark-secondary-color)'}>\n ${l.text}\n </text>\n </g>`\n );\n }\n\n return labels;\n }\n\n private watchFace(): SVGTemplateResult {\n const strokeWidth = 1;\n const th = this.totalHeight;\n const topTicksY = -th / 2;\n\n return svg`\n ${this.renderClipPath()}\n ${this.renderClipPath(-40)}\n <g clip-path=\"url(#frameClipPath)\">\n ${rect('frame-track', {\n width: this.width,\n height: this.trackHeight,\n y:\n th / 2 - this.trackHeight - (this.bottomBar ? this.ticksHeight : 0),\n strokeWidth: strokeWidth,\n strokeColor: 'var(--instrument-frame-secondary-color)',\n strokePosition: 'inside',\n fillColor: 'var(--instrument-frame-secondary-color)',\n borderRadius: 0,\n })}\n ${rect('frame-ticks', {\n width: this.width,\n height: this.ticksHeight,\n y: topTicksY,\n strokeWidth: strokeWidth,\n strokeColor: 'var(--instrument-frame-primary-color)',\n strokePosition: 'inside',\n fillColor: 'var(--instrument-frame-primary-color)',\n borderRadius: 0,\n })}\n ${\n this.bottomBar\n ? rect('frame-bottom-bar', {\n width: this.width,\n height: this.ticksHeight,\n y: th / 2 - this.ticksHeight,\n strokeWidth: strokeWidth,\n strokeColor: 'var(--instrument-frame-primary-color)',\n strokePosition: 'inside',\n fillColor: 'var(--instrument-frame-primary-color)',\n borderRadius: 0,\n })\n : nothing\n }\n </g>\n ${rect('frame-outline', {\n width: this.width,\n height: th,\n strokeWidth: strokeWidth,\n strokeColor: 'var(--instrument-frame-tertiary-color)',\n strokePosition: 'inside',\n fillColor: 'none',\n borderRadius: this.borderRadius,\n })}\n `;\n }\n\n /** Top edge of the track band in SVG user space. */\n private get trackBandY(): number {\n return (\n this.totalHeight / 2 -\n this.trackHeight -\n (this.bottomBar ? this.ticksHeight : 0)\n );\n }\n\n private renderBandBars(): SVGTemplateResult[] | typeof nothing {\n if (this.barAreas.length === 0) {\n return nothing;\n }\n return this.barAreas.map(\n (bar) => svg`\n <rect\n x=\"${Math.min(bar.startX, bar.endX)}\"\n y=\"${this.trackBandY}\"\n width=\"${Math.abs(bar.endX - bar.startX)}\"\n height=\"${this.trackHeight}\"\n fill=${bar.fillColor}\n />\n `\n );\n }\n\n private renderBandNeedles(): SVGTemplateResult[] | typeof nothing {\n if (this.needles.length === 0) {\n return nothing;\n }\n return this.needles.map(\n (needle) => svg`\n <rect\n x=\"${needle.x - 4}\"\n y=\"${this.trackBandY}\"\n width=\"8\"\n height=\"${this.trackHeight}\"\n rx=\"4\"\n fill=${needle.fillColor}\n stroke=${needle.strokeColor}\n stroke-width=\"1\"\n vector-effect=\"non-scaling-stroke\"\n paint-order=\"stroke fill\"\n />\n `\n );\n }\n\n // ---------------------------------------------------------------------------\n // ROT (Rate of Turn) — linear\n // ---------------------------------------------------------------------------\n\n private getRotTrackY(): number {\n const th = this.totalHeight;\n if (this.rotPosition === LinearRotPosition.scale) {\n return -th / 2 + this.ticksHeight / 2;\n }\n if (this.bottomBar) {\n return th / 2 - this.ticksHeight / 2;\n }\n return this.height / 2 - this.trackHeight / 2;\n }\n\n private getRotColors(): {\n dotColor: string;\n barBgColor: string;\n } {\n const isEnhanced = this.rotPriority === Priority.enhanced;\n\n if (this.rotPortStarboard) {\n // For bar type, derive direction from bar positions (visual direction);\n // for dots, use spinner RPM.\n const direction =\n this.rotType === RotType.bar\n ? this.rotEndX - this.rotStartX\n : this._effectiveRpm;\n\n if (direction > 0) {\n return {\n dotColor: 'var(--instrument-starboard-secondary-color)',\n barBgColor: 'var(--instrument-starboard-primary-color)',\n };\n }\n if (direction < 0) {\n return {\n dotColor: 'var(--instrument-port-secondary-color)',\n barBgColor: 'var(--instrument-port-primary-color)',\n };\n }\n }\n\n return {\n dotColor: isEnhanced\n ? 'var(--instrument-enhanced-tertiary-color)'\n : 'var(--instrument-regular-tertiary-color)',\n barBgColor: isEnhanced\n ? 'var(--instrument-enhanced-secondary-color)'\n : 'var(--instrument-regular-secondary-color)',\n };\n }\n\n private renderRot(): SVGTemplateResult | typeof nothing {\n if (!this.rotType) return nothing;\n\n const trackY = this.getRotTrackY();\n const {dotColor, barBgColor} = this.getRotColors();\n const canAnimateDots = this.rotDotSpacing > 0;\n\n if (this.rotType === RotType.bar) {\n const span = Math.abs(this.rotEndX - this.rotStartX);\n const zeroDb = Number.isFinite(this.rotAtZeroDeadband)\n ? this.rotAtZeroDeadband\n : ROT_ZERO_DEADBAND_PX;\n\n if (span < Math.max(zeroDb, BAR_HALF_THICKNESS)) {\n return renderLinearRotZeroPill(barBgColor, this.rotStartX, trackY);\n }\n\n return svg`\n ${renderLinearRotBarStatic({\n startX: this.rotStartX,\n endX: this.rotEndX,\n barColor: barBgColor,\n trackY,\n maskId: 'rot-bar-mask-linear',\n })}\n ${\n canAnimateDots\n ? svg`<g clip-path=\"url(#rot-bar-mask-linear)\">\n <g id=\"rot-spinner\">\n ${renderLinearRotBarDots(dotColor, trackY, this.rotDotSpacing, this.width)}\n </g>\n </g>`\n : nothing\n }\n `;\n }\n\n const isEnhanced = this.rotPriority === Priority.enhanced;\n const neutralDotsColor = isEnhanced\n ? 'var(--instrument-enhanced-secondary-color)'\n : 'var(--instrument-regular-secondary-color)';\n let dotsColor = neutralDotsColor;\n if (this.rotPortStarboard) {\n if (this._effectiveRpm > 0) {\n dotsColor = 'var(--instrument-starboard-secondary-color)';\n } else if (this._effectiveRpm < 0) {\n dotsColor = 'var(--instrument-port-secondary-color)';\n }\n }\n return canAnimateDots\n ? svg`\n <g id=\"rot-spinner\">\n ${renderLinearRotDots(dotsColor, trackY, this.rotDotSpacing, this.width)}\n </g>\n `\n : nothing;\n }\n\n override updated(changed: PropertyValues): void {\n super.updated(changed);\n const el = this.rotType\n ? this.renderRoot.querySelector('#rot-spinner')\n : null;\n\n if (!el) {\n this._rotController = disposeRotController(this, this._rotController);\n return;\n }\n\n const cyclePx = 360 * (this.rotDotSpacing / LINEAR_DOT_ANGLE_SPACING);\n\n if (!this._rotController || this._rotController.el !== el) {\n this._rotController = disposeRotController(this, this._rotController);\n this._rotController = new RateOfTurnController(\n this,\n el,\n this._effectiveRpm,\n cyclePx\n );\n } else {\n this._rotController.cyclePx = cyclePx;\n }\n\n if (\n changed.has('rateOfTurnDegreesPerMinute') ||\n changed.has('rotDotAnimationFactor') ||\n changed.has('rotationsPerMinute')\n ) {\n this._rotController.rotationsPerMinute = this._effectiveRpm;\n }\n }\n\n override disconnectedCallback(): void {\n super.disconnectedCallback();\n this._rotController = disposeRotController(this, this._rotController);\n }\n\n override render() {\n const width = (this.width / 2 + this.padding) * 2;\n const th = this.totalHeight;\n const viewBox = `-${width / 2} -${th / 2} ${width} ${th}`;\n const scale = this.clientWidth / width;\n\n const contentOffsetY = this.bottomBar ? -this.ticksHeight / 2 : 0;\n\n return html`\n <svg\n width=\"100%\"\n height=\"100%\"\n viewBox=${viewBox}\n style=\"--scale: ${scale}\"\n >\n ${this.watchFace()} ${this.renderLabelMask()}\n <g clip-path=\"url(#frameClipPath)\">\n ${this.renderBandBars()} ${this.renderBandNeedles()}\n </g>\n\n <g transform=\"translate(0, ${contentOffsetY})\">\n <g clip-path=\"url(#frameClipPath)\">\n ${this.tickmarks.map(\n (t) => svg`\n <g transform=\"translate(${-this.rotation * this.tickmarkSpacing}, 0)\">\n ${tickmark(t.angle, t.type, TickmarkStyle.regular)}\n </g>\n `\n )}\n </g>\n\n <g mask=\"url(#labelMask)\">${this.renderLabels(scale)}</g>\n </g>\n\n ${this.FOVIndicator}\n\n <g clip-path=\"url(#frameClipPath)\">${this.renderRot()}</g>\n ${svg`<line\n x1=\"0\" y1=\"${-this.totalHeight / 2 + this.ticksHeight}\"\n x2=\"0\" y2=\"${this.totalHeight / 2}\"\n stroke=\"var(--instrument-frame-tertiary-color)\"\n stroke-width=\"1\"\n vector-effect=\"non-scaling-stroke\"\n />`}\n </svg>\n `;\n }\n\n static override styles = unsafeCSS(compentStyle);\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'obc-watch-flat': ObcWatchFlat;\n }\n}\n"],"mappings":";;;;;;;;;;;AAqEO,IAAM,eAAN,MAAM,qBAAqB,WAAW;;;EACT,KAAA,QAAA;EACC,KAAA,SAAA;EACC,KAAA,UAAA;EACC,KAAA,WAAA;EACO,KAAA,kBAAA;EAEuB,KAAA,YAAA,CAAC;EACP,KAAA,SAAA,CAAC;EAE5D,KAAA,eAAA,CAAC;EACsC,KAAA,cAAA,IAAI,IAAK,KAAK;EACf,KAAA,cAAA,KAAK,SAAS,KAAK;EAClB,KAAA,eAAA;EACF,KAAA,YAAA;EACmC,KAAA,WAAA,CAAC;EACH,KAAA,UAAA,CAAC;EAIvE,KAAA,cAAA,kBAAkB;EAC0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AC,MAAM,QAAO,CAAC,CAAA,GAAA,aAAA,WAAA,oBAAA,KAAA,CAAA;AACxB,WAAA,CAAA,SAAS,EAAC,MAAM,OAAM,CAAC,CAAA,GAAA,aAAA,WAAA,qBAAA,KAAA,CAAA;AAEvB,WAAA,CAAA,SAAS,EAAC,MAAM,OAAM,CAAC,CAAA,GAAA,aAAA,WAAA,8BAAA,KAAA,CAAA;AACvB,WAAA,CAAA,SAAS,EAAC,MAAM,OAAM,CAAC,CAAA,GAAA,aAAA,WAAA,yBAAA,KAAA,CAAA;AAOvB,WAAA,CAAA,SAAS,EAAC,MAAM,OAAM,CAAC,CAAA,GAAA,aAAA,WAAA,sBAAA,IAAA;AArCzB,eAAA,WAAA,CAAA,cAAc,gBAAgB,CAAA,GAAA,YAAA"}
|
|
1
|
+
{"version":3,"file":"watch-flat.js","names":[],"sources":["../../../src/navigation-instruments/watch-flat/watch-flat.ts"],"sourcesContent":["import {\n LitElement,\n PropertyValues,\n SVGTemplateResult,\n html,\n nothing,\n svg,\n unsafeCSS,\n} from 'lit';\nimport {property} from 'lit/decorators.js';\nimport {ResizeController} from '@lit-labs/observers/resize-controller.js';\nimport compentStyle from './watch-flat.css?inline';\nimport {Tickmark, TickmarkStyle, tickmark} from './tickmark-flat.js';\nimport {rect} from '../../svghelpers/rectangular.js';\nimport {\n measureContainerPx,\n observeInnerBox,\n} from '../../svghelpers/radial-frame.js';\nimport {Label} from '../compass-flat/compass-flat.js';\nimport {customElement} from '../../decorator.js';\nimport {Priority} from '../types.js';\nimport {\n RotType,\n LinearRotPosition,\n renderLinearRotDots,\n renderLinearRotBarStatic,\n renderLinearRotBarDots,\n LINEAR_DOT_ANGLE_SPACING,\n renderLinearRotZeroPill,\n BAR_HALF_THICKNESS,\n ROT_ZERO_DEADBAND_PX,\n} from '../rate-of-turn/rot-renderer.js';\nimport {\n RateOfTurnController,\n disposeRotController,\n} from '../rate-of-turn/rate-of-turn.controller.js';\n\nexport {RotType, LinearRotPosition};\n\n/** Filled segment of the track band, in SVG user-space x-coordinates (center-origin). */\nexport interface WatchFlatBarArea {\n startX: number;\n endX: number;\n fillColor: string;\n}\n\n/** Needle marker spanning the track band at `x` (center-origin). */\nexport interface WatchFlatNeedle {\n x: number;\n fillColor: string;\n strokeColor: string;\n}\n\n/**\n * @property barAreas - Filled segments rendered inside the track band (the linear counterpart of the radial bar areas).\n * @property needles - Needle markers spanning the track band (the linear counterpart of the radial needles).\n * @availableWhen rotPosition rotType!=undefined\n * @property rotStartX - Bar start position in SVG user-space x-coordinates (center-origin). Computed by the parent instrument.\n * @availableWhen rotStartX rotType!=undefined\n * @property rotEndX - Bar end position in SVG user-space x-coordinates (center-origin). Computed by the parent instrument.\n * @availableWhen rotEndX rotType!=undefined\n * @property rotDotSpacing - Pixel spacing between adjacent dots in the linear ROT strip.\n * Must be > 0 to enable animation; the default `0` intentionally disables\n * the spinning dots so the parent instrument must supply a meaningful value\n * derived from the current scale (e.g. `LINEAR_DOT_ANGLE_SPACING * translationScale`).\n * @availableWhen rotDotSpacing rotType!=undefined\n * @availableWhen rotPriority rotType!=undefined\n * @availableWhen rotPortStarboard rotType!=undefined\n * @availableWhen rotAtZeroDeadband rotType==bar\n * @availableWhen rateOfTurnDegreesPerMinute rotType!=undefined\n * @availableWhen rotDotAnimationFactor rotType!=undefined\n * @experimental\n */\n@customElement('obc-watch-flat')\nexport class ObcWatchFlat extends LitElement {\n @property({type: Number}) width = 352;\n @property({type: Number}) height = 72;\n @property({type: Number}) padding = 0;\n @property({type: Number}) rotation = 0;\n @property({type: Number}) tickmarkSpacing = 0;\n @property({type: Number}) angleSetpoint: number | undefined;\n @property({type: Array, attribute: false}) tickmarks: Tickmark[] = [];\n @property({type: Array, attribute: false}) labels: Label[] = [];\n @property({type: Array, attribute: false}) FOVIndicator: SVGTemplateResult[] =\n [];\n @property({type: Number}) trackHeight = (2 / 3) * this.height;\n @property({type: Number}) ticksHeight = this.height - this.trackHeight;\n @property({type: Number}) borderRadius = 8;\n @property({type: Boolean}) bottomBar = false;\n @property({type: Array, attribute: false}) barAreas: WatchFlatBarArea[] = [];\n @property({type: Array, attribute: false}) needles: WatchFlatNeedle[] = [];\n\n @property({type: String}) rotType: RotType | undefined;\n @property({type: String}) rotPosition: LinearRotPosition =\n LinearRotPosition.track;\n @property({type: Number}) rotStartX: number = 0;\n @property({type: Number}) rotEndX: number = 0;\n @property({type: Number}) rotDotSpacing: number = 0;\n @property({type: String}) rotPriority: Priority = Priority.regular;\n @property({type: Boolean}) rotPortStarboard: boolean = false;\n @property({type: Number}) rotAtZeroDeadband: number = ROT_ZERO_DEADBAND_PX;\n\n @property({type: Number}) rateOfTurnDegreesPerMinute: number | undefined;\n @property({type: Number}) rotDotAnimationFactor: number = 18;\n\n /**\n * @deprecated Use `rateOfTurnDegreesPerMinute` (and optionally\n * `rotDotAnimationFactor`) instead. Takes effect only when\n * `rateOfTurnDegreesPerMinute` is `undefined`.\n */\n @property({type: Number})\n set rotationsPerMinute(value: number) {\n this._legacyRotationsPerMinute = value;\n }\n get rotationsPerMinute() {\n return this._legacyRotationsPerMinute;\n }\n\n private _legacyRotationsPerMinute = 0;\n private _rotController?: RateOfTurnController;\n private _resizeController = new ResizeController(this, {});\n\n private get _effectiveRpm(): number {\n if (this.rateOfTurnDegreesPerMinute != null) {\n return (\n (this.rateOfTurnDegreesPerMinute / 360) * this.rotDotAnimationFactor\n );\n }\n return this._legacyRotationsPerMinute;\n }\n\n /**\n * Rendered px per user-space unit; the labels divide by it to keep their\n * on-screen size. 1:1 while the strip has no width yet (hidden, or not laid\n * out), until the ResizeController re-renders it.\n */\n private scaleFor(viewBoxWidth: number): number {\n const scale = measureContainerPx(this).width / viewBoxWidth;\n return Number.isFinite(scale) && scale > 0 ? scale : 1;\n }\n\n private get totalHeight(): number {\n return this.bottomBar ? this.height + this.ticksHeight : this.height;\n }\n\n private renderClipPath(offsetY: number = 0): SVGTemplateResult {\n return svg`\n <clipPath id=\"frameClipPath${offsetY === 0 ? '' : 'Tickmarks'}\">\n <rect x=\"${-this.width / 2}\" y=\"${-this.totalHeight / 2 + offsetY}\" \n width=\"${this.width}\" height=\"${this.totalHeight}\" \n rx=\"${this.borderRadius}\" />\n </clipPath>\n `;\n }\n\n private renderLabelMask(): SVGTemplateResult {\n return svg`\n <mask id=\"labelMask\">\n <rect x=\"${-this.width / 2}\" y=\"${-70}\" \n width=\"${this.width}\" height=\"${32}\"\n />\n <linearGradient id=\"fadeGradient\" gradientUnits=\"userSpaceOnUse\"\n x1=\"${-this.width / 2}\" y1=\"0\" x2=\"${this.width / 2}\" y2=\"0\">\n <stop offset=\"0%\" style=\"stop-color:black; stop-opacity:1;\" />\n <stop offset=\"10%\" style=\"stop-color:white; stop-opacity:1;\" />\n <stop offset=\"50%\" style=\"stop-color:white; stop-opacity:1;\" />\n <stop offset=\"90%\" style=\"stop-color:white; stop-opacity:1;\" />\n <stop offset=\"100%\" style=\"stop-color:black; stop-opacity:1;\" />\n </linearGradient>\n <rect x=\"${-this.width / 2}\" y=\"${-70}\" \n width=\"${this.width}\" height=\"${32}\"\n fill=\"url(#fadeGradient)\" />\n </mask>\n `;\n }\n\n private renderLabels(scale: number): SVGTemplateResult[] {\n const labels: SVGTemplateResult[] = [];\n\n for (const l of this.labels) {\n labels.push(\n svg`<g transform=\"translate(${-this.rotation * this.tickmarkSpacing}, ${-6 / scale})\">\n <text x=${l.x} y=${l.y} class=\"label\" fill=${'var(--instrument-tick-mark-secondary-color)'}>\n ${l.text}\n </text>\n </g>`\n );\n }\n\n return labels;\n }\n\n private watchFace(): SVGTemplateResult {\n const strokeWidth = 1;\n const th = this.totalHeight;\n const topTicksY = -th / 2;\n\n return svg`\n ${this.renderClipPath()}\n ${this.renderClipPath(-40)}\n <g clip-path=\"url(#frameClipPath)\">\n ${rect('frame-track', {\n width: this.width,\n height: this.trackHeight,\n y:\n th / 2 - this.trackHeight - (this.bottomBar ? this.ticksHeight : 0),\n strokeWidth: strokeWidth,\n strokeColor: 'var(--instrument-frame-secondary-color)',\n strokePosition: 'inside',\n fillColor: 'var(--instrument-frame-secondary-color)',\n borderRadius: 0,\n })}\n ${rect('frame-ticks', {\n width: this.width,\n height: this.ticksHeight,\n y: topTicksY,\n strokeWidth: strokeWidth,\n strokeColor: 'var(--instrument-frame-primary-color)',\n strokePosition: 'inside',\n fillColor: 'var(--instrument-frame-primary-color)',\n borderRadius: 0,\n })}\n ${\n this.bottomBar\n ? rect('frame-bottom-bar', {\n width: this.width,\n height: this.ticksHeight,\n y: th / 2 - this.ticksHeight,\n strokeWidth: strokeWidth,\n strokeColor: 'var(--instrument-frame-primary-color)',\n strokePosition: 'inside',\n fillColor: 'var(--instrument-frame-primary-color)',\n borderRadius: 0,\n })\n : nothing\n }\n </g>\n ${rect('frame-outline', {\n width: this.width,\n height: th,\n strokeWidth: strokeWidth,\n strokeColor: 'var(--instrument-frame-tertiary-color)',\n strokePosition: 'inside',\n fillColor: 'none',\n borderRadius: this.borderRadius,\n })}\n `;\n }\n\n /** Top edge of the track band in SVG user space. */\n private get trackBandY(): number {\n return (\n this.totalHeight / 2 -\n this.trackHeight -\n (this.bottomBar ? this.ticksHeight : 0)\n );\n }\n\n private renderBandBars(): SVGTemplateResult[] | typeof nothing {\n if (this.barAreas.length === 0) {\n return nothing;\n }\n return this.barAreas.map(\n (bar) => svg`\n <rect\n x=\"${Math.min(bar.startX, bar.endX)}\"\n y=\"${this.trackBandY}\"\n width=\"${Math.abs(bar.endX - bar.startX)}\"\n height=\"${this.trackHeight}\"\n fill=${bar.fillColor}\n />\n `\n );\n }\n\n private renderBandNeedles(): SVGTemplateResult[] | typeof nothing {\n if (this.needles.length === 0) {\n return nothing;\n }\n return this.needles.map(\n (needle) => svg`\n <rect\n x=\"${needle.x - 4}\"\n y=\"${this.trackBandY}\"\n width=\"8\"\n height=\"${this.trackHeight}\"\n rx=\"4\"\n fill=${needle.fillColor}\n stroke=${needle.strokeColor}\n stroke-width=\"1\"\n vector-effect=\"non-scaling-stroke\"\n paint-order=\"stroke fill\"\n />\n `\n );\n }\n\n // ---------------------------------------------------------------------------\n // ROT (Rate of Turn) — linear\n // ---------------------------------------------------------------------------\n\n private getRotTrackY(): number {\n const th = this.totalHeight;\n if (this.rotPosition === LinearRotPosition.scale) {\n return -th / 2 + this.ticksHeight / 2;\n }\n if (this.bottomBar) {\n return th / 2 - this.ticksHeight / 2;\n }\n return this.height / 2 - this.trackHeight / 2;\n }\n\n private getRotColors(): {\n dotColor: string;\n barBgColor: string;\n } {\n const isEnhanced = this.rotPriority === Priority.enhanced;\n\n if (this.rotPortStarboard) {\n // For bar type, derive direction from bar positions (visual direction);\n // for dots, use spinner RPM.\n const direction =\n this.rotType === RotType.bar\n ? this.rotEndX - this.rotStartX\n : this._effectiveRpm;\n\n if (direction > 0) {\n return {\n dotColor: 'var(--instrument-starboard-secondary-color)',\n barBgColor: 'var(--instrument-starboard-primary-color)',\n };\n }\n if (direction < 0) {\n return {\n dotColor: 'var(--instrument-port-secondary-color)',\n barBgColor: 'var(--instrument-port-primary-color)',\n };\n }\n }\n\n return {\n dotColor: isEnhanced\n ? 'var(--instrument-enhanced-tertiary-color)'\n : 'var(--instrument-regular-tertiary-color)',\n barBgColor: isEnhanced\n ? 'var(--instrument-enhanced-secondary-color)'\n : 'var(--instrument-regular-secondary-color)',\n };\n }\n\n private renderRot(): SVGTemplateResult | typeof nothing {\n if (!this.rotType) return nothing;\n\n const trackY = this.getRotTrackY();\n const {dotColor, barBgColor} = this.getRotColors();\n const canAnimateDots = this.rotDotSpacing > 0;\n\n if (this.rotType === RotType.bar) {\n const span = Math.abs(this.rotEndX - this.rotStartX);\n const zeroDb = Number.isFinite(this.rotAtZeroDeadband)\n ? this.rotAtZeroDeadband\n : ROT_ZERO_DEADBAND_PX;\n\n if (span < Math.max(zeroDb, BAR_HALF_THICKNESS)) {\n return renderLinearRotZeroPill(barBgColor, this.rotStartX, trackY);\n }\n\n return svg`\n ${renderLinearRotBarStatic({\n startX: this.rotStartX,\n endX: this.rotEndX,\n barColor: barBgColor,\n trackY,\n maskId: 'rot-bar-mask-linear',\n })}\n ${\n canAnimateDots\n ? svg`<g clip-path=\"url(#rot-bar-mask-linear)\">\n <g id=\"rot-spinner\">\n ${renderLinearRotBarDots(dotColor, trackY, this.rotDotSpacing, this.width)}\n </g>\n </g>`\n : nothing\n }\n `;\n }\n\n const isEnhanced = this.rotPriority === Priority.enhanced;\n const neutralDotsColor = isEnhanced\n ? 'var(--instrument-enhanced-secondary-color)'\n : 'var(--instrument-regular-secondary-color)';\n let dotsColor = neutralDotsColor;\n if (this.rotPortStarboard) {\n if (this._effectiveRpm > 0) {\n dotsColor = 'var(--instrument-starboard-secondary-color)';\n } else if (this._effectiveRpm < 0) {\n dotsColor = 'var(--instrument-port-secondary-color)';\n }\n }\n return canAnimateDots\n ? svg`\n <g id=\"rot-spinner\">\n ${renderLinearRotDots(dotsColor, trackY, this.rotDotSpacing, this.width)}\n </g>\n `\n : nothing;\n }\n\n override firstUpdated(changed: PropertyValues): void {\n super.firstUpdated(changed);\n observeInnerBox(this._resizeController, this.renderRoot);\n }\n\n override updated(changed: PropertyValues): void {\n super.updated(changed);\n const el = this.rotType\n ? this.renderRoot.querySelector('#rot-spinner')\n : null;\n\n if (!el) {\n this._rotController = disposeRotController(this, this._rotController);\n return;\n }\n\n const cyclePx = 360 * (this.rotDotSpacing / LINEAR_DOT_ANGLE_SPACING);\n\n if (!this._rotController || this._rotController.el !== el) {\n this._rotController = disposeRotController(this, this._rotController);\n this._rotController = new RateOfTurnController(\n this,\n el,\n this._effectiveRpm,\n cyclePx\n );\n } else {\n this._rotController.cyclePx = cyclePx;\n }\n\n if (\n changed.has('rateOfTurnDegreesPerMinute') ||\n changed.has('rotDotAnimationFactor') ||\n changed.has('rotationsPerMinute')\n ) {\n this._rotController.rotationsPerMinute = this._effectiveRpm;\n }\n }\n\n override disconnectedCallback(): void {\n super.disconnectedCallback();\n this._rotController = disposeRotController(this, this._rotController);\n }\n\n override render() {\n const width = (this.width / 2 + this.padding) * 2;\n const th = this.totalHeight;\n const viewBox = `-${width / 2} -${th / 2} ${width} ${th}`;\n const scale = this.scaleFor(width);\n\n const contentOffsetY = this.bottomBar ? -this.ticksHeight / 2 : 0;\n\n return html`\n <svg\n width=\"100%\"\n height=\"100%\"\n viewBox=${viewBox}\n style=\"--scale: ${scale}\"\n >\n ${this.watchFace()} ${this.renderLabelMask()}\n <g clip-path=\"url(#frameClipPath)\">\n ${this.renderBandBars()} ${this.renderBandNeedles()}\n </g>\n\n <g transform=\"translate(0, ${contentOffsetY})\">\n <g clip-path=\"url(#frameClipPath)\">\n ${this.tickmarks.map(\n (t) => svg`\n <g transform=\"translate(${-this.rotation * this.tickmarkSpacing}, 0)\">\n ${tickmark(t.angle, t.type, TickmarkStyle.regular)}\n </g>\n `\n )}\n </g>\n\n <g mask=\"url(#labelMask)\">${this.renderLabels(scale)}</g>\n </g>\n\n ${this.FOVIndicator}\n\n <g clip-path=\"url(#frameClipPath)\">${this.renderRot()}</g>\n ${svg`<line\n x1=\"0\" y1=\"${-this.totalHeight / 2 + this.ticksHeight}\"\n x2=\"0\" y2=\"${this.totalHeight / 2}\"\n stroke=\"var(--instrument-frame-tertiary-color)\"\n stroke-width=\"1\"\n vector-effect=\"non-scaling-stroke\"\n />`}\n </svg>\n `;\n }\n\n static override styles = unsafeCSS(compentStyle);\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'obc-watch-flat': ObcWatchFlat;\n }\n}\n"],"mappings":";;;;;;;;;;;;;AA0EO,IAAM,eAAN,MAAM,qBAAqB,WAAW;;;EACT,KAAA,QAAA;EACC,KAAA,SAAA;EACC,KAAA,UAAA;EACC,KAAA,WAAA;EACO,KAAA,kBAAA;EAEuB,KAAA,YAAA,CAAC;EACP,KAAA,SAAA,CAAC;EAE5D,KAAA,eAAA,CAAC;EACsC,KAAA,cAAA,IAAI,IAAK,KAAK;EACf,KAAA,cAAA,KAAK,SAAS,KAAK;EAClB,KAAA,eAAA;EACF,KAAA,YA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CAAA,SAAS,EAAC,MAAM,OAAM,CAAC,CAAA,GAAA,aAAA,WAAA,aAAA,KAAA,CAAA;AACvB,WAAA,CAAA,SAAS,EAAC,MAAM,OAAM,CAAC,CAAA,GAAA,aAAA,WAAA,WAAA,KAAA,CAAA;AACvB,WAAA,CAAA,SAAS,EAAC,MAAM,OAAM,CAAC,CAAA,GAAA,aAAA,WAAA,iBAAA,KAAA,CAAA;AACvB,WAAA,CAAA,SAAS,EAAC,MAAM,OAAM,CAAC,CAAA,GAAA,aAAA,WAAA,eAAA,KAAA,CAAA;AACvB,WAAA,CAAA,SAAS,EAAC,MAAM,QAAO,CAAC,CAAA,GAAA,aAAA,WAAA,oBAAA,KAAA,CAAA;AACxB,WAAA,CAAA,SAAS,EAAC,MAAM,OAAM,CAAC,CAAA,GAAA,aAAA,WAAA,qBAAA,KAAA,CAAA;AAEvB,WAAA,CAAA,SAAS,EAAC,MAAM,OAAM,CAAC,CAAA,GAAA,aAAA,WAAA,8BAAA,KAAA,CAAA;AACvB,WAAA,CAAA,SAAS,EAAC,MAAM,OAAM,CAAC,CAAA,GAAA,aAAA,WAAA,yBAAA,KAAA,CAAA;AAOvB,WAAA,CAAA,SAAS,EAAC,MAAM,OAAM,CAAC,CAAA,GAAA,aAAA,WAAA,sBAAA,IAAA;AArCzB,eAAA,WAAA,CAAA,cAAc,gBAAgB,CAAA,GAAA,YAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@oicl/openbridge-webcomponents-full-bundle",
|
|
3
|
-
"version": "2.1.0-next.
|
|
3
|
+
"version": "2.1.0-next.7",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -129,6 +129,7 @@
|
|
|
129
129
|
"test-storybook:watch": "vitest --project=storybook --watch",
|
|
130
130
|
"test-a11y": "vitest run --config vitest.a11y.config.ts && tsx ./script/check-a11y-baseline.ts",
|
|
131
131
|
"test-a11y:update": "vitest run --config vitest.a11y.config.ts && tsx ./script/check-a11y-baseline.ts --update",
|
|
132
|
+
"test-hidden-mount": "vitest run --config vitest.hidden-mount.config.ts",
|
|
132
133
|
"build-storybook": "storybook build",
|
|
133
134
|
"storybook:server": "http-server -p 6006 storybook-static",
|
|
134
135
|
"preview": "vite preview",
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
// Collapses the Angular package's per-entry-point `exports` into one subpath
|
|
2
|
+
// pattern. ng-packagr writes an explicit export for every secondary entry
|
|
3
|
+
// point (one per component and icon, ~2400), which makes dist/package.json
|
|
4
|
+
// ~445 kB. Some npm-compatible registries cap package.json at 384000 bytes
|
|
5
|
+
// and reject the publish. Every generated entry follows the same layout, so
|
|
6
|
+
// a single `./*` pattern resolves to exactly the same files.
|
|
7
|
+
//
|
|
8
|
+
// Usage: node compact-ng-exports.mjs <path/to/dist/package.json>
|
|
9
|
+
import * as fs from 'node:fs';
|
|
10
|
+
import * as path from 'node:path';
|
|
11
|
+
import {fileURLToPath} from 'node:url';
|
|
12
|
+
|
|
13
|
+
const PATTERN_KEY = './*';
|
|
14
|
+
/** The smallest registry `package.json` cap seen in the field. */
|
|
15
|
+
const MAX_PACKAGE_JSON_BYTES = 384000;
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Returns a copy of `packageJson` whose secondary entry-point exports are
|
|
19
|
+
* replaced by one `./*` pattern. Entries that do not match the pattern exactly
|
|
20
|
+
* (nested subpaths, extra conditions) are kept as explicit exports, which take
|
|
21
|
+
* precedence over the pattern.
|
|
22
|
+
*/
|
|
23
|
+
export function compactNgExports(packageJson) {
|
|
24
|
+
const exportsMap = packageJson.exports;
|
|
25
|
+
const mainBundle = exportsMap?.['.']?.default;
|
|
26
|
+
if (!mainBundle || !/^\.\/fesm2022\/[^/]+\.mjs$/.test(mainBundle)) {
|
|
27
|
+
throw new Error(
|
|
28
|
+
`Unexpected main export ${JSON.stringify(mainBundle)}; refusing to compact exports.`
|
|
29
|
+
);
|
|
30
|
+
}
|
|
31
|
+
if (exportsMap[PATTERN_KEY]) {
|
|
32
|
+
return {packageJson, collapsed: 0};
|
|
33
|
+
}
|
|
34
|
+
const bundlePrefix = mainBundle.replace(/\.mjs$/, '-');
|
|
35
|
+
const pattern = {
|
|
36
|
+
types: './*/index.d.ts',
|
|
37
|
+
default: `${bundlePrefix}*.mjs`,
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
const kept = {};
|
|
41
|
+
let collapsed = 0;
|
|
42
|
+
for (const [key, value] of Object.entries(exportsMap)) {
|
|
43
|
+
const name = key.slice(2);
|
|
44
|
+
const matchesPattern =
|
|
45
|
+
key.startsWith('./') &&
|
|
46
|
+
name !== '' &&
|
|
47
|
+
!name.includes('/') &&
|
|
48
|
+
!name.includes('*') &&
|
|
49
|
+
value !== null &&
|
|
50
|
+
typeof value === 'object' &&
|
|
51
|
+
Object.keys(value).join() === 'types,default' &&
|
|
52
|
+
value.types === pattern.types.replace('*', name) &&
|
|
53
|
+
value.default === pattern.default.replace('*', name);
|
|
54
|
+
if (matchesPattern) {
|
|
55
|
+
collapsed++;
|
|
56
|
+
} else {
|
|
57
|
+
kept[key] = value;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
if (collapsed === 0) {
|
|
61
|
+
return {packageJson, collapsed};
|
|
62
|
+
}
|
|
63
|
+
return {
|
|
64
|
+
packageJson: {...packageJson, exports: {...kept, [PATTERN_KEY]: pattern}},
|
|
65
|
+
collapsed,
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
function main() {
|
|
70
|
+
const packageJsonPath = process.argv[2];
|
|
71
|
+
if (!packageJsonPath) {
|
|
72
|
+
throw new Error('Usage: compact-ng-exports.mjs <dist/package.json>');
|
|
73
|
+
}
|
|
74
|
+
const before = fs.readFileSync(packageJsonPath, 'utf-8');
|
|
75
|
+
const {packageJson, collapsed} = compactNgExports(JSON.parse(before));
|
|
76
|
+
|
|
77
|
+
// Every collapsed entry must still resolve to files that exist.
|
|
78
|
+
const root = path.dirname(packageJsonPath);
|
|
79
|
+
const pattern = packageJson.exports[PATTERN_KEY];
|
|
80
|
+
const names = fs
|
|
81
|
+
.readdirSync(root, {withFileTypes: true})
|
|
82
|
+
.filter((entry) => fs.existsSync(path.join(root, entry.name, 'index.d.ts')))
|
|
83
|
+
.map((entry) => entry.name);
|
|
84
|
+
for (const name of names) {
|
|
85
|
+
if (packageJson.exports[`./${name}`]) continue;
|
|
86
|
+
for (const target of [pattern.types, pattern.default]) {
|
|
87
|
+
const file = path.join(root, target.replaceAll('*', name));
|
|
88
|
+
if (!fs.existsSync(file)) {
|
|
89
|
+
throw new Error(`Pattern export for ./${name} misses ${file}`);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
const after = JSON.stringify(packageJson, null, 2) + '\n';
|
|
95
|
+
fs.writeFileSync(packageJsonPath, after);
|
|
96
|
+
console.log(
|
|
97
|
+
`compact-ng-exports: collapsed ${collapsed} exports into "${PATTERN_KEY}", ` +
|
|
98
|
+
`package.json ${Buffer.byteLength(before)} -> ${Buffer.byteLength(after)} bytes`
|
|
99
|
+
);
|
|
100
|
+
if (Buffer.byteLength(after) > MAX_PACKAGE_JSON_BYTES) {
|
|
101
|
+
throw new Error(
|
|
102
|
+
`${packageJsonPath} is still over ${MAX_PACKAGE_JSON_BYTES} bytes; registries will reject the publish.`
|
|
103
|
+
);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
if (process.argv[1] === fileURLToPath(import.meta.url)) {
|
|
108
|
+
main();
|
|
109
|
+
}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import {describe, expect, it} from 'vitest';
|
|
2
|
+
import {compactNgExports} from './compact-ng-exports.mjs';
|
|
3
|
+
|
|
4
|
+
const bundle = './fesm2022/oicl-openbridge-webcomponents-ng';
|
|
5
|
+
|
|
6
|
+
function entry(name: string) {
|
|
7
|
+
return {types: `./${name}/index.d.ts`, default: `${bundle}-${name}.mjs`};
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
const packageJson = {
|
|
11
|
+
name: '@oicl/openbridge-webcomponents-ng',
|
|
12
|
+
exports: {
|
|
13
|
+
'./package.json': {default: './package.json'},
|
|
14
|
+
'.': {types: './index.d.ts', default: `${bundle}.mjs`},
|
|
15
|
+
'./obc-button': entry('obc-button'),
|
|
16
|
+
'./obi-02-illustration': entry('obi-02-illustration'),
|
|
17
|
+
},
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
describe('compactNgExports', () => {
|
|
21
|
+
it('replaces matching entry points with one pattern', () => {
|
|
22
|
+
const {packageJson: result, collapsed} = compactNgExports(packageJson);
|
|
23
|
+
expect(collapsed).toBe(2);
|
|
24
|
+
expect(result.exports).toEqual({
|
|
25
|
+
'./package.json': {default: './package.json'},
|
|
26
|
+
'.': {types: './index.d.ts', default: `${bundle}.mjs`},
|
|
27
|
+
'./*': {types: './*/index.d.ts', default: `${bundle}-*.mjs`},
|
|
28
|
+
});
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
it('keeps entries the pattern would resolve differently', () => {
|
|
32
|
+
const odd = {
|
|
33
|
+
...packageJson,
|
|
34
|
+
exports: {
|
|
35
|
+
...packageJson.exports,
|
|
36
|
+
'./nested/entry': entry('nested/entry'),
|
|
37
|
+
'./with-style': {...entry('with-style'), style: './style.css'},
|
|
38
|
+
'./renamed': {
|
|
39
|
+
types: './renamed/index.d.ts',
|
|
40
|
+
default: `${bundle}-other.mjs`,
|
|
41
|
+
},
|
|
42
|
+
},
|
|
43
|
+
};
|
|
44
|
+
const {packageJson: result, collapsed} = compactNgExports(odd);
|
|
45
|
+
expect(collapsed).toBe(2);
|
|
46
|
+
expect(Object.keys(result.exports)).toEqual([
|
|
47
|
+
'./package.json',
|
|
48
|
+
'.',
|
|
49
|
+
'./nested/entry',
|
|
50
|
+
'./with-style',
|
|
51
|
+
'./renamed',
|
|
52
|
+
'./*',
|
|
53
|
+
]);
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
it('is a no-op on an already compacted manifest', () => {
|
|
57
|
+
const once = compactNgExports(packageJson).packageJson;
|
|
58
|
+
const twice = compactNgExports(once);
|
|
59
|
+
expect(twice.collapsed).toBe(0);
|
|
60
|
+
expect(twice.packageJson).toBe(once);
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
it('refuses a manifest without the expected main bundle', () => {
|
|
64
|
+
expect(() => compactNgExports({exports: {}})).toThrow(/main export/);
|
|
65
|
+
});
|
|
66
|
+
});
|
|
@@ -234,7 +234,9 @@ export class ObcChartObjectVesselButton extends LitElement {
|
|
|
234
234
|
if (!hasTurnRate) {
|
|
235
235
|
return nothing;
|
|
236
236
|
}
|
|
237
|
-
|
|
237
|
+
// A binding that passes `undefined` would put NaN in the arc path.
|
|
238
|
+
const turnRate = Number.isFinite(this.turnRate) ? this.turnRate : 0;
|
|
239
|
+
const deg = (turnRate / 100) * 12;
|
|
238
240
|
const R = 24;
|
|
239
241
|
const x = -R * Math.cos(degToRad(deg)) + R + 3;
|
|
240
242
|
const y = R * Math.sin(degToRad(deg)) + 8;
|
|
@@ -7,6 +7,14 @@ canvas {
|
|
|
7
7
|
position: relative;
|
|
8
8
|
}
|
|
9
9
|
|
|
10
|
+
/* Pixel mode: pin the canvas to the requested size. Chart.js writes its
|
|
11
|
+
measured size back inline, so a chart created in a hidden container would
|
|
12
|
+
otherwise keep the 48 px minimum it measured there. */
|
|
13
|
+
:host(:not([fixedaspectratioscaling])) canvas {
|
|
14
|
+
width: var(--chart-width, 100%) !important;
|
|
15
|
+
height: var(--chart-height, auto) !important;
|
|
16
|
+
}
|
|
17
|
+
|
|
10
18
|
/* Scale slots - absolutely positioned at edges */
|
|
11
19
|
slot[name="top-scale"],
|
|
12
20
|
slot[name="bottom-scale"],
|
|
@@ -2285,25 +2285,30 @@ export class ObcChartLineBase extends LitElement {
|
|
|
2285
2285
|
* NOTE: For non-threshold modes (solid, semitransparent), backgroundColor is already
|
|
2286
2286
|
* set correctly in buildDataset(). This method now only handles threshold gradients
|
|
2287
2287
|
* which require Chart.js scales to be available.
|
|
2288
|
+
*
|
|
2289
|
+
* @returns Whether it set gradients; they reach the drawn chart on its next update.
|
|
2288
2290
|
*/
|
|
2289
|
-
protected applyFillModes() {
|
|
2291
|
+
protected applyFillModes(): boolean {
|
|
2290
2292
|
// Guard: Verify chart and canvas exist and are connected
|
|
2291
|
-
if (!this.chart || !this.canvasEl || !this.canvasEl.isConnected)
|
|
2293
|
+
if (!this.chart || !this.canvasEl || !this.canvasEl.isConnected)
|
|
2294
|
+
return false;
|
|
2292
2295
|
|
|
2293
2296
|
const chart = this.chart; // Store reference for TypeScript
|
|
2294
2297
|
const ctx = chart.ctx as CanvasRenderingContext2D;
|
|
2295
2298
|
|
|
2296
2299
|
// Guard: Verify canvas context is available
|
|
2297
|
-
if (!ctx) return;
|
|
2300
|
+
if (!ctx) return false;
|
|
2298
2301
|
|
|
2299
2302
|
const fill = this.shouldApplyFill();
|
|
2300
2303
|
const fillMode = this.getFillMode();
|
|
2301
2304
|
|
|
2302
2305
|
// Only process threshold mode - other modes already have correct backgroundColor from buildDataset()
|
|
2303
2306
|
if (fillMode !== 'threshold' || !fill) {
|
|
2304
|
-
return;
|
|
2307
|
+
return false;
|
|
2305
2308
|
}
|
|
2306
2309
|
|
|
2310
|
+
let applied = false;
|
|
2311
|
+
|
|
2307
2312
|
chart.data.datasets.forEach((ds, _idx) => {
|
|
2308
2313
|
const dataset = ds as ChartDataset<'line'> & {
|
|
2309
2314
|
fill?:
|
|
@@ -2369,7 +2374,9 @@ export class ObcChartLineBase extends LitElement {
|
|
|
2369
2374
|
const borderGradient = createGradient(0.8, 0.8);
|
|
2370
2375
|
dataset.backgroundColor = fillGradient as unknown as string;
|
|
2371
2376
|
dataset.borderColor = borderGradient as unknown as string;
|
|
2377
|
+
applied = true;
|
|
2372
2378
|
});
|
|
2379
|
+
return applied;
|
|
2373
2380
|
}
|
|
2374
2381
|
|
|
2375
2382
|
// Update external library AFTER render
|
|
@@ -3219,7 +3226,11 @@ export class ObcChartLineBase extends LitElement {
|
|
|
3219
3226
|
|
|
3220
3227
|
// Defer legend update to next tick to ensure Chart.js metadata is initialized
|
|
3221
3228
|
requestAnimationFrame(() => this.updateLegend());
|
|
3222
|
-
|
|
3229
|
+
// The constructor has already resolved the dataset colours, so a chart
|
|
3230
|
+
// rebuilt with nothing updating it after would keep its pre-gradient line.
|
|
3231
|
+
if (this.applyFillModes()) {
|
|
3232
|
+
this.chart.update('none');
|
|
3233
|
+
}
|
|
3223
3234
|
this.syncSlottedScaleRanges();
|
|
3224
3235
|
}
|
|
3225
3236
|
|
|
@@ -43,4 +43,32 @@ describe('observeLabelThreshold', () => {
|
|
|
43
43
|
|
|
44
44
|
expect(events).toEqual(['update', 'rebuild', 'update', 'rebuild']);
|
|
45
45
|
});
|
|
46
|
+
|
|
47
|
+
it('rebuilds once when a target created without a size gets one', async () => {
|
|
48
|
+
const parent = document.createElement('div');
|
|
49
|
+
parent.style.display = 'none';
|
|
50
|
+
el = document.createElement('div');
|
|
51
|
+
el.style.height = '100px';
|
|
52
|
+
parent.append(el);
|
|
53
|
+
document.body.append(parent);
|
|
54
|
+
const events: string[] = [];
|
|
55
|
+
|
|
56
|
+
observer = observeLabelThreshold(
|
|
57
|
+
el,
|
|
58
|
+
() => (el?.clientHeight ?? 0) >= THRESHOLD_PX,
|
|
59
|
+
{
|
|
60
|
+
rebuild: () => events.push('rebuild'),
|
|
61
|
+
update: () => events.push('update'),
|
|
62
|
+
}
|
|
63
|
+
);
|
|
64
|
+
await settle();
|
|
65
|
+
|
|
66
|
+
parent.style.display = 'block';
|
|
67
|
+
await settle();
|
|
68
|
+
el.style.height = '120px';
|
|
69
|
+
await settle();
|
|
70
|
+
parent.remove();
|
|
71
|
+
|
|
72
|
+
expect(events).toEqual(['update', 'rebuild', 'update']);
|
|
73
|
+
});
|
|
46
74
|
});
|