Skip to content
Open
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
3 changes: 3 additions & 0 deletions .storybook/preview.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,9 @@ const preview: Preview = {
globals: { theme: 'light' },
},
controls: {
// Полная таблица в панели Controls: имя, описание, тип, дефолт и группы категорий.
// В компактном режиме Storybook 10 описание пропса не отображается.
expanded: true,
matchers: {
color: /(background|color)$/i,
date: /Date$/i
Expand Down
43 changes: 22 additions & 21 deletions docs/components-api/inputtext.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,27 +4,28 @@

> ✅ **Реализован**: `ExtraInputTextComponent` (`@cdek-it/angular-ui-kit`) соответствует спецификации.

| Свойство | Описание | Типизация | По умолчанию |
| ---------------- | ----------------------------------------------------------------------------- | ---------------------------------- | ------------ |
| `placeholder` | текст подсказки внутри поля | `string` | `''` |
| `label` | текст названия поля | `string` | `''` |
| `labelPosition` | положение лейбла | `top \| left` | `top` |
| `floatLabel` | плавающий лейбл внутри поля (перекрывает `labelPosition`) | `boolean` | `false` |
| `clearable` | отображение иконки для очистки поля | `boolean` | `false` |
| `caption` | текст пояснения под полем | `string` | `''` |
| `info` | текст с доп. информацией (показывается в тултипе иконки ti-info-circle) | `string` | `''` |
| `size` | размер поля | `small \| base \| large \| xlarge` | `base` |
| `fluid` | растягивает поле на всю ширину контейнера | `boolean` | `false` |
| `type` | тип поля input | `text \| password` | `text` |
| `readonly` | только для чтения | `boolean` | `false` |
| `required` | поле обязательно для заполнения | `boolean` | `false` |
| `name` | имя поля (нативный атрибут `name`); используется браузером для автозаполнения | `string` | — |
| `autocomplete` | значение нативного атрибута `autocomplete` | `string` | — |
| `maxLength` | максимальное количество символов | `number` | — |
| `ariaLabel` | метка для программ экранного доступа | `string` | — |
| `ariaLabelledBy` | `id` внешнего элемента-метки для доступности | `string` | — |
| `autofocus` | автофокус при монтировании компонента | `boolean` | `false` |
| `tabindex` | порядок перехода по Tab | `number` | — |
| Свойство | Описание | Типизация | По умолчанию |
| ----------------- | ------------------------------------------------------------------------------- | ---------------------------------- | ------------ |
| `placeholder` | текст подсказки внутри поля | `string` | `''` |
| `label` | текст названия поля | `string` | `''` |
| `labelPosition` | положение лейбла: сверху, плавающий внутри поля или слева | `default \| float \| left` | `default` |
| `requiredMark` | маркер «\*» перед лейблом (только визуальный, валидацию не включает) | `boolean` | `false` |
| `clearable` | отображение иконки для очистки поля | `boolean` | `false` |
| `caption` | текст пояснения под полем | `string` | `''` |
| `captionSeverity` | вариант подписи (цвет и иконка): `base`, `success`, `warning`, `danger`, `info` | `ExtraCaptionSeverity` | `base` |
| `info` | текст с доп. информацией (показывается в тултипе иконки ti-info-circle) | `string` | `''` |
| `size` | размер поля | `small \| base \| large \| xlarge` | `base` |
| `fluid` | растягивает поле на всю ширину контейнера | `boolean` | `false` |
| `type` | тип поля input | `text \| password` | `text` |
| `readonly` | только для чтения | `boolean` | `false` |
| `required` | поле обязательно для заполнения | `boolean` | `false` |
| `name` | имя поля (нативный атрибут `name`); используется браузером для автозаполнения | `string` | — |
| `autocomplete` | значение нативного атрибута `autocomplete` | `string` | — |
| `maxLength` | максимальное количество символов | `number` | — |
| `ariaLabel` | метка для программ экранного доступа | `string` | — |
| `ariaLabelledBy` | `id` внешнего элемента-метки для доступности | `string` | — |
| `autofocus` | автофокус при монтировании компонента | `boolean` | `false` |
| `tabindex` | порядок перехода по Tab | `number` | — |

# Стекозависимые пропсы

Expand Down
65 changes: 39 additions & 26 deletions src/lib/components/inputtext/inputtext.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,17 +27,27 @@ import { IconField } from 'primeng/iconfield';
import { InputIcon } from 'primeng/inputicon';
import { FloatLabel } from 'primeng/floatlabel';
import { ExtraTooltipDirective } from '@cdek-it/angular-ui-kit/components/tooltip';
import { ExtraCaptionComponent, ExtraCaptionSeverity } from '@cdek-it/angular-ui-kit/components/caption';

export type ExtraInputTextSize = 'small' | 'base' | 'large' | 'xlarge';
export type ExtraInputTextLabelPosition = 'top' | 'left';
export type ExtraInputTextLabelPosition = 'default' | 'float' | 'left';
export type ExtraInputTextType = 'text' | 'password';

let nextInputId = 0;

@Component({
selector: 'extra-input-text',
standalone: true,
imports: [InputText, IconField, InputIcon, FloatLabel, NgClass, NgTemplateOutlet, ExtraTooltipDirective],
imports: [
InputText,
IconField,
InputIcon,
FloatLabel,
NgClass,
NgTemplateOutlet,
ExtraTooltipDirective,
ExtraCaptionComponent
],
host: { style: 'display: contents' },
providers: [
{
Expand All @@ -55,27 +65,26 @@ let nextInputId = 0;
<!-- Без label/caption поле не оборачиваем — сохраняем прежнюю DOM-структуру
(важно для p-inputgroup, где input обязан быть прямым flex-элементом). -->
@if (label || caption) {
<!-- floatLabel перекрывает labelPosition: лейбл уезжает внутрь поля, строчной раскладки нет -->
<div class="extra-inputtext" [class.extra-inputtext--left]="labelPosition === 'left' && !floatLabel">
@if (label && labelPosition === 'left' && !floatLabel) {
<div class="extra-inputtext" [class.extra-inputtext--left]="labelPosition === 'left'">
@if (label && labelPosition === 'left') {
<ng-container [ngTemplateOutlet]="labelTpl" />
}
<div class="extra-inputtext-body">
@if (floatLabel) {
@if (labelPosition === 'float') {
<p-floatlabel variant="in">
<ng-container [ngTemplateOutlet]="fieldTpl" />
@if (label) {
<ng-container [ngTemplateOutlet]="labelTpl" />
}
</p-floatlabel>
} @else {
@if (label && labelPosition === 'top') {
@if (label && labelPosition === 'default') {
<ng-container [ngTemplateOutlet]="labelTpl" />
}
<ng-container [ngTemplateOutlet]="fieldTpl" />
}
@if (caption) {
<div class="extra-inputtext-caption">{{ caption }}</div>
<extra-caption [severity]="captionSeverity">{{ caption }}</extra-caption>
}
</div>
</div>
Expand All @@ -85,8 +94,11 @@ let nextInputId = 0;

<ng-template #labelTpl>
<label class="extra-inputtext-label" [for]="inputId">
@if (requiredMark) {
<span class="extra-inputtext-required" aria-hidden="true">*</span>
}
{{ label }}
@if (info) {
@if (info && labelPosition !== 'float') {
<i class="extra-inputtext-label-icon ti ti-info-circle" [extra-tooltip]="info"></i>
}
</label>
Expand All @@ -103,8 +115,8 @@ let nextInputId = 0;
[fluid]="fluid"
[type]="type"
[disabled]="disabled"
[invalid]="invalid"
[readOnly]="readonly"
[invalid]="invalid"
[autofocus]="autofocus"
[attr.placeholder]="placeholder || null"
[attr.name]="name || null"
Expand All @@ -118,17 +130,17 @@ let nextInputId = 0;
(input)="onInput($event)"
(blur)="onTouched()"
/>
@if (modelValue && !readonly && !disabled) {
<p-inputicon
class="ti ti-x"
role="button"
aria-label="Очистить поле"
tabindex="0"
(click)="clearValue()"
(keydown.enter)="clearValue()"
(keydown.space)="$event.preventDefault(); clearValue()"
></p-inputicon>
}
<p-inputicon
class="ti ti-x"
role="button"
aria-label="Очистить поле"
tabindex="0"
[style.visibility]="modelValue && !readonly && !disabled ? 'visible' : 'hidden'"
[style.pointerEvents]="modelValue && !readonly && !disabled ? 'auto' : 'none'"
(click)="clearValue()"
(keydown.enter)="clearValue()"
(keydown.space)="$event.preventDefault(); clearValue()"
></p-inputicon>
</p-iconfield>
} @else {
<input
Expand All @@ -139,8 +151,8 @@ let nextInputId = 0;
[fluid]="fluid"
[type]="type"
[disabled]="disabled"
[invalid]="invalid"
[readOnly]="readonly"
[invalid]="invalid"
[autofocus]="autofocus"
[attr.placeholder]="placeholder || null"
[attr.name]="name || null"
Expand Down Expand Up @@ -168,17 +180,18 @@ export class ExtraInputTextComponent implements ControlValueAccessor, OnInit, On

@Input() placeholder = '';
@Input() label = '';
@Input() labelPosition: ExtraInputTextLabelPosition = 'top';
/** Плавающий лейбл внутри поля (PrimeNG `p-floatlabel`); перекрывает `labelPosition`. */
@Input({ transform: booleanAttribute }) floatLabel = false;
/** Показывает маркер «*» перед лейблом (визуальный, валидацию не включает). */
@Input() requiredMark = false;
@Input() labelPosition: ExtraInputTextLabelPosition = 'default';
@Input({ transform: booleanAttribute }) clearable = false;
@Input({ transform: booleanAttribute }) readonly = false;
@Input() caption = '';
@Input() captionSeverity: ExtraCaptionSeverity = 'base';
@Input() info = '';
@Input() size: ExtraInputTextSize = 'base';
/** Растягивает поле на всю ширину контейнера. */
@Input({ transform: booleanAttribute }) fluid = false;
@Input() type: ExtraInputTextType = 'text';
@Input({ transform: booleanAttribute }) readonly = false;
/** Поле обязательно для заполнения; в Angular работает как NG_VALIDATORS-валидатор. */
@Input({ transform: booleanAttribute }) required = false;
@Input() name: string | undefined = undefined;
Expand Down
Loading
Loading