From fc1e67ed010201c0e8faa791c626e6f572c80d25 Mon Sep 17 00:00:00 2001
From: Wilmer Arambula
Date: Thu, 30 Apr 2026 09:09:31 -0400
Subject: [PATCH 1/2] refactor: align attributes, docs, tests, and release
tooling with the current package scope.
---
.github/workflows/build.yml | 5 +-
.github/workflows/dependency-check.yml | 2 +-
.github/workflows/ecs.yml | 4 +-
.github/workflows/static.yml | 2 +-
.styleci.yml | 2 +-
CHANGELOG.md | 136 +++++--------
README.md | 42 ++--
composer.json | 31 ++-
docs/development.md | 42 ----
docs/svgs/features-mobile.svg | 107 +++++-----
docs/svgs/features.svg | 106 +++++-----
docs/testing.md | 4 +
src/CanBeDisabled.php | 2 +-
src/CanBeSelected.php | 4 +-
src/Element/HasAlt.php | 41 ----
src/Element/HasDecoding.php | 50 -----
src/Element/HasHeight.php | 42 ----
src/Element/HasHref.php | 42 ----
src/Element/HasLoading.php | 50 -----
src/Element/HasPopoverTarget.php | 40 ----
src/Element/HasPopoverTargetAction.php | 47 -----
src/Element/HasReferrerpolicy.php | 53 -----
src/Element/HasSrc.php | 40 ----
src/Element/HasSrcset.php | 42 ----
src/Element/HasUsemap.php | 40 ----
src/Element/HasWidth.php | 43 ----
src/Exception/Message.php | 4 +-
src/Form/CanBeChecked.php | 38 ----
src/Form/CanBeMultiple.php | 38 ----
src/Form/CanBeReadonly.php | 38 ----
src/Form/CanBeRequired.php | 38 ----
src/Form/HasAccept.php | 41 ----
src/Form/HasAutocomplete.php | 41 ----
src/Form/HasDirname.php | 40 ----
src/Form/HasForm.php | 40 ----
src/Form/HasList.php | 40 ----
src/Form/HasMax.php | 41 ----
src/Form/HasMaxlength.php | 60 ------
src/Form/HasMin.php | 41 ----
src/Form/HasMinlength.php | 60 ------
src/Form/HasPattern.php | 40 ----
src/Form/HasPlaceholder.php | 40 ----
src/Form/HasSize.php | 59 ------
src/Form/HasStep.php | 42 ----
src/Global/CanBeAutofocus.php | 2 +-
src/Global/CanBeHidden.php | 2 +-
src/Global/HasAccesskey.php | 2 +-
src/Global/HasAria.php | 25 ++-
src/Global/HasAutocapitalize.php | 6 +-
src/Global/HasAutocorrect.php | 4 +-
src/Global/HasContentEditable.php | 4 +-
src/Global/HasData.php | 25 ++-
src/Global/HasDir.php | 4 +-
src/Global/HasDraggable.php | 2 +-
src/Global/HasEvents.php | 24 ++-
src/Global/HasId.php | 2 +-
src/Global/HasInputMode.php | 6 +-
src/Global/HasLang.php | 2 +-
src/Global/HasMicroData.php | 10 +-
src/Global/HasNonce.php | 2 +-
src/Global/HasPopover.php | 4 +-
src/Global/HasRole.php | 2 +-
src/Global/HasSpellcheck.php | 2 +-
src/Global/HasStyle.php | 6 +-
src/Global/HasTabindex.php | 7 +-
src/Global/HasTitle.php | 2 +-
src/Global/HasTranslate.php | 4 +-
src/HasAs.php | 6 +-
src/HasBlocking.php | 6 +-
src/HasCharset.php | 6 +-
src/HasContent.php | 2 +-
src/HasCrossorigin.php | 2 +-
src/HasDownload.php | 4 +-
src/HasFetchpriority.php | 2 +-
src/HasFor.php | 2 +-
src/HasHreflang.php | 4 +-
src/HasHttpEquiv.php | 6 +-
src/{HasImagesizes.php => HasImageSizes.php} | 6 +-
...{HasImagesrcset.php => HasImageSrcSet.php} | 6 +-
src/HasIntegrity.php | 2 +-
src/HasLabel.php | 4 +-
src/HasMedia.php | 2 +-
src/HasName.php | 4 +-
src/HasPing.php | 4 +-
src/HasReferrerpolicy.php | 2 +-
src/HasRel.php | 2 +-
src/HasSizes.php | 6 +-
src/HasSrc.php | 2 +-
src/HasTarget.php | 2 +-
src/HasType.php | 2 +-
src/HasValue.php | 8 +-
src/Values/Attribute.php | 105 ----------
src/Values/ElementAttribute.php | 188 ++++++++++++++++++
tests/CanBeDisabledTest.php | 2 +-
tests/CanBeSelectedTest.php | 4 +-
tests/Element/HasAltTest.php | 89 ---------
tests/Element/HasDecodingTest.php | 111 -----------
tests/Element/HasHeightTest.php | 89 ---------
tests/Element/HasHrefTest.php | 89 ---------
tests/Element/HasLoadingTest.php | 111 -----------
tests/Element/HasPopoverTargetActionTest.php | 111 -----------
tests/Element/HasPopoverTargetTest.php | 89 ---------
tests/Element/HasReferrerpolicyTest.php | 111 -----------
tests/Element/HasSrcTest.php | 89 ---------
tests/Element/HasSrcsetTest.php | 89 ---------
tests/Element/HasUsemapTest.php | 89 ---------
tests/Element/HasWidthTest.php | 89 ---------
tests/Form/CanBeCheckedTest.php | 87 --------
tests/Form/CanBeMultipleTest.php | 87 --------
tests/Form/CanBeReadonlyTest.php | 87 --------
tests/Form/CanBeRequiredTest.php | 87 --------
tests/Form/HasAcceptTest.php | 89 ---------
tests/Form/HasAutocompleteTest.php | 89 ---------
tests/Form/HasDirnameTest.php | 89 ---------
tests/Form/HasFormTest.php | 89 ---------
tests/Form/HasListTest.php | 89 ---------
tests/Form/HasMaxTest.php | 89 ---------
tests/Form/HasMaxlengthTest.php | 117 -----------
tests/Form/HasMinTest.php | 89 ---------
tests/Form/HasMinlengthTest.php | 117 -----------
tests/Form/HasPatternTest.php | 89 ---------
tests/Form/HasPlaceholderTest.php | 89 ---------
tests/Form/HasSizeTest.php | 89 ---------
tests/Form/HasStepTest.php | 89 ---------
tests/Global/CanBeAutofocusTest.php | 2 +-
tests/Global/CanBeHiddenTest.php | 2 +-
tests/Global/HasAccesskeyTest.php | 2 +-
tests/Global/HasAutocapitalizeTest.php | 6 +-
tests/Global/HasAutocorrectTest.php | 6 +-
tests/Global/HasClassTest.php | 2 +-
tests/Global/HasContentEditableTest.php | 6 +-
tests/Global/HasDirTest.php | 6 +-
tests/Global/HasDraggableTest.php | 6 +-
tests/Global/HasIdTest.php | 2 +-
tests/Global/HasInputModeTest.php | 6 +-
tests/Global/HasLangTest.php | 6 +-
tests/Global/HasMicroDataTest.php | 10 +-
tests/Global/HasNonceTest.php | 2 +-
tests/Global/HasPopoverTest.php | 6 +-
tests/Global/HasRoleTest.php | 6 +-
tests/Global/HasSpellcheckTest.php | 2 +-
tests/Global/HasStyleTest.php | 2 +-
tests/Global/HasTabIndexTest.php | 2 +-
tests/Global/HasTitleTest.php | 2 +-
tests/Global/HasTranslateTest.php | 6 +-
tests/HasAsTest.php | 10 +-
tests/HasBlockingTest.php | 10 +-
tests/HasCharsetTest.php | 10 +-
tests/HasContentTest.php | 2 +-
tests/HasCrossoriginTest.php | 6 +-
tests/HasDownloadTest.php | 4 +-
tests/HasFetchpriorityTest.php | 6 +-
tests/HasForTest.php | 2 +-
tests/HasHreflangTest.php | 4 +-
tests/HasHttpEquivTest.php | 10 +-
...agesizesTest.php => HasImageSizesTest.php} | 18 +-
...esrcsetTest.php => HasImageSrcSetTest.php} | 18 +-
tests/HasIntegrityTest.php | 2 +-
tests/HasLabelTest.php | 4 +-
tests/HasMediaTest.php | 2 +-
tests/HasNameTest.php | 4 +-
tests/HasPingTest.php | 4 +-
tests/HasReferrerpolicyTest.php | 6 +-
tests/HasRelTest.php | 6 +-
tests/HasSizesTest.php | 4 +-
tests/HasSrcTest.php | 2 +-
tests/HasTargetTest.php | 6 +-
tests/HasTypeTest.php | 6 +-
tests/HasValueTest.php | 4 +-
tests/Provider/AsProvider.php | 4 +-
tests/Provider/BlockingProvider.php | 4 +-
tests/Provider/CharsetProvider.php | 4 +-
tests/Provider/Element/AltProvider.php | 95 ---------
tests/Provider/Element/DecodingProvider.php | 86 --------
tests/Provider/Element/HeightProvider.php | 95 ---------
tests/Provider/Element/HrefProvider.php | 109 ----------
tests/Provider/Element/LoadingProvider.php | 86 --------
.../Element/PopoverTargetActionProvider.php | 89 ---------
.../Element/PopoverTargetProvider.php | 95 ---------
.../Element/ReferrerpolicyProvider.php | 86 --------
tests/Provider/Element/SrcProvider.php | 95 ---------
tests/Provider/Element/SrcsetProvider.php | 102 ----------
tests/Provider/Element/UsemapProvider.php | 95 ---------
tests/Provider/Element/WidthProvider.php | 95 ---------
tests/Provider/Form/AcceptProvider.php | 95 ---------
tests/Provider/Form/AutocompleteProvider.php | 86 --------
tests/Provider/Form/CheckedProvider.php | 60 ------
tests/Provider/Form/DirnameProvider.php | 95 ---------
tests/Provider/Form/FormProvider.php | 95 ---------
tests/Provider/Form/ListProvider.php | 95 ---------
tests/Provider/Form/MaxProvider.php | 109 ----------
tests/Provider/Form/MaxlengthProvider.php | 134 -------------
tests/Provider/Form/MinProvider.php | 109 ----------
tests/Provider/Form/MinlengthProvider.php | 134 -------------
tests/Provider/Form/MultipleProvider.php | 60 ------
tests/Provider/Form/PatternProvider.php | 95 ---------
tests/Provider/Form/PlaceholderProvider.php | 95 ---------
tests/Provider/Form/ReadonlyProvider.php | 60 ------
tests/Provider/Form/RequiredProvider.php | 60 ------
tests/Provider/Form/SizeProvider.php | 88 --------
tests/Provider/Form/StepProvider.php | 116 -----------
tests/Provider/Global/AriaProvider.php | 8 +-
tests/Provider/Global/ClassProvider.php | 8 +-
tests/Provider/Global/DataProvider.php | 8 +-
tests/Provider/Global/EventProvider.php | 8 +-
tests/Provider/HttpEquivProvider.php | 4 +-
...zesProvider.php => ImageSizesProvider.php} | 4 +-
...etProvider.php => ImageSrcSetProvider.php} | 4 +-
tests/Provider/NameProvider.php | 4 +-
209 files changed, 677 insertions(+), 7354 deletions(-)
delete mode 100644 docs/development.md
delete mode 100644 src/Element/HasAlt.php
delete mode 100644 src/Element/HasDecoding.php
delete mode 100644 src/Element/HasHeight.php
delete mode 100644 src/Element/HasHref.php
delete mode 100644 src/Element/HasLoading.php
delete mode 100644 src/Element/HasPopoverTarget.php
delete mode 100644 src/Element/HasPopoverTargetAction.php
delete mode 100644 src/Element/HasReferrerpolicy.php
delete mode 100644 src/Element/HasSrc.php
delete mode 100644 src/Element/HasSrcset.php
delete mode 100644 src/Element/HasUsemap.php
delete mode 100644 src/Element/HasWidth.php
delete mode 100644 src/Form/CanBeChecked.php
delete mode 100644 src/Form/CanBeMultiple.php
delete mode 100644 src/Form/CanBeReadonly.php
delete mode 100644 src/Form/CanBeRequired.php
delete mode 100644 src/Form/HasAccept.php
delete mode 100644 src/Form/HasAutocomplete.php
delete mode 100644 src/Form/HasDirname.php
delete mode 100644 src/Form/HasForm.php
delete mode 100644 src/Form/HasList.php
delete mode 100644 src/Form/HasMax.php
delete mode 100644 src/Form/HasMaxlength.php
delete mode 100644 src/Form/HasMin.php
delete mode 100644 src/Form/HasMinlength.php
delete mode 100644 src/Form/HasPattern.php
delete mode 100644 src/Form/HasPlaceholder.php
delete mode 100644 src/Form/HasSize.php
delete mode 100644 src/Form/HasStep.php
rename src/{HasImagesizes.php => HasImageSizes.php} (87%)
rename src/{HasImagesrcset.php => HasImageSrcSet.php} (87%)
delete mode 100644 tests/Element/HasAltTest.php
delete mode 100644 tests/Element/HasDecodingTest.php
delete mode 100644 tests/Element/HasHeightTest.php
delete mode 100644 tests/Element/HasHrefTest.php
delete mode 100644 tests/Element/HasLoadingTest.php
delete mode 100644 tests/Element/HasPopoverTargetActionTest.php
delete mode 100644 tests/Element/HasPopoverTargetTest.php
delete mode 100644 tests/Element/HasReferrerpolicyTest.php
delete mode 100644 tests/Element/HasSrcTest.php
delete mode 100644 tests/Element/HasSrcsetTest.php
delete mode 100644 tests/Element/HasUsemapTest.php
delete mode 100644 tests/Element/HasWidthTest.php
delete mode 100644 tests/Form/CanBeCheckedTest.php
delete mode 100644 tests/Form/CanBeMultipleTest.php
delete mode 100644 tests/Form/CanBeReadonlyTest.php
delete mode 100644 tests/Form/CanBeRequiredTest.php
delete mode 100644 tests/Form/HasAcceptTest.php
delete mode 100644 tests/Form/HasAutocompleteTest.php
delete mode 100644 tests/Form/HasDirnameTest.php
delete mode 100644 tests/Form/HasFormTest.php
delete mode 100644 tests/Form/HasListTest.php
delete mode 100644 tests/Form/HasMaxTest.php
delete mode 100644 tests/Form/HasMaxlengthTest.php
delete mode 100644 tests/Form/HasMinTest.php
delete mode 100644 tests/Form/HasMinlengthTest.php
delete mode 100644 tests/Form/HasPatternTest.php
delete mode 100644 tests/Form/HasPlaceholderTest.php
delete mode 100644 tests/Form/HasSizeTest.php
delete mode 100644 tests/Form/HasStepTest.php
rename tests/{HasImagesizesTest.php => HasImageSizesTest.php} (83%)
rename tests/{HasImagesrcsetTest.php => HasImageSrcSetTest.php} (83%)
delete mode 100644 tests/Provider/Element/AltProvider.php
delete mode 100644 tests/Provider/Element/DecodingProvider.php
delete mode 100644 tests/Provider/Element/HeightProvider.php
delete mode 100644 tests/Provider/Element/HrefProvider.php
delete mode 100644 tests/Provider/Element/LoadingProvider.php
delete mode 100644 tests/Provider/Element/PopoverTargetActionProvider.php
delete mode 100644 tests/Provider/Element/PopoverTargetProvider.php
delete mode 100644 tests/Provider/Element/ReferrerpolicyProvider.php
delete mode 100644 tests/Provider/Element/SrcProvider.php
delete mode 100644 tests/Provider/Element/SrcsetProvider.php
delete mode 100644 tests/Provider/Element/UsemapProvider.php
delete mode 100644 tests/Provider/Element/WidthProvider.php
delete mode 100644 tests/Provider/Form/AcceptProvider.php
delete mode 100644 tests/Provider/Form/AutocompleteProvider.php
delete mode 100644 tests/Provider/Form/CheckedProvider.php
delete mode 100644 tests/Provider/Form/DirnameProvider.php
delete mode 100644 tests/Provider/Form/FormProvider.php
delete mode 100644 tests/Provider/Form/ListProvider.php
delete mode 100644 tests/Provider/Form/MaxProvider.php
delete mode 100644 tests/Provider/Form/MaxlengthProvider.php
delete mode 100644 tests/Provider/Form/MinProvider.php
delete mode 100644 tests/Provider/Form/MinlengthProvider.php
delete mode 100644 tests/Provider/Form/MultipleProvider.php
delete mode 100644 tests/Provider/Form/PatternProvider.php
delete mode 100644 tests/Provider/Form/PlaceholderProvider.php
delete mode 100644 tests/Provider/Form/ReadonlyProvider.php
delete mode 100644 tests/Provider/Form/RequiredProvider.php
delete mode 100644 tests/Provider/Form/SizeProvider.php
delete mode 100644 tests/Provider/Form/StepProvider.php
rename tests/Provider/{ImagesizesProvider.php => ImageSizesProvider.php} (98%)
rename tests/Provider/{ImagesrcsetProvider.php => ImageSrcSetProvider.php} (98%)
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index 3254d3d..b0d2a83 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -17,6 +17,9 @@ permissions:
jobs:
phpunit:
- uses: yii2-framework/actions/.github/workflows/phpunit.yml@main
+ uses: yii2-framework/actions/.github/workflows/phpunit.yml@v1
secrets:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
+ with:
+ php-version: '["8.3","8.4","8.5"]'
+
diff --git a/.github/workflows/dependency-check.yml b/.github/workflows/dependency-check.yml
index e69d7d1..294a347 100644
--- a/.github/workflows/dependency-check.yml
+++ b/.github/workflows/dependency-check.yml
@@ -18,4 +18,4 @@ permissions:
jobs:
composer-require-checker:
- uses: yii2-framework/actions/.github/workflows/composer-require-checker.yml@main
+ uses: yii2-framework/actions/.github/workflows/composer-require-checker.yml@v1
diff --git a/.github/workflows/ecs.yml b/.github/workflows/ecs.yml
index e18f15c..4f8e0f7 100644
--- a/.github/workflows/ecs.yml
+++ b/.github/workflows/ecs.yml
@@ -18,4 +18,6 @@ permissions:
jobs:
easy-coding-standard:
- uses: yii2-framework/actions/.github/workflows/ecs.yml@main
+ uses: yii2-framework/actions/.github/workflows/ecs.yml@v1
+ with:
+ php-version: '["8.3"]'
diff --git a/.github/workflows/static.yml b/.github/workflows/static.yml
index 99d7c1c..cc1c99d 100644
--- a/.github/workflows/static.yml
+++ b/.github/workflows/static.yml
@@ -18,4 +18,4 @@ permissions:
jobs:
phpstan:
- uses: yii2-framework/actions/.github/workflows/phpstan.yml@main
+ uses: yii2-framework/actions/.github/workflows/phpstan.yml@v1
diff --git a/.styleci.yml b/.styleci.yml
index 40c1c55..8995a69 100644
--- a/.styleci.yml
+++ b/.styleci.yml
@@ -1,7 +1,7 @@
preset: psr12
risky: true
-version: 8.1
+version: 8.3
finder:
exclude:
diff --git a/CHANGELOG.md b/CHANGELOG.md
index f241e87..8a8a4b0 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,123 +1,79 @@
-# ChangeLog
+# Changelog
+
+All notable changes to this project will be documented in this file.
+
+The format is based on Keep a Changelog, and this project adheres to Semantic Versioning.
## 0.6.0 Under development
-- Enh #32: Add `HasBlocking` trait and `blocking()` method to manage `blocking` attribute for HTML elements (@terabytesoftw)
-- Enh #33: Add `HasMedia` trait and `media()` method to manage `media` attribute for HTML elements (@terabytesoftw)
-- Enh #34: Add `HasType` trait and `type()` method to manage `type` attribute for HTML elements (@terabytesoftw)
-- Enh #35: Add `HasNonce` trait and `nonce()` method to manage `nonce` attribute for HTML elements (@terabytesoftw)
-- Bug #36: Clarify documentation for various HTML attributes to specify value types for better understanding (@terabytesoftw)
-- Enh #37: Add `HasIntegrity` trait and `integrity()` method to manage `integrity` attribute for HTML elements (@terabytesoftw)
-- Enh #38: Add `HasReferrerpolicy` trait and `referrerpolicy()` method to manage `referrerpolicy` attribute for HTML elements (@terabytesoftw)
-- Enh #39: Add `HasSrc` trait and `src()` method to manage `src` attribute for HTML elements (@terabytesoftw)
-- Bug #40: Enhance documentation for HTML attributes (@terabytesoftw)
-- Enh #41: Add `HasTarget` trait and `target()` method to manage `target` attribute for HTML elements (@terabytesoftw)
-- Enh #42: Add `HasAs` trait and `as()` method to manage `as` attribute for HTML elements (@terabytesoftw)
-- Bug #43: Update copyright year to `2026` in multiple files (@terabytesoftw)
-- Enh #44: Add `HasDisabled` trait and `disabled()` method to manage `disabled` attribute for HTML elements (@terabytesoftw)
-- Enh #45: Add `HasHreflang` trait and `hreflang()` method to manage `hreflang` attribute for HTML elements (@terabytesoftw)
-- Enh #46: Add `HasImagesizes` trait and `imagesizes()` method to manage `imagesizes` attribute for HTML elements (@terabytesoftw)
-- Enh #47: Add `HasImagesrcset` trait and `imagesrcset()` method to manage `imagesrcset` attribute for HTML elements (@terabytesoftw)
-- Enh #48: Add `HasSizes` trait and `sizes()` method to manage `sizes` attribute for HTML elements (@terabytesoftw)
-- Enh #49: Add `HasCharset` trait and `charset()` method to manage `charset` attribute for HTML elements (@terabytesoftw)
-- Enh #50: Add `HasContent` trait and `content()` method to manage `content` attribute for HTML elements (@terabytesoftw)
-- Enh #51: Add `HasHttpEquiv` trait and `httpEquiv()` method to manage `http-equiv` attribute for HTML elements (@terabytesoftw)
-- Enh #52: Add `HasName` trait and `name()` method to manage `name` attribute for HTML elements (@terabytesoftw)
-- Bug #53: Update documentation for various HTML attributes and their usage in elements (@terabytesoftw)
-- Enh #54: Add `HasDownload` trait and `download()` method to manage `download` attribute for HTML elements (@terabytesoftw)
-- Enh #55: Add `HasPing` trait and `ping()` method to manage `ping` attribute for HTML elements (@terabytesoftw)
-- Enh #56: Add `HasLoading` trait and `loading()` method to manage `loading` attribute for HTML elements (@terabytesoftw)
-- Enh #57: Add `HasSrcset` trait and `srcset()` method to manage `srcset` attribute for HTML elements (@terabytesoftw)
-- Enh #58: Add `HasUsemap` trait and `usemap()` method to manage `usemap` attribute for HTML elements (@terabytesoftw)
-- Enh #59: Add `HasValue` trait and `value()` method to manage `value` attribute for HTML elements (@terabytesoftw)
-- Enh #60: Add `HasForm` trait and `form()` method to manage `form` attribute for HTML elements (@terabytesoftw)
-- Enh #61: Add `Type` enum for common `type` attribute values (@terabytesoftw)
-- Enh #62: Add `HasMax`, `HasMin` traits and `max()`, `min()` methods to manage `max` and `min` attributes for HTML elements (@terabytesoftw)
-- Enh #63: Add `HasReadonly`, `HasStep` traits and `readonly()`, `step()` methods to manage `readonly` and `step` attributes for HTML elements (@terabytesoftw)
-- Enh #64: Add `HasMaxlength`, `HasMinlength` traits and `maxlength()`, `minlength()` methods to manage `maxlength` and `minlength` attributes for HTML elements (@terabytesoftw)
-- Enh #65: Add `HasRequired` trait and `required()` method to manage `required` attribute for HTML elements (@terabytesoftw)
-- Bug #66: Enhance HTML attribute element handling with Stringable and UnitEnum support (@terabytesoftw)
-- Enh #67: Add `HasAccept`, `HasAutocomplete` traits and `accept()`, `autocomplete()` methods to manage `accept` and `autocomplete` attributes for HTML elements (@terabytesoftw)
-- Enh #68: Add `HasChecked`, `HasDirname` traits and `checked()`, `dirname()` methods to manage `checked` and `dirname` attributes for HTML elements (@terabytesoftw)
-- Enh #69: Add `HasList`, `HasMultiple` traits and `list()`, `multiple()` methods to manage `list` and `multiple` attributes for HTML elements (@terabytesoftw)
-- Enh #70: Add `HasPattern`, `HasPlaceholder`, `HasSize` traits and `pattern()`, `placeholder()`, `size()` methods to manage `pattern`, `placeholder`, and `size` attributes for HTML elements (@terabytesoftw)
-- Bug #71: Move HTML attribute traits to `Form` namespace and update related imports accordingly (@terabytesoftw)
-- Bug #72: Update documentation for HTML attribute elements in `Element` namespace (@terabytesoftw)
-- Bug #73: Standardize PHPDoc headers across src directory files (@terabytesoftw)
-- Bug #74: Remove directory `tests\Stub` and move `tests\Support\Provider` to `tests\Provider` in tests (@terabytesoftw)
-- Bug #75: Standardize PHPDoc headers for test classes (@terabytesoftw)
-- Bug #76: Move `HasDisabled` trait to `UIAwesome\Html\Attribute` namespace and update related imports accordingly (@terabytesoftw)
-- Enh #77: Add `Autocomplete` enum and update `AutocompleteProvider` to add test data (@terabytesoftw)
-- Enh #78: Add `HasPopover`, `HasPopoverTarget`, `HasPopoverTargetAction` traits and `popover()`, `popoverTarget()`, `popoverTargetAction()` methods to manage popover attributes for HTML elements (@terabytesoftw)
-- Enh #79: Add `HasInputmode` trait and `inputmode()` method to manage `inputmode` attribute for HTML elements (@terabytesoftw)
-- Bug #80: Update `value()` method in `HasValue` trait to accept boolean values and adjust related tests and data provider (@terabytesoftw)
-- Bug #81: Migrate mixin attribute setters and tests to the simplified API (@terabytesoftw)
-- Bug #82: Update `ui-awesome/html-helper` requirement to use stable version constraint `^0.7` in `composer.json` (@terabytesoftw)
-- Enh #83: Enhance `HasAria`, `HasData`, and `HasEvents` traits to support prefix attributes `aria-`, `data-`, and `on` (@terabytesoftw)
-- Bug #84: Refactor attribute documentation in traits (@terabytesoftw)
-- Bug #85: Bug `#85`: Rename boolean attribute traits from `Has*` prefix to improve naming clarity (@terabytesoftw)
-- Enh #86: Add `HasAutocapitalize` and `HasAutocorrect` traits and `autocapitalize()`, `autocorrect()` methods to manage `autocapitalize` and `autocorrect` attributes for HTML elements (@terabytesoftw)
-- Bug #87: Update test method names for clarity by removing redundant `Value` suffix (@terabytesoftw)
-- Enh #88: Add `CanBeSelected`, `HasLabel` traits and `selected()`, `label()` methods to manage `selected` and `label` attributes for HTML elements (@terabytesoftw)
-- Enh #89: Add `HasFor` trait and `for()` method to manage `for` attribute for HTML elements (@terabytesoftw)
+- feat: add common attribute traits for blocking, media, type, nonce, integrity, referrer policy, source, target, link preload, metadata, form, and selectable attributes.
+- feat: add enum values for autocomplete, type, and shared attribute allow-lists.
+- feat: add prefixed `aria-*`, `data-*`, and `on*` attribute support.
+- feat: add autocapitalize, autocorrect, selected, label, and for attribute APIs.
+- fix: support `Stringable`, `UnitEnum`, and boolean values consistently in attribute setters.
+- refactor: migrate attribute setters and tests to the simplified `addAttribute()` API.
+- refactor: remove element, form, media, and interactive element-specific traits now owned by `ui-awesome/html`.
+- refactor: move element-specific enum cases from `Attribute` to `ElementAttribute`.
+- refactor: rename boolean attribute traits from `Has*` to `CanBe*` for clearer API names.
+- refactor: rename image size traits to `HasImageSizes` and `HasImageSrcSet`.
+- docs: standardize attribute PHPDoc and clarify value types across traits and enums.
+- test: standardize test PHPDoc, provider organization, exception names, and attribute assertions.
+- chore: update `ui-awesome/html-helper` to the stable `^0.7` constraint.
+- refactor: align attributes, docs, tests, and release tooling with the current package scope.
## 0.5.2 January 29, 2026
-- Enh #28: Add `php-forge/coding-standard` to development dependencies for code quality checks (@terabytesoftw)
-- Bug #29: Add section for automated refactoring using `Rector` in testing documentation (@terabytesoftw)
-- Bug #30: Update examples in `testing.md` for running Composer script with arguments and update `.styleci.yml` accordingly (@terabytesoftw)
-- Bug #31: Remove redundant ignore rule in `actionlint.yml` configuration and update Rector command in `composer.json` to remove unnecessary `src` argument (@terabytesoftw)
+- chore: add `php-forge/coding-standard` to development dependencies for code quality checks.
+- docs: add automated refactoring guidance with Rector to the testing documentation.
+- docs: update testing examples for running Composer scripts with arguments and align `.styleci.yml`.
+- chore: remove the redundant `actionlint` ignore rule and simplify the Rector Composer script.
## 0.5.1 January 20, 2026
-- Enh #27: Add `php-forge/support` as a development dependency and update related test classes (@terabytesoftw)
+- chore: add `php-forge/support` as a development dependency and update related tests.
## 0.5.0 January 19, 2026
-- Enh #14: Add `HasHref` trait and `href()` method to manage `href` attribute for HTML elements (@terabytesoftw)
-- Enh #15: Add `HasCrossorigin` trait and `crossorigin()` method to manage `crossorigin` attribute for HTML elements (@terabytesoftw)
-- Enh #16: Use package `ui-awesome/html-mixin` for mixin traits and update related imports accordingly (@terabytesoftw)
-- Enh #17: Add development guide and sync metadata instructions and update testing documentation (@terabytesoftw)
-- Enh #18: Move attribute traits from `ui-awesome/html-core` package and update related imports accordingly (@terabytesoftw)
-- Bug #19: Update alert content in SVGs to reflect accurate descriptions for MDN standards compliance and specific & lightweight features (@terabytesoftw)
-- Enh #20: Add `HasDecoding` trait and `decoding()` method to manage `decoding` attribute for HTML elements (@terabytesoftw)
-- Enh #21: Add `HasFetchpriority` trait and `fetchpriority()` method to manage `fetchpriority` attribute for HTML elements (@terabytesoftw)
-- Bug #22: Update documentation for `Crossorigin` and `ElementAttribute` enums to clarify attribute representation and compliance with MDN standards (@terabytesoftw)
-- Bug #23: Update attribute retrieval in tests to use `getAttribute()` method for consistency (@terabytesoftw)
-- Bug #24: Update documentation traits and enums for clarity and consistency (@terabytesoftw)
-- Bug #25: Update documentation tests classes for clarity and consistency (@terabytesoftw)
-- Bug #26: Improve `testing.md` for clarity and consistency in Composer script usage (@terabytesoftw)
+- feat: add href, crossorigin, decoding, fetchpriority, and other element attribute traits.
+- feat: add attribute traits moved from `ui-awesome/html-core`.
+- feat: add `HasForm` and shared form-related attribute APIs.
+- docs: add development guide, sync metadata instructions, and improved testing documentation.
+- docs: refresh SVG feature descriptions for MDN alignment.
+- docs: clarify `Crossorigin` and `ElementAttribute` enum documentation.
+- docs: standardize trait, enum, and test documentation.
+- fix: use `getAttribute()` consistently in tests.
+- chore: update `ui-awesome/html-helper` to `0.2`.
## 0.4.0 December 27, 2025
-- Dep #13: Update `ui-awesome/html-helper` version constraint to `^0.6` in `composer.json` (@terabytesoftw)
+- chore: update `ui-awesome/html-helper` constraint to `^0.6`.
## 0.3.0 December 26, 2025
-- Bug #10: Refactor codebase to improve performance and maintainability (@terabytesoftw)
-- Bug #11: Improve test suite documentation for HTML attributes with detailed descriptions and coverage (@terabytesoftw)
-- Bug #12: Add `StyleCI` badge to `README.md` for code style checks (@terabytesoftw)
+- refactor: improve codebase performance and maintainability.
+- docs: improve HTML attribute test suite documentation.
+- docs: add the StyleCI badge to `README.md`.
## 0.2.0 March 30, 2024
-- Enh #9: Update `ui-awesome/html-helper` to `0.2` (@terabytesoftw)
+- chore: update `ui-awesome/html-helper` to `0.2`.
## 0.1.3 March 16, 2024
-- Bug #8: Fix all `data` attributes for accept `true` value when `id` attribute is used (@terabytesoftw)
+- fix: allow `data-*` attributes to accept `true` values when the `id` attribute is used.
## 0.1.2 March 14, 2024
-- Bug #3: Change visibility property `attributes` to `public` in tests (@terabytesoftw)
-- Enh #4: Add `HasAriaCurrent` trait and `ariaCurrent()` method (@terabytesoftw)
-- Bug #5: Remove dead code in `HasAriaCurrent` trait (@terabytesoftw)
-- Bug #6: Change branch alias to `1.0-dev` in `composer.json` (@terabytesoftw)
-- Bug #7: Remove redundant abstract method in `data` classes (@terabytesoftw)
+- feat: add `HasAriaCurrent` trait and `ariaCurrent()` method.
+- fix: change test attribute visibility to public.
+- fix: remove dead code from `HasAriaCurrent`.
+- fix: change the branch alias to `1.0-dev` in `composer.json`.
+- fix: remove redundant abstract methods from data classes.
## 0.1.1 March 7, 2024
-- Bug #2: Add bool typehint to `dataBsToggle()` method and add default value to `true` in `dataBsTarget()`, `dataBstoggle()`, `dataDismissTarget()`, `dataDrawerTarget()`, `dataDrawerTarget()`,`dataDropdownToggle()` and `dataToggle()` (@terabytesoftw)
+- fix: add boolean typing and default values to data attribute helper methods.
## 0.1.0 March 5, 2024
-- Initial release
+- feat: initial `ui-awesome/html-attribute` package structure.
diff --git a/README.md b/README.md
index 7dc9e43..e9a4529 100644
--- a/README.md
+++ b/README.md
@@ -1,11 +1,9 @@
-
-
-
+
-
Html attribute
+ Html Attribute
@@ -37,12 +35,12 @@
### Installation
```bash
-composer require ui-awesome/html-attribute:^0.3
+composer require ui-awesome/html-attribute:^0.6
```
### Quick start
-Below are concise examples showing common attribute tasks.
+Compose reusable attribute APIs by combining the package traits with the immutable attribute mixin.
```php
getAttributes());
+ }
}
+
+$attributes = (new LinkAttributes())
+ ->id('documentation')
+ ->class('nav-link')
+ ->class('is-active')
+ ->rel(Rel::NOOPENER)
+ ->addDataAttribute('tracking', 'docs');
+
+echo 'render() . ' href="/docs">Documentation';
```
### Documentation
@@ -65,11 +84,10 @@ final class ImageComponent
For detailed configuration options and advanced usage see:
- 🧪 [Testing Guide](docs/testing.md)
-- 🛠️ [Development Guide](docs/development.md)
## Package information
-[](https://www.php.net/releases/8.1/en.php)
+[](https://www.php.net/releases/8.3/en.php)
[](https://packagist.org/packages/ui-awesome/html-attribute)
[](https://packagist.org/packages/ui-awesome/html-attribute)
diff --git a/composer.json b/composer.json
index b7b9c8f..2cae5c7 100644
--- a/composer.json
+++ b/composer.json
@@ -1,29 +1,35 @@
{
"name": "ui-awesome/html-attribute",
"type": "library",
- "description": "UI Awesome HTML Attribute Library for PHP.",
+ "description": "Type-safe traits and backed enums for HTML attribute composition: global attributes, ARIA, data-*, events, and element-specific setters.",
"keywords": [
"ui-awesome",
"html",
- "attribute",
- "library",
+ "html-attribute",
+ "traits",
+ "enums",
+ "attributes",
+ "aria",
+ "data-attributes",
+ "events",
+ "value-objects",
"php"
],
"license": "BSD-3-Clause",
"require": {
- "php": "^8.1",
+ "php": "^8.3",
"ui-awesome/html-helper": "^0.7",
- "ui-awesome/html-mixin": "^0.4"
+ "ui-awesome/html-mixin": "^0.5"
},
"require-dev": {
- "infection/infection": "^0.27|^0.32",
+ "infection/infection": "^0.32",
"maglnet/composer-require-checker": "^4.1",
"php-forge/coding-standard": "^0.1",
"php-forge/support": "^0.3",
"phpstan/extension-installer": "^1.4",
"phpstan/phpstan": "^2.1",
- "phpstan/phpstan-strict-rules": "^2.0.3",
- "phpunit/phpunit": "^10.5"
+ "phpstan/phpstan-strict-rules": "^2.0",
+ "phpunit/phpunit": "^12.5"
},
"autoload": {
"psr-4": {
@@ -54,15 +60,6 @@
"mutation-static": "./vendor/bin/infection --threads=4 --ignore-msi-with-no-mutations --min-msi=100 --min-covered-msi=100 --static-analysis-tool=phpstan --static-analysis-tool-options='--memory-limit=-1'",
"rector": "./vendor/bin/rector process",
"static": "./vendor/bin/phpstan --memory-limit=-1",
- "sync-metadata": [
- "curl -fsSL -o .editorconfig https://raw.githubusercontent.com/yii2-extensions/template/main/.editorconfig",
- "curl -fsSL -o .gitattributes https://raw.githubusercontent.com/yii2-extensions/template/main/.gitattributes",
- "curl -fsSL -o .gitignore https://raw.githubusercontent.com/yii2-extensions/template/main/.gitignore",
- "curl -fsSL -o .styleci.yml https://raw.githubusercontent.com/yii2-extensions/template/main/.styleci.yml",
- "curl -fsSL -o infection.json5 https://raw.githubusercontent.com/yii2-extensions/template/main/infection.json5",
- "curl -fsSL -o phpstan.neon https://raw.githubusercontent.com/yii2-extensions/template/main/phpstan.neon",
- "curl -fsSL -o phpunit.xml.dist https://raw.githubusercontent.com/yii2-extensions/template/main/phpunit.xml.dist"
- ],
"tests": "./vendor/bin/phpunit"
}
}
diff --git a/docs/development.md b/docs/development.md
deleted file mode 100644
index 0e75489..0000000
--- a/docs/development.md
+++ /dev/null
@@ -1,42 +0,0 @@
-# Development
-
-This document describes development workflows and maintenance tasks for the project.
-
-## Sync Metadata
-
-To keep configuration files synchronized with the latest template updates, use the `sync-metadata` command. This command
-downloads the latest configuration files from the template repository.
-
-```bash
-composer sync-metadata
-```
-
-### Updated Files
-
-This command updates the following configuration files:
-
-| File | Purpose |
-| ------------------ | -------------------------------------------- |
-| `.editorconfig` | Editor settings and code style configuration |
-| `.gitattributes` | Git attributes and file handling rules |
-| `.gitignore` | Git ignore patterns and exclusions |
-| `.styleci.yml` | StyleCI code style analysis configuration |
-| `infection.json5` | Infection mutation testing configuration |
-| `phpstan.neon` | PHPStan static analysis configuration |
-| `phpunit.xml.dist` | PHPUnit test configuration |
-
-### When to Run
-
-Run this command in the following scenarios:
-
-- **Periodic Updates** - Monthly or quarterly to benefit from template improvements.
-- **After Template Updates** - When the template repository has new configuration improvements.
-- **Before Major Releases** - Ensure your project uses the latest best practices.
-- **When Issues Occur** - If configuration files become outdated or incompatible.
-
-### Important Notes
-
-- This command overwrites existing configuration files with the latest versions from the template.
-- Ensure you have committed any custom configuration changes before running this command.
-- Review the updated files after syncing to ensure they work with your specific project needs.
-- Some projects may require customizations after syncing configuration files.
diff --git a/docs/svgs/features-mobile.svg b/docs/svgs/features-mobile.svg
index 0f746e3..092fd0f 100644
--- a/docs/svgs/features-mobile.svg
+++ b/docs/svgs/features-mobile.svg
@@ -1,59 +1,52 @@
-
-
diff --git a/docs/svgs/features.svg b/docs/svgs/features.svg
index 4b437fe..27b52aa 100644
--- a/docs/svgs/features.svg
+++ b/docs/svgs/features.svg
@@ -1,56 +1,56 @@
-
diff --git a/docs/testing.md b/docs/testing.md
index e0e9d88..f1ad2a0 100644
--- a/docs/testing.md
+++ b/docs/testing.md
@@ -80,3 +80,7 @@ Run PHPStan with a different memory limit.
```bash
composer static -- --memory-limit=512M
```
+
+## Next steps
+
+- 📖 [Readme](../README.md)
diff --git a/src/CanBeDisabled.php b/src/CanBeDisabled.php
index d3988ba..aee53e1 100644
--- a/src/CanBeDisabled.php
+++ b/src/CanBeDisabled.php
@@ -33,6 +33,6 @@ trait CanBeDisabled
*/
public function disabled(bool|null $value): static
{
- return $this->setAttribute(Attribute::DISABLED, $value);
+ return $this->addAttribute(Attribute::DISABLED, $value);
}
}
diff --git a/src/CanBeSelected.php b/src/CanBeSelected.php
index 4df3b48..7e14660 100644
--- a/src/CanBeSelected.php
+++ b/src/CanBeSelected.php
@@ -4,7 +4,7 @@
namespace UIAwesome\Html\Attribute;
-use UIAwesome\Html\Attribute\Values\Attribute;
+use UIAwesome\Html\Attribute\Values\ElementAttribute;
/**
* Provides an immutable API for the `selected` attribute.
@@ -33,6 +33,6 @@ trait CanBeSelected
*/
public function selected(bool|null $value): static
{
- return $this->setAttribute(Attribute::SELECTED, $value);
+ return $this->addAttribute(ElementAttribute::SELECTED, $value);
}
}
diff --git a/src/Element/HasAlt.php b/src/Element/HasAlt.php
deleted file mode 100644
index 0f7ee05..0000000
--- a/src/Element/HasAlt.php
+++ /dev/null
@@ -1,41 +0,0 @@
-alt('A penguin on a beach.');
- * $element->alt('');
- * $element->alt(null);
- * ```
- *
- * @param string|Stringable|UnitEnum|null $value Alternative text for the element, or `null` to remove the
- * attribute.
- *
- * @return static New instance with the updated `alt` attribute.
- */
- public function alt(string|Stringable|UnitEnum|null $value): static
- {
- return $this->setAttribute(ElementAttribute::ALT, $value);
- }
-}
diff --git a/src/Element/HasDecoding.php b/src/Element/HasDecoding.php
deleted file mode 100644
index de79d9a..0000000
--- a/src/Element/HasDecoding.php
+++ /dev/null
@@ -1,50 +0,0 @@
-decoding('async');
- * $element->decoding(Decoding::ASYNC);
- * $element->decoding(null);
- * ```
- *
- * @param string|Stringable|UnitEnum|null $value Decoding hint value. Use `async`, `sync`, or `auto`, or `null` to
- * remove the attribute.
- *
- * @throws InvalidArgumentException If the value is not valid.
- *
- * @return static New instance with the updated `decoding` attribute.
- *
- * {@see Decoding} for predefined enum values.
- */
- public function decoding(string|Stringable|UnitEnum|null $value): static
- {
- Validator::oneOf($value, Decoding::cases(), ElementAttribute::DECODING);
-
- return $this->setAttribute(ElementAttribute::DECODING, $value);
- }
-}
diff --git a/src/Element/HasHeight.php b/src/Element/HasHeight.php
deleted file mode 100644
index 9706ba1..0000000
--- a/src/Element/HasHeight.php
+++ /dev/null
@@ -1,42 +0,0 @@
-height(200);
- * $element->height('50%');
- * $element->height('auto');
- * ```
- *
- * @param int|string|Stringable|UnitEnum|null $value Height value in pixels or CSS units, or `null` to remove the
- * attribute.
- *
- * @return static New instance with the updated `height` attribute.
- */
- public function height(int|string|Stringable|UnitEnum|null $value): static
- {
- return $this->setAttribute(ElementAttribute::HEIGHT, $value);
- }
-}
diff --git a/src/Element/HasHref.php b/src/Element/HasHref.php
deleted file mode 100644
index 65c97c4..0000000
--- a/src/Element/HasHref.php
+++ /dev/null
@@ -1,42 +0,0 @@
-href('https://example.com/page');
- * $element->href('/about');
- * $element->href('#section');
- * $element->href(null);
- * ```
- *
- * @param string|Stringable|UnitEnum|null $value URL, path, or fragment, or `null` to remove the attribute.
- *
- * @return static New instance with the updated `href` attribute.
- */
- public function href(string|Stringable|UnitEnum|null $value): static
- {
- return $this->setAttribute(ElementAttribute::HREF, $value);
- }
-}
diff --git a/src/Element/HasLoading.php b/src/Element/HasLoading.php
deleted file mode 100644
index 27c0b15..0000000
--- a/src/Element/HasLoading.php
+++ /dev/null
@@ -1,50 +0,0 @@
-loading('lazy');
- * $element->loading(Loading::LAZY);
- * $element->loading(null);
- * ```
- *
- * @param string|Stringable|UnitEnum|null $value Loading strategy (`eager` or `lazy`), or `null` to remove the
- * attribute.
- *
- * @throws InvalidArgumentException If the value is not valid.
- *
- * @return static New instance with the updated `loading` attribute.
- *
- * {@see Loading} for predefined enum values.
- */
- public function loading(string|Stringable|UnitEnum|null $value): static
- {
- Validator::oneOf($value, Loading::cases(), ElementAttribute::LOADING);
-
- return $this->setAttribute(ElementAttribute::LOADING, $value);
- }
-}
diff --git a/src/Element/HasPopoverTarget.php b/src/Element/HasPopoverTarget.php
deleted file mode 100644
index 8b3b9e9..0000000
--- a/src/Element/HasPopoverTarget.php
+++ /dev/null
@@ -1,40 +0,0 @@
-popoverTarget('popover-id');
- * $element->popoverTarget($targetId);
- * $element->popoverTarget(null);
- * ```
- *
- * @param string|Stringable|UnitEnum|null $value Popover target ID, or `null` to remove the attribute.
- *
- * @return static New instance with the updated `popovertarget` attribute.
- */
- public function popoverTarget(string|Stringable|UnitEnum|null $value): static
- {
- return $this->setAttribute(ElementAttribute::POPOVERTARGET, $value);
- }
-}
diff --git a/src/Element/HasPopoverTargetAction.php b/src/Element/HasPopoverTargetAction.php
deleted file mode 100644
index 1a3baf0..0000000
--- a/src/Element/HasPopoverTargetAction.php
+++ /dev/null
@@ -1,47 +0,0 @@
-popoverTargetAction('toggle');
- * $element->popoverTargetAction($action);
- * $element->popoverTargetAction(null);
- * ```
- *
- * @param string|Stringable|UnitEnum|null $value Popover target action (`hide`, `show`, `toggle`), or `null` to
- * remove the attribute.
- *
- * @throws InvalidArgumentException If the provided value is not valid.
- *
- * @return static New instance with the updated `popovertargetaction` attribute.
- */
- public function popoverTargetAction(string|Stringable|UnitEnum|null $value): static
- {
- Validator::oneOf($value, PopoverTargetAction::cases(), ElementAttribute::POPOVERTARGETACTION);
-
- return $this->setAttribute(ElementAttribute::POPOVERTARGETACTION, $value);
- }
-}
diff --git a/src/Element/HasReferrerpolicy.php b/src/Element/HasReferrerpolicy.php
deleted file mode 100644
index 856a9e5..0000000
--- a/src/Element/HasReferrerpolicy.php
+++ /dev/null
@@ -1,53 +0,0 @@
-referrerpolicy('origin');
- * $element->referrerpolicy(Referrerpolicy::NO_REFERRER);
- * $element->referrerpolicy(null);
- * ```
- *
- * @param string|Stringable|UnitEnum|null $value Referrer policy token, or `null` to remove the attribute.
- *
- * @throws InvalidArgumentException If the value is not valid.
- *
- * @return static New instance with the updated `referrerpolicy` attribute.
- *
- * {@see Referrerpolicy} for predefined enum values.
- */
- public function referrerpolicy(string|Stringable|UnitEnum|null $value): static
- {
- Validator::oneOf($value, Referrerpolicy::cases(), ElementAttribute::REFERRERPOLICY);
-
- return $this->setAttribute(ElementAttribute::REFERRERPOLICY, $value);
- }
-}
diff --git a/src/Element/HasSrc.php b/src/Element/HasSrc.php
deleted file mode 100644
index 46b4c81..0000000
--- a/src/Element/HasSrc.php
+++ /dev/null
@@ -1,40 +0,0 @@
-src('https://example.com/image.png');
- * $element->src('images/photo.jpg');
- * $element->src(null);
- * ```
- *
- * @param string|Stringable|UnitEnum|null $value Image source URL or path, or `null` to remove the attribute.
- *
- * @return static New instance with the updated `src` attribute.
- */
- public function src(string|Stringable|UnitEnum|null $value): static
- {
- return $this->setAttribute(ElementAttribute::SRC, $value);
- }
-}
diff --git a/src/Element/HasSrcset.php b/src/Element/HasSrcset.php
deleted file mode 100644
index 1b436d6..0000000
--- a/src/Element/HasSrcset.php
+++ /dev/null
@@ -1,42 +0,0 @@
-srcset('small.jpg 480w, medium.jpg 800w, large.jpg 1200w');
- * $element->srcset('image-1x.jpg 1x, image-2x.jpg 2x');
- * $element->srcset(null);
- * ```
- *
- * @param string|Stringable|UnitEnum|null $value Comma-separated image URLs with size descriptors, or `null` to
- * remove the attribute.
- *
- * @return static New instance with the updated `srcset` attribute.
- */
- public function srcset(string|Stringable|UnitEnum|null $value): static
- {
- return $this->setAttribute('srcset', $value);
- }
-}
diff --git a/src/Element/HasUsemap.php b/src/Element/HasUsemap.php
deleted file mode 100644
index 05db080..0000000
--- a/src/Element/HasUsemap.php
+++ /dev/null
@@ -1,40 +0,0 @@
-usemap('#imagemap');
- * $element->usemap(null);
- * ```
- *
- * @param string|Stringable|UnitEnum|null $value Hash-name reference to a `map` element, or `null` to remove the
- * attribute.
- *
- * @return static New instance with the updated `usemap` attribute.
- */
- public function usemap(string|Stringable|UnitEnum|null $value): static
- {
- return $this->setAttribute(ElementAttribute::USEMAP, $value);
- }
-}
diff --git a/src/Element/HasWidth.php b/src/Element/HasWidth.php
deleted file mode 100644
index 8eda341..0000000
--- a/src/Element/HasWidth.php
+++ /dev/null
@@ -1,43 +0,0 @@
-width(400);
- * $element->width('50%');
- * $element->width('auto');
- * $element->width(null);
- * ```
- *
- * @param int|string|Stringable|UnitEnum|null $value Width value in pixels or CSS units, or `null` to remove the
- * attribute.
- *
- * @return static New instance with the updated `width` attribute.
- */
- public function width(int|string|Stringable|UnitEnum|null $value): static
- {
- return $this->setAttribute(ElementAttribute::WIDTH, $value);
- }
-}
diff --git a/src/Exception/Message.php b/src/Exception/Message.php
index 0f8a99e..83fac49 100644
--- a/src/Exception/Message.php
+++ b/src/Exception/Message.php
@@ -9,7 +9,7 @@
/**
* Represents error message templates for attribute exceptions.
*
- * Use {@see Message::getMessage()} to format the template with `sprintf()` arguments.
+ * Use {@see Message::getMessage()} to format the template with {@see sprintf()} arguments.
*
* @copyright Copyright (C) 2025 Terabytesoftw.
* @license https://opensource.org/license/bsd-3-clause BSD 3-Clause License.
@@ -24,7 +24,7 @@ enum Message: string
case ATTRIBUTE_INVALID_VALUE = "Invalid value '%s' for attribute '%s'. Expected: '%s'.";
/**
- * Error when an attribute value is not a `scalar` or `Closure`.
+ * Error when an attribute value is not a scalar or Closure.
*
* Format: "Attribute value must be of type 'scalar' or 'Closure', '%s' given."
*/
diff --git a/src/Form/CanBeChecked.php b/src/Form/CanBeChecked.php
deleted file mode 100644
index 2b64edd..0000000
--- a/src/Form/CanBeChecked.php
+++ /dev/null
@@ -1,38 +0,0 @@
-checked(true);
- * $element->checked(null);
- * ```
- *
- * @param bool|null $value Checked state. Use `true` to check, `false` to uncheck, or `null` to remove the
- * attribute.
- *
- * @return static New instance with the updated `checked` attribute.
- */
- public function checked(bool|null $value): static
- {
- return $this->setAttribute(Attribute::CHECKED, $value);
- }
-}
diff --git a/src/Form/CanBeMultiple.php b/src/Form/CanBeMultiple.php
deleted file mode 100644
index 0d6a77e..0000000
--- a/src/Form/CanBeMultiple.php
+++ /dev/null
@@ -1,38 +0,0 @@
-multiple(true);
- * $element->multiple(null);
- * ```
- *
- * @param bool|null $value Multiple state. Use `true` to allow multiple values, `false` to disallow, or `null` to
- * remove the attribute.
- *
- * @return static New instance with the updated `multiple` attribute.
- */
- public function multiple(bool|null $value): static
- {
- return $this->setAttribute(Attribute::MULTIPLE, $value);
- }
-}
diff --git a/src/Form/CanBeReadonly.php b/src/Form/CanBeReadonly.php
deleted file mode 100644
index 9a14232..0000000
--- a/src/Form/CanBeReadonly.php
+++ /dev/null
@@ -1,38 +0,0 @@
-readonly(true);
- * $element->readonly(null);
- * ```
- *
- * @param bool|null $value Readonly state. Use `true` to make readonly, `false` to make editable, or `null` to
- * remove the attribute.
- *
- * @return static New instance with the updated `readonly` attribute.
- */
- public function readonly(bool|null $value): static
- {
- return $this->setAttribute(Attribute::READONLY, $value);
- }
-}
diff --git a/src/Form/CanBeRequired.php b/src/Form/CanBeRequired.php
deleted file mode 100644
index c8c71e0..0000000
--- a/src/Form/CanBeRequired.php
+++ /dev/null
@@ -1,38 +0,0 @@
-required(true);
- * $element->required(null);
- * ```
- *
- * @param bool|null $value Required state. Use `true` to require a value, `false` to make it optional, or `null` to
- * remove the attribute.
- *
- * @return static New instance with the updated `required` attribute.
- */
- public function required(bool|null $value): static
- {
- return $this->setAttribute(Attribute::REQUIRED, $value);
- }
-}
diff --git a/src/Form/HasAccept.php b/src/Form/HasAccept.php
deleted file mode 100644
index 93effa5..0000000
--- a/src/Form/HasAccept.php
+++ /dev/null
@@ -1,41 +0,0 @@
-accept('image/*');
- * $element->accept('.jpg,.png,.pdf');
- * $element->accept('image/jpeg,application/pdf');
- * $element->accept(null);
- * ```
- *
- * @param string|Stringable|UnitEnum|null $value Accept value, or `null` to remove the attribute.
- *
- * @return static New instance with the updated `accept` attribute.
- */
- public function accept(string|Stringable|UnitEnum|null $value): static
- {
- return $this->setAttribute(Attribute::ACCEPT, $value);
- }
-}
diff --git a/src/Form/HasAutocomplete.php b/src/Form/HasAutocomplete.php
deleted file mode 100644
index 72197c0..0000000
--- a/src/Form/HasAutocomplete.php
+++ /dev/null
@@ -1,41 +0,0 @@
-autocomplete('on');
- * $element->autocomplete('email');
- * $element->autocomplete('new-password');
- * $element->autocomplete(null);
- * ```
- *
- * @param string|Stringable|UnitEnum|null $value Autocomplete value, or `null` to remove the attribute.
- *
- * @return static New instance with the updated `autocomplete` attribute.
- */
- public function autocomplete(string|Stringable|UnitEnum|null $value): static
- {
- return $this->setAttribute(Attribute::AUTOCOMPLETE, $value);
- }
-}
diff --git a/src/Form/HasDirname.php b/src/Form/HasDirname.php
deleted file mode 100644
index 11935cc..0000000
--- a/src/Form/HasDirname.php
+++ /dev/null
@@ -1,40 +0,0 @@
-dirname('comment-dir');
- * $element->dirname('text-direction');
- * $element->dirname(null);
- * ```
- *
- * @param string|Stringable|UnitEnum|null $value Dirname value, or `null` to remove the attribute.
- *
- * @return static New instance with the updated `dirname` attribute.
- */
- public function dirname(string|Stringable|UnitEnum|null $value): static
- {
- return $this->setAttribute(Attribute::DIRNAME, $value);
- }
-}
diff --git a/src/Form/HasForm.php b/src/Form/HasForm.php
deleted file mode 100644
index 9d27165..0000000
--- a/src/Form/HasForm.php
+++ /dev/null
@@ -1,40 +0,0 @@
-form('myForm');
- * $element->form($formId);
- * $element->form(null);
- * ```
- *
- * @param string|Stringable|UnitEnum|null $value Form ID, or `null` to remove the attribute.
- *
- * @return static New instance with the updated `form` attribute.
- */
- public function form(string|Stringable|UnitEnum|null $value): static
- {
- return $this->setAttribute(Attribute::FORM, $value);
- }
-}
diff --git a/src/Form/HasList.php b/src/Form/HasList.php
deleted file mode 100644
index 519dcea..0000000
--- a/src/Form/HasList.php
+++ /dev/null
@@ -1,40 +0,0 @@
-list('suggestions');
- * $element->list('countries-list');
- * $element->list(null);
- * ```
- *
- * @param string|Stringable|UnitEnum|null $value Datalist ID, or `null` to remove the attribute.
- *
- * @return static New instance with the updated `list` attribute.
- */
- public function list(string|Stringable|UnitEnum|null $value): static
- {
- return $this->setAttribute(Attribute::LIST, $value);
- }
-}
diff --git a/src/Form/HasMax.php b/src/Form/HasMax.php
deleted file mode 100644
index bc3ee41..0000000
--- a/src/Form/HasMax.php
+++ /dev/null
@@ -1,41 +0,0 @@
-max(100);
- * $element->max('2024-12-31');
- * $element->max('23:59');
- * $element->max(null);
- * ```
- *
- * @param float|int|string|Stringable|UnitEnum|null $value Maximum value, or `null` to remove the attribute.
- *
- * @return static New instance with the updated `max` attribute.
- */
- public function max(float|int|string|Stringable|UnitEnum|null $value): static
- {
- return $this->setAttribute(Attribute::MAX, $value);
- }
-}
diff --git a/src/Form/HasMaxlength.php b/src/Form/HasMaxlength.php
deleted file mode 100644
index 5b3f3df..0000000
--- a/src/Form/HasMaxlength.php
+++ /dev/null
@@ -1,60 +0,0 @@
-maxlength(50);
- * $element->maxlength(255);
- * $element->maxlength(null);
- * ```
- *
- * @param int|string|Stringable|UnitEnum|null $value Maximum length. Must be `>= 0`, or `null` to remove the
- * attribute.
- *
- * @throws InvalidArgumentException if the value is not an integer-like value `>= 0`.
- *
- * @return static New instance with the updated `maxlength` attribute.
- */
- public function maxlength(int|string|Stringable|UnitEnum|null $value): static
- {
- if ($value instanceof UnitEnum) {
- $value = Enum::normalizeValue($value);
- }
-
- if ($value !== null && Validator::intLike($value) === false) {
- throw new InvalidArgumentException(
- Message::ATTRIBUTE_INVALID_VALUE->getMessage(
- (string) $value,
- Attribute::MAXLENGTH->value,
- 'value >= 0',
- ),
- );
- }
-
- return $this->setAttribute(Attribute::MAXLENGTH, $value);
- }
-}
diff --git a/src/Form/HasMin.php b/src/Form/HasMin.php
deleted file mode 100644
index d974d4f..0000000
--- a/src/Form/HasMin.php
+++ /dev/null
@@ -1,41 +0,0 @@
-min(0);
- * $element->min('2024-01-01');
- * $element->min('08:00');
- * $element->min(null);
- * ```
- *
- * @param float|int|string|Stringable|UnitEnum|null $value Minimum value, or `null` to remove the attribute.
- *
- * @return static New instance with the updated `min` attribute.
- */
- public function min(float|int|string|Stringable|UnitEnum|null $value): static
- {
- return $this->setAttribute(Attribute::MIN, $value);
- }
-}
diff --git a/src/Form/HasMinlength.php b/src/Form/HasMinlength.php
deleted file mode 100644
index 5e20cfe..0000000
--- a/src/Form/HasMinlength.php
+++ /dev/null
@@ -1,60 +0,0 @@
-minlength(3);
- * $element->minlength(8);
- * $element->minlength(null);
- * ```
- *
- * @param int|string|Stringable|UnitEnum|null $value Minimum length. Must be `>= 0`, or `null` to remove the
- * attribute.
- *
- * @throws InvalidArgumentException if the value is not an integer-like value `>= 0`.
- *
- * @return static New instance with the updated `minlength` attribute.
- */
- public function minlength(int|string|Stringable|UnitEnum|null $value): static
- {
- if ($value instanceof UnitEnum) {
- $value = Enum::normalizeValue($value);
- }
-
- if ($value !== null && Validator::intLike($value) === false) {
- throw new InvalidArgumentException(
- Message::ATTRIBUTE_INVALID_VALUE->getMessage(
- (string) $value,
- Attribute::MINLENGTH->value,
- 'value >= 0',
- ),
- );
- }
-
- return $this->setAttribute(Attribute::MINLENGTH, $value);
- }
-}
diff --git a/src/Form/HasPattern.php b/src/Form/HasPattern.php
deleted file mode 100644
index d601eab..0000000
--- a/src/Form/HasPattern.php
+++ /dev/null
@@ -1,40 +0,0 @@
-pattern('[0-9]{3}-[0-9]{2}-[0-9]{4}');
- * $element->pattern('[a-z]+');
- * $element->pattern(null);
- * ```
- *
- * @param string|Stringable|UnitEnum|null $value Pattern value, or `null` to remove the attribute.
- *
- * @return static New instance with the updated `pattern` attribute.
- */
- public function pattern(string|Stringable|UnitEnum|null $value): static
- {
- return $this->setAttribute(Attribute::PATTERN, $value);
- }
-}
diff --git a/src/Form/HasPlaceholder.php b/src/Form/HasPlaceholder.php
deleted file mode 100644
index 0839cac..0000000
--- a/src/Form/HasPlaceholder.php
+++ /dev/null
@@ -1,40 +0,0 @@
-placeholder('Enter your email');
- * $element->placeholder('for example, John Doe');
- * $element->placeholder(null);
- * ```
- *
- * @param string|Stringable|UnitEnum|null $value Placeholder text, or `null` to remove the attribute.
- *
- * @return static New instance with the updated `placeholder` attribute.
- */
- public function placeholder(string|Stringable|UnitEnum|null $value): static
- {
- return $this->setAttribute(Attribute::PLACEHOLDER, $value);
- }
-}
diff --git a/src/Form/HasSize.php b/src/Form/HasSize.php
deleted file mode 100644
index cde284c..0000000
--- a/src/Form/HasSize.php
+++ /dev/null
@@ -1,59 +0,0 @@
-size(10);
- * $element->size(50);
- * $element->size(null);
- * ```
- *
- * @param int|string|Stringable|UnitEnum|null $value Size value. Must be `>= 0`, or `null` to remove the attribute.
- *
- * @throws InvalidArgumentException if the value is not an integer-like value `>= 0`.
- *
- * @return static New instance with the updated `size` attribute.
- */
- public function size(int|string|Stringable|UnitEnum|null $value): static
- {
- if ($value instanceof UnitEnum) {
- $value = Enum::normalizeValue($value);
- }
-
- if ($value !== null && Validator::intLike($value) === false) {
- throw new InvalidArgumentException(
- Message::ATTRIBUTE_INVALID_VALUE->getMessage(
- (string) $value,
- Attribute::SIZE->value,
- 'value >= 0',
- ),
- );
- }
-
- return $this->setAttribute(Attribute::SIZE, $value);
- }
-}
diff --git a/src/Form/HasStep.php b/src/Form/HasStep.php
deleted file mode 100644
index 5e56b14..0000000
--- a/src/Form/HasStep.php
+++ /dev/null
@@ -1,42 +0,0 @@
-step(1);
- * $element->step(0.5);
- * $element->step('any');
- * $element->step(null);
- * ```
- *
- * @param float|int|string|Stringable|UnitEnum|null $value Step value. Use `any` for no stepping restriction, or
- * `null` to remove the attribute.
- *
- * @return static New instance with the updated `step` attribute.
- */
- public function step(float|int|string|Stringable|UnitEnum|null $value): static
- {
- return $this->setAttribute(Attribute::STEP, $value);
- }
-}
diff --git a/src/Global/CanBeAutofocus.php b/src/Global/CanBeAutofocus.php
index 8c7cf52..cae5d2f 100644
--- a/src/Global/CanBeAutofocus.php
+++ b/src/Global/CanBeAutofocus.php
@@ -32,6 +32,6 @@ trait CanBeAutofocus
*/
public function autofocus(bool|null $value): static
{
- return $this->setAttribute(GlobalAttribute::AUTOFOCUS, $value);
+ return $this->addAttribute(GlobalAttribute::AUTOFOCUS, $value);
}
}
diff --git a/src/Global/CanBeHidden.php b/src/Global/CanBeHidden.php
index 6cb57e1..c49b0bb 100644
--- a/src/Global/CanBeHidden.php
+++ b/src/Global/CanBeHidden.php
@@ -33,6 +33,6 @@ trait CanBeHidden
*/
public function hidden(bool|null $value): static
{
- return $this->setAttribute(GlobalAttribute::HIDDEN, $value);
+ return $this->addAttribute(GlobalAttribute::HIDDEN, $value);
}
}
diff --git a/src/Global/HasAccesskey.php b/src/Global/HasAccesskey.php
index 4278817..50d176e 100644
--- a/src/Global/HasAccesskey.php
+++ b/src/Global/HasAccesskey.php
@@ -34,6 +34,6 @@ trait HasAccesskey
*/
public function accesskey(string|Stringable|UnitEnum|null $value): static
{
- return $this->setAttribute(GlobalAttribute::ACCESSKEY, $value);
+ return $this->addAttribute(GlobalAttribute::ACCESSKEY, $value);
}
}
diff --git a/src/Global/HasAria.php b/src/Global/HasAria.php
index e7e5a44..d776534 100644
--- a/src/Global/HasAria.php
+++ b/src/Global/HasAria.php
@@ -7,6 +7,7 @@
use Closure;
use InvalidArgumentException;
use Stringable;
+use UIAwesome\Html\Helper\AttributeBag;
use UnitEnum;
/**
@@ -35,20 +36,18 @@ trait HasAria
* ```
*
* @param string|UnitEnum $key Aria attribute key without the `aria-` prefix.
- * @param bool|Closure|float|int|string|Stringable|UnitEnum|null $value Aria attribute value, or `null` to remove
- * the attribute.
+ * @param bool|Closure(): mixed|float|int|string|Stringable|UnitEnum|null $value Aria attribute value, or `null` to
+ * remove the attribute.
*
* @throws InvalidArgumentException if one or more arguments are invalid, of incorrect type or format.
*
* @return static New instance with the updated `aria-*` attribute.
- *
- * @phpstan-param scalar|Stringable|UnitEnum|Closure(): mixed $value
*/
public function addAriaAttribute(
string|UnitEnum $key,
bool|float|int|string|Closure|Stringable|UnitEnum|null $value,
): static {
- return $this->setAttribute($key, $value, 'aria-');
+ return $this->addAttribute(AttributeBag::normalizeKey($key, 'aria-'), $value);
}
/**
@@ -70,18 +69,22 @@ public function addAriaAttribute(
* );
* ```
*
- * @param array $values Associative array of aria keys and values. Values may be scalar, `Stringable`, `UnitEnum`,
- * `Closure`, or `null` to remove the attribute.
+ * @param mixed[] $values Associative array of aria keys and values. Values may be scalar, Stringable, UnitEnum,
+ * Closure, or `null` to remove the attribute.
*
* @throws InvalidArgumentException if one or more arguments are invalid, of incorrect type or format.
*
* @return static New instance with the updated `aria-*` attributes.
- *
- * @phpstan-param mixed[] $values
*/
public function ariaAttributes(array $values): static
{
- return $this->attributes($values, 'aria-');
+ $new = $this;
+
+ foreach ($values as $key => $value) {
+ $new = $new->addAttribute(AttributeBag::normalizeKey($key, 'aria-'), $value);
+ }
+
+ return $new;
}
/**
@@ -99,6 +102,6 @@ public function ariaAttributes(array $values): static
*/
public function removeAriaAttribute(string|UnitEnum $key): static
{
- return $this->removeAttribute($key, 'aria-');
+ return $this->addAttribute(AttributeBag::normalizeKey($key, 'aria-'), null);
}
}
diff --git a/src/Global/HasAutocapitalize.php b/src/Global/HasAutocapitalize.php
index 789d268..86c84f6 100644
--- a/src/Global/HasAutocapitalize.php
+++ b/src/Global/HasAutocapitalize.php
@@ -29,8 +29,8 @@ trait HasAutocapitalize
* $element->autocapitalize(\UIAwesome\Html\Attribute\Values\Autocapitalize::SENTENCES)->render();
* ```
*
- * @param string|UnitEnum|null $value Capitalization behavior (`none`, `off`, `sentences`, `on`, `words`,
- * `characters`), or `null` to remove the attribute.
+ * @param string|UnitEnum|null $value Capitalization behavior ('none', 'off', 'sentences', 'on', 'words',
+ * 'characters'), or `null` to remove the attribute.
*
* @throws InvalidArgumentException if the provided value is not valid.
*
@@ -42,6 +42,6 @@ public function autocapitalize(string|UnitEnum|null $value): static
{
Validator::oneOf($value, Autocapitalize::cases(), 'autocapitalize');
- return $this->setAttribute('autocapitalize', $value);
+ return $this->addAttribute('autocapitalize', $value);
}
}
diff --git a/src/Global/HasAutocorrect.php b/src/Global/HasAutocorrect.php
index d1e4692..6ca65bf 100644
--- a/src/Global/HasAutocorrect.php
+++ b/src/Global/HasAutocorrect.php
@@ -29,7 +29,7 @@ trait HasAutocorrect
* $element->autocorrect(\UIAwesome\Html\Attribute\Values\Autocorrect::ON)->render();
* ```
*
- * @param string|UnitEnum|null $value Autocorrect behavior (`on` or `off`), or `null` to remove the attribute.
+ * @param string|UnitEnum|null $value Autocorrect behavior ('on' or 'off'), or `null` to remove the attribute.
*
* @throws InvalidArgumentException if the provided value is not valid.
*
@@ -41,6 +41,6 @@ public function autocorrect(string|UnitEnum|null $value): static
{
Validator::oneOf($value, Autocorrect::cases(), 'autocorrect');
- return $this->setAttribute('autocorrect', $value);
+ return $this->addAttribute('autocorrect', $value);
}
}
diff --git a/src/Global/HasContentEditable.php b/src/Global/HasContentEditable.php
index 0ac5fff..c59a5fe 100644
--- a/src/Global/HasContentEditable.php
+++ b/src/Global/HasContentEditable.php
@@ -32,7 +32,7 @@ trait HasContentEditable
* $element->contentEditable(ContentEditable::TRUE);
* ```
*
- * @param bool|string|UnitEnum|null $value Content editability value. Use `true`, `false`, or `plaintext-only`, or
+ * @param bool|string|UnitEnum|null $value Content editability value. Use `true`, `false`, or 'plaintext-only', or
* `null` to remove the attribute.
*
* @throws InvalidArgumentException If the value is not valid.
@@ -49,6 +49,6 @@ public function contentEditable(bool|string|UnitEnum|null $value): static
Validator::oneOf($value, ContentEditable::cases(), GlobalAttribute::CONTENTEDITABLE);
- return $this->setAttribute(GlobalAttribute::CONTENTEDITABLE, $value);
+ return $this->addAttribute(GlobalAttribute::CONTENTEDITABLE, $value);
}
}
diff --git a/src/Global/HasData.php b/src/Global/HasData.php
index 67798e2..c365a66 100644
--- a/src/Global/HasData.php
+++ b/src/Global/HasData.php
@@ -7,6 +7,7 @@
use Closure;
use InvalidArgumentException;
use Stringable;
+use UIAwesome\Html\Helper\AttributeBag;
use UnitEnum;
/**
@@ -33,20 +34,18 @@ trait HasData
* ```
*
* @param string|UnitEnum $key Data attribute key without the `data-` prefix.
- * @param bool|Closure|float|int|string|Stringable|UnitEnum|null $value Data attribute value, or `null` to remove
- * the attribute.
+ * @param bool|Closure(): mixed|float|int|string|Stringable|UnitEnum|null $value Data attribute value, or `null` to
+ * remove the attribute.
*
* @throws InvalidArgumentException if one or more arguments are invalid, of incorrect type or format.
*
* @return static New instance with the updated `data-*` attribute.
- *
- * @phpstan-param scalar|Stringable|UnitEnum|Closure(): mixed $value
*/
public function addDataAttribute(
string|UnitEnum $key,
bool|float|int|string|Closure|Stringable|UnitEnum|null $value,
): static {
- return $this->setAttribute($key, $value, 'data-');
+ return $this->addAttribute(AttributeBag::normalizeKey($key, 'data-'), $value);
}
/**
@@ -67,18 +66,22 @@ public function addDataAttribute(
* );
* ```
*
- * @param array $values Associative array of data keys and values. Values may be scalar, `Stringable`, `UnitEnum`,
- * `Closure`, or `null` to remove the attribute.
+ * @param mixed[] $values Associative array of data keys and values. Values may be scalar, Stringable, UnitEnum,
+ * Closure, or `null` to remove the attribute.
*
* @throws InvalidArgumentException if one or more arguments are invalid, of incorrect type or format.
*
* @return static New instance with the updated `data-*` attributes.
- *
- * @phpstan-param mixed[] $values
*/
public function dataAttributes(array $values): static
{
- return $this->attributes($values, 'data-');
+ $new = $this;
+
+ foreach ($values as $key => $value) {
+ $new = $new->addAttribute(AttributeBag::normalizeKey($key, 'data-'), $value);
+ }
+
+ return $new;
}
/**
@@ -96,6 +99,6 @@ public function dataAttributes(array $values): static
*/
public function removeDataAttribute(string|UnitEnum $key): static
{
- return $this->removeAttribute($key, 'data-');
+ return $this->addAttribute(AttributeBag::normalizeKey($key, 'data-'), null);
}
}
diff --git a/src/Global/HasDir.php b/src/Global/HasDir.php
index 2077a28..67d6543 100644
--- a/src/Global/HasDir.php
+++ b/src/Global/HasDir.php
@@ -30,7 +30,7 @@ trait HasDir
* $element->dir(Direction::AUTO);
* ```
*
- * @param string|UnitEnum|null $value Directionality value. Use `ltr`, `rtl`, or `auto`, or `null` to remove the
+ * @param string|UnitEnum|null $value Directionality value. Use 'ltr', 'rtl', or 'auto', or `null` to remove the
* attribute.
*
* @throws InvalidArgumentException If the value is not valid.
@@ -43,6 +43,6 @@ public function dir(string|UnitEnum|null $value): static
{
Validator::oneOf($value, Direction::cases(), GlobalAttribute::DIR);
- return $this->setAttribute(GlobalAttribute::DIR, $value);
+ return $this->addAttribute(GlobalAttribute::DIR, $value);
}
}
diff --git a/src/Global/HasDraggable.php b/src/Global/HasDraggable.php
index 6d946d8..557c527 100644
--- a/src/Global/HasDraggable.php
+++ b/src/Global/HasDraggable.php
@@ -48,6 +48,6 @@ public function draggable(bool|string|UnitEnum|null $value): static
Validator::oneOf($value, Draggable::cases(), GlobalAttribute::DRAGGABLE);
- return $this->setAttribute(GlobalAttribute::DRAGGABLE, $value);
+ return $this->addAttribute(GlobalAttribute::DRAGGABLE, $value);
}
}
diff --git a/src/Global/HasEvents.php b/src/Global/HasEvents.php
index 11a1c83..d71fcb1 100644
--- a/src/Global/HasEvents.php
+++ b/src/Global/HasEvents.php
@@ -7,6 +7,7 @@
use Closure;
use InvalidArgumentException;
use Stringable;
+use UIAwesome\Html\Helper\AttributeBag;
use UnitEnum;
/**
@@ -32,17 +33,16 @@ trait HasEvents
* ```
*
* @param string|UnitEnum $key Event attribute key with or without the leading `on` prefix.
- * @param Closure|string|Stringable|UnitEnum|null $value JavaScript handler code, or `null` to remove the attribute.
+ * @param Closure(): mixed|string|Stringable|UnitEnum|null $value JavaScript handler code, or `null` to remove the
+ * attribute.
*
* @throws InvalidArgumentException if one or more arguments are invalid, of incorrect type or format.
*
* @return static New instance with the updated `on*` event attribute.
- *
- * @phpstan-param Closure(): mixed|string|Stringable|UnitEnum|null $value
*/
public function addEvent(string|UnitEnum $key, string|Closure|Stringable|UnitEnum|null $value): static
{
- return $this->setAttribute($key, $value, 'on');
+ return $this->addAttribute(AttributeBag::normalizeKey($key, 'on'), $value);
}
/**
@@ -58,18 +58,22 @@ public function addEvent(string|UnitEnum $key, string|Closure|Stringable|UnitEnu
* );
* ```
*
- * @param array $values Associative array of event keys and handlers. Values may be `Stringable`, `Closure`,
- * `string`, or `null` to remove the attribute.
+ * @param mixed[] $values Associative array of event keys and handlers. Values may be Stringable, Closure, string,
+ * or `null` to remove the attribute.
*
* @throws InvalidArgumentException if one or more arguments are invalid, of incorrect type or format.
*
* @return static New instance with the updated `on*` event attributes.
- *
- * @phpstan-param mixed[] $values
*/
public function events(array $values): static
{
- return $this->attributes($values, 'on');
+ $new = $this;
+
+ foreach ($values as $key => $value) {
+ $new = $new->addAttribute(AttributeBag::normalizeKey($key, 'on'), $value);
+ }
+
+ return $new;
}
/**
@@ -89,6 +93,6 @@ public function events(array $values): static
*/
public function removeEvent(string|UnitEnum $key): static
{
- return $this->removeAttribute($key, 'on');
+ return $this->addAttribute(AttributeBag::normalizeKey($key, 'on'), null);
}
}
diff --git a/src/Global/HasId.php b/src/Global/HasId.php
index 2fb9de1..c015634 100644
--- a/src/Global/HasId.php
+++ b/src/Global/HasId.php
@@ -34,6 +34,6 @@ trait HasId
*/
public function id(string|Stringable|UnitEnum|null $value): static
{
- return $this->setAttribute(GlobalAttribute::ID, $value);
+ return $this->addAttribute(GlobalAttribute::ID, $value);
}
}
diff --git a/src/Global/HasInputMode.php b/src/Global/HasInputMode.php
index c41cc36..7939114 100644
--- a/src/Global/HasInputMode.php
+++ b/src/Global/HasInputMode.php
@@ -29,8 +29,8 @@ trait HasInputMode
* $element->inputMode('numeric');
* ```
*
- * @param string|UnitEnum|null $value Input mode value (`decimal`, `email`, `none`, `numeric`, `search`, `tel`,
- * `text`, `url`, or `null` to remove the attribute).
+ * @param string|UnitEnum|null $value Input mode value ('decimal', 'email', 'none', 'numeric', 'search', 'tel',
+ * 'text', 'url', or `null` to remove the attribute).
*
* @throws InvalidArgumentException If the provided value is not valid.
*
@@ -40,6 +40,6 @@ public function inputMode(string|UnitEnum|null $value): static
{
Validator::oneOf($value, InputMode::cases(), GlobalAttribute::INPUTMODE);
- return $this->setAttribute(GlobalAttribute::INPUTMODE, $value);
+ return $this->addAttribute(GlobalAttribute::INPUTMODE, $value);
}
}
diff --git a/src/Global/HasLang.php b/src/Global/HasLang.php
index cb24370..d9234a5 100644
--- a/src/Global/HasLang.php
+++ b/src/Global/HasLang.php
@@ -43,6 +43,6 @@ public function lang(string|Stringable|UnitEnum|null $value): static
{
Validator::oneOf($value, Language::cases(), GlobalAttribute::LANG);
- return $this->setAttribute(GlobalAttribute::LANG, $value);
+ return $this->addAttribute(GlobalAttribute::LANG, $value);
}
}
diff --git a/src/Global/HasMicroData.php b/src/Global/HasMicroData.php
index 9a4ec21..2ea69ed 100644
--- a/src/Global/HasMicroData.php
+++ b/src/Global/HasMicroData.php
@@ -35,7 +35,7 @@ trait HasMicroData
*/
public function itemId(string|Stringable|UnitEnum|null $value): static
{
- return $this->setAttribute(GlobalAttribute::ITEMID, $value);
+ return $this->addAttribute(GlobalAttribute::ITEMID, $value);
}
/**
@@ -55,7 +55,7 @@ public function itemId(string|Stringable|UnitEnum|null $value): static
*/
public function itemProp(string|Stringable|UnitEnum|null $value): static
{
- return $this->setAttribute(GlobalAttribute::ITEMPROP, $value);
+ return $this->addAttribute(GlobalAttribute::ITEMPROP, $value);
}
/**
@@ -75,7 +75,7 @@ public function itemProp(string|Stringable|UnitEnum|null $value): static
*/
public function itemRef(string|Stringable|UnitEnum|null $value): static
{
- return $this->setAttribute(GlobalAttribute::ITEMREF, $value);
+ return $this->addAttribute(GlobalAttribute::ITEMREF, $value);
}
/**
@@ -95,7 +95,7 @@ public function itemRef(string|Stringable|UnitEnum|null $value): static
*/
public function itemScope(bool|null $value): static
{
- return $this->setAttribute(GlobalAttribute::ITEMSCOPE, $value);
+ return $this->addAttribute(GlobalAttribute::ITEMSCOPE, $value);
}
/**
@@ -115,6 +115,6 @@ public function itemScope(bool|null $value): static
*/
public function itemType(string|Stringable|UnitEnum|null $value): static
{
- return $this->setAttribute(GlobalAttribute::ITEMTYPE, $value);
+ return $this->addAttribute(GlobalAttribute::ITEMTYPE, $value);
}
}
diff --git a/src/Global/HasNonce.php b/src/Global/HasNonce.php
index ffa51bb..ae564be 100644
--- a/src/Global/HasNonce.php
+++ b/src/Global/HasNonce.php
@@ -34,6 +34,6 @@ trait HasNonce
*/
public function nonce(string|Stringable|UnitEnum|null $value): static
{
- return $this->setAttribute(GlobalAttribute::NONCE, $value);
+ return $this->addAttribute(GlobalAttribute::NONCE, $value);
}
}
diff --git a/src/Global/HasPopover.php b/src/Global/HasPopover.php
index e662b8e..ae911c0 100644
--- a/src/Global/HasPopover.php
+++ b/src/Global/HasPopover.php
@@ -29,7 +29,7 @@ trait HasPopover
* $element->popover(Popover::AUTO);
* ```
*
- * @param string|UnitEnum|null $value Popover state (`auto`, `hint`, `manual`), or `null` to remove the attribute.
+ * @param string|UnitEnum|null $value Popover state ('auto', 'hint', 'manual'), or `null` to remove the attribute.
*
* @throws InvalidArgumentException If the provided value is not valid.
*
@@ -41,6 +41,6 @@ public function popover(string|UnitEnum|null $value): static
{
Validator::oneOf($value, Popover::cases(), GlobalAttribute::POPOVER);
- return $this->setAttribute(GlobalAttribute::POPOVER, $value);
+ return $this->addAttribute(GlobalAttribute::POPOVER, $value);
}
}
diff --git a/src/Global/HasRole.php b/src/Global/HasRole.php
index ac6166b..432cce3 100644
--- a/src/Global/HasRole.php
+++ b/src/Global/HasRole.php
@@ -43,6 +43,6 @@ public function role(string|Stringable|UnitEnum|null $value): static
{
Validator::oneOf($value, Role::cases(), GlobalAttribute::ROLE);
- return $this->setAttribute(GlobalAttribute::ROLE, $value);
+ return $this->addAttribute(GlobalAttribute::ROLE, $value);
}
}
diff --git a/src/Global/HasSpellcheck.php b/src/Global/HasSpellcheck.php
index 5b2e9c8..6c2f1d2 100644
--- a/src/Global/HasSpellcheck.php
+++ b/src/Global/HasSpellcheck.php
@@ -44,6 +44,6 @@ public function spellcheck(bool|string|null $value): static
Validator::oneOf($value, ['false', 'true'], GlobalAttribute::SPELLCHECK);
- return $this->setAttribute(GlobalAttribute::SPELLCHECK, $value);
+ return $this->addAttribute(GlobalAttribute::SPELLCHECK, $value);
}
}
diff --git a/src/Global/HasStyle.php b/src/Global/HasStyle.php
index 69a774a..7769e07 100644
--- a/src/Global/HasStyle.php
+++ b/src/Global/HasStyle.php
@@ -43,15 +43,13 @@ trait HasStyle
* $element->style(null);
* ```
*
- * @param array|string|Stringable|UnitEnum|null $value Style value as a CSS `string`, an associative array of CSS
+ * @param mixed[]|string|Stringable|UnitEnum|null $value Style value as a CSS string, an associative array of CSS
* property-value pairs, or `null` to remove the attribute.
*
* @return static New instance with the updated `style` attribute.
- *
- * @phpstan-param mixed[]|string|Stringable|UnitEnum|null $value
*/
public function style(array|string|Stringable|UnitEnum|null $value): static
{
- return $this->setAttribute(GlobalAttribute::STYLE, $value);
+ return $this->addAttribute(GlobalAttribute::STYLE, $value);
}
}
diff --git a/src/Global/HasTabindex.php b/src/Global/HasTabindex.php
index 2bfddea..6db8205 100644
--- a/src/Global/HasTabindex.php
+++ b/src/Global/HasTabindex.php
@@ -30,11 +30,10 @@ trait HasTabindex
* $element->tabIndex(1);
* ```
*
- * @param int|string|null $value Tab order value as an `integer` or `string` of `-1` or greater, or `null` to remove
+ * @param int|string|null $value Tab order value as an integer or string of '-1' or greater, or `null` to remove
* the attribute.
*
- * @throws InvalidArgumentException if the value is not a valid `integer` or `string` representation of `-1` or
- * greater.
+ * @throws InvalidArgumentException if the value is not a valid integer or string representation of '-1' or greater.
* @return static New instance with the updated `tabindex` attribute.
*/
public function tabIndex(int|string|null $value): static
@@ -45,6 +44,6 @@ public function tabIndex(int|string|null $value): static
);
}
- return $this->setAttribute(GlobalAttribute::TABINDEX, $value);
+ return $this->addAttribute(GlobalAttribute::TABINDEX, $value);
}
}
diff --git a/src/Global/HasTitle.php b/src/Global/HasTitle.php
index 1e91cde..1aaa748 100644
--- a/src/Global/HasTitle.php
+++ b/src/Global/HasTitle.php
@@ -34,6 +34,6 @@ trait HasTitle
*/
public function title(string|Stringable|UnitEnum|null $value): static
{
- return $this->setAttribute(GlobalAttribute::TITLE, $value);
+ return $this->addAttribute(GlobalAttribute::TITLE, $value);
}
}
diff --git a/src/Global/HasTranslate.php b/src/Global/HasTranslate.php
index ae0216b..a6e2d94 100644
--- a/src/Global/HasTranslate.php
+++ b/src/Global/HasTranslate.php
@@ -31,7 +31,7 @@ trait HasTranslate
* $element->translate(Translate::NO);
* ```
*
- * @param bool|string|UnitEnum|null $value Translation behavior. Use `yes`, `no`, `true`, `false`, or `null` to
+ * @param bool|string|UnitEnum|null $value Translation behavior. Use 'yes', 'no', `true`, `false`, or `null` to
* remove the attribute.
*
* @throws InvalidArgumentException If the value is not valid.
@@ -54,6 +54,6 @@ public function translate(bool|string|UnitEnum|null $value): static
Validator::oneOf($value, Translate::cases(), GlobalAttribute::TRANSLATE);
- return $this->setAttribute(GlobalAttribute::TRANSLATE, $value);
+ return $this->addAttribute(GlobalAttribute::TRANSLATE, $value);
}
}
diff --git a/src/HasAs.php b/src/HasAs.php
index d6c7bf2..dc7ad98 100644
--- a/src/HasAs.php
+++ b/src/HasAs.php
@@ -6,7 +6,7 @@
use InvalidArgumentException;
use Stringable;
-use UIAwesome\Html\Attribute\Values\{AsValue, Attribute};
+use UIAwesome\Html\Attribute\Values\{AsValue, ElementAttribute};
use UIAwesome\Html\Helper\Validator;
use UnitEnum;
@@ -43,8 +43,8 @@ trait HasAs
*/
public function as(string|Stringable|UnitEnum|null $value): static
{
- Validator::oneOf($value, AsValue::cases(), Attribute::AS);
+ Validator::oneOf($value, AsValue::cases(), ElementAttribute::AS);
- return $this->setAttribute(Attribute::AS, $value);
+ return $this->addAttribute(ElementAttribute::AS, $value);
}
}
diff --git a/src/HasBlocking.php b/src/HasBlocking.php
index cede7ba..e30a92b 100644
--- a/src/HasBlocking.php
+++ b/src/HasBlocking.php
@@ -5,7 +5,7 @@
namespace UIAwesome\Html\Attribute;
use InvalidArgumentException;
-use UIAwesome\Html\Attribute\Values\{Attribute, Blocking};
+use UIAwesome\Html\Attribute\Values\{Blocking, ElementAttribute};
use UIAwesome\Html\Helper\Validator;
use UnitEnum;
@@ -42,8 +42,8 @@ trait HasBlocking
*/
public function blocking(string|UnitEnum|null $value): static
{
- Validator::oneOf($value, Blocking::cases(), Attribute::BLOCKING);
+ Validator::oneOf($value, Blocking::cases(), ElementAttribute::BLOCKING);
- return $this->setAttribute(Attribute::BLOCKING, $value);
+ return $this->addAttribute(ElementAttribute::BLOCKING, $value);
}
}
diff --git a/src/HasCharset.php b/src/HasCharset.php
index 458fba8..8e0c258 100644
--- a/src/HasCharset.php
+++ b/src/HasCharset.php
@@ -6,7 +6,7 @@
use InvalidArgumentException;
use Stringable;
-use UIAwesome\Html\Attribute\Values\{Attribute, Charset};
+use UIAwesome\Html\Attribute\Values\{Charset, ElementAttribute};
use UIAwesome\Html\Helper\Validator;
use UnitEnum;
@@ -43,8 +43,8 @@ trait HasCharset
*/
public function charset(string|Stringable|UnitEnum|null $value): static
{
- Validator::oneOf($value, Charset::cases(), Attribute::CHARSET);
+ Validator::oneOf($value, Charset::cases(), ElementAttribute::CHARSET);
- return $this->setAttribute(Attribute::CHARSET, $value);
+ return $this->addAttribute(ElementAttribute::CHARSET, $value);
}
}
diff --git a/src/HasContent.php b/src/HasContent.php
index 1eb5fed..094d2f7 100644
--- a/src/HasContent.php
+++ b/src/HasContent.php
@@ -37,6 +37,6 @@ trait HasContent
*/
public function content(string|Stringable|UnitEnum|null $value): static
{
- return $this->setAttribute(Attribute::CONTENT, $value);
+ return $this->addAttribute(Attribute::CONTENT, $value);
}
}
diff --git a/src/HasCrossorigin.php b/src/HasCrossorigin.php
index 44890d1..970ad98 100644
--- a/src/HasCrossorigin.php
+++ b/src/HasCrossorigin.php
@@ -44,6 +44,6 @@ public function crossorigin(string|UnitEnum|null $value): static
{
Validator::oneOf($value, Crossorigin::cases(), Attribute::CROSSORIGIN);
- return $this->setAttribute(Attribute::CROSSORIGIN, $value);
+ return $this->addAttribute(Attribute::CROSSORIGIN, $value);
}
}
diff --git a/src/HasDownload.php b/src/HasDownload.php
index 6185d83..a88728b 100644
--- a/src/HasDownload.php
+++ b/src/HasDownload.php
@@ -5,7 +5,7 @@
namespace UIAwesome\Html\Attribute;
use Stringable;
-use UIAwesome\Html\Attribute\Values\Attribute;
+use UIAwesome\Html\Attribute\Values\ElementAttribute;
use UnitEnum;
/**
@@ -40,6 +40,6 @@ trait HasDownload
*/
public function download(bool|string|Stringable|UnitEnum|null $value): static
{
- return $this->setAttribute(Attribute::DOWNLOAD, $value);
+ return $this->addAttribute(ElementAttribute::DOWNLOAD, $value);
}
}
diff --git a/src/HasFetchpriority.php b/src/HasFetchpriority.php
index 92a6d28..befcd61 100644
--- a/src/HasFetchpriority.php
+++ b/src/HasFetchpriority.php
@@ -44,6 +44,6 @@ public function fetchpriority(string|UnitEnum|null $value): static
{
Validator::oneOf($value, Fetchpriority::cases(), Attribute::FETCHPRIORITY);
- return $this->setAttribute(Attribute::FETCHPRIORITY, $value);
+ return $this->addAttribute(Attribute::FETCHPRIORITY, $value);
}
}
diff --git a/src/HasFor.php b/src/HasFor.php
index b9293bc..22df4e3 100644
--- a/src/HasFor.php
+++ b/src/HasFor.php
@@ -36,6 +36,6 @@ trait HasFor
*/
public function for(string|Stringable|UnitEnum|null $value): static
{
- return $this->setAttribute(Attribute::FOR, $value);
+ return $this->addAttribute(Attribute::FOR, $value);
}
}
diff --git a/src/HasHreflang.php b/src/HasHreflang.php
index 669094f..2954cef 100644
--- a/src/HasHreflang.php
+++ b/src/HasHreflang.php
@@ -5,7 +5,7 @@
namespace UIAwesome\Html\Attribute;
use Stringable;
-use UIAwesome\Html\Attribute\Values\Attribute;
+use UIAwesome\Html\Attribute\Values\ElementAttribute;
use UnitEnum;
/**
@@ -37,6 +37,6 @@ trait HasHreflang
*/
public function hreflang(string|Stringable|UnitEnum|null $value): static
{
- return $this->setAttribute(Attribute::HREFLANG, $value);
+ return $this->addAttribute(ElementAttribute::HREFLANG, $value);
}
}
diff --git a/src/HasHttpEquiv.php b/src/HasHttpEquiv.php
index 91550f4..f4eb2c3 100644
--- a/src/HasHttpEquiv.php
+++ b/src/HasHttpEquiv.php
@@ -6,7 +6,7 @@
use InvalidArgumentException;
use Stringable;
-use UIAwesome\Html\Attribute\Values\{Attribute, HttpEquiv};
+use UIAwesome\Html\Attribute\Values\{ElementAttribute, HttpEquiv};
use UIAwesome\Html\Helper\Validator;
use UnitEnum;
@@ -43,8 +43,8 @@ trait HasHttpEquiv
*/
public function httpEquiv(string|Stringable|UnitEnum|null $value): static
{
- Validator::oneOf($value, HttpEquiv::cases(), Attribute::HTTP_EQUIV);
+ Validator::oneOf($value, HttpEquiv::cases(), ElementAttribute::HTTP_EQUIV);
- return $this->setAttribute(Attribute::HTTP_EQUIV, $value);
+ return $this->addAttribute(ElementAttribute::HTTP_EQUIV, $value);
}
}
diff --git a/src/HasImagesizes.php b/src/HasImageSizes.php
similarity index 87%
rename from src/HasImagesizes.php
rename to src/HasImageSizes.php
index 4453d22..461ae3c 100644
--- a/src/HasImagesizes.php
+++ b/src/HasImageSizes.php
@@ -5,7 +5,7 @@
namespace UIAwesome\Html\Attribute;
use Stringable;
-use UIAwesome\Html\Attribute\Values\Attribute;
+use UIAwesome\Html\Attribute\Values\ElementAttribute;
use UnitEnum;
/**
@@ -17,7 +17,7 @@
* @copyright Copyright (C) 2026 Terabytesoftw.
* @license https://opensource.org/license/bsd-3-clause BSD 3-Clause License.
*/
-trait HasImagesizes
+trait HasImageSizes
{
/**
* Sets the `imagesizes` attribute.
@@ -37,6 +37,6 @@ trait HasImagesizes
*/
public function imagesizes(string|Stringable|UnitEnum|null $value): static
{
- return $this->setAttribute(Attribute::IMAGESIZES, $value);
+ return $this->addAttribute(ElementAttribute::IMAGESIZES, $value);
}
}
diff --git a/src/HasImagesrcset.php b/src/HasImageSrcSet.php
similarity index 87%
rename from src/HasImagesrcset.php
rename to src/HasImageSrcSet.php
index 063ba85..213e7a2 100644
--- a/src/HasImagesrcset.php
+++ b/src/HasImageSrcSet.php
@@ -5,7 +5,7 @@
namespace UIAwesome\Html\Attribute;
use Stringable;
-use UIAwesome\Html\Attribute\Values\Attribute;
+use UIAwesome\Html\Attribute\Values\ElementAttribute;
use UnitEnum;
/**
@@ -17,7 +17,7 @@
* @copyright Copyright (C) 2026 Terabytesoftw.
* @license https://opensource.org/license/bsd-3-clause BSD 3-Clause License.
*/
-trait HasImagesrcset
+trait HasImageSrcSet
{
/**
* Sets the `imagesrcset` attribute.
@@ -37,6 +37,6 @@ trait HasImagesrcset
*/
public function imagesrcset(string|Stringable|UnitEnum|null $value): static
{
- return $this->setAttribute(Attribute::IMAGESRCSET, $value);
+ return $this->addAttribute(ElementAttribute::IMAGESRCSET, $value);
}
}
diff --git a/src/HasIntegrity.php b/src/HasIntegrity.php
index d20176d..be52e16 100644
--- a/src/HasIntegrity.php
+++ b/src/HasIntegrity.php
@@ -37,6 +37,6 @@ trait HasIntegrity
*/
public function integrity(string|Stringable|UnitEnum|null $value): static
{
- return $this->setAttribute(Attribute::INTEGRITY, $value);
+ return $this->addAttribute(Attribute::INTEGRITY, $value);
}
}
diff --git a/src/HasLabel.php b/src/HasLabel.php
index 4cac77e..8ae242f 100644
--- a/src/HasLabel.php
+++ b/src/HasLabel.php
@@ -5,7 +5,7 @@
namespace UIAwesome\Html\Attribute;
use Stringable;
-use UIAwesome\Html\Attribute\Values\Attribute;
+use UIAwesome\Html\Attribute\Values\ElementAttribute;
use UnitEnum;
/**
@@ -34,6 +34,6 @@ trait HasLabel
*/
public function label(string|Stringable|UnitEnum|null $value): static
{
- return $this->setAttribute(Attribute::LABEL, $value);
+ return $this->addAttribute(ElementAttribute::LABEL, $value);
}
}
diff --git a/src/HasMedia.php b/src/HasMedia.php
index 0565243..94f8fcc 100644
--- a/src/HasMedia.php
+++ b/src/HasMedia.php
@@ -37,6 +37,6 @@ trait HasMedia
*/
public function media(string|Stringable|UnitEnum|null $value): static
{
- return $this->setAttribute(Attribute::MEDIA, $value);
+ return $this->addAttribute(Attribute::MEDIA, $value);
}
}
diff --git a/src/HasName.php b/src/HasName.php
index 2a25cb7..ed2ade9 100644
--- a/src/HasName.php
+++ b/src/HasName.php
@@ -5,7 +5,7 @@
namespace UIAwesome\Html\Attribute;
use Stringable;
-use UIAwesome\Html\Attribute\Values\Attribute;
+use UIAwesome\Html\Attribute\Values\ElementAttribute;
use UnitEnum;
/**
@@ -39,6 +39,6 @@ trait HasName
*/
public function name(string|Stringable|UnitEnum|null $value): static
{
- return $this->setAttribute(Attribute::NAME, $value);
+ return $this->addAttribute(ElementAttribute::NAME, $value);
}
}
diff --git a/src/HasPing.php b/src/HasPing.php
index eaeacd8..ed578fc 100644
--- a/src/HasPing.php
+++ b/src/HasPing.php
@@ -5,7 +5,7 @@
namespace UIAwesome\Html\Attribute;
use Stringable;
-use UIAwesome\Html\Attribute\Values\Attribute;
+use UIAwesome\Html\Attribute\Values\ElementAttribute;
use UnitEnum;
/**
@@ -37,6 +37,6 @@ trait HasPing
*/
public function ping(string|Stringable|UnitEnum|null $value): static
{
- return $this->setAttribute(Attribute::PING, $value);
+ return $this->addAttribute(ElementAttribute::PING, $value);
}
}
diff --git a/src/HasReferrerpolicy.php b/src/HasReferrerpolicy.php
index 8a4040d..ccf275d 100644
--- a/src/HasReferrerpolicy.php
+++ b/src/HasReferrerpolicy.php
@@ -45,6 +45,6 @@ public function referrerpolicy(string|Stringable|UnitEnum|null $value): static
{
Validator::oneOf($value, Referrerpolicy::cases(), Attribute::REFERRERPOLICY);
- return $this->setAttribute(Attribute::REFERRERPOLICY, $value);
+ return $this->addAttribute(Attribute::REFERRERPOLICY, $value);
}
}
diff --git a/src/HasRel.php b/src/HasRel.php
index 97924da..e29b4d3 100644
--- a/src/HasRel.php
+++ b/src/HasRel.php
@@ -45,6 +45,6 @@ public function rel(string|Stringable|UnitEnum|null $value): static
{
Validator::oneOf($value, Rel::cases(), Attribute::REL);
- return $this->setAttribute(Attribute::REL, $value);
+ return $this->addAttribute(Attribute::REL, $value);
}
}
diff --git a/src/HasSizes.php b/src/HasSizes.php
index 8ca6b34..6908e95 100644
--- a/src/HasSizes.php
+++ b/src/HasSizes.php
@@ -5,7 +5,7 @@
namespace UIAwesome\Html\Attribute;
use Stringable;
-use UIAwesome\Html\Attribute\Values\Attribute;
+use UIAwesome\Html\Attribute\Values\ElementAttribute;
use UnitEnum;
/**
@@ -31,12 +31,12 @@ trait HasSizes
* $element->sizes(null);
* ```
*
- * @param string|Stringable|UnitEnum|null $value Icon size list or `any` token, or `null` to remove the attribute.
+ * @param string|Stringable|UnitEnum|null $value Icon size list or 'any' token, or `null` to remove the attribute.
*
* @return static New instance with the updated `sizes` attribute.
*/
public function sizes(string|Stringable|UnitEnum|null $value): static
{
- return $this->setAttribute(Attribute::SIZES, $value);
+ return $this->addAttribute(ElementAttribute::SIZES, $value);
}
}
diff --git a/src/HasSrc.php b/src/HasSrc.php
index f8f110a..7b6862f 100644
--- a/src/HasSrc.php
+++ b/src/HasSrc.php
@@ -37,6 +37,6 @@ trait HasSrc
*/
public function src(string|Stringable|UnitEnum|null $value): static
{
- return $this->setAttribute(Attribute::SRC, $value);
+ return $this->addAttribute(Attribute::SRC, $value);
}
}
diff --git a/src/HasTarget.php b/src/HasTarget.php
index 5748a81..a2519ab 100644
--- a/src/HasTarget.php
+++ b/src/HasTarget.php
@@ -44,6 +44,6 @@ public function target(string|UnitEnum|null $value): static
{
Validator::oneOf($value, Target::cases(), Attribute::TARGET);
- return $this->setAttribute(Attribute::TARGET, $value);
+ return $this->addAttribute(Attribute::TARGET, $value);
}
}
diff --git a/src/HasType.php b/src/HasType.php
index b99ae31..110ca03 100644
--- a/src/HasType.php
+++ b/src/HasType.php
@@ -45,6 +45,6 @@ public function type(string|Stringable|UnitEnum|null $value): static
{
Validator::oneOf($value, Type::cases(), Attribute::TYPE);
- return $this->setAttribute(Attribute::TYPE, $value);
+ return $this->addAttribute(Attribute::TYPE, $value);
}
}
diff --git a/src/HasValue.php b/src/HasValue.php
index ae2b0ea..b135342 100644
--- a/src/HasValue.php
+++ b/src/HasValue.php
@@ -5,7 +5,7 @@
namespace UIAwesome\Html\Attribute;
use Stringable;
-use UIAwesome\Html\Attribute\Values\Attribute;
+use UIAwesome\Html\Attribute\Values\ElementAttribute;
use UnitEnum;
/**
@@ -34,13 +34,13 @@ trait HasValue
* $element->value(null);
* ```
*
- * @param bool|float|int|string|Stringable|UnitEnum|null $value Element value as `bool`, `int`, `float`, `string`,
- * `Stringable`, `UnitEnum`, or `null` to remove the attribute.
+ * @param bool|float|int|string|Stringable|UnitEnum|null $value Element value as bool, int, float, string,
+ * Stringable, UnitEnum, or `null` to remove the attribute.
*
* @return static New instance with the updated `value` attribute.
*/
public function value(bool|float|int|string|Stringable|UnitEnum|null $value): static
{
- return $this->setAttribute(Attribute::VALUE, $value);
+ return $this->addAttribute(ElementAttribute::VALUE, $value);
}
}
diff --git a/src/Values/Attribute.php b/src/Values/Attribute.php
index 9e8940a..317da81 100644
--- a/src/Values/Attribute.php
+++ b/src/Values/Attribute.php
@@ -21,13 +21,6 @@ enum Attribute: string
*/
case ACCEPT = 'accept';
- /**
- * `as` — Specifies the type of content being loaded by the link element.
- *
- * @link https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/link#as
- */
- case AS = 'as';
-
/**
* `autocomplete` — Indicates whether controls can have their values automatically completed.
*
@@ -35,13 +28,6 @@ enum Attribute: string
*/
case AUTOCOMPLETE = 'autocomplete';
- /**
- * `blocking` — Indicates that certain operations should be blocked on the fetching of an external resource.
- *
- * @link https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/style#blocking
- */
- case BLOCKING = 'blocking';
-
/**
* `capture` — Media capture hint for file inputs.
*
@@ -49,13 +35,6 @@ enum Attribute: string
*/
case CAPTURE = 'capture';
- /**
- * `charset` — Declares the document's character encoding.
- *
- * @link https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/meta#charset
- */
- case CHARSET = 'charset';
-
/**
* `checked` — Indicates whether the command or control is checked.
*
@@ -91,13 +70,6 @@ enum Attribute: string
*/
case DISABLED = 'disabled';
- /**
- * `download` — Indicates that the hyperlink is to be used for downloading a resource.
- *
- * @link https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/a#download
- */
- case DOWNLOAD = 'download';
-
/**
* `elementtiming` — Marks the element for observation by the `PerformanceElementTiming` API.
*
@@ -126,34 +98,6 @@ enum Attribute: string
*/
case FORM = 'form';
- /**
- * `hreflang` — Indicates the language of the linked resource.
- *
- * @link https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/link#hreflang
- */
- case HREFLANG = 'hreflang';
-
- /**
- * `http-equiv` — Defines a pragma directive for processing the document.
- *
- * @link https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/meta/http-equiv
- */
- case HTTP_EQUIV = 'http-equiv';
-
- /**
- * `imagesizes` — Specifies the image sizes for preload.
- *
- * @link https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/link#imagesizes
- */
- case IMAGESIZES = 'imagesizes';
-
- /**
- * `imagesrcset` — Specifies the image srcset for preload.
- *
- * @link https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/link#imagesrcset
- */
- case IMAGESRCSET = 'imagesrcset';
-
/**
* `integrity` — Contains inline metadata that a user agent can use to verify that a fetched resource has been
* delivered without unexpected manipulation (Subresource Integrity).
@@ -162,20 +106,6 @@ enum Attribute: string
*/
case INTEGRITY = 'integrity';
- /**
- * `label` — Text used as a label for an option or option group.
- *
- * @link https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/option#label
- */
- case LABEL = 'label';
-
- /**
- * `list` — Identifies a `