Skip to content

Commit 145ad9c

Browse files
committed
♻️ Refactor date type definitions in examples for improved consistency
Updated various TypeScript type definitions across multiple example files to use `Array<{}>` syntax for better clarity and uniformity. This change enhances code readability and maintains consistency in how date-related types are defined throughout the documentation examples.
1 parent 552f2f0 commit 145ad9c

13 files changed

Lines changed: 32 additions & 29 deletions

docs-site/src/examples/ts/customDayClassName.tsx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
const CustomDayClassName = () => {
22
const [selectedDate, setSelectedDate] = useState<Date | null>(new Date());
33

4+
const getDayClassName = (date: Date): string => {
5+
return date.getDate() === 1 ? "text-success" : "";
6+
};
7+
48
return (
59
<DatePicker
610
selected={selectedDate}
711
onChange={setSelectedDate}
8-
dayClassName={(date: Date) =>
9-
DateFNS.getDate(date) < Math.random() * 31 ? "random" : undefined
10-
}
12+
dayClassName={getDayClassName}
1113
/>
1214
);
1315
};

docs-site/src/examples/ts/excludeDateIntervals.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
type TExcludeDateIntervals = {
1+
type TExcludeDateIntervals = Array<{
22
start: Date;
33
end: Date;
4-
}[];
4+
}>;
55

66
const ExcludeDateIntervals = () => {
77
const [selectedDate, setSelectedDate] = useState<Date | null>(new Date());

docs-site/src/examples/ts/excludeDates.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
type TExcludeDates =
2-
| {
2+
| Array<{
33
date: Date;
44
message?: string;
5-
}[]
6-
| Date[];
5+
}>
6+
| Array<Date>;
77

88
const ExcludeDates = () => {
99
const [selectedDate, setSelectedDate] = useState<Date | null>(new Date());

docs-site/src/examples/ts/excludeDatesMonthPicker.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
type TExcludeDates =
2-
| {
2+
| Array<{
33
date: Date;
44
message?: string;
5-
}[]
6-
| Date[];
5+
}>
6+
| Array<Date>;
77

88
const ExcludeDatesMonthPicker = () => {
99
const [selectedDate, setSelectedDate] = useState<Date | null>(

docs-site/src/examples/ts/excludeDatesRangeMonthPicker.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
type TExcludeDates =
2-
| {
2+
| Array<{
33
date: Date;
44
message?: string;
5-
}[]
6-
| Date[];
5+
}>
6+
| Array<Date>;
77

88
const ExcludeDatesRangeMonthPicker = () => {
99
const defaultStartDate = new Date("2024-08-01");

docs-site/src/examples/ts/excludeDatesWithMessage.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
type TExcludeDates =
2-
| {
2+
| Array<{
33
date: Date;
44
message?: string;
5-
}[]
6-
| Date[];
5+
}>
6+
| Array<Date>;
77

88
const ExcludeDatesWithMessage = () => {
99
const [selectedDate, setSelectedDate] = useState<Date | null>(new Date());

docs-site/src/examples/ts/excludeWeeks.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
type TExcludeDateIntervals = {
1+
type TExcludeDateIntervals = Array<{
22
start: Date | string;
33
end: Date | string;
4-
}[];
4+
}>;
55

66
const ExcludeWeeks = () => {
77
const [selectedDate, setSelectedDate] = useState<Date | null>(

docs-site/src/examples/ts/highlightDates.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ type HighlightDate = {
22
[className: string]: Date[];
33
};
44

5-
type THighlightDates = (Date | HighlightDate)[];
5+
type THighlightDates = Array<Date | HighlightDate>;
66

77
const HighlightDates = () => {
88
const [selectedDate, setSelectedDate] = useState<Date | null>(new Date());

docs-site/src/examples/ts/highlightDatesRanges.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ type HighlightDate = {
33
[className: string]: Date[];
44
};
55

6-
type THighlightDates = (Date | HighlightDate)[];
6+
type THighlightDates = Array<Date | HighlightDate>;
77

88
const HighlightDatesRanges = () => {
99
const [selectedDate, setSelectedDate] = useState<Date | null>(new Date());

docs-site/src/examples/ts/includeDateIntervals.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
const { subDays, addDays } = DateFNS;
2-
type TIncludeDateIntervals = {
2+
type TIncludeDateIntervals = Array<{
33
start: Date;
44
end: Date;
5-
}[];
5+
}>;
66

77
const IncludeDateIntervals = () => {
88
const [selectedDate, setSelectedDate] = useState<Date | null>(null);

0 commit comments

Comments
 (0)