Skip to content

Commit

Permalink
fix(docs): add api references
Browse files Browse the repository at this point in the history
  • Loading branch information
JaeYeopHan committed Jan 24, 2021
1 parent 2ceae94 commit d480fa4
Showing 1 changed file with 65 additions and 0 deletions.
65 changes: 65 additions & 0 deletions docs/src/api-references/useCalendar.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,75 @@ function Component() {

## Options

### [UseCalendarOptions](https://github.com/veccu/react-calendar/blob/main/src/useCalendar.ts#L17)

```ts
export interface UseCalendarOptions {
defaultDate?: Date | number | string
defaultWeekStart?: WeekDayType
defaultViewType?: CalendarViewType
}
```

## Models

### [Return type of useCalendar](https://github.com/veccu/react-calendar/blob/main/src/useCalendar.ts#L121)

```ts

interface ReturnValue extends ReturnType<typeof createCalendarInfo> {
headers: {
weekDays: Array<{ key: string; value: Date }>;
};
body: _MonthViewBody | _WeekViewBody | _DayViewBody;
navigation: {
toNext(): void;
toPrev(): void;
setToday(): void;
setDate(date: Date): void;
};
view: {
type: CalendarViewType;
setViewType(type: CalendarViewType): void;
setWeeksStartsOn(weekDay: WeekDayType): void;
isMonthView: boolean;
isWeekView: boolean;
isDayView: boolean;
showMonthView(): void;
showWeekView(): void;
showDayView(): void;
}
}
```

#### [_MonthViewBody (private)](https://github.com/veccu/react-calendar/blob/main/src/models/Calendar.ts#L9)

```ts
interface MonthViewBody {
value: Array<{
key: string; /* id */
value: Array<{
key: string; /* id */
value: Date;
isCurrentMonth: boolean;
isCurrentDate: boolean;
}>;
}>;
}
```

#### [CalendarViewType](https://github.com/veccu/react-calendar/blob/main/src/models/CalendarViewType.ts)

```ts
enum CalendarViewtype {
Month = 'month',
Week = 'week',
Day = 'day',
}
```

#### [WeekDayType](https://github.com/veccu/react-calendar/blob/main/src/models/WeekDayType.ts)

```ts
type WeekDayType = 0 | 1 | 2 | 3 | 4 | 5 | 6
```

0 comments on commit d480fa4

Please sign in to comment.