gbs-add-block 0.0.33 → 0.0.34
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/package.json
CHANGED
|
@@ -17,7 +17,7 @@ export const DatePicker = ({
|
|
|
17
17
|
minDate = null,
|
|
18
18
|
maxDate = null,
|
|
19
19
|
yearLimitStart = 50,
|
|
20
|
-
yearLimitEnd =
|
|
20
|
+
yearLimitEnd = 0,
|
|
21
21
|
onDateChange,
|
|
22
22
|
}: DatePickerProps) => {
|
|
23
23
|
const [showDatepicker, setShowDatepicker] = useState(false);
|
|
@@ -36,6 +36,12 @@ export const DatePicker = ({
|
|
|
36
36
|
const dateRef = useRef<HTMLDivElement>(null);
|
|
37
37
|
const today = new Date();
|
|
38
38
|
|
|
39
|
+
const actualCurrentYear = today.getFullYear();
|
|
40
|
+
const years = Array.from(
|
|
41
|
+
{ length: yearLimitStart + yearLimitEnd + 1 },
|
|
42
|
+
(_, i) => actualCurrentYear - yearLimitStart + i
|
|
43
|
+
).sort((a, b) => b - a);
|
|
44
|
+
|
|
39
45
|
useEffect(() => {
|
|
40
46
|
if (selectedDateValue) {
|
|
41
47
|
setSelectedDate(selectedDateValue);
|
|
@@ -44,13 +50,10 @@ export const DatePicker = ({
|
|
|
44
50
|
}
|
|
45
51
|
}, [selectedDateValue]);
|
|
46
52
|
|
|
47
|
-
// This useEffect will ensure the server and client
|
|
48
|
-
// rendererd date will not mismatch
|
|
49
53
|
useEffect(() => {
|
|
50
54
|
setHasMounted(true);
|
|
51
55
|
}, []);
|
|
52
56
|
|
|
53
|
-
// This will helps to close the popup when clicked outside of datepicker component
|
|
54
57
|
useEffect(() => {
|
|
55
58
|
function handleClickOutside(event: MouseEvent) {
|
|
56
59
|
if (dateRef.current && !dateRef.current.contains(event.target as Node)) {
|
|
@@ -68,13 +71,11 @@ export const DatePicker = ({
|
|
|
68
71
|
setDays(generateCalendarHelper(currentYear, currentMonth));
|
|
69
72
|
}, [currentYear, currentMonth]);
|
|
70
73
|
|
|
71
|
-
// DatePicker Toggler
|
|
72
74
|
const toggleDatepicker = () => {
|
|
73
75
|
setShowDatepicker(!showDatepicker);
|
|
74
76
|
setShowYearMonthPicker(false);
|
|
75
77
|
};
|
|
76
78
|
|
|
77
|
-
// YearMonthPicker Toggler
|
|
78
79
|
const toggleYearMonthPicker = () => {
|
|
79
80
|
setShowYearMonthPicker(!showYearMonthPicker);
|
|
80
81
|
};
|
|
@@ -93,7 +94,6 @@ export const DatePicker = ({
|
|
|
93
94
|
setDays(generateCalendarHelper(year, month));
|
|
94
95
|
};
|
|
95
96
|
|
|
96
|
-
// *** DatePicker navigation starts here
|
|
97
97
|
const prevMonth = () => {
|
|
98
98
|
if (currentMonth === 0) {
|
|
99
99
|
setCurrentMonth(11);
|
|
@@ -118,12 +118,6 @@ export const DatePicker = ({
|
|
|
118
118
|
setSelectedDate(new Date());
|
|
119
119
|
if (onDateChange) onDateChange(new Date());
|
|
120
120
|
};
|
|
121
|
-
// DatePicker navigation ends here ***
|
|
122
|
-
|
|
123
|
-
const years = Array.from(
|
|
124
|
-
{ length: yearLimitEnd },
|
|
125
|
-
(_, i) => currentYear - yearLimitStart + i
|
|
126
|
-
);
|
|
127
121
|
|
|
128
122
|
if (!hasMounted) {
|
|
129
123
|
return null;
|
|
@@ -137,9 +131,9 @@ export const DatePicker = ({
|
|
|
137
131
|
className="border p-2 rounded w-full flex items-center gap-2 dark:text-white"
|
|
138
132
|
>
|
|
139
133
|
<Icon
|
|
140
|
-
dimensions={{ width: "
|
|
134
|
+
dimensions={{ width: "20", height: "20" }}
|
|
141
135
|
elements={calender}
|
|
142
|
-
svgClass={"stroke-
|
|
136
|
+
svgClass={"stroke-gray-500 fill-none dark:stroke-white"}
|
|
143
137
|
/>
|
|
144
138
|
|
|
145
139
|
{showPlaceHolder ? showPlaceHolder : selectedDate.toLocaleDateString()}
|