88use Tempest \Validation \Rule ;
99use Tempest \View \Elements \ViewComponentElement ;
1010use Tempest \View \ViewComponent ;
11+ use Tempest \View \ViewComponentMetadata ;
1112use Tempest \View \ViewComponentParameter ;
1213use Tempest \View \ViewComponentParameters ;
1314
14- final readonly class Input implements ViewComponent
15+ final readonly class Input implements ViewComponent, ViewComponentMetadata
1516{
1617 public function __construct (
1718 private Session $ session ,
@@ -36,6 +37,31 @@ public static function getParameters(): ViewComponentParameters
3637 new ViewComponentParameter (
3738 name: 'type ' ,
3839 description: 'The type of the input field (e.g., text, email, password, textarea). ' ,
40+ possibleValues: [
41+ 'button ' ,
42+ 'checkbox ' ,
43+ 'color ' ,
44+ 'date ' ,
45+ 'datetime-local ' ,
46+ 'email ' ,
47+ 'file ' ,
48+ 'hidden ' ,
49+ 'image ' ,
50+ 'month ' ,
51+ 'number ' ,
52+ 'password ' ,
53+ 'radio ' ,
54+ 'range ' ,
55+ 'reset ' ,
56+ 'search ' ,
57+ 'submit ' ,
58+ 'tel ' ,
59+ 'text ' ,
60+ 'time ' ,
61+ 'url ' ,
62+ 'week ' ,
63+ 'textarea ' , // Not an HTML input type, but allowed for textarea elements
64+ ],
3965 ),
4066 new ViewComponentParameter (
4167 name: 'default ' ,
@@ -44,6 +70,26 @@ public static function getParameters(): ViewComponentParameters
4470 );
4571 }
4672
73+ public static function getDescription (): string
74+ {
75+ return 'A generic input component for forms. ' ;
76+ }
77+
78+ public static function hasSlots (): bool
79+ {
80+ return false ;
81+ }
82+
83+ public static function getNamedSlots (): array
84+ {
85+ return [];
86+ }
87+
88+ public static function getDeprecationMessage (): ?string
89+ {
90+ return null ;
91+ }
92+
4793 public function compile (ViewComponentElement $ element ): string
4894 {
4995 $ name = $ element ->getAttribute ('name ' );
0 commit comments