2023-11-09 14:43:06 +03:00

34 lines
1.1 KiB
TypeScript

import { cn } from './utils';
import type { VariantProps } from 'class-variance-authority';
import { cva } from 'class-variance-authority';
import type { PropsWithChildren } from 'react';
import { forwardRef } from 'react';
const wrapperVariants = cva('flex flex-col');
export type DivProps = React.HTMLAttributes<HTMLDivElement> &
VariantProps<typeof wrapperVariants> &
PropsWithChildren;
export const Wrapper = forwardRef<HTMLDivElement, DivProps>(
({ children, className, ...props }, ref) => (
<div {...props} className={cn(wrapperVariants({ className }))} ref={ref}>
{children}
</div>
)
);
const titleVariants = cva(
'mb-1 block overflow-hidden overflow-ellipsis whitespace-nowrap text-sm font-medium text-black text-opacity-90'
);
export type LabelProps = React.LabelHTMLAttributes<HTMLLabelElement>;
export const Title = forwardRef<HTMLLabelElement, LabelProps>(
({ className, htmlFor, title, ...props }, ref) => (
<label {...props} htmlFor={htmlFor} className={cn(titleVariants({ className }))} ref={ref}>
{title}
</label>
)
);