@jsenv/navi 0.18.5 → 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.
- package/dist/jsenv_navi.js +26 -13
- package/dist/jsenv_navi.js.map +9 -6
- package/package.json +1 -1
package/dist/jsenv_navi.js
CHANGED
|
@@ -5374,6 +5374,11 @@ const POSITION_PROPS = {
|
|
|
5374
5374
|
// only the first item will be positioned as expected because subsequent items
|
|
5375
5375
|
// will be positioned relative to the previous item's margins, not the container edge.
|
|
5376
5376
|
selfAlignX: (value, { parentBoxFlow }) => {
|
|
5377
|
+
const inGridFlow = parentBoxFlow === "grid";
|
|
5378
|
+
if (inGridFlow) {
|
|
5379
|
+
return { justifySelf: value };
|
|
5380
|
+
}
|
|
5381
|
+
|
|
5377
5382
|
const inRowFlow = parentBoxFlow === "row" || parentBoxFlow === "inline-row";
|
|
5378
5383
|
|
|
5379
5384
|
if (value === "start") {
|
|
@@ -5400,6 +5405,11 @@ const POSITION_PROPS = {
|
|
|
5400
5405
|
return undefined;
|
|
5401
5406
|
},
|
|
5402
5407
|
selfAlignY: (value, { parentBoxFlow }) => {
|
|
5408
|
+
const inGridFlow = parentBoxFlow === "grid";
|
|
5409
|
+
if (inGridFlow) {
|
|
5410
|
+
return { alignSelf: value };
|
|
5411
|
+
}
|
|
5412
|
+
|
|
5403
5413
|
const inColumnFlow =
|
|
5404
5414
|
parentBoxFlow === "column" || parentBoxFlow === "inline-column";
|
|
5405
5415
|
|
|
@@ -29450,7 +29460,7 @@ installImportMetaCss(import.meta);import.meta.css = /* css */`
|
|
|
29450
29460
|
@layer navi {
|
|
29451
29461
|
.navi_stat {
|
|
29452
29462
|
--unit-color: color-mix(in srgb, currentColor 50%, white);
|
|
29453
|
-
--unit-ratio: 0.7;
|
|
29463
|
+
--unit-size-ratio: 0.7;
|
|
29454
29464
|
}
|
|
29455
29465
|
}
|
|
29456
29466
|
|
|
@@ -29475,7 +29485,7 @@ installImportMetaCss(import.meta);import.meta.css = /* css */`
|
|
|
29475
29485
|
.navi_stat_unit {
|
|
29476
29486
|
color: var(--unit-color);
|
|
29477
29487
|
font-weight: normal;
|
|
29478
|
-
font-size: calc(var(--unit-ratio) * 1em);
|
|
29488
|
+
font-size: calc(var(--unit-size-ratio) * 1em);
|
|
29479
29489
|
}
|
|
29480
29490
|
}
|
|
29481
29491
|
|
|
@@ -29511,7 +29521,7 @@ const Stat = ({
|
|
|
29511
29521
|
children,
|
|
29512
29522
|
unit,
|
|
29513
29523
|
unitPosition = "right",
|
|
29514
|
-
|
|
29524
|
+
unitSizeRatio,
|
|
29515
29525
|
label,
|
|
29516
29526
|
size,
|
|
29517
29527
|
lang,
|
|
@@ -29554,8 +29564,8 @@ const Stat = ({
|
|
|
29554
29564
|
}), unit && jsx("span", {
|
|
29555
29565
|
className: "navi_stat_unit",
|
|
29556
29566
|
style: {
|
|
29557
|
-
...(
|
|
29558
|
-
"--unit-ratio":
|
|
29567
|
+
...(unitSizeRatio === undefined ? {} : {
|
|
29568
|
+
"--unit-size-ratio": unitSizeRatio
|
|
29559
29569
|
})
|
|
29560
29570
|
},
|
|
29561
29571
|
children: unit
|
|
@@ -29691,7 +29701,7 @@ const Meter = ({
|
|
|
29691
29701
|
loading,
|
|
29692
29702
|
readOnly,
|
|
29693
29703
|
disabled,
|
|
29694
|
-
|
|
29704
|
+
caption,
|
|
29695
29705
|
percentage,
|
|
29696
29706
|
fillOnly,
|
|
29697
29707
|
fillRound = fillOnly,
|
|
@@ -29701,10 +29711,11 @@ const Meter = ({
|
|
|
29701
29711
|
}) => {
|
|
29702
29712
|
const clampedValue = value < min ? min : value > max ? max : value;
|
|
29703
29713
|
const fillRatio = max === min ? 0 : (clampedValue - min) / (max - min);
|
|
29714
|
+
let children = caption;
|
|
29704
29715
|
if (children === undefined && percentage) {
|
|
29705
29716
|
children = jsx(Stat, {
|
|
29706
29717
|
unit: "%",
|
|
29707
|
-
|
|
29718
|
+
unitSizeRatio: "1",
|
|
29708
29719
|
children: Math.round(fillRatio * 100)
|
|
29709
29720
|
});
|
|
29710
29721
|
}
|
|
@@ -29721,22 +29732,24 @@ const Meter = ({
|
|
|
29721
29732
|
if (!trackContainer) {
|
|
29722
29733
|
return;
|
|
29723
29734
|
}
|
|
29724
|
-
|
|
29725
|
-
|
|
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) {
|
|
29726
29739
|
return;
|
|
29727
29740
|
}
|
|
29728
|
-
const
|
|
29729
|
-
const textColor = pickLightOrDark(
|
|
29741
|
+
const bgColor = getComputedStyle(bgEl).backgroundColor;
|
|
29742
|
+
const textColor = pickLightOrDark(bgColor, "white", "black", bgEl);
|
|
29730
29743
|
const shadowColor = textColor === "white" ? "black" : "white";
|
|
29731
29744
|
trackContainer.style.setProperty("--x-caption-color", textColor);
|
|
29732
29745
|
trackContainer.style.setProperty("--x-caption-shadow-color", shadowColor);
|
|
29733
|
-
}, [children, level]);
|
|
29746
|
+
}, [children, level, fillRatio]);
|
|
29734
29747
|
return jsx(Box, {
|
|
29735
29748
|
role: "meter",
|
|
29736
29749
|
"aria-valuenow": clampedValue,
|
|
29737
29750
|
"aria-valuemin": min,
|
|
29738
29751
|
"aria-valuemax": max,
|
|
29739
|
-
"aria-label": typeof
|
|
29752
|
+
"aria-label": typeof caption === "string" ? caption : undefined,
|
|
29740
29753
|
baseClassName: "navi_meter",
|
|
29741
29754
|
styleCSSVars: MeterStyleCSSVars,
|
|
29742
29755
|
basePseudoState: {
|