@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.
Files changed (41) hide show
  1. package/es/button/Button.js +4 -5
  2. package/es/calendar/Calendar.js +88 -111
  3. package/es/calendar/ClickableDate.js +20 -41
  4. package/es/calendar/Header.js +13 -14
  5. package/es/calendar/NonClickableDate.js +1 -2
  6. package/es/datelogic/simplecalendar.js +97 -124
  7. package/es/datelogic/simpledate.js +66 -96
  8. package/es/datepicker/Datepicker.js +2 -25
  9. package/es/datepicker/DatepickerComp.js +61 -64
  10. package/es/datepicker/DatepickerContext.js +33 -36
  11. package/es/datepicker/SpinButton.js +8 -32
  12. package/es/datepicker/padZero.js +2 -2
  13. package/es/datepicker/testHelper.js +72 -143
  14. package/es/datepicker/toNumber.js +4 -6
  15. package/es/i18n/i18n.js +3 -3
  16. package/es/input/DateInput.js +3 -26
  17. package/es/types.js +1 -1
  18. package/es/util/dateRangeUtils.js +12 -12
  19. package/es/util/dateUtil.js +2 -2
  20. package/es/util/isIOSSafari.js +4 -4
  21. package/lib/button/Button.js +8 -9
  22. package/lib/calendar/Calendar.js +94 -116
  23. package/lib/calendar/ClickableDate.js +22 -42
  24. package/lib/calendar/Header.js +17 -18
  25. package/lib/calendar/NonClickableDate.js +2 -3
  26. package/lib/datelogic/simplecalendar.js +99 -125
  27. package/lib/datelogic/simpledate.js +67 -96
  28. package/lib/datepicker/Datepicker.js +5 -28
  29. package/lib/datepicker/DatepickerComp.js +74 -77
  30. package/lib/datepicker/DatepickerContext.js +36 -39
  31. package/lib/datepicker/SpinButton.js +10 -34
  32. package/lib/datepicker/padZero.js +2 -2
  33. package/lib/datepicker/testHelper.js +73 -177
  34. package/lib/datepicker/toNumber.js +4 -6
  35. package/lib/i18n/i18n.js +3 -3
  36. package/lib/input/DateInput.js +7 -30
  37. package/lib/types.js +1 -1
  38. package/lib/util/dateRangeUtils.js +14 -14
  39. package/lib/util/dateUtil.js +3 -3
  40. package/lib/util/isIOSSafari.js +4 -4
  41. package/package.json +13 -14
@@ -11,53 +11,52 @@ import { getSimpleDateFromString } from '../datelogic/simpledate';
11
11
  import { ErrorFieldMessage } from '@sb1/ffe-form-react';
12
12
  import i18n from '../i18n/i18n';
13
13
  import { isMonth } from '../types';
14
- export var DatepickerComp = function (_a) {
15
- var ariaInvalidState = _a.ariaInvalid, ariaInvalidProp = _a["aria-invalid"], ariaDescribedbyState = _a.ariaDescribedby, ariaDescribedbyProp = _a["aria-describedby"], onBlur = _a.onBlur, calendarAbove = _a.calendarAbove, id = _a.id, maxDateProp = _a.maxDate, minDateProp = _a.minDate, onChange = _a.onChange, fullWidth = _a.fullWidth, fieldMessage = _a.fieldMessage, labelId = _a.labelId, dropdownCaption = _a.dropdownCaption, disabledDates = _a.disabledDates;
16
- var _b = useContext(DatepickerContext), day = _b.day, setDay = _b.setDay, year = _b.year, setYear = _b.setYear, month = _b.month, setMonth = _b.setMonth, locale = _b.locale, calendarActiveDate = _b.calendarActiveDate, setCalendarActiveDate = _b.setCalendarActiveDate, setLastChangedValue = _b.setLastChangedValue;
17
- var formatDate = useCallback(function () {
14
+ export const DatepickerComp = ({ ariaInvalid: ariaInvalidState, 'aria-invalid': ariaInvalidProp, ariaDescribedby: ariaDescribedbyState, 'aria-describedby': ariaDescribedbyProp, onBlur, calendarAbove, id, maxDate: maxDateProp, minDate: minDateProp, onChange, fullWidth, fieldMessage, labelId, dropdownCaption, disabledDates, }) => {
15
+ const { day, setDay, year, setYear, month, setMonth, locale, calendarActiveDate, setCalendarActiveDate, setLastChangedValue, } = useContext(DatepickerContext);
16
+ const formatDate = useCallback(() => {
18
17
  return getPaddedDateString(day, month, year);
19
18
  }, [day, month, year]);
20
- var _c = useState(false), displayDatePicker = _c[0], setDisplayDatePicker = _c[1];
21
- var _d = useState(minDateProp), minDate = _d[0], setMinDate = _d[1];
22
- var _e = useState(maxDateProp), maxDate = _e[0], setMaxDate = _e[1];
23
- var _f = useState(formatDate()), lastValidDate = _f[0], setLastValidDate = _f[1];
24
- var datepickerId = useId();
25
- var buttonRef = useRef(null);
26
- var dayRef = useRef(null);
27
- var monthRef = useRef(null);
28
- var yearRef = useRef(null);
29
- var getFieldMessageId = function () {
30
- return fieldMessage ? "".concat(datepickerId, "-fieldmessage") : undefined;
19
+ const [displayDatePicker, setDisplayDatePicker] = useState(false);
20
+ const [minDate, setMinDate] = useState(minDateProp);
21
+ const [maxDate, setMaxDate] = useState(maxDateProp);
22
+ const [lastValidDate, setLastValidDate] = useState(formatDate());
23
+ const datepickerId = useId();
24
+ const buttonRef = useRef(null);
25
+ const dayRef = useRef(null);
26
+ const monthRef = useRef(null);
27
+ const yearRef = useRef(null);
28
+ const getFieldMessageId = () => {
29
+ return fieldMessage ? `${datepickerId}-fieldmessage` : undefined;
31
30
  };
32
- var _onChange = useCallback(function (date) {
31
+ const _onChange = useCallback((date) => {
33
32
  setLastChangedValue(date);
34
33
  onChange(date);
35
34
  }, [onChange, setLastChangedValue]);
36
- var fieldMessageId = getFieldMessageId();
35
+ const fieldMessageId = getFieldMessageId();
37
36
  // eslint-disable-next-line react-hooks/exhaustive-deps
38
- var debounceCalendar = useCallback(debounce(function (newValue) {
37
+ const debounceCalendar = useCallback(debounce((newValue) => {
39
38
  if (newValue !== lastValidDate && validateDate(newValue)) {
40
39
  setCalendarActiveDate(newValue);
41
40
  setLastValidDate(newValue);
42
41
  }
43
42
  }, 250), [lastValidDate]);
44
- var hasMessage = !!fieldMessage;
45
- useEffect(function () {
46
- return function () {
43
+ const hasMessage = !!fieldMessage;
44
+ useEffect(() => {
45
+ return () => {
47
46
  debounceCalendar.cancel();
48
47
  };
49
48
  }, [debounceCalendar]);
50
- var validateDateIntervals = useCallback(function () {
51
- var dateString = formatDate();
52
- getSimpleDateFromString(dateString, function (date) {
53
- var maxDateValidated = maxDateProp
49
+ const validateDateIntervals = useCallback(() => {
50
+ const dateString = formatDate();
51
+ getSimpleDateFromString(dateString, date => {
52
+ const maxDateValidated = maxDateProp
54
53
  ? getSimpleDateFromString(maxDateProp)
55
54
  : null;
56
55
  if ((maxDateValidated === null || maxDateValidated === void 0 ? void 0 : maxDateValidated.isBefore(date)) &&
57
56
  isDateInputWithTwoDigitYear(dateString)) {
58
57
  date.adjust({ period: 'Y', offset: -100 });
59
58
  }
60
- var formattedDate = date.format();
59
+ const formattedDate = date.format();
61
60
  if (formattedDate !== dateString) {
62
61
  setDay([date.date]);
63
62
  setMonth([date.month + 1]);
@@ -66,7 +65,7 @@ export var DatepickerComp = function (_a) {
66
65
  setLastValidDate(formattedDate);
67
66
  });
68
67
  }, [formatDate, maxDateProp, setDay, setMonth, setYear]);
69
- useEffect(function () {
68
+ useEffect(() => {
70
69
  if (minDateProp !== minDate || maxDateProp !== maxDate) {
71
70
  setMinDate(minDateProp);
72
71
  setMaxDate(maxDateProp);
@@ -82,43 +81,43 @@ export var DatepickerComp = function (_a) {
82
81
  maxDate,
83
82
  validateDateIntervals,
84
83
  ]);
85
- var closeCalendarSetInputFocus = function () {
84
+ const closeCalendarSetInputFocus = () => {
86
85
  var _a;
87
86
  setDisplayDatePicker(false);
88
87
  (_a = buttonRef.current) === null || _a === void 0 ? void 0 : _a.focus();
89
88
  validateDateIntervals();
90
89
  };
91
- var escKeyHandler = function (evt) {
90
+ const escKeyHandler = (evt) => {
92
91
  if (evt.key === 'Escape') {
93
92
  closeCalendarSetInputFocus();
94
93
  }
95
94
  };
96
- var globalClickHandler = function (evt) {
95
+ const globalClickHandler = (evt) => {
97
96
  if (displayDatePicker && evt.__datepickerID !== datepickerId) {
98
97
  closeCalendarSetInputFocus();
99
98
  }
100
99
  };
101
- var addGlobalEventListeners = function () {
100
+ const addGlobalEventListeners = () => {
102
101
  window.addEventListener('click', globalClickHandler);
103
102
  window.addEventListener('keyup', escKeyHandler);
104
103
  };
105
- var removeGlobalEventListeners = function () {
104
+ const removeGlobalEventListeners = () => {
106
105
  window.removeEventListener('click', globalClickHandler);
107
106
  window.removeEventListener('keyup', escKeyHandler);
108
107
  };
109
- useEffect(function () {
108
+ useEffect(() => {
110
109
  if (displayDatePicker) {
111
110
  addGlobalEventListeners();
112
111
  }
113
112
  else {
114
113
  removeGlobalEventListeners();
115
114
  }
116
- return function () {
115
+ return () => {
117
116
  removeGlobalEventListeners();
118
117
  };
119
118
  // eslint-disable-next-line react-hooks/exhaustive-deps
120
119
  }, [displayDatePicker]);
121
- var calendarButtonClickHandler = function () {
120
+ const calendarButtonClickHandler = () => {
122
121
  validateDateIntervals();
123
122
  setDisplayDatePicker(!displayDatePicker);
124
123
  };
@@ -126,11 +125,11 @@ export var DatepickerComp = function (_a) {
126
125
  * Adds a flag on the click event so that the globalClickHandler()
127
126
  * can determine whether the ID matches. Makes it so that only one datepicker can be open at the same time
128
127
  */
129
- var addFlagOnClickEventClickHandler = function (evt) {
130
- var nativeEvent = evt.nativeEvent;
128
+ const addFlagOnClickEventClickHandler = (evt) => {
129
+ const nativeEvent = evt.nativeEvent;
131
130
  nativeEvent.__datepickerID = datepickerId;
132
131
  };
133
- var focusSpinButton = function (evt) {
132
+ const focusSpinButton = (evt) => {
134
133
  var _a;
135
134
  if (evt.target !== yearRef.current &&
136
135
  evt.target !== buttonRef.current &&
@@ -139,9 +138,9 @@ export var DatepickerComp = function (_a) {
139
138
  (_a = dayRef.current) === null || _a === void 0 ? void 0 : _a.focus();
140
139
  }
141
140
  };
142
- var datePickedHandler = function (date) {
141
+ const datePickedHandler = (date) => {
143
142
  var _a;
144
- var simpleDate = getSimpleDateFromString(date);
143
+ const simpleDate = getSimpleDateFromString(date);
145
144
  if (simpleDate) {
146
145
  setDay([simpleDate.date]);
147
146
  setMonth([simpleDate.month + 1]);
@@ -151,34 +150,34 @@ export var DatepickerComp = function (_a) {
151
150
  (_a = buttonRef.current) === null || _a === void 0 ? void 0 : _a.focus();
152
151
  }
153
152
  };
154
- var ariaInvalid = function () {
155
- var ariaInvalidTotal = ariaInvalidProp === 'true' || ariaInvalidState;
156
- var isAriaInvalid = ariaInvalidTotal === 'true' || ariaInvalidTotal === true
153
+ const ariaInvalid = () => {
154
+ const ariaInvalidTotal = ariaInvalidProp === 'true' || ariaInvalidState;
155
+ const isAriaInvalid = ariaInvalidTotal === 'true' || ariaInvalidTotal === true
157
156
  ? 'true'
158
157
  : undefined;
159
158
  return isAriaInvalid;
160
159
  };
161
- var ariaDescribedby = function () {
162
- var ariaDescribedbyTotal = ariaDescribedbyProp !== null && ariaDescribedbyProp !== void 0 ? ariaDescribedbyProp : ariaDescribedbyState;
160
+ const ariaDescribedby = () => {
161
+ const ariaDescribedbyTotal = ariaDescribedbyProp !== null && ariaDescribedbyProp !== void 0 ? ariaDescribedbyProp : ariaDescribedbyState;
163
162
  return ariaDescribedbyTotal;
164
163
  };
165
- var handlePaste = function (evt) {
164
+ const handlePaste = (evt) => {
166
165
  evt.preventDefault();
167
- var paste = (evt.clipboardData || window.Clipboard).getData('text');
168
- var date = getSimpleDateFromString(paste);
166
+ const paste = (evt.clipboardData || window.Clipboard).getData('text');
167
+ const date = getSimpleDateFromString(paste);
169
168
  if (date) {
170
169
  setDay([date.date]);
171
170
  setMonth([date.month + 1]);
172
171
  setYear([date.year]);
173
172
  }
174
173
  };
175
- var _g = useState(true), init = _g[0], setInit = _g[1];
176
- useEffect(function () {
174
+ const [init, setInit] = useState(true);
175
+ useEffect(() => {
177
176
  if (init) {
178
177
  setInit(false);
179
178
  return;
180
179
  }
181
- var _a = lastValidDate.split('.').map(Number), day = _a[0], month = _a[1], year = _a[2];
180
+ const [day, month, year] = lastValidDate.split('.').map(Number);
182
181
  if (day * month * year > 0) {
183
182
  _onChange(lastValidDate);
184
183
  return;
@@ -191,12 +190,12 @@ export var DatepickerComp = function (_a) {
191
190
  'ffe-datepicker--full-width': fullWidth,
192
191
  'ffe-input-group--message': hasMessage,
193
192
  'ffe-datepicker--invalid': ariaInvalid(),
194
- }), "data-testid": "date-picker", onClick: function (e) {
193
+ }), "data-testid": "date-picker", onClick: e => {
195
194
  addFlagOnClickEventClickHandler(e);
196
195
  focusSpinButton(e);
197
196
  }, role: 'group', id: id },
198
- React.createElement("div", { className: classNames('ffe-dateinput'), onBlur: function (evt) {
199
- var elementReceivingFocus = evt.relatedTarget;
197
+ React.createElement("div", { className: classNames('ffe-dateinput'), onBlur: evt => {
198
+ const elementReceivingFocus = evt.relatedTarget;
200
199
  if (elementReceivingFocus !== yearRef.current &&
201
200
  elementReceivingFocus !== dayRef.current &&
202
201
  elementReceivingFocus !== monthRef.current) {
@@ -204,22 +203,20 @@ export var DatepickerComp = function (_a) {
204
203
  validateDateIntervals();
205
204
  }
206
205
  } },
207
- React.createElement(SpinButton, { ref: dayRef, value: day !== null && day !== void 0 ? day : undefined, min: 1, max: 31, onPaste: handlePaste, onSpinButtonChange: function (newValue, allowFocusNext) {
208
- if (allowFocusNext === void 0) { allowFocusNext = true; }
206
+ React.createElement(SpinButton, { ref: dayRef, value: day !== null && day !== void 0 ? day : undefined, min: 1, max: 31, onPaste: handlePaste, onSpinButtonChange: (newValue, allowFocusNext = true) => {
209
207
  return allowFocusNext
210
- ? setDay(newValue, function () {
208
+ ? setDay(newValue, () => {
211
209
  var _a;
212
210
  return (_a = monthRef.current) === null || _a === void 0 ? void 0 : _a.focus({
213
211
  preventScroll: true,
214
212
  });
215
213
  })
216
214
  : setDay(newValue);
217
- }, nextSpinButton: monthRef, maxLength: 2, "aria-invalid": ariaInvalid(), "aria-valuenow": typeof day === 'number' ? day : undefined, "aria-valuetext": "".concat(day), "aria-label": i18n[locale].DAY, "aria-describedby": ariaDescribedby(), "aria-labelledby": labelId }, day ? padZero(day) : 'dd'),
215
+ }, nextSpinButton: monthRef, maxLength: 2, "aria-invalid": ariaInvalid(), "aria-valuenow": typeof day === 'number' ? day : undefined, "aria-valuetext": `${day}`, "aria-label": i18n[locale].DAY, "aria-describedby": ariaDescribedby(), "aria-labelledby": labelId }, day ? padZero(day) : 'dd'),
218
216
  ".",
219
- React.createElement(SpinButton, { ref: monthRef, value: month !== null && month !== void 0 ? month : undefined, min: 1, max: 12, onPaste: handlePaste, onSpinButtonChange: function (newValue, allowFocusNext) {
220
- if (allowFocusNext === void 0) { allowFocusNext = true; }
217
+ React.createElement(SpinButton, { ref: monthRef, value: month !== null && month !== void 0 ? month : undefined, min: 1, max: 12, onPaste: handlePaste, onSpinButtonChange: (newValue, allowFocusNext = true) => {
221
218
  return allowFocusNext
222
- ? setMonth(newValue, function () {
219
+ ? setMonth(newValue, () => {
223
220
  var _a;
224
221
  return (_a = yearRef.current) === null || _a === void 0 ? void 0 : _a.focus({
225
222
  preventScroll: true,
@@ -227,12 +224,12 @@ export var DatepickerComp = function (_a) {
227
224
  })
228
225
  : setMonth(newValue);
229
226
  }, nextSpinButton: yearRef, prevSpinButton: dayRef, maxLength: 2, "aria-invalid": ariaInvalid(), "aria-valuenow": typeof month === 'number' ? month : undefined, "aria-valuetext": isMonth(month)
230
- ? "".concat(month, " - ").concat(i18n[locale]["MONTH_".concat(month)])
227
+ ? `${month} - ${i18n[locale][`MONTH_${month}`]}`
231
228
  : undefined, "aria-label": i18n[locale].MONTH, "aria-describedby": ariaDescribedby(), "aria-labelledby": labelId }, month ? padZero(month) : 'mm'),
232
229
  ".",
233
- React.createElement(SpinButton, { ref: yearRef, className: 'ffe-dateinput__field-year', value: year !== null && year !== void 0 ? year : undefined, min: 1, max: 9999, onPaste: handlePaste, onSpinButtonChange: function (newValue) {
230
+ React.createElement(SpinButton, { ref: yearRef, className: 'ffe-dateinput__field-year', value: year !== null && year !== void 0 ? year : undefined, min: 1, max: 9999, onPaste: handlePaste, onSpinButtonChange: newValue => {
234
231
  setYear(newValue);
235
- }, prevSpinButton: monthRef, maxLength: 4, "aria-invalid": ariaInvalid(), "aria-valuetext": "".concat(year), "aria-valuenow": typeof year === 'number' ? year : undefined, "aria-label": i18n[locale].YEAR, "aria-describedby": ariaDescribedby(), "aria-labelledby": labelId }, year ? year : 'yyyy')),
232
+ }, prevSpinButton: monthRef, maxLength: 4, "aria-invalid": ariaInvalid(), "aria-valuetext": `${year}`, "aria-valuenow": typeof year === 'number' ? year : undefined, "aria-label": i18n[locale].YEAR, "aria-describedby": ariaDescribedby(), "aria-labelledby": labelId }, year ? year : 'yyyy')),
236
233
  React.createElement(Button, { onClick: calendarButtonClickHandler, locale: locale, value: calendarActiveDate || '', ref: buttonRef }),
237
234
  displayDatePicker && (React.createElement(Calendar, { calendarClassName: classNames('ffe-calendar ffe-calendar--datepicker', { 'ffe-calendar--datepicker--above': calendarAbove }), locale: locale, onDatePicked: datePickedHandler, selectedDate: calendarActiveDate, focusOnMount: true, dropdownCaption: dropdownCaption, minDate: minDate, maxDate: maxDate, disabledDates: disabledDates })),
238
235
  !!fieldMessage && (React.createElement(ErrorFieldMessage, { as: "p", id: fieldMessageId }, fieldMessage))));
@@ -2,30 +2,29 @@ import React, { createContext, useEffect, useState } from 'react';
2
2
  import { getSimpleDateFromString } from '../datelogic/simpledate';
3
3
  import { validateDate } from '../util/dateUtil';
4
4
  import { toNumber } from './toNumber';
5
- export var DatepickerContext = createContext({
5
+ export const DatepickerContext = createContext({
6
6
  day: null,
7
7
  month: null,
8
8
  year: null,
9
- setDay: function () { return null; },
10
- setMonth: function () { return null; },
11
- setYear: function () { return null; },
9
+ setDay: () => null,
10
+ setMonth: () => null,
11
+ setYear: () => null,
12
12
  locale: 'nb',
13
13
  calendarActiveDate: '',
14
- setCalendarActiveDate: function () { return null; },
15
- setLastChangedValue: function () { return null; },
14
+ setCalendarActiveDate: () => null,
15
+ setLastChangedValue: () => null,
16
16
  });
17
- var MONTHS_PER_YEAR = 12;
18
- var MAX_DAYS = 31;
19
- export var DatepickerProvider = function (_a) {
20
- var _b;
21
- var children = _a.children, _c = _a.value, value = _c === void 0 ? '' : _c, locale = _a.locale;
22
- var newDate = validateDate(value) ? getSimpleDateFromString(value) : '';
23
- var _d = useState(newDate ? newDate.date : null), day = _d[0], setDay = _d[1];
24
- var _e = useState(newDate ? newDate.month + 1 : null), month = _e[0], setMonth = _e[1];
25
- var _f = useState(newDate ? newDate.year : null), year = _f[0], setYear = _f[1];
26
- var _g = useState((_b = newDate === null || newDate === void 0 ? void 0 : newDate.toString()) !== null && _b !== void 0 ? _b : ''), calendarActiveDate = _g[0], setCalendarActiveDate = _g[1];
27
- var _h = useState(value !== null && value !== void 0 ? value : ''), lastChangedValue = _h[0], setLastChangedValue = _h[1];
28
- useEffect(function () {
17
+ const MONTHS_PER_YEAR = 12;
18
+ const MAX_DAYS = 31;
19
+ export const DatepickerProvider = ({ children, value = '', locale, }) => {
20
+ var _a;
21
+ const newDate = validateDate(value) ? getSimpleDateFromString(value) : '';
22
+ const [day, setDay] = useState(newDate ? newDate.date : null);
23
+ const [month, setMonth] = useState(newDate ? newDate.month + 1 : null);
24
+ const [year, setYear] = useState(newDate ? newDate.year : null);
25
+ const [calendarActiveDate, setCalendarActiveDate] = useState((_a = newDate === null || newDate === void 0 ? void 0 : newDate.toString()) !== null && _a !== void 0 ? _a : '');
26
+ const [lastChangedValue, setLastChangedValue] = useState(value !== null && value !== void 0 ? value : '');
27
+ useEffect(() => {
29
28
  var _a;
30
29
  if (value !== lastChangedValue) {
31
30
  setDay(newDate ? newDate.date : null);
@@ -36,14 +35,13 @@ export var DatepickerProvider = function (_a) {
36
35
  // eslint-disable-next-line react-hooks/exhaustive-deps
37
36
  }, [value]);
38
37
  return (React.createElement(DatepickerContext.Provider, { value: {
39
- day: day,
40
- month: month,
41
- year: year,
42
- setDay: function (newValue, focusNext) {
43
- if (focusNext === void 0) { focusNext = undefined; }
44
- var numbers = newValue.slice(-2);
45
- var first = numbers[0], second = numbers[1];
46
- var total = toNumber(numbers);
38
+ day,
39
+ month,
40
+ year,
41
+ setDay: (newValue, focusNext = undefined) => {
42
+ const numbers = newValue.slice(-2);
43
+ const [first, second] = numbers;
44
+ const total = toNumber(numbers);
47
45
  if (total > MAX_DAYS) {
48
46
  focusNext === null || focusNext === void 0 ? void 0 : focusNext();
49
47
  }
@@ -58,11 +56,10 @@ export var DatepickerProvider = function (_a) {
58
56
  }
59
57
  }
60
58
  },
61
- setMonth: function (newValue, focusNext) {
62
- if (focusNext === void 0) { focusNext = undefined; }
63
- var numbers = newValue.slice(-2);
64
- var first = numbers[0], second = numbers[1];
65
- var total = toNumber(numbers);
59
+ setMonth: (newValue, focusNext = undefined) => {
60
+ const numbers = newValue.slice(-2);
61
+ const [first, second] = numbers;
62
+ const total = toNumber(numbers);
66
63
  if (total > MONTHS_PER_YEAR) {
67
64
  focusNext === null || focusNext === void 0 ? void 0 : focusNext();
68
65
  }
@@ -77,15 +74,15 @@ export var DatepickerProvider = function (_a) {
77
74
  }
78
75
  }
79
76
  },
80
- setYear: function (newValue) {
77
+ setYear: newValue => {
81
78
  setYear(toNumber(newValue.slice(-4)));
82
79
  },
83
- calendarActiveDate: calendarActiveDate,
84
- setCalendarActiveDate: function (date) {
80
+ calendarActiveDate,
81
+ setCalendarActiveDate: date => {
85
82
  setCalendarActiveDate(date);
86
83
  },
87
- locale: locale,
88
- setLastChangedValue: function (val) {
84
+ locale,
85
+ setLastChangedValue: val => {
89
86
  setLastChangedValue(val);
90
87
  },
91
88
  } }, children));
@@ -1,33 +1,9 @@
1
- var __assign = (this && this.__assign) || function () {
2
- __assign = Object.assign || function(t) {
3
- for (var s, i = 1, n = arguments.length; i < n; i++) {
4
- s = arguments[i];
5
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
6
- t[p] = s[p];
7
- }
8
- return t;
9
- };
10
- return __assign.apply(this, arguments);
11
- };
12
- var __rest = (this && this.__rest) || function (s, e) {
13
- var t = {};
14
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
15
- t[p] = s[p];
16
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
17
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
18
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
19
- t[p[i]] = s[p[i]];
20
- }
21
- return t;
22
- };
23
1
  import React, { useRef } from 'react';
24
2
  import classNames from 'classnames';
25
- export var SpinButton = React.forwardRef(function (_a, ref) {
26
- var className = _a.className, onSpinButtonChange = _a.onSpinButtonChange, maxLength = _a.maxLength, min = _a.min, max = _a.max, value = _a.value, nextSpinButton = _a.nextSpinButton, prevSpinButton = _a.prevSpinButton, children = _a.children, rest = __rest(_a, ["className", "onSpinButtonChange", "maxLength", "min", "max", "value", "nextSpinButton", "prevSpinButton", "children"]);
27
- var history = useRef([]);
28
- var handleKeyDown = function (evt) {
3
+ export const SpinButton = React.forwardRef(({ className, onSpinButtonChange, maxLength, min, max, value, nextSpinButton, prevSpinButton, children, ...rest }, ref) => {
4
+ const history = useRef([]);
5
+ const handleKeyDown = (evt) => {
29
6
  var _a, _b, _c;
30
- evt.stopPropagation();
31
7
  if (/\d/.test(evt.key)) {
32
8
  history.current =
33
9
  history.current.length === maxLength
@@ -41,7 +17,7 @@ export var SpinButton = React.forwardRef(function (_a, ref) {
41
17
  (_a = prevSpinButton === null || prevSpinButton === void 0 ? void 0 : prevSpinButton.current) === null || _a === void 0 ? void 0 : _a.focus();
42
18
  return;
43
19
  }
44
- var newValue = value === null || value === void 0 ? void 0 : value.toString().slice(0, -1);
20
+ const newValue = value === null || value === void 0 ? void 0 : value.toString().slice(0, -1);
45
21
  history.current = newValue
46
22
  ? newValue.split('').map(Number)
47
23
  : [];
@@ -49,7 +25,7 @@ export var SpinButton = React.forwardRef(function (_a, ref) {
49
25
  }
50
26
  else if (evt.key === 'ArrowUp') {
51
27
  evt.preventDefault();
52
- var newValue = (value !== null && value !== void 0 ? value : 0) + 1;
28
+ let newValue = (value !== null && value !== void 0 ? value : 0) + 1;
53
29
  if (newValue && newValue !== null && newValue > max) {
54
30
  newValue = min;
55
31
  }
@@ -57,7 +33,7 @@ export var SpinButton = React.forwardRef(function (_a, ref) {
57
33
  }
58
34
  else if (evt.key === 'ArrowDown') {
59
35
  evt.preventDefault();
60
- var newValue = (value !== null && value !== void 0 ? value : 0) - 1;
36
+ let newValue = (value !== null && value !== void 0 ? value : 0) - 1;
61
37
  if (newValue < min) {
62
38
  newValue = max;
63
39
  }
@@ -72,7 +48,7 @@ export var SpinButton = React.forwardRef(function (_a, ref) {
72
48
  (_c = nextSpinButton === null || nextSpinButton === void 0 ? void 0 : nextSpinButton.current) === null || _c === void 0 ? void 0 : _c.focus();
73
49
  }
74
50
  };
75
- return (React.createElement("span", __assign({ role: 'spinbutton', inputMode: 'numeric', className: classNames(className, 'ffe-dateinput__field'), tabIndex: 0, onFocus: function () {
51
+ return (React.createElement("span", { role: 'spinbutton', inputMode: 'numeric', className: classNames(className, 'ffe-dateinput__field'), tabIndex: 0, onFocus: () => {
76
52
  history.current = [];
77
- }, "aria-valuemin": min, "aria-valuemax": max, "aria-valuenow": value, ref: ref, onKeyDown: handleKeyDown }, rest), children));
53
+ }, "aria-valuemin": min, "aria-valuemax": max, "aria-valuenow": value, ref: ref, onKeyDown: handleKeyDown, ...rest }, children));
78
54
  });
@@ -1,6 +1,6 @@
1
- export var padZero = function (value) {
1
+ export const padZero = (value) => {
2
2
  if (value < 10) {
3
- return "0".concat(value);
3
+ return `0${value}`;
4
4
  }
5
5
  return value;
6
6
  };