Skip to content

Commit d4356d8

Browse files
Fix all data attributes for accept true value when id attribute is used. (#8)
1 parent 457fbc8 commit d4356d8

19 files changed

+133
-38
lines changed

CHANGELOG.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
# Change Log
22

3-
## 0.1.3 Under development
3+
## 0.1.3 March 16, 2024
4+
5+
- Bug #8: Fix all `data` attributes for accept `true` value when `id` attribute is used (@terabytesoftw)
46

57
## 0.1.2 March 14, 2024
68

src/Data/HasDataBsAutoClose.php

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,25 @@
99
*/
1010
trait HasDataBsAutoClose
1111
{
12+
protected bool|string $dataBsAutoClose = false;
13+
1214
/**
13-
* Set the `HTML` data-bs-auto-close attribute for the toggle.
15+
* Set the `HTML` `data-bs-auto-close` attribute for the toggle.
1416
*
15-
* @param string $value The data-bs-auto-close attribute value.
17+
* @param bool|string $value The `data-bs-auto-close` attribute value. If `true`, the value of the `id` attribute
18+
* will be used.
1619
*
1720
* @return static A new instance of the current class with the specified toggle attributes.
1821
*/
19-
public function dataBsAutoClose(string $value): static
22+
public function dataBsAutoClose(bool|string $value = true): static
2023
{
21-
return $this->dataAttributes([DataAttributeValues::BS_AUTO_CLOSE => $value]);
24+
if (is_string($value)) {
25+
return $this->dataAttributes([DataAttributeValues::BS_AUTO_CLOSE => $value]);
26+
}
27+
28+
$new = clone $this;
29+
$new->dataBsAutoClose = $value;
30+
31+
return $new;
2232
}
2333
}

src/Data/HasDataBsDismiss.php

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,25 @@
99
*/
1010
trait HasDataBsDismiss
1111
{
12+
protected bool|string $dataBsDismiss = false;
13+
1214
/**
13-
* Set the `HTML` data-bs-dismiss attribute for the toggle.
15+
* Set the `HTML` `data-bs-dismiss` attribute for the toggle.
1416
*
15-
* @param string $value The data-bs-dismiss attribute value.
17+
* @param bool|string $value The `data-bs-dismiss` attribute value. If `true`, the value of the `id` attribute will
18+
* be used.
1619
*
1720
* @return static A new instance of the current class with the specified toggle attributes.
1821
*/
19-
public function dataBsDismiss(string $value): static
22+
public function dataBsDismiss(bool|string $value = true): static
2023
{
21-
return $this->dataAttributes([DataAttributeValues::BS_DISMISS => $value]);
24+
if (is_string($value)) {
25+
return $this->dataAttributes([DataAttributeValues::BS_DISMISS => $value]);
26+
}
27+
28+
$new = clone $this;
29+
$new->dataBsDismiss = $value;
30+
31+
return $new;
2232
}
2333
}

src/Data/HasDataBsTarget.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@ trait HasDataBsTarget
1212
protected bool|string $dataBsTarget = false;
1313

1414
/**
15-
* Set the `HTML` data-bs-target attribute for the toggle.
15+
* Set the `HTML` `data-bs-target` attribute for the toggle.
1616
*
17-
* @param bool|string $value The data-bs-target attribute value. If true, the value of the id attribute will be
18-
* used.
17+
* @param bool|string $value The `data-bs-target` attribute value. If `true`, the value of the `id` attribute will
18+
* be used.
1919
*
2020
* @return static A new instance of the current class with the specified toggle attributes.
2121
*/

src/Data/HasDataBsToggle.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@ trait HasDataBsToggle
1212
protected bool|string $dataBsToggle = false;
1313

1414
/**
15-
* Set the `HTML` data-bs-toggle attribute for the toggle.
15+
* Set the `HTML` `data-bs-toggle` attribute for the toggle.
1616
*
17-
* @param bool|string $value The data-bs-toogle attribute value. If true, the value of the id attribute will be
18-
* used.
17+
* @param bool|string $value The `data-bs-toogle` attribute value. If `true`, the value of the `id` attribute will
18+
* be used.
1919
*
2020
* @return static A new instance of the current class with the specified toggle attributes.
2121
*/

src/Data/HasDataCollapseToggle.php

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,25 @@
99
*/
1010
trait HasDataCollapseToggle
1111
{
12+
protected bool|string $dataCollapseToggle = false;
13+
1214
/**
13-
* Set the `HTML` data-collapse-toggle attribute for the toggle.
15+
* Set the `HTML` `data-collapse-toggle` attribute for the toggle.
1416
*
15-
* @param string $value The data-collapse-toggle attribute value.
17+
* @param bool|string $value The `data-collapse-toggle` attribute value. If `true`, the value of the `id` attribute
18+
* will be used.
1619
*
1720
* @return static A new instance of the current class with the specified toggle attributes.
1821
*/
19-
public function dataCollapseToggle(string $value): static
22+
public function dataCollapseToggle(bool|string $value = true): static
2023
{
21-
return $this->dataAttributes([DataAttributeValues::COLLAPSE_TOGGLE => $value]);
24+
if (is_string($value)) {
25+
return $this->dataAttributes([DataAttributeValues::COLLAPSE_TOGGLE => $value]);
26+
}
27+
28+
$new = clone $this;
29+
$new->dataCollapseToggle = $value;
30+
31+
return $new;
2232
}
2333
}

src/Data/HasDataDismissTarget.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@ trait HasDataDismissTarget
1212
protected bool|string $dataDismissTarget = false;
1313

1414
/**
15-
* Set the `HTML` data-dismiss-target attribute for the toggle.
15+
* Set the `HTML` `data-dismiss-target` attribute for the toggle.
1616
*
17-
* @param bool|string $value The data-dismiss-target attribute value. If true, the value of the id attribute will be
18-
* used.
17+
* @param bool|string $value The `data-dismiss-target` attribute value. If `true`, the value of the `id` attribute
18+
* will be used.
1919
*/
2020
public function dataDismissTarget(bool|string $value = true): static
2121
{

src/Data/HasDataDrawerTarget.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@ trait HasDataDrawerTarget
1212
protected bool|string $dataDrawerTarget = false;
1313

1414
/**
15-
* Set the `HTML` data drawer target attribute for the toggle.
15+
* Set the `HTML` `data-drawer-target` attribute for the toggle.
1616
*
17-
* @param bool|string $value The data-drawer-target attribute value. If true, the value of the id attribute will be
18-
* used.
17+
* @param bool|string $value The `data-drawer-target` attribute value. If `true`, the value of the `id` attribute
18+
* will be used.
1919
*
2020
* @return static A new instance of the current class with the specified toggle attributes.
2121
*/

src/Data/HasDataDropdownToggle.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@ trait HasDataDropdownToggle
1212
protected bool|string $dataDropdownToggle = false;
1313

1414
/**
15-
* Set the `HTML` data dropdown toggle attribute for the toggle.
15+
* Set the `HTML` `data-dropdown-toggle` attribute for the toggle.
1616
*
17-
* @param bool|string $value The data-dropdown-toggle attribute value. If true, the value of the id attribute will
18-
* be used.
17+
* @param bool|string $value The `data-dropdown-toggle` attribute value. If `true`, the value of the `id` attribute
18+
* will be used.
1919
*
2020
* @return static A new instance of the current class with the specified toggle attributes.
2121
*/

src/Data/HasDataToggle.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ trait HasDataToggle
1212
protected bool|string $dataToggle = false;
1313

1414
/**
15-
* Set the `HTML` data toggle attribute for the toggle.
15+
* Set the `HTML` `data-toggle` attribute for the toggle.
1616
*
17-
* @param bool|string $value The data-toggle attribute value. If true, the value of the id attribute will be
17+
* @param bool|string $value The `data-toggle` attribute value. If `true`, the value of the `id` attribute will be
1818
* used.
1919
*
2020
* @return static A new instance of the current class with the specified toggle attributes.

0 commit comments

Comments
 (0)