//
//  SQTextFieldConfiguration.swift
//  Allovoisins
//
//  Created by Claude on 22/10/2025.
//  Copyright © 2025 AlloVoisins. All rights reserved.
//

import SwiftUI

/// Configuration structure for Sequoia TextField components.
/// Contains all customizable options that can be set via View Modifiers.
struct SQTextFieldConfiguration {
    var placeholder: String = ""
    var isDisabled: Bool = false
    var isOptional: Bool = false
    var isLoading: Binding<Bool> = .constant(false)
    var tooltipText: String? = nil
    var helperText: String? = nil
    var error: Binding<SQFormFieldError> = .constant(.none)
    var minCharacters: Int? = nil
    var maxCharacters: Int? = nil
    var showCharacterCount: Bool = true
    var backgroundColor: Color = .clear
    var keyboardType: UIKeyboardType = .default
    var infoAction: (() -> Void)? = nil
}

// MARK: - Environment Key

private struct SQTextFieldConfigurationKey: EnvironmentKey {
    static let defaultValue = SQTextFieldConfiguration()
}

extension EnvironmentValues {
    var sqTextFieldConfiguration: SQTextFieldConfiguration {
        get { self[SQTextFieldConfigurationKey.self] }
        set { self[SQTextFieldConfigurationKey.self] = newValue }
    }
}
