Skip to content

Commit

Permalink
chore(demo): fix types for reuse components
Browse files Browse the repository at this point in the history
  • Loading branch information
mdlufy committed Oct 5, 2024
1 parent 3f2455b commit 2f9295a
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 11 deletions.
11 changes: 7 additions & 4 deletions projects/demo/src/components/control/index.html
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
<tr>
<td colspan="3">
<span tuiTitle>
<strong>ControlOptions</strong>
<strong>Control</strong>
<span tuiSubtitle>Applied as a host directive</span>
</span>
</td>
</tr>

<tr
*ngIf="!hiddenOptions.includes('readonly')"
*ngIf="!hiddenOptions.includes('readOnly')"
name="[readonly]"
tuiDocAPIItem
type="boolean"
Expand All @@ -23,13 +23,16 @@
type="boolean"
[(value)]="disabled"
>
Disabled state
Disabled state (use
<code>control.disable()/.enable()</code>
for reactive forms)
</tr>
<tr
*ngIf="!hiddenOptions.includes('invalid')"
name="[invalid]"
tuiDocAPIItem
type="boolean"
type="boolean | null"
[items]="[true, false]"
[(value)]="invalid"
>
Invalid state
Expand Down
5 changes: 2 additions & 3 deletions projects/demo/src/components/control/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import {NgIf} from '@angular/common';
import {ChangeDetectionStrategy, Component, Input} from '@angular/core';
import type {AbstractControl} from '@angular/forms';
import {DemoRoute} from '@demo/routes';
import {TuiDocAPIItem} from '@taiga-ui/addon-doc';
import type {TuiLooseUnion} from '@taiga-ui/cdk';
Expand All @@ -17,9 +16,9 @@ export class TuiDocControl {
protected readonly routes = DemoRoute;

@Input()
public hiddenOptions: Array<TuiLooseUnion<keyof AbstractControl>> = [];
public hiddenOptions: Array<TuiLooseUnion<'disabled' | 'invalid' | 'readOnly'>> = [];

public readonly = false;
public disabled = false;
public invalid = false;
public invalid: boolean | null = null;
}
3 changes: 0 additions & 3 deletions projects/demo/src/components/textfield/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import {NgIf} from '@angular/common';
import {ChangeDetectionStrategy, Component, inject, Input} from '@angular/core';
import {DemoRoute} from '@demo/routes';
import {TuiDocAPIItem} from '@taiga-ui/addon-doc';
import type {TuiLooseUnion} from '@taiga-ui/cdk';
import type {TuiSizeL, TuiSizeS, TuiTextfieldOptions} from '@taiga-ui/core';
Expand All @@ -16,8 +15,6 @@ import {TUI_TEXTFIELD_OPTIONS, TuiTitle} from '@taiga-ui/core';
export class TuiDocTextfield {
private readonly options = inject(TUI_TEXTFIELD_OPTIONS);

protected readonly routes = DemoRoute;

protected readonly sizeVariants: ReadonlyArray<TuiSizeL | TuiSizeS> = ['s', 'm', 'l'];

@Input()
Expand Down
2 changes: 1 addition & 1 deletion projects/demo/src/modules/components/textfield/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
type="string"
[(value)]="value"
>
Value
Value (or reactive control directives)
</tr>
<tr
name="[filler]"
Expand Down

0 comments on commit 2f9295a

Please sign in to comment.