'ui-input', ]; public array $options = [ 'tag-type' => "single", ]; protected mixed $value; protected string $name; public function __construct( public string $tag = "input", ) {} public function parse(\Picea\Compiler\Context &$context, ?string $arguments, string $token, array $options = []) : string { return "buildHtml($arguments) ?>"; } public function exportFunctions(): array { if ( null === $type = $this->attributes['type'] ?? null ) { return []; } $key = str_replace('-', '_', 'ui_'. ( $this->attributes['type'] ?? 'text' )); return [ $key => fn(string $name, mixed $value = null, array $attributes = [], array $options = []) : string => $this->buildHtml($name, $value, $attributes, $options), ]; } public function buildHtml(string $name, mixed $value = null, array $attributes = [], array $options = []) : string { $this->name = $name; if (null !== $this->value = $value) { $this->setValue($value); } if ($options) { $this->options += $options; } if ($attributes['class'] ?? false) { $attributes['class'] = implode(" ", array_merge((array) $attributes['class'], (array) $this->attributes['class'])); unset($this->attributes['class']); } $this->attributes([ 'name' => $name ] + $attributes + $this->attributes + $this->objectAttribute()); return $this->render(); } protected function setValue($value) : void { $this->attributes['value'] = $value; } protected function objectAttribute() : array { return []; } }