Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using it's URL and the proper URL extention.

+ add another resource

JavaScript

Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <div class="datepicker ${backwards ? '--reverse' : ''} ${transition ? '--transition' : ''} --month-${currentMonth}" with.bind="$this">
  <nav class="datepicker-nav">
    <div class="datepicker-nav-controls">
      <a class="datepicker-nav-controls-action" click.trigger="prev($this, $event)">   
          <svg class="ux-icon-svg" width="16" height="16">
            <use xlink:href="#chevron-circle-left"></use>            
        </svg>
      </a>
      <a class="datepicker-nav-controls-action" click.trigger="next($this, $event)">      
        <svg class="ux-icon-svg" width="16" height="16">
          <use xlink:href="#chevron-circle-right"></use>          
        </svg>
      </a>
    </div>
    <div class="datepicker-nav-title">
      <compose view-model.bind="titleVM & defer:vmChanged"  
               model.bind="headerData"
               swap-order="with"
               containerless></compose>
    </div>    
  </nav>
  <div class="datepicker-calendar-wrapper">
    <compose view-model.bind="calendarVM & defer:vmChanged" 
             model.bind="calendarData" 
             swap-order="with"
             containerless></compose>
  </div>
</div>


<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" id="svg-icons" style="display: none;">
  <symbol data-bind="attr:{id:name, viewBox: viewBox}" viewBox="0 0 512 512" id="chevron-circle-left">
    <path d="M504 256C504 119 393 8 256 8S8 119 8 256s111 248 248 248 248-111 248-248zM256 472c-118.7 0-216-96.1-216-216 0-118.7 96.1-216 216-216 118.7 0 216 96.1 216 216 0 118.7-96.1 216-216 216zm-86.6-224.5l115.1-115c4.7-4.7 12.3-4.7 17 0l7.1 7.1c4.7 4.7 4.7 12.3 0 17L209 256l99.5 99.5c4.7 4.7 4.7 12.3 0 17l-7.1 7.1c-4.7 4.7-12.3 4.7-17 0l-115.1-115c-4.6-4.8-4.6-12.4.1-17.1z"/>
  </symbol>
  <symbol data-bind="attr:{id:name, viewBox: viewBox}" viewBox="0 0 512 512" id="chevron-circle-right">
    <path d="M8 256c0 137 111 248 248 248s248-111 248-248S393 8 256 8 8 119 8 256zM256 40c118.7 0 216 96.1 216 216 0 118.7-96.1 216-216 216-118.7 0-216-96.1-216-216 0-118.7 96.1-216 216-216zm86.6 224.5l-115.1 115c-4.7 4.7-12.3 4.7-17 0l-7.1-7.1c-4.7-4.7-4.7-12.3 0-17L303 256l-99.5-99.5c-4.7-4.7-4.7-12.3 0-17l7.1-7.1c4.7-4.7 12.3-4.7 17 0l115.1 115c4.6 4.8 4.6 12.4-.1 17.1z"/>
  </symbol>
</svg>
              
            
!

CSS

              
                // Demo Setup Styles
* {
  @include box-sizing(border-box);
}
*:before,
*:after {
  @include box-sizing(border-box);
}

body {
  min-width: unset;
  width: 100%;
  @include display(flex);
  @include justify-content(center);
  @include align-items(center);
} 

// Datepicker
// ----------------------------------------------
// 
// 

$datepicker-base-color-map: (
  'palette-name': $cm-color--control, 
  'background-shade': '50',
);
$datepicker-base-type-map: 'omega';
$datepicker-base-space-map: 'md';

$datepicker-title-type-map: 'delta';
$datepicker-title-space-map: 'lg';

@mixin datepicker-styles($color-map: $datepicker-base-color-map, $type-map: null) {
  & {
    &-nav {
      color: cm-color($cm-color--primary, '500');
      &-title {
        
      }
    }
    &-calendar {
      &-action {
        
      }
    }
  }
}

$datepicker-day-padding-horizontal: null !default;
$datepicker-day-padding-vertical:   null !default;
$datepicker-day-height:             null !default;

$datepicker-day-font-size:          null !default;
$datepicker-day-line-height:        null !default;

$datepicker-day-font-style:         null !default;
$datepicker-day-font-variant:       null !default;
$datepicker-day-font-weight:        null !default;
$datepicker-day-font-family:        null !default;

$datepicker-day-actual-height:      null !default;

$datepicker-title-padding-horizontal: null !default;
$datepicker-title-padding-vertical:   null !default;
$datepicker-title-height:             null !default;

$datepicker-title-font-size:          null !default;
$datepicker-title-line-height:        null !default;

$datepicker-title-actual-height:      null !default;

@mixin datepicker-size-context($space-map: $datepicker-base-space-map, $type-map: $datepicker-base-type-map, 
                               $title-space-map: $datepicker-title-space-map, $title-type-map: $datepicker-title-type-map) {
  $scope-day-padding-horizontal:  $datepicker-day-padding-horizontal;
  $scope-day-padding-vertical:    $datepicker-day-padding-vertical;
  $scope-day-height:              $datepicker-day-height;

  $scope-day-font-size:           $datepicker-day-font-size;
  $scope-day-line-height:         $datepicker-day-line-height; 
   
  $scope-day-font-style:          $datepicker-day-font-style;      
  $scope-day-font-variant:        $datepicker-day-font-variant;    
  $scope-day-font-weight:         $datepicker-day-font-weight;     
  $scope-day-font-family:         $datepicker-day-font-family; 

  $scope-day-actual-height:       $datepicker-day-actual-height;

  @include cm-spacing-context($space-map) {
    $datepicker-day-height: $min-height                         !global;
    $datepicker-day-padding-vertical: $padding-vertical         !global; 
    $datepicker-day-padding-horizontal: $padding-horizontal   !global;
  }

  $datepicker-day-actual-height: $datepicker-day-height        !global;
  @include cm-typography-context($type-map) {
    $datepicker-day-font-size:       $font-size            !global;  
    $datepicker-day-line-height:     $line-height          !global;
   
    $datepicker-day-font-style:      $font-style           !global;      
    $datepicker-day-font-variant:    $font-variant         !global;    
    $datepicker-day-font-weight:     $font-weight          !global; 
    $datepicker-day-font-family:     $font-family          !global;
    @if $space-map {
      $datepicker-day-actual-height: $datepicker-day-line-height + (2 * $datepicker-day-padding-vertical)  !global;
    }
  }
                                 
  $scope-title-padding-horizontal:  $datepicker-title-padding-horizontal;
  $scope-title-padding-vertical:    $datepicker-title-padding-vertical;
  $scope-title-height:              $datepicker-title-height;

  $scope-title-font-size:           $datepicker-title-font-size;
  $scope-title-line-height:         $datepicker-title-line-height; 

  $scope-title-actual-height:       $datepicker-title-actual-height;

  @include cm-spacing-context($title-space-map) {
    $datepicker-title-height: $min-height                         !global;
    $datepicker-title-padding-vertical: $padding-vertical         !global; 
    $datepicker-title-padding-horizontal: $padding-horizontal   !global;
  }

  $datepicker-title-actual-height: $datepicker-title-height        !global;
  @include cm-typography-context($title-type-map) {
    $datepicker-title-font-size:       $font-size            !global;  
    $datepicker-title-line-height:     $line-height          !global;
    @if $space-map {
      $datepicker-title-actual-height: $datepicker-title-line-height + (2 * $datepicker-title-padding-vertical)  !global;
    }
  }

  
  @content;

  $datepicker-day-padding-horizontal: $scope-day-padding-horizontal !global;
  $datepicker-day-padding-vertical:   $scope-day-padding-vertical   !global;
  $datepicker-day-height:             $scope-day-height             !global;

  $datepicker-day-font-size:          $scope-day-font-size          !global;
  $datepicker-day-line-height:        $scope-day-line-height        !global;

  $datepicker-day-font-style:         $scope-day-font-style         !global;      
  $datepicker-day-font-variant:       $scope-day-font-variant       !global;    
  $datepicker-day-font-weight:        $scope-day-font-weight        !global; 
  $datepicker-day-font-family:        $scope-day-font-family        !global; 

  $datepicker-day-actual-height:      $scope-day-actual-height      !global; 

  $datepicker-title-padding-horizontal: $scope-title-padding-horizontal !global;
  $datepicker-title-padding-vertical:   $scope-title-padding-vertical   !global;
  $datepicker-title-height:             $scope-title-height             !global;

  $datepicker-title-font-size:          $scope-title-font-size          !global;
  $datepicker-title-line-height:        $scope-title-line-height        !global;

  $datepicker-title-actual-height:      $scope-title-actual-height      !global; 
}

@mixin datepicker-size($space-map: $datepicker-base-space-map, $type-map: null, 
                       $title-space-map: $datepicker-title-space-map, $title-type-map: $datepicker-title-type-map) {
  & {
    @include datepicker-size-context($space-map, $type-map, $title-space-map, $title-type-map) {
      & {
        $datepicker-size-min-width: $datepicker-day-actual-height * 7;
        $datepicker-size-flex-amount: $datepicker-day-padding-vertical * 14;
        $datepicker-size-starting-width: $datepicker-size-min-width + $datepicker-size-flex-amount;
        @include flex-basis($datepicker-size-starting-width);
      }
      
      &-nav {      
        padding-top: $datepicker-title-padding-vertical; 
        padding-bottom: $datepicker-title-padding-vertical;
        padding-left: $datepicker-title-padding-horizontal;
        &-controls {
          padding-left: $datepicker-day-padding-vertical;
          padding-right: $datepicker-day-padding-vertical;
          margin-right: $datepicker-title-padding-horizontal;
          &-action {
            padding: $datepicker-day-padding-vertical;          
          }
        }
        $svg-width: 16px;
        $control-width: ($datepicker-day-padding-vertical * 6) + ($svg-width * 2) + $datepicker-title-padding-horizontal;
        &-title {
            padding-left: $datepicker-title-padding-horizontal;
            margin-left: -$datepicker-title-padding-horizontal;
          & .au-animate {            
            padding-left: $datepicker-title-padding-horizontal;
          }
          & .--yearly.au-animate {
            padding-left: 0;
            & > * {
              margin-left: -$control-width;
            }
          }
          @if $type-map {
            line-height: $datepicker-title-line-height;
            font-size: $datepicker-title-font-size;
            font-weight: $datepicker-day-font-weight;
            font-family: $datepicker-day-font-family;
            font-style: $datepicker-day-font-style;
          }        
        }
      }
      &-calendar {
        &-wrapper {
          margin-right: -$datepicker-title-padding-horizontal;
          margin-left: -$datepicker-title-padding-horizontal; 
          & .au-animate {
            padding-left: $datepicker-title-padding-horizontal;
            padding-right: $datepicker-title-padding-horizontal;
          }
        }        
        &-item--month &-action {          
          padding: $datepicker-day-padding-vertical $datepicker-title-padding-horizontal;
          margin-top: $datepicker-day-padding-vertical;
          margin-bottom: $datepicker-day-padding-vertical;
          @if $type-map {
            line-height: $datepicker-title-line-height;
            font-size: $datepicker-title-font-size;
            font-weight: $datepicker-day-font-weight;
            font-family: $datepicker-day-font-family;
            font-style: $datepicker-day-font-style;
          }
        }
        &-header,
        &-item--day &-action {
          padding: $datepicker-day-padding-vertical;
          height: $datepicker-day-actual-height;
          min-width: $datepicker-day-actual-height;
          @if $type-map {
            line-height: $datepicker-day-line-height;
            font-size: $datepicker-day-font-size;
            line-height: $datepicker-day-line-height;
            font-weight: $datepicker-day-font-weight;
            font-family: $datepicker-day-font-family;
            font-style: $datepicker-day-font-style;
          }
        }
        
        &-action {
          &:hover {
            border-radius: $datepicker-day-padding-vertical - 1;
          }
        }        
      }
    }
  }
}

@mixin datepicker-base() {
  & {
    &-nav {
      @include display(flex);     
      
      svg {
        fill: currentcolor;
      }
      &-controls {
        @include display(flex);    
        @include flex(0 0 auto);
        &-action {
          @include display(flex);   
          
        }
      }
      &-title {
        @include display(flex);
        @include align-items(center);    
        @include flex-grow(1);        
        position: relative;
        overflow: hidden;
        user-select: none;
        & .au-animate {
          @include display(flex);
          @include align-items(center);  
          position: absolute;
          white-space: nowrap;
          left: 0;
          right: 0;
          bottom: 0;
          top: 0;
        }
        & .--yearly.au-animate {
          @include justify-content(center);
        }
      }
    }
    &-calendar {
      @include display(flex);
      @include flex-wrap(wrap);
      @include justify-content(space-around);
      &-item {
      @include display(flex);
      @include justify-content(space-around);
        //display: contents;
        &--day {
          width: (100% / 7);
          flex: 1 1 (100% / 7);
          &:nth-child(7n)::after {
            //content: '';
            //width: 100%;
          }
        }
        &--month {
          width: (100% / 3);
          flex: 1 1 (100% / 3);
          &:nth-child(3n)::after {
            //content: '';
            //width: 100%;
          }
        }      
      }
      &-header,
      &-action {
        @include display(flex);
        @include flex(0 0 auto);
        @include justify-content(center);
        @include align-items(center);
      }
      &-action {
        cursor: pointer;
        &:hover {
          background-color: cm-color($cm-color--control, '200');
        }
      }
      
      &-header#{&}-header--day {        
        font-family: $type-family-bold;
        color: cm-color($cm-color--control, '600');
      }

      &-item > &-action--day {
        @include dates-before();
      }
      // Date Start Styles
      @for $value from 21 through 30 {
        &[data-date-start*="#{$value}"] {
          counter-reset: datesBefore $value datesCurrent 0 datesAfter 0;
        }
      }
      // Date Reset Styles
      @for $value from 1 through 7 {
        $rest-value: $value + 1;
        $day-reset: unquote(":nth-child(#{$rest-value})");
        &[data-date-reset*="#{$value}"] > &-item#{$day-reset} > &-action--day,
        &[data-date-reset*="#{$value}"] > &-item#{$day-reset} ~ &-item > &-action--day {
          @include dates-current();
        }
      }
      // Date End Reset Styles
      @for $value from 27 through 42 {
        $rest-value: $value + 1;
        $day-end: unquote(":nth-child(#{$rest-value})");

        &[data-date-end*="#{$value}"] > &-item#{$day-end} > &-action#{&}-action--day,
        &[data-date-end*="#{$value}"] > &-item#{$day-end} ~ &-item > &-action#{&}-action--day {

          @include dates-after();
        }
      }

    }
  }
}

@mixin dates-before() {
  &:before {
    counter-increment: datesBefore 1;
    content: counter(datesBefore);
    color: cm-color($cm-color--control, '600');
    //opacity: .25;
  }
}

@mixin dates-current() {
  &:before {
    counter-increment: datesCurrent 1;
    content: counter(datesCurrent);
    color: $cm-color-foreground;
    //opacity: 1;
  }
}

@mixin dates-after() {
  &:before {
    counter-increment: datesAfter 1;
    content: counter(datesAfter);
    color: cm-color($cm-color--control, '600');
    //opacity: .25;
  }
}

.datepicker {
  width: 277px;
  @include datepicker-base();
  @include datepicker-size($datepicker-base-space-map, $datepicker-base-type-map);
  @include datepicker-styles();
}

compose {
  display: contents;
}

.datepicker-calendar-wrapper {
  @include display(flex);
  position: relative;
  overflow: hidden;
  //calc((100% - 36px)/6) calc(100%/8)
  
    $vAlign1: 100%/8;
    $vAlign2: 100%/8 + 100%/4;
    $vAlign3: 100% - (100%/8 + 100%/4);
    $vAlign4: 100% - 100%/8;
    $hAlignLeft: 100%/6;
    $hAlignCenter: 50%;
    $hAlignRight: 100% - (100%/6);
  
  .--transition.--month-0 & .au-animate {
    transform-origin: $hAlignLeft $vAlign1;
  }  
  .--transition.--month-1 & .au-animate {
    transform-origin: $hAlignCenter $vAlign1;
  }  
  .--transition.--month-2 & .au-animate {
    transform-origin: $hAlignRight $vAlign1;
  }  
  .--transition.--month-3 & .au-animate {
    transform-origin: $hAlignLeft $vAlign2;
  }  
  .--transition.--month-4 & .au-animate {
    transform-origin: $hAlignCenter $vAlign2;
  }  
  .--transition.--month-5 & .au-animate {
    transform-origin: $hAlignRight $vAlign2;
  }  
  .--transition.--month-6 & .au-animate {
    transform-origin: $hAlignLeft $vAlign3;
  }  
  .--transition.--month-7 & .au-animate {
    transform-origin: $hAlignCenter $vAlign3;
  }  
  .--transition.--month-8 & .au-animate {
    transform-origin: $hAlignRight $vAlign3;
  }  
  .--transition.--month-9 & .au-animate {
    transform-origin: $hAlignLeft $vAlign4;
  }  
  .--transition.--month-10 & .au-animate {
    transform-origin: $hAlignCenter $vAlign4;
  }  
  .--transition.--month-11 & .au-animate {
    transform-origin: $hAlignRight $vAlign4;
  }
  
  & .au-animate {
    width: 100%;
  }
  & .au-animate ~ .au-animate {
    margin-left: -100%;
  }
}

.--reverse {
  .animate-slide-in-left.au-enter {
    transform: translateX(100%);
  }
  .animate-slide-in-left.au-enter-active {
    animation: SlideInRight;
  }
	.animate-slide-out-left.au-leave-active {
		animation: SlideOutRight;
	}
	.animate-slide-in-right.au-enter {
		transform: translateX(-100%);
	}
	.animate-slide-in-right.au-enter-active {
		animation: SlideInLeft;
	}
	.animate-slide-out-right.au-leave-active {
		animation: SlideOutLeft;
	}
}

.--transition {
  .datepicker-nav {
    .animate-slide-in-right.au-enter > *,
    .animate-slide-in-left.au-enter > * {
      opacity: 0;
    }
    .animate-slide-in-right.au-enter-active > *,
    .animate-slide-in-left.au-enter-active > * {
      animation: FadeIn;
      animation-duration: inherit !important;
    }
    .animate-slide-out-right.au-leave-active > *,
    .animate-slide-out-left.au-leave-active > * {
      animation: FadeOut;
      animation-duration: inherit !important;
    }
  }
  .datepicker-calendar-wrapper {
    .animate-slide-in-right.au-enter,
    .animate-slide-in-left.au-enter {
      opacity: 0;
      transform: scale3d(.3,.3,.3);
    }
    .animate-slide-in-right.au-enter-active,
    .animate-slide-in-left.au-enter-active {
      animation: ZoomIn;
    }
    .animate-slide-out-right.au-leave-active,
    .animate-slide-out-left.au-leave-active {
      animation: ZoomOut;
    }
    .datepicker-year {
      &.animate-slide-in-right.au-enter,
      &.animate-slide-in-left.au-enter {
        opacity: 0;
        transform: scale3d(1.7,1.7,1.7);
      }
      &.animate-slide-in-right.au-enter-active,
      &.animate-slide-in-left.au-enter-active {
        animation: ZoomInBig;
      }
      &.animate-slide-out-right.au-leave-active,
      &.animate-slide-out-left.au-leave-active {
        animation: ZoomOutBig;
      }
    }
  }
}

.datepicker .au-animate {
  animation-timing-function: cubic-bezier(0.4, 0.0, 0.2, 1) !important;
}

.datepicker .au-animate.au-enter {
  animation-duration: 300ms !important;
}

.datepicker .au-animate.au-leave {
  animation-duration: 250ms !important;
}

.datepicker.--transition .au-animate {
  animation-duration: 250ms !important;
}

.datepicker.--transition.--reverse .au-animate {
  animation-duration: 300ms !important;
}

.datepicker.--transition .datepicker-calendar-wrapper .au-animate {
  animation-timing-function: cubic-bezier(0.4, 0.0, 1, 1) !important;
}

.datepicker.--transition.--reverse .datepicker-calendar-wrapper .au-animate {
  animation-timing-function: cubic-bezier(0.0, 0.0, 0.2, 1) !important;
}
              
            
!

JS

              
                
const inject = au.inject;
const swapStrategies = ['with', 'after', 'before'];
//Set up deferred swapStrategies
swapStrategies.forEach((strategy) => {
  au.SwapStrategies[strategy + 'Deferred'] = function (
    viewSlot: any,
    previous: any,
    callback: any
  ) {
    let currentPromise = au.SwapStrategies[strategy](viewSlot, previous, callback);
    viewSlot.previousPromise = currentPromise;
    return Promise.resolve(false);
  };  
})

const interceptMethods = ['updateTarget', 'updateSource', 'callSource'];

function interceptor(method: any, update: any, intercept: any, value: any) {
  if (this.target.swapOrder && this.target.swapOrder.indexOf('Deferred') === -1) {
    this.target.swapOrder = this.target.swapOrder + 'Deferred';
  }
  Promise.resolve(this.target.viewSlot.previousPromise).then(() => {
    if (typeof intercept === 'function') {
      value = intercept.call(this.source.bindingContext, value) || value;
    }
    update(value);    
  });
}

@inject(au.BindingEngine)
class DeferBindingBehavior {
  constructor(BindingEngine:any) {
    this.bindingEngine = BindingEngine;
  }
  
  bind(binding:any, scope:any, intercept:any) {
    let i = interceptMethods.length;
    while (i--) {
      let method = interceptMethods[i];
      if (!binding[method]) {
        continue;
      }
      binding[`intercepted-${method}`] = binding[method];
      let update = binding[method].bind(binding);
      binding[method] = interceptor.bind(binding, method, update, intercept);
    }
  }

  unbind(binding:any, scope:any) {
    let i = interceptMethods.length;
    while (i--) {
      let method = interceptMethods[i];
      if (!binding[method]) {
        continue;
      }

      binding[method] = binding[`intercepted-${method}`];
      binding[`intercepted-${method}`] = null;
    }
  }
}
  
class CalendarHeader {
  constructor(data: any) {
    this.title = data.title;
    this.type = data.type;
  }
  
  getViewStrategy() {
    return new au.InlineViewStrategy(`<template>
      <div click.trigger="onClick($this, $event)"
      class="au-animate animate-slide-out-left animate-slide-in-right ${this.type}"><span textcontent.one-time="title"></span></div>
    </template>`);
  }

  activate(activationData: any) {    
    this.onClickCallback = activationData.onClick;
  }
  onClick(data: any, event: any) {
    if (typeof this.onClickCallback === 'function') {
      this.onClickCallback(data, event);
    }
  }
}

class Year {
  constructor() {
  }
  
  getViewStrategy() {
    return new au.InlineViewStrategy(`<template>
    <div
      class="datepicker-year au-animate animate-slide-out-left animate-slide-in-right">
        <div class="datepicker-calendar">
          <template repeat.for="month of months">
            <div class="datepicker-calendar-item datepicker-calendar-item--month">
              <div class="datepicker-calendar-action datepicker-calendar-action--month" 
                textcontent.bind="month"
                click.delegate="onMonthClick($this, $event, $index)"
                ></div>
            </div>
          </template>
        </div>
      </div>
    </template>`);
  }

  activate(activationData: any) {    
    this.months = activationData.months;
    this.onMonthClickCallback = activationData.onMonthClick;
  }

  attached() { //Fires when the model's view is attached to its parent DOM node.  
    //debugger;
    
  }

  detached() { //Fires when the model's view is removed from the DOM
    //debugger;
    
  }

  //#endregion Durandal Page Lifecycle Events  

  destroy() {
    //debugger;
    
  }
  
  onClick(data: any, event: any, index: number) {
    if (typeof this.onMonthClickCallback === 'function') {
      this.onMonthClickCallback(data, event, index);
    }
  }
}

class Month {
  constructor(data) {
    this.dateStart = data.dateStart;
    this.dateStartReset = data.dateStartReset;
    this.dateEndReset = data.dateEndReset;
  }
  
  getViewStrategy() {
    return new au.InlineViewStrategy(`<template>
    <div
      class="au-animate animate-slide-out-left animate-slide-in-right">
        <header class="datepicker-calendar">
          <template repeat.for="day of $this.weekdays">
           <div class="datepicker-calendar-header datepicker-calendar-header--day" textcontent.one-time="day"></div>
          </template>
        </header>
        <div class="datepicker-calendar"
             data-date-start.one-time="dateStart"
             data-date-reset.one-time="dateStartReset"
             data-date-end.one-time="dateEndReset">
          <template repeat.for="i of 42">
            <div class="datepicker-calendar-item datepicker-calendar-item--day">
              <div class="datepicker-calendar-action datepicker-calendar-action--day"></div>
            </div>
          </template>
        </div>
      </div>
    </template>`);
  }

  activate(activationData: any) {    
    this.weekdays = activationData.weekdayHeaders;
  }
}

@inject(au.Container, au.TaskQueue)
class App {
  public mL = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'];
  public mS = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'June', 'July', 'Aug', 'Sept', 'Oct', 'Nov', 'Dec'];
  public wL = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'];
  public wS = ['Su', 'Mo', 'Tu', 'We', 'Th', 'Fr', 'Sa'];
  public weekdayHeaders: any[];
  public monthCurrentLastDay: Date;
  public monthBeforeLastDay: Date;
  
  constructor(Container: any, TaskQueue:any) {

    this.taskQueue = TaskQueue;
    // firstDayOfWeek Sunday = 0, Monday = 1... Sat = 6
    this.firstDayOfWeek = 0;
    this.backwards = false;
    this.wmCalendars = new Map();
    this.yearView = false;
    this.transition = false;
    if (typeof Intl == 'object' && typeof Intl.DateTimeFormat == 'function') {
      let mformatter = new Intl.DateTimeFormat(navigator.language, {
        month: "short"
      });
      let wformatter = new Intl.DateTimeFormat(navigator.language, {
        weekday: "short"
      });
      let months = [];
      let weekDays = [];

      while (months.length < 12) {
        months.push(mformatter.format(new Date(0, months.length, 1)));
      }
      while (weekDays.length < 7) {
        weekDays.push(wformatter.format(new Date(0, 0, weekDays.length)));
      }

      //this.wS = weekDays;
      //this.mS = months;
    }
    
    let wH = [...this.wS];
    wH.push(...wH.splice(0, this.firstDayOfWeek));
    this.weekdayHeaders = wH;
    
    this.calendarData = {
      weekdayHeaders: this.weekdayHeaders,
      months: this.mS,
      onDayClick: this.onDayClick.bind(this),
      onMonthClick: this.onMonthClick.bind(this)
    };
    
    this.headerData = {
      onClick: this.onHeaderClick.bind(this)
    };
    
    var today = new Date();
    this.setCurrentDate(today);
    
    this.selectedMonth = 0;
    
  }

  created(parent, view) {
    //debugger;
  }

  bind(bindingContext, overrideContext) {
    //debugger;
  }
  
  get dateBefore() {
    return this.monthBeforeLastDay.getDate();
  }
  get dateEnd() {
    return this.monthCurrentLastDay.getDate();
  }
  
  // public
  get dateStart() {
    return this.dateBefore - this.dateStartReset;
  }
  
  get dateStartReset() {
    var dateStartReset = this.monthBeforeLastDay.getDay() + 1 - this.firstDayOfWeek;
    if (dateStartReset > 0) {
      return dateStartReset;
    } else {
      return dateStartReset + 7;
    }
  }
  
  get dateEndReset() {
    return this.dateEnd + this.dateStartReset;
  }
  
  setCurrentDate(date?: any){
    if (date) {
      let year = date.getFullYear();
      let month = date.getMonth();
      
      this.monthCurrentLastDay = new Date(year, month + 1, 0);
      this.monthBeforeLastDay = new Date(year, month, 0);

      this.currentMonth = month;
    } else {      
      var year = this.monthCurrentLastDay.getFullYear();
      var month = this.monthCurrentLastDay.getMonth();
      date = new Date(year, month);
    }
    let Calendar;
    let options;
    if (this.yearView) {
      Calendar = Year;
      options = { year: 'numeric'};          
    } else {
      Calendar = Month;
      options = { year: 'numeric', month: 'long' };          
    }
    
    this.title = date.toLocaleDateString(navigator.language, options);
    
    let classIn = this.calendarVM ? this.calendarVM.classIn : 'right';
    let classOut = this.calendarVM ? this.calendarVM.classOut : 'left';
    
    let cData = {
      dateStart: this.dateStart,
      dateStartReset: this.dateStartReset,
      dateEndReset: this.dateEndReset
    };
    
    let calendar;
    let year;
    let title;
    if (this.wmCalendars && this.wmCalendars.has(this.title)) {
      var cMapData = this.wmCalendars.get(this.title);
      calendar = cMapData[0];
      title = cMapData[1];
    } else {
      calendar = new Calendar(cData);
      title = new CalendarHeader({title: this.title, type: this.yearView ? '--yearly' : ''});
      this.wmCalendars.set(this.title, [calendar, title]);      
    }
    
    this.calendarVM = calendar;    
    this.titleVM = title;
  }
  
  prev(data: any, event: any) {
    var year = this.monthCurrentLastDay.getFullYear();
    var month = this.monthCurrentLastDay.getMonth();
    var prevDate = this.yearView ? new Date(year - 1, month, 1) : new Date(year, month - 1, 1);
    this.deferBackwards = true;
    this.transition = false;    

    this.taskQueue.queueTask(() => {
      this.setCurrentDate(prevDate);  
    });    
  }
  
  next(data: any, event: any) {
    var year = this.monthCurrentLastDay.getFullYear();
    var month = this.monthCurrentLastDay.getMonth();
    var nextDate = this.yearView ? new Date(year + 1, month, 1) : new Date(year, month + 1, 1);
    this.deferBackwards = false;
    this.transition = false; 

    this.taskQueue.queueTask(() => {
      this.setCurrentDate(nextDate); 
    });    
  }
  
  onHeaderClick(data: any, event: any) {
    this.yearView = true;
    this.transition = true;
    this.deferBackwards = false;  

    this.taskQueue.queueTask(() => {
      this.setCurrentDate(); 
    });  
  }
  
  onMonthClick(data: any, event: any, index: number) {    
    var year = this.monthCurrentLastDay.getFullYear();
    var month = this.monthCurrentLastDay.getMonth();
    var date = new Date(year, index, 1);
    this.deferBackwards = true;
    this.transition = true;
    this.yearView = false;    

    this.taskQueue.queueTask(() => {
      this.setCurrentDate(date); 
    });  
  }
  
  onDayClick(data: any, event: any) {
    
  }
  
  vmChanged(){
    this.backwards = this.deferBackwards;
  }
 
}

//const app = new App();

const aurelia = new au.Aurelia();

aurelia
  .use
  .standardConfiguration()
  .feature((config: any) => {
    config.globalResources(DeferBindingBehavior);
  })
  .plugin((config: any, callback: any) => {
    var animator = config.container.get(CssAnimator);
    config.container.get(au.TemplatingEngine).configureAnimator(animator);
    if (typeof callback === 'function') {
      callback(animator);
    }
  })
  .developmentLogging();
aurelia
  .start()
  .then((config: any) => { 
    var app = config.container.get(App);
    aurelia.enhance(app, document.body);
  }
);
              
            
!
999px

Console