(function PointsBar(
{
value,
max = 20,
icon,
label,
showText = false,
iconSize = 16,
lowThreshold = 0,
direction = "ltr",
className,
...rest
},
ref,
) {
const m = useBlockUIMessages();
const safeMax = Math.max(0, max);
const current = clamp(value, 0, safeMax);
const units = Math.ceil(safeMax / 2);
const low = safeMax > 0 && current / safeMax <= lowThreshold;
const fills: Fill[] = Array.from({ length: units }, (_, i) => {
const points = clamp(current - i * 2, 0, 2);
return points >= 2 ? "full" : points >= 1 ? "half" : "empty";
});
return (
{fills.map((fill, index) => (
{icon}
{fill !== "empty" ? {icon} : null}
))}
{showText ? (
{current} / {safeMax}
) : null}
);
});