digitinary-ui 1.0.6 → 1.0.8

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 (80) hide show
  1. package/dist/components/Table/Table.d.ts +1 -1
  2. package/dist/index.js +2 -3
  3. package/dist/types/interfaces.d.ts +4 -0
  4. package/package.json +1 -1
  5. package/dist/components/Accordion/Accordion.js +0 -28
  6. package/dist/components/Accordion/index.js +0 -1
  7. package/dist/components/Alert/Alert.js +0 -58
  8. package/dist/components/Alert/index.js +0 -1
  9. package/dist/components/Button/Button.js +0 -17
  10. package/dist/components/Button/index.js +0 -1
  11. package/dist/components/Card/Card.js +0 -6
  12. package/dist/components/Card/index.js +0 -1
  13. package/dist/components/Checkbox/Checkbox.js +0 -8
  14. package/dist/components/Checkbox/index.js +0 -1
  15. package/dist/components/Chip/Chip.js +0 -18
  16. package/dist/components/Chip/index.js +0 -1
  17. package/dist/components/Date/Date.js +0 -460
  18. package/dist/components/Date/index.js +0 -1
  19. package/dist/components/DateRange/DateRange.js +0 -206
  20. package/dist/components/DateRange/index.js +0 -1
  21. package/dist/components/Dialog/Dialog.js +0 -36
  22. package/dist/components/Dialog/index.js +0 -1
  23. package/dist/components/HelperText/HelperText.js +0 -6
  24. package/dist/components/HelperText/index.js +0 -1
  25. package/dist/components/Input/Input.js +0 -38
  26. package/dist/components/Input/index.js +0 -1
  27. package/dist/components/Label/Label.js +0 -6
  28. package/dist/components/Label/index.js +0 -1
  29. package/dist/components/Overlay/Overlay.js +0 -8
  30. package/dist/components/Overlay/index.js +0 -1
  31. package/dist/components/Pagination/Pagination.js +0 -26
  32. package/dist/components/Pagination/index.js +0 -1
  33. package/dist/components/Radio/Radio.js +0 -8
  34. package/dist/components/Radio/index.js +0 -1
  35. package/dist/components/RadioGroup/RadioGroup.js +0 -14
  36. package/dist/components/RadioGroup/index.js +0 -1
  37. package/dist/components/SelectGroup/SelectGroup.js +0 -251
  38. package/dist/components/SelectGroup/index.js +0 -1
  39. package/dist/components/SideDrawer/SideDrawer.js +0 -54
  40. package/dist/components/SideDrawer/index.js +0 -1
  41. package/dist/components/Switch/Switch.js +0 -6
  42. package/dist/components/Switch/index.js +0 -1
  43. package/dist/components/Table/Table.js +0 -60
  44. package/dist/components/Table/index.js +0 -1
  45. package/dist/components/TextArea/TextArea.js +0 -30
  46. package/dist/components/TextArea/index.js +0 -1
  47. package/dist/components/Tooltip/Tooltip.js +0 -8
  48. package/dist/components/index.js +0 -19
  49. package/dist/constants/index.js +0 -5
  50. package/dist/icons/AlertErrorIcon.js +0 -3
  51. package/dist/icons/AlertInfoIcon.js +0 -3
  52. package/dist/icons/AlertSuccessIcon.js +0 -3
  53. package/dist/icons/AlertWarningIcon.js +0 -3
  54. package/dist/icons/ArrowBottom.js +0 -3
  55. package/dist/icons/ArrowLeft.js +0 -3
  56. package/dist/icons/ArrowRight.js +0 -3
  57. package/dist/icons/ArrowUpIcon.js +0 -3
  58. package/dist/icons/Calendar.js +0 -3
  59. package/dist/icons/CheckMark.js +0 -3
  60. package/dist/icons/ClearField.js +0 -3
  61. package/dist/icons/CloseIcon.js +0 -3
  62. package/dist/icons/DoubleLeftArrow.js +0 -3
  63. package/dist/icons/DoubleRightArrow.js +0 -3
  64. package/dist/icons/ExcelIcon.js +0 -3
  65. package/dist/icons/HidePasswordIcon.js +0 -3
  66. package/dist/icons/InfoIcon.js +0 -3
  67. package/dist/icons/LeftArrowIcon.js +0 -3
  68. package/dist/icons/LoaderIcon.js +0 -3
  69. package/dist/icons/PdfIcon.js +0 -3
  70. package/dist/icons/RightArrowIcon.js +0 -3
  71. package/dist/icons/SearchIcon.js +0 -3
  72. package/dist/icons/SelectFieldDownArrow.js +0 -3
  73. package/dist/icons/SelectFieldUpArrow.js +0 -3
  74. package/dist/icons/ShowPasswordIcon.js +0 -3
  75. package/dist/icons/SortIcon.js +0 -3
  76. package/dist/types/enums.js +0 -25
  77. package/dist/types/index.js +0 -3
  78. package/dist/types/interfaces.js +0 -1
  79. package/dist/types/types.js +0 -1
  80. package/dist/utils/index.js +0 -8
@@ -1,460 +0,0 @@
1
- import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
- import { useState, useEffect, useRef } from 'react';
3
- import moment from 'moment';
4
- import Button from '../Button';
5
- import styles from './date.module.scss';
6
- import ClearField from '../../icons/ClearField';
7
- import CalendarIcon from '../../icons/Calendar';
8
- import ArrowUpIcon from '../../icons/ArrowUpIcon';
9
- import RightArrowIcon from '../../icons/RightArrowIcon';
10
- import ArrowBottomIcon from '../../icons/ArrowBottom';
11
- import LeftArrowIcon from '../../icons/LeftArrowIcon';
12
- const Date = ({ id, label, placeholder, helperText, errorMsg, value, onChange, disabledDay, selectedEndDate, success, disabled, size = 'medium', clearable = true, disablePastDays, timePicker, isEndDay, defaultFormat = !timePicker ? 'DD MMM YYYY' : 'DD MMM YYYY HH:mm:ss', required, acceptSameDay, setCheckDateOpened, maxDate, minDate, className = '', dataId, }) => {
13
- const presentDate = moment().startOf('day');
14
- const years = getYears();
15
- const datepickerRef = useRef(null);
16
- const [currentMonth, setCurrentMonth] = useState(moment());
17
- const [showDatePicker, setShowDatePicker] = useState(false);
18
- const [calendarView, setCalendarView] = useState('daily');
19
- const currentDate = moment();
20
- const [yearsObj, setYearsObj] = useState({
21
- currentView: Math.floor(years.length / 12 - 1),
22
- itemsPerView: 12,
23
- allYears: years,
24
- });
25
- const [time, setTime] = useState({
26
- h: isEndDay && !value ? 23 : value ? Number(moment(value).format('H')) : 0,
27
- mm: isEndDay && !value ? 59 : value ? Number(moment(value).format('m')) : 0,
28
- ss: isEndDay && !value ? 59 : value ? Number(moment(value).format('s')) : 0,
29
- });
30
- const [selectedDate, setSelectedDate] = useState(moment());
31
- const weekdaysShort = moment.weekdaysShort();
32
- const weeks = getWeeksArray(currentMonth);
33
- const monthsShort = moment.monthsShort();
34
- const startYears = (yearsObj.currentView - 1) * yearsObj.itemsPerView;
35
- const endYears = startYears + yearsObj.itemsPerView;
36
- const displayedYears = yearsObj.allYears.slice(startYears, endYears);
37
- const totalYears = Math.ceil(yearsObj.allYears.length / yearsObj.itemsPerView);
38
- const nextMonthRefs = useRef(null);
39
- const prevMonthRefs = useRef(null);
40
- const [isEndDateCorrect, setIsEndDateCorrect] = useState(true);
41
- const [isStartDateCorrect, setIsStartDateCorrect] = useState(true);
42
- function timeKeyDown(e, increaseNum, decreaseNum) {
43
- if (e.key === 'Enter' || e.key === ' ') {
44
- submitDate();
45
- e.stopPropagation();
46
- e.preventDefault();
47
- }
48
- else if (e.key === 'ArrowUp') {
49
- e.stopPropagation();
50
- increaseNum();
51
- e.preventDefault();
52
- }
53
- else if (e.key === 'ArrowDown') {
54
- e.stopPropagation();
55
- decreaseNum();
56
- e.preventDefault();
57
- }
58
- }
59
- function getYears() {
60
- const years = [];
61
- const pastYear = moment().subtract(100, 'years').year();
62
- const futureYear = moment().add(30, 'years').year();
63
- for (let year = pastYear; year <= futureYear; year++)
64
- years.push(year);
65
- return years;
66
- }
67
- function getWeeksArray(month) {
68
- const firstDayOfMonth = moment(month).startOf('month');
69
- const firstDayOfCalendar = moment(firstDayOfMonth).startOf('week');
70
- const lastDayOfMonth = moment(month).endOf('month');
71
- const numWeeks = lastDayOfMonth.diff(firstDayOfMonth, 'weeks') + 1;
72
- const weeks = [];
73
- for (let i = 0; i < numWeeks; i++) {
74
- weeks.push(moment(firstDayOfCalendar).add(i, 'weeks'));
75
- }
76
- return weeks;
77
- }
78
- const increaseHours = () => {
79
- if (time.h < 23)
80
- setTime((prev) => ({ ...prev, h: prev.h + 1 }));
81
- if (time.h === 23)
82
- setTime((prev) => ({ ...prev, h: 0 }));
83
- };
84
- const decreaseHours = () => {
85
- if (time.h > 0)
86
- setTime((prev) => ({ ...prev, h: prev.h - 1 }));
87
- if (time.h === 0)
88
- setTime((prev) => ({ ...prev, h: 23 }));
89
- };
90
- const increaseMinuts = () => {
91
- if (time.mm < 59)
92
- setTime((prev) => ({ ...prev, mm: prev.mm + 1 }));
93
- if (time.mm === 59)
94
- setTime((prev) => ({ ...prev, mm: 0 }));
95
- };
96
- const decreaseMinuts = () => {
97
- if (time.mm > 0)
98
- setTime((prev) => ({ ...prev, mm: prev.mm - 1 }));
99
- if (time.mm === 0)
100
- setTime((prev) => ({ ...prev, mm: 59 }));
101
- };
102
- const increaseSeconds = () => {
103
- if (time.ss < 59)
104
- setTime((prev) => ({ ...prev, ss: prev.ss + 1 }));
105
- if (time.ss === 59)
106
- setTime((prev) => ({ ...prev, ss: 0 }));
107
- };
108
- const decreaseSeconds = () => {
109
- if (time.ss > 0)
110
- setTime((prev) => ({ ...prev, ss: prev.ss - 1 }));
111
- if (time.ss === 0)
112
- setTime((prev) => ({ ...prev, ss: 59 }));
113
- };
114
- const setTimeoutDisable = () => {
115
- if (isEndDay) {
116
- document.querySelectorAll(`.${styles.row} .${styles.dayUnit}`).forEach((cell) => {
117
- const cellElement = cell;
118
- if (disabledDay && moment(cellElement.dataset.val).isBefore(moment(disabledDay))) {
119
- cellElement?.classList.add(styles.dayOff);
120
- cellElement.disabled = true;
121
- }
122
- const endOfDay = moment(disabledDay).clone().endOf('day');
123
- if (acceptSameDay) {
124
- if (disabledDay && moment(cellElement.dataset.val).isBefore(moment(disabledDay))) {
125
- cellElement?.classList.add(styles.dayOff);
126
- cellElement.disabled = true;
127
- }
128
- }
129
- else {
130
- if (moment(disabledDay).format(defaultFormat) === moment(endOfDay).format(defaultFormat)) {
131
- if (moment(cellElement.dataset.val).format('D') === moment(disabledDay).format('D')) {
132
- cellElement?.classList.add(styles.dayOff);
133
- cellElement.disabled = true;
134
- }
135
- }
136
- }
137
- });
138
- }
139
- else if (selectedEndDate) {
140
- document.querySelectorAll(`.${styles.row} .${styles.dayUnit}`).forEach((cell) => {
141
- const cellElement = cell;
142
- if (moment(cellElement.dataset.val).isAfter(selectedEndDate)) {
143
- cellElement?.classList.add(styles.dayOff);
144
- cellElement.disabled = true;
145
- }
146
- });
147
- }
148
- };
149
- useEffect(() => {
150
- setSelectedDate(value === null ? '' : value);
151
- }, [value]);
152
- useEffect(() => {
153
- setCheckDateOpened && setCheckDateOpened(showDatePicker);
154
- }, [showDatePicker]);
155
- const checkDate = (endDate) => {
156
- if (disabledDay &&
157
- (endDate ?? value) &&
158
- id === 'end' &&
159
- !acceptSameDay &&
160
- moment(disabledDay).isSameOrAfter(moment(endDate ?? value))) {
161
- setIsEndDateCorrect(false);
162
- return false;
163
- }
164
- else {
165
- setIsEndDateCorrect(true);
166
- return true;
167
- }
168
- };
169
- const excludePastDate = (startDate) => {
170
- const currentDate = moment().format('DD MMM YYYY HH:mm');
171
- if ((startDate ?? disabledDay) &&
172
- id === 'start' &&
173
- moment(currentDate).isAfter(moment(startDate ?? disabledDay).format('DD MMM YYYY HH:mm'))) {
174
- setIsStartDateCorrect(false);
175
- return false;
176
- }
177
- else {
178
- setIsStartDateCorrect(true);
179
- return true;
180
- }
181
- };
182
- useEffect(() => {
183
- const presentDateElement = document.querySelector(`.${styles.row} .${styles.dayUnit} .${styles.present}`);
184
- const presentDateHtml = presentDateElement;
185
- const presentDate = presentDateHtml ? presentDateHtml.dataset.val : null;
186
- document.querySelectorAll(`.${styles.row} .${styles.dayUnit}`).forEach((cell) => {
187
- const cellElement = cell;
188
- if (presentDate &&
189
- moment(cellElement.dataset.val, 'D MMM YYYY').isSame(moment(presentDate), 'day')) {
190
- cellElement.classList.add(`${styles.present}`);
191
- }
192
- });
193
- setTimeout(() => {
194
- document.querySelectorAll(`.${styles.row} .${styles.dayUnit}`).forEach((selected) => {
195
- const dataVal = selected.getAttribute('data-val');
196
- if (dataVal) {
197
- if (moment(dataVal).isSame(selectedDate, 'day')) {
198
- selected.classList.add(`${styles.active}`);
199
- }
200
- else {
201
- selected.classList.remove(`${styles.active}`);
202
- }
203
- }
204
- });
205
- document
206
- .querySelectorAll(`.${styles.present}.${styles.active}`)
207
- .forEach((cell) => cell.classList.remove(styles.present));
208
- }, 0);
209
- }, [showDatePicker, currentMonth, selectedDate]);
210
- const excludePastDay = () => {
211
- document.querySelectorAll(`.${styles.row} .${styles.dayUnit}`).forEach((cell) => {
212
- const cellElement = cell;
213
- if (moment(cellElement.dataset.val) < presentDate) {
214
- cellElement?.classList.add(styles.dayOff);
215
- cellElement.disabled = true;
216
- }
217
- });
218
- };
219
- const handleMinDate = () => {
220
- const datepickerFrom = document.getElementById('datepicker-from');
221
- if (datepickerFrom) {
222
- const dayUnits = datepickerFrom.querySelectorAll('[data-val]');
223
- dayUnits.forEach((cell) => {
224
- const dataVal = cell.getAttribute('data-val');
225
- if (moment(dataVal).format('YYYY-MM-DD') < moment(minDate).format('YYYY-MM-DD')) {
226
- cell.classList.add(styles.dayOff);
227
- cell.disabled = true;
228
- }
229
- });
230
- }
231
- };
232
- const handleMaxDate = () => {
233
- const datepickerFrom = document.getElementById('datepicker-from');
234
- if (datepickerFrom) {
235
- const dayUnits = datepickerFrom.querySelectorAll('[data-val]');
236
- dayUnits.forEach((cell) => {
237
- const dataVal = cell.getAttribute('data-val');
238
- if (moment(dataVal).format('YYYY-MM-DD') > moment(maxDate).format('YYYY-MM-DD')) {
239
- cell.classList.add(styles.dayOff);
240
- cell.disabled = true;
241
- }
242
- });
243
- }
244
- };
245
- useEffect(() => {
246
- setTimeoutDisable();
247
- if (disablePastDays) {
248
- excludePastDay();
249
- }
250
- else if (maxDate) {
251
- handleMaxDate();
252
- }
253
- }, [currentMonth, calendarView, showDatePicker, yearsObj]);
254
- useEffect(() => {
255
- if (minDate) {
256
- handleMinDate();
257
- }
258
- }, [currentMonth, calendarView, showDatePicker, yearsObj]);
259
- const handlePrev = () => {
260
- switch (calendarView) {
261
- case 'daily':
262
- return setCurrentMonth(moment(currentMonth).subtract(1, 'month'));
263
- case 'monthly':
264
- return setCurrentMonth(moment(currentMonth).subtract(1, 'year'));
265
- case 'yearly':
266
- if (yearsObj.currentView) {
267
- return setYearsObj((prev) => ({
268
- ...prev,
269
- currentView: yearsObj.currentView - 1,
270
- }));
271
- }
272
- else {
273
- return null;
274
- }
275
- default:
276
- }
277
- };
278
- const handleNext = () => {
279
- switch (calendarView) {
280
- case 'daily':
281
- return setCurrentMonth(moment(currentMonth).add(1, 'month'));
282
- case 'monthly':
283
- return setCurrentMonth(moment(currentMonth).add(1, 'year'));
284
- case 'yearly':
285
- if (yearsObj.currentView < totalYears) {
286
- setYearsObj((prev) => ({
287
- ...prev,
288
- currentView: yearsObj.currentView + 1,
289
- }));
290
- }
291
- else {
292
- return null;
293
- }
294
- default:
295
- }
296
- };
297
- const hidePicker = () => {
298
- if (id === 'end' && moment(disabledDay).isSameOrAfter(moment(value))) {
299
- setShowDatePicker(true);
300
- }
301
- else if (id === 'end' && moment(disabledDay).isBefore(moment(value))) {
302
- setShowDatePicker(false);
303
- }
304
- setShowDatePicker(false);
305
- };
306
- const showCalendarView = (view) => setCalendarView(view);
307
- const handleFocus = () => {
308
- setShowDatePicker(!showDatePicker);
309
- setDate(value === null ? '' : value);
310
- };
311
- const selectView = (month, year) => {
312
- if (calendarView === 'monthly') {
313
- setCalendarView('daily');
314
- setCurrentMonth(moment().month(month).year(Number(year)));
315
- }
316
- if (calendarView === 'yearly') {
317
- setCalendarView('monthly');
318
- setCurrentMonth(moment().month(month).year(Number(month)));
319
- }
320
- };
321
- const setDate = (day) => {
322
- setSelectedDate(moment(day).format(defaultFormat));
323
- };
324
- const submitDate = (submittedDate) => {
325
- const isCorrect = checkDate(moment(submittedDate)
326
- .set({ hour: time.h, minute: time.mm, second: time.ss })
327
- .format(defaultFormat));
328
- const isEndDateTimeCorrect = excludePastDate(moment(submittedDate)
329
- .set({ hour: time.h, minute: time.mm, second: time.ss })
330
- .format(defaultFormat));
331
- if (id === 'end' && !isCorrect)
332
- return;
333
- if (id === 'start' && !isEndDateTimeCorrect && disablePastDays)
334
- return;
335
- hidePicker();
336
- onChange(moment(submittedDate)
337
- .set({ hour: time.h, minute: time.mm, second: time.ss })
338
- .format(defaultFormat));
339
- };
340
- useEffect(() => {
341
- function handleClickOutside(event) {
342
- if (datepickerRef.current &&
343
- !datepickerRef.current.contains(event.target) &&
344
- event.target &&
345
- !(event.target.matches &&
346
- event.target.matches(`#${id ?? 'date-picker-id'}`))) {
347
- hidePicker();
348
- }
349
- }
350
- document.addEventListener('mousedown', handleClickOutside);
351
- return () => document.removeEventListener('mousedown', handleClickOutside);
352
- }, [datepickerRef]);
353
- const clearTime = (id) => {
354
- if (id === 'start') {
355
- setTime({ h: 0, mm: 0, ss: 0 });
356
- }
357
- else if (id === 'end') {
358
- setTime({ h: 23, mm: 59, ss: 59 });
359
- }
360
- else
361
- return;
362
- };
363
- const [flipDropdown, setFlipDropdown] = useState(false);
364
- const isInViewport = (element, timePicker) => {
365
- if (element) {
366
- const rect = element.getBoundingClientRect();
367
- const coordinationElement = document.elementFromPoint(rect.left + 50, rect.bottom - 30);
368
- const foundLastItemInList = Array.from(element.children).find((child) => child === coordinationElement);
369
- const isOverlapped = !foundLastItemInList ? 0 : 150;
370
- return timePicker
371
- ? rect.bottom + 373 - (window.innerHeight - isOverlapped) >= 0
372
- : rect.bottom + 287 - window.innerHeight >= 0;
373
- }
374
- // Return false if the element is falsy
375
- return false;
376
- };
377
- useEffect(() => {
378
- if (showDatePicker && datepickerRef.current) {
379
- setFlipDropdown(isInViewport(datepickerRef.current));
380
- }
381
- else
382
- setFlipDropdown(false);
383
- }, [datepickerRef, showDatePicker]);
384
- return (_jsxs("div", { className: `${styles.dateContainer} ${className}`, children: [label && (_jsxs("label", { htmlFor: id, className: styles.dateLabel, "data-id": `${String(dataId ?? label)
385
- .toUpperCase()
386
- .replaceAll(' ', '_')}_FIELD_LABEL_ID`, children: [label, required && _jsx("span", { className: styles.star, children: "*" })] })), _jsxs("div", { className: styles.dateInputContainer, ref: datepickerRef, children: [_jsxs("div", { className: `${styles.inputIconsContainer} ${disabled ? styles.disabled : ''} ${styles[size]} ${errorMsg ? styles.error : ''} ${success ? styles.success : ''} ${!value ? styles.placeholder : ''}`, children: [_jsx("input", { id: id, className: `${styles.dateInput} ${disabled ? styles.disabled : ''}`, onChange: (e) => onChange(e.target.value), disabled: disabled, value: value ?? '', placeholder: placeholder, readOnly: true, "data-id": `${String(dataId ?? label)
387
- ?.toUpperCase()
388
- .replaceAll(' ', '_')}_FIELD_ID`, onClick: () => handleFocus(), onKeyDown: (e) => {
389
- if (e.key === 'Enter' || e.key === ' ') {
390
- e.stopPropagation();
391
- e.preventDefault();
392
- setShowDatePicker(!showDatePicker);
393
- }
394
- }, autoComplete: "off" }), helperText && _jsx("span", { className: styles.dateHelper, children: helperText }), errorMsg && _jsx("span", { className: styles.dateError, children: errorMsg }), _jsxs("div", { className: `${styles.iconsContainer} ${disabled ? styles.disabled : ''}`, onClick: () => !disabled && handleFocus(), children: [clearable && value && !disabled && (_jsx(ClearField, { className: styles.clearIcon, width: '1rem', height: '1rem', onClick: (e) => {
395
- e.stopPropagation();
396
- onChange(null);
397
- clearTime(id);
398
- setShowDatePicker(false);
399
- }, "data-id": 'CLEAR_ICON_ID' })), _jsx(CalendarIcon, { className: `${styles.calendarIcon} ${disabled ? styles.disabled : ''} ${value ? styles.activeContent : ''}`, width: 24, height: 24, onClick: (e) => {
400
- !disabled && handleFocus();
401
- e.stopPropagation();
402
- }, "data-id": "CALENDER_ICON" })] })] }), showDatePicker && (_jsxs("div", { id: "datepicker-from", className: `${styles.datepicker} ${flipDropdown ? styles[`flip-${size}`] : ''}`, children: [_jsxs("div", { className: styles.datepickerCalendar, children: [_jsxs("div", { className: styles.header, children: [_jsxs("div", { className: styles.headerDates, children: [_jsx("button", { type: "button", className: `${styles.monthChange} ${styles.goToPreviousMonth}`, ref: (ref) => (prevMonthRefs.current = ref), onKeyDown: (e) => {
403
- if (e.key === 'Enter' || e.key === ' ') {
404
- handlePrev();
405
- e.preventDefault();
406
- e.stopPropagation();
407
- }
408
- }, onClick: (e) => {
409
- e.preventDefault();
410
- handlePrev();
411
- }, "data-id": "PREVIOUS_DAY", children: _jsx(LeftArrowIcon, { width: '0.875rem', height: '0.875rem' }) }), _jsxs("span", { className: `${styles.headerDates} ${styles.YearAndMonth}`, children: [calendarView === 'daily' && (_jsx("span", {
412
- // className={styles.pickMonth}
413
- className: `${styles.pickMonth} ${moment(currentMonth).format('MMMM') === moment(currentDate).format('MMMM')
414
- ? styles.active
415
- : ''}`, "data-id": "PICK_MONTH", onClick: () => showCalendarView('monthly'), children: currentMonth.format('MMMM') })), (calendarView === 'monthly' || calendarView === 'daily') && (_jsx("span", { className: styles.pickYear, "data-id": "PICK_YEAR", onClick: () => showCalendarView('yearly'), children: currentMonth.format('YYYY') })), calendarView === 'yearly' && (_jsx("span", { className: styles.selectYear, children: "Select a Year" }))] }), _jsx("button", { type: "button", "data-id": "NEXT_DAY", className: `${styles.monthChange} ${styles.goToNextMonth}`, ref: (ref) => (nextMonthRefs.current = ref), onKeyDown: (e) => {
416
- if (e.key === 'Enter' || e.key === ' ') {
417
- e.preventDefault();
418
- handleNext();
419
- }
420
- }, onClick: (e) => {
421
- handleNext();
422
- e.preventDefault();
423
- e.stopPropagation();
424
- }, children: _jsx(RightArrowIcon, { width: '0.875rem', height: '0.875rem' }) })] }), _jsx("div", { className: styles.headerDaysRow, children: calendarView === 'daily' &&
425
- weekdaysShort?.map((day, idx) => (_jsx("span", { className: styles.dayName, children: day }, idx))) })] }), _jsxs("div", { className: styles.bodyDaysRow, children: [calendarView === 'daily' &&
426
- weeks?.map((week) => {
427
- return (_jsx("div", { className: styles.row, children: Array.from({ length: 7 })?.map((_, i) => {
428
- const day = moment(week).add(i, 'days');
429
- const isCurrentMonth = day.isSame(currentMonth, 'month');
430
- const isToday = day.isSame(moment(), 'day');
431
- const className = isCurrentMonth
432
- ? `${styles.currentMonth} ${isToday ? styles.active : ''}`
433
- : styles.otherMonth;
434
- return (_jsx("button", { type: "button", "data-val": moment(day)
435
- .set({ hour: time.h, minute: time.mm, second: time.ss })
436
- .format(defaultFormat), "data-disabledday": moment(disabledDay, defaultFormat).format('D/M'), className: `${styles.dayUnit} ${className}
437
- ${day.isSame(moment(currentDate), 'day') ? styles.present : ''}`, onClick: (e) => {
438
- e.preventDefault();
439
- timePicker
440
- ? setDate(day)
441
- : submitDate(moment(day).format(defaultFormat));
442
- }, children: day.format('D') }, day.format(defaultFormat)));
443
- }) }, week.format(defaultFormat)));
444
- }), calendarView === 'monthly' && (_jsx("div", { className: styles.bodyMonthsView, children: monthsShort?.map((month, index) => {
445
- return (_jsx("button", { type: "button", onClick: () => selectView(index, currentMonth.format('YYYY')), className: `${styles.month} ${index === moment(selectedDate).month() ? styles.active : ''}`, children: _jsx("span", { children: month }) }, month));
446
- }) })), calendarView === 'yearly' && (_jsx("div", { className: styles.bodyYearsView, children: displayedYears?.map((year) => (_jsx("button", { type: "button", onClick: () => selectView(year), className: `${styles.year} ${year === moment(selectedDate).year() ? styles.active : ''}`, children: _jsx("span", { children: year }) }, year))) }))] })] }), timePicker && (_jsxs(_Fragment, { children: [_jsx("hr", { className: styles.separator }), _jsxs("div", { className: styles.timePicker, children: [_jsxs("div", { className: styles.inputContainer, children: [_jsx("input", { className: `${styles.hours} ${!isEndDateCorrect || (!isStartDateCorrect && disablePastDays)
447
- ? styles.errorInput
448
- : ''}`, "data-id": "HOURS_TIME_PICKER", type: "number", value: time.h < 10 ? `0${time.h}` : time.h, readOnly: true, onKeyDown: (e) => timeKeyDown(e, increaseHours, decreaseHours) }), _jsxs("div", { className: styles.buttons, children: [_jsx("span", { className: styles.button, onClick: increaseHours, children: _jsx(ArrowBottomIcon, { width: '1.5rem', height: '1.5rem', "data-id": "DOWN_ARROW_HOURS_TIME_PICKER" }) }), _jsx("span", { className: styles.button, onClick: decreaseHours, children: _jsx(ArrowUpIcon, { width: '1.5rem', height: '1.5rem', "data-id": "UP_ARROW_HOURS_TIME_PICKER" }) })] })] }), _jsxs("div", { className: styles.inputContainer, children: [_jsx("input", { className: `${styles.minutes} ${!isEndDateCorrect || (!isStartDateCorrect && disablePastDays)
449
- ? styles.errorInput
450
- : ''}`, type: "number", "data-id": "MINUTED_TIME_PICKER", value: time.mm < 10 ? `0${time.mm}` : time.mm, readOnly: true, onKeyDown: (e) => timeKeyDown(e, increaseMinuts, decreaseMinuts) }), _jsxs("div", { className: styles.buttons, children: [_jsx("span", { className: styles.button, onClick: increaseMinuts, children: _jsx(ArrowBottomIcon, { width: '1.5rem', height: '1.5rem', "data-id": "DOWN_ARROW_MINUTED_TIME_PICKER" }) }), _jsx("span", { className: styles.button, onClick: decreaseMinuts, children: _jsx(ArrowUpIcon, { width: '1.5rem', height: '1.5rem', "data-id": "UP_ARROW_MINUTED_TIME_PICKER" }) })] })] }), _jsxs("div", { className: styles.inputContainer, children: [_jsx("input", { className: `${styles.seconds} ${!isEndDateCorrect || (!isStartDateCorrect && disablePastDays)
451
- ? styles.errorInput
452
- : ''}`, type: "number", "data-id": "SECONDS_TIME_PICKER", value: time.ss < 10 ? `0${time.ss}` : time.ss, readOnly: true, onKeyDown: (e) => timeKeyDown(e, increaseSeconds, decreaseSeconds) }), _jsxs("div", { className: styles.buttons, children: [_jsx("span", { className: styles.button, onClick: increaseSeconds, children: _jsx(ArrowBottomIcon, { width: '1.5rem', height: '1.5rem', "data-id": "DOWN_ARROW_SECONDS_TIME_PICKER" }) }), _jsx("span", { className: styles.button, onClick: decreaseSeconds, children: _jsx(ArrowUpIcon, { width: '1.5rem', height: '1.5rem', "data-id": "UP_ARROW_SECONDS_TIME_PICKER" }) })] })] }), !isEndDateCorrect || (!isStartDateCorrect && disablePastDays) ? (_jsx("span", { className: styles.errorTimeMessage, children: "Invalid Date" })) : null] }), _jsx(Button, { className: styles.submit, variant: "outlined", fullWidth: true, onClick: () => {
453
- submitDate(selectedDate);
454
- }, disabled: !selectedDate || selectedDate === 'Invalid date', onKeyDown: () => (e) => {
455
- if (e.key === 'Enter' || e.key === ' ') {
456
- submitDate(selectedDate);
457
- }
458
- }, children: "Submit" })] }))] }))] })] }));
459
- };
460
- export default Date;
@@ -1 +0,0 @@
1
- export { default } from './Date';