Files
kulakpos_web/vendor/laravel/prompts/src/ConfirmPrompt.php
eko54r b5e3a778ce
All checks were successful
Build, Push and Deploy / build-and-push (push) Successful in 3m3s
Gitea Actions Demo / Explore-Gitea-Actions (push) Successful in 16s
Build, Push and Deploy / deploy-staging (push) Successful in 32s
Build, Push and Deploy / deploy-production (push) Has been skipped
Build, Push and Deploy / cleanup (push) Successful in 1s
allow vendord
2026-03-30 14:54:57 +07:00

54 lines
1.4 KiB
PHP

<?php
namespace Laravel\Prompts;
use Closure;
class ConfirmPrompt extends Prompt
{
/**
* Whether the prompt has been confirmed.
*/
public bool $confirmed;
/**
* Create a new ConfirmPrompt instance.
*/
public function __construct(
public string $label,
public bool $default = true,
public string $yes = 'Yes',
public string $no = 'No',
public bool|string $required = false,
public mixed $validate = null,
public string $hint = '',
public ?Closure $transform = null,
) {
$this->confirmed = $default;
$this->on('key', fn ($key) => match ($key) {
'y' => $this->confirmed = true,
'n' => $this->confirmed = false,
Key::TAB, Key::UP, Key::UP_ARROW, Key::DOWN, Key::DOWN_ARROW, Key::LEFT, Key::LEFT_ARROW, Key::RIGHT, Key::RIGHT_ARROW, Key::CTRL_P, Key::CTRL_F, Key::CTRL_N, Key::CTRL_B, 'h', 'j', 'k', 'l' => $this->confirmed = ! $this->confirmed,
Key::ENTER => $this->submit(),
default => null,
});
}
/**
* Get the value of the prompt.
*/
public function value(): bool
{
return $this->confirmed;
}
/**
* Get the label of the selected option.
*/
public function label(): string
{
return $this->confirmed ? $this->yes : $this->no;
}
}