2025-08-27 01:15:01 +08:00
|
|
|
import * as React from "react";
|
|
|
|
|
import * as LabelPrimitive from "@radix-ui/react-label";
|
2025-08-26 15:29:52 -05:00
|
|
|
import { useCameraFriendlyName } from "@/hooks/use-camera-friendly-name";
|
2025-08-27 01:15:01 +08:00
|
|
|
import { CameraConfig } from "@/types/frigateConfig";
|
2025-11-07 22:02:06 +08:00
|
|
|
import { useZoneFriendlyName } from "@/hooks/use-zone-friendly-name";
|
2025-08-27 01:15:01 +08:00
|
|
|
|
2026-09-15 16:18:49 -05:00
|
|
|
interface CameraNameLabelProps extends React.ComponentPropsWithoutRef<
|
|
|
|
|
typeof LabelPrimitive.Root
|
|
|
|
|
> {
|
2025-08-27 01:15:01 +08:00
|
|
|
camera?: string | CameraConfig;
|
|
|
|
|
}
|
|
|
|
|
|
2026-09-15 16:18:49 -05:00
|
|
|
interface ZoneNameLabelProps extends React.ComponentPropsWithoutRef<
|
|
|
|
|
typeof LabelPrimitive.Root
|
|
|
|
|
> {
|
2025-11-07 22:02:06 +08:00
|
|
|
zone: string;
|
|
|
|
|
camera?: string;
|
|
|
|
|
}
|
|
|
|
|
|
2025-08-27 01:15:01 +08:00
|
|
|
const CameraNameLabel = React.forwardRef<
|
|
|
|
|
React.ElementRef<typeof LabelPrimitive.Root>,
|
|
|
|
|
CameraNameLabelProps
|
|
|
|
|
>(({ className, camera, ...props }, ref) => {
|
2025-08-26 15:29:52 -05:00
|
|
|
const displayName = useCameraFriendlyName(camera);
|
2025-08-27 01:15:01 +08:00
|
|
|
return (
|
|
|
|
|
<LabelPrimitive.Root ref={ref} className={className} {...props}>
|
|
|
|
|
{displayName}
|
|
|
|
|
</LabelPrimitive.Root>
|
|
|
|
|
);
|
|
|
|
|
});
|
|
|
|
|
CameraNameLabel.displayName = LabelPrimitive.Root.displayName;
|
|
|
|
|
|
2025-11-07 22:02:06 +08:00
|
|
|
const ZoneNameLabel = React.forwardRef<
|
|
|
|
|
React.ElementRef<typeof LabelPrimitive.Root>,
|
|
|
|
|
ZoneNameLabelProps
|
|
|
|
|
>(({ className, zone, camera, ...props }, ref) => {
|
|
|
|
|
const displayName = useZoneFriendlyName(zone, camera);
|
|
|
|
|
return (
|
|
|
|
|
<LabelPrimitive.Root ref={ref} className={className} {...props}>
|
|
|
|
|
{displayName}
|
|
|
|
|
</LabelPrimitive.Root>
|
|
|
|
|
);
|
|
|
|
|
});
|
|
|
|
|
ZoneNameLabel.displayName = LabelPrimitive.Root.displayName;
|
|
|
|
|
|
|
|
|
|
export { CameraNameLabel, ZoneNameLabel };
|