<?php
/**
 * Field render
 * @var Form $form
 * @var string $type
 * @var array $item
 * @var string $prefix
 * @var int $item_index
 * @var string $formId
 * @var string $itemId
 * @var string $key
 * @var array $settings
 */

use ElementorPro\Modules\Forms\Widgets\Form;

if ( ! defined( 'ABSPATH' ) ) {
	exit; // Exit if accessed directly.
}

$form->remove_render_attribute( 'input' . $item_index, 'type' );
$form->add_render_attribute( 'input' . $item_index, 'class', 'elementor-use-native elementor-field-textual ' . $prefix . 'field' );

$settings['attrs'] = $form->get_render_attributes( 'input' . $item_index );
$settings['itemId'] = esc_attr( $itemId );
$settings['formId'] = esc_attr( $formId );
$settings['value'] = esc_attr( $item[ $prefix . 'default_value' ] );
$settings['min'] = esc_attr( $item[ $prefix . 'min' ] );
$settings['max'] = esc_attr( $item[ $prefix . 'max' ] );
$settings['placeholder'] = esc_attr( $item[ $prefix . 'placeholder' ] );
$settings['isNative'] = esc_attr( $item[ $prefix . 'isNative' ] ) === 'yes';
$settings['time_24hr'] = esc_attr( $item[ $prefix . 'time_24hr' ] ) === 'yes';

if ( $settings['isNative'] ) {
	$inputType = 'datetime-local';
} else {
	$inputType = 'text';
}

?>
<div
	class="<?php echo esc_attr( $type ); ?>_wrap elementor-repeater-item-<?php echo esc_attr( $itemId ); ?>"
	data-key="<?php echo esc_attr( $key ); ?>"
>
	<input aria-label="" type="<?php echo esc_attr( $inputType ); ?>" value="<?php echo esc_attr( $settings['value'] ); ?>"
		<?php $form->print_render_attribute_string( 'input' . $item_index ); ?>>
</div>
