Skip to content

Commit

Permalink
fix: added minDate and maxDate in the datepicker
Browse files Browse the repository at this point in the history
  • Loading branch information
rkkp1023 committed Nov 15, 2024
1 parent 6b449df commit 0533ce7
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
12 changes: 12 additions & 0 deletions src/datepicker/datepicker.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,16 @@ export class DatePicker implements

@Input() plugins = [];

/**
* The minimum date that a user can start picking from.
*/
@Input() minDate: string | number;

/**
* The maximum date that a user can pick to.
*/
@Input() maxDate: string | number;

@Input()
set flatpickrOptions(options: Partial<Options>) {
this._flatpickrOptions = Object.assign({}, this._flatpickrOptions, options);
Expand All @@ -240,6 +250,8 @@ export class DatePicker implements
plugins,
dateFormat: this.dateFormat,
locale: languages.default?.default[this.language] || languages.default[this.language],
maxDate: this.maxDate,
minDate: this.minDate,
// Little trick force "readonly mode" on datepicker input.
// Docs: Whether clicking on the input should open the picker.
// You could disable this if you wish to open the calendar manually with.open().
Expand Down
10 changes: 8 additions & 2 deletions src/datepicker/datepicker.stories.ts
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,8 @@ const RangeTemplate = (args) => ({
[warnText]="warnText"
[rangeInvalid]="invalid"
[rangeInvalidText]="invalidText"
[minDate]="minDate"
[maxDate]="maxDate"
[dateFormat]="dateFormat"
[value]="value"
(valueChange)="valueChange($event)"
Expand All @@ -153,6 +155,8 @@ const RangeTemplate = (args) => ({
[warnText]="warnText"
[rangeWarn]="warn"
[rangeWarnText]="warnText"
[minDate]="minDate"
[maxDate]="maxDate"
[dateFormat]="dateFormat"
(valueChange)="valueChange($event)"
[helperText]="helperText">
Expand All @@ -162,8 +166,10 @@ const RangeTemplate = (args) => ({
export const Range = RangeTemplate.bind({});
Range.args = {
dateFormat: "d/m/Y",
value: ["01/02/24", "08/02/24"],
language: "en"
value: ["02/11/24", "08/11/24"],
language: "en",
minDate: "01/11/24",
maxDate: "30/11/24"
};
Range.argTypes = {
language: {
Expand Down

0 comments on commit 0533ce7

Please sign in to comment.