generated from ibexa/bundle-template
-
Notifications
You must be signed in to change notification settings - Fork 0
IBX-7999: Checkbox and ThreeStateCheckbox #13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
GrabowskiM
wants to merge
3
commits into
main
Choose a base branch
from
IBX-7999
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+209
−1
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import BaseCheckbox from '../../shared/BaseCheckbox'; | ||
|
||
export default class Checkbox extends BaseCheckbox {} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
src/bundle/Resources/public/ts/components/inputs/ThreeStateCheckbox.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import BaseCheckbox from '../../shared/BaseCheckbox'; | ||
|
||
export default class ThreeStateCheckbox extends BaseCheckbox { | ||
private _indeterminate = false; | ||
|
||
constructor(container: HTMLDivElement) { | ||
super(container); | ||
|
||
this.indeterminate = this._inputElement.classList.contains('ids-input--indeterminate'); | ||
} | ||
|
||
set indeterminate(value: boolean) { | ||
this._indeterminate = value; | ||
this._inputElement.indeterminate = value; | ||
this._inputElement.classList.toggle('ids-input--indeterminate', value); | ||
|
||
if (value) { | ||
this._inputElement.checked = false; | ||
|
||
this._inputElement.dispatchEvent(new Event('input', { bubbles: true })); | ||
this._inputElement.dispatchEvent(new Event('change', { bubbles: true })); | ||
} | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import Base from './Base'; | ||
|
||
export default abstract class BaseCheckbox extends Base { | ||
protected _inputElement: HTMLInputElement; | ||
|
||
constructor(container: HTMLDivElement) { | ||
super(container); | ||
|
||
const inputElement = container.querySelector<HTMLInputElement>('.ids-input'); | ||
|
||
if (!inputElement) { | ||
throw new Error('Checkbox: Required elements are missing in the container.'); | ||
} | ||
|
||
this._inputElement = inputElement; | ||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
...bundle/Resources/views/themes/standard/design_system/components/inputs/Checkbox.html.twig
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
{% set input_classes = | ||
html_classes( | ||
'ids-input ids-input--checkbox ids-input--medium', | ||
{ | ||
'ids-input--disabled': disabled, | ||
'ids-input--error': error, | ||
'ids-input--required': required | ||
}, | ||
attributes.render('class') ?? '' | ||
) | ||
%} | ||
|
||
<div class="ids-checkbox"> | ||
<input | ||
class="{{ input_classes }}" | ||
mikadamczyk marked this conversation as resolved.
Show resolved
Hide resolved
|
||
type="checkbox" | ||
{{ | ||
attributes.defaults({ | ||
disabled, | ||
required | ||
mikadamczyk marked this conversation as resolved.
Show resolved
Hide resolved
|
||
}) | ||
}} | ||
/> | ||
</div> |
25 changes: 25 additions & 0 deletions
25
...ources/views/themes/standard/design_system/components/inputs/ThreeStateCheckbox.html.twig
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
{% set input_classes = | ||
html_classes( | ||
'ids-input ids-input--checkbox ids-input--medium', | ||
{ | ||
'ids-input--disabled': disabled, | ||
'ids-input--error': error, | ||
'ids-input--required': required, | ||
'ids-input--indeterminate': indeterminate | ||
}, | ||
attributes.render('class') ?? '' | ||
) | ||
%} | ||
|
||
<div class="ids-three-state-checkbox"> | ||
<input | ||
class="{{ input_classes }}" | ||
type="checkbox" | ||
{{ | ||
attributes.defaults({ | ||
disabled, | ||
required | ||
}) | ||
}} | ||
/> | ||
</div> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
<?php | ||
|
||
/** | ||
* @copyright Copyright (C) Ibexa AS. All rights reserved. | ||
* @license For full copyright and license information view LICENSE file distributed with this source code. | ||
*/ | ||
declare(strict_types=1); | ||
|
||
namespace Ibexa\DesignSystemTwig\Twig\Components\inputs; | ||
|
||
use Symfony\Component\OptionsResolver\OptionsResolver; | ||
use Symfony\UX\TwigComponent\Attribute\PreMount; | ||
|
||
abstract class AbstractCheckbox | ||
{ | ||
public bool $disabled = false; | ||
|
||
public bool $error = false; | ||
|
||
public bool $required = false; | ||
|
||
/** | ||
* @param array<string, mixed> $props | ||
* | ||
* @return array<string, mixed> | ||
*/ | ||
#[PreMount] | ||
public function validate(array $props): array | ||
{ | ||
$resolver = new OptionsResolver(); | ||
$resolver->setIgnoreUndefined(); | ||
$resolver | ||
->define('disabled') | ||
->allowedTypes('bool') | ||
->default(false); | ||
$resolver | ||
->define('error') | ||
->allowedTypes('bool') | ||
->default(false); | ||
$resolver | ||
->define('required') | ||
->allowedTypes('bool') | ||
->default(false); | ||
|
||
$this->configurePropsResolver($resolver); | ||
|
||
return $resolver->resolve($props) + $props; | ||
} | ||
|
||
abstract protected function configurePropsResolver(OptionsResolver $resolver): void; | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<?php | ||
|
||
/** | ||
* @copyright Copyright (C) Ibexa AS. All rights reserved. | ||
* @license For full copyright and license information view LICENSE file distributed with this source code. | ||
*/ | ||
declare(strict_types=1); | ||
|
||
namespace Ibexa\DesignSystemTwig\Twig\Components\inputs; | ||
|
||
use Symfony\Component\OptionsResolver\OptionsResolver; | ||
use Symfony\UX\TwigComponent\Attribute\AsTwigComponent; | ||
|
||
GrabowskiM marked this conversation as resolved.
Show resolved
Hide resolved
|
||
#[AsTwigComponent] | ||
final class Checkbox extends AbstractCheckbox | ||
{ | ||
protected function configurePropsResolver(OptionsResolver $resolver): void | ||
{ | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<?php | ||
|
||
/** | ||
* @copyright Copyright (C) Ibexa AS. All rights reserved. | ||
* @license For full copyright and license information view LICENSE file distributed with this source code. | ||
*/ | ||
declare(strict_types=1); | ||
|
||
namespace Ibexa\DesignSystemTwig\Twig\Components\inputs; | ||
|
||
use Symfony\Component\OptionsResolver\OptionsResolver; | ||
use Symfony\UX\TwigComponent\Attribute\AsTwigComponent; | ||
|
||
#[AsTwigComponent] | ||
final class ThreeStateCheckbox extends AbstractCheckbox | ||
{ | ||
public bool $indeterminate = false; | ||
|
||
protected function configurePropsResolver(OptionsResolver $resolver): void | ||
{ | ||
$resolver | ||
->define('indeterminate') | ||
->allowedTypes('bool') | ||
->default(false); | ||
} | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The class name 'InpuText' was misspelled and has been correctly fixed to 'InputText'.
Copilot uses AI. Check for mistakes.