17.0.1 • Published 6 months ago

ngx-multiple-dates v17.0.1

Weekly downloads
15
License
MIT
Repository
github
Last release
6 months ago

Angular Multiple Dates

Multiple dates picker based on Angular Material.

Example

Demo

Installation

  1. Install dependency:
npm install --save ngx-multiple-dates
  1. Include NgxMultipleDatesModule to your module:
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
import { MatNativeDateModule } from '@angular/material/core';
import { MatDatepickerModule } from '@angular/material/datepicker';
import { MatIconModule } from '@angular/material/icon';
import { NgxMultipleDatesModule } from 'ngx-multiple-dates'; // module import

@NgModule({
  imports: [
    BrowserModule,
    BrowserAnimationsModule,
    MatNativeDateModule,
    MatDatepickerModule,
    MatIconModule,
    NgxMultipleDatesModule // import to Angular
    // ...
  ],
  // ...
})
export class AppModule { }
  1. Styles:
  • Add one of the prebuilt themes to angular.json or your styles file:
@import 'ngx-multiple-dates/prebuilt-themes/indigo-pink.css';
  • Or you can use custom SCSS theme:
@import '~@angular/material/theming';
@import '~ngx-multiple-dates/theming'; // import library theme

@include mat-core();
// Palette
$primary: mat-palette($mat-indigo);
$accent:  mat-palette($mat-pink);

$theme: mat-light-theme($primary, $accent); // theme
@include angular-material-theme($theme); // apply Angular Material styles
@include ngx-multiple-dates-theme($theme); // apply Angular Multiple Dates styles

// ...

Available pre-built themes:

  • deeppurple-amber.css
  • indigo-pink.css
  • pink-bluegrey.css
  • purple-green.css

Dependencies

  • Angular
  • Angular CDK
  • Angular Material
  • RxJs

Examples

<mat-form-field>
  <ngx-multiple-dates [matDatepicker]="picker" placeholder="Excluded Dates" name="excludedDates"
                      [(ngModel)]="model">
  </ngx-multiple-dates>
  <mat-datepicker-toggle matPrefix [for]="picker"></mat-datepicker-toggle>
  <mat-datepicker #picker></mat-datepicker>
</mat-form-field>

API reference

MultipleDatesComponent<D = Date>

Selector: ngx-multiple-dates

Exported as: ngxMultipleDates

Properties

NameDescription
Input
@Input()value: D \| nullThe value of the ngx-multiple-dates control.
@Input()matDatepicker: MatDatepicker<D>The datepicker that this ngx-multiple-dates element is associated with.
@Input()color: ThemePaletteTheme color palette for the component.
@Input()placeholder: stringPlaceholder to be shown if no value has been selected.
@Input()required: booleanWhether the component is required.
@Input()disabled: booleanWhether the component is disabled.
@Input()matDatepickerFilter: (date: D) => booleanFunction that can be used to filter out dates within the datepicker.
@Input()max: D \| nullThe maximum valid date.
@Input()min: D \| nullThe minimum valid date.
@Input()id: stringUnique id of the element.
@Input()errorStateMatcher: ErrorStateMatcherAn object used to control when error messages are shown. Color palette to use on the datepicker's calendar.
Output
@Output()dateChange: EventEmitter<MatDatepickerInputEvent<D>>Emits when a change event is fired on this ngx-multiple-dates element.
Properties
resetModel: DateModel used to reset datepicker selected value, so unselect just selectad date will be possible.
closeOnSelected: booleanWhether datepicker should be closed on date selected, or opened to select more dates.
empty: booleanWhether the select has a value.
shouldLabelFloat: booleanWhether the MatFormField label should try to float.
focused: booleanWhether ngx-multiple-dates element has focus.
errorState: booleanWhether the control is in an error state.
stateChanges: Observable<void>Stream that emits whenever the state of the control changes such that the parent MatFormField needs to run change detection.
ngControl: NgControlForm control to manage component.
controlType: 'ngx-multiple-dates'A name for this control that can be used by mat-form-field.

Methods

  • focus Focuses the ngx-multiple-dates element.

  • blur Used to leave focus from the ngx-multiple-dates element.

  • setDescribedByIds Sets the list of element IDs that currently describe this control.

Parameters
ids: string[]Ids to set.
  • onContainerClick Handles a click on the control's container.

  • validate Performs synchronous validation for the control.

Parameters
control: AbstractControlThe control to validate against.
Returns
ValidationErrors \| nullA map of validation errors if validation fails, otherwise null.
  • dateClass Function used to add CSS classes to selected dates.
Parameters
date: DDate to check if classes should be applied.
Returns
MatCalendarCellCssClassesCSS classes to apply.
  • dateChanged Fires when a change event is fired on the datepicker <input />.
Parameters
event: MatDatepickerInputEvent<D>Change event.
  • remove Removes selected chip from the list.
Parameters
date: DValue to remove.

Build

Run npm run build to build the project. The build artifacts will be stored in the dist/ directory. Use the --prod flag for a production build.

Development server

Run npm start for a dev server. Navigate to http://localhost:4200/. The app will automatically reload if you change any of the source files.

17.0.1

6 months ago

15.0.0

11 months ago

15.0.1

11 months ago

16.0.0

11 months ago

14.3.0

2 years ago

14.3.1

2 years ago

14.2.0

2 years ago

14.1.1

2 years ago

14.1.0

2 years ago

14.0.0

2 years ago

13.0.0

2 years ago

13.1.0

2 years ago

12.0.0

2 years ago

1.1.0

3 years ago

1.0.0

4 years ago

1.0.0-rc.1

4 years ago

1.0.0-rc.0

4 years ago

1.0.0-beta.0

4 years ago