1: <?php
2:
3: declare(strict_types=1);
4:
5: namespace Atk4\Ui\Panel;
6:
7: use Atk4\Ui\Callback;
8: use Atk4\Ui\View;
9:
10: /**
11: * Slide Panel Content.
12: *
13: * @method Right getOwner()
14: */
15: class Content extends View implements LoadableContent
16: {
17: public $defaultTemplate = 'panel/content.html';
18:
19: /** @var Callback */
20: public $cb;
21:
22: #[\Override]
23: protected function init(): void
24: {
25: parent::init();
26:
27: $this->addClass('atk-panel-content');
28: $this->setCb(new Callback());
29: }
30:
31: #[\Override]
32: public function getCallbackUrl(): string
33: {
34: return $this->cb->getJsUrl();
35: }
36:
37: #[\Override]
38: public function setCb(Callback $cb): void
39: {
40: $this->cb = $this->add($cb); // @phpstan-ignore-line
41: }
42:
43: /**
44: * Will load content into callback.
45: *
46: * @param \Closure($this): void $fx
47: */
48: #[\Override]
49: public function onLoad(\Closure $fx): void
50: {
51: $this->cb->set(function () use ($fx) {
52: $fx($this);
53: $this->cb->terminateJson($this);
54: });
55: }
56:
57: /**
58: * Return an array of CSS selector where content will be
59: * cleared on reload.
60: */
61: public function getClearSelector(): array
62: {
63: return ['.atk-panel-content'];
64: }
65: }
66: