From 38457fbcff505365ddc74fd0d8122a7a922c0da1 Mon Sep 17 00:00:00 2001 From: Sergey Krylov Date: Tue, 21 May 2024 06:50:44 +0300 Subject: [PATCH] feat(CalendarWidget): add custom DateCell prop --- .../CalendarWidget/ui/CalendarWidget.ui.tsx | 2 ++ .../ui/components/DateCell/index.ts | 1 + .../ui/components/DateCell/ui/DateCell.ui.tsx | 15 ++++++++++++++- 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/src/widgets/CalendarWidget/ui/CalendarWidget.ui.tsx b/src/widgets/CalendarWidget/ui/CalendarWidget.ui.tsx index 234e846..44b38c9 100644 --- a/src/widgets/CalendarWidget/ui/CalendarWidget.ui.tsx +++ b/src/widgets/CalendarWidget/ui/CalendarWidget.ui.tsx @@ -6,6 +6,7 @@ import { DateWrapper } from './components/DateWrapper'; import { DayOfWeekRow } from './components/DayOfWeekRow'; import { HeaderRow } from './components/HeaderRow'; +import type { DateCellProps } from './components/DateCell'; import type { FC, HTMLAttributes } from 'react'; type DateCellPropsType = HTMLAttributes; @@ -20,6 +21,7 @@ export type CalendarWidgetProps = { highlightValue?: boolean; DateCellProps?: DateCellPropsFuncType | DateCellPropsType; + DateCellComponent?: FC; }; const CalendarWidget: FC = (props) => ( diff --git a/src/widgets/CalendarWidget/ui/components/DateCell/index.ts b/src/widgets/CalendarWidget/ui/components/DateCell/index.ts index ab0a98b..e4cac5a 100644 --- a/src/widgets/CalendarWidget/ui/components/DateCell/index.ts +++ b/src/widgets/CalendarWidget/ui/components/DateCell/index.ts @@ -1 +1,2 @@ export { default as DateCell } from './ui/DateCell.ui'; +export type { DateCellProps } from './ui/DateCell.ui'; diff --git a/src/widgets/CalendarWidget/ui/components/DateCell/ui/DateCell.ui.tsx b/src/widgets/CalendarWidget/ui/components/DateCell/ui/DateCell.ui.tsx index a12aaaa..8992c73 100644 --- a/src/widgets/CalendarWidget/ui/components/DateCell/ui/DateCell.ui.tsx +++ b/src/widgets/CalendarWidget/ui/components/DateCell/ui/DateCell.ui.tsx @@ -9,7 +9,7 @@ import classes from './DateCell.style.module.css'; import type { FC, MouseEventHandler, KeyboardEventHandler } from 'react'; -type DateCellProps = React.HTMLAttributes & { +export type DateCellProps = React.HTMLAttributes & { date: Date; }; const DateCell: FC = (props) => { @@ -23,6 +23,7 @@ const DateCell: FC = (props) => { highlightToday, highlightValue, DateCellProps = {}, + DateCellComponent, } = useContext(CalendarWidgetContext); const todayDate = new Date(); @@ -53,6 +54,18 @@ const DateCell: FC = (props) => { onKeyPress?.(event); }; + if (DateCellComponent) { + return ( + + ); + } + return (