66use Illuminate \Support \Str ;
77use Illuminate \View \ComponentAttributeBag ;
88use PowerComponents \LivewirePowerGrid \Button ;
9+ use PowerComponents \LivewirePowerGrid \Providers \SupportLivewireVersions ;
910
1011trait HasActions
1112{
@@ -25,9 +26,13 @@ public function prepareActionsResources(): ?string
2526 $ records = (string ) $ closure ();
2627 }
2728
28- $ this ->js (<<<JS
29- this.pgResourceIcons = $ records
30- JS );
29+ if (SupportLivewireVersions::isV3 ()) {
30+ $ this ->js (<<<JS
31+ this.pgResourceIcons = $ records
32+ JS );
33+ } else {
34+ $ this ->js ('pgResourceIcons ' , $ records );
35+ }
3136
3237 return $ records ;
3338 }
@@ -68,9 +73,15 @@ public function dispatchActionsToJS(array $actionsHtml): void
6873
6974 $ actionsHtml = json_encode ($ actionsHtml );
7075
71- $ this ->js (<<<JS
72- this[`pgActions_ \${ \$wire.id}`] = $ actionsHtml
73- JS );
76+ if (SupportLivewireVersions::isV3 ()) {
77+ $ this ->js (<<<JS
78+ this[`pgActions_ \${ \$wire.id}`] = $ actionsHtml
79+ JS );
80+
81+ return ;
82+ }
83+
84+ $ this ->js ('pgActions ' , $ actionsHtml );
7485 }
7586
7687 public function storeActionsHeaderInJSWindow (): void
@@ -93,9 +104,15 @@ public function storeActionsHeaderInJSWindow(): void
93104
94105 $ actionsHtml = json_encode ($ actionsHtml );
95106
96- $ this ->js (<<<JS
97- this[`pgActionsHeader_ \${ \$wire.id}`] = $ actionsHtml
98- JS );
107+ if (SupportLivewireVersions::isV3 ()) {
108+ $ this ->js (<<<JS
109+ this[`pgActionsHeader_ \${ \$wire.id}`] = $ actionsHtml
110+ JS );
111+
112+ return ;
113+ }
114+
115+ $ this ->js ('pgActionsHeader ' , $ actionsHtml );
99116 }
100117
101118 public function prepareActionRulesForRows (mixed $ row , ?object $ loop = null ): array
0 commit comments