<?php
/**
 * WeCodeArt Framework
 *
 * WARNING: This file is part of the core WeCodeArt Framework. DO NOT edit this file under any circumstances.
 * Please do all modifications in the form of a child theme.
 *
 * @package 	WeCodeArt Framework 
 * @subpackage 	Markup\Inputs
 * @copyright   Copyright (c) 2025, WeCodeArt Framework
 * @since		5.0.0
 * @version		6.4.1
 */

namespace WeCodeArt\Support\DOM\Inputs;

defined( 'ABSPATH' ) || exit;

use WeCodeArt\Support\DOM\Inputs\Basic;
use function WeCodeArt\Functions\get_prop;

/**
 * Standard Inputs Markup
 */
class TextArea extends Basic {
    /**
     * Input's Style Deps.
     *
     * @since   6.4.1
     * @var     array
     */
    static $style_deps = [ 'basic' ];
    
    /**
	 * Constructor 
	 */
	public function __construct( string $type = 'textarea', array $args = [] ) {
        $this->unique_id    = wp_unique_id( 'textarea-' );
        $this->label        = get_prop( $args, 'label', '' );
        $this->_label       = get_prop( $args, '_label', 'before' );
        $this->attrs        = get_prop( $args, 'attrs', [] );
        $this->messages     = get_prop( $args, 'messages', [] );
    }

	/**
	 * Create HTML Inputs
	 *
	 * @since	unknown
	 * @version	5.1.8
	 */
	public function content() {
        ?>
        <textarea <?php $this->input_attrs( [ 'type' ] ); ?>><?php

            echo isset( $this->attrs['value'] ) ? esc_textarea( $this->attrs['value'] ) : '';

        ?></textarea>
        <?php
    }

    /**
	 * Input styles.
	 *
	 * @return 	string
	 */
	public static function styles(): string {
		return '
            textarea {
                resize: vertical;
            }
            textarea.form-control {
                min-height: 150px;
            }
            textarea.form-control-sm {
                min-height: 100px;
            } 
            textarea.form-control-lg {
                min-height: 200px;
            }
            .was-validated textarea.form-control:is(:valid,:invalid),
            textarea.form-control:is(.is-valid,.is-invalid) {
                background-position: top calc(0.375em + 0.1875rem) right calc(0.375em + 0.1875rem);
            }
        ';
	}
}