duetds/date-picker

isDateDisabled is not working

erolabzait opened this issue · 1 comments

I cannot make isDateDisabled work with vanilla js.

I used the example from the docs.

  var pickerDisableWeekend = document.querySelector(".picker-disabled-weekend");
  var PICKER_DISABLED_DATE_FORMAT = /^(\d{4})-(\d{1,2})-(\d{1,2})$/

  pickerDisableWeekend.dateAdapter = {
    parse: function parse() {
      console.log('here 1');
      var value = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : "";
      var createDate = arguments.length > 1 ? arguments[1] : undefined;
      var matches = value.match(PICKER_DISABLED_DATE_FORMAT);
      if (matches) {
        return createDate(matches[3], matches[2], matches[1]);
      }
    },

    format: function format(date) {
      console.log('here 2');
      return ""
              .concat(date.getFullYear(), "-")
              .concat(date.getMonth() + 1, "-")
              .concat(date.getDate());
    },

    isDateDisabled: function isDateDisabled(date, focusedDay) {
      console.log('here 3');
      return (
        date.getDay() === 0 ||
        date.getDay() === 6 ||
        !(date.getFullYear() === focusedDay.getFullYear() && date.getMonth() === focusedDay.getMonth())
      );
    }
  };

In the browser console, i get only the log "here 2".
I used this version https://cdn.jsdelivr.net/npm/@duetds/date-picker@1.3.0/dist/duet/duet.js

That functionality has been merged to master, but not released yet. There were some outstanding tweaks/issues that needed doing first. See #80. I will release in the coming days