カレンダー/日付ピッカー

カレンダーは、タッチ操作に最適化されたコンポーネントであり、日付を簡単に処理できます。

カレンダーは、インラインコンポーネントまたはオーバーレイとして使用できます。オーバーレイカレンダーは、タブレット(iPad)では自動的にポップオーバーに変換されます。

カレンダーアプリメソッド

カレンダーを操作するための関連するアプリメソッドを見てみましょう。

app.calendar.create(パラメーター)- カレンダーインスタンスを作成します。

  • パラメーター - オブジェクト。カレンダーパラメーターを含むオブジェクト

メソッドは作成されたカレンダーのインスタンスを返します。

app.calendar.destroy(el)- カレンダーインスタンスを破棄します。

  • el - HTMLElement または 文字列(CSSセレクター付き)または オブジェクト。破棄するカレンダー要素またはカレンダーインスタンス。

app.calendar.get(el)- HTML要素からカレンダーインスタンスを取得します。

  • el - HTMLElement または 文字列(CSSセレクター付き)。カレンダー要素。

メソッドはカレンダーのインスタンスを返します。

app.calendar.close(el)- カレンダーを閉じます。

  • el - HTMLElement または 文字列(CSSセレクター付き)。閉じるカレンダー要素。

メソッドはカレンダーのインスタンスを返します。

var calendar = app.calendar.create({
    inputEl: '#calendar-input'
});

カレンダーパラメーター

利用可能なすべてカレンダーパラメーターのリストを見てみましょう。

パラメーターデフォルト説明
locale文字列

カレンダーロケール。Intl.DateTimeFormatで受け入れられる正しいロケールである必要があります。指定されていない場合(デフォルト)、ブラウザのロケールが使用されます。

例:en-USruenen-US-u-ca-buddhistなど。

value配列初期選択日を含む配列。各配列項目は選択された日付を表します。
disabled日付範囲追加で無効にする日付。パラメーターは、いわゆる**日付範囲**を受け入れます(詳細は後述)。
events日付範囲

イベントのある日付。カレンダーの日付に追加の「ドット」でマークされます。パラメーターは、いわゆる**日付範囲**を受け入れます(詳細は後述)。

ある日に複数の異なるイベントがあることを示したい場合は、複数の異なる色のドットで示すことができます。この場合、各オブジェクトにdatecolorプロパティを持つ配列として日付範囲を渡す必要があります。例:

[
  {
    date: new Date(2018, 4, 11),
    color: '#2196f3',
  },
  // same date but different color, one more dot will be added to this day
  {
    date: new Date(2018, 4, 11),
    color: '#4caf50',
  },
]
rangesClasses配列追加のスタイルのためにカスタムCSSクラスを追加したい日付範囲。受け入れられる形式については以下を参照してください。
formatValue関数 (values)入力値をフォーマットする関数で、新しい/フォーマットされた文字列値を返す必要があります。**values**は、各項目が選択された日付を表す配列です。dateFormatパラメーターの代わりに、カスタムフォーマットを指定するために使用できます。
monthNames配列auto完全な月の名前を含む配列。autoの場合、指定されたlocale(またはブラウザのロケール)に基づいて月の名前が表示されます。
monthNamesShort配列auto短い月の名前を含む配列。autoの場合、指定されたlocale(またはブラウザのロケール)に基づいて月の名前が表示されます。
dayNames配列auto曜日の名前を含む配列。autoの場合、指定されたlocale(またはブラウザのロケール)に基づいて曜日の名前が表示されます。
dayNamesShort配列auto短い曜日の名前を含む配列。autoの場合、指定されたlocale(またはブラウザのロケール)に基づいて曜日の名前が表示されます。
firstDay数値1週の最初の日。デフォルトは1(月曜日)。
weekendDays配列[0, 6]週末の日のインデックス番号を含む配列。デフォルトは土曜日と日曜日です。
dateFormat文字列
オブジェクト
未定義

未定義の場合、locale(またはブラウザのロケール)に基づいてフォーマットが使用されます。

Intl.DateTimeFormat.optionsを受け入れることができます。

例:{ month: 'long', day: 'numeric' }

または、特別なトークン、利用可能な式を含む文字列を渡すことができます。

  • yyyy - 4桁の年
  • yy - 2桁の年
  • mm - 2桁の月番号(01〜12)
  • m - 月番号(1〜12)
  • MM - 完全な月の名前
  • M - 短い月の名前
  • dd - 2桁の日番号(01〜31)
  • d - 日番号(1〜31)
  • DD - 完全な曜日の名前
  • D - 短い曜日の名前

timePickerが有効になっている場合、次の追加の時間式を使用できます。

  • HH - 24時間形式の2桁の時間(00〜23)
  • H - 24時間形式の時間(0〜23)
  • hh - 12時間形式の2桁の時間(00〜12)
  • h - 12時間形式の時間(0〜12)
  • :mm - 2桁の分(00〜59)
  • :m - 分(0〜59)
  • ss - 2桁の秒(00〜59)
  • s - 秒(0〜59)
  • A - 大文字の午前または午後(PMまたはAM)
  • a - 小文字の午前または午後(pmまたはam)
multipleブール値false複数の日付/値を選択できるようにします。
rangePickerブール値false範囲ピッカーを有効にします。multipleとは互換性がありません。
rangePickerMinDays数値1rangePickerが有効な場合に選択する必要がある最小日数。
rangePickerMaxDays数値0rangePickerが有効な場合に選択できる最大日数。0は最大値がないことを意味します。
direction文字列'horizontal'月のレイアウト方向。'horizontal'または'vertical'にすることができます。
minDate日付null最小許容日付
maxDate日付null最大許容日付
touchMoveブール値true有効にすると、タッチ移動中にカレンダーの月が指に追従してスライドします。
animateブール値true月間のトランジションを有効にします。
closeOnSelectブール値false有効にすると、ユーザーが日付を選択したときにカレンダーが閉じられます。
weekHeaderブール値true短い名前の曜日を含む週ヘッダーを有効にします。
monthSelectorブール値trueツールバーで月のセレクターを有効にします。
monthPickerブール値trueツールバーの月セレクターをクリックしたときに月を選択するための月ピッカーを有効にします。
yearSelectorブール値trueツールバーで年のセレクターを有効にします。
yearPickerブール値trueツールバーの年セレクターをクリックしたときに年を選択するための年ピッカーを有効にします。
yearPickerMin数値年ピッカーで利用可能な最小の年。デフォルトは今日から100年前です。
yearPickerMax数値年ピッカーで利用可能な最大の年。デフォルトは今日から100年後です。
timePickerブール値false時間ピッカーを有効にします。
timePickerFormatオブジェクト{hour: 'numeric', minute: 'numeric'}

時間セレクターに表示される時間形式。Intl.DateTimeFormat.optionsを受け入れます。

AM/PM形式は、指定されたlocale、または指定されていない場合はブラウザのロケールによって異なります。

timePickerPlaceholder文字列時間を選択時間セレクターのプレースホルダーに表示するテキスト。
コンテナ/オープナー固有のパラメーター
containerEl文字列
HTMLElement
生成されたカレンダーHTMLを配置する場所のCSSセレクターまたはHTMLElementを含む文字列。**インラインカレンダーの場合のみ使用してください。**
openIn文字列autoautopopover(カレンダーをポップオーバーで開く)、sheet(シートモーダルで開く)、customModal(カスタムカレンダーモーダルオーバーレイで開く)のいずれかになります。autoの場合、小さい画面ではシートモーダルで、大きい画面ではポップオーバーで開きます。
sheetPushブール値falseカレンダーシートを開いたときに背後のビューをプッシュする機能を有効にします。
sheetSwipeToCloseブール値未定義スワイプでカレンダーシートを閉じることができるようにします。指定されていない場合、アプリのシートswipeToCloseパラメーターを継承します。
inputEl文字列またはHTMLElement関連する入力要素を含むCSSセレクターまたはHTMLElementを含む文字列
scrollToInputブール値trueカレンダーが開かれたときにビューポート(ページコンテンツ)を入力にスクロールします。
inputReadOnlyブール値true指定された入力に「readonly」属性を設定します。
cssClass文字列カレンダー要素に設定する追加のCSSクラス名。
closeByOutsideClickブール値true有効にすると、ピッカーの外側または関連する入力要素をクリックすることでピッカーが閉じられます。
toolbarブール値trueカレンダーのツールバーを有効にします。
toolbarCloseText文字列完了完了/閉じるツールバーボタンのテキスト。
headerブール値falseカレンダーヘッダーを有効にします。
headerPlaceholder文字列日付を選択デフォルトのカレンダーヘッダーのプレースホルダーテキスト。
routableModalsブール値false開かれたカレンダーをルーター履歴に追加します。これにより、ルーター履歴で戻ることでカレンダーを閉じることができ、現在のルートをカレンダーモーダルに設定できます。
url文字列date/現在のルートとして設定されるカレンダーモーダルのURL。
viewオブジェクトroutableModalsが有効な場合にルーティングを設定するビュー。inputElの親ビュー、または親ビューが見つからない場合はメインビューがデフォルトになります。
backdropブール値カレンダーのバックドロップ(後ろにある暗い半透明のレイヤー)を有効にします。デフォルトでは、カレンダーがポップオーバーで開かれた場合にのみ有効になります。
closeByBackdropClickブール値true有効にすると、背景をクリックした際にカレンダーが閉じます。
レンダリング関数
renderWeekHeader関数週のヘッダーをレンダリングする関数。週のヘッダーのHTML文字列を返却する必要があります。
renderMonthsfunction(date)月のコンテナをレンダリングする関数。月のコンテナの完全なHTML文字列を返却する必要があります。
renderMonthfunction(date, offset)単月のカレンダーをレンダリングする関数。単月のHTML文字列を返却する必要があります。
renderMonthSelector関数月のセレクターをレンダリングする関数。月のセレクターのHTML文字列を返却する必要があります。
renderYearSelector関数年のセレクターをレンダリングする関数。年のセレクターのHTML文字列を返却する必要があります。
renderHeader関数カレンダーヘッダーをレンダリングする関数。カレンダーヘッダーのHTML文字列を返却する必要があります。
renderToolbar関数ツールバーをレンダリングする関数。ツールバーのHTML文字列を返却する必要があります。
render関数カレンダー全体をレンダリングする関数。カレンダーの完全なHTML文字列を返却する必要があります。
イベント
onオブジェクト

イベントハンドラーを持つオブジェクト。例:

var calendar = app.calendar.create({
  ...
  on: {
    opened: function () {
      console.log('Calendar opened')
    }
  }
})

以下のすべてのパラメーターは、グローバルアプリケーションパラメーターのcalendarプロパティ内で使用して、すべての日付のデフォルトを設定できます。例:

var app = new Framework7({
  calendar: {
    url: 'calendar/',
    dateFormat: 'dd.mm.yyyy',
  }
});

日付範囲

カレンダーのパラメーターの一部(disabledeventsrangesClasses)は、いわゆる日付範囲を受け入れます。これは、考えられるすべての日付の組み合わせを指定してカバーするための簡単な方法です。

日付を含む配列にすることができます。例:

var calendar = app.calendar.create({
    ...
    // Disabled 10th November 2015 and 11th November 2015:
    disabled: [new Date(2015, 10, 10), new Date(2015, 10, 11)],
    ...
});

trueまたはfalseを返す必要があるカスタム関数にすることができます。

var calendar = app.calendar.create({
    ...
    //Disabled all dates in November 2015
    disabled: function (date) {
        if (date.getFullYear() === 2015 && date.getMonth() === 10) {
            return true;
        }
        else {
            return false;
        }
    },
    ...
});

または、fromtoプロパティを持つオブジェクトにすることができます。

var calendar = app.calendar.create({
    ...
    //Disable all dates between 1st October 2015 and 31 December 2015
    disabled: {
        from: new Date(2015, 9, 1),
        to: new Date(2015, 11, 31)
    },
    ...
});

または、fromまたはtoプロパティのみを持つオブジェクトにすることができます。

var calendar = app.calendar.create({
    ...
    //Disable everyting since December 2015
    disabled: {
        from: new Date(2015, 11, 1)
    },
    ...
});

または、dateプロパティを持つオブジェクトにすることができます。

var calendar = app.calendar.create({
    ...
    // Disabled 1th December 2015
    disabled: {
        date: new Date(2015, 11, 1)
    },
    ...
});

または、日付とオブジェクトを混ぜた配列にすることができます。

var calendar = app.calendar.create({
    ...
    events: [
        new Date(2015, 9, 1),
        new Date(2015, 9, 5),
        {
            from: new Date(2015, 9, 10),
            to: new Date(2015, 9, 15)
        },
        {
            from: new Date(2015, 9, 20),
            to: new Date(2015, 9, 31)
        },
        {
            date: new Date(2015, 11, 1),
            color: '#ff0000'
        },
        // same date but one more color dot will be added
        {
            date: new Date(2015, 11, 1),
            color: '#00ff00'
        },
    ],
    ...
});

rangesClasses

rangesClassesパラメーターは、日付範囲と、その範囲のクラス名を含むオブジェクトの配列を受け入れます。

var calendar = app.calendar.create({
    ...
    //Add classes for november and october
    rangesClasses: [
        //Add "day-october' class for all october dates
        {
            // string CSS class name for this range in "cssClass" property
            cssClass: 'day-october', //string CSS class
            // Date Range in "range" property
            range: function (date) {
                return date.getMonth() === 9
            }
        },
        //Add "day-holiday" class for 1-10th January 2016
        {
            cssClass: 'day-holiday',
            range: {
                from: new Date(2016, 0, 1),
                to: new Date(2016, 0, 10)
            }
        }
    ],
    ...
});

カレンダーメソッドとプロパティ

カレンダーを初期化すると、上記の例にあるcalendar変数のように、便利なメソッドとプロパティを持つ初期化されたインスタンスが変数に格納されます。

プロパティ
calendar.appグローバルアプリケーションインスタンスへのリンク
calendar.containerElカレンダーのラッピングコンテナHTML要素(インラインカレンダーを使用する場合)
calendar.$containerElカレンダーのラッピングコンテナHTML要素を持つDom7インスタンス(インラインカレンダーを使用する場合)
calendar.elカレンダーHTML要素
calendar.$elカレンダーHTML要素を持つDom7インスタンス
calendar.inputElカレンダー入力HTML要素(inputElパラメーターで渡される)
calendar.$inputElカレンダー入力HTML要素を持つDom7インスタンス(inputElパラメーターで渡される)
calendar.value選択された日付を表す各アイテムを含む配列
calendar.currentMonthカレンダービューの現在の月。数値、0から11
calendar.currentYearカレンダービューの現在の年。数値、例:2020
calendar.openedカレンダーが開いている場合true
calendar.inlineインラインカレンダーを使用する場合true
calendar.cols指定されたカレンダー列を含む配列。各列にも独自のメソッドとプロパティがあります(下記参照)。
calendar.urlカレンダーURL(urlパラメーターで渡されたもの)
calendar.viewカレンダービュー(viewパラメーターで渡されたもの)または検出された親ビュー
calendar.params初期化パラメーターを含むオブジェクト
calendar.allowTouchMove初期化後にタッチ移動の操作を防止するには、このフラグをfalseに設定します。
メソッド
calendar.setValue(values)新しい選択された日付を設定します。valuesは、選択された日付を表す各アイテムを含む配列です。
calendar.getValue()現在のカレンダー値を返します。
calendar.addValue()値をvalues配列に追加します。複数選択が有効になっている場合(multiple: trueパラメーター)に便利です。
calendar.update()カレンダーを再レンダリングします。動的に値を追加または変更し、カレンダーレイアウトを更新する必要がある場合に便利です。
calendar.nextMonth(duration)ミリ秒単位で指定されたdurationで、次の月にカレンダー遷移します。
calendar.prevMonth(duration)ミリ秒単位で指定されたdurationで、前の月にカレンダー遷移します。
calendar.nextYear()次の年にカレンダー遷移します。
calendar.prevYear()前の年にカレンダー遷移します。
calendar.setYearMonth(year, month, duration)ミリ秒単位で指定されたdurationで、指定されたyearmonthにカレンダー遷移します。
calendar.open()カレンダーを開きます。
calendar.close()カレンダーを閉じます。
calendar.destroy()カレンダーインスタンスを破棄し、すべてのイベントを削除します。
calendar.on(event, handler)イベントハンドラーを追加します。
calendar.once(event, handler)発生後に削除されるイベントハンドラーを追加します。
calendar.off(event, handler)イベントハンドラーを削除します。
calendar.off(event)指定されたイベントのすべてのハンドラーを削除します。
calendar.emit(event, ...args)インスタンスでイベントを発生させます。

カレンダーイベント

カレンダーは、カレンダー要素で以下のDOMイベント、およびアプリとカレンダーインスタンスでイベントを発生させます。

DOMイベント

イベントターゲット説明
calendar:openカレンダー要素<div class="calendar">カレンダーが開くアニメーションを開始するときにトリガーされます。
calendar:openedカレンダー要素<div class="calendar">カレンダーが開くアニメーションが完了した後にトリガーされます。
calendar:closeカレンダー要素<div class="calendar">カレンダーが閉じるアニメーションを開始するときにトリガーされます。
calendar:closedカレンダー要素<div class="calendar">カレンダーが閉じるアニメーションが完了した後にトリガーされます。

アプリとカレンダーインスタンスのイベント

カレンダーインスタンスは、自身インスタンスとアプリインスタンスの両方でイベントを発生させます。アプリインスタンスイベントは、calendarというプレフィックスが付いた同じ名前を持ちます。

イベントターゲット引数説明
dayClickcalendar(calendar, dayEl, year, month, day)カレンダーの日付要素をクリックした後にトリガーされます。
calendarDayClickapp
changecalendar(calendar, value)カレンダーの値が変更されたときにトリガーされます。
calendarChangeapp
monthAddcalendar(calendar, monthEl)新しい月のHTMLレイアウトが追加されたときにトリガーされます。追加されたHTML要素を後処理する必要がある場合に便利です。
calendarMonthAddapp
monthYearChangeStartcalendar(calendar, year, month)次の月への遷移の開始時にトリガーされます。
calendarMonthYearChangeStartapp
monthYearChangeEndcalendar(calendar, year, month)次の月への遷移後にトリガーされます。
calendarMonthYearChangeEndapp
initcalendar(calendar)カレンダーが初期化されたときにトリガーされます。
calendarInitapp
opencalendar(calendar)カレンダーが開くアニメーションを開始するときにトリガーされます。引数として、イベントハンドラーはカレンダーインスタンスを受け取ります。
calendarOpenapp
openedcalendar(calendar)カレンダーが開くアニメーションが完了した後にトリガーされます。引数として、イベントハンドラーはカレンダーインスタンスを受け取ります。
calendarOpenedapp
closecalendar(calendar)カレンダーが閉じるアニメーションを開始するときにトリガーされます。引数として、イベントハンドラーはカレンダーインスタンスを受け取ります。
calendarCloseapp
closedcalendar(calendar)カレンダーが閉じるアニメーションが完了した後にトリガーされます。引数として、イベントハンドラーはカレンダーインスタンスを受け取ります。
calendarClosedapp
beforeDestroycalendar(calendar)カレンダーインスタンスが破棄される直前にトリガーされます。引数として、イベントハンドラーはカレンダーインスタンスを受け取ります。
calendarBeforeDestroyapp

CSS変数

関連するCSS変数(CSSカスタムプロパティ)のリストを以下に示します。

コメントアウトされた変数はデフォルトでは指定されておらず、その値はこの場合のフォールバック値です。

:root {
  --f7-calendar-height: 340px;
  --f7-calendar-sheet-landscape-height: 220px;
  --f7-calendar-popover-width: 320px;
  --f7-calendar-popover-height: 320px;
  --f7-calendar-modal-height: 420px;
  --f7-calendar-modal-max-width: 380px;
  /*
  --f7-calendar-header-bg-color: var(--f7-bars-bg-color);
  --f7-calendar-header-link-color: var(--f7-bars-link-color);
  --f7-calendar-header-text-color: var(--f7-bars-text-color);
  --f7-calendar-footer-bg-color: var(--f7-bars-bg-color);
  --f7-calendar-footer-border-color: var(--f7-bars-border-color);
  --f7-calendar-footer-link-color: var(--f7-bars-link-color);
  --f7-calendar-footer-text-color: var(--f7-bars-text-color);
  */
  --f7-calendar-week-header-bg-color: transparent;
  --f7-calendar-footer-padding: 0 8px;
  --f7-calendar-week-header-font-size: 11px;
  /*
  --f7-calendar-selected-bg-color:  var(--f7-theme-color);
  */
  --f7-calendar-disabled-text-color: #d4d4d4;
  --f7-calendar-event-dot-size: 4px;
  /*
  --f7-calendar-event-bg-color: var(--f7-theme-color);
  */
  /*
  --f7-calendar-picker-selected-text-color: var(--f7-theme-color);
  */
  --f7-calendar-time-selector-height: 28px;
  --f7-calendar-picker-pressed-bg-color: rgba(0, 0, 0, 0.1);
  --f7-calendar-picker-hover-bg-color: rgba(0, 0, 0, 0.03);
  --f7-calendar-time-selector-bg-color: rgba(0, 0, 0, 0.05);
}
:root .dark,
:root.dark {
  --f7-calendar-picker-pressed-bg-color: rgba(255, 255, 255, 0.08);
  --f7-calendar-picker-hover-bg-color: rgba(255, 255, 255, 0.03);
  --f7-calendar-time-selector-bg-color: rgba(255, 255, 255, 0.1);
}
.ios {
  --f7-calendar-selected-text-color: #fff;
  --f7-calendar-header-height: 44px;
  --f7-calendar-header-font-size: 17px;
  --f7-calendar-header-font-weight: 600;
  --f7-calendar-header-padding: 0 8px;
  --f7-calendar-footer-height: 44px;
  --f7-calendar-footer-font-size: 17px;
  --f7-calendar-week-header-height: 18px;
  --f7-calendar-day-font-size: 15px;
  --f7-calendar-day-size: 30px;
  --f7-calendar-picker-font-size: 17px;
  --f7-calendar-time-selector-font-size: 17px;
  --f7-calendar-modal-border-radius: 4px;
  --f7-calendar-modal-box-shadow: 0px 11px 15px -7px rgba(0, 0, 0, 0.2),
                                  0px 24px 38px 3px rgba(0, 0, 0, 0.14),
                                  0px 9px 46px 8px rgba(0, 0, 0, 0.12);
  --f7-calendar-prev-next-text-color: #c8c8c8;
  --f7-calendar-sheet-border-color: #929499;
  --f7-calendar-sheet-bg-color: #fff;
  --f7-calendar-week-header-text-color: #5e5e5e;
  --f7-calendar-modal-bg-color: #fff;
  --f7-calendar-day-text-color: #000;
  --f7-calendar-today-text-color: #000;
  --f7-calendar-today-bg-color: #e3e3e3;
}
.ios .dark,
.ios.dark {
  --f7-calendar-prev-next-text-color: #5e5e5e;
  --f7-calendar-sheet-border-color: var(--f7-bars-border-color);
  --f7-calendar-sheet-bg-color: #121212;
  --f7-calendar-week-header-text-color: #aaa;
  --f7-calendar-modal-bg-color: #121212;
  --f7-calendar-day-text-color: #fff;
  --f7-calendar-today-text-color: #fff;
  --f7-calendar-today-bg-color: #333;
}
.md {
  --f7-calendar-sheet-border-color: transparent;
  --f7-calendar-header-height: 64px;
  --f7-calendar-header-font-size: 24px;
  --f7-calendar-header-font-weight: 400;
  --f7-calendar-header-padding: 0 24px;
  --f7-calendar-footer-height: 56px;
  --f7-calendar-footer-font-size: 14px;
  --f7-calendar-week-header-height: 24px;
  --f7-calendar-day-font-size: 14px;
  --f7-calendar-today-bg-color: none;
  --f7-calendar-day-size: 32px;
  --f7-calendar-picker-font-size: 14px;
  --f7-calendar-time-selector-font-size: 14px;
  --f7-calendar-modal-border-radius: 28px;
  --f7-calendar-modal-box-shadow: none;
}
.md,
.md .dark,
.md [class*='color-'] {
  --f7-calendar-sheet-bg-color: var(--f7-md-surface-1);
  --f7-calendar-selected-text-color: var(--f7-md-on-primary);
  --f7-calendar-week-header-text-color: var(--f7-md-on-surface-variant);
  --f7-calendar-day-text-color: var(--f7-md-on-surface);
  --f7-calendar-prev-next-text-color: rgba(var(--f7-md-on-surface-variant-rgb), 0.55);
  --f7-calendar-today-text-color: var(--f7-theme-color);
  --f7-calendar-modal-bg-color: var(--f7-md-surface-1);
}

calendar.html
<template>
  <div class="page">
    <div class="navbar">
      <div class="navbar-bg"></div>
      <div class="navbar-inner sliding">
        <div class="title">Calendar</div>
      </div>
    </div>
    <div class="page-content">
      <div class="block">
        <p>Calendar is a touch optimized component that provides an easy way to handle dates.</p>
        <p>Calendar could be used as inline component or as overlay. Overlay Calendar will be automatically converted to
          Popover on tablets (iPad).</p>
      </div>
      <div class="block-title">Default setup</div>
      <div class="list list-strong-ios list-outline-ios">
        <ul>
          <li>
            <div class="item-content item-input">
              <div class="item-inner">
                <div class="item-input-wrap">
                  <input type="text" placeholder="Your birth date" readonly="readonly" id="demo-calendar-default" />
                </div>
              </div>
            </div>
          </li>
        </ul>
      </div>
      <div class="block-title">Custom date format</div>
      <div class="list list-strong-ios list-outline-ios">
        <ul>
          <li>
            <div class="item-content item-input">
              <div class="item-inner">
                <div class="item-input-wrap">
                  <input type="text" placeholder="Select date" readonly="readonly" id="demo-calendar-date-format" />
                </div>
              </div>
            </div>
          </li>
        </ul>
      </div>
      <div class="block-title">Date + Time</div>
      <div class="list list-strong-ios list-outline-ios">
        <ul>
          <li>
            <div class="item-content item-input">
              <div class="item-inner">
                <div class="item-input-wrap">
                  <input type="text" placeholder="Select date and time" readonly="readonly"
                    id="demo-calendar-date-time" />
                </div>
              </div>
            </div>
          </li>
        </ul>
      </div>
      <div class="block-title">Multiple Values</div>
      <div class="list list-strong-ios list-outline-ios">
        <ul>
          <li>
            <div class="item-content item-input">
              <div class="item-inner">
                <div class="item-input-wrap">
                  <input type="text" placeholder="Select multiple dates" readonly="readonly"
                    id="demo-calendar-multiple" />
                </div>
              </div>
            </div>
          </li>
        </ul>
      </div>
      <div class="block-title">Range Picker</div>
      <div class="list list-strong-ios list-outline-ios">
        <ul>
          <li>
            <div class="item-content item-input">
              <div class="item-inner">
                <div class="item-input-wrap">
                  <input type="text" placeholder="Select date range" readonly="readonly" id="demo-calendar-range" />
                </div>
              </div>
            </div>
          </li>
        </ul>
      </div>
      <div class="block-title">Open in Modal</div>
      <div class="list list-strong-ios list-outline-ios">
        <ul>
          <li>
            <div class="item-content item-input">
              <div class="item-inner">
                <div class="item-input-wrap">
                  <input type="text" placeholder="Select date" readonly="readonly" id="demo-calendar-modal" />
                </div>
              </div>
            </div>
          </li>
        </ul>
      </div>
      <div class="block-title">Calendar Page</div>
      <div class="list list-strong list-outline-ios">
        <ul>
          <li>
            <a href="/calendar-page/" class="item-content item-link">
              <div class="item-inner">
                <div class="item-title">Open Calendar Page</div>
              </div>
            </a>
          </li>
        </ul>
      </div>
      <div class="block-title">Inline with custom toolbar</div>
      <div class="block block-strong no-padding">
        <div id="demo-calendar-inline-container"></div>
      </div>
    </div>
  </div>
</template>
<script>
  export default (props, { $f7, $, $on }) => {
    let calendarDefault
    let calendarDateFormat;
    let calendarDateTime;
    let calendarMultiple;
    let calendarRange;
    let calendarModal;
    let calendarInline;
    $on('pageInit', () => {
      // Default
      calendarDefault = $f7.calendar.create({
        inputEl: '#demo-calendar-default',
      });

      // With custom date format
      calendarDateFormat = $f7.calendar.create({
        inputEl: '#demo-calendar-date-format',
        dateFormat: { weekday: 'long', month: 'long', day: '2-digit', year: 'numeric' },
      });

      // Date + Time
      calendarDateTime = $f7.calendar.create({
        inputEl: '#demo-calendar-date-time',
        timePicker: true,
        dateFormat: { month: 'numeric', day: 'numeric', year: 'numeric', hour: 'numeric', minute: 'numeric' },
      });

      // With multiple values
      calendarMultiple = $f7.calendar.create({
        inputEl: '#demo-calendar-multiple',
        dateFormat: { month: 'short', day: 'numeric' },
        multiple: true
      });
      // Range Picker
      calendarRange = $f7.calendar.create({
        inputEl: '#demo-calendar-range',
        rangePicker: true
      });
      // Custom modal
      calendarModal = $f7.calendar.create({
        inputEl: '#demo-calendar-modal',
        openIn: 'customModal',
        header: true,
        footer: true,
      });
      // Inline with custom toolbar
      var monthNames = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'];
      calendarInline = $f7.calendar.create({
        containerEl: '#demo-calendar-inline-container',
        value: [new Date()],
        renderToolbar: function () {
          return '<div class="toolbar calendar-custom-toolbar no-shadow">' +
            '<div class="toolbar-inner">' +
            '<div class="left">' +
            '<a  class="link icon-only"><i class="icon icon-back"></i></a>' +
            '</div>' +
            '<div class="center"></div>' +
            '<div class="right">' +
            '<a  class="link icon-only"><i class="icon icon-forward"></i></a>' +
            '</div>' +
            '</div>' +
            '</div>';
        },
        on: {
          init: function (c) {
            $('.calendar-custom-toolbar .center').text(monthNames[c.currentMonth] + ', ' + c.currentYear);
            $('.calendar-custom-toolbar .left .link').on('click', function () {
              calendarInline.prevMonth();
            });
            $('.calendar-custom-toolbar .right .link').on('click', function () {
              calendarInline.nextMonth();
            });
          },
          monthYearChangeStart: function (c) {
            $('.calendar-custom-toolbar .center').text(monthNames[c.currentMonth] + ', ' + c.currentYear);
          }
        }
      });
    });
    $on('pageBeforeRemove', () => {
      calendarDefault.destroy();
      calendarDateFormat.destroy();
      calendarDateTime.destroy();
      calendarMultiple.destroy();
      calendarRange.destroy();
      calendarModal.destroy();
      calendarInline.destroy();
    });

    return $render;
  };
</script>