-
-
Notifications
You must be signed in to change notification settings - Fork 331
feat: add previewValue option #934
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
base: master
Are you sure you want to change the base?
feat: add previewValue option #934
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
Walkthrough为 Picker/RangePicker 新增可选属性 previewValue('hover' 或 false,默认 'hover'),用以控制悬浮时是否预览输入值。更新了类型与默认填充逻辑、组件悬浮处理分支、文档与示例,并添加对应测试用例。 Changes
Sequence Diagram(s)sequenceDiagram
participant U as 用户
participant P as Picker/RangePicker
participant S as 内部状态
U->>P: 悬浮单元格或预设
P->>P: 检查 previewValue
alt previewValue == 'hover'
P->>S: 更新 internal hover value
S-->>P: 返回预览值
P-->>U: 输入框显示预览
else previewValue == false
P-->>U: 忽略悬浮(不预览)
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~18 minutes Assessment against linked issues
Suggested reviewers
Poem
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (2)
✨ Finishing Touches
🧪 Generate unit tests
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. CodeRabbit Commands (Invoked using PR/Issue comments)Type Other keywords and placeholders
CodeRabbit Configuration File (
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #934 +/- ##
=======================================
Coverage 98.80% 98.80%
=======================================
Files 65 65
Lines 2669 2676 +7
Branches 742 745 +3
=======================================
+ Hits 2637 2644 +7
Misses 29 29
Partials 3 3 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
src/PickerInput/SinglePicker.tsx
Outdated
@@ -433,7 +435,9 @@ function Picker<DateType extends object = any>( | |||
|
|||
// ======================== Panel ========================= | |||
const onPanelHover = (date: DateType | null) => { | |||
setInternalHoverValue(date); | |||
if (showPreviewValue) { |
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.
showHoverValue 如何?
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.
showHoverValue 如何?
类 Select 组件之后也可以支持一下这个功能
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.
突然想到,是否可以 previewValue={(info: { date }) => xxxx} |
tests/generateWithTZ.spec.tsx
Outdated
} else if (actualOffset < -12) { | ||
normalizedOffset = actualOffset + 24; | ||
} | ||
expect(normalizedOffset).toEqual(expectedOffset); |
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.
preview 里为啥要改这个测试用例?
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.
这个单测写的有问题
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.
可以单独给 PR,不混在一起。
src/PickerInput/RangePicker.tsx
Outdated
setInternalHoverValues(date ? fillCalendarValue(date, activeIndex) : null); | ||
if (previewValue === 'hover') { | ||
setInternalHoverValues(date ? fillCalendarValue(date, activeIndex) : null); | ||
} | ||
setHoverSource('cell'); |
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.
setHoverSource 是否也不需要运行。
src/PickerInput/SinglePicker.tsx
Outdated
@@ -413,8 +415,10 @@ function Picker<DateType extends object = any>( | |||
const presetList = usePresets(presets); | |||
|
|||
const onPresetHover = (nextValue: DateType | null) => { | |||
setInternalHoverValue(nextValue); | |||
setHoverSource('preset'); | |||
if (previewValue === 'hover') { |
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.
反过来,不等于的时候提前 return
if (previewValue === 'hover') { | ||
setInternalHoverValue(date); | ||
setHoverSource('cell'); | ||
} | ||
}; |
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.
onPresetHover 和 onPanelHover 内容几乎一样,是否要合并一下?
8dfd0b3
to
515b51c
Compare
@afc163 都已修改 |
中文版模板 / Chinese template
🤔 This is a ...
🔗 Related Issues
💡 Background and Solution
📝 Change Log
Summary by CodeRabbit