Skip to content

Commit 9ba03ad

Browse files
committed
fix for the helper
1 parent 4794992 commit 9ba03ad

File tree

3 files changed

+7
-9
lines changed

3 files changed

+7
-9
lines changed

README.md

+5-4
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,13 @@ $result = explorer(
1818
[2, 'Jane Doe', 'jane.doe@example.com'],
1919
[3, 'Jan Kowalski', 'kowalski@example.com'],
2020
],
21-
);
21+
)
22+
->prompt();
2223
```
2324

2425
### Advanced file explorer example usage:
2526
```php
26-
use Knobik\Prompts\ExplorerPrompt;
27+
use function Knobik\Prompts\explorer;
2728

2829
function getDirectoryFiles(string $path): array
2930
{
@@ -51,15 +52,15 @@ function getDirectoryFiles(string $path): array
5152

5253
$path = '/var/www/html';
5354
while (true) {
54-
$path = (new ExplorerPrompt(
55+
$path = explorer(
5556
title: $path, //fn(ExplorerPrompt $prompt) => $prompt->highlighted,
5657
header: [
5758
'File name',
5859
'Size in bytes',
5960
'Permissions'
6061
],
6162
items: $this->getDirectoryFiles($path),
62-
))
63+
)
6364
->setColumnOptions(
6465
column: 2,
6566
width: 20, // number of characters, null or omit to keep it in auto mode

src/ExplorerPrompt.php

+1-4
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,9 @@ public function __construct(
2222
callable|string|null $title,
2323
public ?array $header = null,
2424
public array $items = [],
25-
public ?int $scroll = null,
25+
public int $scroll = 20,
2626
) {
2727
$this->title = $title ?? '';
28-
if ($this->scroll === null) {
29-
$this->fullscreen();
30-
}
3128

3229
static::$themes['default'][static::class] = ExplorerPromptRenderer::class;
3330

src/helpers.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@
33

44
function explorer(callable|string|null $title, ?array $header = null, array $items = [], ?int $scroll = null): mixed
55
{
6-
return (new ExplorerPrompt(...func_get_args()))->prompt();
6+
return new ExplorerPrompt(...func_get_args());
77
}

0 commit comments

Comments
 (0)