Giter Site home page Giter Site logo

fetrarij / ngx-daterangepicker-material Goto Github PK

View Code? Open in Web Editor NEW
244.0 11.0 247.0 11.7 MB

Pure Angular 2+ date range picker with material design theme, a demo here:

Home Page: https://fetrarij.github.io/ngx-daterangepicker-material/

License: MIT License

TypeScript 62.54% JavaScript 0.98% HTML 19.28% SCSS 17.19%
angular2 angular4 angular5 daterangepicker directive material range-picker ngx daterange picker

ngx-daterangepicker-material's People

Contributors

angelo510 avatar batgos avatar butterknight avatar dependabot[bot] avatar dmpasilva avatar dntlktshrths avatar duxor avatar fetrarij avatar gcko avatar haykoaghababyan avatar kirankumarsripati avatar manwithtwowatches avatar mateusmcordeiro avatar michaelferwer avatar michielmag avatar neilsb avatar paolo-ciucci avatar praveenpuglia avatar rahul-rocket avatar raymondcheung avatar satyendra07 avatar semyenpukhov avatar steveacalabro avatar styopdev avatar timebutt avatar tosipaulo avatar umernaeem217 avatar veerritu avatar xhotsniperx avatar yousefkhan avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ngx-daterangepicker-material's Issues

Ability to open calendars towards left rather than right

I am trying to use this calendar in my project. But my calendar selection is on the right hand side of the screen. When the calendar is opened, it doesn't have space to show both calendars when the widget opens towards right. Can we add a parameter with which we can open calendar towards left rather than on right.

expected param: [opens]="left"

Month order issue

Hi,

there is an issue with the daterangepicker that when a user goes one month forward and then comes back to original month, the order of month changes.

Example : https://fetrarij.github.io/ngx-daterangepicker-material/full

open the calender from dropdown, now move to next month using the arrow ( > ) on top right corner i.e Dec 2018- Jan 2019, now move back using ( < ) arrow on top left corner, the month now will change to Oct 2018-Dec 2018, instead of Nov 2018- Dec 2018

Select week start date

I don't see an option for changing the start date of the week, ex. set it to Monday.
It would be very useful

transform dd / mm / yyyy It does not work.

Hello,

I am applying this in my html

<div class="row">
    <div class="col s6">
        <input type="text" ngxDaterangepickerMd [(ngModel)]="selected" [locale]="locale" [showCustomRangeLabel]="true" [alwaysShowCalendars]="alwaysShowCalendars" [ranges]="ranges" [showClearButton]="true" [linkedCalendars]="true" [keepCalendarOpeningWithRange]="keepCalendarOpeningWithRange"
            [showRangeLabelOnInput]="showRangeLabelOnInput" class="form-control" placeholder="Rango de fechas..." />
    </div>
</div>

and in my ts:

locale: any = {
customRangeLabel: 'Personalizar2',
format: moment().format('dd/mm/yyyy'),
separator: ' - ', // default is ' - '
cancelLabel: 'Calcel', // detault is 'Cancel'
applyLabel: 'Apply', // detault is 'Apply',
daysOfWeek: [
'Do',
'Lu',
'Ma',
'Mi',
'Ju',
'Vi',
'Sa'
],
monthNames: [
'Enero',
'Febrero',
'Marzo',
'Abril',
'Mayo',
'Junio',
'Julio',
'Agusto',
'Septiembre',
'Octubre',
'Noviembre',
'Diciembre'
],
firstDay: 1 // first day is monday
};

the name change in the months if it works, but in the date format no. It always shows MM / DD / YYYY and I need DD / MM / YYYY how do I solve it?

startDate/endDate keeps getting clobbered in reactive form

I'm trying this date range picker as part of a form group in a reactive form. Whenever I select a date range with the picker the value stored in the form control is correct.

But if I change the value of another control in the form group causing a form group value change event, or if I simply open the picker again, the startDate and endDate values have been clobbered with different and invalid values (endDate < startDate)

NOTE: this problem also happens when using a template-driven (non-reactive) form. But the example here is for the reactive form.

Example:

  • select a date range in the picker:
    image
  • form control value is correct: start: 2018-11-01T00:00:00+11:00 end: 2018-11-03T23:59:59+11:00
  • open the date range picker, selected values have changed and are invalid:
    image

html:

<div class="col-auto">
          <input type="text" name="dateRangeX" id="dateRangeX" ngxDaterangepickerMd class="form-control" formControlName="dateRange"
            [ranges]="pickerRanges" />
</div>

ts:

export class BasicChartComponent implements OnInit, AfterViewInit {

...snip...

  pickerRanges = {
    'Last 7 Days': [moment().subtract(6, 'days'), moment()],
    'Last 30 Days': [moment().subtract(29, 'days'), moment()],
    'Last 90 Days': [moment().subtract(89, 'days'), moment()],
    'This Month': [moment().startOf('month'), moment().endOf('month')],
    'Last Month': [moment().subtract(1, 'month').startOf('month'), moment().subtract(1, 'month').endOf('month')]
  }

  monthForm = new FormGroup({
    charger: new FormControl('all'),
    dateRange: new FormControl({
      endDate: moment(),
      startDate: moment().subtract(1, 'month')
    }),
  });

  constructor(private chargerService: ChargerService) {
  }

Last month doesn't adhere to min and max values?

I am using presets and have a preset called 'Last Month' that looks like this.

export const LAST_MONTH: DateRangePreset = {
  name: 'Last Month',
  range: [
    moment()
      .subtract(1, 'month')
      .startOf('month'),
    moment()
      .subtract(1, 'month')
      .endOf('month')
  ]
};

I have this construct for internal purposes and just send the range bit to ngx-daterangepicker-material.

This doesn't seem to be following the minDate and maxDate settings. I have another preset for Last 30 Days which seems to be working fine.

export const LAST_30_DAYS: DateRangePreset = {
  name: 'Last 30 Days',
  range: [moment().subtract(30, 'days'), moment().subtract(1, 'days')]
};

Screenshots

Last Month

image

Last 30 Days

image

Clear selection

This is a feature request.
It would be useful if there was a way to clear selection. I use this to filter records. It would be very useful if I could just clear the filter to get all values, instead of picking a large timespan (and still filtering with the values in the DB or wherever).

Currently, I tried deleting it with backspace, but as soon as the input is focused the calendar opens and overlaps it. A button inside calendar for clearing would be nice. Also an exposed method would be useful, so for example I could add a suffix icon to the input that calls it

Allow blocking a range of list of dates.

I want to use this date picker for a scheduling app.

The minDate and maxDate is step towards what I want to use it for - what I would like to do is supply it with a list of dates that are already taken, and have those be blocked out.

Is this feature already available or is it in the works?

Is there a way to know which preset range was selected?

I am creating a component where I am gonna be using two of these range pickers and I want to know which range I have selected in the first so I can programmatically change the range on the second one and vice versa.

Currently, I didn't find a way to figure out which range is selected be it a custom one or one of the supplied presets.

Is there a way to do this ?

No change event

There is no change event that we could subscribe to when a change happens.
The binding to the member variable works, but there is no event that signals when the change happens.

Adding the ngxDaterangepickerMd seems to disable the native inputs (change) method.
(ngModelChange) does trigger, but the argument is always a blank object for some reason.
Also the selection should happen when it's applied (button click or auto-apply). Currently the model is changed as soon as the second date is selected, not when the selection is applied.

Unable to select custom date range from calendar in IE11

User is not able to select date range from available calendar. When click on dates from calendar, then date is not selected in IE. Its working perfectly on chrome but it is having some issues on IE11.

After debugging, I found there is a issue in ngx-daterangepicker-material.js under esm5 file; line 722; 'e' parameter on 'clickdate' function giving wrong element. e. target expecting 'td' but on IE11 it is coming as 'span' and that's why it is failing.

for timebeing I have made one change and now it is working on IE11.
daterangepicker

Locale.format does not change date formats

if (this.timePicker && !this.locale.format) {
this.locale.format = moment.localeData().longDateFormat('lll');
} else {
this.locale.format = moment.localeData().longDateFormat('L');
}

Looking at the code above, it appears that even if a format is passed as part of the locale, it is not used.

I'm wondering if something like this would be more preferable:

if (!this.locale.format) { 
    if (this.timePicker) { 
        this.locale.format = moment.localeData().longDateFormat('lll'); 
    } else { 
        this.locale.format = moment.localeData().longDateFormat('L'); 
    } 
 }

This sets the format when one is not passed based on whether the timepicker is enabled or not. If a format is passed, we do not need to do anything.

What do you think?

I'm aware that the format could be set by overriding the moment formats for the relevant locale but I'm not sure that's very easy to do globally.

AOT compilation error

Hello, I am using v.1.3.0 with Angular 7 and works fine with a simple ng-serve, but when I build the application with ng-build and AOT enabled, it fails with the following error:

ERROR in Error during template compile of 'AppModule'
  Function calls are not supported in decorators but 'weekdaysMin' was called in 'ɵb'
    'ɵb' calls 'weekdaysMin' at ../ngx-daterangepicker-material/ngx-daterangepicker-material.ts(24,17).

I import the picker module in my app module with NgxDaterangepickerMd.forRoot().

show "2nd / to" calendar as per maxDate if provided

As, we have provided maxDate, there is no use of showing next month as 2nd calendar as those dates will not be selectable - instead, can it be maxDate's month as second calendar and prev month as first calendar?

image

Different models

Model properties are different!

In Custom ranges model is: startDate and endDate.
In Full Options model is: start and end.

I start my ngModel with { startDate: moment(), endDate: moment() };
But after change value, ngModel value is {start: Moment, end: Moment}.

Inline mode

Add ability to set the calendar to inline.
With this options, it could be easy to set the calendar in a modal.
in this case we can track the apply event (may close the modal ...)

Positioning of the calendar using drop property

When i'm using the drop property "up" on an input to toggle the drop menu, the menu doesn"t systematically open on the desired place. I'm using Angular 6.0.0.

You can try this on your own example, using property center/top.
Any idea how to solve this?

Thks

Setting the timePicker to true doesn't show the select boxes to choose times

Hey there

First of all, great Daterangepicker component! I've been looking out for one that uses material design.

But setting the timePicker boolean to true doesn't doesn't show the select boxes to choose times in addition to dates.

Perhaps there is something I missed? I am using the code below to achieve my goal.

<mat-form-field>
     <span matPrefix class="fa fa-calendar"></span>
     <input type="text" matInput ngxDaterangepickerMd [locale]="{format:'DD/MM/YYYY HH:mm',firstDay:1}" />
</mat-form-field>
@ViewChild(DaterangepickerDirective) daterangeDirective: DaterangepickerDirective
this.daterangeDirective.picker.timePicker = true;

setPosition

In some cases the datepicker is not well placed, I have seen that you have the function setPosition, how do I trigger that function? Thank you

change language with locale object

Hi,
I could not find how to change the language with the locale object. Is there any way of doing so by config, like in 'matDatepicker'?
thanks.

prev & next icons are missing in corner case

Thanks for this great project!
I found it does not show the <, > icons when I set minDate (say 2017-May-22) and maxDate (say 2018-May-21); When I use "from" date calendar and go to previous months it shows the < icon, but once it reaches May (in this case), it does not show any icons in both the calendars - so we cannot go to any other months. Issue could be it does not consider year when comparing months.

image

Template parse errors: 'ngx-daterangepicker-material' is not a known element: when using as inline element

I have added NgxDaterangepickerMd to my @NgModule imports, and using the non-inline mode works fine.

eg.

    <input ngxDaterangepickerMd [(ngModel)]="selected"  matInput placeholder="Date" [(ngModel)]="value">

However - using it as an inline component doesn't seem to be working properly:

<ngx-daterangepicker-material (choosedDate)="choseDate($event)">
  </ngx-daterangepicker-material>
compiler.js:215 Uncaught Error: Template parse errors:
'ngx-daterangepicker-material' is not a known element:
1. If 'ngx-daterangepicker-material' is an Angular component, then verify that it is part of this module.
2. If 'ngx-daterangepicker-material' is a Web Component then add 'CUSTOM_ELEMENTS_SCHEMA' to the '@NgModule.schemas' of this component to suppress this message. ("
  </section>

  [ERROR ->]<ngx-daterangepicker-material (choosedDate)="choseDate($event)">
  </ngx-daterangepicker-material>

Default Date Range For Inline Mode

Hi, Is it possible to pass default date range for date picker in inline mode , unable to use ngModel in date range picker while using inline mode

Ability to style/mark dates

In the original daterangepicker project there were a couple of functions to style and mark as invalid certain days.

Is that possible with yours?

The functions I'm referring to are:
isInvalidDate: (function) A function that is passed each date in the two calendars before they are displayed, and may return true or false to indicate whether that date should be available for selection or not.
isCustomDate: (function) A function that is passed each date in the two calendars before they are displayed, and may return a string or array of CSS class names to apply to that date's calendar cell.

The year on January Title is for previous year.

https://fetrarij.github.io/ngx-daterangepicker-material/single-datepicker

If you start scrolling back the months, it goes from "Feb 2018" to "Jan 2017".

I believe the issue is here in daterangepicker.component.html

<ng-container *ngIf="!showDropdowns || !calendarVariables.left.dropdowns">
{{this.locale.monthNames[calendarVariables?.left?.calendar[1][1].month()]}} {{ calendarVariables?.left?.calendar[0][0].format(" YYYY")}}

{{ calendarVariables?.left?.calendar[0][0].format(" YYYY")}}
Is asking for the year of the first date in the top left of the calendar.
For January this date is usually a date in December.

Probable solution is to do the same thing as the Month, and get the 2nd date of the second row, which should always be in the same year as the current month:
{{ calendarVariables?.left?.calendar[1][1].format(" YYYY")}}

isInvalidDate still allow for selecting a range on either side of the invalid date.

This is perhaps a tricky issue as, perhaps you want to allow people to do that (ie. blocking out weekends, but allowing people to still select that range).

In which case - the user could apply their own 'unselect the range' function with datesUpdated - but for the inline picker this means you need to be able to set the set the start date and end date as inputs.

Applied range does not have 'active' class

When you apply a range filter and re-open popup again "applied" range should be marked some way (e.g. with class 'active', like it is on jQuery version), but it is not.

UI responsiveness

The date picker is not showing properly on small screens. It should be responsive.

Inline and locale issue

Hi,

When using the DaterangepickerComponent inline and setting the following locale

<ngx-daterangepicker-material [locale]="{format: 'DD/MM/YYYY HH:mm:ss', firstDay: 1}" >
</ngx-daterangepicker-material>

It throws this error

image

It looks like it has overwritten the locale entirely as it is not able to push the daysOfWeek array further since it is 'undefined'

startDate and endDate inverted for custom range picker

Hi!

thanks for this nice component! Since angular material isn't implementing a date range picker, your component is very useful.

I have noticed a bug, reproducible with your demo page :

issue-start-and-end-date

startDate and endDate are inverted. The endDate is before the startDate.

Could you look at it?

Display calendars and ranges together

Is there any way to display both the calendars and the custom ranges in the same time, like the bootstrap picker does? As soon as I add the ranges the calendars disappear, and only the menu with custom ranges shows.
If it's not supported it would be useful feature request. These things are vastly used on admin UIs, so having things like "last month", "last quarter" really improves the UX.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.