linear-react-components-ui 1.1.20-rc.3 → 1.1.20
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/lib/assets/styles/calendar.scss +64 -30
- package/lib/assets/styles/datepicker.scss +26 -6
- package/lib/assets/styles/periodpicker.scss +60 -20
- package/lib/assets/styles/sidenav.scss +1 -1
- package/lib/assets/styles/tabs.scss +32 -15
- package/lib/calendar/DangerCalendar.d.ts +1 -0
- package/lib/calendar/InfoCalendar.d.ts +1 -0
- package/lib/calendar/PrimaryCalendar.d.ts +1 -0
- package/lib/calendar/SuccessCalendar.d.ts +1 -0
- package/lib/calendar/WarningCalendar.d.ts +1 -0
- package/lib/calendar/base/Day.d.ts +1 -0
- package/lib/calendar/base/Day.js +6 -2
- package/lib/calendar/base/Month.d.ts +2 -1
- package/lib/calendar/base/Month.js +2 -0
- package/lib/calendar/base/Week.d.ts +1 -0
- package/lib/calendar/base/index.d.ts +1 -0
- package/lib/calendar/base/index.js +61 -13
- package/lib/calendar/index.d.ts +1 -0
- package/lib/calendar/types.d.ts +5 -0
- package/lib/dialog/base/Content.js +5 -4
- package/lib/dialog/base/Header.js +0 -1
- package/lib/dialog/base/index.js +26 -3
- package/lib/drawer/Drawer.js +1 -1
- package/lib/inputs/date/Dialog.js +5 -4
- package/lib/inputs/date/Dropdown.js +13 -7
- package/lib/inputs/date/helpers.d.ts +1 -11
- package/lib/inputs/date/helpers.js +1 -14
- package/lib/inputs/date/index.js +127 -95
- package/lib/inputs/date/types.d.ts +7 -6
- package/lib/inputs/period/Dialog.d.ts +1 -1
- package/lib/inputs/period/Dialog.js +5 -3
- package/lib/inputs/period/Dropdown.js +16 -8
- package/lib/inputs/period/PeriodList.js +3 -12
- package/lib/inputs/period/index.js +210 -74
- package/lib/inputs/period/types.d.ts +10 -8
- package/lib/inputs/select/ActionButtons.js +3 -2
- package/lib/inputs/select/multiple/index.js +10 -4
- package/lib/inputs/select/simple/index.js +10 -4
- package/lib/inputs/select/types.d.ts +4 -0
- package/lib/inputs/types.d.ts +1 -0
- package/lib/tabs/DropdownTabs.js +21 -7
- package/lib/tabs/context.d.ts +1 -1
- package/lib/tabs/context.js +3 -3
- package/lib/tabs/types.d.ts +2 -1
- package/lib/toolbar/types.d.ts +2 -1
- package/package.json +1 -1
|
@@ -3,28 +3,58 @@
|
|
|
3
3
|
@import "commons.scss";
|
|
4
4
|
|
|
5
5
|
$padding-size: 10px;
|
|
6
|
+
$border-radius-size: 5px;
|
|
6
7
|
.calendar-component {
|
|
7
|
-
|
|
8
|
-
grid-template-rows: 30px 30px 1fr;
|
|
9
|
-
border: 1px solid $component-border-color;
|
|
10
|
-
border-radius: 5px;
|
|
11
|
-
font-size: 12px;
|
|
8
|
+
width: auto;
|
|
12
9
|
height: 100%;
|
|
13
|
-
|
|
10
|
+
min-height: 20rem;
|
|
11
|
+
font-size: 12px;
|
|
12
|
+
display: flex;
|
|
13
|
+
flex-direction: column;
|
|
14
|
+
border-radius: $border-radius-size;
|
|
15
|
+
border: 1px solid $component-border-color;
|
|
14
16
|
> .calendarheader,
|
|
15
17
|
> .daynames {
|
|
16
|
-
|
|
18
|
+
width: auto;
|
|
19
|
+
height: 1.85rem;
|
|
17
20
|
display: grid;
|
|
21
|
+
align-items: center;
|
|
22
|
+
background-color: #f0f0f0;
|
|
18
23
|
grid-template-columns: 20px 1fr 30px;
|
|
19
|
-
padding: $padding-size;
|
|
20
|
-
padding-top: 4px;
|
|
21
24
|
}
|
|
22
25
|
> .calendarheader {
|
|
26
|
+
width: auto;
|
|
27
|
+
height: 32px;
|
|
28
|
+
padding-top: 4px;
|
|
29
|
+
display: flex;
|
|
30
|
+
align-items: center;
|
|
31
|
+
justify-content: space-between;
|
|
32
|
+
border-top-left-radius: $border-radius-size;
|
|
33
|
+
border-top-right-radius: $border-radius-size;
|
|
23
34
|
> .navbutton {
|
|
35
|
+
width: 2rem;
|
|
36
|
+
height: 2rem;
|
|
37
|
+
padding: 0;
|
|
38
|
+
margin: 0px 2px;
|
|
39
|
+
display: flex;
|
|
40
|
+
align-items: center;
|
|
41
|
+
justify-content: center;
|
|
24
42
|
background-color: transparent;
|
|
25
43
|
font-weight: bold;
|
|
26
|
-
padding: 0;
|
|
27
44
|
border: none;
|
|
45
|
+
svg {
|
|
46
|
+
margin: 0;
|
|
47
|
+
}
|
|
48
|
+
&:hover {
|
|
49
|
+
background-color: $component-border-color;
|
|
50
|
+
}
|
|
51
|
+
&:focus {
|
|
52
|
+
-webkit-box-shadow: none !important;
|
|
53
|
+
box-shadow: none !important;
|
|
54
|
+
border: 1px solid $default-border-color;
|
|
55
|
+
background-color: $component-border-color;
|
|
56
|
+
}
|
|
57
|
+
transition: none;
|
|
28
58
|
}
|
|
29
59
|
> .monthname {
|
|
30
60
|
font-weight: bold;
|
|
@@ -35,16 +65,21 @@ $padding-size: 10px;
|
|
|
35
65
|
}
|
|
36
66
|
}
|
|
37
67
|
> .daynames {
|
|
68
|
+
padding-top: 4px;
|
|
38
69
|
border-bottom: 1px solid $component-border-color;
|
|
39
70
|
grid-template-columns: repeat(7, 1fr);
|
|
40
71
|
text-align: center;
|
|
41
|
-
padding-top: 9px;
|
|
42
72
|
}
|
|
43
73
|
> .calendarmonth {
|
|
44
|
-
|
|
74
|
+
width: 100%;
|
|
75
|
+
height: 100%;
|
|
76
|
+
flex: 1;
|
|
45
77
|
display: grid;
|
|
46
78
|
grid-template-rows: repeat(6, 1fr);
|
|
47
|
-
padding:
|
|
79
|
+
padding: 2px;
|
|
80
|
+
background-color: $font-color-second;
|
|
81
|
+
border-bottom-left-radius: $border-radius-size;
|
|
82
|
+
border-bottom-right-radius: $border-radius-size;
|
|
48
83
|
}
|
|
49
84
|
> .calendarmonth > .monthweek {
|
|
50
85
|
text-align: center;
|
|
@@ -52,16 +87,31 @@ $padding-size: 10px;
|
|
|
52
87
|
grid-template-columns: repeat(7, 1fr)
|
|
53
88
|
}
|
|
54
89
|
.calendarmonth > .monthweek > .monthday {
|
|
55
|
-
|
|
90
|
+
height: auto;
|
|
91
|
+
width: auto;
|
|
56
92
|
text-align: center;
|
|
57
93
|
border-right: 0;
|
|
58
94
|
border-bottom: 0;
|
|
59
95
|
transition: all 0.2s ease-in-out;
|
|
60
96
|
> .daybutton {
|
|
97
|
+
height: 100%;
|
|
98
|
+
width: 100%;
|
|
99
|
+
padding: 0;
|
|
100
|
+
font-size: 13px;
|
|
101
|
+
border: none;
|
|
102
|
+
background-color: transparent;
|
|
103
|
+
&.-nowday {
|
|
104
|
+
font-weight: bold
|
|
105
|
+
}
|
|
106
|
+
&.-outmonth {
|
|
107
|
+
color: #777;
|
|
108
|
+
}
|
|
61
109
|
&:focus {
|
|
62
110
|
-webkit-box-shadow: none !important;
|
|
63
111
|
box-shadow: none !important;
|
|
112
|
+
border: 2px solid $default-border-color;
|
|
64
113
|
}
|
|
114
|
+
transition: none;
|
|
65
115
|
}
|
|
66
116
|
&:hover {
|
|
67
117
|
background-color: $component-border-color;
|
|
@@ -74,19 +124,6 @@ $padding-size: 10px;
|
|
|
74
124
|
&.-selectedday > .daybutton {
|
|
75
125
|
color: $font-color-second;
|
|
76
126
|
}
|
|
77
|
-
> .daybutton {
|
|
78
|
-
background-color: transparent;
|
|
79
|
-
height: 100%;
|
|
80
|
-
padding: 0;
|
|
81
|
-
width: 100%;
|
|
82
|
-
font-size: 13px;
|
|
83
|
-
&.-nowday {
|
|
84
|
-
font-weight: bold
|
|
85
|
-
}
|
|
86
|
-
&.-outmonth {
|
|
87
|
-
color: #777;
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
127
|
}
|
|
91
128
|
}
|
|
92
129
|
|
|
@@ -167,6 +204,3 @@ $padding-size: 10px;
|
|
|
167
204
|
}
|
|
168
205
|
}
|
|
169
206
|
|
|
170
|
-
.numberdaycalendar {
|
|
171
|
-
border: none!important;
|
|
172
|
-
}
|
|
@@ -1,16 +1,36 @@
|
|
|
1
1
|
@import "commons.scss";
|
|
2
2
|
@import "effects.scss";
|
|
3
3
|
|
|
4
|
+
.datepicker-container {
|
|
5
|
+
position: relative;
|
|
6
|
+
transition: none;
|
|
7
|
+
}
|
|
8
|
+
|
|
4
9
|
.datepicker-component {
|
|
5
10
|
@extend %component-box-shadow;
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
11
|
+
z-index: 999999999999;
|
|
12
|
+
margin-top: 4px;
|
|
13
|
+
position: fixed;
|
|
9
14
|
animation: 0.5s ease-in 0s 1 slideDown;
|
|
15
|
+
transition: none;
|
|
10
16
|
}
|
|
11
17
|
|
|
12
18
|
.calendar-button {
|
|
13
19
|
width: 26px;
|
|
14
|
-
|
|
15
|
-
border:
|
|
16
|
-
|
|
20
|
+
border-radius: 0;
|
|
21
|
+
border: 0 !important;
|
|
22
|
+
display: flex;
|
|
23
|
+
align-items: center;
|
|
24
|
+
box-shadow: none !important;
|
|
25
|
+
justify-content: center;
|
|
26
|
+
padding: 0 !important;
|
|
27
|
+
|
|
28
|
+
svg {
|
|
29
|
+
margin: 0 !important;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
>.icon-component {
|
|
33
|
+
width: 16px !important;
|
|
34
|
+
height: 16px !important;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
@@ -1,12 +1,18 @@
|
|
|
1
1
|
@import "commons.scss";
|
|
2
2
|
@import "effects.scss";
|
|
3
|
+
@import "colors.scss";
|
|
4
|
+
|
|
5
|
+
.datepicker-period-container {
|
|
6
|
+
position: relative;
|
|
7
|
+
transition: none;
|
|
8
|
+
}
|
|
3
9
|
|
|
4
10
|
.periodpicker-component {
|
|
5
11
|
height: auto;
|
|
6
12
|
position: relative;
|
|
7
13
|
display: flex;
|
|
8
14
|
border-radius: 2px;
|
|
9
|
-
border: 1px solid
|
|
15
|
+
border: 1px solid $component-border-color;
|
|
10
16
|
|
|
11
17
|
.inputwrapper {
|
|
12
18
|
border: none;
|
|
@@ -18,31 +24,79 @@
|
|
|
18
24
|
}
|
|
19
25
|
|
|
20
26
|
.calendar-button {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
border:
|
|
27
|
+
width: 26px;
|
|
28
|
+
border-radius: 0;
|
|
29
|
+
border: 0 !important;
|
|
30
|
+
display: flex;
|
|
31
|
+
align-items: center;
|
|
32
|
+
box-shadow: none !important;
|
|
33
|
+
justify-content: center;
|
|
34
|
+
padding: 0 !important;
|
|
35
|
+
|
|
36
|
+
svg {
|
|
37
|
+
margin: 0 !important;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
>.icon-component {
|
|
41
|
+
width: 16px !important;
|
|
42
|
+
height: 16px !important;
|
|
43
|
+
}
|
|
24
44
|
}
|
|
25
45
|
|
|
26
46
|
.input-base-component {
|
|
27
47
|
flex: 1;
|
|
28
48
|
}
|
|
49
|
+
}
|
|
29
50
|
|
|
51
|
+
.datepicker-component {
|
|
52
|
+
@extend %component-box-shadow;
|
|
53
|
+
border-radius: 5px;
|
|
54
|
+
margin-top: 4px !important;
|
|
55
|
+
position: fixed;
|
|
56
|
+
animation: 0.5s ease-in 0s 1 slideDown;
|
|
57
|
+
transition: none;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
.dropdown-period {
|
|
61
|
+
width: 100%;
|
|
62
|
+
border-radius: 3px;
|
|
63
|
+
background-color: $component-bg-default;
|
|
64
|
+
border: 1px solid $component-border-color;
|
|
65
|
+
display: grid;
|
|
66
|
+
grid-template-rows: auto;
|
|
67
|
+
height: auto;
|
|
68
|
+
overflow-y: auto;
|
|
69
|
+
overflow-x: hidden;
|
|
30
70
|
}
|
|
31
71
|
|
|
32
72
|
.dropdown-period>.item {
|
|
73
|
+
all: unset;
|
|
33
74
|
margin: 0;
|
|
34
75
|
padding: 6px 10px;
|
|
35
76
|
display: flex;
|
|
36
77
|
cursor: pointer;
|
|
37
78
|
justify-content: stretch;
|
|
38
|
-
|
|
79
|
+
|
|
80
|
+
&:not(:last-child) {
|
|
81
|
+
border-bottom: solid 1px $separator-background;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
&:first-child {
|
|
85
|
+
border-top-left-radius: 3px;
|
|
86
|
+
border-top-right-radius: 3px;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
&:last-child {
|
|
90
|
+
border-bottom-left-radius: 3px;
|
|
91
|
+
border-bottom-right-radius: 3px;
|
|
92
|
+
}
|
|
39
93
|
|
|
40
94
|
&:hover {
|
|
41
95
|
background-color: $default-hover-color;
|
|
42
96
|
}
|
|
43
97
|
|
|
44
98
|
&.-selected {
|
|
45
|
-
background-color: $
|
|
99
|
+
background-color: $component-bg-selected-color;
|
|
46
100
|
}
|
|
47
101
|
|
|
48
102
|
&.-disabled {
|
|
@@ -53,17 +107,3 @@
|
|
|
53
107
|
}
|
|
54
108
|
}
|
|
55
109
|
}
|
|
56
|
-
|
|
57
|
-
.dropdown-period {
|
|
58
|
-
width: 100%;
|
|
59
|
-
/* animation: 0.5s ease-in 0s 1 slideDown; */
|
|
60
|
-
background-color: #FFF;
|
|
61
|
-
border: #dae1e8;
|
|
62
|
-
display: grid;
|
|
63
|
-
grid-template-rows: auto;
|
|
64
|
-
height: auto;
|
|
65
|
-
overflow-y: auto;
|
|
66
|
-
overflow-x: hidden;
|
|
67
|
-
/* margin-top: 2px; */
|
|
68
|
-
z-index: 99999999999;
|
|
69
|
-
}
|
|
@@ -54,7 +54,6 @@ $dropdown-width: 38px;
|
|
|
54
54
|
width: auto;
|
|
55
55
|
min-width: 100px;
|
|
56
56
|
display: flex;
|
|
57
|
-
justify-content: space-between;
|
|
58
57
|
align-items: center;
|
|
59
58
|
&.selected {
|
|
60
59
|
border: 1px solid $component-border-color;
|
|
@@ -113,11 +112,17 @@ $dropdown-width: 38px;
|
|
|
113
112
|
visibility: hidden;
|
|
114
113
|
pointer-events: none;
|
|
115
114
|
opacity: 0;
|
|
115
|
+
display: flex;
|
|
116
|
+
align-items: center;
|
|
117
|
+
justify-content: center;
|
|
116
118
|
&.show {
|
|
117
119
|
visibility: visible;
|
|
118
120
|
pointer-events: all;
|
|
119
121
|
opacity: 1;
|
|
120
122
|
}
|
|
123
|
+
&.has-selected {
|
|
124
|
+
border: 1px solid $component-selected-color !important;
|
|
125
|
+
}
|
|
121
126
|
> svg {
|
|
122
127
|
margin: 0;
|
|
123
128
|
float: none;
|
|
@@ -247,20 +252,32 @@ $dropdown-width: 38px;
|
|
|
247
252
|
/*
|
|
248
253
|
Dropdown hide tabs
|
|
249
254
|
*/
|
|
250
|
-
.dropdown-hide-tabs
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
display: flex;
|
|
255
|
-
align-items: center;
|
|
256
|
-
justify-content: space-between;
|
|
257
|
-
min-height: 50px;
|
|
258
|
-
|
|
259
|
-
>.closepanel {
|
|
260
|
-
@extend %tab-closepanel;
|
|
255
|
+
.dropdown-hide-tabs {
|
|
256
|
+
.item-container > .item {
|
|
257
|
+
width: auto;
|
|
258
|
+
padding-left: 10px;
|
|
261
259
|
}
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
260
|
+
.menuitem {
|
|
261
|
+
cursor: pointer;
|
|
262
|
+
line-height: 20px;
|
|
263
|
+
margin-right: 1px;
|
|
264
|
+
display: flex;
|
|
265
|
+
align-items: center;
|
|
266
|
+
min-height: 50px;
|
|
267
|
+
gap: 8px;
|
|
268
|
+
> svg {
|
|
269
|
+
margin: 0;
|
|
270
|
+
}
|
|
271
|
+
> .menubutton {
|
|
272
|
+
padding: 0;
|
|
273
|
+
}
|
|
274
|
+
>.closepanel {
|
|
275
|
+
@extend %tab-closepanel;
|
|
276
|
+
margin-left: auto;
|
|
277
|
+
margin-right: 0;
|
|
278
|
+
}
|
|
279
|
+
&:hover>.closepanel {
|
|
280
|
+
visibility: visible;
|
|
281
|
+
}
|
|
265
282
|
}
|
|
266
283
|
}
|
package/lib/calendar/base/Day.js
CHANGED
|
@@ -5,6 +5,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
7
|
var _react = _interopRequireWildcard(require("react"));
|
|
8
|
+
var _uuid = require("uuid");
|
|
8
9
|
var _helpers = require("./helpers");
|
|
9
10
|
var _buttons = _interopRequireDefault(require("../../buttons"));
|
|
10
11
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
@@ -21,12 +22,15 @@ const Day = _ref => {
|
|
|
21
22
|
return /*#__PURE__*/_react.default.createElement("div", {
|
|
22
23
|
className: (0, _helpers.getDayContainerCssClass)(currentDate, day)
|
|
23
24
|
}, /*#__PURE__*/_react.default.createElement(_buttons.default, {
|
|
25
|
+
id: (0, _uuid.v1)(),
|
|
26
|
+
type: "button",
|
|
27
|
+
tabIndex: (0, _helpers.dateIsEquals)(currentDate, day) ? 0 : -1,
|
|
24
28
|
boxShadow: false,
|
|
29
|
+
label: day.format('D'),
|
|
25
30
|
onClick: () => {
|
|
26
31
|
if (handleDateChange) handleDateChange(day);
|
|
27
32
|
},
|
|
28
|
-
customClass: ` ${(0, _helpers.getDayCssClass)(currentDate, day)} numberdaycalendar
|
|
29
|
-
label: day.format('D')
|
|
33
|
+
customClass: ` ${(0, _helpers.getDayCssClass)(currentDate, day)} numberdaycalendar`
|
|
30
34
|
}));
|
|
31
35
|
};
|
|
32
36
|
var _default = exports.default = Day;
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { IMonthProps } from '../types.js';
|
|
2
|
+
import 'react';
|
|
2
3
|
import 'moment';
|
|
3
4
|
import '../../@types/ColorStyles.js';
|
|
4
5
|
|
|
5
|
-
declare const Month: ({ currentDate }: IMonthProps) => JSX.Element;
|
|
6
|
+
declare const Month: ({ monthRef, currentDate }: IMonthProps) => JSX.Element;
|
|
6
7
|
|
|
7
8
|
export { Month as default };
|
|
@@ -10,6 +10,7 @@ var _helpers = require("./helpers");
|
|
|
10
10
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
11
11
|
const Month = _ref => {
|
|
12
12
|
let {
|
|
13
|
+
monthRef,
|
|
13
14
|
currentDate
|
|
14
15
|
} = _ref;
|
|
15
16
|
const renderWeeks = () => {
|
|
@@ -31,6 +32,7 @@ const Month = _ref => {
|
|
|
31
32
|
return weeks;
|
|
32
33
|
};
|
|
33
34
|
return /*#__PURE__*/_react.default.createElement("div", {
|
|
35
|
+
ref: monthRef,
|
|
34
36
|
className: "calendarmonth"
|
|
35
37
|
}, renderWeeks());
|
|
36
38
|
};
|
|
@@ -5,14 +5,17 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
7
|
var _react = _interopRequireWildcard(require("react"));
|
|
8
|
+
var _uuid = require("uuid");
|
|
8
9
|
var _moment = _interopRequireDefault(require("moment"));
|
|
9
10
|
var _Month = _interopRequireDefault(require("./Month"));
|
|
10
11
|
var _buttons = _interopRequireDefault(require("../../buttons"));
|
|
12
|
+
var _gridlayout = _interopRequireDefault(require("../../gridlayout"));
|
|
11
13
|
var _helpers = require("./helpers");
|
|
12
14
|
require("../../assets/styles/calendar.scss");
|
|
13
15
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
14
16
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
15
17
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
18
|
+
const arrowKeys = ['ArrowUp', 'ArrowRight', 'ArrowDown', 'ArrowLeft'];
|
|
16
19
|
const Calendar = props => {
|
|
17
20
|
const {
|
|
18
21
|
currentDate = (0, _moment.default)(),
|
|
@@ -20,12 +23,14 @@ const Calendar = props => {
|
|
|
20
23
|
drawGridLines = false,
|
|
21
24
|
colorStyle,
|
|
22
25
|
unpadding = false,
|
|
23
|
-
customClass
|
|
26
|
+
customClass,
|
|
27
|
+
gridLayout,
|
|
28
|
+
currentDateButton,
|
|
29
|
+
calendarContainer
|
|
24
30
|
} = props;
|
|
31
|
+
const currentMonth = (0, _react.useRef)(null);
|
|
32
|
+
const currentCalendarRef = (0, _react.useRef)(null);
|
|
25
33
|
const [dataAtual, setDataAtual] = (0, _react.useState)((0, _helpers.validDate)(currentDate));
|
|
26
|
-
(0, _react.useEffect)(() => {
|
|
27
|
-
setDataAtual((0, _helpers.validDate)(currentDate));
|
|
28
|
-
}, []);
|
|
29
34
|
const onDateChangeFunction = date => {
|
|
30
35
|
if (onDateChange) onDateChange(date);
|
|
31
36
|
setDataAtual(date);
|
|
@@ -38,12 +43,46 @@ const Calendar = props => {
|
|
|
38
43
|
const currentDateClone = dataAtual.clone();
|
|
39
44
|
setDataAtual(currentDateClone.add(1, 'month'));
|
|
40
45
|
};
|
|
46
|
+
const navigateWithArrows = event => {
|
|
47
|
+
const sourceTarget = event.target;
|
|
48
|
+
const daysOfMonth = currentMonth.current?.getElementsByClassName('daybutton');
|
|
49
|
+
let indexCurrentDay = 0;
|
|
50
|
+
if (daysOfMonth.length) {
|
|
51
|
+
Array.from(daysOfMonth).find((dayButton, index) => {
|
|
52
|
+
if (dayButton && dayButton.id === sourceTarget.id) indexCurrentDay = index;
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
const element = {
|
|
56
|
+
ArrowUp: daysOfMonth[indexCurrentDay - 7],
|
|
57
|
+
ArrowRight: daysOfMonth[indexCurrentDay + 1],
|
|
58
|
+
ArrowDown: daysOfMonth[indexCurrentDay + 7],
|
|
59
|
+
ArrowLeft: daysOfMonth[indexCurrentDay - 1]
|
|
60
|
+
}[event.code];
|
|
61
|
+
if (element) element.focus();
|
|
62
|
+
};
|
|
41
63
|
const contextValues = {
|
|
42
64
|
handleDateChange: onDateChangeFunction
|
|
43
65
|
};
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
66
|
+
(0, _react.useEffect)(() => {
|
|
67
|
+
calendarContainer?.(currentCalendarRef?.current);
|
|
68
|
+
setDataAtual((0, _helpers.validDate)(currentDate));
|
|
69
|
+
document.addEventListener('keydown', event => {
|
|
70
|
+
if (event && event.code && arrowKeys.includes(event.code) && currentCalendarRef.current && currentCalendarRef.current.contains(document.activeElement) && currentMonth.current && currentMonth.current.contains(document.activeElement)) {
|
|
71
|
+
navigateWithArrows(event);
|
|
72
|
+
event.stopPropagation();
|
|
73
|
+
event.preventDefault();
|
|
74
|
+
}
|
|
75
|
+
});
|
|
76
|
+
return () => {
|
|
77
|
+
document.removeEventListener('keydown', () => {});
|
|
78
|
+
};
|
|
79
|
+
}, []);
|
|
80
|
+
(0, _react.useEffect)(() => {
|
|
81
|
+
const daysOfMonth = currentMonth.current?.getElementsByClassName('-selectedday')[0];
|
|
82
|
+
currentDateButton?.(daysOfMonth.firstChild);
|
|
83
|
+
}, [currentDate]);
|
|
84
|
+
const component = /*#__PURE__*/_react.default.createElement("div", {
|
|
85
|
+
ref: currentCalendarRef,
|
|
47
86
|
className: (0, _helpers.getCalendarCssClass)({
|
|
48
87
|
unpadding,
|
|
49
88
|
drawGridLines,
|
|
@@ -53,27 +92,36 @@ const Calendar = props => {
|
|
|
53
92
|
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
54
93
|
className: "calendarheader"
|
|
55
94
|
}, /*#__PURE__*/_react.default.createElement(_buttons.default, {
|
|
56
|
-
|
|
95
|
+
id: (0, _uuid.v1)(),
|
|
57
96
|
boxShadow: false,
|
|
97
|
+
iconName: "arrow_left",
|
|
98
|
+
customClass: "navbutton nav-arrow-left",
|
|
58
99
|
onClick: () => {
|
|
59
100
|
previousMonth();
|
|
60
|
-
}
|
|
61
|
-
customClass: "navbutton"
|
|
101
|
+
}
|
|
62
102
|
}), /*#__PURE__*/_react.default.createElement("span", {
|
|
63
103
|
className: "monthname"
|
|
64
104
|
}, dataAtual.format('MMMM YYYY')), /*#__PURE__*/_react.default.createElement(_buttons.default, {
|
|
105
|
+
id: (0, _uuid.v1)(),
|
|
65
106
|
boxShadow: false,
|
|
66
107
|
iconName: "arrow_right",
|
|
108
|
+
customClass: "navbutton nav-arrow-right",
|
|
67
109
|
onClick: () => {
|
|
68
110
|
nextMonth();
|
|
69
|
-
}
|
|
70
|
-
customClass: "navbutton"
|
|
111
|
+
}
|
|
71
112
|
})), /*#__PURE__*/_react.default.createElement("div", {
|
|
72
113
|
className: "daynames"
|
|
73
114
|
}, (0, _helpers.dayNames)().map(name => /*#__PURE__*/_react.default.createElement("div", {
|
|
74
115
|
key: `day-${name}`
|
|
75
116
|
}, name))), /*#__PURE__*/_react.default.createElement(_Month.default, {
|
|
117
|
+
monthRef: currentMonth,
|
|
76
118
|
currentDate: dataAtual
|
|
77
|
-
}))
|
|
119
|
+
}));
|
|
120
|
+
return /*#__PURE__*/_react.default.createElement(_helpers.CalendarContext.Provider, {
|
|
121
|
+
value: contextValues
|
|
122
|
+
}, !gridLayout ? component : /*#__PURE__*/_react.default.createElement(_gridlayout.default, {
|
|
123
|
+
customClass: "-withinput",
|
|
124
|
+
cols: gridLayout
|
|
125
|
+
}, component));
|
|
78
126
|
};
|
|
79
127
|
var _default = exports.default = Calendar;
|
package/lib/calendar/index.d.ts
CHANGED
|
@@ -5,6 +5,7 @@ export { default as DangerCalendar } from './DangerCalendar.js';
|
|
|
5
5
|
export { default as WarningCalendar } from './WarningCalendar.js';
|
|
6
6
|
export { default as InfoCalendar } from './InfoCalendar.js';
|
|
7
7
|
import './types.js';
|
|
8
|
+
import 'react';
|
|
8
9
|
import 'moment';
|
|
9
10
|
import '../@types/ColorStyles.js';
|
|
10
11
|
|
package/lib/calendar/types.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { LegacyRef } from 'react';
|
|
1
2
|
import { Moment } from 'moment';
|
|
2
3
|
import { ColorStyles } from '../@types/ColorStyles.js';
|
|
3
4
|
|
|
@@ -9,6 +10,9 @@ interface ICalendarProps {
|
|
|
9
10
|
onDateChange?: (date: Moment) => void;
|
|
10
11
|
colorStyle?: ColorStyles;
|
|
11
12
|
handleDateChange?: (date: Moment) => void;
|
|
13
|
+
gridLayout?: string;
|
|
14
|
+
currentDateButton?: (buttonElement: HTMLButtonElement) => void;
|
|
15
|
+
calendarContainer?: (calendarElement: HTMLDivElement | null) => void;
|
|
12
16
|
}
|
|
13
17
|
interface IWeekProps {
|
|
14
18
|
weekStartDate: Moment;
|
|
@@ -19,6 +23,7 @@ interface IDayProps {
|
|
|
19
23
|
day: Moment;
|
|
20
24
|
}
|
|
21
25
|
interface IMonthProps {
|
|
26
|
+
monthRef: LegacyRef<HTMLDivElement> | undefined;
|
|
22
27
|
currentDate: Moment;
|
|
23
28
|
}
|
|
24
29
|
|