Skip to content

Commit

Permalink
fix(range-picker): correct type for min, max, filter properties (#2877)
Browse files Browse the repository at this point in the history
BREAKING CHANGE:
`NbRangepickerComponent`'s `min`, `max` properties are expecting `Date` (or `moment` if using moment adapter) type. `filter` function parameter also corrected to `Date`. `NbDatepicker` now a has second generic `D` to use for `min`, `max`, and `filter` arguments. It should be set to `Date` or `moment` type.
  • Loading branch information
katebatura committed Nov 15, 2021
1 parent a76fccf commit 73cdec0
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ import { convertToBoolProperty, NbBooleanInput } from '../helpers';
/**
* The `NbBasePicker` component concentrates overlay manipulation logic.
* */
export abstract class NbBasePicker<D, T, P> extends NbDatepicker<T> {
export abstract class NbBasePicker<D, T, P> extends NbDatepicker<T, D> {
/**
* Datepicker date format. Can be used only with date adapters (moment, date-fns) since native date
* object doesn't support formatting.
Expand All @@ -73,17 +73,17 @@ export abstract class NbBasePicker<D, T, P> extends NbDatepicker<T> {
/**
* Minimum available date for selection.
* */
abstract min: T;
abstract min: D;

/**
* Maximum available date for selection.
* */
abstract max: T;
abstract max: D;

/**
* Predicate that decides which cells will be disabled.
* */
abstract filter: (T) => boolean;
abstract filter: (D) => boolean;

/**
* Custom day cell component. Have to implement `NbCalendarCell` interface.
Expand Down Expand Up @@ -242,7 +242,7 @@ export abstract class NbBasePicker<D, T, P> extends NbDatepicker<T> {
this.subscribeOnTriggers();
}

getValidatorConfig(): NbPickerValidatorConfig<T> {
getValidatorConfig(): NbPickerValidatorConfig<D> {
return { min: this.min, max: this.max, filter: this.filter };
}

Expand Down Expand Up @@ -397,17 +397,17 @@ export class NbBasePickerComponent<D, T, P>
/**
* Minimum available date for selection.
* */
@Input() min: T;
@Input() min: D;

/**
* Maximum available date for selection.
* */
@Input() max: T;
@Input() max: D;

/**
* Predicate that decides which cells will be disabled.
* */
@Input() filter: (T) => boolean;
@Input() filter: (D) => boolean;

/**
* Custom day cell component. Have to implement `NbCalendarCell` interface.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ export interface NbPickerValidatorConfig<D> {
* Datepicker is an control that can pick any values anyway.
* It has to be bound to the datepicker directive through nbDatepicker input.
* */
export abstract class NbDatepicker<T> {
export abstract class NbDatepicker<T, D = T> {
/**
* HTML input element date format.
* */
Expand All @@ -103,7 +103,7 @@ export abstract class NbDatepicker<T> {
/**
* Returns validator configuration based on the input properties.
* */
abstract getValidatorConfig(): NbPickerValidatorConfig<T>;
abstract getValidatorConfig(): NbPickerValidatorConfig<D>;

abstract show();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ import { CommonModule } from '@angular/common';
import { NbOverlayModule } from '../cdk/overlay/overlay.module';
import { NbListModule } from '../list/list.module';
import { NbCardModule } from '../card/card.module';
import { NbCalendarKitModule } from '../calendar-kit/calendar-kit.module';
import { NbTimePickerDirective } from './timepicker.directive';
import { NbTimePickerComponent } from './timepicker.component';
import { NbTimePickerCellComponent } from './timepicker-cell.component';
import { NbCalendarTimeModelService } from '../calendar-kit/services/calendar-time-model.service';
import { NB_TIME_PICKER_CONFIG, NbTimePickerConfig } from './model';
import { NbCalendarKitModule } from '../calendar-kit/calendar-kit.module';

@NgModule({
imports: [
Expand Down

0 comments on commit 73cdec0

Please sign in to comment.