diff --git a/CHANGELOG.md b/CHANGELOG.md
index 60dab789..d1573b4b 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,17 @@
# Changelog
+## [5.0.0](https://github.com/Okipa/laravel-bootstrap-components/compare/4.0.0...5.0.0)
+
+2020-12-02
+
+* Added Livewire support
+* Added named validation bag support
+* Templates updated
+* Methods signature update
+* Components default config update
+
+:point_right: [See the upgrade guide](/docs/upgrade-guides/from-v4-to-v5.md)
+
## [4.0.0](https://github.com/Okipa/laravel-bootstrap-components/compare/3.0.3...4.0.0)
2020-11-14
@@ -40,6 +52,8 @@
* Dropped Laravel 5.8 and 6.0 support
* Dropped PHP 7.2 and 7.3 support
+:point_right: [See the upgrade guide](/docs/upgrade-guides/from-v2-to-v3.md)
+
## [2.2.3](https://github.com/Okipa/laravel-bootstrap-components/compare/2.2.2...2.2.3)
2020-07-16
diff --git a/README.md b/README.md
index 30da35df..bb8488ac 100644
--- a/README.md
+++ b/README.md
@@ -17,7 +17,7 @@
-Save time and take advantage of an extended set of ready-to-use and fully customizable bootstrap form components.
+Save time and take advantage of a set of dynamical, ready-to-use and fully customizable bootstrap form components.
Found this package helpful? Please consider supporting my work!
@@ -35,7 +35,9 @@ Found this package helpful? Please consider supporting my work!
## Upgrade guide
+* [From V4 to V5](/docs/upgrade-guides/from-v4-to-v5.md)
* [From V3 to V4](/docs/upgrade-guides/from-v3-to-v4.md)
+* [From V2 to V3](/docs/upgrade-guides/from-v2-to-v3.md)
* [From V1 to V2](/docs/upgrade-guides/from-v1-to-v2.md)
## Usage
@@ -82,10 +84,10 @@ And get this HTML generated for you:
Call this component in your view:
```blade
-{{-- helper style --}}
+{{-- Helper style --}}
{{ inputText()->name('title')->localized(['fr', 'en']) }}
-{{-- facade style --}}
+{{-- Facade style --}}
{{ InputText::name('title')->localized(['fr', 'en']) }}
```
diff --git a/composer.json b/composer.json
index de529853..d4d11375 100644
--- a/composer.json
+++ b/composer.json
@@ -31,7 +31,7 @@
"require-dev": {
"nunomaduro/larastan": "^0.6",
"orchestra/testbench": "^5.0||^6.0",
- "phpmd/phpmd": "^2.8",
+ "phpmd/phpmd": "^2.9",
"squizlabs/php_codesniffer": "^3.5"
},
"autoload": {
diff --git a/docs/api/components.md b/docs/api/components.md
index 69cc56ae..e1bdec9f 100644
--- a/docs/api/components.md
+++ b/docs/api/components.md
@@ -2,7 +2,7 @@
* [Form components](#form-components)
* [Input text](#input-text)
- * [Input e-mail](#input-e-mail)
+ * [Input email](#input-email)
* [Input password](#input-password)
* [Input URL](#input-url)
* [Input tel](#input-tel)
@@ -49,7 +49,7 @@
* Display success : `config('bootstrap-components.form.formValidation.displaySuccess')`
* Display failure : `config('bootstrap-components.form.formValidation.displayFailure')`
-## Input e-mail
+## Input email
**Type :** [FormAbstract](./types.md#formabstract)
@@ -61,6 +61,7 @@
* Prepend : ``
* Label positioned above : `config('bootstrap-components.form.labelPositionedAbove')`
+* Component HTML attributes: `autocomplete="on"`
* Container classes : : `form-group`
* Display success : `config('bootstrap-components.form.formValidation.displaySuccess')`
* Display failure : `config('bootstrap-components.form.formValidation.displayFailure')`
@@ -77,6 +78,7 @@
* Prepend : ``
* Label positioned above : `config('bootstrap-components.form.labelPositionedAbove')`
+* Component HTML attributes: `autocomplete="on"`
* Container classes : : `form-group`
* Display success : `config('bootstrap-components.form.formValidation.displaySuccess')`
* Display failure : `config('bootstrap-components.form.formValidation.displayFailure')`
@@ -109,6 +111,7 @@
* Prepend : ``
* Label positioned above : `config('bootstrap-components.form.labelPositionedAbove')`
+* Component HTML attributes: `autocomplete="on"`
* Container classes : : `form-group`
* Display success : `config('bootstrap-components.form.formValidation.displaySuccess')`
* Display failure : `config('bootstrap-components.form.formValidation.displayFailure')`
diff --git a/docs/api/types.md b/docs/api/types.md
index f9bb15b9..b0a53905 100644
--- a/docs/api/types.md
+++ b/docs/api/types.md
@@ -21,20 +21,20 @@
|---|---|---|
| containerId(string $containerId): self | No | Set the component container id. |
| componentId(string $componentId): self | No | Set the component id. |
-| containerClasses(array $containerClasses): self | No | Set the component container classes. |
-| componentClasses(array $componentClasses): self | No | Set the component classes. |
-| containerHtmlAttributes(array $containerHtmlAttributes): self | No | Set the component container HTML attributes. |
-| componentHtmlAttributes(array $componentHtmlAttributes): self | No | Set the component HTML attributes. |
+| componentClasses(array $componentClasses): self | No | The given HTML classes will replace the component default ones. You can activate the merge mode in order to add the given classes to the default ones by setting the second argument to `true`. |
+| containerClasses(array $containerClasses): self | No | The given HTML classes will replace the component default ones. You can activate the merge mode in order to add the given classes to the default ones by setting the second argument to `true`. |
+| componentHtmlAttributes(array $componentHtmlAttributes): self | No | The given HTML attributes will replace the component default ones. You can activate the merge mode in order to add the given attributes to the default ones by setting the second argument to `true`. |
+| containerHtmlAttributes(array $containerHtmlAttributes): self | No | The given HTML attributes will replace the component default ones. You can activate the merge mode in order to add the given attributes to the default ones by setting the second argument to `true`. |
**Usage**
```php
->containerId('container-id')
- ->componentId('component-id')
->containerClasses(['container', 'classes'])
- ->componentClasses(['component', 'classes'])
->containerHtmlAttributes(['container', 'html', 'attributes'])
+ ->componentId('component-id')
+ ->componentClasses(['component', 'classes'])
->componentHtmlAttributes(['component', 'html', 'attributes']);
```
@@ -57,6 +57,7 @@
| caption(?string $caption): self | No | Set the component caption. |
| displaySuccess(?bool $displaySuccess = true): self | No | Set the component input validation success display status. |
| displayFailure(?bool $displayFailure = true): self | No | Set the component input validation failure display status. |
+| errorBag(string $errorBag): self | No | Define the name of the error bag that will contain the error related to this input. By default, the Laravel error bag is `default`. |
**Usage**
@@ -70,15 +71,16 @@
->append('')
->label('Email')
->labelPositionedAbove()
- ->placeholder('Set your e-mail')
- ->caption('Set your caption here.')
+ ->placeholder('Set your email')
+ ->caption('Your email will tested against to RFC, DNS and spoof checks.')
->displaySuccess(false)
- ->displayFailure(false);
+ ->displayFailure(false)
+ ->errorBag('profileUpdate');
```
**Components**
-* [Input e-mail](./components.md#input-e-mail)
+* [Input email](./components.md#input-email)
* [Input password](./components.md#input-password)
* [Input URL](./components.md#input-url)
* [Input tel](./components.md#input-tel)
@@ -120,15 +122,9 @@
// inherits FormAbstract methods
->locales(['fr', 'en'])
- ->value(function(string $locale){
- return $name[$locale];
- });
- ->prepend(function(string $locale){
- return 'prepend-' . $locale;
- })
- ->append(function(string $locale){
- return 'append-' . $locale;
- })
+ ->value(fn(string $locale) => $name[$locale]);
+ ->prepend(fn(string $locale) => 'prepend-' . $locale)
+ ->append(fn(string $locale) => 'append-' . $locale)
```
**Components**
@@ -176,9 +172,7 @@
```php
// inherits FormAbstract methods
- ->uploadedFile(function(){
- return '
Some HTML
';
- })
+ ->uploadedFile(fn() => '
Some HTML
')
->showRemoveCheckbox(true, 'Remove this file');
```
@@ -242,9 +236,7 @@
]), 'id', 'title')
->selected('id', 1)
// or ->selected('id', [1]) in multiple mode
- ->disabled(function(array $option){
- return ! $option['active'];
- })
+ ->disabled(fn(array $option) => ! $option['active'])
->multiple();
```
diff --git a/docs/upgrade-guides/from-v2-to-v3.md b/docs/upgrade-guides/from-v2-to-v3.md
new file mode 100644
index 00000000..ca7f6fa9
--- /dev/null
+++ b/docs/upgrade-guides/from-v2-to-v3.md
@@ -0,0 +1,19 @@
+# Upgrade from v2 to v3
+
+Follow the steps below to upgrade the package.
+
+## Laravel and PHP old version support drop
+
+Whereas Laravel 8 is now supported by this package, support for any version before Laravel 7 has been dropped.
+
+Support for any version before PHP 7.4 has also been dropped.
+
+As so, you should upgrade your Laravel and PHP versions in order upgrade to V3.
+
+## See all changes
+
+See all change with the [comparison tool](https://github.com/Okipa/laravel-bootstrap-components/compare/2.2.3...3.0.0).
+
+## Undocumented changes
+
+If you see any forgotten and undocumented change, please submit a PR to add them to this upgrade guide.
diff --git a/docs/upgrade-guides/from-v4-to-v5.md b/docs/upgrade-guides/from-v4-to-v5.md
new file mode 100644
index 00000000..18b03a1e
--- /dev/null
+++ b/docs/upgrade-guides/from-v4-to-v5.md
@@ -0,0 +1,67 @@
+# Upgrade from v4 to v5
+
+Follow the steps below to upgrade the package.
+
+## Livewire support
+
+There was an issue preventing the error message and the validation class to be displayed on form components when they were used into a livewire component.
+
+This was related to the fact the session was used to detect errors, which can't work with livewire as the `$errors` variable is passed in the blade view on re-rendering.
+
+This has been fixed and the error message + the validation class are now generated from the `$errors` variable given in the view instead of the session.
+
+## Templates updated
+
+Related to the previous point (Livewire support added), the view templates provided with this package have been updated.
+
+If you have published the views in order to make some customizations, you will have to [re-publish them](../../README.md#templates) and to redo your customizations.
+
+## Named validation bag support
+
+All form components can now correctly display validation class and error message when using a named validation bag.
+
+If you validate an email this way:
+
+```php
+Validator::make(
+ ['email' => 'spoof@email.test']
+ ['email' => ['required', 'string', 'email:rfc,dns,spoof']],
+])->validateWithBag('profileUpdate');
+```
+
+The `is-invalid` validation class and the input related error message will correctly will be displayed when the form will be submitted with:
+
+```blade
+{{ inputEmail()->name('email')->errorBag('profileUpdate') }}
+```
+
+## Methods signature update
+
+The following methods have gained the ability to merge given HTML classes or HTML attributes to the component default ones instead of replacing them.
+
+To use this new behaviour, you'll just have to set the second `$mergeMode` boolean attribute to `true`.
+
+* All components: `componentClasses`
+* All components: `containerClasses`
+* All components: `componentHtmlAttributes`
+* All components: `containerHtmlAttributes`
+* Image component: `linkClasses`
+* Image component: `linkHtmlAttributes`
+
+For example, using `inputText()->name('name')->componentClasses(['merged', 'classes'], true)` will append the `merged classes` classes to the ones defined by default on the input text component.
+
+## Components default config update
+
+The `autocomplete="on"` HTML attribute has been added in the default configuration of the following components, in order to improve the default behavior (see https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/autocomplete):
+
+* Input email component
+* Input password component
+* Input url component
+
+## See all changes
+
+See all change with the [comparison tool](https://github.com/Okipa/laravel-bootstrap-components/compare/4.0.0...5.0.0).
+
+## Undocumented changes
+
+If you see any forgotten and undocumented change, please submit a PR to add them to this upgrade guide.
diff --git a/resources/views/bootstrap-components/form/checkbox.blade.php b/resources/views/bootstrap-components/form/checkbox.blade.php
index 264034c7..ca08dc3f 100644
--- a/resources/views/bootstrap-components/form/checkbox.blade.php
+++ b/resources/views/bootstrap-components/form/checkbox.blade.php
@@ -1,5 +1,5 @@