Skip to content

Commit

Permalink
chor: compatible with react 18
Browse files Browse the repository at this point in the history
  • Loading branch information
Samsam Ahmadi committed Jan 24, 2023
1 parent 7a989e2 commit eb14f1b
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 25 deletions.
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "react-trip-date",
"version": "1.12.0",
"version": "1.12.1",
"description": "date-picker and range-picker for React applications",
"author": "Samsam Ahmadi",
"license": "GPL-3.0",
Expand All @@ -22,8 +22,8 @@
"datePicker"
],
"peerDependencies": {
"react": "^17.0.1",
"react-dom": "^17.0.1"
"react": "^16.9.0 || ^17 || ^18",
"react-dom": "^16.9.0 || ^17 || ^18"
},
"dependencies": {
"dayjs": "^1.11.7",
Expand Down
4 changes: 2 additions & 2 deletions src/calendar/Calendar.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { Dayjs } from "dayjs";
import { ReactElement } from "react";
import { FC, ReactElement } from "react";
import { createCalendar } from "libs/createCalendar";
import { dayjs } from "libs/dayjs-config";
import { sliceDaysOfMonthToWeeks } from "libs/sliceDaysOfMonthToWeeks";

import { CalendarProps } from "./calendar.type";

export const Calendar: React.FC<CalendarProps> = ({
export const Calendar: FC<CalendarProps> = ({
jalali,
startOfWeek = 1,
children,
Expand Down
16 changes: 8 additions & 8 deletions src/components/TitleOfWeek.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import styled from "styled-components";
import { ElementType } from "react";
import { ElementType, FC } from "react";

type Props = {
jalali: boolean;
Expand All @@ -10,11 +10,7 @@ type Props = {
};
};

export const TitleOfWeek: React.FunctionComponent<Props> = ({
jalali,
startOfWeek,
components,
}) => {
export const TitleOfWeek: FC<Props> = ({ jalali, startOfWeek, components }) => {
let titles = ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"];
if (components?.titles) titles = [...components?.titles];
else if (jalali) titles = ["ش", "ی", "د", "س", "چ", "پ", "ج"];
Expand All @@ -25,12 +21,16 @@ export const TitleOfWeek: React.FunctionComponent<Props> = ({
}

if (components?.wrapper) {
const WrapperC = components?.wrapper;
const WrapperC = components.wrapper;
return <WrapperC jalali={jalali} startOfWeek={startOfWeek} />;
}

return (
<Wrapper className="tp-calendar-week-titles" jalali={jalali} startOfWeek={startOfWeek}>
<Wrapper
className="tp-calendar-week-titles"
jalali={jalali}
startOfWeek={startOfWeek}
>
{titles.map(item => (
<p key={item}>{item}</p>
))}
Expand Down
28 changes: 16 additions & 12 deletions src/datePicker/Day.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import styled from "styled-components";
import { Dayjs } from "dayjs";
import { Dispatch, SetStateAction } from "react";
import { Dispatch, FC, SetStateAction } from "react";
import { FORMAT_DATE } from "constant";
import { classNames } from "libs/classNames";
import { dayjs } from "libs/dayjs-config";
Expand All @@ -26,7 +26,7 @@ type Props = {
dayClasses?: (day: Dayjs) => string[];
};

export const Day: React.FC<Props> = ({
export const Day: FC<Props> = ({
day,
jalali,
source,
Expand Down Expand Up @@ -144,16 +144,20 @@ export const Day: React.FC<Props> = ({
<Wrapper
data-test={day.format(FORMAT_DATE)}
onClick={handleClick}
className={classNames({
inactive: day.month() !== source.add(numberOfMonth, "month").month(),
selected: handleSelectedDate(),
disabled: handleDisabledDate(),
disable: disabled,
today:
dayjs()
.calendar(jalali ? "jalali" : "gregory")
.format(FORMAT_DATE) === day.format(FORMAT_DATE),
}, extraDayClasses, "tp-calendar-day")}
className={classNames(
{
inactive: day.month() !== source.add(numberOfMonth, "month").month(),
selected: handleSelectedDate(),
disabled: handleDisabledDate(),
disable: disabled,
today:
dayjs()
.calendar(jalali ? "jalali" : "gregory")
.format(FORMAT_DATE) === day.format(FORMAT_DATE),
},
extraDayClasses,
"tp-calendar-day",
)}
>
{DayComponent && (
<DayComponent day={day.format(FORMAT_DATE)} jalali={jalali} />
Expand Down

0 comments on commit eb14f1b

Please sign in to comment.