@jsenv/navi 0.18.6 → 0.18.9

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
@@ -29681,6 +29681,14 @@ installImportMetaCss(import.meta);import.meta.css = /* css */`
29681
29681
  border-color: transparent;
29682
29682
  }
29683
29683
  }
29684
+ &[data-transition] {
29685
+ .navi_meter_fill {
29686
+ transition: clip-path 0.4s ease;
29687
+ }
29688
+ &[data-fill-round] .navi_meter_fill {
29689
+ transition: width 0.4s ease;
29690
+ }
29691
+ }
29684
29692
  }
29685
29693
  `;
29686
29694
  const MeterStyleCSSVars = {
@@ -29701,20 +29709,22 @@ const Meter = ({
29701
29709
  loading,
29702
29710
  readOnly,
29703
29711
  disabled,
29704
- children,
29712
+ caption,
29705
29713
  percentage,
29706
29714
  fillOnly,
29707
29715
  fillRound = fillOnly,
29708
29716
  borderless,
29717
+ transition,
29709
29718
  style,
29710
29719
  ...props
29711
29720
  }) => {
29712
29721
  const clampedValue = value < min ? min : value > max ? max : value;
29713
29722
  const fillRatio = max === min ? 0 : (clampedValue - min) / (max - min);
29723
+ let children = caption;
29714
29724
  if (children === undefined && percentage) {
29715
29725
  children = jsx(Stat, {
29716
29726
  unit: "%",
29717
- unitRatio: "1",
29727
+ unitSizeRatio: "1",
29718
29728
  children: Math.round(fillRatio * 100)
29719
29729
  });
29720
29730
  }
@@ -29731,22 +29741,24 @@ const Meter = ({
29731
29741
  if (!trackContainer) {
29732
29742
  return;
29733
29743
  }
29734
- const fillEl = trackContainer.querySelector(".navi_meter_fill");
29735
- if (!fillEl) {
29744
+ // When fill covers less than half the track, the text center sits on the
29745
+ // empty track — use the track color for contrast. Otherwise use fill color.
29746
+ const bgEl = fillRatio >= 0.5 ? trackContainer.querySelector(".navi_meter_fill") : trackContainer.querySelector(".navi_meter_track");
29747
+ if (!bgEl) {
29736
29748
  return;
29737
29749
  }
29738
- const fillBgColor = getComputedStyle(fillEl).backgroundColor;
29739
- const textColor = pickLightOrDark(fillBgColor, "white", "black", fillEl);
29750
+ const bgColor = getComputedStyle(bgEl).backgroundColor;
29751
+ const textColor = pickLightOrDark(bgColor, "white", "black", bgEl);
29740
29752
  const shadowColor = textColor === "white" ? "black" : "white";
29741
29753
  trackContainer.style.setProperty("--x-caption-color", textColor);
29742
29754
  trackContainer.style.setProperty("--x-caption-shadow-color", shadowColor);
29743
- }, [children, level]);
29755
+ }, [children, level, fillRatio]);
29744
29756
  return jsx(Box, {
29745
29757
  role: "meter",
29746
29758
  "aria-valuenow": clampedValue,
29747
29759
  "aria-valuemin": min,
29748
29760
  "aria-valuemax": max,
29749
- "aria-label": typeof children === "string" ? children : undefined,
29761
+ "aria-label": typeof caption === "string" ? caption : undefined,
29750
29762
  baseClassName: "navi_meter",
29751
29763
  styleCSSVars: MeterStyleCSSVars,
29752
29764
  basePseudoState: {
@@ -29759,6 +29771,7 @@ const Meter = ({
29759
29771
  "data-fill-only": fillOnly ? "" : undefined,
29760
29772
  "data-fill-round": fillRound ? "" : undefined,
29761
29773
  "data-borderless": borderless ? "" : undefined,
29774
+ "data-transition": transition ? "" : undefined,
29762
29775
  style: {
29763
29776
  "--x-fill-ratio": fillRatio,
29764
29777
  "--x-fill-color": fillColorVar,