@jsenv/navi 0.18.6 → 0.18.8

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.
@@ -29460,7 +29460,7 @@ installImportMetaCss(import.meta);import.meta.css = /* css */`
29460
29460
  @layer navi {
29461
29461
  .navi_stat {
29462
29462
  --unit-color: color-mix(in srgb, currentColor 50%, white);
29463
- --unit-ratio: 0.7;
29463
+ --unit-size-ratio: 0.7;
29464
29464
  }
29465
29465
  }
29466
29466
 
@@ -29485,7 +29485,7 @@ installImportMetaCss(import.meta);import.meta.css = /* css */`
29485
29485
  .navi_stat_unit {
29486
29486
  color: var(--unit-color);
29487
29487
  font-weight: normal;
29488
- font-size: calc(var(--unit-ratio) * 1em);
29488
+ font-size: calc(var(--unit-size-ratio) * 1em);
29489
29489
  }
29490
29490
  }
29491
29491
 
@@ -29521,7 +29521,7 @@ const Stat = ({
29521
29521
  children,
29522
29522
  unit,
29523
29523
  unitPosition = "right",
29524
- unitRatio,
29524
+ unitSizeRatio,
29525
29525
  label,
29526
29526
  size,
29527
29527
  lang,
@@ -29564,8 +29564,8 @@ const Stat = ({
29564
29564
  }), unit && jsx("span", {
29565
29565
  className: "navi_stat_unit",
29566
29566
  style: {
29567
- ...(unitRatio === undefined ? {} : {
29568
- "--unit-ratio": unitRatio
29567
+ ...(unitSizeRatio === undefined ? {} : {
29568
+ "--unit-size-ratio": unitSizeRatio
29569
29569
  })
29570
29570
  },
29571
29571
  children: unit
@@ -29701,7 +29701,7 @@ const Meter = ({
29701
29701
  loading,
29702
29702
  readOnly,
29703
29703
  disabled,
29704
- children,
29704
+ caption,
29705
29705
  percentage,
29706
29706
  fillOnly,
29707
29707
  fillRound = fillOnly,
@@ -29711,10 +29711,11 @@ const Meter = ({
29711
29711
  }) => {
29712
29712
  const clampedValue = value < min ? min : value > max ? max : value;
29713
29713
  const fillRatio = max === min ? 0 : (clampedValue - min) / (max - min);
29714
+ let children = caption;
29714
29715
  if (children === undefined && percentage) {
29715
29716
  children = jsx(Stat, {
29716
29717
  unit: "%",
29717
- unitRatio: "1",
29718
+ unitSizeRatio: "1",
29718
29719
  children: Math.round(fillRatio * 100)
29719
29720
  });
29720
29721
  }
@@ -29731,22 +29732,24 @@ const Meter = ({
29731
29732
  if (!trackContainer) {
29732
29733
  return;
29733
29734
  }
29734
- const fillEl = trackContainer.querySelector(".navi_meter_fill");
29735
- if (!fillEl) {
29735
+ // When fill covers less than half the track, the text center sits on the
29736
+ // empty track — use the track color for contrast. Otherwise use fill color.
29737
+ const bgEl = fillRatio >= 0.5 ? trackContainer.querySelector(".navi_meter_fill") : trackContainer.querySelector(".navi_meter_track");
29738
+ if (!bgEl) {
29736
29739
  return;
29737
29740
  }
29738
- const fillBgColor = getComputedStyle(fillEl).backgroundColor;
29739
- const textColor = pickLightOrDark(fillBgColor, "white", "black", fillEl);
29741
+ const bgColor = getComputedStyle(bgEl).backgroundColor;
29742
+ const textColor = pickLightOrDark(bgColor, "white", "black", bgEl);
29740
29743
  const shadowColor = textColor === "white" ? "black" : "white";
29741
29744
  trackContainer.style.setProperty("--x-caption-color", textColor);
29742
29745
  trackContainer.style.setProperty("--x-caption-shadow-color", shadowColor);
29743
- }, [children, level]);
29746
+ }, [children, level, fillRatio]);
29744
29747
  return jsx(Box, {
29745
29748
  role: "meter",
29746
29749
  "aria-valuenow": clampedValue,
29747
29750
  "aria-valuemin": min,
29748
29751
  "aria-valuemax": max,
29749
- "aria-label": typeof children === "string" ? children : undefined,
29752
+ "aria-label": typeof caption === "string" ? caption : undefined,
29750
29753
  baseClassName: "navi_meter",
29751
29754
  styleCSSVars: MeterStyleCSSVars,
29752
29755
  basePseudoState: {