-
-
Notifications
You must be signed in to change notification settings - Fork 332
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?
Changes from 7 commits
555a775
4e75254
9bb291b
99a78ed
bd871ce
ca23b8a
187bfbb
515b51c
cf7b088
a8a18ff
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -128,6 +128,8 @@ function Picker<DateType extends object = any>( | |
styles: propStyles, | ||
classNames: propClassNames, | ||
|
||
previewValue, | ||
|
||
// Value | ||
order, | ||
defaultValue, | ||
|
@@ -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') { | ||
setInternalHoverValue(nextValue); | ||
setHoverSource('preset'); | ||
} | ||
}; | ||
|
||
// TODO: handle this | ||
|
@@ -433,8 +437,10 @@ function Picker<DateType extends object = any>( | |
|
||
// ======================== Panel ========================= | ||
const onPanelHover = (date: DateType | null) => { | ||
setInternalHoverValue(date); | ||
setHoverSource('cell'); | ||
if (previewValue === 'hover') { | ||
setInternalHoverValue(date); | ||
setHoverSource('cell'); | ||
} | ||
}; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. onPresetHover 和 onPanelHover 内容几乎一样,是否要合并一下? |
||
|
||
// >>> Focus | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -38,6 +38,16 @@ describe('dayjs: getNow', () => { | |
const M_now = moment().tz(JP); | ||
|
||
expect(D_now.format()).toEqual(M_now.format()); | ||
expect(D_now.get('hour') - D_now.utc().get('hour')).toEqual(9); | ||
|
||
const expectedOffset = M_now.utcOffset() / 60; | ||
const actualOffset = D_now.get('hour') - D_now.utc().get('hour'); | ||
|
||
let normalizedOffset = actualOffset; | ||
if (actualOffset > 12) { | ||
normalizedOffset = actualOffset - 24; | ||
} else if (actualOffset < -12) { | ||
normalizedOffset = actualOffset + 24; | ||
} | ||
expect(normalizedOffset).toEqual(expectedOffset); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 commentThe 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 commentThe reason will be displayed to describe this comment to others. Learn more. 可以单独给 PR,不混在一起。 |
||
}); | ||
}); |
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