1 | const _excluded = ["focusedItem", "disabled", "onChange", "value", "min", "localizer", "max"];
|
2 |
|
3 | function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
4 |
|
5 | function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
6 |
|
7 | import React from 'react';
|
8 | import CalendarView from './CalendarView';
|
9 | import { chunk } from './_';
|
10 | import dates from './dates';
|
11 | const months = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11];
|
12 |
|
13 | function monthsInYear(year) {
|
14 | let date = new Date(year, 0, 1);
|
15 | return months.map(i => dates.month(date, i));
|
16 | }
|
17 |
|
18 | function YearView(_ref) {
|
19 | let {
|
20 | focusedItem,
|
21 | disabled,
|
22 | onChange,
|
23 | value,
|
24 | min,
|
25 | localizer,
|
26 | max
|
27 | } = _ref,
|
28 | props = _objectWithoutPropertiesLoose(_ref, _excluded);
|
29 |
|
30 | let months = monthsInYear(dates.year(focusedItem));
|
31 | return React.createElement(CalendarView, _extends({}, props, {
|
32 | focusedItem: focusedItem
|
33 | }), React.createElement(CalendarView.Body, null, chunk(months, 4).map((row, rowIdx) => React.createElement(CalendarView.Row, {
|
34 | key: rowIdx
|
35 | }, row.map((date, colIdx) => {
|
36 | let label = localizer.formatDate(date, 'header');
|
37 | return React.createElement(CalendarView.Cell, {
|
38 | key: colIdx,
|
39 | label: label,
|
40 | date: date,
|
41 | min: min,
|
42 | max: max,
|
43 | unit: "month",
|
44 | viewUnit: "year",
|
45 | onChange: onChange,
|
46 | focusedItem: focusedItem,
|
47 | selected: value,
|
48 | disabled: disabled
|
49 | }, localizer.formatDate(date, 'month'));
|
50 | })))));
|
51 | }
|
52 |
|
53 | export default YearView; |
\ | No newline at end of file |