-
Notifications
You must be signed in to change notification settings - Fork 76
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
I added compatibility with Alpine 3, by default it is still loading the v2.29 of Alpine but this customizable to import Alpine manually. - I moved the Pickaday and moment dependencias to import them by a CDN since with alpine 3 the `init` method is called automatically when the component is rendered
- Loading branch information
1 parent
a1c5284
commit ede4986
Showing
7 changed files
with
40 additions
and
56 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,41 +1,17 @@ | ||
import feather from 'feather-icons' | ||
import Pikaday from 'pikaday' | ||
|
||
try { | ||
const setUpUiLibraries = () => { | ||
feather.replace() | ||
} | ||
|
||
const datePicker = (id) => { | ||
return { | ||
picker: null, | ||
id: null, | ||
dispatch: null, | ||
init (id, dispatch) { | ||
this.id = id | ||
this.dispatch = dispatch | ||
this.picker = new Pikaday({ | ||
field: this.$refs[this.id], | ||
format: "YYYY-MM-DD", | ||
onSelect: this.onSelect.bind(this) | ||
}) | ||
}, | ||
onSelect (date) { | ||
this.dispatch("input", this.picker.toString("YYYY-MM-DD")); | ||
} | ||
} | ||
} | ||
|
||
// require('bootstrap') | ||
document.addEventListener("DOMContentLoaded", () => { | ||
setUpUiLibraries() | ||
|
||
Livewire.hook('message.processed', () => { | ||
setUpUiLibraries() | ||
}) | ||
}) | ||
|
||
window.laravelViews = { | ||
datePicker | ||
} | ||
} catch (e) {} | ||
} catch (error) { | ||
throw new Error(error) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,5 +23,5 @@ | |
</button> | ||
</div> | ||
@endif | ||
</x-lv-drop-down> | ||
</x-lv-drop-down> | ||
@endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -30,7 +30,8 @@ public function components() | |
'form.input-group' => 'form.input-group', | ||
'icon' => 'icon', | ||
'modal' => 'modal', | ||
'form.checkbox' => 'checkbox' | ||
'form.checkbox' => 'checkbox', | ||
'form.input' => 'input', | ||
]; | ||
} | ||
|
||
|
@@ -80,7 +81,9 @@ public function js($options = '') | |
$assets = [ | ||
'livewire' => Livewire::scripts(), | ||
'alpine' => '<script src="https://cdn.jsdelivr.net/gh/alpinejs/[email protected]/dist/alpine.min.js" defer></script>', | ||
'laravel-views' => '<script src="' . asset('/vendor/laravel-views.js') . '" type="text/javascript" defer></script>' | ||
'laravel-views' => '<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.29.1/moment.min.js" integrity="sha512-qTXRIMyZIFb8iQcfjXWCO8+M5Tbc38Qi5WzdPOYZHIlZpzBHG3L3by84BBBOiRGiEb7KKtAOAs5qYdUiZiQNNQ==" crossorigin="anonymous" referrerpolicy="no-referrer"></script> | ||
<script src="https://cdn.jsdelivr.net/npm/pikaday/pikaday.js"></script> | ||
<script src="' . asset('/vendor/laravel-views.js') . '" type="text/javascript" defer></script>' | ||
]; | ||
|
||
return $this->getCustomizedLinks($assets, $options); | ||
|
@@ -116,6 +119,9 @@ private function getCustomizedLinks($assets = [], $options = '') | |
$links = $assets; | ||
} | ||
|
||
return implode("\n", $links); | ||
$linksStr = implode(PHP_EOL, $links); | ||
return <<<HTML | ||
{$linksStr} | ||
HTML; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,8 +26,10 @@ public function testRenderJsLinks() | |
$js = LaravelViews::js(); | ||
$this->assertEquals( | ||
$js, | ||
\Livewire\Livewire::scripts()."\n". | ||
'<script src="https://cdn.jsdelivr.net/gh/alpinejs/[email protected]/dist/alpine.min.js" defer></script>'."\n". | ||
\Livewire\Livewire::scripts().PHP_EOL. | ||
'<script src="https://cdn.jsdelivr.net/gh/alpinejs/[email protected]/dist/alpine.min.js" defer></script>'.PHP_EOL. | ||
'<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.29.1/moment.min.js" integrity="sha512-qTXRIMyZIFb8iQcfjXWCO8+M5Tbc38Qi5WzdPOYZHIlZpzBHG3L3by84BBBOiRGiEb7KKtAOAs5qYdUiZiQNNQ==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>'.PHP_EOL. | ||
'<script src="https://cdn.jsdelivr.net/npm/pikaday/pikaday.js"></script>'.PHP_EOL. | ||
'<script src="' . asset('/vendor/laravel-views.js') . '" type="text/javascript" defer></script>' | ||
); | ||
} | ||
|
@@ -49,14 +51,18 @@ public function testRenderCustomizedJsLinks() | |
|
||
$this->assertEquals( | ||
$js, | ||
'<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.29.1/moment.min.js" integrity="sha512-qTXRIMyZIFb8iQcfjXWCO8+M5Tbc38Qi5WzdPOYZHIlZpzBHG3L3by84BBBOiRGiEb7KKtAOAs5qYdUiZiQNNQ==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>'.PHP_EOL. | ||
'<script src="https://cdn.jsdelivr.net/npm/pikaday/pikaday.js"></script>'.PHP_EOL. | ||
'<script src="' . asset('/vendor/laravel-views.js') . '" type="text/javascript" defer></script>' | ||
); | ||
|
||
$js = LaravelViews::js('laravel-views,alpine'); | ||
|
||
$this->assertEquals( | ||
$js, | ||
'<script src="https://cdn.jsdelivr.net/gh/alpinejs/[email protected]/dist/alpine.min.js" defer></script>'."\n". | ||
'<script src="https://cdn.jsdelivr.net/gh/alpinejs/[email protected]/dist/alpine.min.js" defer></script>'.PHP_EOL. | ||
'<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.29.1/moment.min.js" integrity="sha512-qTXRIMyZIFb8iQcfjXWCO8+M5Tbc38Qi5WzdPOYZHIlZpzBHG3L3by84BBBOiRGiEb7KKtAOAs5qYdUiZiQNNQ==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>'.PHP_EOL. | ||
'<script src="https://cdn.jsdelivr.net/npm/pikaday/pikaday.js"></script>'.PHP_EOL. | ||
'<script src="' . asset('/vendor/laravel-views.js') . '" type="text/javascript" defer></script>' | ||
); | ||
} | ||
|