linear-react-components-ui 1.1.24-beta.8 → 1.1.24-beta.9
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/button.scss +1 -1
- package/lib/assets/styles/calendar.scss +137 -32
- package/lib/assets/styles/fieldset.scss +1 -1
- package/lib/assets/styles/file.scss +8 -0
- package/lib/assets/styles/multiSelect.scss +6 -6
- package/lib/assets/styles/table.scss +6 -0
- package/lib/assets/styles/tabs.scss +6 -2
- package/lib/buttons/DefaultButton.js +1 -1
- package/lib/calendar/base/index.js +113 -40
- package/lib/dialog/base/Content.js +4 -5
- package/lib/dialog/base/index.js +15 -16
- package/lib/drawer/Drawer.js +1 -1
- package/lib/form2/index.d.ts +1 -1
- package/lib/index-19761a50.d.ts +26 -0
- package/lib/index-35ba9ed8.d.ts +15 -0
- package/lib/index-efe0a0e4.d.ts +41 -0
- package/lib/inputs/base/types.d.ts +1 -1
- package/lib/inputs/color/index.js +1 -1
- package/lib/inputs/file/DefaultFile.js +26 -26
- package/lib/inputs/file/File.js +1 -0
- package/lib/inputs/file/FileButtonSettings.js +0 -1
- package/lib/inputs/multiSelect/Dropdown.js +1 -1
- package/lib/inputs/multiSelect/index.js +17 -2
- package/lib/inputs/period/index.js +10 -8
- package/lib/inputs/period/types.d.ts +4 -1
- package/lib/inputs/search/index.js +6 -2
- package/lib/inputs/types.d.ts +1 -0
- package/lib/inputs2/checkboxfield/index.d.ts +1 -1
- package/lib/inputs2/date/datefield/calendarbox.d.ts +1 -1
- package/lib/inputs2/date/dateperiodfield/calendarbox.d.ts +1 -1
- package/lib/inputs2/index.d.ts +3 -3
- package/lib/inputs2/radiofield/index.d.ts +1 -1
- package/lib/inputs2/selectfield/index.d.ts +1 -1
- package/lib/inputs2/selectfield/item.d.ts +1 -1
- package/lib/inputs2/selectfield/listbox.d.ts +1 -1
- package/lib/inputs2/selectfield/options.d.ts +1 -1
- package/lib/inputs2/selectfield/search.d.ts +1 -1
- package/lib/inputs2/selectfield/selections.d.ts +1 -1
- package/lib/inputs2/slot/index.d.ts +2 -2
- package/lib/table/index.js +18 -8
- package/lib/table/types.d.ts +1 -0
- package/lib/tabs/index.js +2 -2
- package/package.json +1 -1
- package/lib/calendar/base/Day.d.ts +0 -8
- package/lib/calendar/base/Day.js +0 -36
- package/lib/calendar/base/Month.d.ts +0 -8
- package/lib/calendar/base/Month.js +0 -39
- package/lib/calendar/base/Week.d.ts +0 -8
- package/lib/calendar/base/Week.js +0 -35
- package/lib/index-118afd58.d.ts +0 -26
- package/lib/index-8f540f57.d.ts +0 -41
- package/lib/index-b2ef36a6.d.ts +0 -15
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
|
|
2
1
|
@import "colors.scss";
|
|
3
2
|
@import "commons.scss";
|
|
4
3
|
|
|
5
4
|
$padding-size: 10px;
|
|
6
5
|
$border-radius-size: 5px;
|
|
6
|
+
|
|
7
7
|
.calendar-component {
|
|
8
8
|
width: auto;
|
|
9
9
|
height: 100%;
|
|
@@ -13,8 +13,9 @@ $border-radius-size: 5px;
|
|
|
13
13
|
flex-direction: column;
|
|
14
14
|
border-radius: $border-radius-size;
|
|
15
15
|
border: 1px solid $component-border-color;
|
|
16
|
-
|
|
17
|
-
|
|
16
|
+
|
|
17
|
+
>.calendarheader,
|
|
18
|
+
>.daynames {
|
|
18
19
|
width: auto;
|
|
19
20
|
height: 1.85rem;
|
|
20
21
|
display: grid;
|
|
@@ -22,7 +23,8 @@ $border-radius-size: 5px;
|
|
|
22
23
|
background-color: #f0f0f0;
|
|
23
24
|
grid-template-columns: 20px 1fr 30px;
|
|
24
25
|
}
|
|
25
|
-
|
|
26
|
+
|
|
27
|
+
>.calendarheader {
|
|
26
28
|
width: auto;
|
|
27
29
|
height: 32px;
|
|
28
30
|
padding-top: 4px;
|
|
@@ -31,7 +33,8 @@ $border-radius-size: 5px;
|
|
|
31
33
|
justify-content: space-between;
|
|
32
34
|
border-top-left-radius: $border-radius-size;
|
|
33
35
|
border-top-right-radius: $border-radius-size;
|
|
34
|
-
|
|
36
|
+
|
|
37
|
+
>.navbutton {
|
|
35
38
|
width: 2rem;
|
|
36
39
|
height: 2rem;
|
|
37
40
|
padding: 0;
|
|
@@ -42,21 +45,26 @@ $border-radius-size: 5px;
|
|
|
42
45
|
background-color: transparent;
|
|
43
46
|
font-weight: bold;
|
|
44
47
|
border: none;
|
|
48
|
+
|
|
45
49
|
svg {
|
|
46
50
|
margin: 0;
|
|
47
51
|
}
|
|
52
|
+
|
|
48
53
|
&:hover {
|
|
49
54
|
background-color: $component-border-color;
|
|
50
55
|
}
|
|
56
|
+
|
|
51
57
|
&:focus {
|
|
52
58
|
-webkit-box-shadow: none !important;
|
|
53
59
|
box-shadow: none !important;
|
|
54
60
|
border: 1px solid $default-border-color;
|
|
55
61
|
background-color: $component-border-color;
|
|
56
62
|
}
|
|
63
|
+
|
|
57
64
|
transition: none;
|
|
58
65
|
}
|
|
59
|
-
|
|
66
|
+
|
|
67
|
+
>.monthname {
|
|
60
68
|
font-weight: bold;
|
|
61
69
|
vertical-align: middle;
|
|
62
70
|
text-align: center;
|
|
@@ -64,117 +72,209 @@ $border-radius-size: 5px;
|
|
|
64
72
|
font-size: 14px;
|
|
65
73
|
}
|
|
66
74
|
}
|
|
67
|
-
|
|
75
|
+
|
|
76
|
+
>.daynames {
|
|
68
77
|
padding-top: 4px;
|
|
69
78
|
border-bottom: 1px solid $component-border-color;
|
|
70
79
|
grid-template-columns: repeat(7, 1fr);
|
|
71
80
|
text-align: center;
|
|
72
81
|
}
|
|
73
|
-
|
|
82
|
+
|
|
83
|
+
>.calendarmonth {
|
|
74
84
|
width: 100%;
|
|
75
85
|
height: 100%;
|
|
76
86
|
flex: 1;
|
|
77
87
|
display: grid;
|
|
78
|
-
grid-template-rows: repeat(6, 1fr);
|
|
79
88
|
padding: 2px;
|
|
80
89
|
background-color: $font-color-second;
|
|
81
90
|
border-bottom-left-radius: $border-radius-size;
|
|
82
91
|
border-bottom-right-radius: $border-radius-size;
|
|
83
92
|
}
|
|
84
|
-
|
|
93
|
+
|
|
94
|
+
>.calendarmonth>.monthweek {
|
|
85
95
|
text-align: center;
|
|
86
96
|
display: grid;
|
|
87
97
|
grid-template-columns: repeat(7, 1fr)
|
|
88
98
|
}
|
|
89
|
-
|
|
99
|
+
|
|
100
|
+
.calendarmonth>.monthweek>.monthday {
|
|
90
101
|
height: auto;
|
|
91
102
|
width: auto;
|
|
92
103
|
text-align: center;
|
|
93
104
|
border-right: 0;
|
|
94
105
|
border-bottom: 0;
|
|
95
106
|
transition: all 0.2s ease-in-out;
|
|
96
|
-
|
|
107
|
+
|
|
108
|
+
>.daybutton {
|
|
97
109
|
height: 100%;
|
|
98
110
|
width: 100%;
|
|
99
111
|
padding: 0;
|
|
100
112
|
font-size: 13px;
|
|
101
113
|
border: none;
|
|
102
114
|
background-color: transparent;
|
|
115
|
+
|
|
103
116
|
&.-nowday {
|
|
104
117
|
font-weight: bold
|
|
105
118
|
}
|
|
119
|
+
|
|
106
120
|
&.-outmonth {
|
|
107
121
|
color: #777;
|
|
108
122
|
}
|
|
123
|
+
|
|
109
124
|
&:focus {
|
|
110
125
|
-webkit-box-shadow: none !important;
|
|
111
126
|
box-shadow: none !important;
|
|
112
127
|
border: 2px solid $default-border-color;
|
|
113
128
|
}
|
|
129
|
+
|
|
114
130
|
transition: none;
|
|
115
131
|
}
|
|
132
|
+
|
|
116
133
|
&:hover {
|
|
117
134
|
background-color: $component-border-color;
|
|
118
135
|
border-radius: 4px;
|
|
119
136
|
}
|
|
137
|
+
|
|
120
138
|
&.-selectedday {
|
|
121
139
|
background-color: $font-selected-color;
|
|
122
140
|
border-radius: 4px;
|
|
123
141
|
}
|
|
124
|
-
|
|
142
|
+
|
|
143
|
+
&.-selectedday>.daybutton {
|
|
125
144
|
color: $font-color-second;
|
|
126
145
|
}
|
|
127
146
|
}
|
|
128
147
|
}
|
|
129
148
|
|
|
130
149
|
.calendar-component {
|
|
131
|
-
|
|
132
|
-
|
|
150
|
+
|
|
151
|
+
&.-success,
|
|
152
|
+
&.-primary,
|
|
153
|
+
&.-info,
|
|
154
|
+
&.-warning,
|
|
155
|
+
&.-danger {
|
|
156
|
+
|
|
157
|
+
>.calendarheader,
|
|
158
|
+
>.daynames {
|
|
133
159
|
color: $font-color-second;
|
|
134
160
|
}
|
|
161
|
+
|
|
162
|
+
.navbutton {
|
|
163
|
+
svg {
|
|
164
|
+
fill: $font-color-second;
|
|
165
|
+
}
|
|
166
|
+
}
|
|
135
167
|
}
|
|
168
|
+
|
|
136
169
|
&.-success {
|
|
137
|
-
|
|
138
|
-
|
|
170
|
+
|
|
171
|
+
>.calendarheader,
|
|
172
|
+
>.daynames {
|
|
139
173
|
background-color: $success-color;
|
|
140
174
|
}
|
|
175
|
+
|
|
176
|
+
.navbutton {
|
|
177
|
+
&:focus {
|
|
178
|
+
background-color: $success-actived-color;
|
|
179
|
+
border-color: $success-border-color;
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
&:hover {
|
|
183
|
+
background-color: $success-hover-color;
|
|
184
|
+
}
|
|
185
|
+
}
|
|
141
186
|
}
|
|
187
|
+
|
|
142
188
|
&.-primary {
|
|
143
|
-
|
|
144
|
-
|
|
189
|
+
|
|
190
|
+
>.calendarheader,
|
|
191
|
+
>.daynames {
|
|
145
192
|
background-color: $primary-color;
|
|
146
193
|
}
|
|
194
|
+
|
|
195
|
+
.navbutton {
|
|
196
|
+
&:focus {
|
|
197
|
+
background-color: $primary-actived-color;
|
|
198
|
+
border-color: $primary-border-color;
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
&:hover {
|
|
202
|
+
background-color: $primary-hover-color;
|
|
203
|
+
}
|
|
204
|
+
}
|
|
147
205
|
}
|
|
206
|
+
|
|
148
207
|
&.-info {
|
|
149
|
-
|
|
150
|
-
|
|
208
|
+
|
|
209
|
+
>.calendarheader,
|
|
210
|
+
>.daynames {
|
|
151
211
|
background-color: $info-color;
|
|
152
212
|
}
|
|
213
|
+
|
|
214
|
+
.navbutton {
|
|
215
|
+
&:focus {
|
|
216
|
+
background-color: $info-actived-color;
|
|
217
|
+
border-color: $info-border-color;
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
&:hover {
|
|
221
|
+
background-color: $info-hover-color;
|
|
222
|
+
}
|
|
223
|
+
}
|
|
153
224
|
}
|
|
225
|
+
|
|
154
226
|
&.-warning {
|
|
155
|
-
|
|
156
|
-
|
|
227
|
+
|
|
228
|
+
>.calendarheader,
|
|
229
|
+
>.daynames {
|
|
157
230
|
background-color: $warning-color;
|
|
158
231
|
}
|
|
232
|
+
|
|
233
|
+
.navbutton {
|
|
234
|
+
&:focus {
|
|
235
|
+
background-color: $warning-actived-color;
|
|
236
|
+
border-color: $warning-border-color;
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
&:hover {
|
|
240
|
+
background-color: $warning-hover-color;
|
|
241
|
+
}
|
|
242
|
+
}
|
|
159
243
|
}
|
|
244
|
+
|
|
160
245
|
&.-danger {
|
|
161
|
-
|
|
162
|
-
|
|
246
|
+
|
|
247
|
+
>.calendarheader,
|
|
248
|
+
>.daynames {
|
|
163
249
|
background-color: $danger-color;
|
|
164
250
|
}
|
|
251
|
+
|
|
252
|
+
.navbutton {
|
|
253
|
+
&:focus {
|
|
254
|
+
background-color: $danger-actived-color;
|
|
255
|
+
border-color: $danger-border-color;
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
&:hover {
|
|
259
|
+
background-color: $danger-hover-color;
|
|
260
|
+
}
|
|
261
|
+
}
|
|
165
262
|
}
|
|
166
263
|
}
|
|
167
264
|
|
|
168
265
|
//Add border to days container
|
|
169
266
|
.calendar-component.-draw-grid-lines {
|
|
170
|
-
|
|
267
|
+
>.calendarmonth>.monthweek {
|
|
171
268
|
border-bottom: 1px solid $component-border-color;
|
|
269
|
+
|
|
172
270
|
&:first-child {
|
|
173
271
|
border-top: 1px solid $component-border-color;
|
|
174
272
|
}
|
|
175
273
|
}
|
|
176
|
-
|
|
274
|
+
|
|
275
|
+
>.calendarmonth>.monthweek>.monthday {
|
|
177
276
|
border-left: 1px solid $component-border-color;
|
|
277
|
+
|
|
178
278
|
&:last-child {
|
|
179
279
|
border-right: 1px solid $component-border-color;
|
|
180
280
|
}
|
|
@@ -183,24 +283,29 @@ $border-radius-size: 5px;
|
|
|
183
283
|
|
|
184
284
|
//Remove padding
|
|
185
285
|
.calendar-component.-unpadding {
|
|
186
|
-
|
|
286
|
+
|
|
287
|
+
>.calendarmonth,
|
|
288
|
+
>.daynames {
|
|
187
289
|
padding: 0;
|
|
188
290
|
}
|
|
189
|
-
|
|
291
|
+
|
|
292
|
+
>.calendarmonth>.monthweek {
|
|
190
293
|
&:first-child {
|
|
191
294
|
border-top: 0px;
|
|
192
295
|
}
|
|
296
|
+
|
|
193
297
|
&:last-child {
|
|
194
298
|
border-bottom: 0px;
|
|
195
299
|
}
|
|
196
300
|
}
|
|
197
|
-
|
|
301
|
+
|
|
302
|
+
>.calendarmonth>.monthweek>.monthday {
|
|
198
303
|
&:last-child {
|
|
199
304
|
border-right: 0px
|
|
200
305
|
}
|
|
306
|
+
|
|
201
307
|
&:first-child {
|
|
202
308
|
border-left: 0;
|
|
203
309
|
}
|
|
204
310
|
}
|
|
205
|
-
}
|
|
206
|
-
|
|
311
|
+
}
|
|
@@ -58,23 +58,23 @@
|
|
|
58
58
|
z-index: 9999;
|
|
59
59
|
|
|
60
60
|
>.filtercontainer {
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
61
|
+
display: flex;
|
|
62
|
+
align-items: center;
|
|
63
|
+
justify-content: start;
|
|
64
64
|
border: 1px solid $component-border-color;
|
|
65
65
|
margin: 4px;
|
|
66
66
|
|
|
67
67
|
>.filterinput {
|
|
68
68
|
border: 0;
|
|
69
|
+
flex: 1;
|
|
69
70
|
font-size: 13px;
|
|
70
71
|
text-indent: 4px;
|
|
71
72
|
padding: 10px 5px;
|
|
72
73
|
}
|
|
73
74
|
|
|
74
75
|
>.filtericon {
|
|
75
|
-
|
|
76
|
-
right:
|
|
77
|
-
top: 10px;
|
|
76
|
+
margin: 0px;
|
|
77
|
+
margin-right: 6px;
|
|
78
78
|
}
|
|
79
79
|
}
|
|
80
80
|
|
|
@@ -82,8 +82,6 @@ $dropdown-width: 38px;
|
|
|
82
82
|
}
|
|
83
83
|
|
|
84
84
|
.menu>.menuitem>.menubutton {
|
|
85
|
-
white-space: nowrap;
|
|
86
|
-
text-overflow: ellipsis;
|
|
87
85
|
background: transparent;
|
|
88
86
|
border: 0;
|
|
89
87
|
width: 100%;
|
|
@@ -92,10 +90,16 @@ $dropdown-width: 38px;
|
|
|
92
90
|
box-shadow: none !important;
|
|
93
91
|
|
|
94
92
|
.button-container {
|
|
93
|
+
overflow: hidden;
|
|
95
94
|
justify-content: flex-start;
|
|
96
95
|
> svg {
|
|
97
96
|
margin-right: 10px;
|
|
98
97
|
}
|
|
98
|
+
.button-content {
|
|
99
|
+
overflow: hidden;
|
|
100
|
+
white-space: nowrap;
|
|
101
|
+
text-overflow: ellipsis;
|
|
102
|
+
}
|
|
99
103
|
}
|
|
100
104
|
}
|
|
101
105
|
|
|
@@ -68,7 +68,7 @@ const DefaultButton = _ref => {
|
|
|
68
68
|
const refButton = (0, _react.useRef)(null);
|
|
69
69
|
const disabledIconColor = 'rgb(193, 193, 193)';
|
|
70
70
|
const disabledByPermission = onDenied.disabled;
|
|
71
|
-
const isDisabled = !!onDenied.disabled || disabled;
|
|
71
|
+
const isDisabled = !!onDenied.disabled || disabled || skeletonize;
|
|
72
72
|
const getClass = () => `button-component ${className}
|
|
73
73
|
${customClass}
|
|
74
74
|
${transparent && '-transparent'}
|
|
@@ -4,21 +4,20 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
+
require("../../assets/styles/calendar.scss");
|
|
7
8
|
var _react = _interopRequireWildcard(require("react"));
|
|
8
|
-
var _uuid = require("uuid");
|
|
9
9
|
var _moment = _interopRequireDefault(require("moment"));
|
|
10
|
-
var
|
|
11
|
-
var _buttons = _interopRequireDefault(require("../../buttons"));
|
|
10
|
+
var _uuid = require("uuid");
|
|
12
11
|
var _gridlayout = _interopRequireDefault(require("../../gridlayout"));
|
|
12
|
+
var _buttons = _interopRequireDefault(require("../../buttons"));
|
|
13
13
|
var _helpers = require("./helpers");
|
|
14
|
-
require("../../assets/styles/calendar.scss");
|
|
15
14
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
16
15
|
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); }
|
|
17
16
|
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
17
|
const arrowKeys = ['ArrowUp', 'ArrowRight', 'ArrowDown', 'ArrowLeft'];
|
|
19
18
|
const Calendar = props => {
|
|
20
19
|
const {
|
|
21
|
-
currentDate = (0, _moment.default)(),
|
|
20
|
+
currentDate: currentDateProp = (0, _moment.default)(),
|
|
22
21
|
onDateChange,
|
|
23
22
|
drawGridLines = false,
|
|
24
23
|
colorStyle,
|
|
@@ -28,46 +27,98 @@ const Calendar = props => {
|
|
|
28
27
|
currentDateButton,
|
|
29
28
|
calendarContainer
|
|
30
29
|
} = props;
|
|
31
|
-
const currentMonth = (0, _react.useRef)(null);
|
|
32
30
|
const currentCalendarRef = (0, _react.useRef)(null);
|
|
33
|
-
const
|
|
31
|
+
const calendarMonthsContainerRef = (0, _react.useRef)(null);
|
|
32
|
+
const currentDaySelectedContainerRef = (0, _react.useRef)(null);
|
|
33
|
+
const [currentDate, setCurrentDate] = (0, _react.useState)(currentDateProp);
|
|
34
|
+
const [currentMonth, setCurrentMonth] = (0, _react.useState)((0, _moment.default)(currentDateProp).format('MM-YYYY'));
|
|
34
35
|
const onDateChangeFunction = date => {
|
|
36
|
+
setCurrentDate(date);
|
|
35
37
|
if (onDateChange) onDateChange(date);
|
|
36
|
-
setDataAtual(date);
|
|
37
38
|
};
|
|
38
|
-
const
|
|
39
|
-
const
|
|
40
|
-
|
|
39
|
+
const createCalendarWithWeeksAndDays = () => {
|
|
40
|
+
const firstDayOfMonth = (0, _moment.default)(currentMonth, 'MM-YYYY').startOf('month');
|
|
41
|
+
const lastDayOfMonth = (0, _moment.default)(currentMonth, 'MM-YYYY').endOf('month');
|
|
42
|
+
const startDate = firstDayOfMonth.clone().startOf('week');
|
|
43
|
+
const endDate = lastDayOfMonth.clone().endOf('week');
|
|
44
|
+
const days = [];
|
|
45
|
+
const day = startDate.clone();
|
|
46
|
+
while (day.isBefore(endDate, 'day') || day.isSame(endDate, 'day')) {
|
|
47
|
+
days.push({
|
|
48
|
+
date: day.clone(),
|
|
49
|
+
isDaySelected: day.isSame(currentDate)
|
|
50
|
+
});
|
|
51
|
+
day.add(1, 'day');
|
|
52
|
+
}
|
|
53
|
+
return days;
|
|
41
54
|
};
|
|
42
|
-
const
|
|
43
|
-
const
|
|
44
|
-
|
|
55
|
+
const changeMonth = amountMonthsToChange => {
|
|
56
|
+
const newDate = (0, _moment.default)(currentMonth, 'MM-YYYY').add(amountMonthsToChange, 'month').format('MM-YYYY');
|
|
57
|
+
setCurrentMonth(newDate);
|
|
58
|
+
};
|
|
59
|
+
const getFirstOrLastDayButtonOfCalendar = function () {
|
|
60
|
+
let firstOrLast = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'first';
|
|
61
|
+
const listOfButtons = currentCalendarRef.current?.getElementsByClassName('daybutton') || [];
|
|
62
|
+
if (firstOrLast === 'first') return listOfButtons[0];
|
|
63
|
+
if (firstOrLast === 'last') return listOfButtons[listOfButtons.length - 1];
|
|
45
64
|
};
|
|
46
65
|
const navigateWithArrows = event => {
|
|
47
|
-
const sourceTarget = event.target;
|
|
48
|
-
const daysOfMonth = currentMonth.current?.getElementsByClassName('daybutton');
|
|
49
66
|
let indexCurrentDay = 0;
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
67
|
+
const eventTarget = event.target;
|
|
68
|
+
indexCurrentDay = Number(eventTarget.getAttribute('data-day-index') || 0);
|
|
69
|
+
const containerDaySelected = currentCalendarRef.current?.getElementsByClassName('-selectedday');
|
|
70
|
+
const buttonDaySelected = containerDaySelected?.[0]?.firstChild;
|
|
71
|
+
const daysOfMonth = currentCalendarRef.current?.getElementsByClassName('daybutton');
|
|
72
|
+
const lastDayButtonElement = getFirstOrLastDayButtonOfCalendar('last');
|
|
73
|
+
if (!currentCalendarRef.current?.contains(document.activeElement)) {
|
|
74
|
+
if (currentCalendarRef.current?.contains(buttonDaySelected)) {
|
|
75
|
+
buttonDaySelected.focus();
|
|
76
|
+
indexCurrentDay = Number(buttonDaySelected.getAttribute('data-day-index') || 0);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
if (calendarMonthsContainerRef.current?.contains(document.activeElement)) {
|
|
80
|
+
const element = {
|
|
81
|
+
ArrowUp: daysOfMonth[indexCurrentDay - 7],
|
|
82
|
+
ArrowRight: daysOfMonth[indexCurrentDay + 1],
|
|
83
|
+
ArrowDown: daysOfMonth[indexCurrentDay + 7],
|
|
84
|
+
ArrowLeft: daysOfMonth[indexCurrentDay - 1]
|
|
85
|
+
}[event.code];
|
|
86
|
+
if (element) element.focus();
|
|
87
|
+
const lastButtonElementIndex = Number(lastDayButtonElement?.getAttribute('data-day-index') || 0);
|
|
88
|
+
if (indexCurrentDay === 0 && event.code === 'ArrowLeft') {
|
|
89
|
+
setCurrentMonth(prevState => {
|
|
90
|
+
return (0, _moment.default)(prevState, 'MM-YYYY').subtract(1, 'month').format('MM-YYYY');
|
|
91
|
+
});
|
|
92
|
+
setTimeout(() => {
|
|
93
|
+
getFirstOrLastDayButtonOfCalendar('last')?.focus();
|
|
94
|
+
}, 1);
|
|
95
|
+
}
|
|
96
|
+
if (indexCurrentDay === lastButtonElementIndex && event.code === 'ArrowRight') {
|
|
97
|
+
setCurrentMonth(prevState => {
|
|
98
|
+
return (0, _moment.default)(prevState, 'MM-YYYY').add(1, 'month').format('MM-YYYY');
|
|
99
|
+
});
|
|
100
|
+
setTimeout(() => {
|
|
101
|
+
getFirstOrLastDayButtonOfCalendar('first')?.focus();
|
|
102
|
+
}, 1);
|
|
103
|
+
}
|
|
104
|
+
} else {
|
|
105
|
+
if (calendarMonthsContainerRef.current?.contains(buttonDaySelected)) {
|
|
106
|
+
buttonDaySelected.focus();
|
|
107
|
+
} else {
|
|
108
|
+
getFirstOrLastDayButtonOfCalendar('first')?.focus();
|
|
109
|
+
}
|
|
54
110
|
}
|
|
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
111
|
};
|
|
63
112
|
const contextValues = {
|
|
64
113
|
handleDateChange: onDateChangeFunction
|
|
65
114
|
};
|
|
66
115
|
(0, _react.useEffect)(() => {
|
|
116
|
+
setCurrentDate((0, _helpers.validDate)(currentDateProp));
|
|
67
117
|
calendarContainer?.(currentCalendarRef?.current);
|
|
68
|
-
|
|
118
|
+
}, []);
|
|
119
|
+
(0, _react.useEffect)(() => {
|
|
69
120
|
document.addEventListener('keydown', event => {
|
|
70
|
-
if (event && event.code && arrowKeys.includes(event.code) &&
|
|
121
|
+
if (event && event.code && arrowKeys.includes(event.code) && document.contains(currentCalendarRef.current)) {
|
|
71
122
|
navigateWithArrows(event);
|
|
72
123
|
event.stopPropagation();
|
|
73
124
|
event.preventDefault();
|
|
@@ -77,12 +128,10 @@ const Calendar = props => {
|
|
|
77
128
|
document.removeEventListener('keydown', () => {});
|
|
78
129
|
};
|
|
79
130
|
}, []);
|
|
80
|
-
(0, _react.useEffect)(() => {
|
|
81
|
-
const daysOfMonth = currentMonth.current?.getElementsByClassName('-selectedday')[0];
|
|
82
|
-
currentDateButton?.(daysOfMonth.firstChild);
|
|
83
|
-
}, [currentDate]);
|
|
84
131
|
const component = /*#__PURE__*/_react.default.createElement("div", {
|
|
85
132
|
ref: currentCalendarRef,
|
|
133
|
+
role: "grid",
|
|
134
|
+
"aria-label": String('calendar-container-').concat((0, _uuid.v1)()),
|
|
86
135
|
className: (0, _helpers.getCalendarCssClass)({
|
|
87
136
|
unpadding,
|
|
88
137
|
drawGridLines,
|
|
@@ -93,30 +142,54 @@ const Calendar = props => {
|
|
|
93
142
|
className: "calendarheader"
|
|
94
143
|
}, /*#__PURE__*/_react.default.createElement(_buttons.default, {
|
|
95
144
|
id: (0, _uuid.v1)(),
|
|
145
|
+
tabIndex: -1,
|
|
96
146
|
boxShadow: false,
|
|
97
147
|
iconName: "arrow_left",
|
|
98
148
|
customClass: "navbutton nav-arrow-left",
|
|
99
149
|
onClick: () => {
|
|
100
|
-
|
|
150
|
+
changeMonth(-1);
|
|
101
151
|
}
|
|
102
152
|
}), /*#__PURE__*/_react.default.createElement("span", {
|
|
103
153
|
className: "monthname"
|
|
104
|
-
},
|
|
154
|
+
}, (0, _moment.default)(currentMonth, 'MM-YYYY').format('MMMM YYYY')), /*#__PURE__*/_react.default.createElement(_buttons.default, {
|
|
105
155
|
id: (0, _uuid.v1)(),
|
|
156
|
+
tabIndex: -1,
|
|
106
157
|
boxShadow: false,
|
|
107
158
|
iconName: "arrow_right",
|
|
108
159
|
customClass: "navbutton nav-arrow-right",
|
|
109
160
|
onClick: () => {
|
|
110
|
-
|
|
161
|
+
changeMonth(1);
|
|
111
162
|
}
|
|
112
163
|
})), /*#__PURE__*/_react.default.createElement("div", {
|
|
113
164
|
className: "daynames"
|
|
114
165
|
}, (0, _helpers.dayNames)().map(name => /*#__PURE__*/_react.default.createElement("div", {
|
|
115
166
|
key: `day-${name}`
|
|
116
|
-
}, name))), /*#__PURE__*/_react.default.createElement(
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
}
|
|
167
|
+
}, name))), /*#__PURE__*/_react.default.createElement("div", {
|
|
168
|
+
ref: calendarMonthsContainerRef,
|
|
169
|
+
className: "calendarmonth"
|
|
170
|
+
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
171
|
+
className: "monthweek"
|
|
172
|
+
}, createCalendarWithWeeksAndDays().map((_ref, index) => {
|
|
173
|
+
let {
|
|
174
|
+
date,
|
|
175
|
+
isDaySelected
|
|
176
|
+
} = _ref;
|
|
177
|
+
return /*#__PURE__*/_react.default.createElement("div", {
|
|
178
|
+
key: date.format('YYYY-MM-DD'),
|
|
179
|
+
ref: isDaySelected ? currentDaySelectedContainerRef : undefined,
|
|
180
|
+
className: (0, _helpers.getDayContainerCssClass)(currentDate, date)
|
|
181
|
+
}, /*#__PURE__*/_react.default.createElement(_buttons.default, {
|
|
182
|
+
"data-day-index": index,
|
|
183
|
+
id: (0, _uuid.v1)(),
|
|
184
|
+
type: "button",
|
|
185
|
+
buttonRef: ref => isDaySelected && ref ? currentDateButton?.(ref) : undefined,
|
|
186
|
+
tabIndex: -1,
|
|
187
|
+
boxShadow: false,
|
|
188
|
+
label: date.date().toString(),
|
|
189
|
+
onClick: () => onDateChangeFunction(date),
|
|
190
|
+
customClass: ` ${(0, _helpers.getDayCssClass)(currentDate, date)} numberdaycalendar`
|
|
191
|
+
}));
|
|
192
|
+
}))));
|
|
120
193
|
return /*#__PURE__*/_react.default.createElement(_helpers.CalendarContext.Provider, {
|
|
121
194
|
value: contextValues
|
|
122
195
|
}, !gridLayout ? component : /*#__PURE__*/_react.default.createElement(_gridlayout.default, {
|