Skip to content

Commit

Permalink
Move common interfaces to php-forge/html-interop. (#336)
Browse files Browse the repository at this point in the history
  • Loading branch information
terabytesoftw committed Feb 27, 2024
1 parent f6fe500 commit 83c5658
Show file tree
Hide file tree
Showing 34 changed files with 364 additions and 657 deletions.
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# Change Log

## 0.1.2 Under development
## 0.2.0 February 27, 2024

- Enh #336: Move common interfaces to `php-forge/html-interop` package (@terabytesoftw)

## 0.1.1 February 25, 2024

Expand Down
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
"ext-mbstring": "*",
"enshrined/svg-sanitize": "^0.17.0",
"php-forge/awesome-widget": "^0.1.2",
"php-forge/html-interop": "^0.1",
"voku/anti-xss": "^4.1"
},
"require-dev": {
Expand Down
63 changes: 34 additions & 29 deletions src/FormControl/Base/AbstractSelect.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,35 +5,36 @@
namespace PHPForge\Html\FormControl\Base;

use InvalidArgumentException;
use PHPForge\Html\{
Attribute\Aria\HasAriaLabel,
Attribute\CanBeAutofocus,
Attribute\Custom\HasAttributes,
Attribute\Custom\HasLabelCollection,
Attribute\Custom\HasPrefixCollection,
Attribute\Custom\HasSuffixCollection,
Attribute\Field\HasGenerateField,
Attribute\HasClass,
Attribute\HasId,
Attribute\HasStyle,
Attribute\HasTabindex,
Attribute\Input\CanBeDisabled,
Attribute\Input\CanBeMultiple,
Attribute\Input\CanBeRequired,
Attribute\Input\HasName,
Attribute\Input\HasSize,
Attribute\Input\HasValue,
Attribute\Tag\HasGroup,
Attribute\Tag\HasItems,
Attribute\Tag\HasItemsAttributes,
Attribute\Tag\HasPrompt,
FormControl\Input\Contract\InputInterface,
FormControl\Input\Contract\RequiredInterface,
FormControl\Input\Contract\ValueInterface,
FormControl\Label,
Tag
use PHPForge\{
Html\Attribute\Aria\HasAriaLabel,
Html\Attribute\CanBeAutofocus,
Html\Attribute\Custom\HasAttributes,
Html\Attribute\Custom\HasLabelCollection,
Html\Attribute\Custom\HasPrefixCollection,
Html\Attribute\Custom\HasSuffixCollection,
Html\Attribute\Field\HasGenerateField,
Html\Attribute\HasClass,
Html\Attribute\HasId,
Html\Attribute\HasStyle,
Html\Attribute\HasTabindex,
Html\Attribute\Input\CanBeDisabled,
Html\Attribute\Input\CanBeMultiple,
Html\Attribute\Input\CanBeRequired,
Html\Attribute\Input\HasName,
Html\Attribute\Input\HasSize,
Html\Attribute\Input\HasValue,
Html\Attribute\Tag\HasGroup,
Html\Attribute\Tag\HasItems,
Html\Attribute\Tag\HasItemsAttributes,
Html\Attribute\Tag\HasPrompt,
Html\FormControl\Label,
Html\Interop\InputInterface,
Html\Interop\RequiredInterface,
Html\Interop\ValueInterface,
Html\Tag,
Widget\Element,
Widget\ElementInterface
};
use PHPForge\Widget\Element;
use Stringable;

use function array_merge;
Expand All @@ -47,7 +48,11 @@
/**
* Provides a foundation for creating HTML `select` elements with various attributes and content.
*/
abstract class AbstractSelect extends Element implements InputInterface, RequiredInterface, ValueInterface
abstract class AbstractSelect extends Element implements
ElementInterface,
InputInterface,
RequiredInterface,
ValueInterface
{
use CanBeAutofocus;
use CanBeDisabled;
Expand Down
56 changes: 29 additions & 27 deletions src/FormControl/Input/Base/AbstractChoiceList.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,34 +4,35 @@

namespace PHPForge\Html\FormControl\Input\Base;

use PHPForge\Html\{
Attribute\Aria\HasAriaDescribedBy,
Attribute\Aria\HasAriaLabel,
Attribute\CanBeAutofocus,
Attribute\Custom\HasAttributes,
Attribute\Custom\HasContainerCollection,
Attribute\Custom\HasEnclosedByLabel,
Attribute\Custom\HasLabelCollection,
Attribute\Custom\HasLabelItemClass,
Attribute\Custom\HasSeparator,
Attribute\Custom\HasTemplate,
Attribute\Custom\HasUncheckedCollection,
Attribute\Field\HasGenerateField,
Attribute\HasClass,
Attribute\HasId,
Attribute\HasTabindex,
Attribute\Input\CanBeChecked,
Attribute\Input\CanBeRequired,
Attribute\Input\HasName,
FormControl\Input\Contract\AriaDescribedByInterface,
FormControl\Input\Contract\CheckedInterface,
FormControl\Input\Contract\InputInterface,
FormControl\Input\Contract\LabelInterface,
FormControl\Input\Contract\RequiredInterface,
Helper\Utils,
Tag
use PHPForge\{
Html\Attribute\Aria\HasAriaDescribedBy,
Html\Attribute\Aria\HasAriaLabel,
Html\Attribute\CanBeAutofocus,
Html\Attribute\Custom\HasAttributes,
Html\Attribute\Custom\HasContainerCollection,
Html\Attribute\Custom\HasEnclosedByLabel,
Html\Attribute\Custom\HasLabelCollection,
Html\Attribute\Custom\HasLabelItemClass,
Html\Attribute\Custom\HasSeparator,
Html\Attribute\Custom\HasTemplate,
Html\Attribute\Custom\HasUncheckedCollection,
Html\Attribute\Field\HasGenerateField,
Html\Attribute\HasClass,
Html\Attribute\HasId,
Html\Attribute\HasTabindex,
Html\Attribute\Input\CanBeChecked,
Html\Attribute\Input\CanBeRequired,
Html\Attribute\Input\HasName,
Html\FormControl\Input\Contract\LabelInterface,
Html\Helper\Utils,
Html\Interop\AriaDescribedByInterface,
Html\Interop\CheckedInterface,
Html\Interop\InputInterface,
Html\Interop\RequiredInterface,
Html\Tag,
Widget\Element,
Widget\ElementInterface
};
use PHPForge\Widget\Element;

use function in_array;
use function is_bool;
Expand All @@ -41,6 +42,7 @@
abstract class AbstractChoiceList extends Element implements
AriaDescribedByInterface,
CheckedInterface,
ElementInterface,
InputInterface,
LabelInterface,
RequiredInterface
Expand Down
22 changes: 11 additions & 11 deletions src/FormControl/Input/Base/AbstractHidden.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,17 @@

namespace PHPForge\Html\FormControl\Input\Base;

use PHPForge\Html\{
Attribute\Custom\HasAttributes,
Attribute\Custom\HasTemplate,
Attribute\Custom\HasValidateString,
Attribute\HasClass,
Attribute\HasId,
Attribute\HasStyle,
Attribute\Input\HasName,
Attribute\Input\HasValue,
FormControl\Input\Contract\ValueInterface,
Tag
use PHPForge\{
Html\Attribute\Custom\HasAttributes,
Html\Attribute\Custom\HasTemplate,
Html\Attribute\Custom\HasValidateString,
Html\Attribute\HasClass,
Html\Attribute\HasId,
Html\Attribute\HasStyle,
Html\Attribute\Input\HasName,
Html\Attribute\Input\HasValue,
Html\Interop\ValueInterface,
Html\Tag
};
use PHPForge\Widget\Element;

Expand Down
53 changes: 27 additions & 26 deletions src/FormControl/Input/Base/AbstractInput.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,37 +4,38 @@

namespace PHPForge\Html\FormControl\Input\Base;

use PHPForge\Html\{
Attribute\Aria\HasAriaDescribedBy,
Attribute\Aria\HasAriaLabel,
Attribute\CanBeAutofocus,
Attribute\CanBeHidden,
Attribute\Custom\HasAttributes,
Attribute\Custom\HasPrefixCollection,
Attribute\Custom\HasSuffixCollection,
Attribute\Custom\HasTemplate,
Attribute\Field\HasGenerateField,
Attribute\HasClass,
Attribute\HasData,
Attribute\HasId,
Attribute\HasLang,
Attribute\HasStyle,
Attribute\HasTabindex,
Attribute\HasTitle,
Attribute\Input\CanBeDisabled,
Attribute\Input\CanBeReadonly,
Attribute\Input\HasForm,
Attribute\Input\HasName,
FormControl\Input\Contract\AriaDescribedByInterface,
FormControl\Input\Contract\InputInterface,
Tag
use PHPForge\{
Html\Attribute\Aria\HasAriaDescribedBy,
Html\Attribute\Aria\HasAriaLabel,
Html\Attribute\CanBeAutofocus,
Html\Attribute\CanBeHidden,
Html\Attribute\Custom\HasAttributes,
Html\Attribute\Custom\HasPrefixCollection,
Html\Attribute\Custom\HasSuffixCollection,
Html\Attribute\Custom\HasTemplate,
Html\Attribute\Field\HasGenerateField,
Html\Attribute\HasClass,
Html\Attribute\HasData,
Html\Attribute\HasId,
Html\Attribute\HasLang,
Html\Attribute\HasStyle,
Html\Attribute\HasTabindex,
Html\Attribute\HasTitle,
Html\Attribute\Input\CanBeDisabled,
Html\Attribute\Input\CanBeReadonly,
Html\Attribute\Input\HasForm,
Html\Attribute\Input\HasName,
Html\Interop\AriaDescribedByInterface,
Html\Interop\InputInterface,
Html\Tag,
Widget\Element,
Widget\ElementInterface,
};
use PHPForge\Widget\Element;

/**
* Provides a foundation for creating HTML `input` custom elements with various attributes and content.
*/
abstract class AbstractInput extends Element implements AriaDescribedByInterface, InputInterface
abstract class AbstractInput extends Element implements AriaDescribedByInterface, ElementInterface, InputInterface
{
use CanBeAutofocus;
use CanBeDisabled;
Expand Down
80 changes: 41 additions & 39 deletions src/FormControl/Input/Base/AbstractInputChoice.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,53 +4,55 @@

namespace PHPForge\Html\FormControl\Input\Base;

use PHPForge\Html\{
Attribute\Aria\HasAriaDescribedBy,
Attribute\Aria\HasAriaLabel,
Attribute\CanBeAutofocus,
Attribute\CanBeHidden,
Attribute\Custom\HasAttributes,
Attribute\Custom\HasContainerCollection,
Attribute\Custom\HasContent,
Attribute\Custom\HasEnclosedByLabel,
Attribute\Custom\HasLabelCollection,
Attribute\Custom\HasPrefixCollection,
Attribute\Custom\HasSeparator,
Attribute\Custom\HasSuffixCollection,
Attribute\Custom\HasTemplate,
Attribute\Custom\HasUncheckedCollection,
Attribute\Custom\HasValidateScalar,
Attribute\Field\HasGenerateField,
Attribute\HasClass,
Attribute\HasData,
Attribute\HasId,
Attribute\HasLang,
Attribute\HasStyle,
Attribute\HasTabindex,
Attribute\HasTitle,
Attribute\Input\CanBeChecked,
Attribute\Input\CanBeDisabled,
Attribute\Input\CanBeReadonly,
Attribute\Input\CanBeRequired,
Attribute\Input\HasForm,
Attribute\Input\HasName,
Attribute\Input\HasValue,
FormControl\Input\Contract\AriaDescribedByInterface,
FormControl\Input\Contract\CheckedInterface,
FormControl\Input\Contract\InputInterface,
FormControl\Input\Contract\LabelInterface,
FormControl\Input\Contract\RequiredInterface,
FormControl\Label,
Tag
use PHPForge\{
Html\Attribute\Aria\HasAriaDescribedBy,
Html\Attribute\Aria\HasAriaLabel,
Html\Attribute\CanBeAutofocus,
Html\Attribute\CanBeHidden,
Html\Attribute\Custom\HasAttributes,
Html\Attribute\Custom\HasContainerCollection,
Html\Attribute\Custom\HasContent,
Html\Attribute\Custom\HasEnclosedByLabel,
Html\Attribute\Custom\HasLabelCollection,
Html\Attribute\Custom\HasPrefixCollection,
Html\Attribute\Custom\HasSeparator,
Html\Attribute\Custom\HasSuffixCollection,
Html\Attribute\Custom\HasTemplate,
Html\Attribute\Custom\HasUncheckedCollection,
Html\Attribute\Custom\HasValidateScalar,
Html\Attribute\Field\HasGenerateField,
Html\Attribute\HasClass,
Html\Attribute\HasData,
Html\Attribute\HasId,
Html\Attribute\HasLang,
Html\Attribute\HasStyle,
Html\Attribute\HasTabindex,
Html\Attribute\HasTitle,
Html\Attribute\Input\CanBeChecked,
Html\Attribute\Input\CanBeDisabled,
Html\Attribute\Input\CanBeReadonly,
Html\Attribute\Input\CanBeRequired,
Html\Attribute\Input\HasForm,
Html\Attribute\Input\HasName,
Html\Attribute\Input\HasValue,
Html\FormControl\Input\Contract\LabelInterface,
Html\FormControl\Label,
Html\Interop\AriaDescribedByInterface,
Html\Interop\CheckedInterface,
Html\Interop\InputInterface,
Html\Interop\RequiredInterface,
Html\Tag,
Widget\Element,
Widget\ElementInterface
};
use PHPForge\Widget\Element;

/**
* Provides a foundation for creating HTML elements with various attributes and content.
*/
abstract class AbstractInputChoice extends Element implements
AriaDescribedByInterface,
CheckedInterface,
ElementInterface,
InputInterface,
LabelInterface,
RequiredInterface
Expand Down
10 changes: 8 additions & 2 deletions src/FormControl/Input/Color.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,21 @@

namespace PHPForge\Html\FormControl\Input;

use PHPForge\Html\Attribute\{Custom\HasValidateString, Input\CanBeRequired, Input\HasValue};
use PHPForge\{
Html\Attribute\Custom\HasValidateString,
Html\Attribute\Input\CanBeRequired,
Html\Attribute\Input\HasValue,
Html\Interop\RequiredInterface,
Html\Interop\ValueInterface
};

/**
* The input element with a type attribute whose value is "color" represents a color-well control, for setting the
* element’s value to a string representing a simple color.
*
* @link https://www.w3.org/TR/2012/WD-html-markup-20120329/input.color.html#input.color
*/
final class Color extends Base\AbstractInput implements Contract\RequiredInterface, Contract\ValueInterface
final class Color extends Base\AbstractInput implements RequiredInterface, ValueInterface
{
use CanBeRequired;
use HasValidateString;
Expand Down

0 comments on commit 83c5658

Please sign in to comment.