Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs-site/src/examples/ts/calendarContainer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const CustomCalendarContainer = () => {
return (
<DatePicker
selected={selectedDate}
onChange={(date: Date | null) => setSelectedDate(date)}
onChange={setSelectedDate}
calendarContainer={MyContainer}
/>
);
Expand Down
6 changes: 1 addition & 5 deletions docs-site/src/examples/ts/calendarIcon.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,7 @@ const CalendarIcon = () => {
const [selectedDate, setSelectedDate] = useState<Date | null>(new Date());

return (
<DatePicker
showIcon
selected={selectedDate}
onChange={(date: Date | null) => setSelectedDate(date)}
/>
<DatePicker showIcon selected={selectedDate} onChange={setSelectedDate} />
);
};

Expand Down
2 changes: 1 addition & 1 deletion docs-site/src/examples/ts/calendarIconExternal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const CalendarIconExternal = () => {
<DatePicker
showIcon
selected={selectedDate}
onChange={(date: Date | null) => setSelectedDate(date)}
onChange={setSelectedDate}
icon="fa fa-calendar"
/>
);
Expand Down
2 changes: 1 addition & 1 deletion docs-site/src/examples/ts/calendarIconSvgIcon.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const CalendarIconSvgIcon = () => {
<DatePicker
showIcon
selected={selectedDate}
onChange={(date: Date | null) => setSelectedDate(date)}
onChange={setSelectedDate}
icon={
<svg
xmlns="http://www.w3.org/2000/svg"
Expand Down
2 changes: 1 addition & 1 deletion docs-site/src/examples/ts/calendarStartDay.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const CalendarStartDay = () => {
return (
<DatePicker
selected={selectedDate}
onChange={(date: Date | null) => setSelectedDate(date)}
onChange={setSelectedDate}
calendarStartDay={3}
/>
);
Expand Down
5 changes: 1 addition & 4 deletions docs-site/src/examples/ts/children.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,7 @@ const Children = () => {
const [selectedDate, setSelectedDate] = useState<Date | null>(new Date());

return (
<DatePicker
selected={selectedDate}
onChange={(date: Date | null) => setSelectedDate(date)}
>
<DatePicker selected={selectedDate} onChange={setSelectedDate}>
<div style={{ color: "red" }}>Don't forget to check the weather!</div>
</DatePicker>
);
Expand Down
2 changes: 1 addition & 1 deletion docs-site/src/examples/ts/clearInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const ClearInput = () => {
return (
<DatePicker
selected={selectedDate}
onChange={(date: Date | null) => setSelectedDate(date)}
onChange={setSelectedDate}
isClearable
placeholderText="I have been cleared!"
/>
Expand Down
2 changes: 1 addition & 1 deletion docs-site/src/examples/ts/closeOnScroll.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const CloseOnScroll = () => {
<DatePicker
closeOnScroll
selected={selectedDate}
onChange={(date: Date | null) => setSelectedDate(date)}
onChange={setSelectedDate}
/>
);
};
Expand Down
2 changes: 1 addition & 1 deletion docs-site/src/examples/ts/closeOnScrollCallback.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const CloseOnScrollCallback = () => {
<DatePicker
closeOnScroll={(e: Event): boolean => e.target === document}
selected={selectedDate}
onChange={(date: Date | null) => setSelectedDate(date)}
onChange={setSelectedDate}
/>
);
};
Expand Down
2 changes: 1 addition & 1 deletion docs-site/src/examples/ts/configureFloatingUI.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const ConfigureFloatingUI = () => {
return (
<DatePicker
selected={selectedDate}
onChange={(date: Date | null) => setSelectedDate(date)}
onChange={setSelectedDate}
popperClassName="some-custom-class"
popperPlacement="top-end"
popperModifiers={[
Expand Down
2 changes: 1 addition & 1 deletion docs-site/src/examples/ts/customCalendarClassName.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const CustomCalendarClassName = () => {
return (
<DatePicker
selected={selectedDate}
onChange={(date: Date | null) => setSelectedDate(date)}
onChange={setSelectedDate}
calendarClassName="rasta-stripes"
/>
);
Expand Down
2 changes: 1 addition & 1 deletion docs-site/src/examples/ts/customClassName.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const CustomClassName = () => {
return (
<DatePicker
selected={selectedDate}
onChange={(date: Date | null) => setSelectedDate(date)}
onChange={setSelectedDate}
className="red-border"
/>
);
Expand Down
2 changes: 1 addition & 1 deletion docs-site/src/examples/ts/customDateFormat.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const CustomDateFormat = () => {
<DatePicker
dateFormat="yyyy/MM/dd"
selected={selectedDate}
onChange={(date: Date | null) => setSelectedDate(date)}
onChange={setSelectedDate}
/>
);
};
Expand Down
10 changes: 6 additions & 4 deletions docs-site/src/examples/ts/customDayClassName.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
const CustomDayClassName = () => {
const [selectedDate, setSelectedDate] = useState<Date | null>(new Date());

const getDayClassName = (date: Date): string => {
return date.getDate() === 1 ? "text-success" : "";
};

return (
<DatePicker
selected={selectedDate}
onChange={(date: Date | null) => setSelectedDate(date)}
dayClassName={(date: Date) =>
DateFNS.getDate(date) < Math.random() * 31 ? "random" : undefined
}
onChange={setSelectedDate}
dayClassName={getDayClassName}
/>
);
};
Expand Down
21 changes: 11 additions & 10 deletions docs-site/src/examples/ts/customInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,23 @@ type ExampleCustomInputProps = {
onClick?: () => void;
};

const ExampleCustomInput = forwardRef<
HTMLButtonElement,
ExampleCustomInputProps
>(({ value, onClick, className }, ref) => (
<button type="button" className={className} onClick={onClick} ref={ref}>
{value}
</button>
));
ExampleCustomInput.displayName = "ExampleCustomInput";

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

const ExampleCustomInput = forwardRef<
HTMLButtonElement,
ExampleCustomInputProps
>(({ value, onClick, className }, ref) => (
<button className={className} onClick={onClick} ref={ref}>
{value}
</button>
));

return (
<DatePicker
selected={selectedDate}
onChange={(date: Date | null) => setSelectedDate(date)}
onChange={setSelectedDate}
customInput={<ExampleCustomInput className="example-custom-input" />}
/>
);
Expand Down
2 changes: 1 addition & 1 deletion docs-site/src/examples/ts/customTimeClassName.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const CustomTimeClassName = () => {
<DatePicker
showTimeSelect
selected={selectedDateTime}
onChange={(date: Date | null) => setSelectedDateTime(date)}
onChange={setSelectedDateTime}
timeClassName={handleColor}
/>
);
Expand Down
2 changes: 1 addition & 1 deletion docs-site/src/examples/ts/customTimeInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ const CustomTimeInput = () => {
return (
<DatePicker
selected={selectedDateTime}
onChange={(date: Date | null) => setSelectedDateTime(date)}
onChange={setSelectedDateTime}
showTimeInput
customTimeInput={<ExampleCustomTimeInput />}
/>
Expand Down
4 changes: 2 additions & 2 deletions docs-site/src/examples/ts/dateRange.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@ const DateRange = () => {
<>
<DatePicker
selected={selectedDate}
onChange={(date: Date | null) => setStartDate(date)}
onChange={setStartDate}
selectsStart
startDate={selectedDate}
endDate={endDate}
/>
<DatePicker
selected={endDate}
onChange={(date: Date | null) => setEndDate(date)}
onChange={setEndDate}
selectsEnd
startDate={selectedDate}
endDate={endDate}
Expand Down
4 changes: 1 addition & 3 deletions docs-site/src/examples/ts/dateRangeInputWithClearButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,7 @@ const DateRangeInputWithClearButton = () => {
<DatePicker
startDate={startDate}
endDate={endDate}
onChange={(update: [Date | null, Date | null]) => {
setDateRange(update);
}}
onChange={setDateRange}
selectsRange
isClearable
/>
Expand Down
4 changes: 1 addition & 3 deletions docs-site/src/examples/ts/dateRangeWithPortal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,7 @@ const DateRangeWithPortal = () => {
<DatePicker
startDate={startDate}
endDate={endDate}
onChange={(update: [Date | null, Date | null]) => {
setDateRange(update);
}}
onChange={setDateRange}
selectsRange
withPortal
/>
Expand Down
11 changes: 5 additions & 6 deletions docs-site/src/examples/ts/default.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
const Default = () => {
const [selectedDate, setSelectedDate] = useState<Date | null>(new Date());

return (
<DatePicker
selected={selectedDate}
onChange={(date: Date | null) => setSelectedDate(date)}
/>
);
const handleChange = (date: Date | null) => {
setSelectedDate(date);
};

return <DatePicker selected={selectedDate} onChange={handleChange} />;
};

render(Default);
2 changes: 1 addition & 1 deletion docs-site/src/examples/ts/disabled.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const Disabled = () => {
return (
<DatePicker
selected={selectedDate}
onChange={(date: Date | null) => setSelectedDate(date)}
onChange={setSelectedDate}
disabled
placeholderText="This is disabled"
/>
Expand Down
2 changes: 1 addition & 1 deletion docs-site/src/examples/ts/disabledInline.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const DisabledInline = () => {
return (
<DatePicker
selected={selectedDate}
onChange={(date: Date | null) => setSelectedDate(date)}
onChange={setSelectedDate}
disabled
inline
/>
Expand Down
2 changes: 1 addition & 1 deletion docs-site/src/examples/ts/disabledKeyboardNavigation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const DisabledKeyboardNavigation = () => {
return (
<DatePicker
selected={selectedDate}
onChange={(date: Date | null) => setSelectedDate(date)}
onChange={setSelectedDate}
disabledKeyboardNavigation
placeholderText="This has disabled keyboard navigation"
/>
Expand Down
2 changes: 1 addition & 1 deletion docs-site/src/examples/ts/dontCloseOnSelect.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const DontCloseOnSelect = () => {
return (
<DatePicker
selected={selectedDate}
onChange={(date: Date | null) => setSelectedDate(date)}
onChange={setSelectedDate}
shouldCloseOnSelect={false}
/>
);
Expand Down
6 changes: 3 additions & 3 deletions docs-site/src/examples/ts/excludeDateIntervals.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
type TExcludeDateIntervals = {
type TExcludeDateIntervals = Array<{
start: Date;
end: Date;
}[];
}>;

const ExcludeDateIntervals = () => {
const [selectedDate, setSelectedDate] = useState<Date | null>(new Date());
Expand All @@ -16,7 +16,7 @@ const ExcludeDateIntervals = () => {
return (
<DatePicker
selected={selectedDate}
onChange={(date: Date | null) => setSelectedDate(date)}
onChange={setSelectedDate}
excludeDateIntervals={excludeDateIntervals}
placeholderText="Select a date other than the interval from 5 days ago to 5 days in the future"
/>
Expand Down
8 changes: 4 additions & 4 deletions docs-site/src/examples/ts/excludeDates.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
type TExcludeDates =
| {
| Array<{
date: Date;
message?: string;
}[]
| Date[];
}>
| Array<Date>;

const ExcludeDates = () => {
const [selectedDate, setSelectedDate] = useState<Date | null>(new Date());
Expand All @@ -16,7 +16,7 @@ const ExcludeDates = () => {
return (
<DatePicker
selected={selectedDate}
onChange={(date: Date | null) => setSelectedDate(date)}
onChange={setSelectedDate}
excludeDates={excludeDates}
placeholderText="Select a date other than today or yesterday"
/>
Expand Down
8 changes: 4 additions & 4 deletions docs-site/src/examples/ts/excludeDatesMonthPicker.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
type TExcludeDates =
| {
| Array<{
date: Date;
message?: string;
}[]
| Date[];
}>
| Array<Date>;

const ExcludeDatesMonthPicker = () => {
const [selectedDate, setSelectedDate] = useState<Date | null>(
Expand All @@ -18,7 +18,7 @@ const ExcludeDatesMonthPicker = () => {
return (
<DatePicker
selected={selectedDate}
onChange={(date: Date | null) => setSelectedDate(date)}
onChange={setSelectedDate}
dateFormat="MM/yyyy"
excludeDates={excludeDates}
showMonthYearPicker
Expand Down
6 changes: 3 additions & 3 deletions docs-site/src/examples/ts/excludeDatesRangeMonthPicker.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
type TExcludeDates =
| {
| Array<{
date: Date;
message?: string;
}[]
| Date[];
}>
| Array<Date>;

const ExcludeDatesRangeMonthPicker = () => {
const defaultStartDate = new Date("2024-08-01");
Expand Down
8 changes: 4 additions & 4 deletions docs-site/src/examples/ts/excludeDatesWithMessage.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
type TExcludeDates =
| {
| Array<{
date: Date;
message?: string;
}[]
| Date[];
}>
| Array<Date>;

const ExcludeDatesWithMessage = () => {
const [selectedDate, setSelectedDate] = useState<Date | null>(new Date());
Expand All @@ -16,7 +16,7 @@ const ExcludeDatesWithMessage = () => {
return (
<DatePicker
selected={selectedDate}
onChange={(date: Date | null) => setSelectedDate(date)}
onChange={setSelectedDate}
excludeDates={excludeDates}
placeholderText="Select a date other than today or yesterday"
/>
Expand Down
2 changes: 1 addition & 1 deletion docs-site/src/examples/ts/excludeTimePeriod.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const ExcludeTimePeriod = () => {
return (
<DatePicker
selected={selectedDateTime}
onChange={(date: Date | null) => setSelectedDateTime(date)}
onChange={setSelectedDateTime}
showTimeSelect
minTime={setHours(setMinutes(new Date(), 0), 17)}
maxTime={setHours(setMinutes(new Date(), 30), 20)}
Expand Down
Loading
Loading