| 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164 |
11×
11×
11×
11×
11×
11×
11×
11×
11×
11×
77×
2×
2×
| import Component from '@ember/component';
import layout from '../../templates/components/polaris-date-picker/month';
import { computed } from '@ember/object';
import {
monthsArray,
weekdaysArray,
getWeeksForMonth,
getNewRange,
abbreviationForWeekday
} from '../../utils/dates';
export default Component.extend({
classNames: ['Polaris-DatePicker__Month'],
attributeBindings: ['role'],
layout,
/**
* @property focusedDate
* @public
* @type {Date}
* @default null
*/
focusedDate: null,
/**
* @property selected
* @public
* @type {Object}
* @default null
*/
selected: null,
/**
* @property hoverDate
* @public
* @type {Date}
* @default null
*/
hoverDate: null,
/**
* @property month
* @public
* @type {Number}
* @default null
*/
month: null,
/**
* @property year
* @public
* @type {Number}
* @default null
*/
year: null,
/**
* @property disableDatesBefore
* @public
* @type {Date}
* @default null
*/
disableDatesBefore: null,
/**
* @property disableDatesAfter
* @public
* @type {Date}
* @default null
*/
disableDatesAfter: null,
/**
* @property allowRange
* @public
* @type {Boolean}
* @default false
*/
allowRange: false,
/**
* @property onChange
* @public
* @type {Function}
* @default noop
*/
onChange(/* dateRange */) {},
/**
* @property onHover
* @public
* @type {Function}
* @default noop
*/
onHover(/* hoverEnd */) {},
/**
* @property onFocus
* @public
* @type {Function}
* @default noop
*/
onFocus(/* date */) {},
/**
* @property monthName
* @public
* @type {Function}
* @default noop
*/
monthName(/* month */) {},
/**
* @property weekdayName
* @public
* @type {Function}
* @default noop
*/
weekdayName(/* weekday */) {},
role: 'grid',
current: computed('month', 'year', function() {
let date = new Date();
let thisMonth = date.getMonth();
let thisYear = date.getFullYear();
return thisMonth === this.get('month') && thisYear === this.get('year');
}).readOnly(),
monthDisplayName: computed('month', function() {
return monthsArray[this.get('month')];
}).readOnly(),
weeks: computed('month', 'year', function() {
let { month, year } = this.getProperties('month', 'year');
return getWeeksForMonth(month, year);
}).readOnly(),
weekdays: computed('current', function() {
let current = this.get('current');
let day = new Date().getDay();
return weekdaysArray.map((weekday, i) => {
return {
title: abbreviationForWeekday(weekday),
current: (current && day === i),
label: weekday
};
});
}).readOnly(),
actions: {
handleDateClick(day) {
let range = getNewRange(this.get('selected'), day);
this.get('onChange')(range);
}
}
});
|