-
Notifications
You must be signed in to change notification settings - Fork 470
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(layout):
Form
add new component (#9933)
Co-authored-by: taiga-family-bot <[email protected]>
- Loading branch information
1 parent
1092bcc
commit 52ab367
Showing
26 changed files
with
455 additions
and
45 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 |
---|---|---|
@@ -1,16 +1,16 @@ | ||
import type {FactoryProvider, InjectionToken} from '@angular/core'; | ||
import type {FactoryProvider, InjectionToken, ProviderToken} from '@angular/core'; | ||
import {inject} from '@angular/core'; | ||
|
||
export function tuiProvideOptions<T>( | ||
provide: InjectionToken<T>, | ||
options: Partial<T>, | ||
options: Partial<T> | ProviderToken<Partial<T>>, | ||
fallback: T, | ||
): FactoryProvider { | ||
return { | ||
provide, | ||
useFactory: (): T => ({ | ||
...(inject(provide, {optional: true, skipSelf: true}) || fallback), | ||
...options, | ||
...(inject(options as any, {optional: true}) || options), | ||
}), | ||
}; | ||
} |
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
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
87 changes: 87 additions & 0 deletions
87
projects/demo/src/modules/components/form/examples/1/index.html
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,87 @@ | ||
<form | ||
tuiAppearance="floating" | ||
tuiCardLarge | ||
tuiForm="m" | ||
[formGroup]="form" | ||
[style.max-width.rem]="32" | ||
> | ||
<header tuiHeader> | ||
<h2 tuiTitle> | ||
Registration form | ||
<span tuiSubtitle>Tell us about yourself</span> | ||
</h2> | ||
<span tuiAccessories> | ||
<tui-segmented> | ||
<label> | ||
<input | ||
formControlName="basic" | ||
type="radio" | ||
[value]="true" | ||
/> | ||
Brief | ||
</label> | ||
<label> | ||
<input | ||
formControlName="basic" | ||
type="radio" | ||
[value]="false" | ||
/> | ||
Detailed | ||
</label> | ||
</tui-segmented> | ||
</span> | ||
</header> | ||
<tui-notification appearance="warning"> | ||
<h3 tuiTitle> | ||
Authenticity required | ||
<span tuiSubtitle>Please be honest and use your real data</span> | ||
</h3> | ||
</tui-notification> | ||
<tui-textfield> | ||
<label tuiLabel>Name</label> | ||
<input | ||
formControlName="name" | ||
placeholder="John Wick" | ||
tuiTextfield | ||
/> | ||
</tui-textfield> | ||
<tui-error | ||
formControlName="name" | ||
[error]="[] | tuiFieldError | async" | ||
/> | ||
<ng-container *ngIf="!form.controls.basic.value"> | ||
<tui-textfield> | ||
<label tuiLabel>Email</label> | ||
<input | ||
formControlName="email" | ||
placeholder="[email protected]" | ||
tuiTextfield | ||
type="email" | ||
/> | ||
</tui-textfield> | ||
<label tuiLabel> | ||
<input | ||
formControlName="subscribe" | ||
tuiSwitch | ||
type="checkbox" | ||
/> | ||
Subscribe for newsletter | ||
<tui-icon tuiTooltip="We will not send you spam, pinky promise!" /> | ||
</label> | ||
</ng-container> | ||
<footer> | ||
<button | ||
appearance="secondary" | ||
tuiButton | ||
type="button" | ||
> | ||
Cancel | ||
</button> | ||
<button | ||
tuiButton | ||
type="submit" | ||
> | ||
Submit | ||
</button> | ||
</footer> | ||
</form> |
50 changes: 50 additions & 0 deletions
50
projects/demo/src/modules/components/form/examples/1/index.ts
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,50 @@ | ||
import {AsyncPipe, NgIf} from '@angular/common'; | ||
import {Component} from '@angular/core'; | ||
import {FormControl, FormGroup, ReactiveFormsModule, Validators} from '@angular/forms'; | ||
import {changeDetection} from '@demo/emulate/change-detection'; | ||
import {encapsulation} from '@demo/emulate/encapsulation'; | ||
import { | ||
TuiAppearance, | ||
TuiButton, | ||
TuiError, | ||
TuiIcon, | ||
TuiNotification, | ||
TuiTextfield, | ||
TuiTitle, | ||
} from '@taiga-ui/core'; | ||
import {TuiFieldErrorPipe, TuiSegmented, TuiSwitch, TuiTooltip} from '@taiga-ui/kit'; | ||
import {TuiCardLarge, TuiForm, TuiHeader} from '@taiga-ui/layout'; | ||
|
||
@Component({ | ||
standalone: true, | ||
imports: [ | ||
AsyncPipe, | ||
NgIf, | ||
ReactiveFormsModule, | ||
TuiAppearance, | ||
TuiButton, | ||
TuiCardLarge, | ||
TuiError, | ||
TuiFieldErrorPipe, | ||
TuiForm, | ||
TuiHeader, | ||
TuiIcon, | ||
TuiNotification, | ||
TuiSegmented, | ||
TuiSwitch, | ||
TuiTextfield, | ||
TuiTitle, | ||
TuiTooltip, | ||
], | ||
templateUrl: './index.html', | ||
encapsulation, | ||
changeDetection, | ||
}) | ||
export default class Example { | ||
protected readonly form = new FormGroup({ | ||
name: new FormControl('', Validators.required), | ||
email: new FormControl(''), | ||
subscribe: new FormControl(false), | ||
basic: new FormControl(true), | ||
}); | ||
} |
18 changes: 18 additions & 0 deletions
18
projects/demo/src/modules/components/form/examples/import/import.md
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,18 @@ | ||
```ts | ||
import {TuiAppearance} from '@taiga-ui/core'; | ||
import {TuiCardLarge, TuiForm} from '@taiga-ui/layout'; | ||
|
||
// ... | ||
|
||
@Component({ | ||
standalone: true, | ||
imports: [ | ||
// ... | ||
TuiCardLarge, | ||
TuiAppearance, | ||
TuiForm, | ||
], | ||
// ... | ||
}) | ||
export class Example {} | ||
``` |
9 changes: 9 additions & 0 deletions
9
projects/demo/src/modules/components/form/examples/import/template.md
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,9 @@ | ||
```html | ||
<form | ||
tuiAppearance="floating" | ||
tuiCardLarge | ||
tuiForm="l" | ||
> | ||
<!-- Form content --> | ||
</form> | ||
``` |
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 @@ | ||
<tui-doc-page | ||
header="Form" | ||
package="LAYOUT" | ||
type="components" | ||
> | ||
<tui-notification appearance="warning"> | ||
Size sets DI options, therefore it only works for static values like | ||
<code>tuiForm="m"</code> | ||
. If you need dynamic binding for the size, you would have to set it for buttons, segmented control and header | ||
manually as well. | ||
</tui-notification> | ||
<ng-template pageTab> | ||
<tui-doc-example | ||
*ngFor="let example of examples; let index = index" | ||
[component]="index + 1 | tuiComponent" | ||
[content]="index + 1 | tuiExample" | ||
[fullsize]="true" | ||
[heading]="example" | ||
[id]="example | tuiKebab" | ||
/> | ||
</ng-template> | ||
|
||
<tui-setup *pageTab="'Setup'" /> | ||
</tui-doc-page> |
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,3 @@ | ||
.bar { | ||
block-size: 6.25rem; | ||
} |
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,14 @@ | ||
import {Component} from '@angular/core'; | ||
import {changeDetection} from '@demo/emulate/change-detection'; | ||
import {TuiDemo} from '@demo/utils'; | ||
|
||
@Component({ | ||
standalone: true, | ||
imports: [TuiDemo], | ||
templateUrl: './index.html', | ||
styleUrls: ['./index.less'], | ||
changeDetection, | ||
}) | ||
export default class Page { | ||
protected readonly examples = ['Basic']; | ||
} |
Oops, something went wrong.