@bbl-digital/snorre 3.1.20 → 3.1.22

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,56 +0,0 @@
1
- import React from 'react';
2
- import { MONTHS } from '../../utils/dates';
3
- import { StyledSelect, Div } from './styles';
4
- import { jsx as _jsx } from "react/jsx-runtime";
5
- import { jsxs as _jsxs } from "react/jsx-runtime";
6
-
7
- const YearMonthForm = ({
8
- onChange,
9
- date,
10
- fromDate,
11
- toDate
12
- }) => {
13
- const months = MONTHS;
14
- const years = [];
15
-
16
- for (let i = fromDate.getFullYear(); i <= toDate.getFullYear(); i += 1) {
17
- years.push(i);
18
- }
19
-
20
- const changeMonth = e => {
21
- let newDate = date;
22
- newDate.setMonth(e.target.value);
23
- if (newDate > toDate) newDate = toDate;
24
- onChange(newDate);
25
- };
26
-
27
- const changeYear = e => {
28
- let newDate = date;
29
- newDate.setFullYear(e.target.value);
30
- if (newDate > toDate) newDate = toDate;
31
- onChange(newDate);
32
- };
33
-
34
- return /*#__PURE__*/_jsxs(Div, {
35
- className: "DayPicker-Caption",
36
- children: [/*#__PURE__*/_jsx(StyledSelect, {
37
- name: "month",
38
- onChange: changeMonth,
39
- value: date.getMonth(),
40
- children: months.map((month, i) => /*#__PURE__*/_jsx("option", {
41
- value: i,
42
- children: month
43
- }, month))
44
- }), /*#__PURE__*/_jsx(StyledSelect, {
45
- name: "year",
46
- onChange: changeYear,
47
- value: date.getFullYear(),
48
- children: years.map(year => /*#__PURE__*/_jsx("option", {
49
- value: year,
50
- children: year
51
- }, year))
52
- })]
53
- });
54
- };
55
-
56
- export default YearMonthForm;