-
Notifications
You must be signed in to change notification settings - Fork 92
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
INT-2974: Support OnPush change detection (#368)
* INT-2974: Now uses OnPush change detection * INT-2974: Added a story to show support for OnPush change detection form/parent element * INT-2974: Added changelog entry * INT-2974: Update CHANGELOG.md Co-authored-by: Andrew Herron <[email protected]> --------- Co-authored-by: Andrew Herron <[email protected]>
- Loading branch information
1 parent
4dea8ea
commit 1fe5ed3
Showing
5 changed files
with
88 additions
and
2 deletions.
There are no files selected for viewing
This file contains 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 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 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,31 @@ | ||
/* eslint-disable @typescript-eslint/unbound-method */ | ||
/* eslint-disable @typescript-eslint/no-parameter-properties */ | ||
import { | ||
Component, | ||
ChangeDetectionStrategy, | ||
Input, | ||
} from '@angular/core'; | ||
import { FormControl, FormGroup, Validators } from '@angular/forms'; | ||
import type { EditorComponent } from '../../tinymce-angular-component/src/main/ts/public_api'; | ||
|
||
@Component({ | ||
selector: 'form-with-on-push', | ||
templateUrl: './form-with-on-push.html', | ||
changeDetection: ChangeDetectionStrategy.OnPush, | ||
}) | ||
export class FormWithOnPushComponent { | ||
@Input() public apiKey = ''; | ||
public readonly initialValue = ''; | ||
public readonly init: EditorComponent['init'] = { | ||
plugins: [ 'help' ], | ||
}; | ||
public readonly form = new FormGroup({ | ||
tiny: new FormControl('', { | ||
validators: Validators.compose([ | ||
Validators.required, | ||
Validators.minLength(10) | ||
]), | ||
}), | ||
regular: new FormControl(''), | ||
}); | ||
} |
This file contains 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 @@ | ||
<form [formGroup]="form" style="display: flex; gap: 0.2em; flex-direction: column;"> | ||
<editor | ||
formControlName="tiny" | ||
plugins="table" | ||
init="{ width: '200px', }" | ||
/> | ||
<br /> | ||
<label> | ||
<span>Regular input</span> | ||
<br /> | ||
<input type="text" formControlName="regular" /> | ||
</label> | ||
<br /> | ||
<button type="reset" style="width: 200px">Reset form</button> | ||
<button [disabled]="form.invalid" type="submit" style="width: 200px">Submit form</button> | ||
</form> | ||
<br /> | ||
<pre> | ||
Pristine: {{ form.pristine }} | ||
Touched: {{ form.touched }} | ||
Dirty: {{ form.dirty }} | ||
Valid: {{ form.valid }} | ||
Data: {{ form.value | json }} | ||
</pre> |
This file contains 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