Skip to content
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

feat(kit): introduce new version of InputNumber #10099

Merged
merged 2 commits into from
Dec 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 6 additions & 9 deletions projects/demo/src/modules/app/pages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -544,15 +544,12 @@ export const pages: DocRoutePages = [
keywords: 'поле, инпут, форма, ввод, input, month, месяц, год, дата',
route: DemoRoute.InputMonthRange,
},
// TODO: it will be revealed later
// {
// section: 'Components',
// title: 'InputNumber',
// keywords:
// 'поле, инпут, number, число, форма, ввод, input, money, деньги, ' +
// 'cash, копейки, рубли, доллары, евро, control, контрол',
// route: DemoRoute.InputNumber,
// },
{
section: 'Components',
title: 'InputNumber',
keywords: 'textfield, input, number, count, digit, money, число',
route: DemoRoute.InputNumber,
},
{
section: 'Components',
title: 'InputNumber [deprecated]',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,21 @@
header="InputNumberLegacy"
package="LEGACY"
type="components"
[deprecated]="true"
>
<ng-template pageTab>
<div class="tui-space_bottom-3">A component to input numbers. Control value is also of number type.</div>
<tui-notification appearance="negative">
This version of the component is deprecated and will be removed in the next major version. Use
<a
tuiLink
[routerLink]="routes.InputNumber"
>
<strong>new version of InputNumber</strong>
</a>
instead!
</tui-notification>

<p>A component to input numbers. Control value is also of number type.</p>

<section>
<h3>There are also other components to input numbers:</h3>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<tui-textfield>
<label tuiLabel>Enter a number</label>

<input
inputmode="decimal"
tuiInputNumber
[formControl]="control"
/>
</tui-textfield>

<tui-error
[error]="[] | tuiFieldError | async"
[formControl]="control"
/>

<p><strong>Control value:</strong></p>
<code>{{ control.value | json }}</code>
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import {AsyncPipe, JsonPipe} from '@angular/common';
import {Component} from '@angular/core';
import {FormControl, ReactiveFormsModule, Validators} from '@angular/forms';
import {changeDetection} from '@demo/emulate/change-detection';
import {encapsulation} from '@demo/emulate/encapsulation';
import {TuiError, TuiTextfield} from '@taiga-ui/core';
import {
TuiFieldErrorPipe,
TuiInputNumber,
tuiValidationErrorsProvider,
} from '@taiga-ui/kit';

@Component({
standalone: true,
imports: [
AsyncPipe,
JsonPipe,
ReactiveFormsModule,
TuiError,
TuiFieldErrorPipe,
TuiInputNumber,
TuiTextfield,
],
templateUrl: './index.html',
encapsulation,
changeDetection,
providers: [
tuiValidationErrorsProvider({
required: 'Required field',
}),
],
})
export default class Example {
protected readonly control = new FormControl<number | null>(
null,
Validators.required,
);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<tui-textfield
iconStart="@tui.euro"
tuiTextfieldSize="m"
>
<label tuiLabel>I am a label</label>

<input
inputmode="decimal"
placeholder="I am placeholder"
tuiInputNumber
[(ngModel)]="value"
/>

<tui-icon
icon="@tui.circle-alert"
style="color: var(--tui-status-negative)"
/>

<tui-icon tuiTooltip="I am a hint" />
</tui-textfield>
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import {Component} from '@angular/core';
import {FormsModule} from '@angular/forms';
import {changeDetection} from '@demo/emulate/change-detection';
import {encapsulation} from '@demo/emulate/encapsulation';
import {TuiIcon, TuiTextfield} from '@taiga-ui/core';
import {TuiInputNumber, TuiTooltip} from '@taiga-ui/kit';

@Component({
standalone: true,
imports: [FormsModule, TuiIcon, TuiInputNumber, TuiTextfield, TuiTooltip],
templateUrl: './index.html',
encapsulation,
changeDetection,
})
export default class Example {
protected value: number | null = null;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<tui-textfield>
<label tuiLabel>Type number like a German</label>

<input
inputmode="decimal"
tuiInputNumber
[tuiNumberFormat]="numberFormat"
[(ngModel)]="value"
/>

<tui-icon
tuiHintDirection="right"
tuiTooltip="In Germany people use comma as decimal separator and point for thousands"
/>
</tui-textfield>
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import {Component} from '@angular/core';
import {FormsModule} from '@angular/forms';
import {changeDetection} from '@demo/emulate/change-detection';
import {encapsulation} from '@demo/emulate/encapsulation';
import type {TuiNumberFormatSettings} from '@taiga-ui/core';
import {TuiIcon, TuiNumberFormat, TuiTextfield} from '@taiga-ui/core';
import {TuiInputNumber, TuiTooltip} from '@taiga-ui/kit';

@Component({
standalone: true,
imports: [
FormsModule,
TuiIcon,
TuiInputNumber,
TuiNumberFormat,
TuiTextfield,
TuiTooltip,
],
templateUrl: './index.html',
encapsulation,
changeDetection,
})
export default class Example {
protected value: number | null = 1_234_567.89;
protected numberFormat: Partial<TuiNumberFormatSettings> = {
decimalSeparator: ',',
thousandSeparator: '.',
};
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<tui-textfield>
<label tuiLabel>Price</label>

<input
inputmode="decimal"
tuiInputNumber
[min]="0"
[prefix]="'USD' | tuiCurrency"
[(ngModel)]="value"
/>
</tui-textfield>
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import {Component} from '@angular/core';
import {FormsModule} from '@angular/forms';
import {changeDetection} from '@demo/emulate/change-detection';
import {encapsulation} from '@demo/emulate/encapsulation';
import {TuiCurrencyPipe} from '@taiga-ui/addon-commerce';
import {TuiTextfield} from '@taiga-ui/core';
import {TuiInputNumber} from '@taiga-ui/kit';

@Component({
standalone: true,
imports: [FormsModule, TuiCurrencyPipe, TuiInputNumber, TuiTextfield],
templateUrl: './index.html',
encapsulation,
changeDetection,
})
export default class Example {
protected value: number | null = null;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<tui-textfield>
<label tuiLabel>Percentage</label>

<input
inputmode="decimal"
postfix="%"
tuiInputNumber
[max]="100"
[min]="0"
[step]="1"
[(ngModel)]="value"
/>
</tui-textfield>
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import {Component} from '@angular/core';
import {FormsModule} from '@angular/forms';
import {changeDetection} from '@demo/emulate/change-detection';
import {encapsulation} from '@demo/emulate/encapsulation';
import {TuiTextfield} from '@taiga-ui/core';
import {TuiInputNumber} from '@taiga-ui/kit';

@Component({
standalone: true,
imports: [FormsModule, TuiInputNumber, TuiTextfield],
templateUrl: './index.html',
encapsulation,
changeDetection,
})
export default class Example {
protected value: number | null = null;
}
Loading
Loading