-
Notifications
You must be signed in to change notification settings - Fork 2.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(CalendarPickerView): add renderTop and renderBottom hide logic #6735
feat(CalendarPickerView): add renderTop and renderBottom hide logic #6735
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #6735 +/- ##
==========================================
+ Coverage 92.68% 92.70% +0.02%
==========================================
Files 334 335 +1
Lines 7191 7199 +8
Branches 1795 1767 -28
==========================================
+ Hits 6665 6674 +9
Misses 517 517
+ Partials 9 8 -1 ☔ View full report in Codecov by Sentry. |
PR preview has been successfully built and deployed to https://antd-mobile-preview-pr-6735.surge.sh |
@@ -21,8 +21,8 @@ Only the simplest content area is shown here, and other more usages can be consu | |||
| max | Maximum value of a selectable range. | `Date` | - | | |||
| min | Minimum value of a selectable range. | `Date` | - | - | | |||
| onChange | Trigger when selected date changes. | `(val: Date \| null) => void` when selection mode is "single". `(val: [Date, Date] \| null) => void` when selection mode is "range". | - | | |||
| renderTop | The top information of date render function. | `(date: Date) => ReactNode \| null \| undefined` | - | | |||
| renderBottom | The bottom information of date render function. | `(date: Date) => ReactNode \| null \| undefined` | - | | |||
| renderTop | The top information of date render function. | `((date: Date) => ReactNode \| null \| undefined) \| false` | - | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@@ -44,9 +44,9 @@ export type CalendarPickerViewProps = { | |||
title?: React.ReactNode | false | |||
confirmText?: string | |||
weekStartsOn?: 'Monday' | 'Sunday' | |||
renderTop?: (date: Date) => React.ReactNode | |||
renderTop?: ((date: Date) => React.ReactNode) | false |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
加一下对应的测试用例
@@ -243,6 +245,8 @@ export const CalendarPickerView = forwardRef< | |||
(minDay && d.isBefore(minDay, 'day')) | |||
|
|||
const renderTop = () => { | |||
if (props.renderTop === false) return |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这个逻辑看起来没有用?下面的代码里已经写了
if (props.renderXXX === false) return
所有 renderXXX 走到的地方其实已经都判断过了
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
renderXXX 类型为 function | false
这里如果不把 boolean 过滤掉 ts 会报错, 所以才加上的
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
那可以考虑调整一下代码结构,也不需要这个 renderTop
函数了,直接内联写。
259489c
to
5866c28
Compare
cd6bc4a
to
b839f9d
Compare
增加 renderTop 和 renderBottom false 隐藏