<?php
/**
 * Campo select de tamaño.
 *
 * @package Logistica
 *
 * @var string $field_name
 * @var string $field_value
 * @var string $select_attr
 * @var bool   $required
 */

if ( ! defined( 'ABSPATH' ) ) {
	exit;
}

$field_name  = isset( $field_name ) ? (string) $field_name : 'tamano';
$field_value = isset( $field_value ) ? (string) $field_value : '';
$select_attr = isset( $select_attr ) ? (string) $select_attr : 'data-etiqueta-tamano-select';
$required    = ! empty( $required );
$tamanos     = Logistica_Label_Etiqueta_Tamanos::get_options();
?>
<div class="logistica-etiqueta-tamano-field">
	<label><?php esc_html_e( 'Tamaño', 'logistica' ); ?>
		<select name="<?php echo esc_attr( $field_name ); ?>" <?php echo $select_attr; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?> <?php echo $required ? 'required' : ''; ?>>
			<option value=""><?php esc_html_e( '— Seleccionar —', 'logistica' ); ?></option>
			<?php foreach ( $tamanos as $tamano_option ) : ?>
				<option value="<?php echo esc_attr( $tamano_option ); ?>" <?php selected( $field_value, $tamano_option ); ?>><?php echo esc_html( $tamano_option ); ?></option>
			<?php endforeach; ?>
		</select>
	</label>
</div>
