Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/upgrade livewire 3 #30

Merged
merged 3 commits into from
Sep 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions src/Livewire/WithInlineInput.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,10 @@ public function setEditMode()
{
$this->editMode = true;

$this->dispatchBrowserEvent('edit-mode', [
'id' => $this->model()->getKey(),
]);
$this->dispatch(
'edit-mode',
id: $this->model()->getKey(),
);
}

public function submitInlineData()
Expand Down
18 changes: 10 additions & 8 deletions src/Livewire/WithMap.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,20 @@ trait WithMap
{
public function addPlaces(string $mapId, array $places)
{
$this->dispatchBrowserEvent($mapId, [
'type' => 'loadPlaces',
'places' => $this->formatPlaces($places),
]);
$this->dispatch(
$mapId,
type:'loadPlaces',
places:$this->formatPlaces($places),
);
}

public function flyTo(string $mapId, string $lng, string $lat)
{
$this->dispatchBrowserEvent($mapId, [
'type' => 'fly',
'coordinate' => [$lng, $lat],
]);
$this->dispatch(
$mapId,
type:'fly',
coordinate:[$lng, $lat],
);
}

public function formatPlaces(array $places): array
Expand Down
4 changes: 2 additions & 2 deletions src/Livewire/WithModal.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ trait WithModal
{
public function closeModal(string $modalId)
{
$this->dispatchBrowserEvent($modalId, ['type' => 'close']);
$this->dispatch($modalId, type: 'close');
}

public function openModal(string $modalId)
{
$this->dispatchBrowserEvent($modalId, ['type' => 'open']);
$this->dispatch($modalId, type: 'open');
}
}
33 changes: 18 additions & 15 deletions src/Livewire/WithNotification.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,29 +6,32 @@ trait WithNotification
{
public function success(string $message, ?array $action = null)
{
$this->dispatchBrowserEvent('notify', [
'message' => $message,
'type' => 'success',
'action' => $action,
]);
$this->dispatch(
'notify',
message: $message,
type:'success',
action:$action,
);
}

public function error(string $message, ?array $action = null)
{
$this->dispatchBrowserEvent('notify', [
'message' => $message,
'type' => 'error',
'action' => $action,
]);
$this->dispatch(
'notify',
message: $message,
type:'error',
action:$action,
);
}

public function info(string $message, ?array $action = null)
{
$this->dispatchBrowserEvent('notify', [
'message' => $message,
'type' => 'info',
'action' => $action,
]);
$this->dispatch(
'notify',
message: $message,
type:'info',
action:$action,
);
}

public function alertInvalidInput(?string $message = null)
Expand Down
4 changes: 2 additions & 2 deletions src/Livewire/WithStepWizard.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,12 @@ public function next(): void
{
$livewireComponentId = $this->submit();

$this->dispatchBrowserEvent('next-step-emitted', $livewireComponentId);
$this->dispatch('next-step-emitted', $livewireComponentId);
}

public function back(): void
{
$this->dispatchBrowserEvent('previous-step-emitted');
$this->dispatch('previous-step-emitted');
}

protected function fillSessionData()
Expand Down
11 changes: 6 additions & 5 deletions src/Livewire/WithStripe.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,14 @@ public function updateStripePaymentMethod(string $event, string $message)
$this->emitSelf('stripePaymentMethodUpdated', $billable);

// Let Alpinejs now Stripe payment method updated.
$this->dispatchBrowserEvent('stripe-payment-method-updated');
$this->dispatch('stripe-payment-method-updated');

// Notify payment method was updated.
$this->dispatchBrowserEvent(empty($event) ? 'notify' : $event, [
'type' => 'success',
'message' => empty($message) ? 'Your payment method was updated!' : $message,
]);
$this->dispatch(
empty($event) ? 'notify' : $event,
type: 'success',
message: empty($message) ? 'Your payment method was updated!' : $message,
);

return [
'card_brand' => $billable->card_brand,
Expand Down