@oicl/openbridge-webcomponents-full-bundle 2.0.0-next.161 → 2.0.0-next.163
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/preview.tsx +1 -1
- package/bundle/openbridge-webcomponents.bundle.js +439 -327
- package/bundle/openbridge-webcomponents.bundle.js.map +1 -1
- package/custom-elements.json +134 -34
- package/dist/components/keyboard-numeric/keyboard-numeric.css.js +2 -3
- package/dist/components/keyboard-numeric/keyboard-numeric.css.js.map +1 -1
- package/dist/navigation-instruments/compass-sector/compass-sector.css.js +20 -11
- package/dist/navigation-instruments/compass-sector/compass-sector.css.js.map +1 -1
- package/dist/navigation-instruments/compass-sector/compass-sector.d.ts +18 -17
- package/dist/navigation-instruments/compass-sector/compass-sector.d.ts.map +1 -1
- package/dist/navigation-instruments/compass-sector/compass-sector.js +85 -52
- package/dist/navigation-instruments/compass-sector/compass-sector.js.map +1 -1
- package/dist/navigation-instruments/gauge-radial/gauge-radial.css.js +2 -6
- package/dist/navigation-instruments/gauge-radial/gauge-radial.css.js.map +1 -1
- package/dist/navigation-instruments/rudder/rudder.css.js +40 -0
- package/dist/navigation-instruments/rudder/rudder.css.js.map +1 -0
- package/dist/navigation-instruments/rudder/rudder.d.ts +9 -0
- package/dist/navigation-instruments/rudder/rudder.d.ts.map +1 -1
- package/dist/navigation-instruments/rudder/rudder.js +40 -23
- package/dist/navigation-instruments/rudder/rudder.js.map +1 -1
- package/dist/navigation-instruments/watch/watch.css.js +6 -0
- package/dist/navigation-instruments/watch/watch.css.js.map +1 -1
- package/dist/navigation-instruments/watch/watch.d.ts.map +1 -1
- package/dist/navigation-instruments/watch/watch.js +11 -1
- package/dist/navigation-instruments/watch/watch.js.map +1 -1
- package/dist/svghelpers/arc-frame.d.ts +8 -0
- package/dist/svghelpers/arc-frame.d.ts.map +1 -1
- package/dist/svghelpers/arc-frame.js +16 -6
- package/dist/svghelpers/arc-frame.js.map +1 -1
- package/dist/svghelpers/radial-frame.d.ts +14 -1
- package/dist/svghelpers/radial-frame.d.ts.map +1 -1
- package/dist/svghelpers/radial-frame.js +3 -1
- package/dist/svghelpers/radial-frame.js.map +1 -1
- package/docs/GettingStarted.mdx +2 -0
- package/docs/MigrationGuide.mdx +924 -0
- package/docs/migration-guide/api-ar.md +7 -0
- package/docs/migration-guide/api-automation.md +11 -0
- package/docs/migration-guide/api-building-blocks.md +4 -0
- package/docs/migration-guide/api-instruments.md +19 -0
- package/docs/migration-guide/api-ui-components.md +19 -0
- package/docs/migration-guide/ar-paths.md +16 -0
- package/docs/migration-guide/css-variables.md +13 -0
- package/docs/migration-guide/deprecated-components.md +6 -0
- package/docs/migration-guide/deprecated-members.md +8 -0
- package/docs/migration-guide/flash-tempo.md +5 -0
- package/docs/migration-guide/icons-renamed.md +6 -0
- package/docs/migration-guide/icons-wind.md +16 -0
- package/docs/migration-guide/svelte-snippets.md +8 -0
- package/docs/migration-guide/wind-properties.md +10 -0
- package/package.json +1 -1
- package/script/check-css-variables.ts +1 -5
- package/src/components/keyboard-numeric/keyboard-numeric.css +2 -3
- package/src/mixins/contain-aspect.css +14 -0
- package/src/navigation-instruments/compass-sector/compass-sector.css +17 -11
- package/src/navigation-instruments/compass-sector/compass-sector.spec.ts +57 -0
- package/src/navigation-instruments/compass-sector/compass-sector.stories.ts +23 -0
- package/src/navigation-instruments/compass-sector/compass-sector.ts +127 -60
- package/src/navigation-instruments/gauge-radial/gauge-radial.css +3 -10
- package/src/navigation-instruments/rudder/rudder.css +27 -0
- package/src/navigation-instruments/rudder/rudder.ts +52 -22
- package/src/navigation-instruments/watch/watch.css +6 -0
- package/src/navigation-instruments/watch/watch.ts +16 -1
- package/src/svghelpers/arc-frame.ts +19 -5
- package/src/svghelpers/radial-frame.spec.ts +51 -0
- package/src/svghelpers/radial-frame.ts +15 -1
|
@@ -9,6 +9,13 @@ export interface ArcViewBox {
|
|
|
9
9
|
export interface ZoomToFitArcFrame extends ArcViewBox {
|
|
10
10
|
radiusOffset: number;
|
|
11
11
|
}
|
|
12
|
+
/** Shape of the zoom viewBox. */
|
|
13
|
+
export declare enum ArcFrameFit {
|
|
14
|
+
/** Square around the arc — what instruments with a round face expect. */
|
|
15
|
+
square = "square",
|
|
16
|
+
/** The arc's own bounding box, which crops a flat arc's empty height. */
|
|
17
|
+
bbox = "bbox"
|
|
18
|
+
}
|
|
12
19
|
/**
|
|
13
20
|
* Normalize a user-supplied watch-arc half-extent (in degrees) to a finite
|
|
14
21
|
* value clamped into a sane range. Guards against `NaN`/`Infinity` produced
|
|
@@ -62,6 +69,7 @@ export declare function computeZoomToFitArcFrame(options: {
|
|
|
62
69
|
xMax: number;
|
|
63
70
|
yMax: number;
|
|
64
71
|
};
|
|
72
|
+
fit?: ArcFrameFit;
|
|
65
73
|
}): ZoomToFitArcFrame;
|
|
66
74
|
/**
|
|
67
75
|
* Shift an arc viewBox so the arc's outer-edge midpoint coincides with the
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"arc-frame.d.ts","sourceRoot":"","sources":["../../src/svghelpers/arc-frame.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,SAAS,EAAC,MAAM,0CAA0C,CAAC;AAGxE,MAAM,WAAW,UAAU;IACzB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,iBAAkB,SAAQ,UAAU;IACnD,YAAY,EAAE,MAAM,CAAC;CACtB;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,iBAAiB,CAC/B,KAAK,EAAE,MAAM,GAAG,SAAS,EACzB,QAAQ,EAAE,MAAM,GACf,MAAM,CAGR;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,wBAAgB,wBAAwB,CAAC,OAAO,EAAE;IAChD,KAAK,EAAE,SAAS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UAAU,CAAC,EAAE;QAAC,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAC,CAAC;IACtE,GAAG,CAAC,EAAE,WAAW,CAAC;CACnB,GAAG,iBAAiB,CA8FpB;AAuED;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,wBAAgB,wBAAwB,CACtC,KAAK,EAAE,iBAAiB,EACxB,cAAc,EAAE,MAAM,EACtB,eAAe,EAAE,MAAM,EACvB,UAAU,EAAE,MAAM,GACjB,iBAAiB,CAkBnB"}
|
|
@@ -1,4 +1,9 @@
|
|
|
1
1
|
import { degToRad, normalizeAngle } from "./math.js";
|
|
2
|
+
var ArcFrameFit = /* @__PURE__ */ ((ArcFrameFit2) => {
|
|
3
|
+
ArcFrameFit2["square"] = "square";
|
|
4
|
+
ArcFrameFit2["bbox"] = "bbox";
|
|
5
|
+
return ArcFrameFit2;
|
|
6
|
+
})(ArcFrameFit || {});
|
|
2
7
|
function normalizeArcAngle(value, fallback) {
|
|
3
8
|
const v = Number.isFinite(value) ? value : fallback;
|
|
4
9
|
return Math.min(180, Math.max(2, v));
|
|
@@ -11,7 +16,9 @@ function computeZoomToFitArcFrame(options) {
|
|
|
11
16
|
extension,
|
|
12
17
|
targetSize,
|
|
13
18
|
margin = 0.06,
|
|
14
|
-
includeBox
|
|
19
|
+
includeBox,
|
|
20
|
+
fit = "square"
|
|
21
|
+
/* square */
|
|
15
22
|
} = options;
|
|
16
23
|
if (areas.length === 0) {
|
|
17
24
|
const side2 = targetSize;
|
|
@@ -61,13 +68,15 @@ function computeZoomToFitArcFrame(options) {
|
|
|
61
68
|
const rawW = bbox.xMax - bbox.xMin;
|
|
62
69
|
const rawH = bbox.yMax - bbox.yMin;
|
|
63
70
|
const side = Math.max(rawW, rawH);
|
|
64
|
-
const
|
|
71
|
+
const pad = side * margin;
|
|
65
72
|
const cx = (bbox.xMin + bbox.xMax) / 2;
|
|
66
73
|
const cy = (bbox.yMin + bbox.yMax) / 2;
|
|
67
|
-
const
|
|
68
|
-
const
|
|
69
|
-
const
|
|
70
|
-
const
|
|
74
|
+
const boxW = fit === "bbox" ? rawW + pad * 2 : side + pad * 2;
|
|
75
|
+
const boxH = fit === "bbox" ? rawH + pad * 2 : side + pad * 2;
|
|
76
|
+
const x = round4(cx - boxW / 2);
|
|
77
|
+
const y = round4(cy - boxH / 2);
|
|
78
|
+
const w = round4(boxW);
|
|
79
|
+
const h = round4(boxH);
|
|
71
80
|
return {
|
|
72
81
|
radiusOffset,
|
|
73
82
|
x,
|
|
@@ -155,6 +164,7 @@ function round4(n) {
|
|
|
155
164
|
return Math.round(n * 1e4) / 1e4;
|
|
156
165
|
}
|
|
157
166
|
export {
|
|
167
|
+
ArcFrameFit,
|
|
158
168
|
computeZoomToFitArcFrame,
|
|
159
169
|
normalizeArcAngle,
|
|
160
170
|
shiftArcFrameToOuterEdge
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"arc-frame.js","sources":["../../src/svghelpers/arc-frame.ts"],"sourcesContent":["import type {WatchArea} from '../navigation-instruments/watch/watch.js';\nimport {degToRad, normalizeAngle} from './math.js';\n\nexport interface ArcViewBox {\n x: number;\n y: number;\n width: number;\n height: number;\n viewBox: string;\n}\n\nexport interface ZoomToFitArcFrame extends ArcViewBox {\n radiusOffset: number;\n}\n\n/**\n * Normalize a user-supplied watch-arc half-extent (in degrees) to a finite\n * value clamped into a sane range. Guards against `NaN`/`Infinity` produced\n * by Lit's Number attribute converter for invalid string attributes\n * (e.g. `<obc-pitch arc-angle=\"abc\">`), which would otherwise propagate\n * through trig and `viewBox` math and produce invalid SVG output.\n *\n * @param value Raw arc half-extent in degrees.\n * @param fallback Value to use when `value` is non-finite.\n * @returns A finite number in `[2, 180]`.\n */\nexport function normalizeArcAngle(\n value: number | undefined,\n fallback: number\n): number {\n const v = Number.isFinite(value) ? (value as number) : fallback;\n return Math.min(180, Math.max(2, v));\n}\n\n/**\n * Compute the optimal radius enlargement and square viewBox so that a\n * partial-arc watch face fills its container instead of leaving empty space.\n *\n * When `zoomToFitArc` is enabled on a clipped watch (e.g. rudder ±45°), the\n * visible arc segment is small relative to the full circle — lots of space\n * is wasted. This function finds a `radiusOffset` that, when added to every\n * radius constant, enlarges the circle so the visible band fills the target\n * viewport. Band thickness, tickmark sizes, and all decorative elements\n * remain unchanged in SVG units; only the curvature flattens because the\n * radius is larger.\n *\n * Uses binary search over `radiusOffset` so that the bounding box of the\n * annular arc (outer + extension … inner) fits within `targetSize × (1 − 2 × margin)`.\n *\n * @param options.areas Visible arc segments (same array passed to `<obc-watch>`).\n * @param options.outerRadius Base outer ring radius (typically `OUTER_RING_RADIUS`).\n * @param options.innerRadius Base innermost visible radius (depends on `WatchCircleType`).\n * @param options.extension Extra radial room beyond outer for tickmarks/labels.\n * @param options.targetSize Default SVG viewport side length, e.g. `(176 + padding) * 2`.\n * @param options.margin Fraction of computed extent used as padding (default 0.06).\n * @param options.includeBox Optional bounding box in SVG coordinates that must remain\n * inside the FINAL viewBox. Use this to keep a fixed central\n * element (e.g. a vessel image at the origin) visible after\n * the arc has been enlarged. Does NOT constrain how large\n * the arc can grow — it only widens/tallens the final\n * viewBox to include the requested region.\n */\nexport function computeZoomToFitArcFrame(options: {\n areas: WatchArea[];\n outerRadius: number;\n innerRadius: number;\n extension: number;\n targetSize: number;\n margin?: number;\n includeBox?: {xMin: number; yMin: number; xMax: number; yMax: number};\n}): ZoomToFitArcFrame {\n const {\n areas,\n outerRadius,\n innerRadius,\n extension,\n targetSize,\n margin = 0.06,\n includeBox,\n } = options;\n\n if (areas.length === 0) {\n const side = targetSize;\n return {\n radiusOffset: 0,\n x: -side / 2,\n y: -side / 2,\n width: side,\n height: side,\n viewBox: `${-side / 2} ${-side / 2} ${side} ${side}`,\n };\n }\n\n const available = targetSize * (1 - 2 * margin);\n\n // The search measures the arc-only bbox: folding `includeBox` in here would\n // let the origin-to-arc distance dominate and cap how far the arc can grow\n // at narrow `arcAngle`. It is applied to the final viewBox instead, so the\n // arc grows freely and the central element still fits.\n const measureSize = (radiusOffset: number) => {\n const bbox = computeAnnularArcBBox(\n areas,\n outerRadius + radiusOffset,\n innerRadius + radiusOffset,\n extension\n );\n return Math.max(bbox.xMax - bbox.xMin, bbox.yMax - bbox.yMin);\n };\n\n // Dynamic upper bound: double until the band bbox exceeds the available space.\n let lo = 0;\n let hi = targetSize;\n for (let i = 0; i < 16 && measureSize(hi) < available; i++) {\n hi *= 2;\n }\n\n for (let i = 0; i < 50; i++) {\n const mid = (lo + hi) / 2;\n const size = measureSize(mid);\n if (size < available) {\n lo = mid;\n } else {\n hi = mid;\n }\n }\n\n const radiusOffset = Math.max(0, lo);\n\n // Final bbox at the computed offset\n const bbox = expandBBoxToIncludeBox(\n computeAnnularArcBBox(\n areas,\n outerRadius + radiusOffset,\n innerRadius + radiusOffset,\n extension\n ),\n includeBox\n );\n const rawW = bbox.xMax - bbox.xMin;\n const rawH = bbox.yMax - bbox.yMin;\n const side = Math.max(rawW, rawH);\n const padded = side * (1 + margin * 2);\n\n const cx = (bbox.xMin + bbox.xMax) / 2;\n const cy = (bbox.yMin + bbox.yMax) / 2;\n\n const x = round4(cx - padded / 2);\n const y = round4(cy - padded / 2);\n const w = round4(padded);\n const h = round4(padded);\n\n return {\n radiusOffset,\n x,\n y,\n width: w,\n height: h,\n viewBox: `${x} ${y} ${w} ${h}`,\n };\n}\n\n/**\n * Bounding box of an annular arc (the visible band between inner and outer radii).\n *\n * Samples arc endpoints and cardinal-axis crossings on both the outermost and\n * innermost circles. The result frames just the band, NOT the circle centre.\n */\nfunction computeAnnularArcBBox(\n areas: WatchArea[],\n outerRadius: number,\n innerRadius: number,\n extension: number\n): {xMin: number; xMax: number; yMin: number; yMax: number} {\n const R_vis = outerRadius + extension;\n const R_in = innerRadius;\n\n let xMin = Infinity;\n let xMax = -Infinity;\n let yMin = Infinity;\n let yMax = -Infinity;\n\n const expand = (x: number, y: number) => {\n if (x < xMin) xMin = x;\n if (x > xMax) xMax = x;\n if (y < yMin) yMin = y;\n if (y > yMax) yMax = y;\n };\n\n for (const area of areas) {\n const startRad = degToRad(area.startAngle);\n const endRad = degToRad(area.endAngle);\n\n for (const R of [R_vis, R_in]) {\n expand(R * Math.sin(startRad), -R * Math.cos(startRad));\n expand(R * Math.sin(endRad), -R * Math.cos(endRad));\n }\n\n const startNorm = normalizeAngle(area.startAngle);\n const endNorm = normalizeAngle(area.endAngle);\n const axes = [0, 90, 180, 270];\n for (const axis of axes) {\n if (arcContainsAngle(startNorm, endNorm, axis)) {\n const axisRad = degToRad(axis);\n for (const R of [R_vis, R_in]) {\n expand(R * Math.sin(axisRad), -R * Math.cos(axisRad));\n }\n }\n }\n }\n\n if (xMin === Infinity) {\n return {xMin: 0, xMax: 0, yMin: 0, yMax: 0};\n }\n\n return {xMin, xMax, yMin, yMax};\n}\n\nfunction expandBBoxToIncludeBox(\n bbox: {xMin: number; xMax: number; yMin: number; yMax: number},\n box: {xMin: number; yMin: number; xMax: number; yMax: number} | undefined\n): {xMin: number; xMax: number; yMin: number; yMax: number} {\n if (!box) return bbox;\n return {\n xMin: Math.min(bbox.xMin, box.xMin),\n xMax: Math.max(bbox.xMax, box.xMax),\n yMin: Math.min(bbox.yMin, box.yMin),\n yMax: Math.max(bbox.yMax, box.yMax),\n };\n}\n\n/**\n * Shift an arc viewBox so the arc's outer-edge midpoint coincides with the\n * outer edge of a co-located reference frame (e.g. the central vessel layer\n * with viewBox `-centreHalf -centreHalf 2*centreHalf 2*centreHalf`).\n *\n * The direction is taken from the arc bbox-center, so single-side arcs\n * (pitch on the left, roll on top, rudder on the bottom) are pushed\n * outward to that side. Four-way symmetric arcs (pitch-roll) keep their\n * origin-centred bbox and the function becomes a no-op.\n *\n * The arc's pixel size is preserved; only `x`, `y` and `viewBox` change.\n *\n * @param frame The arc frame returned by `computeZoomToFitArcFrame`.\n * @param arcOuterRadius Outer radius of the arc band INCLUDING `radiusOffset`\n * (i.e. `outerRadius + frame.radiusOffset`). Extension\n * padding is intentionally excluded — the visible band\n * edge is what should align with the reference frame.\n * @param referenceRadius Distance from origin to the reference frame's outer\n * edge, in the reference frame's SVG units. Typically\n * `OUTER_RING_RADIUS` for the original instrument\n * outer ring, or `centreHalf` to align with the\n * container edge directly.\n * @param centreHalf Half-side of the reference frame's square viewBox in\n * SVG units. The arc's outer-edge midpoint is placed\n * on `referenceRadius` in the same direction.\n */\nexport function shiftArcFrameToOuterEdge(\n frame: ZoomToFitArcFrame,\n arcOuterRadius: number,\n referenceRadius: number,\n centreHalf: number\n): ZoomToFitArcFrame {\n const cx = frame.x + frame.width / 2;\n const cy = frame.y + frame.height / 2;\n const dist = Math.hypot(cx, cy);\n if (dist < 0.001) return frame;\n const ux = cx / dist;\n const uy = cy / dist;\n const r = referenceRadius / centreHalf;\n const outerX = arcOuterRadius * ux;\n const outerY = arcOuterRadius * uy;\n const newX = round4(outerX - (frame.width * (r * ux + 1)) / 2);\n const newY = round4(outerY - (frame.height * (r * uy + 1)) / 2);\n return {\n ...frame,\n x: newX,\n y: newY,\n viewBox: `${newX} ${newY} ${frame.width} ${frame.height}`,\n };\n}\n\nfunction arcContainsAngle(\n startDeg: number,\n endDeg: number,\n testDeg: number\n): boolean {\n const s = normalizeAngle(startDeg);\n const e = normalizeAngle(endDeg);\n const t = normalizeAngle(testDeg);\n if (s <= e) {\n return t >= s && t <= e;\n }\n return t >= s || t <= e;\n}\n\nfunction round4(n: number): number {\n return Math.round(n * 10000) / 10000;\n}\n"],"names":["side","radiusOffset","bbox"],"mappings":";AA0BO,SAAS,kBACd,OACA,UACQ;AACR,QAAM,IAAI,OAAO,SAAS,KAAK,IAAK,QAAmB;AACvD,SAAO,KAAK,IAAI,KAAK,KAAK,IAAI,GAAG,CAAC,CAAC;AACrC;AA8BO,SAAS,yBAAyB,SAQnB;AACpB,QAAM;AAAA,IACJ;AAAA,IACA;AAAA,IACA;AAAA,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,MAAM,KAAK,IAAI,MAAM,MAAM;AAAA,EAAA;AAE3D;AAEA,SAAS,iBACP,UACA,QACA,SACS;AACT,QAAM,IAAI,eAAe,QAAQ;AACjC,QAAM,IAAI,eAAe,MAAM;AAC/B,QAAM,IAAI,eAAe,OAAO;AAChC,MAAI,KAAK,GAAG;AACV,WAAO,KAAK,KAAK,KAAK;AAAA,EACxB;AACA,SAAO,KAAK,KAAK,KAAK;AACxB;AAEA,SAAS,OAAO,GAAmB;AACjC,SAAO,KAAK,MAAM,IAAI,GAAK,IAAI;AACjC;"}
|
|
1
|
+
{"version":3,"file":"arc-frame.js","sources":["../../src/svghelpers/arc-frame.ts"],"sourcesContent":["import type {WatchArea} from '../navigation-instruments/watch/watch.js';\nimport {degToRad, normalizeAngle} from './math.js';\n\nexport interface ArcViewBox {\n x: number;\n y: number;\n width: number;\n height: number;\n viewBox: string;\n}\n\nexport interface ZoomToFitArcFrame extends ArcViewBox {\n radiusOffset: number;\n}\n\n/** Shape of the zoom viewBox. */\nexport enum ArcFrameFit {\n /** Square around the arc — what instruments with a round face expect. */\n square = 'square',\n /** The arc's own bounding box, which crops a flat arc's empty height. */\n bbox = 'bbox',\n}\n\n/**\n * Normalize a user-supplied watch-arc half-extent (in degrees) to a finite\n * value clamped into a sane range. Guards against `NaN`/`Infinity` produced\n * by Lit's Number attribute converter for invalid string attributes\n * (e.g. `<obc-pitch arc-angle=\"abc\">`), which would otherwise propagate\n * through trig and `viewBox` math and produce invalid SVG output.\n *\n * @param value Raw arc half-extent in degrees.\n * @param fallback Value to use when `value` is non-finite.\n * @returns A finite number in `[2, 180]`.\n */\nexport function normalizeArcAngle(\n value: number | undefined,\n fallback: number\n): number {\n const v = Number.isFinite(value) ? (value as number) : fallback;\n return Math.min(180, Math.max(2, v));\n}\n\n/**\n * Compute the optimal radius enlargement and square viewBox so that a\n * partial-arc watch face fills its container instead of leaving empty space.\n *\n * When `zoomToFitArc` is enabled on a clipped watch (e.g. rudder ±45°), the\n * visible arc segment is small relative to the full circle — lots of space\n * is wasted. This function finds a `radiusOffset` that, when added to every\n * radius constant, enlarges the circle so the visible band fills the target\n * viewport. Band thickness, tickmark sizes, and all decorative elements\n * remain unchanged in SVG units; only the curvature flattens because the\n * radius is larger.\n *\n * Uses binary search over `radiusOffset` so that the bounding box of the\n * annular arc (outer + extension … inner) fits within `targetSize × (1 − 2 × margin)`.\n *\n * @param options.areas Visible arc segments (same array passed to `<obc-watch>`).\n * @param options.outerRadius Base outer ring radius (typically `OUTER_RING_RADIUS`).\n * @param options.innerRadius Base innermost visible radius (depends on `WatchCircleType`).\n * @param options.extension Extra radial room beyond outer for tickmarks/labels.\n * @param options.targetSize Default SVG viewport side length, e.g. `(176 + padding) * 2`.\n * @param options.margin Fraction of computed extent used as padding (default 0.06).\n * @param options.includeBox Optional bounding box in SVG coordinates that must remain\n * inside the FINAL viewBox. Use this to keep a fixed central\n * element (e.g. a vessel image at the origin) visible after\n * the arc has been enlarged. Does NOT constrain how large\n * the arc can grow — it only widens/tallens the final\n * viewBox to include the requested region.\n */\nexport function computeZoomToFitArcFrame(options: {\n areas: WatchArea[];\n outerRadius: number;\n innerRadius: number;\n extension: number;\n targetSize: number;\n margin?: number;\n includeBox?: {xMin: number; yMin: number; xMax: number; yMax: number};\n fit?: ArcFrameFit;\n}): ZoomToFitArcFrame {\n const {\n areas,\n outerRadius,\n innerRadius,\n extension,\n targetSize,\n margin = 0.06,\n includeBox,\n fit = ArcFrameFit.square,\n } = options;\n\n if (areas.length === 0) {\n const side = targetSize;\n return {\n radiusOffset: 0,\n x: -side / 2,\n y: -side / 2,\n width: side,\n height: side,\n viewBox: `${-side / 2} ${-side / 2} ${side} ${side}`,\n };\n }\n\n const available = targetSize * (1 - 2 * margin);\n\n // The search measures the arc-only bbox: folding `includeBox` in here would\n // let the origin-to-arc distance dominate and cap how far the arc can grow\n // at narrow `arcAngle`. It is applied to the final viewBox instead, so the\n // arc grows freely and the central element still fits.\n const measureSize = (radiusOffset: number) => {\n const bbox = computeAnnularArcBBox(\n areas,\n outerRadius + radiusOffset,\n innerRadius + radiusOffset,\n extension\n );\n return Math.max(bbox.xMax - bbox.xMin, bbox.yMax - bbox.yMin);\n };\n\n // Dynamic upper bound: double until the band bbox exceeds the available space.\n let lo = 0;\n let hi = targetSize;\n for (let i = 0; i < 16 && measureSize(hi) < available; i++) {\n hi *= 2;\n }\n\n for (let i = 0; i < 50; i++) {\n const mid = (lo + hi) / 2;\n const size = measureSize(mid);\n if (size < available) {\n lo = mid;\n } else {\n hi = mid;\n }\n }\n\n const radiusOffset = Math.max(0, lo);\n\n // Final bbox at the computed offset\n const bbox = expandBBoxToIncludeBox(\n computeAnnularArcBBox(\n areas,\n outerRadius + radiusOffset,\n innerRadius + radiusOffset,\n extension\n ),\n includeBox\n );\n const rawW = bbox.xMax - bbox.xMin;\n const rawH = bbox.yMax - bbox.yMin;\n const side = Math.max(rawW, rawH);\n const pad = side * margin;\n\n const cx = (bbox.xMin + bbox.xMax) / 2;\n const cy = (bbox.yMin + bbox.yMax) / 2;\n\n // 'bbox' hugs the arc; a flat arc in a square box is mostly empty.\n const boxW = fit === ArcFrameFit.bbox ? rawW + pad * 2 : side + pad * 2;\n const boxH = fit === ArcFrameFit.bbox ? rawH + pad * 2 : side + pad * 2;\n\n const x = round4(cx - boxW / 2);\n const y = round4(cy - boxH / 2);\n const w = round4(boxW);\n const h = round4(boxH);\n\n return {\n radiusOffset,\n x,\n y,\n width: w,\n height: h,\n viewBox: `${x} ${y} ${w} ${h}`,\n };\n}\n\n/**\n * Bounding box of an annular arc (the visible band between inner and outer radii).\n *\n * Samples arc endpoints and cardinal-axis crossings on both the outermost and\n * innermost circles. The result frames just the band, NOT the circle centre.\n */\nfunction computeAnnularArcBBox(\n areas: WatchArea[],\n outerRadius: number,\n innerRadius: number,\n extension: number\n): {xMin: number; xMax: number; yMin: number; yMax: number} {\n const R_vis = outerRadius + extension;\n const R_in = innerRadius;\n\n let xMin = Infinity;\n let xMax = -Infinity;\n let yMin = Infinity;\n let yMax = -Infinity;\n\n const expand = (x: number, y: number) => {\n if (x < xMin) xMin = x;\n if (x > xMax) xMax = x;\n if (y < yMin) yMin = y;\n if (y > yMax) yMax = y;\n };\n\n for (const area of areas) {\n const startRad = degToRad(area.startAngle);\n const endRad = degToRad(area.endAngle);\n\n for (const R of [R_vis, R_in]) {\n expand(R * Math.sin(startRad), -R * Math.cos(startRad));\n expand(R * Math.sin(endRad), -R * Math.cos(endRad));\n }\n\n const startNorm = normalizeAngle(area.startAngle);\n const endNorm = normalizeAngle(area.endAngle);\n const axes = [0, 90, 180, 270];\n for (const axis of axes) {\n if (arcContainsAngle(startNorm, endNorm, axis)) {\n const axisRad = degToRad(axis);\n for (const R of [R_vis, R_in]) {\n expand(R * Math.sin(axisRad), -R * Math.cos(axisRad));\n }\n }\n }\n }\n\n if (xMin === Infinity) {\n return {xMin: 0, xMax: 0, yMin: 0, yMax: 0};\n }\n\n return {xMin, xMax, yMin, yMax};\n}\n\nfunction expandBBoxToIncludeBox(\n bbox: {xMin: number; xMax: number; yMin: number; yMax: number},\n box: {xMin: number; yMin: number; xMax: number; yMax: number} | undefined\n): {xMin: number; xMax: number; yMin: number; yMax: number} {\n if (!box) return bbox;\n return {\n xMin: Math.min(bbox.xMin, box.xMin),\n xMax: Math.max(bbox.xMax, box.xMax),\n yMin: Math.min(bbox.yMin, box.yMin),\n yMax: Math.max(bbox.yMax, box.yMax),\n };\n}\n\n/**\n * Shift an arc viewBox so the arc's outer-edge midpoint coincides with the\n * outer edge of a co-located reference frame (e.g. the central vessel layer\n * with viewBox `-centreHalf -centreHalf 2*centreHalf 2*centreHalf`).\n *\n * The direction is taken from the arc bbox-center, so single-side arcs\n * (pitch on the left, roll on top, rudder on the bottom) are pushed\n * outward to that side. Four-way symmetric arcs (pitch-roll) keep their\n * origin-centred bbox and the function becomes a no-op.\n *\n * The arc's pixel size is preserved; only `x`, `y` and `viewBox` change.\n *\n * @param frame The arc frame returned by `computeZoomToFitArcFrame`.\n * @param arcOuterRadius Outer radius of the arc band INCLUDING `radiusOffset`\n * (i.e. `outerRadius + frame.radiusOffset`). Extension\n * padding is intentionally excluded — the visible band\n * edge is what should align with the reference frame.\n * @param referenceRadius Distance from origin to the reference frame's outer\n * edge, in the reference frame's SVG units. Typically\n * `OUTER_RING_RADIUS` for the original instrument\n * outer ring, or `centreHalf` to align with the\n * container edge directly.\n * @param centreHalf Half-side of the reference frame's square viewBox in\n * SVG units. The arc's outer-edge midpoint is placed\n * on `referenceRadius` in the same direction.\n */\nexport function shiftArcFrameToOuterEdge(\n frame: ZoomToFitArcFrame,\n arcOuterRadius: number,\n referenceRadius: number,\n centreHalf: number\n): ZoomToFitArcFrame {\n const cx = frame.x + frame.width / 2;\n const cy = frame.y + frame.height / 2;\n const dist = Math.hypot(cx, cy);\n if (dist < 0.001) return frame;\n const ux = cx / dist;\n const uy = cy / dist;\n const r = referenceRadius / centreHalf;\n const outerX = arcOuterRadius * ux;\n const outerY = arcOuterRadius * uy;\n const newX = round4(outerX - (frame.width * (r * ux + 1)) / 2);\n const newY = round4(outerY - (frame.height * (r * uy + 1)) / 2);\n return {\n ...frame,\n x: newX,\n y: newY,\n viewBox: `${newX} ${newY} ${frame.width} ${frame.height}`,\n };\n}\n\nfunction arcContainsAngle(\n startDeg: number,\n endDeg: number,\n testDeg: number\n): boolean {\n const s = normalizeAngle(startDeg);\n const e = normalizeAngle(endDeg);\n const t = normalizeAngle(testDeg);\n if (s <= e) {\n return t >= s && t <= e;\n }\n return t >= s || t <= e;\n}\n\nfunction round4(n: number): number {\n return Math.round(n * 10000) / 10000;\n}\n"],"names":["ArcFrameFit","side","radiusOffset","bbox"],"mappings":";AAgBO,IAAK,gCAAAA,iBAAL;AAELA,eAAA,QAAA,IAAS;AAETA,eAAA,MAAA,IAAO;AAJG,SAAAA;AAAA,GAAA,eAAA,CAAA,CAAA;AAkBL,SAAS,kBACd,OACA,UACQ;AACR,QAAM,IAAI,OAAO,SAAS,KAAK,IA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AC5B,QAAM,SAAS,iBAAiB;AAChC,QAAM,SAAS,iBAAiB;AAChC,QAAM,OAAO,OAAO,SAAU,MAAM,SAAS,IAAI,KAAK,KAAM,CAAC;AAC7D,QAAM,OAAO,OAAO,SAAU,MAAM,UAAU,IAAI,KAAK,KAAM,CAAC;AAC9D,SAAO;AAAA,IACL,GAAG;AAAA,IACH,GAAG;AAAA,IACH,GAAG;AAAA,IACH,SAAS,GAAG,IAAI,IAAI,IAAI,IAAI,MAAM,KAAK,IAAI,MAAM,MAAM;AAAA,EAAA;AAE3D;AAEA,SAAS,iBACP,UACA,QACA,SACS;AACT,QAAM,IAAI,eAAe,QAAQ;AACjC,QAAM,IAAI,eAAe,MAAM;AAC/B,QAAM,IAAI,eAAe,OAAO;AAChC,MAAI,KAAK,GAAG;AACV,WAAO,KAAK,KAAK,KAAK;AAAA,EACxB;AACA,SAAO,KAAK,KAAK,KAAK;AACxB;AAEA,SAAS,OAAO,GAAmB;AACjC,SAAO,KAAK,MAAM,IAAI,GAAK,IAAI;AACjC;"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { WatchArea } from '../navigation-instruments/watch/watch.js';
|
|
2
|
-
import { ZoomToFitArcFrame } from './arc-frame.js';
|
|
2
|
+
import { ArcFrameFit, ZoomToFitArcFrame } from './arc-frame.js';
|
|
3
3
|
/** Approximate digit advance at 12px font-instrument-label. */
|
|
4
4
|
export declare const DIGIT_WIDTH_PX = 7;
|
|
5
5
|
/** Compass NSWE label width assumed by label.ts (`labelWidth = 16`). */
|
|
@@ -63,6 +63,19 @@ export interface RadialFrameOptions {
|
|
|
63
63
|
areas?: WatchArea[];
|
|
64
64
|
/** Innermost visible radius (depends on WatchCircleType); zoom path only. */
|
|
65
65
|
innerRadius?: number;
|
|
66
|
+
/** Zoom viewBox shape; `bbox` crops a flat arc's empty height. */
|
|
67
|
+
zoomFit?: ArcFrameFit;
|
|
68
|
+
/**
|
|
69
|
+
* Region that must stay inside the zoomed viewBox — an overlay the arc's own
|
|
70
|
+
* box would leave out, such as a needle reaching in toward the centre. It
|
|
71
|
+
* widens the final box only; the arc still grows freely.
|
|
72
|
+
*/
|
|
73
|
+
zoomIncludeBox?: {
|
|
74
|
+
xMin: number;
|
|
75
|
+
yMin: number;
|
|
76
|
+
xMax: number;
|
|
77
|
+
yMax: number;
|
|
78
|
+
};
|
|
66
79
|
}
|
|
67
80
|
export interface RadialFrame extends ZoomToFitArcFrame {
|
|
68
81
|
/** Px per SVG unit implied by container or faceDiameter (1 when unknown). */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"radial-frame.d.ts","sourceRoot":"","sources":["../../src/svghelpers/radial-frame.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,SAAS,EAAC,MAAM,0CAA0C,CAAC;AACxE,OAAO,
|
|
1
|
+
{"version":3,"file":"radial-frame.d.ts","sourceRoot":"","sources":["../../src/svghelpers/radial-frame.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,SAAS,EAAC,MAAM,0CAA0C,CAAC;AACxE,OAAO,EAEL,WAAW,EACX,KAAK,iBAAiB,EACvB,MAAM,gBAAgB,CAAC;AA6DxB,+DAA+D;AAC/D,eAAO,MAAM,cAAc,IAAI,CAAC;AAChC,wEAAwE;AACxE,eAAO,MAAM,mBAAmB,KAAK,CAAC;AACtC;;;;GAIG;AACH,eAAO,MAAM,oBAAoB,KAAK,CAAC;AACvC;;;;;;GAMG;AACH,eAAO,MAAM,0BAA0B,OAAO,CAAC;AAC/C;;;;GAIG;AACH,eAAO,MAAM,wBAAwB,KAAK,CAAC;AAC3C;;;GAGG;AACH,eAAO,MAAM,kBAAkB,KAAK,CAAC;AAErC,6EAA6E;AAC7E,MAAM,WAAW,WAAW;IAC1B,GAAG,EAAE,MAAM,CAAC;IACZ,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,kBAAk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,mBAAmB,CACjC,IAAI,EAAE,WAAW,EACjB,KAAK,EAAE,WAAW,GAAG,SAAS,EAC9B,SAAS,EAAE,OAAO,GACjB,OAAO,CAaT;AAED;;;;;;;GAOG;AACH,wBAAgB,eAAe,CAC7B,UAAU,EAAE;IAAC,OAAO,CAAC,MAAM,EAAE,OAAO,GAAG,IAAI,CAAA;CAAC,EAC5C,UAAU,EAAE,UAAU,GACrB,IAAI,CAKN;AAED;;GAEG;AACH,wBAAgB,oBAAoB,CAClC,KAAK,EAAE,SAAS,CAAC,MAAM,GAAG,SAAS,CAAC,EAAE,GACrC,MAAM,CAQR;AAoJD;;;GAGG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,kBAAkB,GAAG,WAAW,CA4DxE"}
|
|
@@ -230,7 +230,9 @@ function zoomFrameAt(opts, extension) {
|
|
|
230
230
|
outerRadius: OUTER_RING_RADIUS,
|
|
231
231
|
innerRadius: opts.innerRadius ?? OUTER_RING_RADIUS,
|
|
232
232
|
extension,
|
|
233
|
-
targetSize: (RADIAL_VIEWBOX_BASE + extension) * 2
|
|
233
|
+
targetSize: (RADIAL_VIEWBOX_BASE + extension) * 2,
|
|
234
|
+
fit: opts.zoomFit,
|
|
235
|
+
includeBox: opts.zoomIncludeBox
|
|
234
236
|
});
|
|
235
237
|
}
|
|
236
238
|
function pinnedZoomedScale(opts, frame) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"radial-frame.js","sources":["../../src/svghelpers/radial-frame.ts"],"sourcesContent":["import type {WatchArea} from '../navigation-instruments/watch/watch.js';\nimport {computeZoomToFitArcFrame, type ZoomToFitArcFrame} from './arc-frame.js';\n\n/**\n * Shared frame computation for circular/radial watch-based instruments.\n *\n * Every radial instrument (watch, instrument-radial/gauge-radial, speed-gauge,\n * azimuth-thruster, compass, heading, rudder, pitch/roll, …) needs the same\n * three outputs to render: an SVG viewBox for `<obc-watch>` and its overlay,\n * a zoom radius offset, and — since issue #1021 — enough reserved room around\n * the outer ring that tick labels are not clipped when the instrument shrinks\n * inside a flex container.\n *\n * `computeRadialFrame()` is the single source of truth for that geometry.\n * Consumers call it once per render and pass the resulting frame to\n * `<obc-watch .arcFrame=...>` (which uses it verbatim) and to their own\n * overlay `<svg viewBox=...>`, guaranteeing the two layers stay aligned.\n *\n * ## Label reserve (issue #1021)\n *\n * Tick labels render at `font-size: calc(12px / scale)` so they keep a\n * constant on-screen size while the ring scales. Their footprint in SVG units\n * is therefore `px / scale`, where `scale = containerPx / viewBoxSide` — the\n * smaller the instrument, the more SVG units a label needs. The frame solves\n * the resulting equation in closed form:\n *\n * ```\n * side/2 >= (OUTER_RING_RADIUS + LABEL_RADIAL_PAD_UNITS) + P/scale\n * scale = containerPx / side\n * => side = 2 * (OUTER_RING_RADIUS + LABEL_RADIAL_PAD_UNITS) / (1 - 2P/containerPx)\n * ```\n *\n * where `P` is the label's pixel cost beyond the ring (anchor offsets + text\n * width + edge padding). The viewBox never shrinks below the legacy\n * `(176 + basePadding) * 2` box, so instruments without labels — or with\n * labels that already fit — render byte-identical to the pre-#1021 output.\n *\n * When the reserve would exceed `LABEL_RESERVE_MAX_FRACTION` of the box, the\n * frame reports `labelsHidden: true` and falls back to the base box; callers\n * must then strip tick label texts (graceful degradation instead of clipping,\n * mirroring the canvas charts).\n *\n * ## Equal circumference (`faceDiameter`)\n *\n * When `faceDiameter` (px) is given, the outer-ring diameter is pinned:\n * `scale = faceDiameter / 368`. The frame then reports `hostWidthPx` /\n * `hostHeightPx` so the host element can adopt a fixed intrinsic size, and\n * instruments sharing a `faceDiameter` value have identical ring\n * circumference regardless of label width or arc extent — the SVG counterpart\n * of `obc-donut-chart`'s fixed-height ⇒ fixed-circumference contract.\n */\n\n// Keep in sync with watch.ts OUTER_RING_RADIUS (importing it would be circular).\nconst OUTER_RING_RADIUS = 368 / 2;\n/** Legacy viewBox base: `side = (RADIAL_VIEWBOX_BASE + padding) * 2`. */\nconst RADIAL_VIEWBOX_BASE = 176;\n/** Non-scaled part of the tickmark text radius pad (`3/scale + 3` in tickmark.ts). */\nconst LABEL_RADIAL_PAD_UNITS = 3;\n/** Scaled label anchor offsets in px: `3/scale` textRadius pad + `6/scale` xOffset. */\nconst LABEL_ANCHOR_OFFSET_PX = 9;\n/** Breathing room between the label's far edge and the viewBox edge, in px. */\nconst LABEL_EDGE_PAD_PX = 4;\n/** Approximate digit advance at 12px font-instrument-label. */\nexport const DIGIT_WIDTH_PX = 7;\n/** Compass NSWE label width assumed by label.ts (`labelWidth = 16`). */\nexport const NSWE_LABEL_WIDTH_PX = 16;\n/**\n * North-arrow glyph allowance for outside-decor reserves (px). The arrow\n * renders regardless of `showLabels`, so consumers charge this portion\n * whenever the arrow sits outside the ring.\n */\nexport const NORTH_ARROW_WIDTH_PX = 16;\n/**\n * Labels are dropped (not clipped) when their reserve would exceed this share\n * of the box. 0.45 makes a 4-digit gauge hide labels below a ~182px container\n * — near the canvas charts' fixed MIN_HEIGHT_WITH_LABELS = 192px threshold —\n * while 2-digit labels survive down to ~120px. Designers may later prefer a\n * fixed pixel threshold instead (see charthelpers/constants.ts).\n */\nexport const LABEL_RESERVE_MAX_FRACTION = 0.45;\n/**\n * Pixel drop of \"Max-min\" end labels (`endLabelsMaxMin`) below the ±90° line:\n * anchored at `12px/scale` with `dominant-baseline: central` (tickmark.ts),\n * so the glyph bottom reaches ~12 + 6 + descender ≈ 20px — plus 1px pad.\n */\nexport const END_MAXMIN_LABEL_DROP_PX = 21;\n/**\n * Pixel drop of regular side labels at the ±90° ends: glyph centered on the\n * line (half-height ~6px + descender), plus pad.\n */\nexport const SIDE_LABEL_DROP_PX = 13;\n\n/** Per-edge viewBox crops in percent (0–100), matching obc-watch `clip*`. */\nexport interface RadialClips {\n top: number;\n bottom: number;\n left: number;\n right: number;\n}\n\nexport interface RadialFrameOptions {\n /** Legacy padding: the frame never shrinks below `(176 + basePadding) * 2`. */\n basePadding: number;\n /** Max label pixel width at 12px font; 0/undefined = no outside labels. */\n labelWidthPx?: number;\n /** Un-zoomed viewBox crops; ignored when `zoomToFitArc` is set. */\n clips?: RadialClips;\n /**\n * Pixel extent the outside labels need past the ±90° horizontal line\n * toward a top/bottom crop edge (see END_MAXMIN_LABEL_DROP_PX /\n * SIDE_LABEL_DROP_PX). When a `clips.top`/`clips.bottom` crop would cut\n * into that drop, the clip is lowered so the labels stay inside the box.\n * Absent/0 keeps the requested clips untouched (legacy geometry).\n */\n labelDropPx?: number;\n /** Host client box in px; absent or zero ⇒ scale-1 fallback (first paint). */\n containerPx?: {width: number; height: number};\n /** Outer-ring diameter in px; pins scale for equal circumference (mode b). */\n faceDiameter?: number;\n zoomToFitArc?: boolean;\n /** Visible arc segments; required for the zoom path. */\n areas?: WatchArea[];\n /** Innermost visible radius (depends on WatchCircleType); zoom path only. */\n innerRadius?: number;\n}\n\nexport interface RadialFrame extends ZoomToFitArcFrame {\n /** Px per SVG unit implied by container or faceDiameter (1 when unknown). */\n scale: number;\n /** SVG units added beyond the base geometry for labels (0 when none/hidden). */\n labelReserve: number;\n /** True when the label reserve exceeded the cap; callers strip tick texts. */\n labelsHidden: boolean;\n /**\n * True when `labelDropPx` lowered a top/bottom clip: the box's aspect no\n * longer matches the requested clip fractions, so hosts with an\n * aspect-ratio derived from those fractions must follow the frame instead.\n */\n clipsAdjusted: boolean;\n /** Fixed host size in px; defined only when `faceDiameter` is set. */\n hostWidthPx?: number;\n /** Fixed host size in px; defined only when `faceDiameter` is set. */\n hostHeightPx?: number;\n}\n\n/**\n * Measure the host's available box in px. Radial instrument hosts render\n * inline by default, so clientWidth/Height are often 0 — fall back to the\n * parent box, like obc-watch's getScale() has always done (issue #1032).\n */\nexport function measureContainerPx(host: HTMLElement): {\n width: number;\n height: number;\n} {\n let width = host.clientWidth;\n let height = host.clientHeight;\n if (width === 0 || height === 0) {\n const box = host.parentElement?.getBoundingClientRect();\n if (box) {\n width = box.width;\n height = box.height;\n }\n }\n return {width, height};\n}\n\n/**\n * Apply/remove the fixed intrinsic host size a `faceDiameter` frame pins.\n * The hosts render inline by default, so a pinned size also needs\n * `display: block` for width/height to apply. Returns whether the size is\n * currently pinned; pass that back as `wasPinned` on the next call so an\n * unpinned host's own inline styles are never clobbered.\n */\nexport function applyPinnedHostSize(\n host: HTMLElement,\n frame: RadialFrame | undefined,\n wasPinned: boolean\n): boolean {\n if (frame?.hostWidthPx !== undefined && frame.hostHeightPx !== undefined) {\n host.style.width = `${frame.hostWidthPx}px`;\n host.style.height = `${frame.hostHeightPx}px`;\n host.style.display = 'block';\n return true;\n }\n if (wasPinned) {\n host.style.removeProperty('width');\n host.style.removeProperty('height');\n host.style.removeProperty('display');\n }\n return false;\n}\n\n/**\n * Additionally observe an internal element that always generates a box (the\n * shadow `<svg>` or `.container`). Several radial hosts render inline (no\n * `:host {display}` rule), and ResizeObserver never fires for inline boxes —\n * the host reports a permanent 0×0 size, so a controller observing only the\n * host misses every resize. That freezes the container-dependent frame and\n * the `--scale` font counter-scaling at their first-paint values.\n */\nexport function observeInnerBox(\n controller: {observe(target: Element): void},\n renderRoot: ParentNode\n): void {\n const box = renderRoot.querySelector('svg, .container');\n if (box) {\n controller.observe(box);\n }\n}\n\n/**\n * Estimate the widest label's pixel width at the 12px instrument label font.\n */\nexport function estimateLabelWidthPx(\n texts: readonly (string | undefined)[]\n): number {\n let maxChars = 0;\n for (const t of texts) {\n if (t !== undefined && t.length > maxChars) {\n maxChars = t.length;\n }\n }\n return maxChars * DIGIT_WIDTH_PX;\n}\n\nfunction clipFractions(clips?: RadialClips): {fx: number; fy: number} {\n if (!clips) {\n return {fx: 1, fy: 1};\n }\n const fx = 1 - (clips.left + clips.right) / 100;\n const fy = 1 - (clips.top + clips.bottom) / 100;\n return {fx: fx > 0 ? fx : 1, fy: fy > 0 ? fy : 1};\n}\n\nfunction buildViewBox(side: number, clips?: RadialClips): ZoomToFitArcFrame {\n const {fx, fy} = clipFractions(clips);\n const width = side * fx;\n const height = side * fy;\n const x = -side / 2 + (side * (clips?.left ?? 0)) / 100;\n const y = -side / 2 + (side * (clips?.top ?? 0)) / 100;\n return {\n x,\n y,\n width,\n height,\n viewBox: `${x} ${y} ${width} ${height}`,\n radiusOffset: 0,\n };\n}\n\nfunction pinnedScale(opts: RadialFrameOptions): number | undefined {\n if (opts.faceDiameter === undefined) {\n return undefined;\n }\n const scale = opts.faceDiameter / (2 * OUTER_RING_RADIUS);\n return Number.isFinite(scale) && scale > 0 ? scale : undefined;\n}\n\n/** Container px available for the full (un-clipped) square, or undefined. */\nfunction effectiveContainer(\n opts: RadialFrameOptions,\n fx: number,\n fy: number\n): number | undefined {\n const w = opts.containerPx?.width ?? 0;\n const h = opts.containerPx?.height ?? 0;\n if (!Number.isFinite(w) || !Number.isFinite(h) || w <= 0 || h <= 0) {\n return undefined;\n }\n return Math.min(w / fx, h / fy);\n}\n\nfunction containerScale(\n opts: RadialFrameOptions,\n frame: {width: number; height: number}\n): number | undefined {\n const w = opts.containerPx?.width ?? 0;\n const h = opts.containerPx?.height ?? 0;\n if (!Number.isFinite(w) || !Number.isFinite(h) || w <= 0 || h <= 0) {\n return undefined;\n }\n const scale = Math.min(w / frame.width, h / frame.height);\n return Number.isFinite(scale) && scale > 0 ? scale : undefined;\n}\n\nfunction withHostPx(\n frame: ZoomToFitArcFrame,\n pinned: boolean,\n scale: number,\n labelReserve: number,\n labelsHidden: boolean,\n clipsAdjusted = false\n): RadialFrame {\n const result: RadialFrame = {\n ...frame,\n scale,\n labelReserve,\n labelsHidden,\n clipsAdjusted,\n };\n if (pinned) {\n result.hostWidthPx = frame.width * scale;\n result.hostHeightPx = frame.height * scale;\n }\n return result;\n}\n\n/**\n * Solve the un-zoomed box side and label visibility for a given clip window.\n */\nfunction solveSide(\n opts: RadialFrameOptions,\n labelCostPx: number,\n clips: RadialClips | undefined\n): {side: number; labelsHidden: boolean} {\n const baseSide = (RADIAL_VIEWBOX_BASE + opts.basePadding) * 2;\n const {fx, fy} = clipFractions(clips);\n const labelSideAt = (scale: number): number =>\n 2 * (OUTER_RING_RADIUS + LABEL_RADIAL_PAD_UNITS + labelCostPx / scale);\n\n let side = baseSide;\n let labelsHidden = false;\n\n if (labelCostPx > 0) {\n const pinned = pinnedScale(opts);\n if (pinned !== undefined) {\n const grown = Math.max(baseSide, labelSideAt(pinned));\n labelsHidden =\n (2 * (labelCostPx / pinned)) / grown > LABEL_RESERVE_MAX_FRACTION;\n side = labelsHidden ? baseSide : grown;\n } else {\n const container = effectiveContainer(opts, fx, fy);\n if (container === undefined) {\n side = Math.max(baseSide, labelSideAt(1));\n } else if ((2 * labelCostPx) / container > LABEL_RESERVE_MAX_FRACTION) {\n labelsHidden = true;\n } else {\n side = Math.max(\n baseSide,\n (2 * (OUTER_RING_RADIUS + LABEL_RADIAL_PAD_UNITS)) /\n (1 - (2 * labelCostPx) / container)\n );\n }\n }\n }\n\n return {side, labelsHidden};\n}\n\n/**\n * Lower a top/bottom clip so the crop edge keeps `labelDropPx / scale` SVG\n * units past the ±90° horizontal line (where the arc end labels hang).\n * Returns the input object unchanged when the requested clips already fit.\n */\nfunction adjustClipsForLabelDrop(\n clips: RadialClips,\n side: number,\n scale: number,\n labelDropPx: number\n): RadialClips {\n const requiredUnits = labelDropPx / scale;\n const requiredClipPct = Math.max(0, (0.5 - requiredUnits / side) * 100);\n const bottom =\n clips.bottom > requiredClipPct ? requiredClipPct : clips.bottom;\n const top = clips.top > requiredClipPct ? requiredClipPct : clips.top;\n if (bottom === clips.bottom && top === clips.top) {\n return clips;\n }\n return {...clips, top, bottom};\n}\n\n/**\n * Compute the viewBox frame for a radial instrument, reserving width-aware\n * room for outside tick labels. See the module documentation for the model.\n */\nexport function computeRadialFrame(opts: RadialFrameOptions): RadialFrame {\n const labelWidthPx = opts.labelWidthPx ?? 0;\n const labelCostPx =\n labelWidthPx > 0\n ? LABEL_ANCHOR_OFFSET_PX + labelWidthPx + LABEL_EDGE_PAD_PX\n : 0;\n\n if (opts.zoomToFitArc && opts.areas && opts.areas.length > 0) {\n return computeZoomedFrame(opts, labelCostPx);\n }\n\n const baseSide = (RADIAL_VIEWBOX_BASE + opts.basePadding) * 2;\n let clips = opts.clips;\n let {side, labelsHidden} = solveSide(opts, labelCostPx, clips);\n\n // Label drop past the ±90° line: lower a top/bottom crop that would cut\n // into it. The clip change alters the container fit (fy grows), so run a\n // second pass; visually exact after two.\n const labelDropPx = opts.labelDropPx ?? 0;\n if (labelDropPx > 0 && labelCostPx > 0 && !labelsHidden && clips) {\n for (let i = 0; i < 2; i++) {\n const scale =\n pinnedScale(opts) ??\n containerScale(opts, buildViewBox(side, clips)) ??\n 1;\n const adjusted = adjustClipsForLabelDrop(\n clips!,\n side,\n scale,\n labelDropPx\n );\n if (adjusted === clips) {\n break;\n }\n clips = adjusted;\n const solved = solveSide(opts, labelCostPx, clips);\n side = solved.side;\n labelsHidden = solved.labelsHidden;\n }\n if (labelsHidden) {\n // The taller window pushed the reserve past the cap: labels are\n // stripped, so the drop is moot — restore the requested clips.\n clips = opts.clips;\n const solved = solveSide(opts, labelCostPx, clips);\n side = solved.side;\n labelsHidden = solved.labelsHidden;\n }\n }\n\n const frame = buildViewBox(side, clips);\n const pinned = pinnedScale(opts);\n const scale = pinned ?? containerScale(opts, frame) ?? 1;\n return withHostPx(\n frame,\n pinned !== undefined,\n scale,\n (side - baseSide) / 2,\n labelsHidden,\n clips !== opts.clips\n );\n}\n\nfunction computeZoomedFrame(\n opts: RadialFrameOptions,\n labelCostPx: number\n): RadialFrame {\n let reserve = 0;\n let labelsHidden = false;\n let frame: ZoomToFitArcFrame = zoomFrameAt(opts, opts.basePadding);\n\n if (labelCostPx > 0) {\n // Fixed-point on the extension: the reserve depends on the scale, and the\n // scale on the frame size. Converges monotonically; two passes suffice.\n for (let i = 0; i < 2; i++) {\n const passScale = zoomedScale(opts, frame);\n const reserveUnits = labelCostPx / passScale;\n if (\n (2 * reserveUnits) / Math.max(frame.width, frame.height) >\n LABEL_RESERVE_MAX_FRACTION\n ) {\n labelsHidden = true;\n reserve = 0;\n frame = zoomFrameAt(opts, opts.basePadding);\n break;\n }\n reserve = reserveUnits;\n frame = zoomFrameAt(opts, opts.basePadding + reserve);\n }\n }\n\n const pinned = pinnedZoomedScale(opts, frame);\n const scale = pinned ?? containerScale(opts, frame) ?? 1;\n return withHostPx(\n frame,\n pinned !== undefined,\n scale,\n labelsHidden ? 0 : reserve,\n labelsHidden\n );\n}\n\nfunction zoomFrameAt(\n opts: RadialFrameOptions,\n extension: number\n): ZoomToFitArcFrame {\n return computeZoomToFitArcFrame({\n areas: opts.areas!,\n outerRadius: OUTER_RING_RADIUS,\n innerRadius: opts.innerRadius ?? OUTER_RING_RADIUS,\n extension,\n targetSize: (RADIAL_VIEWBOX_BASE + extension) * 2,\n });\n}\n\n/** Pin scale for a zoomed frame, or undefined when `faceDiameter` is unusable. */\nfunction pinnedZoomedScale(\n opts: RadialFrameOptions,\n frame: ZoomToFitArcFrame\n): number | undefined {\n if (opts.faceDiameter === undefined) {\n return undefined;\n }\n const scale =\n opts.faceDiameter / (2 * (OUTER_RING_RADIUS + frame.radiusOffset));\n return Number.isFinite(scale) && scale > 0 ? scale : undefined;\n}\n\nfunction zoomedScale(\n opts: RadialFrameOptions,\n frame: ZoomToFitArcFrame\n): number {\n return pinnedZoomedScale(opts, frame) ?? containerScale(opts, frame) ?? 1;\n}\n"],"names":["scale"],"mappings":";AAqDA,MAAM,oBAAoB,MAAM;AAEhC,MAAM,sBAAsB;AAE5B,MAAM,yBAAyB;AAE/B,MAAM,yBAAyB;AAE/B,MAAM,oBAAoB;AAEnB,MAAM,iBAAiB;AAEvB,MAAM,sBAAsB;AAM5B,MAAM,uBAAuB;AAQ7B,MAAM,6BAA6B;AAMnC,MAAM,2BAA2B;AAKjC,MAAM,qBAAqB;AA4D3B,SAAS,mBAAmB,MAGjC;AACA,MAAI,QAAQ,KAAK;AACjB,MAAI,SAAS,KAAK;AAClB,MAAI,UAAU,KAAK,WAAW,GAAG;AAC/B,UAAM,MAAM,KAAK,eAAe,sBAAA;AAChC,QA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AS,IAAI,GAAG,IAAI,GAAG,KAAK;AAC1B,YAAM,YAAY,YAAY,MAAM,KAAK;AACzC,YAAM,eAAe,cAAc;AACnC,UACG,IAAI,eAAgB,KAAK,IAAI,MAAM,OAAO,MAAM,MAAM,IACvD,4BACA;AACA,uBAAe;AACf,kBAAU;AACV,gBAAQ,YAAY,MAAM,KAAK,WAAW;AAC1C;AAAA,MACF;AACA,gBAAU;AACV,cAAQ,YAAY,MAAM,KAAK,cAAc,OAAO;AAAA,IACtD;AAAA,EACF;AAEA,QAAM,SAAS,kBAAkB,MAAM,KAAK;AAC5C,QAAM,QAAQ,UAAU,eAAe,MAAM,KAAK,KAAK;AACvD,SAAO;AAAA,IACL;AAAA,IACA,WAAW;AAAA,IACX;AAAA,IACA,eAAe,IAAI;AAAA,IACnB;AAAA,EAAA;AAEJ;AAEA,SAAS,YACP,MACA,WACmB;AACnB,SAAO,yBAAyB;AAAA,IAC9B,OAAO,KAAK;AAAA,IACZ,aAAa;AAAA,IACb,aAAa,KAAK,eAAe;AAAA,IACjC;AAAA,IACA,aAAa,sBAAsB,aAAa;AAAA,EAAA,CACjD;AACH;AAGA,SAAS,kBACP,MACA,OACoB;AACpB,MAAI,KAAK,iBAAiB,QAAW;AACnC,WAAO;AAAA,EACT;AACA,QAAM,QACJ,KAAK,gBAAgB,KAAK,oBAAoB,MAAM;AACtD,SAAO,OAAO,SAAS,KAAK,KAAK,QAAQ,IAAI,QAAQ;AACvD;AAEA,SAAS,YACP,MACA,OACQ;AACR,SAAO,kBAAkB,MAAM,KAAK,KAAK,eAAe,MAAM,KAAK,KAAK;AAC1E;"}
|
|
1
|
+
{"version":3,"file":"radial-frame.js","sources":["../../src/svghelpers/radial-frame.ts"],"sourcesContent":["import type {WatchArea} from '../navigation-instruments/watch/watch.js';\nimport {\n computeZoomToFitArcFrame,\n ArcFrameFit,\n type ZoomToFitArcFrame,\n} from './arc-frame.js';\n\n/**\n * Shared frame computation for circular/radial watch-based instruments.\n *\n * Every radial instrument (watch, instrument-radial/gauge-radial, speed-gauge,\n * azimuth-thruster, compass, heading, rudder, pitch/roll, …) needs the same\n * three outputs to render: an SVG viewBox for `<obc-watch>` and its overlay,\n * a zoom radius offset, and — since issue #1021 — enough reserved room around\n * the outer ring that tick labels are not clipped when the instrument shrinks\n * inside a flex container.\n *\n * `computeRadialFrame()` is the single source of truth for that geometry.\n * Consumers call it once per render and pass the resulting frame to\n * `<obc-watch .arcFrame=...>` (which uses it verbatim) and to their own\n * overlay `<svg viewBox=...>`, guaranteeing the two layers stay aligned.\n *\n * ## Label reserve (issue #1021)\n *\n * Tick labels render at `font-size: calc(12px / scale)` so they keep a\n * constant on-screen size while the ring scales. Their footprint in SVG units\n * is therefore `px / scale`, where `scale = containerPx / viewBoxSide` — the\n * smaller the instrument, the more SVG units a label needs. The frame solves\n * the resulting equation in closed form:\n *\n * ```\n * side/2 >= (OUTER_RING_RADIUS + LABEL_RADIAL_PAD_UNITS) + P/scale\n * scale = containerPx / side\n * => side = 2 * (OUTER_RING_RADIUS + LABEL_RADIAL_PAD_UNITS) / (1 - 2P/containerPx)\n * ```\n *\n * where `P` is the label's pixel cost beyond the ring (anchor offsets + text\n * width + edge padding). The viewBox never shrinks below the legacy\n * `(176 + basePadding) * 2` box, so instruments without labels — or with\n * labels that already fit — render byte-identical to the pre-#1021 output.\n *\n * When the reserve would exceed `LABEL_RESERVE_MAX_FRACTION` of the box, the\n * frame reports `labelsHidden: true` and falls back to the base box; callers\n * must then strip tick label texts (graceful degradation instead of clipping,\n * mirroring the canvas charts).\n *\n * ## Equal circumference (`faceDiameter`)\n *\n * When `faceDiameter` (px) is given, the outer-ring diameter is pinned:\n * `scale = faceDiameter / 368`. The frame then reports `hostWidthPx` /\n * `hostHeightPx` so the host element can adopt a fixed intrinsic size, and\n * instruments sharing a `faceDiameter` value have identical ring\n * circumference regardless of label width or arc extent — the SVG counterpart\n * of `obc-donut-chart`'s fixed-height ⇒ fixed-circumference contract.\n */\n\n// Keep in sync with watch.ts OUTER_RING_RADIUS (importing it would be circular).\nconst OUTER_RING_RADIUS = 368 / 2;\n/** Legacy viewBox base: `side = (RADIAL_VIEWBOX_BASE + padding) * 2`. */\nconst RADIAL_VIEWBOX_BASE = 176;\n/** Non-scaled part of the tickmark text radius pad (`3/scale + 3` in tickmark.ts). */\nconst LABEL_RADIAL_PAD_UNITS = 3;\n/** Scaled label anchor offsets in px: `3/scale` textRadius pad + `6/scale` xOffset. */\nconst LABEL_ANCHOR_OFFSET_PX = 9;\n/** Breathing room between the label's far edge and the viewBox edge, in px. */\nconst LABEL_EDGE_PAD_PX = 4;\n/** Approximate digit advance at 12px font-instrument-label. */\nexport const DIGIT_WIDTH_PX = 7;\n/** Compass NSWE label width assumed by label.ts (`labelWidth = 16`). */\nexport const NSWE_LABEL_WIDTH_PX = 16;\n/**\n * North-arrow glyph allowance for outside-decor reserves (px). The arrow\n * renders regardless of `showLabels`, so consumers charge this portion\n * whenever the arrow sits outside the ring.\n */\nexport const NORTH_ARROW_WIDTH_PX = 16;\n/**\n * Labels are dropped (not clipped) when their reserve would exceed this share\n * of the box. 0.45 makes a 4-digit gauge hide labels below a ~182px container\n * — near the canvas charts' fixed MIN_HEIGHT_WITH_LABELS = 192px threshold —\n * while 2-digit labels survive down to ~120px. Designers may later prefer a\n * fixed pixel threshold instead (see charthelpers/constants.ts).\n */\nexport const LABEL_RESERVE_MAX_FRACTION = 0.45;\n/**\n * Pixel drop of \"Max-min\" end labels (`endLabelsMaxMin`) below the ±90° line:\n * anchored at `12px/scale` with `dominant-baseline: central` (tickmark.ts),\n * so the glyph bottom reaches ~12 + 6 + descender ≈ 20px — plus 1px pad.\n */\nexport const END_MAXMIN_LABEL_DROP_PX = 21;\n/**\n * Pixel drop of regular side labels at the ±90° ends: glyph centered on the\n * line (half-height ~6px + descender), plus pad.\n */\nexport const SIDE_LABEL_DROP_PX = 13;\n\n/** Per-edge viewBox crops in percent (0–100), matching obc-watch `clip*`. */\nexport interface RadialClips {\n top: number;\n bottom: number;\n left: number;\n right: number;\n}\n\nexport interface RadialFrameOptions {\n /** Legacy padding: the frame never shrinks below `(176 + basePadding) * 2`. */\n basePadding: number;\n /** Max label pixel width at 12px font; 0/undefined = no outside labels. */\n labelWidthPx?: number;\n /** Un-zoomed viewBox crops; ignored when `zoomToFitArc` is set. */\n clips?: RadialClips;\n /**\n * Pixel extent the outside labels need past the ±90° horizontal line\n * toward a top/bottom crop edge (see END_MAXMIN_LABEL_DROP_PX /\n * SIDE_LABEL_DROP_PX). When a `clips.top`/`clips.bottom` crop would cut\n * into that drop, the clip is lowered so the labels stay inside the box.\n * Absent/0 keeps the requested clips untouched (legacy geometry).\n */\n labelDropPx?: number;\n /** Host client box in px; absent or zero ⇒ scale-1 fallback (first paint). */\n containerPx?: {width: number; height: number};\n /** Outer-ring diameter in px; pins scale for equal circumference (mode b). */\n faceDiameter?: number;\n zoomToFitArc?: boolean;\n /** Visible arc segments; required for the zoom path. */\n areas?: WatchArea[];\n /** Innermost visible radius (depends on WatchCircleType); zoom path only. */\n innerRadius?: number;\n /** Zoom viewBox shape; `bbox` crops a flat arc's empty height. */\n zoomFit?: ArcFrameFit;\n /**\n * Region that must stay inside the zoomed viewBox — an overlay the arc's own\n * box would leave out, such as a needle reaching in toward the centre. It\n * widens the final box only; the arc still grows freely.\n */\n zoomIncludeBox?: {xMin: number; yMin: number; xMax: number; yMax: number};\n}\n\nexport interface RadialFrame extends ZoomToFitArcFrame {\n /** Px per SVG unit implied by container or faceDiameter (1 when unknown). */\n scale: number;\n /** SVG units added beyond the base geometry for labels (0 when none/hidden). */\n labelReserve: number;\n /** True when the label reserve exceeded the cap; callers strip tick texts. */\n labelsHidden: boolean;\n /**\n * True when `labelDropPx` lowered a top/bottom clip: the box's aspect no\n * longer matches the requested clip fractions, so hosts with an\n * aspect-ratio derived from those fractions must follow the frame instead.\n */\n clipsAdjusted: boolean;\n /** Fixed host size in px; defined only when `faceDiameter` is set. */\n hostWidthPx?: number;\n /** Fixed host size in px; defined only when `faceDiameter` is set. */\n hostHeightPx?: number;\n}\n\n/**\n * Measure the host's available box in px. Radial instrument hosts render\n * inline by default, so clientWidth/Height are often 0 — fall back to the\n * parent box, like obc-watch's getScale() has always done (issue #1032).\n */\nexport function measureContainerPx(host: HTMLElement): {\n width: number;\n height: number;\n} {\n let width = host.clientWidth;\n let height = host.clientHeight;\n if (width === 0 || height === 0) {\n const box = host.parentElement?.getBoundingClientRect();\n if (box) {\n width = box.width;\n height = box.height;\n }\n }\n return {width, height};\n}\n\n/**\n * Apply/remove the fixed intrinsic host size a `faceDiameter` frame pins.\n * The hosts render inline by default, so a pinned size also needs\n * `display: block` for width/height to apply. Returns whether the size is\n * currently pinned; pass that back as `wasPinned` on the next call so an\n * unpinned host's own inline styles are never clobbered.\n */\nexport function applyPinnedHostSize(\n host: HTMLElement,\n frame: RadialFrame | undefined,\n wasPinned: boolean\n): boolean {\n if (frame?.hostWidthPx !== undefined && frame.hostHeightPx !== undefined) {\n host.style.width = `${frame.hostWidthPx}px`;\n host.style.height = `${frame.hostHeightPx}px`;\n host.style.display = 'block';\n return true;\n }\n if (wasPinned) {\n host.style.removeProperty('width');\n host.style.removeProperty('height');\n host.style.removeProperty('display');\n }\n return false;\n}\n\n/**\n * Additionally observe an internal element that always generates a box (the\n * shadow `<svg>` or `.container`). Several radial hosts render inline (no\n * `:host {display}` rule), and ResizeObserver never fires for inline boxes —\n * the host reports a permanent 0×0 size, so a controller observing only the\n * host misses every resize. That freezes the container-dependent frame and\n * the `--scale` font counter-scaling at their first-paint values.\n */\nexport function observeInnerBox(\n controller: {observe(target: Element): void},\n renderRoot: ParentNode\n): void {\n const box = renderRoot.querySelector('svg, .container');\n if (box) {\n controller.observe(box);\n }\n}\n\n/**\n * Estimate the widest label's pixel width at the 12px instrument label font.\n */\nexport function estimateLabelWidthPx(\n texts: readonly (string | undefined)[]\n): number {\n let maxChars = 0;\n for (const t of texts) {\n if (t !== undefined && t.length > maxChars) {\n maxChars = t.length;\n }\n }\n return maxChars * DIGIT_WIDTH_PX;\n}\n\nfunction clipFractions(clips?: RadialClips): {fx: number; fy: number} {\n if (!clips) {\n return {fx: 1, fy: 1};\n }\n const fx = 1 - (clips.left + clips.right) / 100;\n const fy = 1 - (clips.top + clips.bottom) / 100;\n return {fx: fx > 0 ? fx : 1, fy: fy > 0 ? fy : 1};\n}\n\nfunction buildViewBox(side: number, clips?: RadialClips): ZoomToFitArcFrame {\n const {fx, fy} = clipFractions(clips);\n const width = side * fx;\n const height = side * fy;\n const x = -side / 2 + (side * (clips?.left ?? 0)) / 100;\n const y = -side / 2 + (side * (clips?.top ?? 0)) / 100;\n return {\n x,\n y,\n width,\n height,\n viewBox: `${x} ${y} ${width} ${height}`,\n radiusOffset: 0,\n };\n}\n\nfunction pinnedScale(opts: RadialFrameOptions): number | undefined {\n if (opts.faceDiameter === undefined) {\n return undefined;\n }\n const scale = opts.faceDiameter / (2 * OUTER_RING_RADIUS);\n return Number.isFinite(scale) && scale > 0 ? scale : undefined;\n}\n\n/** Container px available for the full (un-clipped) square, or undefined. */\nfunction effectiveContainer(\n opts: RadialFrameOptions,\n fx: number,\n fy: number\n): number | undefined {\n const w = opts.containerPx?.width ?? 0;\n const h = opts.containerPx?.height ?? 0;\n if (!Number.isFinite(w) || !Number.isFinite(h) || w <= 0 || h <= 0) {\n return undefined;\n }\n return Math.min(w / fx, h / fy);\n}\n\nfunction containerScale(\n opts: RadialFrameOptions,\n frame: {width: number; height: number}\n): number | undefined {\n const w = opts.containerPx?.width ?? 0;\n const h = opts.containerPx?.height ?? 0;\n if (!Number.isFinite(w) || !Number.isFinite(h) || w <= 0 || h <= 0) {\n return undefined;\n }\n const scale = Math.min(w / frame.width, h / frame.height);\n return Number.isFinite(scale) && scale > 0 ? scale : undefined;\n}\n\nfunction withHostPx(\n frame: ZoomToFitArcFrame,\n pinned: boolean,\n scale: number,\n labelReserve: number,\n labelsHidden: boolean,\n clipsAdjusted = false\n): RadialFrame {\n const result: RadialFrame = {\n ...frame,\n scale,\n labelReserve,\n labelsHidden,\n clipsAdjusted,\n };\n if (pinned) {\n result.hostWidthPx = frame.width * scale;\n result.hostHeightPx = frame.height * scale;\n }\n return result;\n}\n\n/**\n * Solve the un-zoomed box side and label visibility for a given clip window.\n */\nfunction solveSide(\n opts: RadialFrameOptions,\n labelCostPx: number,\n clips: RadialClips | undefined\n): {side: number; labelsHidden: boolean} {\n const baseSide = (RADIAL_VIEWBOX_BASE + opts.basePadding) * 2;\n const {fx, fy} = clipFractions(clips);\n const labelSideAt = (scale: number): number =>\n 2 * (OUTER_RING_RADIUS + LABEL_RADIAL_PAD_UNITS + labelCostPx / scale);\n\n let side = baseSide;\n let labelsHidden = false;\n\n if (labelCostPx > 0) {\n const pinned = pinnedScale(opts);\n if (pinned !== undefined) {\n const grown = Math.max(baseSide, labelSideAt(pinned));\n labelsHidden =\n (2 * (labelCostPx / pinned)) / grown > LABEL_RESERVE_MAX_FRACTION;\n side = labelsHidden ? baseSide : grown;\n } else {\n const container = effectiveContainer(opts, fx, fy);\n if (container === undefined) {\n side = Math.max(baseSide, labelSideAt(1));\n } else if ((2 * labelCostPx) / container > LABEL_RESERVE_MAX_FRACTION) {\n labelsHidden = true;\n } else {\n side = Math.max(\n baseSide,\n (2 * (OUTER_RING_RADIUS + LABEL_RADIAL_PAD_UNITS)) /\n (1 - (2 * labelCostPx) / container)\n );\n }\n }\n }\n\n return {side, labelsHidden};\n}\n\n/**\n * Lower a top/bottom clip so the crop edge keeps `labelDropPx / scale` SVG\n * units past the ±90° horizontal line (where the arc end labels hang).\n * Returns the input object unchanged when the requested clips already fit.\n */\nfunction adjustClipsForLabelDrop(\n clips: RadialClips,\n side: number,\n scale: number,\n labelDropPx: number\n): RadialClips {\n const requiredUnits = labelDropPx / scale;\n const requiredClipPct = Math.max(0, (0.5 - requiredUnits / side) * 100);\n const bottom =\n clips.bottom > requiredClipPct ? requiredClipPct : clips.bottom;\n const top = clips.top > requiredClipPct ? requiredClipPct : clips.top;\n if (bottom === clips.bottom && top === clips.top) {\n return clips;\n }\n return {...clips, top, bottom};\n}\n\n/**\n * Compute the viewBox frame for a radial instrument, reserving width-aware\n * room for outside tick labels. See the module documentation for the model.\n */\nexport function computeRadialFrame(opts: RadialFrameOptions): RadialFrame {\n const labelWidthPx = opts.labelWidthPx ?? 0;\n const labelCostPx =\n labelWidthPx > 0\n ? LABEL_ANCHOR_OFFSET_PX + labelWidthPx + LABEL_EDGE_PAD_PX\n : 0;\n\n if (opts.zoomToFitArc && opts.areas && opts.areas.length > 0) {\n return computeZoomedFrame(opts, labelCostPx);\n }\n\n const baseSide = (RADIAL_VIEWBOX_BASE + opts.basePadding) * 2;\n let clips = opts.clips;\n let {side, labelsHidden} = solveSide(opts, labelCostPx, clips);\n\n // Label drop past the ±90° line: lower a top/bottom crop that would cut\n // into it. The clip change alters the container fit (fy grows), so run a\n // second pass; visually exact after two.\n const labelDropPx = opts.labelDropPx ?? 0;\n if (labelDropPx > 0 && labelCostPx > 0 && !labelsHidden && clips) {\n for (let i = 0; i < 2; i++) {\n const scale =\n pinnedScale(opts) ??\n containerScale(opts, buildViewBox(side, clips)) ??\n 1;\n const adjusted = adjustClipsForLabelDrop(\n clips!,\n side,\n scale,\n labelDropPx\n );\n if (adjusted === clips) {\n break;\n }\n clips = adjusted;\n const solved = solveSide(opts, labelCostPx, clips);\n side = solved.side;\n labelsHidden = solved.labelsHidden;\n }\n if (labelsHidden) {\n // The taller window pushed the reserve past the cap: labels are\n // stripped, so the drop is moot — restore the requested clips.\n clips = opts.clips;\n const solved = solveSide(opts, labelCostPx, clips);\n side = solved.side;\n labelsHidden = solved.labelsHidden;\n }\n }\n\n const frame = buildViewBox(side, clips);\n const pinned = pinnedScale(opts);\n const scale = pinned ?? containerScale(opts, frame) ?? 1;\n return withHostPx(\n frame,\n pinned !== undefined,\n scale,\n (side - baseSide) / 2,\n labelsHidden,\n clips !== opts.clips\n );\n}\n\nfunction computeZoomedFrame(\n opts: RadialFrameOptions,\n labelCostPx: number\n): RadialFrame {\n let reserve = 0;\n let labelsHidden = false;\n let frame: ZoomToFitArcFrame = zoomFrameAt(opts, opts.basePadding);\n\n if (labelCostPx > 0) {\n // Fixed-point on the extension: the reserve depends on the scale, and the\n // scale on the frame size. Converges monotonically; two passes suffice.\n for (let i = 0; i < 2; i++) {\n const passScale = zoomedScale(opts, frame);\n const reserveUnits = labelCostPx / passScale;\n if (\n (2 * reserveUnits) / Math.max(frame.width, frame.height) >\n LABEL_RESERVE_MAX_FRACTION\n ) {\n labelsHidden = true;\n reserve = 0;\n frame = zoomFrameAt(opts, opts.basePadding);\n break;\n }\n reserve = reserveUnits;\n frame = zoomFrameAt(opts, opts.basePadding + reserve);\n }\n }\n\n const pinned = pinnedZoomedScale(opts, frame);\n const scale = pinned ?? containerScale(opts, frame) ?? 1;\n return withHostPx(\n frame,\n pinned !== undefined,\n scale,\n labelsHidden ? 0 : reserve,\n labelsHidden\n );\n}\n\nfunction zoomFrameAt(\n opts: RadialFrameOptions,\n extension: number\n): ZoomToFitArcFrame {\n return computeZoomToFitArcFrame({\n areas: opts.areas!,\n outerRadius: OUTER_RING_RADIUS,\n innerRadius: opts.innerRadius ?? OUTER_RING_RADIUS,\n extension,\n targetSize: (RADIAL_VIEWBOX_BASE + extension) * 2,\n fit: opts.zoomFit,\n includeBox: opts.zoomIncludeBox,\n });\n}\n\n/** Pin scale for a zoomed frame, or undefined when `faceDiameter` is unusable. */\nfunction pinnedZoomedScale(\n opts: RadialFrameOptions,\n frame: ZoomToFitArcFrame\n): number | undefined {\n if (opts.faceDiameter === undefined) {\n return undefined;\n }\n const scale =\n opts.faceDiameter / (2 * (OUTER_RING_RADIUS + frame.radiusOffset));\n return Number.isFinite(scale) && scale > 0 ? scale : undefined;\n}\n\nfunction zoomedScale(\n opts: RadialFrameOptions,\n frame: ZoomToFitArcFrame\n): number {\n return pinnedZoomedScale(opts, frame) ?? containerScale(opts, frame) ?? 1;\n}\n"],"names":["scale"],"mappings":";AAyDA,MA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AACA,QAAM,QACJ,KAAK,gBAAgB,KAAK,oBAAoB,MAAM;AACtD,SAAO,OAAO,SAAS,KAAK,KAAK,QAAQ,IAAI,QAAQ;AACvD;AAEA,SAAS,YACP,MACA,OACQ;AACR,SAAO,kBAAkB,MAAM,KAAK,KAAK,eAAe,MAAM,KAAK,KAAK;AAC1E;"}
|
package/docs/GettingStarted.mdx
CHANGED
|
@@ -10,6 +10,8 @@ marking our first stable milestone.
|
|
|
10
10
|
|
|
11
11
|
# Getting Started
|
|
12
12
|
|
|
13
|
+
Upgrading from 1.x? The [Migration Guide](?path=/docs/introduction-migration-guide--docs) lists what changed in 2.0.
|
|
14
|
+
|
|
13
15
|
## Installation
|
|
14
16
|
|
|
15
17
|
The package is publicly available on [npm](https://www.npmjs.com/package/@oicl/openbridge-webcomponents) — no authentication required.
|