Skip to content

Commit 0e6237e

Browse files
authored
Merge pull request #8 from sadegh19b/rtl
Add rtl option for the inputs container
2 parents f34dccc + 4bc4424 commit 0e6237e

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

resources/views/components/otp-input.blade.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
$isAutofocused = $isAutofocused();
1717
$inputType = $getType();
1818
$autocomplete = $getAutocomplete();
19+
$isRtl = $getInputsContainerDirection();
1920
@endphp
2021

2122
<x-dynamic-component
@@ -25,6 +26,7 @@
2526
:label-sr-only="$isLabelHidden()"
2627
:helper-text="$getHelperText()"
2728
:hint="$getHint()"
29+
:hint-actions="$getHintActions()"
2830
:hint-icon="$getHintIcon()"
2931
:required="$isRequired()"
3032
:state-path="$getStatePath()"
@@ -80,7 +82,7 @@
8082
e.preventDefault();
8183
},
8284
}">
83-
<div class="flex justify-between gap-6 fi-otp-input-container">
85+
<div class="flex justify-between gap-6 fi-otp-input-container" dir="{{ $isRtl ? 'rtl' : 'ltr' }}">
8486

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

src/Components/OtpInput.php

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,10 @@ class OtpInput extends Field implements Contracts\CanBeLengthConstrained, Contra
2323

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

26+
protected bool | \Closure | null $isRtl = false;
2627

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

29-
3030
public function numberInput(int | \Closure $number = 4):static
3131
{
3232
$this->numberInput = $number;
@@ -42,12 +42,14 @@ public function getNumberInput():int
4242
public function password(): static
4343
{
4444
$this->type = 'password';
45+
4546
return $this;
4647
}
4748

4849
public function text(): static
4950
{
5051
$this->type = 'text';
52+
5153
return $this;
5254
}
5355

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

61+
public function rtl(bool|\Closure $condition = false): static
62+
{
63+
$this->isRtl = $condition;
64+
65+
return $this;
66+
}
67+
68+
public function getInputsContainerDirection(): string
69+
{
70+
return $this->evaluate($this->isRtl);
71+
}
5972
}

0 commit comments

Comments
 (0)