@sb1/ffe-datepicker-react 100.12.4 → 101.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/es/button/Button.js +4 -5
- package/es/calendar/Calendar.js +88 -111
- package/es/calendar/ClickableDate.js +20 -41
- package/es/calendar/Header.js +13 -14
- package/es/calendar/NonClickableDate.js +1 -2
- package/es/datelogic/simplecalendar.js +97 -124
- package/es/datelogic/simpledate.js +66 -96
- package/es/datepicker/Datepicker.js +2 -25
- package/es/datepicker/DatepickerComp.js +61 -64
- package/es/datepicker/DatepickerContext.js +33 -36
- package/es/datepicker/SpinButton.js +8 -32
- package/es/datepicker/padZero.js +2 -2
- package/es/datepicker/testHelper.js +72 -143
- package/es/datepicker/toNumber.js +4 -6
- package/es/i18n/i18n.js +3 -3
- package/es/input/DateInput.js +3 -26
- package/es/types.js +1 -1
- package/es/util/dateRangeUtils.js +12 -12
- package/es/util/dateUtil.js +2 -2
- package/es/util/isIOSSafari.js +4 -4
- package/lib/button/Button.js +8 -9
- package/lib/calendar/Calendar.js +94 -116
- package/lib/calendar/ClickableDate.js +22 -42
- package/lib/calendar/Header.js +17 -18
- package/lib/calendar/NonClickableDate.js +2 -3
- package/lib/datelogic/simplecalendar.js +99 -125
- package/lib/datelogic/simpledate.js +67 -96
- package/lib/datepicker/Datepicker.js +5 -28
- package/lib/datepicker/DatepickerComp.js +74 -77
- package/lib/datepicker/DatepickerContext.js +36 -39
- package/lib/datepicker/SpinButton.js +10 -34
- package/lib/datepicker/padZero.js +2 -2
- package/lib/datepicker/testHelper.js +73 -177
- package/lib/datepicker/toNumber.js +4 -6
- package/lib/i18n/i18n.js +3 -3
- package/lib/input/DateInput.js +7 -30
- package/lib/types.js +1 -1
- package/lib/util/dateRangeUtils.js +14 -14
- package/lib/util/dateUtil.js +3 -3
- package/lib/util/isIOSSafari.js +4 -4
- package/package.json +13 -14
package/lib/calendar/Calendar.js
CHANGED
|
@@ -1,19 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __extends = (this && this.__extends) || (function () {
|
|
3
|
-
var extendStatics = function (d, b) {
|
|
4
|
-
extendStatics = Object.setPrototypeOf ||
|
|
5
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
-
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
-
return extendStatics(d, b);
|
|
8
|
-
};
|
|
9
|
-
return function (d, b) {
|
|
10
|
-
if (typeof b !== "function" && b !== null)
|
|
11
|
-
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
|
-
extendStatics(d, b);
|
|
13
|
-
function __() { this.constructor = d; }
|
|
14
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
|
-
};
|
|
16
|
-
})();
|
|
17
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
18
3
|
if (k2 === undefined) k2 = k;
|
|
19
4
|
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
@@ -49,110 +34,107 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
49
34
|
})();
|
|
50
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
51
36
|
exports.Calendar = void 0;
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
_this.yearSelectRef = react_1.default.createRef();
|
|
68
|
-
_this.focusTrap = function (event) {
|
|
37
|
+
const react_1 = __importStar(require("react"));
|
|
38
|
+
const ClickableDate_1 = require("./ClickableDate");
|
|
39
|
+
const NonClickableDate_1 = require("./NonClickableDate");
|
|
40
|
+
const Header_1 = require("./Header");
|
|
41
|
+
const simpledate_1 = require("../datelogic/simpledate");
|
|
42
|
+
const simplecalendar_1 = require("../datelogic/simplecalendar");
|
|
43
|
+
class Calendar extends react_1.Component {
|
|
44
|
+
constructor(props) {
|
|
45
|
+
super(props);
|
|
46
|
+
this.clickableDateRef = react_1.default.createRef();
|
|
47
|
+
this.prevMonthButtonElementRef = react_1.default.createRef();
|
|
48
|
+
this.nextMonthButtonElementRef = react_1.default.createRef();
|
|
49
|
+
this.monthSelectRef = react_1.default.createRef();
|
|
50
|
+
this.yearSelectRef = react_1.default.createRef();
|
|
51
|
+
this.focusTrap = (event) => {
|
|
69
52
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
|
|
70
|
-
|
|
53
|
+
const activeElement = document.activeElement;
|
|
71
54
|
if (event.key === 'Tab') {
|
|
72
55
|
event.preventDefault();
|
|
73
|
-
|
|
56
|
+
const { dropdownCaption } = this.props;
|
|
74
57
|
if (event.shiftKey) {
|
|
75
|
-
if (activeElement ===
|
|
76
|
-
(_a =
|
|
77
|
-
|
|
58
|
+
if (activeElement === this.clickableDateRef.current) {
|
|
59
|
+
(_a = this.nextMonthButtonElementRef.current) === null || _a === void 0 ? void 0 : _a.focus();
|
|
60
|
+
this.setState({ isFocusingHeader: true });
|
|
78
61
|
}
|
|
79
|
-
else if (activeElement ===
|
|
62
|
+
else if (activeElement === this.nextMonthButtonElementRef.current) {
|
|
80
63
|
if (dropdownCaption) {
|
|
81
|
-
(_b =
|
|
64
|
+
(_b = this.yearSelectRef.current) === null || _b === void 0 ? void 0 : _b.focus();
|
|
82
65
|
}
|
|
83
66
|
else {
|
|
84
|
-
(_c =
|
|
67
|
+
(_c = this.prevMonthButtonElementRef.current) === null || _c === void 0 ? void 0 : _c.focus();
|
|
85
68
|
}
|
|
86
69
|
}
|
|
87
|
-
else if (dropdownCaption && activeElement ===
|
|
88
|
-
(_d =
|
|
70
|
+
else if (dropdownCaption && activeElement === this.yearSelectRef.current) {
|
|
71
|
+
(_d = this.monthSelectRef.current) === null || _d === void 0 ? void 0 : _d.focus();
|
|
89
72
|
}
|
|
90
|
-
else if (dropdownCaption && activeElement ===
|
|
91
|
-
(_e =
|
|
73
|
+
else if (dropdownCaption && activeElement === this.monthSelectRef.current) {
|
|
74
|
+
(_e = this.prevMonthButtonElementRef.current) === null || _e === void 0 ? void 0 : _e.focus();
|
|
92
75
|
}
|
|
93
|
-
else if (activeElement ===
|
|
94
|
-
(_f =
|
|
95
|
-
|
|
96
|
-
|
|
76
|
+
else if (activeElement === this.prevMonthButtonElementRef.current) {
|
|
77
|
+
(_f = this.clickableDateRef.current) === null || _f === void 0 ? void 0 : _f.focus();
|
|
78
|
+
this.setState({ isFocusingHeader: false });
|
|
79
|
+
this.forceUpdate();
|
|
97
80
|
}
|
|
98
81
|
}
|
|
99
82
|
else {
|
|
100
|
-
if (activeElement ===
|
|
101
|
-
(_g =
|
|
102
|
-
|
|
83
|
+
if (activeElement === this.clickableDateRef.current) {
|
|
84
|
+
(_g = this.prevMonthButtonElementRef.current) === null || _g === void 0 ? void 0 : _g.focus();
|
|
85
|
+
this.setState({ isFocusingHeader: true });
|
|
103
86
|
}
|
|
104
|
-
else if (activeElement ===
|
|
87
|
+
else if (activeElement === this.prevMonthButtonElementRef.current) {
|
|
105
88
|
if (dropdownCaption) {
|
|
106
|
-
(_h =
|
|
89
|
+
(_h = this.monthSelectRef.current) === null || _h === void 0 ? void 0 : _h.focus();
|
|
107
90
|
}
|
|
108
91
|
else {
|
|
109
|
-
(_j =
|
|
92
|
+
(_j = this.nextMonthButtonElementRef.current) === null || _j === void 0 ? void 0 : _j.focus();
|
|
110
93
|
}
|
|
111
94
|
}
|
|
112
|
-
else if (dropdownCaption && activeElement ===
|
|
113
|
-
(_k =
|
|
95
|
+
else if (dropdownCaption && activeElement === this.monthSelectRef.current) {
|
|
96
|
+
(_k = this.yearSelectRef.current) === null || _k === void 0 ? void 0 : _k.focus();
|
|
114
97
|
}
|
|
115
|
-
else if (dropdownCaption && activeElement ===
|
|
116
|
-
(_l =
|
|
98
|
+
else if (dropdownCaption && activeElement === this.yearSelectRef.current) {
|
|
99
|
+
(_l = this.nextMonthButtonElementRef.current) === null || _l === void 0 ? void 0 : _l.focus();
|
|
117
100
|
}
|
|
118
|
-
else if (activeElement ===
|
|
119
|
-
(_m =
|
|
120
|
-
|
|
121
|
-
|
|
101
|
+
else if (activeElement === this.nextMonthButtonElementRef.current) {
|
|
102
|
+
(_m = this.clickableDateRef.current) === null || _m === void 0 ? void 0 : _m.focus();
|
|
103
|
+
this.setState({ isFocusingHeader: false });
|
|
104
|
+
this.forceUpdate();
|
|
122
105
|
}
|
|
123
106
|
}
|
|
124
107
|
}
|
|
125
108
|
};
|
|
126
|
-
|
|
109
|
+
this.state = {
|
|
127
110
|
calendar: new simplecalendar_1.SimpleCalendar((0, simpledate_1.getSimpleDateFromString)(props === null || props === void 0 ? void 0 : props.selectedDate), props.minDate, props.maxDate, props.disabledDates, props.locale),
|
|
128
111
|
isFocusingHeader: false,
|
|
129
112
|
};
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
return _this;
|
|
113
|
+
this.datepickerId = `ffe-calendar-${Math.random().toString(36).slice(2)}`;
|
|
114
|
+
this.keyDown = this.keyDown.bind(this);
|
|
115
|
+
this.mouseClick = this.mouseClick.bind(this);
|
|
116
|
+
this.nextMonth = this.nextMonth.bind(this);
|
|
117
|
+
this.previousMonth = this.previousMonth.bind(this);
|
|
118
|
+
this.navigateToMonthYear = this.navigateToMonthYear.bind(this);
|
|
119
|
+
this.renderDate = this.renderDate.bind(this);
|
|
120
|
+
this.renderWeek = this.renderWeek.bind(this);
|
|
121
|
+
this.renderDay = this.renderDay.bind(this);
|
|
140
122
|
}
|
|
141
123
|
/* eslint-disable react/no-did-update-set-state */
|
|
142
|
-
|
|
124
|
+
componentDidUpdate(prevProps) {
|
|
143
125
|
if (prevProps.selectedDate !== this.props.selectedDate) {
|
|
144
126
|
this.setState({
|
|
145
127
|
calendar: new simplecalendar_1.SimpleCalendar((0, simpledate_1.getSimpleDateFromString)(this.props.selectedDate), this.props.minDate, this.props.maxDate, this.props.disabledDates, this.props.locale),
|
|
146
128
|
}, this.forceUpdate);
|
|
147
129
|
}
|
|
148
|
-
}
|
|
149
|
-
|
|
130
|
+
}
|
|
131
|
+
shouldComponentUpdate(nextProps) {
|
|
150
132
|
return nextProps.selectedDate !== this.props.selectedDate;
|
|
151
|
-
}
|
|
152
|
-
|
|
133
|
+
}
|
|
134
|
+
keyDown(event) {
|
|
153
135
|
var _a, _b, _c;
|
|
154
|
-
|
|
155
|
-
|
|
136
|
+
const calendar = this.state.calendar;
|
|
137
|
+
const scrollableEvents = [
|
|
156
138
|
'PageUp',
|
|
157
139
|
'PageDown',
|
|
158
140
|
'End',
|
|
@@ -217,79 +199,75 @@ var Calendar = /** @class */ (function (_super) {
|
|
|
217
199
|
return;
|
|
218
200
|
}
|
|
219
201
|
this.forceUpdate();
|
|
220
|
-
}
|
|
221
|
-
|
|
222
|
-
|
|
202
|
+
}
|
|
203
|
+
mouseClick(date) {
|
|
204
|
+
const pickedDate = (0, simpledate_1.getSimpleDateFromTimestamp)(date.timestamp);
|
|
223
205
|
if (this.state.calendar.isDateWithinDateRange(pickedDate) &&
|
|
224
206
|
date.isEnabled) {
|
|
225
207
|
this.state.calendar.selectTimestamp(date.timestamp);
|
|
226
208
|
this.props.onDatePicked(this.state.calendar.selected());
|
|
227
209
|
}
|
|
228
|
-
}
|
|
229
|
-
|
|
210
|
+
}
|
|
211
|
+
nextMonth(evt) {
|
|
230
212
|
evt.preventDefault();
|
|
231
213
|
this.state.calendar.nextMonth();
|
|
232
214
|
this.forceUpdate();
|
|
233
|
-
}
|
|
234
|
-
|
|
215
|
+
}
|
|
216
|
+
previousMonth(evt) {
|
|
235
217
|
evt.preventDefault();
|
|
236
218
|
this.state.calendar.previousMonth();
|
|
237
219
|
this.forceUpdate();
|
|
238
|
-
}
|
|
239
|
-
|
|
240
|
-
|
|
220
|
+
}
|
|
221
|
+
renderDate(calendarButtonState, index) {
|
|
222
|
+
const { calendar } = this.state;
|
|
241
223
|
if (calendarButtonState.isNonClickableDate) {
|
|
242
224
|
return (react_1.default.createElement(NonClickableDate_1.NonClickableDate, { key: calendarButtonState.dayInMonth, date: { timestamp: calendarButtonState.timestamp } }));
|
|
243
225
|
}
|
|
244
|
-
return (react_1.default.createElement(ClickableDate_1.ClickableDate, { calendarButtonState: calendarButtonState, month: calendar.focusedMonth, year: calendar.focusedYear, headers:
|
|
226
|
+
return (react_1.default.createElement(ClickableDate_1.ClickableDate, { calendarButtonState: calendarButtonState, month: calendar.focusedMonth, year: calendar.focusedYear, headers: `header__${this.datepickerId}__${index}`, key: calendarButtonState.timestamp, onClick: this.mouseClick, locale: this.props.locale, dateButtonRef: calendarButtonState.isFocus
|
|
245
227
|
? this.clickableDateRef
|
|
246
228
|
: undefined, isFocusingHeader: this.state.isFocusingHeader, focusOnMount: this.props.focusOnMount }));
|
|
247
|
-
}
|
|
248
|
-
|
|
249
|
-
return (react_1.default.createElement("tr", { key:
|
|
250
|
-
}
|
|
251
|
-
|
|
252
|
-
return (react_1.default.createElement("th", { "aria-label": day.name, className: "ffe-calendar__weekday", id:
|
|
229
|
+
}
|
|
230
|
+
renderWeek(week) {
|
|
231
|
+
return (react_1.default.createElement("tr", { key: `week-${week.number}`, role: "presentation" }, week.dates.map(this.renderDate)));
|
|
232
|
+
}
|
|
233
|
+
renderDay(day, index) {
|
|
234
|
+
return (react_1.default.createElement("th", { "aria-label": day.name, className: "ffe-calendar__weekday", id: `header__${this.datepickerId}__${index}`, key: day.name },
|
|
253
235
|
react_1.default.createElement("span", { title: day.name }, day.shortName)));
|
|
254
|
-
}
|
|
236
|
+
}
|
|
255
237
|
/**
|
|
256
238
|
* Navigate to a specific month and year
|
|
257
239
|
*/
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
240
|
+
navigateToMonthYear(month, year) {
|
|
241
|
+
const { calendar } = this.state;
|
|
242
|
+
let currentMonth = calendar.focusedDate.month + 1; // 1-indexed month
|
|
243
|
+
let currentYear = calendar.focusedYear;
|
|
262
244
|
// Calculate how many months to move based on current and target date
|
|
263
|
-
|
|
245
|
+
const monthsDiff = (year - currentYear) * 12 + (month - currentMonth);
|
|
264
246
|
if (monthsDiff < 0) {
|
|
265
247
|
// Go backward
|
|
266
|
-
for (
|
|
248
|
+
for (let i = 0; i > monthsDiff; i--) {
|
|
267
249
|
calendar.previousMonth();
|
|
268
250
|
}
|
|
269
251
|
}
|
|
270
252
|
else if (monthsDiff > 0) {
|
|
271
253
|
// Go forward
|
|
272
|
-
for (
|
|
254
|
+
for (let i = 0; i < monthsDiff; i++) {
|
|
273
255
|
calendar.nextMonth();
|
|
274
256
|
}
|
|
275
257
|
}
|
|
276
258
|
this.forceUpdate();
|
|
277
|
-
}
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
var calendar = this.state.calendar;
|
|
259
|
+
}
|
|
260
|
+
render() {
|
|
261
|
+
const { calendar } = this.state;
|
|
281
262
|
/* eslint-disable jsx-a11y/no-noninteractive-element-interactions */
|
|
282
|
-
return (react_1.default.createElement("div", { role: "dialog", "aria-modal": true, "aria-labelledby":
|
|
263
|
+
return (react_1.default.createElement("div", { role: "dialog", "aria-modal": true, "aria-labelledby": `${this.datepickerId}-title`, className: "ffe-default-mode" },
|
|
283
264
|
react_1.default.createElement("div", { className: this.props.calendarClassName || 'ffe-calendar', role: "application", onKeyDown: this.focusTrap },
|
|
284
|
-
react_1.default.createElement(Header_1.Header, { datepickerId: this.datepickerId, month: calendar.focusedMonth, nextMonthHandler: this.nextMonth, nextMonthLabel: calendar.nextName, previousMonthHandler: this.previousMonth, previousMonthLabel: calendar.previousName, year: calendar.focusedYear, prevMonthButtonElement: this.prevMonthButtonElementRef, nextMonthButtonElement: this.nextMonthButtonElementRef, monthNumber: calendar.focusedDate.month + 1, locale: this.props.locale, dropdownCaption: this.props.dropdownCaption, onMonthYearChange:
|
|
285
|
-
return _this.navigateToMonthYear(month, year);
|
|
286
|
-
}, minDate: this.props.minDate, maxDate: this.props.maxDate, monthSelectRef: this.monthSelectRef, yearSelectRef: this.yearSelectRef }),
|
|
265
|
+
react_1.default.createElement(Header_1.Header, { datepickerId: this.datepickerId, month: calendar.focusedMonth, nextMonthHandler: this.nextMonth, nextMonthLabel: calendar.nextName, previousMonthHandler: this.previousMonth, previousMonthLabel: calendar.previousName, year: calendar.focusedYear, prevMonthButtonElement: this.prevMonthButtonElementRef, nextMonthButtonElement: this.nextMonthButtonElementRef, monthNumber: calendar.focusedDate.month + 1, locale: this.props.locale, dropdownCaption: this.props.dropdownCaption, onMonthYearChange: (month, year) => this.navigateToMonthYear(month, year), minDate: this.props.minDate, maxDate: this.props.maxDate, monthSelectRef: this.monthSelectRef, yearSelectRef: this.yearSelectRef }),
|
|
287
266
|
react_1.default.createElement("table", { className: "ffe-calendar__grid", onKeyDown: this.keyDown, role: "presentation" },
|
|
288
267
|
react_1.default.createElement("thead", null,
|
|
289
268
|
react_1.default.createElement("tr", null, calendar.dayNames.map(this.renderDay))),
|
|
290
269
|
react_1.default.createElement("tbody", null, calendar.visibleDates.map(this.renderWeek))))));
|
|
291
270
|
/* eslint-enable jsx-a11y/no-noninteractive-element-interactions */
|
|
292
|
-
}
|
|
293
|
-
|
|
294
|
-
}(react_1.Component));
|
|
271
|
+
}
|
|
272
|
+
}
|
|
295
273
|
exports.Calendar = Calendar;
|
|
@@ -1,19 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __extends = (this && this.__extends) || (function () {
|
|
3
|
-
var extendStatics = function (d, b) {
|
|
4
|
-
extendStatics = Object.setPrototypeOf ||
|
|
5
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
-
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
-
return extendStatics(d, b);
|
|
8
|
-
};
|
|
9
|
-
return function (d, b) {
|
|
10
|
-
if (typeof b !== "function" && b !== null)
|
|
11
|
-
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
|
-
extendStatics(d, b);
|
|
13
|
-
function __() { this.constructor = d; }
|
|
14
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
|
-
};
|
|
16
|
-
})();
|
|
17
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
18
3
|
if (k2 === undefined) k2 = k;
|
|
19
4
|
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
@@ -52,31 +37,27 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
52
37
|
};
|
|
53
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
54
39
|
exports.ClickableDate = void 0;
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
function ClickableDate() {
|
|
60
|
-
return _super !== null && _super.apply(this, arguments) || this;
|
|
61
|
-
}
|
|
62
|
-
ClickableDate.prototype.componentDidMount = function () {
|
|
40
|
+
const react_1 = __importStar(require("react"));
|
|
41
|
+
const classnames_1 = __importDefault(require("classnames"));
|
|
42
|
+
class ClickableDate extends react_1.Component {
|
|
43
|
+
componentDidMount() {
|
|
63
44
|
if (this.props.focusOnMount) {
|
|
64
45
|
this.focusIfNeeded();
|
|
65
46
|
}
|
|
66
|
-
}
|
|
67
|
-
|
|
47
|
+
}
|
|
48
|
+
componentDidUpdate() {
|
|
68
49
|
this.focusIfNeeded();
|
|
69
|
-
}
|
|
70
|
-
|
|
50
|
+
}
|
|
51
|
+
focusIfNeeded() {
|
|
71
52
|
var _a;
|
|
72
|
-
|
|
53
|
+
const { calendarButtonState, isFocusingHeader, dateButtonRef } = this.props;
|
|
73
54
|
if (calendarButtonState.isFocus && !isFocusingHeader) {
|
|
74
55
|
(_a = dateButtonRef === null || dateButtonRef === void 0 ? void 0 : dateButtonRef.current) === null || _a === void 0 ? void 0 : _a.focus();
|
|
75
56
|
}
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
57
|
+
}
|
|
58
|
+
dateClassName() {
|
|
59
|
+
const { calendarButtonState, isFocusingHeader } = this.props;
|
|
60
|
+
const { isEnabled, isFocus, isSelected, isToday } = calendarButtonState;
|
|
80
61
|
return (0, classnames_1.default)({
|
|
81
62
|
'ffe-calendar__date': true,
|
|
82
63
|
'ffe-calendar__date--today': isToday,
|
|
@@ -85,16 +66,15 @@ var ClickableDate = /** @class */ (function (_super) {
|
|
|
85
66
|
'ffe-calendar__date--selected': isSelected,
|
|
86
67
|
'ffe-calendar__date--disabled-focus': !isEnabled && isFocus,
|
|
87
68
|
});
|
|
88
|
-
}
|
|
89
|
-
|
|
69
|
+
}
|
|
70
|
+
tabIndex() {
|
|
90
71
|
return this.props.calendarButtonState.isFocus ? 0 : -1;
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
return (react_1.default.createElement("td", { className: "ffe-calendar__day", headers: headers, role: "button", ref: dateButtonRef, "aria-disabled": !calendarButtonState.isEnabled, "aria-current": calendarButtonState.isSelected, "aria-label":
|
|
72
|
+
}
|
|
73
|
+
render() {
|
|
74
|
+
const { calendarButtonState, headers, onClick, locale, dateButtonRef, month, year, } = this.props;
|
|
75
|
+
const monthName = locale === 'en' ? month : month.toLowerCase();
|
|
76
|
+
return (react_1.default.createElement("td", { className: "ffe-calendar__day", headers: headers, role: "button", ref: dateButtonRef, "aria-disabled": !calendarButtonState.isEnabled, "aria-current": calendarButtonState.isSelected, "aria-label": `${calendarButtonState.dayInMonth}. ${monthName} ${year}`, tabIndex: this.tabIndex(), onClick: () => onClick(calendarButtonState) },
|
|
96
77
|
react_1.default.createElement("span", { className: this.dateClassName(), "aria-hidden": "true" }, calendarButtonState.dayInMonth)));
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
}(react_1.Component));
|
|
78
|
+
}
|
|
79
|
+
}
|
|
100
80
|
exports.ClickableDate = ClickableDate;
|
package/lib/calendar/Header.js
CHANGED
|
@@ -4,42 +4,41 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.Header = void 0;
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
var selectedMonth = parseInt(e.target.value, 10);
|
|
7
|
+
const react_1 = __importDefault(require("react"));
|
|
8
|
+
const ffe_icons_react_1 = require("@sb1/ffe-icons-react");
|
|
9
|
+
const ffe_dropdown_react_1 = require("@sb1/ffe-dropdown-react");
|
|
10
|
+
const dateRangeUtils_1 = require("../util/dateRangeUtils");
|
|
11
|
+
const Header = ({ datepickerId, month, nextMonthHandler, nextMonthLabel, previousMonthHandler, previousMonthLabel, year, prevMonthButtonElement, nextMonthButtonElement, monthNumber, dropdownCaption = false, locale, onMonthYearChange, minDate, maxDate, monthSelectRef, yearSelectRef, }) => {
|
|
12
|
+
const arrowBackIosIcon = 'data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIGhlaWdodD0iMjQiIHZpZXdCb3g9IjAgLTk2MCA5NjAgOTYwIiB3aWR0aD0iMjQiPjxwYXRoIGQ9Im0zNjcuMzg0LTQ4MCAzMDEuMzA4IDMwMS4zMDhxMTEuOTIzIDExLjkyMyAxMS42MTUgMjguMDc3LS4zMDggMTYuMTUzLTEyLjIzMSAyOC4wNzZxLTExLjkyMiAxMS45MjMtMjguMDc2IDExLjkyM3QtMjguMDc2LTExLjkyM0wzMDUuMDc4LTQyOC43N3EtMTAuODQ3LTEwLjg0Ni0xNi4wNzctMjQuMzA3LTUuMjMxLTEzLjQ2Mi01LjIzMS0yNi45MjMgMC0xMy40NjEgNS4yMzEtMjYuOTIzIDUuMjMtMTMuNDYxIDE2LjA3Ny0yNC4zMDdsMzA2Ljg0Ni0zMDYuODQ2cTExLjkyMi0xMS45MjMgMjguMzg0LTExLjYxNiAxNi40NjEuMzA4IDI4LjM4NCAxMi4yMzEgMTEuOTIzIDExLjkyMyAxMS45MjMgMjguMDc2IDAgMTYuMTU0LTExLjkyMyAyOC4wNzdMMzY3LjM4NC00ODBaIi8+PC9zdmc+';
|
|
13
|
+
const monthOptions = (0, dateRangeUtils_1.getMonthOptions)(locale);
|
|
14
|
+
const yearOptions = (0, dateRangeUtils_1.getYearOptions)(minDate, maxDate);
|
|
15
|
+
const handleMonthChange = (e) => {
|
|
16
|
+
const selectedMonth = parseInt(e.target.value, 10);
|
|
18
17
|
onMonthYearChange === null || onMonthYearChange === void 0 ? void 0 : onMonthYearChange(selectedMonth, year);
|
|
19
18
|
};
|
|
20
|
-
|
|
21
|
-
|
|
19
|
+
const handleYearChange = (e) => {
|
|
20
|
+
const selectedYear = parseInt(e.target.value, 10);
|
|
22
21
|
onMonthYearChange === null || onMonthYearChange === void 0 ? void 0 : onMonthYearChange(monthNumber, selectedYear);
|
|
23
22
|
};
|
|
24
23
|
// Prevent event propagation when interacting with dropdowns to avoid
|
|
25
24
|
// closing the calendar when selecting from dropdowns
|
|
26
|
-
|
|
25
|
+
const handleDropdownClick = (e) => {
|
|
27
26
|
// Add datepickerId flag to prevent calendar from closing
|
|
28
27
|
e.nativeEvent.__datepickerID = datepickerId;
|
|
29
28
|
e.stopPropagation();
|
|
30
29
|
};
|
|
31
|
-
|
|
30
|
+
const handleDropdownFocus = (e) => {
|
|
32
31
|
e.stopPropagation();
|
|
33
32
|
};
|
|
34
33
|
return (react_1.default.createElement("div", { className: "ffe-calendar__header" },
|
|
35
34
|
react_1.default.createElement("div", { className: "ffe-calendar__header-inner-wrapper" },
|
|
36
35
|
react_1.default.createElement("button", { className: "ffe-calendar__month-nav ffe-calendar__previous", onClick: previousMonthHandler, "aria-label": previousMonthLabel, type: "button", ref: prevMonthButtonElement, tabIndex: -1 },
|
|
37
36
|
react_1.default.createElement(ffe_icons_react_1.Icon, { fileUrl: arrowBackIosIcon, size: "md", className: "ffe-calendar__icon-prev" })),
|
|
38
|
-
react_1.default.createElement("header", { "aria-live": "polite", className: "ffe-calendar__title", id:
|
|
37
|
+
react_1.default.createElement("header", { "aria-live": "polite", className: "ffe-calendar__title", id: `${datepickerId}-title` }, dropdownCaption ? (react_1.default.createElement("div", { className: "ffe-calendar__dropdown-container" },
|
|
39
38
|
react_1.default.createElement("div", { className: "ffe-calendar__dropdown ffe-calendar__month-dropdown" },
|
|
40
|
-
react_1.default.createElement(ffe_dropdown_react_1.Dropdown, { id:
|
|
39
|
+
react_1.default.createElement(ffe_dropdown_react_1.Dropdown, { id: `${datepickerId}__month-select`, className: "ffe-calendar__month-select", value: monthNumber, onChange: handleMonthChange, "aria-label": `${month} ${year}`, onClick: handleDropdownClick, onFocus: handleDropdownFocus, ref: monthSelectRef }, monthOptions.map(option => (react_1.default.createElement("option", { key: option.value, value: option.value }, option.label))))),
|
|
41
40
|
react_1.default.createElement("div", { className: "ffe-calendar__dropdown ffe-calendar__year-dropdown" },
|
|
42
|
-
react_1.default.createElement(ffe_dropdown_react_1.Dropdown, { id:
|
|
41
|
+
react_1.default.createElement(ffe_dropdown_react_1.Dropdown, { id: `${datepickerId}__year-select`, className: "ffe-calendar__year-select", value: year, onChange: handleYearChange, "aria-label": `${year}`, onClick: handleDropdownClick, onFocus: handleDropdownFocus, ref: yearSelectRef }, yearOptions.map(option => (react_1.default.createElement("option", { key: option.value, value: option.value }, option.label))))))) : (react_1.default.createElement("div", { id: `${datepickerId}__month-label`, "data-testid": `${datepickerId}__month-label` },
|
|
43
42
|
react_1.default.createElement("span", { className: "ffe-calendar__month" }, month),
|
|
44
43
|
react_1.default.createElement("span", { className: "ffe-calendar__year" }, year)))),
|
|
45
44
|
react_1.default.createElement("button", { className: "ffe-calendar__month-nav ffe-calendar__next", onClick: nextMonthHandler, "aria-label": nextMonthLabel, type: "button", ref: nextMonthButtonElement, tabIndex: -1 },
|
|
@@ -4,9 +4,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.NonClickableDate = void 0;
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
var date = _a.date;
|
|
7
|
+
const react_1 = __importDefault(require("react"));
|
|
8
|
+
const NonClickableDate = ({ date }) => {
|
|
10
9
|
return (react_1.default.createElement("td", { "aria-hidden": true, className: "ffe-calendar__day", key: date.timestamp, role: "button" }));
|
|
11
10
|
};
|
|
12
11
|
exports.NonClickableDate = NonClickableDate;
|