import { ReactNode, useEffect, useState } from 'react';
import { useField } from '@unform/core';
import { Colors, colors, useTheme } from '../../hooks/theme';
import { Container } from './Select/styles';
import { Label, Error, ColorView, InputContainer } from './styles';
type Option = {
value: string;
label: string;
};
interface Props {
name: string;
label?: string;
placeholder?: string;
returnType?: 'key' | 'option';
}
type ColorPickerProps = JSX.IntrinsicElements['input'] & Props;
const options = Object.keys(colors).map((item) => ({
value: item,
label: item,
}));
export function ColorPicker({
name,
label,
disabled,
placeholder,
returnType = 'key',
}: ColorPickerProps): JSX.Element {
const { colorScheme } = useTheme();
const { fieldName, defaultValue = '', registerField, error } = useField(name);
const [selected, setSelected] = useState