Skip to content

Commit cea7011

Browse files
committed
Use renderer for SelectableItem
1 parent 5362114 commit cea7011

File tree

1 file changed

+1
-31
lines changed

1 file changed

+1
-31
lines changed

src/MenuItem/SelectableItem.php

Lines changed: 1 addition & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -57,37 +57,7 @@ public function __construct(
5757
*/
5858
public function getRows(MenuStyle $style, bool $selected = false) : array
5959
{
60-
$marker = sprintf("%s", $this->style->getMarker($this, $selected));
61-
62-
$length = $this->style->getDisplaysExtra()
63-
? $style->getContentWidth() - (mb_strlen($this->style->getItemExtra()) + 2)
64-
: $style->getContentWidth();
65-
66-
$rows = explode(
67-
"\n",
68-
StringUtil::wordwrap(
69-
sprintf('%s%s', $marker, $this->text),
70-
$length,
71-
sprintf("\n%s", str_repeat(' ', mb_strlen($marker)))
72-
)
73-
);
74-
75-
return mapWithKeys($rows, function (int $key, string $row) use ($style, $length) {
76-
$text = $this->disabled ? $style->getDisabledItemText($row) : $row;
77-
78-
if ($key === 0) {
79-
return $this->showItemExtra
80-
? sprintf(
81-
'%s%s %s',
82-
$text,
83-
str_repeat(' ', $length - mb_strlen($row)),
84-
$this->style->getItemExtra()
85-
)
86-
: $text;
87-
}
88-
89-
return $text;
90-
});
60+
return (new SelectableItemRenderer())->render($style, $this, $selected, $this->disabled);
9161
}
9262

9363
/**

0 commit comments

Comments
 (0)