* esm * wip * wip * wip * wip * wip * wip * subscription notice * wip * wip * wip * fix envs * fix: update docker build * fix * esm/types * delete dashboard :D * add patches to dockerfiles * update packages + catalogs + ts * wip * remove native libs * ts * improvements * fix redirects and fetching session * try fix favicon * fixes * fix * order and resize reportds within a dashboard * improvements * wip * added userjot to dashboard * fix * add op * wip * different cache key * improve date picker * fix table * event details loading * redo onboarding completely * fix login * fix * fix * extend session, billing and improve bars * fix * reduce price on 10M
55 lines
1.5 KiB
TypeScript
55 lines
1.5 KiB
TypeScript
import { cn } from '@/utils/cn';
|
|
import { slug } from '@/utils/slug';
|
|
import type { LucideIcon } from 'lucide-react';
|
|
import { forwardRef } from 'react';
|
|
import type { ControllerRenderProps } from 'react-hook-form';
|
|
|
|
import { Switch } from '../ui/switch';
|
|
|
|
type Props = {
|
|
label: string;
|
|
description: string;
|
|
Icon: LucideIcon;
|
|
children?: React.ReactNode;
|
|
error?: string;
|
|
} & ControllerRenderProps;
|
|
|
|
export const CheckboxItem = forwardRef<HTMLButtonElement, Props>(
|
|
(
|
|
{ label, description, Icon, children, onChange, value, disabled, error },
|
|
ref,
|
|
) => {
|
|
const id = slug(label);
|
|
return (
|
|
<div>
|
|
<label
|
|
className={cn(
|
|
'flex items-center gap-4 px-4 py-6 transition-colors hover:bg-def-200',
|
|
disabled && 'cursor-not-allowed opacity-50',
|
|
)}
|
|
htmlFor={id}
|
|
>
|
|
{Icon && <div className="w-6 shrink-0">{<Icon />}</div>}
|
|
<div className="flex-1">
|
|
<div className="font-medium">{label}</div>
|
|
<div className=" text-muted-foreground">{description}</div>
|
|
{error && <div className="text-sm text-red-600">{error}</div>}
|
|
</div>
|
|
<div>
|
|
<Switch
|
|
ref={ref}
|
|
disabled={disabled}
|
|
checked={!!value}
|
|
onCheckedChange={onChange}
|
|
id={id}
|
|
/>
|
|
</div>
|
|
</label>
|
|
{children}
|
|
</div>
|
|
);
|
|
},
|
|
);
|
|
|
|
CheckboxItem.displayName = 'CheckboxItem';
|