11<?php
2-
32namespace Ajax \semantic \html \elements ;
43
54use Ajax \semantic \html \base \HtmlSemDoubleElement ;
65use Ajax \semantic \html \base \constants \State ;
7- use Ajax \semantic \html \base \constants \Direction ;
86use Ajax \semantic \html \base \constants \Variation ;
97use Ajax \semantic \html \base \traits \IconTrait ;
10- use Ajax \semantic \html \modules \HtmlDropdown ;
8+ use Ajax \semantic \html \collections \form \traits \TextFieldsTrait ;
9+ use Ajax \semantic \html \collections \form \traits \FieldTrait ;
1110
1211class HtmlInput extends HtmlSemDoubleElement {
13- use IconTrait;
12+ use IconTrait,TextFieldsTrait,FieldTrait ;
1413
1514 public function __construct ($ identifier , $ type ="text " , $ value ="" , $ placeholder ="" ) {
1615 parent ::__construct ("div- " . $ identifier , "div " , "ui input " );
@@ -19,58 +18,10 @@ public function __construct($identifier, $type="text", $value="", $placeholder="
1918 $ this ->_variations =[ Variation::TRANSPARENT ];
2019 }
2120
22- public function setFocus () {
23- $ this ->addToProperty ("class " , State::FOCUS );
24- }
25-
26- public function addLoading () {
27- if ($ this ->_hasIcon === false ) {
28- throw new \Exception ("Input must have an icon for showing a loader, use addIcon before " );
29- }
30- return $ this ->addToProperty ("class " , State::LOADING );
31- }
32-
33- public function labeled ($ label , $ direction =Direction::LEFT , $ icon =NULL ) {
34- $ labelO =$ this ->addLabel ($ label ,$ direction ===Direction::LEFT ,$ icon );
35- $ this ->addToProperty ("class " , $ direction . " labeled " );
36- return $ labelO ;
37- }
38-
39- public function labeledToCorner ($ icon , $ direction =Direction::LEFT ) {
40- return $ this ->labeled ("" , $ direction . " corner " , $ icon )->toCorner ($ direction );
41- }
42-
43- public function addAction ($ action , $ direction =Direction::RIGHT , $ icon =NULL , $ labeled =false ) {
44- $ actionO =$ action ;
45- if (\is_object ($ action ) === false ) {
46- $ actionO =new HtmlButton ("action- " . $ this ->identifier , $ action );
47- if (isset ($ icon ))
48- $ actionO ->addIcon ($ icon , true , $ labeled );
49- }
50- $ this ->addToProperty ("class " , $ direction . " action " );
51- $ this ->addContent ($ actionO , \strstr ($ direction , Direction::LEFT ) !== false );
52- return $ actionO ;
53- }
54-
55- public function addDropdown ($ label ="" , $ items =array (),$ direction =Direction::RIGHT ){
56- $ labelO =new HtmlDropdown ("dd- " .$ this ->identifier ,$ label ,$ items );
57- $ labelO ->asSelect ("select- " .$ this ->identifier ,false ,true );
58- return $ this ->labeled ($ labelO ,$ direction );
59- }
60-
6121 public function getField () {
6222 return $ this ->content ["field " ];
6323 }
6424
65- public function setPlaceholder ($ value ) {
66- $ this ->getField ()->setPlaceholder ($ value );
67- return $ this ;
68- }
69-
70- public function setTransparent () {
71- return $ this ->addToProperty ("class " , "transparent " );
72- }
73-
7425 public static function outline ($ identifier , $ icon , $ value ="" , $ placeholder ="" ) {
7526 $ result =new HtmlInput ($ identifier , "text " , $ value , $ placeholder );
7627 $ result ->addToProperty ("class " , "transparent " );
0 commit comments