@magmonium/one 0.4.89 → 0.4.91

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.
@@ -34817,11 +34817,16 @@ const ladderScale = ({ value, levels, forward = [], maxSpanPct }) => {
34817
34817
  clamp: (v) => Math.max(0, Math.min(100, pos(v)))
34818
34818
  };
34819
34819
  };
34820
- const layoutLanes = (items, minGapPx) => {
34820
+ const pointExtent = (_keys, x) => [x, x];
34821
+ const layoutLanes = (items, minGapPx, extent = pointExtent) => {
34821
34822
  const labels = [];
34822
34823
  const last = [null, null];
34823
34824
  for (const item of [...items].sort((a, b) => a.x - b.x)) {
34824
- const lane = [0, 1].find((l) => !last[l] || item.x - last[l].x >= minGapPx);
34825
+ const [start] = extent([item.key], item.x);
34826
+ const lane = [0, 1].find((l) => {
34827
+ const prev = last[l];
34828
+ return !prev || start - extent(prev.keys, prev.x)[1] >= minGapPx;
34829
+ });
34825
34830
  if (lane !== void 0) {
34826
34831
  const label = {
34827
34832
  lane,
@@ -36495,7 +36500,9 @@ const BREAKPOINT_PX = {
36495
36500
  xxl: 1400
36496
36501
  };
36497
36502
  const FALLBACK_PX = 640;
36498
- const LABEL_GAP_PX = 72;
36503
+ const LABEL_GAP_PX = 12;
36504
+ const LABEL_CHAR_PX = 7.5;
36505
+ const labelPx = (text) => Array.from(text).length * LABEL_CHAR_PX;
36499
36506
  const ROW_PX = 28;
36500
36507
  const MIN_VERTICAL_PX = 200;
36501
36508
  const finite = (v) => typeof v === "number" && Number.isFinite(v) ? v : null;
@@ -36553,10 +36560,11 @@ var ScaleComponent = class ScaleComponent {
36553
36560
  const w = this.width();
36554
36561
  return w > 0 && w < BREAKPOINT_PX[this.breakpoint()] ? "vertical" : "horizontal";
36555
36562
  }, ...ngDevMode ? [{ debugName: "shownAs" }] : /* istanbul ignore next */ []);
36556
- marks = computed(() => this.markTags().flatMap((tag) => {
36563
+ marks = computed(() => this.markTags().flatMap((tag, i) => {
36557
36564
  const value = finite(tag.value());
36558
36565
  if (value === null) return [];
36559
36566
  return [{
36567
+ id: `mark-${i}`,
36560
36568
  key: tag.key(),
36561
36569
  name: this.t(tag.label() || tag.key()),
36562
36570
  value,
@@ -36621,7 +36629,7 @@ var ScaleComponent = class ScaleComponent {
36621
36629
  const ticks = marks.map((m) => {
36622
36630
  const pin = domain.pin(m.value);
36623
36631
  return {
36624
- key: m.key,
36632
+ key: m.id,
36625
36633
  kind: m.kind,
36626
36634
  primary: m.primary,
36627
36635
  at: at(m.value),
@@ -36629,7 +36637,7 @@ var ScaleComponent = class ScaleComponent {
36629
36637
  };
36630
36638
  });
36631
36639
  const bands = marks.filter((m) => m.kind === "target" && m.low !== null && m.high !== null).map((m) => ({
36632
- key: m.key,
36640
+ key: m.id,
36633
36641
  ...span(at(m.low), at(m.high))
36634
36642
  }));
36635
36643
  const bounds = marks.filter((m) => m.kind === "bound").map((m) => m.value);
@@ -36647,9 +36655,9 @@ var ScaleComponent = class ScaleComponent {
36647
36655
  ...b,
36648
36656
  row
36649
36657
  }));
36650
- const byKey = new Map(marks.map((m) => [m.key, m]));
36651
- const text = (keys) => {
36652
- const group = keys.map((k) => byKey.get(k));
36658
+ const byId = new Map(marks.map((m) => [m.id, m]));
36659
+ const text = (ids) => {
36660
+ const group = ids.map((id) => byId.get(id));
36653
36661
  return {
36654
36662
  name: group.map((m) => m.name).join(" · "),
36655
36663
  valueText: group.map((m) => this.formatValue(m.value)).join(" · "),
@@ -36677,10 +36685,16 @@ var ScaleComponent = class ScaleComponent {
36677
36685
  };
36678
36686
  }
36679
36687
  const widthPx = this.width() || FALLBACK_PX;
36688
+ const extent = (ids, x) => {
36689
+ const { name, valueText } = text(ids);
36690
+ const w = Math.max(labelPx(name), labelPx(valueText));
36691
+ const start = x - w * x / widthPx;
36692
+ return [start, start + w];
36693
+ };
36680
36694
  const labels = layoutLanes(ticks.map((t) => ({
36681
36695
  key: t.key,
36682
36696
  x: t.at / 100 * widthPx
36683
- })), LABEL_GAP_PX).map((l) => ({
36697
+ })), LABEL_GAP_PX, extent).map((l) => ({
36684
36698
  key: l.keys.join("+"),
36685
36699
  lane: l.lane,
36686
36700
  at: l.x / widthPx * 100,