44
55use Filament \Forms \Components \Concerns \HasLabel ;
66use Filament \Forms \Components \Grid ;
7+ use Closure ;
8+ use Filament \Forms \Components \Field ;
79
810class InputGroup extends Grid
911{
1012 use HasLabel;
11-
1213 protected string $ view = 'filament-custom-forms::components.grid ' ;
1314
1415 public static function make (array | int | string | null $ columns = 2 ): static
@@ -18,7 +19,62 @@ public static function make(array | int | string | null $columns = 2): static
1819 $ static ->extraAttributes (['class ' => 'filament-input-group gap-y-2 grid ' ]);
1920
2021 $ static ->columnSpan (1 );
21-
22+
2223 return $ static ;
2324 }
25+
26+
27+ public function schema (array | Closure $ components ): static
28+ {
29+ $ this ->childComponents ($ components );
30+
31+ return $ this ;
32+ }
33+
34+ public function showChildLabel (bool $ condition = true )
35+ {
36+
37+ $ this ->isHideChildLabel = !$ condition ;
38+
39+ return $ this ;
40+ }
41+
42+ /**
43+ * @return array<Component>
44+ */
45+ public function getChildComponents (): array
46+ {
47+
48+ $ components = $ this ->childComponents ;
49+
50+ if ($ this ->isHideChildLabel ) {
51+ $ components = collect ($ components )->map (function (Field $ component ) {
52+ if (method_exists ($ component , 'placeholder ' )) {
53+ $ component = $ component ->placeholder ($ component ->getLabel ());
54+ }
55+ return $ component ->hiddenLabel ();
56+ })->toArray ();
57+ }
58+
59+ return $ this ->evaluate ($ components );
60+ }
61+ // /**
62+ // * @return array<Component>
63+ // */
64+ // public function getChildComponents(): array
65+ // {
66+ // $components = $this->getChildComponents();
67+
68+ // if ($this->isHideChildLabel) {
69+ // $components = collect($components)->map(function (Field $component) {
70+ // return $component->hiddenLabel();
71+ // })->toArray();
72+ // }
73+
74+ // return $this->evaluate($components);
75+ // }
76+
77+ protected function setUp (): void
78+ {
79+ }
2480}
0 commit comments