Skip to content

Commit

Permalink
Merge pull request #8 from sadegh19b/rtl
Browse files Browse the repository at this point in the history
Add rtl option for the inputs container
  • Loading branch information
hasan-ahani authored Oct 10, 2024
2 parents f34dccc + 4bc4424 commit 0e6237e
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
4 changes: 3 additions & 1 deletion resources/views/components/otp-input.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
$isAutofocused = $isAutofocused();
$inputType = $getType();
$autocomplete = $getAutocomplete();
$isRtl = $getInputsContainerDirection();
@endphp

<x-dynamic-component
Expand All @@ -25,6 +26,7 @@
:label-sr-only="$isLabelHidden()"
:helper-text="$getHelperText()"
:hint="$getHint()"
:hint-actions="$getHintActions()"
:hint-icon="$getHintIcon()"
:required="$isRequired()"
:state-path="$getStatePath()"
Expand Down Expand Up @@ -80,7 +82,7 @@
e.preventDefault();
},
}">
<div class="flex justify-between gap-6 fi-otp-input-container">
<div class="flex justify-between gap-6 fi-otp-input-container" dir="{{ $isRtl ? 'rtl' : 'ltr' }}">

@foreach(range(1, $numberInput) as $column)

Expand Down
15 changes: 14 additions & 1 deletion src/Components/OtpInput.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ class OtpInput extends Field implements Contracts\CanBeLengthConstrained, Contra

protected int | \Closure | null $numberInput = 4;

protected bool | \Closure | null $isRtl = false;

protected string | \Closure | null $type = 'number';


public function numberInput(int | \Closure $number = 4):static
{
$this->numberInput = $number;
Expand All @@ -42,12 +42,14 @@ public function getNumberInput():int
public function password(): static
{
$this->type = 'password';

return $this;
}

public function text(): static
{
$this->type = 'text';

return $this;
}

Expand All @@ -56,4 +58,15 @@ public function getType(): string
return $this->evaluate($this->type);
}

public function rtl(bool|\Closure $condition = false): static
{
$this->isRtl = $condition;

return $this;
}

public function getInputsContainerDirection(): string
{
return $this->evaluate($this->isRtl);
}
}

0 comments on commit 0e6237e

Please sign in to comment.