Skip to content

Commit

Permalink
fix(kit): InputDateMulti fix disableItemHandler (#6946)
Browse files Browse the repository at this point in the history
  • Loading branch information
vladimirpotekhin authored Mar 5, 2024
1 parent 5fb91f3 commit 8d7917e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import {
tuiIsString,
type TuiMapper,
TuiMonth,
TuiTypedMapper,
} from '@taiga-ui/cdk';
import {
TUI_DEFAULT_MARKER_HANDLER,
Expand Down Expand Up @@ -239,6 +240,11 @@ export class TuiInputDateMultiComponent
> = handler => stringifiable =>
tuiIsString(stringifiable) || handler(stringifiable.item);

protected readonly valueMapper: TuiTypedMapper<
[readonly TuiDay[]],
ReadonlyArray<TuiStringifiableItem<TuiDay>>
> = value => value.map(item => new TuiStringifiableItem(item, item => String(item)));

protected onEnter(search: string): void {
if (!this.tagValidator(search)) {
return;
Expand All @@ -256,14 +262,14 @@ export class TuiInputDateMultiComponent
this.done();
}

protected onValueChange(value: readonly TuiDay[]): void {
protected onValueChange(value: ReadonlyArray<TuiStringifiableItem<TuiDay>>): void {
this.control?.updateValueAndValidity({emitEvent: false});

if (!value.length) {
this.onOpenChange(true);
}

this.value = value;
this.value = value.map(({item}) => item);
}

protected onDayClick(value: TuiDay): void {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@
[inputHidden]="inputHidden"
[maskito]="maskitoOptions"
[nativeId]="nativeId"
[ngModel]="value"
[ngModel]="value | tuiMapper: valueMapper"
[placeholder]="placeholder"
[pseudoFocus]="pseudoFocus"
[pseudoHover]="pseudoHover"
[pseudoInvalid]="computedInvalid"
[readOnly]="readOnly"
[removable]="!nativeDropdownMode"
[rows]="rows"
[tagValidator]="tagValidator"
[tagValidator]="tagValidator | tuiMapper: disabledItemHandlerWrapper"
[tuiTextfieldFiller]="(filler$ | async) || ''"
[tuiTextfieldIcon]="calendarIcon && iconContent"
(keydown.enter)="onEnter(inputTag.search || '')"
Expand Down

0 comments on commit 8d7917e

Please sign in to comment.