@camstack/ui-library 1.2.115 → 1.2.117
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/composites/battery-badge.d.ts +1 -1
- package/dist/index.cjs +7 -3
- package/dist/index.js +7 -3
- package/package.json +1 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export interface BatteryStatusLike {
|
|
2
2
|
readonly percentage: number;
|
|
3
|
-
readonly charging: 'dc' | 'solar' | 'none';
|
|
3
|
+
readonly charging: 'dc' | 'solar' | 'none' | 'unknown';
|
|
4
4
|
readonly sleeping: boolean;
|
|
5
5
|
/** True for a binary LOW_BAT source with no real % — render "Normal"/"Low"
|
|
6
6
|
* instead of a misleading exact percentage. */
|
package/dist/index.cjs
CHANGED
|
@@ -24374,8 +24374,12 @@ function pickIcon(percentage) {
|
|
|
24374
24374
|
if (percentage <= 70) return BatteryMedium;
|
|
24375
24375
|
return BatteryFull;
|
|
24376
24376
|
}
|
|
24377
|
+
/** A power source the camera actually reported, as opposed to none or unknown. */
|
|
24378
|
+
function isPowered(charging) {
|
|
24379
|
+
return charging === "dc" || charging === "solar";
|
|
24380
|
+
}
|
|
24377
24381
|
function levelColor(percentage, charging) {
|
|
24378
|
-
if (charging
|
|
24382
|
+
if (isPowered(charging)) return "text-emerald-400";
|
|
24379
24383
|
if (percentage <= 10) return "text-rose-400";
|
|
24380
24384
|
if (percentage <= 30) return "text-amber-400";
|
|
24381
24385
|
return "text-foreground-subtle";
|
|
@@ -24397,13 +24401,13 @@ function BatteryBadge({ status, variant = "compact", className }) {
|
|
|
24397
24401
|
const showSleeping = status.sleeping;
|
|
24398
24402
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
|
|
24399
24403
|
className: cn("inline-flex items-center gap-1 text-[10px] font-medium", color, className),
|
|
24400
|
-
title: `Battery: ${Math.round(status.percentage)}%` + (status.charging
|
|
24404
|
+
title: `Battery: ${Math.round(status.percentage)}%` + (isPowered(status.charging) ? ` · charging (${status.charging})` : "") + (status.sleeping ? " · sleeping" : ""),
|
|
24401
24405
|
children: [
|
|
24402
24406
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(Icon, { className: "h-3.5 w-3.5" }),
|
|
24403
24407
|
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", { children: [Math.round(status.percentage), "%"] }),
|
|
24404
24408
|
ChargingGlyph && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ChargingGlyph, { className: "h-3 w-3" }),
|
|
24405
24409
|
showSleeping && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Moon, { className: "h-3 w-3 text-blue-300" }),
|
|
24406
|
-
variant === "full" && status.charging
|
|
24410
|
+
variant === "full" && isPowered(status.charging) && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
24407
24411
|
className: "text-foreground-subtle",
|
|
24408
24412
|
children: status.charging
|
|
24409
24413
|
})
|
package/dist/index.js
CHANGED
|
@@ -24350,8 +24350,12 @@ function pickIcon(percentage) {
|
|
|
24350
24350
|
if (percentage <= 70) return BatteryMedium;
|
|
24351
24351
|
return BatteryFull;
|
|
24352
24352
|
}
|
|
24353
|
+
/** A power source the camera actually reported, as opposed to none or unknown. */
|
|
24354
|
+
function isPowered(charging) {
|
|
24355
|
+
return charging === "dc" || charging === "solar";
|
|
24356
|
+
}
|
|
24353
24357
|
function levelColor(percentage, charging) {
|
|
24354
|
-
if (charging
|
|
24358
|
+
if (isPowered(charging)) return "text-emerald-400";
|
|
24355
24359
|
if (percentage <= 10) return "text-rose-400";
|
|
24356
24360
|
if (percentage <= 30) return "text-amber-400";
|
|
24357
24361
|
return "text-foreground-subtle";
|
|
@@ -24373,13 +24377,13 @@ function BatteryBadge({ status, variant = "compact", className }) {
|
|
|
24373
24377
|
const showSleeping = status.sleeping;
|
|
24374
24378
|
return /* @__PURE__ */ jsxs("span", {
|
|
24375
24379
|
className: cn("inline-flex items-center gap-1 text-[10px] font-medium", color, className),
|
|
24376
|
-
title: `Battery: ${Math.round(status.percentage)}%` + (status.charging
|
|
24380
|
+
title: `Battery: ${Math.round(status.percentage)}%` + (isPowered(status.charging) ? ` · charging (${status.charging})` : "") + (status.sleeping ? " · sleeping" : ""),
|
|
24377
24381
|
children: [
|
|
24378
24382
|
/* @__PURE__ */ jsx(Icon, { className: "h-3.5 w-3.5" }),
|
|
24379
24383
|
/* @__PURE__ */ jsxs("span", { children: [Math.round(status.percentage), "%"] }),
|
|
24380
24384
|
ChargingGlyph && /* @__PURE__ */ jsx(ChargingGlyph, { className: "h-3 w-3" }),
|
|
24381
24385
|
showSleeping && /* @__PURE__ */ jsx(Moon, { className: "h-3 w-3 text-blue-300" }),
|
|
24382
|
-
variant === "full" && status.charging
|
|
24386
|
+
variant === "full" && isPowered(status.charging) && /* @__PURE__ */ jsx("span", {
|
|
24383
24387
|
className: "text-foreground-subtle",
|
|
24384
24388
|
children: status.charging
|
|
24385
24389
|
})
|