@7365admin1/layer-common 4.97.1-staging.640 → 4.97.1-staging.641

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.
@@ -176,7 +176,7 @@
176
176
  type="button"
177
177
  class="hero-bmap__name"
178
178
  :class="{ 'hero-bmap__name--left': nameTagSide(r.left, r.top, r.name, plane.w, plane.h, BUILDING_TAG).flipX }"
179
- :style="{ transform: `translateZ(${look.pinZ}px) ${unskew}` }"
179
+ :style="{ transform: `translateZ(${look.pinZ + (nameTagStack(f.robots)[r.id] ?? 0) * TAG_STEP}px) ${unskew}` }"
180
180
  @click.stop="emit('open', r.id)"
181
181
  @mousedown.stop
182
182
  >
@@ -246,6 +246,7 @@ import { siteFloorKey, siteFloorLabel, type TSiteFloor } from "../../utils/robot
246
246
  import {
247
247
  BUILDING_TAG,
248
248
  nameTagSide,
249
+ nameTagStack,
249
250
  brandName,
250
251
  siteFloorOf,
251
252
  mapFloors,
@@ -287,6 +288,9 @@ import {
287
288
  type TMapCamera,
288
289
  } from "../../utils/robot-building";
289
290
 
291
+ // Height between stacked name tags of robots standing close together (px, along the pin).
292
+ const TAG_STEP = 22;
293
+
290
294
  const props = withDefaults(
291
295
  defineProps<{
292
296
  organization: string;
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@7365admin1/layer-common",
3
3
  "license": "MIT",
4
4
  "type": "module",
5
- "version": "4.97.1-staging.640",
5
+ "version": "4.97.1-staging.641",
6
6
  "author": "7365admin1",
7
7
  "main": "./nuxt.config.ts",
8
8
  "//files": "What a consumer extending this layer actually loads. Without this npm ships the whole working tree - the changesets, the CI workflows, the render harness in tools/ and any scratch directory that happened to exist at publish time. Nuxt resolves a layer by directory, so every runtime directory below has to stay listed; adding a new top-level runtime directory means adding it here too.",
@@ -2041,3 +2041,22 @@ export function jobOptionsLine(offered: { clean: boolean; rounds: boolean; modes
2041
2041
  }
2042
2042
  return "";
2043
2043
  }
2044
+
2045
+ /**
2046
+ * Name tags of robots standing close together on one floor would print on top of each other. Each robot gets a
2047
+ * stack level: 0 for the first in a cluster, 1, 2... for the next ones, so their tags can be raised one above the
2048
+ * other. `near` is in plan percent.
2049
+ * ponytail: O(n^2) per floor, fine for the handful of robots a floor carries.
2050
+ */
2051
+ export function nameTagStack(robots: { id: string; left: string; top: string }[], near = { x: 14, y: 8 }): Record<string, number> {
2052
+ const pct = (v: string) => Number.parseFloat(v) || 0;
2053
+ const out: Record<string, number> = {};
2054
+ robots.forEach((r, i) => {
2055
+ const taken = new Set(robots.slice(0, i).filter((o) => Math.abs(pct(o.left) - pct(r.left)) < near.x && Math.abs(pct(o.top) - pct(r.top)) < near.y).map((o) => out[o.id]));
2056
+ let level = 0;
2057
+ while (taken.has(level)) level++;
2058
+ out[r.id] = level;
2059
+ });
2060
+ return out;
2061
+ }
2062
+