# from flask_wtf import FlaskForm
# from wtforms import StringField, FileField
# from wtforms.fields import HiddenField
# from wtforms.validators import DataRequired
# from wtforms.widgets import ColorInput
# from flask_wtf.file import FileAllowed

# import re
# from wtforms import ValidationError

# # def hex_color_only(form, field):
# #     if not re.match(r'^#(?:[0-9a-fA-F]{3}){1,2}$', field.data):
# #         raise ValidationError('Debe ser un color hexadecimal válido (#RRGGBB o #RGB).')

# class Carousel(FlaskForm):
#     # id = HiddenField()  # Descomenta si lo necesitas
    
#     img = FileField(
#       'Imagen de fondo: ',
#       validators=[
#         DataRequired(),
#         FileAllowed(['jpg', 'jpeg', 'png', 'mp4'], 'Solo se permiten archivos .jpg, .png o .mp4')
#       ]
#     )


#     bg_color = StringField('Color de fondo del texto: ', widget=ColorInput(), validators=[DataRequired()])
    
#     txt_color = StringField('Color del texto: ', widget=ColorInput(), validators=[DataRequired()])
    
#     txt = StringField('Texto: ', validators=[DataRequired()])

#     url = StringField('URL (opt): ')


from flask_wtf import FlaskForm
from wtforms import StringField, FileField, BooleanField  # Añade BooleanField aquí
from wtforms.fields import HiddenField
from wtforms.validators import DataRequired
from wtforms.widgets import ColorInput
from flask_wtf.file import FileAllowed

import re
from wtforms import ValidationError

class Carousel(FlaskForm):
    # id = HiddenField()  # Descomenta si lo necesitas
    
    img = FileField(
      'Imagen de fondo: ',
      validators=[
        DataRequired(),
        FileAllowed(['jpg', 'jpeg', 'png', 'mp4', 'avif', 'webp'], 'Solo se permiten archivos: .jpg, jpeg, mp4, avif o webp')
      ]
    )

    bg_color = StringField('Color de fondo: ', widget=ColorInput(), validators=[DataRequired()])
    
    txt_color = StringField('Color del texto: ', widget=ColorInput(), validators=[DataRequired()])
    
    txt = StringField('Texto: ', validators=[DataRequired()])

    url = StringField('URL (opt): ')
    
    # Añade el checkbox aquí
    isNewTab = BooleanField('¿En nueva ventana?', default=False)