1 | const _excluded = ["className", "focusedItem", "disabled", "onChange", "value", "min", "max", "localizer", "renderDay"];
|
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 cn from 'classnames';
|
8 | import React from 'react';
|
9 | import CalendarView from './CalendarView';
|
10 | import { chunk } from './_';
|
11 | import dates from './dates';
|
12 |
|
13 | function visibleDays(date, weekStart) {
|
14 | let current = dates.startOf(dates.startOf(date, 'month'), 'week', weekStart);
|
15 | let last = dates.endOf(dates.endOf(date, 'month'), 'week', weekStart);
|
16 | let days = [];
|
17 |
|
18 | while (dates.lte(current, last, 'day')) {
|
19 | days.push(current);
|
20 | current = dates.add(current, 1, 'day');
|
21 | }
|
22 |
|
23 | return days;
|
24 | }
|
25 |
|
26 | function MonthView(_ref) {
|
27 | let {
|
28 | className,
|
29 | focusedItem,
|
30 | disabled,
|
31 | onChange,
|
32 | value,
|
33 | min,
|
34 | max,
|
35 | localizer,
|
36 | renderDay
|
37 | } = _ref,
|
38 | props = _objectWithoutPropertiesLoose(_ref, _excluded);
|
39 |
|
40 | let month = visibleDays(focusedItem, localizer.firstOfWeek());
|
41 | let rows = chunk(month, 7);
|
42 | return React.createElement(CalendarView, _extends({}, props, {
|
43 | focusedItem: focusedItem,
|
44 | className: cn(className, 'rw-calendar-month')
|
45 | }), React.createElement("div", {
|
46 | role: "rowgroup",
|
47 | className: "rw-calendar-head"
|
48 | }, React.createElement(CalendarView.Row, {
|
49 | className: "rw-calendar-row"
|
50 | }, rows[0].map((date, idx) => React.createElement("div", {
|
51 | role: "columnheader",
|
52 | className: "rw-head-cell",
|
53 | key: idx
|
54 | }, localizer.formatDate(date, 'weekday'))))), React.createElement(CalendarView.Body, null, rows.map((row, rowIdx) => React.createElement(CalendarView.Row, {
|
55 | key: rowIdx
|
56 | }, row.map((date, colIdx) => {
|
57 | let formattedDate = localizer.formatDate(date, 'dayOfMonth');
|
58 | let label = localizer.formatDate(date, 'date');
|
59 | return React.createElement(CalendarView.Cell, {
|
60 | key: colIdx,
|
61 | label: label,
|
62 | date: date,
|
63 | min: min,
|
64 | max: max,
|
65 | unit: "day",
|
66 | viewUnit: "month",
|
67 | onChange: onChange,
|
68 | focusedItem: focusedItem,
|
69 | selected: value,
|
70 | disabled: disabled
|
71 | }, renderDay ? renderDay({
|
72 | date,
|
73 | label: formattedDate
|
74 | }) : formattedDate);
|
75 | })))));
|
76 | }
|
77 |
|
78 | export default MonthView; |
\ | No newline at end of file |