diff --git a/src/components/calendar/calendar.tsx b/src/components/calendar/calendar.tsx index 65aa6587..ba2e89f6 100644 --- a/src/components/calendar/calendar.tsx +++ b/src/components/calendar/calendar.tsx @@ -1,6 +1,6 @@ import cn from 'classnames'; import React, { Fragment, SyntheticEvent, useEffect, useRef } from 'react'; -import { Ref, Segment } from 'semantic-ui-react'; +import * as SemanticUiReact from 'semantic-ui-react'; import { Locale, RenderProps, SemanticDatepickerProps } from 'types'; import { getShortDate, getToday } from '../../utils'; import Button from '../button'; @@ -78,147 +78,153 @@ const Calendar: React.FC = ({ } }); - return ( - - +
-
- {calendars.map((calendar, calendarIdx) => ( -
-
-
- {calendarIdx === 0 && ( - -
+ {calendars.map((calendar, calendarIdx) => ( +
+
+
+ {calendarIdx === 0 && ( + +
- - {months[calendar.month].slice(0, 3)} {calendar.year} - + + {months[calendar.month].slice(0, 3)} {calendar.year} + -
- {calendarIdx === calendars.length - 1 && ( - -
+
+ {calendarIdx === calendars.length - 1 && ( + +
-
- {weekdays.map((weekday) => ( - - {weekday.slice(0, 2)} - - ))} - {calendar.weeks.map((week) => - week.map((dateObj, weekIdx) => { - const key = `${calendar.year}-${calendar.month}-${weekIdx}`; +
+
+ {weekdays.map((weekday) => ( + + {weekday.slice(0, 2)} + + ))} + {calendar.weeks.map((week) => + week.map((dateObj, weekIdx) => { + const key = `${calendar.year}-${calendar.month}-${weekIdx}`; - if (!dateObj) { - return ; - } + if (!dateObj) { + return ; + } - const selectable = - dateObj.selectable && filterDate(dateObj.date); - const shortDate = getShortDate(dateObj.date); + const selectable = + dateObj.selectable && filterDate(dateObj.date); + const shortDate = getShortDate(dateObj.date); - return ( - - {dateObj.date.getDate()} - - ); - }) - )} -
+ return ( + + {dateObj.date.getDate()} + + ); + }) + )}
- ))} -
- {showToday ? ( - - {todayButton} - - ) : null} - - +
+ ))} +
+ {showToday ? ( + + {todayButton} + + ) : null} + + ); + return SemanticUiReact.Ref ? ( + + {calendarInstance} + + ) : ( + calendarInstance ); }; diff --git a/stories/data.ts b/stories/data.ts index 889835bc..bc9f2e7d 100644 --- a/stories/data.ts +++ b/stories/data.ts @@ -33,7 +33,7 @@ const locale = [ function arrayToMap( arr: readonly T[] -): { [key in typeof arr[number]]: typeof arr[number] } { +): { [key in (typeof arr)[number]]: (typeof arr)[number] } { return arr.reduce( (acc, cur) => ({ ...acc, [cur]: cur }), {} as { [key in T]: T }