This commit is contained in:
Sampanna Rimal
2024-09-04 12:22:04 +05:45
parent 53c0140f58
commit 82fab174dc
203 changed files with 4255 additions and 1343 deletions

View File

@ -2,6 +2,37 @@
All notable changes to `laravel-html` will be documented in this file.
## 3.8.0 - 2024-04-24
### What's Changed
* Add autocomplete attribute helper to the form element by @raveren in https://github.com/spatie/laravel-html/pull/221
* Added support for Htmlable contents in BaseElement by @hemmesdev in https://github.com/spatie/laravel-html/pull/215
* Register Service Provider in Laravel 11 by @gqrdev in https://github.com/spatie/laravel-html/pull/224
* Add name attribute to form element by @bskl in https://github.com/spatie/laravel-html/pull/223
### New Contributors
* @hemmesdev made their first contribution in https://github.com/spatie/laravel-html/pull/215
* @gqrdev made their first contribution in https://github.com/spatie/laravel-html/pull/224
**Full Changelog**: https://github.com/spatie/laravel-html/compare/3.7.0...3.8.0
## 3.7.0 - 2024-03-23
### What's Changed
* Fix return value in docs in element-methods.md by @raveren in https://github.com/spatie/laravel-html/pull/218
* Add autocomplete attribute helper to input, select and textarea by @raveren in https://github.com/spatie/laravel-html/pull/219
* Fix link with version in documentation by @fey in https://github.com/spatie/laravel-html/pull/217
### New Contributors
* @raveren made their first contribution in https://github.com/spatie/laravel-html/pull/218
* @fey made their first contribution in https://github.com/spatie/laravel-html/pull/217
**Full Changelog**: https://github.com/spatie/laravel-html/compare/3.6.0...3.7.0
## 3.6.0 - 2024-03-08
### What's Changed

View File

@ -169,6 +169,17 @@ abstract class BaseElement implements Htmlable, HtmlElement
return $this->attribute("data-{$name}", $value);
}
/**
* @param string $attribute
* @param string|null $value
*
* @return static
*/
public function aria($attribute, $value = null)
{
return $this->attribute("aria-{$attribute}", $value);
}
/**
* @param \Spatie\Html\HtmlElement|string|iterable|int|float|null $children
* @param callable|null $mapper
@ -465,6 +476,8 @@ abstract class BaseElement implements Htmlable, HtmlElement
{
if ($children instanceof HtmlElement) {
$children = [$children];
} elseif ($children instanceof Htmlable) {
$children = $children->toHtml();
}
$children = Collection::make($children);

View File

@ -3,10 +3,14 @@
namespace Spatie\Html\Elements;
use Spatie\Html\BaseElement;
use Spatie\Html\Elements\Attributes\Autocomplete;
use Spatie\Html\Elements\Attributes\Name;
use Spatie\Html\Elements\Attributes\Target;
class Form extends BaseElement
{
use Autocomplete;
use Name;
use Target;
protected $tag = 'form';

View File

@ -4,6 +4,7 @@ namespace Spatie\Html;
use BackedEnum;
use DateTimeImmutable;
use Exception;
use Illuminate\Contracts\Support\Htmlable;
use Illuminate\Http\Request;
use Illuminate\Support\Collection;
@ -271,8 +272,9 @@ class Html
*/
public function fieldset($legend = null)
{
return $legend ?
Fieldset::create()->legend($legend) : Fieldset::create();
return $legend
? Fieldset::create()->legend($legend)
: Fieldset::create();
}
/**
@ -389,9 +391,9 @@ class Html
public function number($name = null, $value = null, $min = null, $max = null, $step = null)
{
return $this->input('number', $name, $value)
->attributeIfNotNull($min, 'min', $min)
->attributeIfNotNull($max, 'max', $max)
->attributeIfNotNull($step, 'step', $step);
->attributeIfNotNull($min, 'min', $min)
->attributeIfNotNull($max, 'max', $max)
->attributeIfNotNull($step, 'step', $step);
}
/**
@ -658,7 +660,7 @@ class Html
$date = new DateTimeImmutable($value);
return $date->format($format);
} catch (\Exception $e) {
} catch (Exception $e) {
return $value;
}
}
@ -672,7 +674,7 @@ class Html
protected function getEnumValue($value)
{
return $value instanceof BackedEnum
? $value->value
: $value->name;
? $value->value
: $value->name;
}
}