1: <?php
2:
3: declare(strict_types=1);
4:
5: namespace Atk4\Ui\Js;
6:
7: use Atk4\Core\WarnDynamicPropertyTrait;
8:
9: /**
10: * Shortcut handler for calling method of the atk JS vue service.
11: */
12: class JsVueService
13: {
14: use WarnDynamicPropertyTrait;
15:
16: public function createServiceChain(): JsChain
17: {
18: return new JsChain('atk.vueService');
19: }
20:
21: /**
22: * Create a new Vue instance using a component managed by ATK.
23: *
24: * This output js: atk.vueService.createAtkVue('id', 'component', {});
25: */
26: public function createAtkVue(string $id, string $componentName, array $data = []): JsChain
27: {
28: return $this->createServiceChain()->createAtkVue($id, $componentName, $data);
29: }
30:
31: /**
32: * Create a new Vue instance using an external component.
33: * External component should be load via js file and define properly.
34: *
35: * This output js: atk.vueService.createVue('id', 'component', {}, {});
36: */
37: public function createVue(string $id, string $componentName, JsExpressionable $component, array $data = []): JsChain
38: {
39: return $this->createServiceChain()->createVue($id, $componentName, $component, $data);
40: }
41: }
42: