ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
Dropdown.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22
25use ILIAS\UI\Implementation\Component\ComponentHelper;
31
35abstract class Dropdown implements C\Dropdown\Dropdown
36{
37 use ComponentHelper;
39 use Triggerer;
40
41 protected ?string $label = null;
42 protected ?string $aria_label = null;
43
47 protected array $items;
48
53 public function __construct(array $items)
54 {
55 $this->items = $items;
56 }
57
61 public function getLabel(): ?string
62 {
63 return $this->label;
64 }
65
69 public function getAriaLabel(): ?string
70 {
71 return $this->aria_label;
72 }
73
77 public function getItems(): array
78 {
79 return $this->items;
80 }
81
85 public function withLabel(string $label): C\Dropdown\Dropdown
86 {
87 $clone = clone $this;
88 $clone->label = $label;
89 return $clone;
90 }
91
95 public function withAriaLabel(string $label): C\Dropdown\Dropdown
96 {
97 $clone = clone $this;
98 $clone->aria_label = $label;
99 return $clone;
100 }
101
105 public function withOnClick(Signal $signal): C\Clickable
106 {
107 return $this->withTriggeredSignal($signal, 'click');
108 }
109
113 public function appendOnClick(Signal $signal): C\Clickable
114 {
115 return $this->appendTriggeredSignal($signal, 'click');
116 }
117
121 public function withOnHover(Signal $signal): C\Hoverable
122 {
123 return $this->withTriggeredSignal($signal, 'hover');
124 }
125
129 public function appendOnHover(Signal $signal): C\Hoverable
130 {
131 return $this->appendTriggeredSignal($signal, 'hover');
132 }
133}
This implements commonalities between different types of Dropdowns.
Definition: Dropdown.php:36
__construct(array $items)
Dropdown constructor.
Definition: Dropdown.php:53
appendTriggeredSignal(C\Signal $signal, string $event)
Append a triggered signal to other signals of the same event.
Definition: Triggerer.php:47
withTriggeredSignal(C\Signal $signal, string $event)
Add a triggered signal, replacing any other signals registered on the same event.
Definition: Triggerer.php:62
trait JavaScriptBindable
Trait for components implementing JavaScriptBindable providing standard implementation.