<?php
namespace PpPhp\Plugins;
use PpPhp\Core\EditPlugin;

class TextBox implements EditPlugin
{
    public static function id(): string { return 'TextBox'; }
    public static function label(): string { return 'Text Box'; }
    public static function version(): string { return '1.0.0'; }
    public static function description(): string { return 'A single-line text input.'; }

    public static function render(string $fieldName, mixed $value, array $settings): string
    {
        return '<input type="text" name="' . $fieldName . '" value="' . htmlspecialchars($value ?? '') . '" class="form-control">';
    }

    public static function settingsSchema(): array
    {
        return [
            ['key' => 'placeholder', 'type' => 'text', 'label' => 'Placeholder', 'default' => ''],
        ];
    }

    public static function assets(): array
    {
        return ['js' => [], 'css' => []];
    }
}